diff options
Diffstat (limited to 'configmgr/source/api2')
66 files changed, 0 insertions, 18622 deletions
diff --git a/configmgr/source/api2/accessimpl.cxx b/configmgr/source/api2/accessimpl.cxx deleted file mode 100644 index 4b8936129b1a..000000000000 --- a/configmgr/source/api2/accessimpl.cxx +++ /dev/null @@ -1,804 +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 "accessimpl.hxx" -#include "apinodeaccess.hxx" -#include "valueref.hxx" -#include "anynoderef.hxx" -#include "noderef.hxx" -#include "configset.hxx" -#include "confignotifier.hxx" -#include "propertyinfohelper.hxx" -#include "treeiterators.hxx" -#include "attributes.hxx" -#include "apitypes.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/lang/WrappedTargetException.hpp> -#include <com/sun/star/beans/PropertyVetoException.hpp> -#include <osl/diagnose.h> -#include <rtl/logfile.hxx> - -#define RTL_LOGFILE_OU2A(rtlOUString) (::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr()) - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------------- - namespace lang = css::lang; - namespace util = css::util; - -//----------------------------------------------------------------------------------- -// Constructors -//----------------------------------------------------------------------------------- - -// Interface methods -//----------------------------------------------------------------------------------- - - -// XHierarchicalName -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString implGetHierarchicalName( NodeAccess& rNode ) throw(uno::RuntimeException) -{ - // RTL_LOGFILE_CONTEXT(aLog, "Configmgr::API::implGetHierarchicalName()"); - - rtl::OUString sRet; - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree()); - - configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(lock.getNode()); - sRet = aFullPath.toString(); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return sRet; -} - -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const rtl::OUString& sRelativeName ) - throw(css::lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException) -{ - rtl::OUString sRet; - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - configuration::NodeRef aNode( lock.getNode() ); - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - - configuration::RelativePath const aAddedPath = configuration::validateRelativePath(sRelativeName, aTree, aNode); - - // TODO: add (relative) name validation based on node type - may then need provider lock - configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(aNode).compose(aAddedPath); - - sRet = aFullPath.toString(); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(1); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - - return sRet; -} - -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const rtl::OUString& sElementName ) - throw(css::lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException) -{ - rtl::OUString sRet; - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - configuration::NodeRef aNode( lock.getNode() ); - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - - configuration::Path::Component const aAddedName = configuration::validateElementPathComponent(sElementName, aTree, aNode); - - // TODO: add (relative) name validation based on node type - may then need provider lock - configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(aNode).compose(aAddedName); - - sRet = aFullPath.toString(); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(1); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - - return sRet; -} - -//------------------------------------------------------------------------------------------------------------------ - -// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? ) -//----------------------------------------------------------------------------------- - - -//----------------------------------------------------------------------------------- -// for group nodes -uno::Type implGetElementType(NodeGroupInfoAccess& rNode) throw(uno::RuntimeException) -{ - rNode.checkAlive(); - // group nodes have a mix of types - // TODO(?): Discover single common type - return ::getCppuType( static_cast< uno::Any const*>(0) ); -} - -// for set nodes -uno::Type implGetElementType(NodeSetInfoAccess& rNode) throw(uno::RuntimeException) -{ - uno::Type aRet; - try - { - GuardedNodeData<NodeSetInfoAccess> lock( rNode ); - - aRet = rNode.getElementInfo()->getInstanceType(); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - return aRet; -} - -//----------------------------------------------------------------------------------- -// for group nodes -sal_Bool implHasElements(NodeGroupInfoAccess& rNode) throw(uno::RuntimeException) -{ - // rNode.checkAlive(); -// return true; // group nodes always have children - -// Better: cater for the case where we are reaching the depth limit - try - { - GuardedNodeData<NodeAccess> lock( rNode ); // no provider lock needed - - rtl::Reference< configuration::Tree > aThisTree( lock.getTree() ); - configuration::NodeRef aThisNode( lock.getNode() ); - OSL_ASSERT( !aThisTree->hasElements(aThisNode) ); - return aThisTree->hasChildren(aThisNode); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make compiler happy - OSL_ASSERT(!"Unreachable code"); - return false; -} - -// for set nodes -sal_Bool implHasElements(NodeSetInfoAccess& rNode) throw(uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); // provider lock needed - - rtl::Reference< configuration::Tree > aThisTree( lock.getTree() ); - configuration::NodeRef aThisNode( lock.getNode() ); - OSL_ASSERT( !aThisTree->hasChildren(aThisNode) ); - return aThisTree->hasElements(aThisNode); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make compiler happy - OSL_ASSERT(!"Unreachable code"); - return false; -} - -// XExactName -//----------------------------------------------------------------------------------- - - -//------------------------------------------------------------------------------------------------------------------ -namespace internal -{ - struct SearchExactName : private configuration::NodeVisitor - { - protected: - // warning: order dependency - configuration::RelativePath aSearchPath; - std::vector<configuration::Path::Component>::reverse_iterator pSearchComponent; - public: - explicit - SearchExactName(const configuration::RelativePath& aLookFor) - : aSearchPath(aLookFor) - , pSearchComponent(aSearchPath.begin_mutate()) - {} - - bool complete() { return aSearchPath.end_mutate() == pSearchComponent; } - - bool search(configuration::NodeRef const& aNode, rtl::Reference< configuration::Tree > const& aTree); - - configuration::RelativePath const& getBestMatch() const { return aSearchPath; } - - private: - bool findMatch(configuration::NodeRef& aNode, rtl::Reference< configuration::Tree > & aTree); - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const&); // NodeVisitor - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const&); // NodeVisitor - }; -//.................................................................................................................. - bool SearchExactName::findMatch(configuration::NodeRef& aNode, rtl::Reference< configuration::Tree > & aTree) - { - OSL_ASSERT( !complete() ); - - if ( !aNode.isValid() ) return false; - - // exact match ? - if (!configuration::hasChildOrElement(aTree,aNode,*pSearchComponent)) - { - if (aTree->dispatchToChildren(aNode,*this) == CONTINUE) // not found there - return false; - } - OSL_ASSERT(configuration::hasChildOrElement(aTree,aNode,*pSearchComponent)); - - if (! configuration::findInnerChildOrAvailableElement(aTree,aNode,pSearchComponent->getName()) ) - aNode = configuration::NodeRef(); // will stop recursion (value or unloaded element found) - ++pSearchComponent; - - return true; - } - //.................................................................................................................. - // helper - static configuration::Path::Component getExtendedNodeName(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, rtl::OUString const& aSimpleNodeName) - { - OSL_PRECOND( !configuration::isEmpty(aTree.get()), "ERROR: Configuration: Tree operation requires valid tree" ); - OSL_PRECOND( !aNode.isValid() || aTree->isValidNode(aNode.getOffset()), "ERROR: Configuration: NodeRef does not match tree" ); - - if (aTree->isRootNode(aNode)) - return aTree->getExtendedRootName(); - - else - return configuration::Path::wrapSimpleName(aSimpleNodeName); - } - //.................................................................................................................. - configuration::NodeVisitor::Result SearchExactName::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) - { - OSL_ASSERT( aNode.isValid() ); - OSL_ASSERT( !complete() ); - - // find inexact match (the first one, but the order is unspecified) - // TODO: Add support for node-type-specific element names - rtl::OUString aNodeName = aTree->getSimpleNodeName(aNode.getOffset()); - rtl::OUString aSearchName = pSearchComponent->getName(); - if (aNodeName.equalsIgnoreAsciiCase(aSearchName)) - { - *pSearchComponent = getExtendedNodeName(aTree,aNode,aNodeName); - return DONE; // for this level - } - else - return CONTINUE; - } - //.................................................................................................................. - configuration::NodeVisitor::Result SearchExactName::handle(rtl::Reference< configuration::Tree > const&, configuration::ValueRef const& aNode) - { - OSL_ASSERT( aNode.isValid() ); - OSL_ASSERT( !complete() ); - - // find inexact match (the first one, but the order is unspecified) - // TODO: Add support for node-type-specific element names - rtl::OUString aNodeName = aNode.m_sNodeName; - OSL_ASSERT( configuration::isSimpleName(aNodeName) ); - - // value refs are group members and thus have to have simple names - if (aNodeName.equalsIgnoreAsciiCase(pSearchComponent->getName())) - { - *pSearchComponent = configuration::Path::wrapSimpleName(aNodeName); - return DONE; // for this level - } - else - return CONTINUE; - } -//.................................................................................................................. - bool SearchExactName::search(configuration::NodeRef const & aNode, rtl::Reference< configuration::Tree > const & aTree) - { - if (!aNode.isValid()) return false; - - rtl::Reference< configuration::Tree > aSearchTree(aTree); - configuration::NodeRef aSearchNode(aNode); - - while (!complete()) - if (! findMatch(aSearchNode, aSearchTree)) - break; - - return complete(); - } - -} // namespace internal - -//.................................................................................................................. -rtl::OUString implGetExactName(NodeGroupInfoAccess& rNode, const rtl::OUString& rApproximateName ) throw(uno::RuntimeException) -{ - // here we try to support both tree-fragment-local pathes and simple names (the latter ones are just an instance of the first) - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree(lock.getTree()); - configuration::NodeRef aNode(lock.getNode()); - - configuration::RelativePath aApproximatePath = configuration::validateRelativePath(rApproximateName,aTree,aNode); - - internal::SearchExactName aSearch(aApproximatePath); - - aSearch.search(aNode, aTree); - - OSL_ENSURE( aSearch.getBestMatch().getDepth() == aApproximatePath.getDepth(), - "Search for exact names changed number of path components !?"); - - return aSearch.getBestMatch().toString(); - } - catch (configuration::InvalidName& ) - { - OSL_TRACE("WARNING: Configuration::getExactName: query uses locally invalid Path"); - return rApproximateName; - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make compiler happy - OSL_ASSERT(!"Unreachable code"); - return rApproximateName; -} - -//.................................................................................................................. -rtl::OUString implGetExactName(NodeSetInfoAccess& rNode, const rtl::OUString& rApproximateName ) throw(uno::RuntimeException) -{ - - // here we can support only local names - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree(lock.getTree()); - configuration::NodeRef aNode(lock.getNode()); - - configuration::Path::Component aApproximateName = configuration::validateElementPathComponent(rApproximateName,aTree,aNode); - - internal::SearchExactName aSearch(aApproximateName); - - aSearch.search(aNode, aTree); - - OSL_ENSURE( aSearch.getBestMatch().getDepth() == 1, - "Search for exact names changed number of path components !?"); - - return aSearch.getBestMatch().getLocalName().getName(); - } - catch (configuration::InvalidName& ) - { - OSL_TRACE("WARNING: Configuration::getExactName: query uses locally invalid Path"); - return rApproximateName; - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make compiler happy - OSL_ASSERT(!"Unreachable code"); - return rApproximateName; -} - -// XProperty -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -beans::Property implGetAsProperty(NodeAccess& rNode) - throw(uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree()); - configuration::NodeRef aNode( lock.getNode()); - - rtl::OUString aName = aTree->getSimpleNodeName(aNode.getOffset()); - node::Attributes aAttributes = aTree->getAttributes(aNode); - uno::Type aApiType = getUnoInterfaceType(); - - return helperMakeProperty( aName,aAttributes,aApiType, aTree->hasNodeDefault(aNode) ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return beans::Property(); -} -// XPropertySetInfo -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode ) throw (uno::RuntimeException) -{ - CollectPropertyInfo aCollect; - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - lock.getTree()->dispatchToChildren(lock.getNode(), aCollect); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return makeSequence( aCollect.list() ); -} - -//----------------------------------------------------------------------------------- -css::beans::Property implGetPropertyByName( NodeAccess& rNode, const rtl::OUString& aName ) - throw (css::beans::UnknownPropertyException, uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildOrElementName(aName,aTree,aNode); - - configuration::AnyNodeRef aChildNode = configuration::getChildOrElement(aTree,aNode, aChildName); - - if (!aChildNode.isValid()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property. Property '") ); - sMessage += aName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw css::beans::UnknownPropertyException( sMessage, xContext ); - } - - node::Attributes aChildAttributes = aTree->getAttributes(aChildNode); - uno::Type aApiType = aChildNode.isNode() ? getUnoInterfaceType() : aTree->getUnoType(aChildNode.toValue()); - - return helperMakeProperty( aChildName,aChildAttributes,aApiType, aTree->hasNodeDefault(aChildNode) ); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw css::beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return css::beans::Property(); -} - - -//----------------------------------------------------------------------------------- -sal_Bool implHasPropertyByName( NodeAccess& rNode, const rtl::OUString& name ) throw (uno::RuntimeException) -{ - return implHasByName(rNode, name); -} - -// XNameAccess -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// TODO: optimization - cache the node found (for subsequent getByName) -// TODO: optimization - less locking for group nodes -//----------------------------------------------------------------------------------- -sal_Bool implHasByName(NodeAccess& rNode, const rtl::OUString& sName ) throw(uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::OUString aChildName(sName); - - return configuration::hasChildOrElement(lock.getTree(), lock.getNode(), aChildName); - } -#if OSL_DEBUG_LEVEL > 0 - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - OSL_ENSURE(false,"configmgr: BasicAccess::hasByName: Unexpected exception <InvalidName>"); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -#endif - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make compiler happy - OSL_ASSERT(!"Unreachable code"); - return false; -} - -//----------------------------------------------------------------------------------- -uno::Any implGetByName(NodeAccess& rNode, const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - configuration::NodeRef aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildOrElementName(sName,aTree,aNode); - - configuration::AnyNodeRef aChildNode = configuration::getChildOrElement(aTree,aNode, aChildName); - if (!aChildNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Child Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw com::sun::star::container::NoSuchElementException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - return configapi::makeElement( rNode.getFactory(), aTree, aChildNode ); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw com::sun::star::container::NoSuchElementException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return uno::Any(); -} - -//----------------------------------------------------------------------------------- -// TODO: optimization - less locking for group nodes -//----------------------------------------------------------------------------------- -uno::Sequence< rtl::OUString > implGetElementNames( NodeAccess& rNode ) throw( uno::RuntimeException) -{ - CollectNodeNames aCollect; - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - lock.getTree()->dispatchToChildren(lock.getNode(), aCollect); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return makeSequence( aCollect.list() ); -} - -// XHierarchicalNameAccess -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// TO DO: optimization - cache the node found for subsequent getByHierarchicalName() -//----------------------------------------------------------------------------------- -sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const rtl::OUString& sHierarchicalName ) throw(uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - configuration::NodeRef aNode( lock.getNode() ); - - configuration::RelativePath aRelPath = configuration::validateAndReducePath( sHierarchicalName, aTree, aNode ); - - return configuration::getDeepDescendant(aTree, aNode, aRelPath).isValid(); - } - catch (configuration::InvalidName& ) - { - OSL_TRACE("WARNING: Configuration::hasByHierarchicalName: query uses locally invalid Path"); - return false; - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return false; -} - -//----------------------------------------------------------------------------------- -uno::Any implGetByHierarchicalName(NodeAccess& rNode, const rtl::OUString& sHierarchicalName ) - throw(css::container::NoSuchElementException, uno::RuntimeException) -{ - // rtl::OUString aTmpStr(implGetHierarchicalName(rNode)); - // RTL_LOGFILE_CONTEXT_TRACE2(aLog, "Node: %s HierachicalName: %s",RTL_LOGFILE_OU2A(aTmpStr), RTL_LOGFILE_OU2A(sHierarchicalName)); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - configuration::NodeRef aNode( lock.getNode() ); - - configuration::RelativePath aRelPath = configuration::validateAndReducePath( sHierarchicalName, aTree, aNode ); - - configuration::AnyNodeRef aNestedNode = configuration::getDeepDescendant( aTree, aNode, aRelPath ); - if (!aNestedNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Descendant Element '") ); - sMessage += aRelPath.toString(); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Node ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw com::sun::star::container::NoSuchElementException( sMessage, xContext ); - } - - OSL_ASSERT(aNode.isValid()); - return configapi::makeElement( rNode.getFactory(), aTree, aNestedNode ); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw com::sun::star::container::NoSuchElementException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return uno::Any(); -} - -// XPropertyWithState -//--------------------------------------------------------------------- -css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode) - throw (uno::RuntimeException) -{ - css::beans::PropertyState aRet = css::beans::PropertyState_AMBIGUOUS_VALUE; - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - if ( lock.getTree()->isNodeDefault( lock.getNode() ) ) - aRet = css::beans::PropertyState_DEFAULT_VALUE; - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - return aRet; -} - -uno::Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& ) - throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - // not really supported - - /* possible, but nor really useful: - GuardedNodeAccess lock( rNode ); - if (implGetStateAsProperty(rNode) == PropertyState_DEFAULT_VALUE) - return rNode.getUnoInstance(); - */ - - return uno::Reference< uno::XInterface >(); -} - - -// set-specific Interfaces -//----------------------------------------------------------------------------------- - - -// XTemplateContainer -//----------------------------------------------------------------------------------- -rtl::OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode) - throw(uno::RuntimeException) -{ - GuardedNodeData<NodeSetInfoAccess> lock(rNode); - return rNode.getElementInfo()->getPathString(); -} - -//----------------------------------------------------------------------------------- - } // namespace configapi - -} // namespace configmgr - - diff --git a/configmgr/source/api2/accessimpl.hxx b/configmgr/source/api2/accessimpl.hxx deleted file mode 100644 index b4b7e95f2a0f..000000000000 --- a/configmgr/source/api2/accessimpl.hxx +++ /dev/null @@ -1,136 +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_API_BASEACCESSIMPL_HXX_ -#define CONFIGMGR_API_BASEACCESSIMPL_HXX_ - -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/configuration/XTemplateInstance.hpp> -#include <com/sun/star/configuration/XTemplateContainer.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/beans/XProperty.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/beans/XPropertyWithState.hpp> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - /* implementations of the interfaces supported by a (parent) node - within the configuration tree. - (read-only operation) - */ - namespace configapi - { - class NodeAccess; - class NodeSetInfoAccess; - class NodeGroupInfoAccess; - - // XHierarchicalName - rtl::OUString implGetHierarchicalName(NodeAccess& rNode) - throw(uno::RuntimeException); - - rtl::OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const rtl::OUString& aRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException); - - rtl::OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const rtl::OUString& aRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException); - - // XElementAccess, base class of XNameAccess - uno::Type implGetElementType(NodeGroupInfoAccess& rNode) - throw(uno::RuntimeException); - - uno::Type implGetElementType(NodeSetInfoAccess& rNode) - throw(uno::RuntimeException); - - sal_Bool implHasElements(NodeGroupInfoAccess& rNode) - throw(uno::RuntimeException); - - sal_Bool implHasElements(NodeSetInfoAccess& rNode) - throw(uno::RuntimeException); - - // XNameAccess - uno::Any implGetByName(NodeAccess& rNode, const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - uno::Sequence< rtl::OUString > implGetElementNames(NodeAccess& rNode) - throw( uno::RuntimeException); - - sal_Bool implHasByName(NodeAccess& rNode, const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XHierarchicalNameAccess - uno::Any implGetByHierarchicalName(NodeAccess& rNode, const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, uno::RuntimeException); - - sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XExactName - rtl::OUString implGetExactName(NodeGroupInfoAccess& rNode, const rtl::OUString& aApproximateName ) - throw(uno::RuntimeException); - - rtl::OUString implGetExactName(NodeSetInfoAccess& rNode, const rtl::OUString& aApproximateName ) - throw(uno::RuntimeException); - - // XProperty - css::beans::Property implGetAsProperty(NodeAccess& rNode) - throw(uno::RuntimeException); - - // XPropertySetInfo - uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode ) - throw (uno::RuntimeException); - - css::beans::Property implGetPropertyByName( NodeAccess& rNode, const rtl::OUString& aName ) - throw (css::beans::UnknownPropertyException, uno::RuntimeException); - - sal_Bool implHasPropertyByName( NodeAccess& rNode, const rtl::OUString& name ) - throw (uno::RuntimeException); - - - // XPropertyWithState - css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode) - throw (uno::RuntimeException); - - uno::Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& rNode) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - // set-specific interfaces - - // XTemplateContainer - rtl::OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode) - throw(uno::RuntimeException); - - } - -} -#endif // CONFIGMGR_API_BASEACCESSIMPL_HXX_ - - diff --git a/configmgr/source/api2/apiaccessobj.cxx b/configmgr/source/api2/apiaccessobj.cxx deleted file mode 100644 index 9f06806d290c..000000000000 --- a/configmgr/source/api2/apiaccessobj.cxx +++ /dev/null @@ -1,290 +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 "apiaccessobj.hxx" - -#include "apiserviceinfo.hxx" -#include "confsvccomponent.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//======================================================================== -//= service infos -//======================================================================== -/* -const AsciiServiceName c_aUserContainerServices[] = -{ - "com.sun.star.configuration.UserAdministration", - "com.sun.star.configuration.ConfigurationContainer", - "com.sun.star.configuration.ConfigurationUpdateAccess", - "com.sun.star.configuration.ConfigurationAccess", - NULL -}; -const AsciiServiceName c_aContainerServices[] = -{ - "com.sun.star.configuration.ConfigurationContainer", - "com.sun.star.configuration.ConfigurationUpdateAccess", - "com.sun.star.configuration.ConfigurationAccess", - NULL -}; -const AsciiServiceName c_aUpdateServices[] = -{ - "com.sun.star.configuration.ConfigurationUpdateAccess", - "com.sun.star.configuration.ConfigurationAccess", - NULL -}; - -const AsciiServiceName c_aAccessServices[] = -{ - "com.sun.star.configuration.ConfigurationAccess", - NULL -}; - -const AsciiServiceName c_aNoServices[] = -{ - NULL -}; -//----------------------------------------------------------------------------- - -ServiceInfo const aInnerGroupInfoSI = -{ - "com.sun.star.configuration.configmgr.OInnerGroupInfoAccess", - c_aNoServices -}; -ServiceInfo const aInnerGroupUpdateSI = -{ - "com.sun.star.configuration.configmgr.OInnerGroupUpdateAccess", - c_aNoServices -}; -ServiceInfo const aInnerSetInfoSI = -{ - "com.sun.star.configuration.configmgr.OInnerSetInfoAccess", - c_aNoServices -}; -ServiceInfo const aInnerTreeSetSI = -{ - "com.sun.star.configuration.configmgr.OInnerTreeSetUpdateAccess", - c_aNoServices -}; -ServiceInfo const aInnerValueSetSI = -{ - "com.sun.star.configuration.configmgr.OInnerValueSetUpdateAccess", - c_aNoServices -}; -//----------------------------------------------------------------------------- - -ServiceInfo const aSetElementGroupInfoSI = -{ - "com.sun.star.configuration.configmgr.OSetElementGroupInfoAccess", - c_aAccessServices -}; -ServiceInfo const aSetElementGroupUpdateSI = -{ - "com.sun.star.configuration.configmgr.OSetElementGroupUpdateAccess", - c_aUpdateServices -}; -ServiceInfo const aSetElementSetInfoSI = -{ - "com.sun.star.configuration.configmgr.OSetElementSetInfoAccess", - c_aAccessServices -}; -ServiceInfo const aSetElementTreeSetSI = -{ - "com.sun.star.configuration.configmgr.OSetElementTreeSetUpdateAccess", - c_aContainerServices -}; -ServiceInfo const aSetElementValueSetSI = -{ - "com.sun.star.configuration.configmgr.OSetElementValueSetUpdateAccess", - c_aContainerServices -}; -//----------------------------------------------------------------------------- - -ServiceInfo const aRootElementGroupInfoSI = -{ - "com.sun.star.configuration.configmgr.ORootElementGroupInfoAccess", - c_aAccessServices -}; -ServiceInfo const aRootElementGroupUpdateSI = -{ - "com.sun.star.configuration.configmgr.ORootElementGroupUpdateAccess", - c_aUpdateServices -}; -ServiceInfo const aRootElementSetInfoSI = -{ - "com.sun.star.configuration.configmgr.ORootElementSetInfoAccess", - c_aAccessServices -}; -ServiceInfo const aRootElementTreeSetUpdateSI = -{ - "com.sun.star.configuration.configmgr.ORootElementTreeSetUpdateAccess", - c_aContainerServices -}; -ServiceInfo const aRootElementValueSetUpdateSI = -{ - "com.sun.star.configuration.configmgr.ORootElementValueSetUpdateAccess", - c_aContainerServices -}; -//----------------------------------------------------------------------------- - -ServiceInfo const aRootElementReadAccessSI = -{ - "com.sun.star.configuration.configmgr.ORootElementReadAccess", - c_aAccessServices -}; -ServiceInfo const aRootElementUpdateAccessSI = -{ - "com.sun.star.configuration.configmgr.ORootElementUpdateAccess", - c_aUpdateServices -}; -ServiceInfo const aRootElementAdminAccessSI = -{ - "com.sun.star.configuration.configmgr.ORootElementUserAdminAccess", - c_aUserContainerServices -};*/ - -//======================================================================== -//= service info static members -//======================================================================== - -//----------------------------------------------------------------------------- -// Inner Elements -//----------------------------------------------------------------------------- - -template <> -ServiceImplementationInfo const * -const OInnerElement<NodeGroupInfoAccess>::s_pServiceInfo = &aInnerGroupInfoSI; - -template <> -ServiceImplementationInfo const * -const OInnerElement<NodeGroupAccess>::s_pServiceInfo = &aInnerGroupUpdateSI; - -template <> -ServiceImplementationInfo const * -const OInnerElement<NodeSetInfoAccess>::s_pServiceInfo = &aInnerSetInfoSI; - -template <> -ServiceImplementationInfo const * -const OInnerElement<NodeTreeSetAccess>::s_pServiceInfo = &aInnerTreeSetSI; - -template <> -ServiceImplementationInfo const * -const OInnerElement<NodeValueSetAccess>::s_pServiceInfo = &aInnerValueSetSI; - - -//----------------------------------------------------------------------------- -// Set Elements -//----------------------------------------------------------------------------- - -template <> -ServiceImplementationInfo const * -const OSetElement<NodeGroupInfoAccess>::s_pServiceInfo = &aSetElementGroupInfoSI; - -template <> -ServiceImplementationInfo const * -const OSetElement<NodeGroupAccess>::s_pServiceInfo = &aSetElementGroupUpdateSI; - -template <> -ServiceImplementationInfo const * -const OSetElement<NodeSetInfoAccess>::s_pServiceInfo = &aSetElementSetInfoSI; - -template <> -ServiceImplementationInfo const * -const OSetElement<NodeTreeSetAccess>::s_pServiceInfo = &aSetElementTreeSetSI; - -template <> -ServiceImplementationInfo const * -const OSetElement<NodeValueSetAccess>::s_pServiceInfo = &aSetElementValueSetSI; - -//----------------------------------------------------------------------------- -// Root Elements -//----------------------------------------------------------------------------- - -template <> -ServiceImplementationInfo const * -const OReadRootElement<NodeGroupInfoAccess>::s_pServiceInfo = &aRootElementGroupInfoSI; - -template <> -ServiceImplementationInfo const * -const OUpdateRootElement<NodeGroupAccess>::s_pServiceInfo = &aRootElementGroupUpdateSI; - -template <> -ServiceImplementationInfo const * -const OReadRootElement<NodeSetInfoAccess>::s_pServiceInfo = &aRootElementSetInfoSI; - -template <> -ServiceImplementationInfo const * -const OUpdateRootElement<NodeTreeSetAccess>::s_pServiceInfo = &aRootElementTreeSetUpdateSI; - -template <> -ServiceImplementationInfo const * -const OUpdateRootElement<NodeValueSetAccess>::s_pServiceInfo = &aRootElementValueSetUpdateSI; - - - -//======================================================================== -//= Instantiations -//======================================================================== -/* -//----------------------------------------------------------------------------- -// Inner Elements -//----------------------------------------------------------------------------- - -template class OInnerElement<NodeGroupInfoAccess>; // OInnerGroupInfoAccess -template class OInnerElement<NodeGroupAccess>; // OInnerGroupUpdateAccess -template class OInnerElement<NodeSetInfoAccess>; // OInnerSetInfoAccess -template class OInnerElement<NodeTreeSetAccess>; // OInnerTreeSetUpdateAccess -template class OInnerElement<NodeValueSetAccess>; // OInnerValueSetUpdateAccess - -//----------------------------------------------------------------------------- -// Set Elements -//----------------------------------------------------------------------------- -template class OSetElement<NodeGroupInfoAccess>; // OSetElementGroupInfoAccess -template class OSetElement<NodeGroupAccess>; // OSetElementGroupUpdateAccess -template class OSetElement<NodeSetInfoAccess>; // OSetElementSetInfoAccess -template class OSetElement<NodeTreeSetAccess>; // OSetElementTreeSetUpdateAccess -template class OSetElement<NodeValueSetAccess>; // OSetElementValueSetUpdateAccess - -//----------------------------------------------------------------------------- -// Root Elements -//----------------------------------------------------------------------------- - -template class OReadRootElement<NodeGroupInfoAccess>; // ORootElementGroupInfoAccess -template class OUpdateRootElement<NodeGroupAccess>; // ORootElementGroupUpdateAccess -template class OReadRootElement<NodeSetInfoAccess>; // ORootElementSetInfoAccess -template class OUpdateRootElement<NodeTreeSetAccess>; // ORootElementTreeSetUpdateAccess -template class OUpdateRootElement<NodeValueSetAccess>; // ORootElementValueSetUpdateAccess -*/ -//----------------------------------------------------------------------------- - } -} diff --git a/configmgr/source/api2/apiaccessobj.hxx b/configmgr/source/api2/apiaccessobj.hxx deleted file mode 100644 index dc2bf7e107da..000000000000 --- a/configmgr/source/api2/apiaccessobj.hxx +++ /dev/null @@ -1,145 +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_API_ACCESSOBJECTS_HXX_ -#define CONFIGMGR_API_ACCESSOBJECTS_HXX_ - -#include "apitreeaccess.hxx" -#include "apinodeaccess.hxx" -#include "apinodeupdate.hxx" - -#include "apitreeimplobj.hxx" -#include "noderef.hxx" - -#include "apiserviceinfo.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- -// Inner Elements -//----------------------------------------------------------------------------- - - template <class NodeClass> - class OInnerElement : public InnerElement, public NodeClass - { - static ServiceImplementationInfo const*const s_pServiceInfo; - - uno::XInterface* m_pUnoThis; - ApiTreeImpl& m_rTree; - configuration::NodeRef m_aNode; - public: - inline OInnerElement(uno::XInterface* pUnoThis,ApiTreeImpl& rTree, configuration::NodeRef const& aNode); - inline ~OInnerElement(); - - virtual inline configuration::NodeRef doGetNode() const; - virtual inline ApiTreeImpl& getApiTree() const; - - virtual inline uno::XInterface* doGetUnoInstance() const; - virtual inline ServiceImplementationInfo const* doGetServiceInfo() const; - - static inline ServiceImplementationInfo const* getStaticServiceInfo(); - }; - -//----------------------------------------------------------------------------- -// Set Elements -//----------------------------------------------------------------------------- - - template <class NodeClass> - class OSetElement : public SetElement, public NodeClass - { - static ServiceImplementationInfo const*const s_pServiceInfo; - - mutable ApiTreeImpl m_aTree; - public: - OSetElement(uno::XInterface* pUnoThis, rtl::Reference< configuration::Tree > const& aTree, ApiProvider& rProvider, ApiTreeImpl* pParentTree = 0) - : m_aTree(pUnoThis, rProvider,aTree,pParentTree) - {} - - virtual inline configuration::NodeRef doGetNode() const; - virtual inline ApiTreeImpl& getApiTree() const; - - virtual inline uno::XInterface* doGetUnoInstance() const; - virtual inline ServiceImplementationInfo const* doGetServiceInfo() const; - - static inline ServiceImplementationInfo const* getStaticServiceInfo(); - }; - -//----------------------------------------------------------------------------- -// Root Elements -//----------------------------------------------------------------------------- - - template <class NodeClass> - class OReadRootElement : public RootElement, public NodeClass - { - static ServiceImplementationInfo const*const s_pServiceInfo; - mutable ApiRootTreeImpl m_aRootTree; - public: - OReadRootElement(uno::XInterface* pUnoThis, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aRootTree(pUnoThis, rProvider,aTree, _xOptions) - {} - - virtual inline configuration::NodeRef doGetNode() const; - virtual inline ApiTreeImpl& getApiTree() const; - virtual inline ApiRootTreeImpl& getRootTree(); - - virtual inline uno::XInterface* doGetUnoInstance() const; - virtual inline ServiceImplementationInfo const* doGetServiceInfo() const; - - static inline ServiceImplementationInfo const* getStaticServiceInfo(); - }; - //------------------------------------------------------------------------- - - template <class NodeClass> - class OUpdateRootElement : public UpdateRootElement, public NodeClass - { - static ServiceImplementationInfo const*const s_pServiceInfo; - - mutable ApiRootTreeImpl m_aRootTree; - public: - OUpdateRootElement(uno::XInterface* pUnoThis, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aRootTree(pUnoThis, rProvider,aTree,_xOptions) - {} - - virtual inline configuration::NodeRef doGetNode() const; - virtual inline ApiTreeImpl& getApiTree() const; - virtual inline ApiRootTreeImpl& getRootTree(); - - virtual inline uno::XInterface* doGetUnoInstance() const; - virtual inline ServiceImplementationInfo const* doGetServiceInfo() const; - - static inline ServiceImplementationInfo const* getStaticServiceInfo(); - }; - } -} -//----------------------------------------------------------------------------- -#include "apiaccessobj.inl" -//----------------------------------------------------------------------------- - -#endif // CONFIGMGR_API_ACCESSOBJECTS_HXX_ diff --git a/configmgr/source/api2/apiaccessobj.inl b/configmgr/source/api2/apiaccessobj.inl deleted file mode 100644 index 5cdb54ae6802..000000000000 --- a/configmgr/source/api2/apiaccessobj.inl +++ /dev/null @@ -1,260 +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. - * - ************************************************************************/ - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { - -//======================================================================== -//= member functions -//======================================================================== - -//----------------------------------------------------------------------------- -// Inner Elements -//----------------------------------------------------------------------------- - -template <class NodeClass> -OInnerElement<NodeClass>::OInnerElement(uno::XInterface* pUnoThis,ApiTreeImpl& rTree, configuration::NodeRef const& aNode) -: m_pUnoThis(pUnoThis) -, m_rTree(rTree) -, m_aNode(aNode) -{ - m_rTree.setNodeInstance(aNode,pUnoThis); - m_rTree.getUnoInstance()->acquire(); -} - -template <class NodeClass> -OInnerElement<NodeClass>::~OInnerElement() -{ - m_rTree.getUnoInstance()->release(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -configuration::NodeRef OInnerElement<NodeClass>::doGetNode() const -{ - return m_aNode; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiTreeImpl& OInnerElement<NodeClass>::getApiTree() const -{ - return m_rTree; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -uno::XInterface* OInnerElement<NodeClass>::doGetUnoInstance() const -{ - return m_pUnoThis; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OInnerElement<NodeClass>::doGetServiceInfo() const -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OInnerElement<NodeClass>::getStaticServiceInfo() -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Set Elements -//----------------------------------------------------------------------------- - -template <class NodeClass> -configuration::NodeRef OSetElement<NodeClass>::doGetNode() const -{ - return m_aTree.getTree()->getRootNode(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiTreeImpl& OSetElement<NodeClass>::getApiTree() const -{ - return m_aTree; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -uno::XInterface* OSetElement<NodeClass>::doGetUnoInstance() const -{ - return m_aTree.getUnoInstance(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OSetElement<NodeClass>::doGetServiceInfo() const -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OSetElement<NodeClass>::getStaticServiceInfo() -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Read-only Root Elements -//----------------------------------------------------------------------------- - -template <class NodeClass> -configuration::NodeRef OReadRootElement<NodeClass>::doGetNode() const -{ - return m_aRootTree.getApiTree().getTree()->getRootNode(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiTreeImpl& OReadRootElement<NodeClass>::getApiTree() const -{ - return m_aRootTree.getApiTree(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiRootTreeImpl& OReadRootElement<NodeClass>::getRootTree() -{ - return m_aRootTree; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -uno::XInterface* OReadRootElement<NodeClass>::doGetUnoInstance() const -{ - return m_aRootTree.getApiTree().getUnoInstance(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OReadRootElement<NodeClass>::doGetServiceInfo() const -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OReadRootElement<NodeClass>::getStaticServiceInfo() -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Update Root Elements -//----------------------------------------------------------------------------- - -template <class NodeClass> -configuration::NodeRef OUpdateRootElement<NodeClass>::doGetNode() const -{ - return m_aRootTree.getApiTree().getTree()->getRootNode(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiTreeImpl& OUpdateRootElement<NodeClass>::getApiTree() const -{ - return m_aRootTree.getApiTree(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ApiRootTreeImpl& OUpdateRootElement<NodeClass>::getRootTree() -{ - return m_aRootTree; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -uno::XInterface* OUpdateRootElement<NodeClass>::doGetUnoInstance() const -{ - return m_aRootTree.getApiTree().getUnoInstance(); -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OUpdateRootElement<NodeClass>::doGetServiceInfo() const -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -template <class NodeClass> -ServiceImplementationInfo const* OUpdateRootElement<NodeClass>::getStaticServiceInfo() -{ - return s_pServiceInfo; -} -//----------------------------------------------------------------------------- - -//======================================================================== -//= Instantiations -//======================================================================== -/* -//----------------------------------------------------------------------------- -// Inner Elements -//----------------------------------------------------------------------------- - -template class OInnerElement<NodeGroupInfoAccess>; // OInnerGroupInfoAccess -template class OInnerElement<NodeGroupAccess>; // OInnerGroupUpdateAccess -template class OInnerElement<NodeSetInfoAccess>; // OInnerSetInfoAccess -template class OInnerElement<NodeTreeSetAccess>; // OInnerTreeSetUpdateAccess -template class OInnerElement<NodeValueSetAccess>; // OInnerValueSetUpdateAccess - -//----------------------------------------------------------------------------- -// Set Elements -//----------------------------------------------------------------------------- -template class OSetElement<NodeGroupInfoAccess>; // OSetElementGroupInfoAccess -template class OSetElement<NodeGroupAccess>; // OSetElementGroupUpdateAccess -template class OSetElement<NodeSetInfoAccess>; // OSetElementSetInfoAccess -template class OSetElement<NodeTreeSetAccess>; // OSetElementTreeSetUpdateAccess -template class OSetElement<NodeValueSetAccess>; // OSetElementValueSetUpdateAccess - -//----------------------------------------------------------------------------- -// Root Elements -//----------------------------------------------------------------------------- - -template class OReadRootElement<NodeGroupInfoAccess>; // ORootElementGroupInfoAccess -template class OUpdateRootElement<NodeGroupAccess>; // ORootElementGroupUpdateAccess -template class OReadRootElement<NodeSetInfoAccess>; // ORootElementSetInfoAccess -template class OUpdateRootElement<NodeTreeSetAccess>; // ORootElementTreeSetUpdateAccess -template class OUpdateRootElement<NodeValueSetAccess>; // ORootElementValueSetUpdateAccess -*/ -//----------------------------------------------------------------------------- - } -} diff --git a/configmgr/source/api2/apifactory.cxx b/configmgr/source/api2/apifactory.cxx deleted file mode 100644 index 5e338431822e..000000000000 --- a/configmgr/source/api2/apifactory.cxx +++ /dev/null @@ -1,335 +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 "apifactory.hxx" -#include "objectregistry.hxx" - -#include "apitreeaccess.hxx" -#include "apitreeimplobj.hxx" - -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/lang/XUnoTunnel.hpp> - -#include "noderef.hxx" -#include "anynoderef.hxx" - -#include "configexcept.hxx" -#include "configset.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- -ObjectRegistry::~ObjectRegistry() -{ - OSL_ENSURE(m_aMap.empty(),"WARNING: Configuration Object Map: Some Objects were not revoked correctly"); -} - -//----------------------------------------------------------------------------- - -Factory::Factory(rtl::Reference<ObjectRegistry> pRegistry) -: m_pRegistry(pRegistry) -, m_aTunnelID() -{ - OSL_ENSURE(pRegistry.is(), "ERROR: Factory requires a Object Registry"); -} -//----------------------------------------------------------------------------- - -Factory::~Factory() -{ -} -//----------------------------------------------------------------------------- -inline -NodeElement* Factory::implFind(configuration::NodeID const& aNode) -{ - return m_pRegistry->findElement(aNode); -} -//----------------------------------------------------------------------------- -inline -void Factory::doRegisterElement(configuration::NodeID const& aNode, NodeElement* pElement) -{ - m_pRegistry->registerElement(aNode,pElement); -} -//----------------------------------------------------------------------------- -inline -void Factory::doRevokeElement(configuration::NodeID const& aNode, NodeElement* pElement) -{ - m_pRegistry->revokeElement(aNode,pElement); -} -//----------------------------------------------------------------------------- - -ApiTreeImpl& Factory::getImplementation(NodeElement& rElement) -{ - return rElement.getApiTree(); -} -//----------------------------------------------------------------------------- - -inline -rtl::Reference<configuration::Template> Factory::implGetSetElementTemplate(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) -{ - rtl::Reference<configuration::Template> aRet; - if (configuration::isSetNode(aTree,aNode)) - { - aRet = aTree->extractElementInfo(aNode); - } - else if (!configuration::isGroupNode(aTree,aNode)) - { - OSL_ENSURE( !configuration::isStructuralNode(aTree,aNode), "ERROR: Configuration: unknown kind of object"); - throw configuration::Exception("INTERNAL ERROR: Cannot create template - Unexpected node type"); - } - return aRet; -} -//----------------------------------------------------------------------------- -inline -uno::Reference< uno::XInterface > Factory::implToUno(NodeElement* pElement) -{ - if ( pElement ) - return uno::Reference< uno::XInterface >(pElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - else - return uno::Reference< uno::XInterface >(); -} -//----------------------------------------------------------------------------- -inline -void Factory::implHaveNewElement(configuration::NodeID aNodeID, NodeElement* pElement) -{ - OSL_ENSURE(pElement ,"WARNING: New API object could not be created"); - - if (pElement) - { - doRegisterElement(aNodeID,pElement); - OSL_ENSURE(implFind(aNodeID) == pElement,"WARNING: New API object could not be registered with its factory"); - } -} -//----------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > Factory::makeUnoElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) -{ - return implToUno(makeElement(aTree,aNode)); -} -//----------------------------------------------------------------------------- -NodeElement* Factory::makeElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) -{ - OSL_PRECOND( !configuration::isEmpty(aTree.get()) == aNode.isValid(), "ERROR: Configuration: Making element from tree requires valid node"); - if (configuration::isEmpty(aTree.get())) - return 0; - - OSL_PRECOND( aNode.isValid() && aTree->isValidNode(aNode.getOffset()), "ERROR: Configuration: NodeRef does not match Tree"); - OSL_PRECOND( configuration::isStructuralNode(aTree,aNode), "ERROR: Configuration: Cannot make object for value node"); - - configuration::NodeID aNodeID(aTree,aNode); - NodeElement* pRet = findElement(aNodeID); - if (pRet == 0) - { - rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aNode); - - if (!aTree->isRootNode(aNode)) - { - pRet = doCreateGroupMember(aTree,aNode,aTemplate.get()); - } - else - { - rtl::Reference< configuration::ElementTree > aElementTree(dynamic_cast< configuration::ElementTree * >(aTree.get())); - if (aElementTree.is()) - { - pRet = doCreateSetElement(aElementTree,aTemplate.get()); - } - else - { - OSL_ENSURE(configuration::isEmpty(aTree->getContextTree()),"INTERNAL ERROR: Found tree (not a set element) with a parent tree."); - pRet = doCreateAccessRoot(aTree,aTemplate.get(), vos::ORef< OOptions >()); - } - } - implHaveNewElement(aNodeID,pRet); - } - return pRet; -} -//----------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > Factory::findUnoElement(configuration::NodeID const& aNodeID) -{ - return implToUno(findElement(aNodeID)); -} -//----------------------------------------------------------------------------- -NodeElement* Factory::findElement(configuration::NodeID const& aNodeID) -{ - NodeElement* pReturn = implFind(aNodeID); - if (pReturn) pReturn->getUnoInstance()->acquire(); - return pReturn; -} -//----------------------------------------------------------------------------- - -void Factory::revokeElement(configuration::NodeID const& aNodeID) -{ - if (NodeElement* pElement = implFind(aNodeID)) - doRevokeElement(aNodeID, pElement); -} -//----------------------------------------------------------------------------- - -TreeElement* Factory::makeAccessRoot(rtl::Reference< configuration::Tree > const& aTree, RequestOptions const& _aOptions) -{ - OSL_PRECOND( !configuration::isEmpty(aTree.get()) , "ERROR: Configuration: Making element from tree requires valid tree"); - if (configuration::isEmpty(aTree.get())) return 0; - - OSL_ENSURE(configuration::isEmpty(aTree->getContextTree()),"INTERNAL ERROR: Tree with parent tree should not be used for an access root"); - OSL_ENSURE(dynamic_cast< configuration::ElementTree * >(aTree.get()) == 0, "INTERNAL ERROR: Element Tree should not be used for an access root"); - - configuration::NodeRef aRoot = aTree->getRootNode(); - OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node"); - - OSL_PRECOND( configuration::isStructuralNode(aTree,aRoot), "ERROR: Configuration: Cannot make object for value node"); - - configuration::NodeID aNodeID(aTree,aRoot); - // must be a tree element if it is a tree root - TreeElement* pRet = static_cast<TreeElement*>(findElement(aNodeID)); - if (0 == pRet) - { - rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aRoot); - vos::ORef<OOptions> xOptions = new OOptions(_aOptions); - pRet = doCreateAccessRoot(aTree,aTemplate.get(), xOptions); - implHaveNewElement (aNodeID,pRet); - } - return pRet; -} -//----------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > Factory::makeUnoSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree) -{ - uno::Reference< uno::XInterface > aRet = implToUno(makeSetElement(aElementTree)); - OSL_ENSURE( uno::Reference<lang::XUnoTunnel>::query(aRet).is(),"ERROR: API set element has no UnoTunnel"); - OSL_ENSURE( uno::Reference<lang::XUnoTunnel>::query(aRet).is() && - 0 != uno::Reference<lang::XUnoTunnel>::query(aRet)->getSomething(doGetElementTunnelID()), - "ERROR: API set element does not support the right tunnel ID"); - - return aRet; -} -//----------------------------------------------------------------------------- - -SetElement* Factory::makeSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree) -{ - OSL_PRECOND( aElementTree.is() , "ERROR: Configuration: Making element from tree requires valid tree"); - if (!aElementTree.is()) return 0; - - rtl::Reference< configuration::Tree > aTree(aElementTree.get()); - OSL_ENSURE(!configuration::isEmpty(aTree.get()),"INTERNAL ERROR: Element Tree has no Tree"); - - configuration::NodeRef aRoot = aTree->getRootNode(); - OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node"); - - OSL_ENSURE( configuration::isStructuralNode(aTree,aRoot), "ERROR: Configuration: Cannot make object for value node"); - - configuration::NodeID aNodeID(aTree,aRoot); - // must be a set element if it wraps a ElementTree - SetElement* pRet = static_cast<SetElement*>( findElement(aNodeID) ); - if (0 == pRet) - { - rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aRoot); - - pRet = doCreateSetElement(aElementTree,aTemplate.get()); - - implHaveNewElement(aNodeID,pRet); - } - return pRet; -} -//----------------------------------------------------------------------------- - -SetElement* Factory::findSetElement(rtl::Reference< configuration::ElementTree > const& aElement) -{ - OSL_PRECOND( aElement.is() , "ERROR: Configuration: Making element from tree requires valid tree"); - if (!aElement.is()) return 0; - - rtl::Reference< configuration::Tree > aTree(aElement.get()); - OSL_ENSURE(!isEmpty(aTree.get()),"INTERNAL ERROR: Element Tree has no Tree"); - - configuration::NodeRef aRoot = aTree->getRootNode(); - OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node"); - - configuration::NodeID aNodeID(aTree,aRoot); - // must be a set element if it wraps a ElementTree - SetElement* pRet = static_cast<SetElement*>( findElement(aNodeID) ); - - return pRet; -} -//----------------------------------------------------------------------------- - -SetElement* Factory::extractSetElement(uno::Any const& aElement) -{ - SetElement* pTunneledImpl = 0; - - uno::Reference< lang::XUnoTunnel > xElementTunnel; - if ( aElement.hasValue() && (aElement >>= xElementTunnel) ) - { - OSL_ASSERT( xElementTunnel.is() ); - - sal_Int64 nSomething = xElementTunnel->getSomething(doGetElementTunnelID()); - if (0 != nSomething) - { - void* pVoid = reinterpret_cast<void*>(nSomething); - pTunneledImpl = static_cast<SetElement*>(pVoid); - } - } - return pTunneledImpl; -} -//----------------------------------------------------------------------------- - -bool Factory::tunnelSetElement(sal_Int64& nSomething, SetElement& rElement, uno::Sequence< sal_Int8 > const& aTunnelID) -{ - if (aTunnelID == doGetElementTunnelID()) - { - void* pVoid = &rElement; - nSomething = reinterpret_cast<sal_Int64>(pVoid); - - return true; - } - else - return false; -} - -//----------------------------------------------------------------------------- - -ApiTreeImpl const* Factory::findDescendantTreeImpl(configuration::NodeID const& aNode, ApiTreeImpl const* pImpl) -{ - ApiTreeImpl* pRet = 0; - if (pImpl) - { - if ( NodeElement* pElement = pImpl->getFactory().implFind( aNode ) ) - pRet = &pElement->getApiTree(); - } - return pRet; -} - -//----------------------------------------------------------------------------- - } -} diff --git a/configmgr/source/api2/apifactory.hxx b/configmgr/source/api2/apifactory.hxx deleted file mode 100644 index ff5de1296712..000000000000 --- a/configmgr/source/api2/apifactory.hxx +++ /dev/null @@ -1,119 +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_API_FACTORY_HXX_ -#define CONFIGMGR_API_FACTORY_HXX_ - -#include "options.hxx" -#include "utility.hxx" -#include <boost/utility.hpp> -#include <rtl/ref.hxx> -#include <vos/ref.hxx> -#include <cppuhelper/typeprovider.hxx> - -namespace configmgr -{ - namespace configuration - { - class NodeID; - class NodeRef; - class ElementTree; - class Template; - class Tree; - } - namespace configapi - { - namespace uno = com::sun::star::uno; - - class ApiTreeImpl; - class NodeElement; - class InnerElement; - class TreeElement; - class SetElement; - class RootElement; - - // used to register objects - class ObjectRegistry; - - // used to create UNO objects - class Factory : private boost::noncopyable - { - rtl::Reference<ObjectRegistry> m_pRegistry; - cppu::OImplementationId const m_aTunnelID; - - private: - /// return the element _without_ acquiring it - NodeElement* implFind(configuration::NodeID const& aNode); - - public: - Factory(rtl::Reference<ObjectRegistry> pRegistry); - virtual ~Factory(); - - uno::Reference< uno::XInterface > makeUnoElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); - uno::Reference< uno::XInterface > findUnoElement(configuration::NodeID const& aNode); - - uno::Reference< uno::XInterface > makeUnoSetElement(rtl::Reference< configuration::ElementTree > const& aTree); - - NodeElement* makeElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); - NodeElement* findElement(configuration::NodeID const& aNode); - - TreeElement* makeAccessRoot(rtl::Reference< configuration::Tree > const& aTree, RequestOptions const& _aOptions); - SetElement* makeSetElement(rtl::Reference< configuration::ElementTree > const& aTree); - - SetElement* findSetElement(rtl::Reference< configuration::ElementTree > const& aElement); - - /// check for the existence of an element - sal_Bool hasElement(configuration::NodeID const& _rNode) { return NULL != implFind(_rNode); } - - void revokeElement(configuration::NodeID const& aNode); - - SetElement* extractSetElement(uno::Any const& aElement); - bool tunnelSetElement(sal_Int64& nSomething, SetElement& rElement, uno::Sequence< sal_Int8 > const& aTunnelID); - // registry operations - - static ApiTreeImpl const* findDescendantTreeImpl(configuration::NodeID const& aNode, ApiTreeImpl const* pImpl); - protected: - void doRegisterElement(configuration::NodeID const& aNode, NodeElement* pElement); - void doRevokeElement(configuration::NodeID const& aNode, NodeElement* pElement); - - uno::Sequence< sal_Int8 > doGetElementTunnelID() const { return m_aTunnelID.getImplementationId(); } - - virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate) = 0; - virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions) = 0; - virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate) = 0; - - static ApiTreeImpl& getImplementation(NodeElement& pElement); - private: - static rtl::Reference<configuration::Template> implGetSetElementTemplate(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); - static uno::Reference< uno::XInterface > implToUno(NodeElement* pNode); - void implHaveNewElement(configuration::NodeID aNodeID, NodeElement* pNode); - }; - - } -} - -#endif // CONFIGMGR_API_FACTORY_HXX_ diff --git a/configmgr/source/api2/apifactoryimpl.cxx b/configmgr/source/api2/apifactoryimpl.cxx deleted file mode 100644 index 4d355a4bbb8c..000000000000 --- a/configmgr/source/api2/apifactoryimpl.cxx +++ /dev/null @@ -1,352 +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 "apifactoryimpl.hxx" - -#include "setobjects.hxx" -#include "groupobjects.hxx" - -#include "configset.hxx" -#include "configpath.hxx" -#include "template.hxx" -#include "noderef.hxx" -#include "objectregistry.hxx" -#include "attributes.hxx" - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------- -// class ReadOnlyObjectFactory -//----------------------------------------------------------------------------- - -ReadOnlyObjectFactory::ReadOnlyObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry) -: Factory(pRegistry) -, m_rProvider(rProvider) -{ -} -//----------------------------------------------------------------------------- - -ReadOnlyObjectFactory::~ReadOnlyObjectFactory() -{ -} -//----------------------------------------------------------------------------- - -NodeElement* ReadOnlyObjectFactory::doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate) -{ - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a group member without a tree"); - OSL_ENSURE(aNode.isValid(), "ERROR: trying to create a group member without a node"); - OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create a group member"); - OSL_ENSURE(!aTree->isRootNode(aNode), "ERROR: trying to create a group member on a root node"); - if (aTree->isRootNode(aNode)) - return 0; - - NodeElement* pRootElement = makeElement(aTree,aTree->getRootNode()); - OSL_ENSURE(pRootElement, "Could not create root element of tree - cannot create group member object"); - if (!pRootElement) - return 0; - - uno::Reference<uno::XInterface> aRootRelease(pRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - ApiTreeImpl& rRootContext = getImplementation(*pRootElement); - - NodeElement * pResult = 0; - if (!pSetElementTemplate) - { - OInnerGroupInfo * pNewObject = new OInnerGroupInfo(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OInnerSetInfo * pNewObject = new OInnerSetInfo(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - - return pResult; -} -//----------------------------------------------------------------------------- - -TreeElement* ReadOnlyObjectFactory::doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions) -{ - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a root object without a tree"); - - TreeElement * pResult = 0; - if (!pSetElementTemplate) - { - ORootElementGroupInfo * pNewObject = new ORootElementGroupInfo(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - ORootElementSetInfo * pNewObject = new ORootElementSetInfo(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - return pResult; -} - -//----------------------------------------------------------------------------- -SetElement* ReadOnlyObjectFactory::doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree, configuration::Template* pSetElementTemplate) -{ - OSL_ENSURE(aElementTree.is(), "ERROR: trying to create a set element object without a tree"); - - rtl::Reference< configuration::Tree > aTree( aElementTree.get() ); - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a set element object without a tree"); - - ApiTreeImpl * pParentContext = 0; - uno::Reference<uno::XInterface> aParentRelease; - - rtl::Reference< configuration::Tree > aParentTree = aTree->getContextTree(); - if (!configuration::isEmpty(aParentTree.get())) - { - //configuration::NodeRef aParentNode = aTree.getContextNode(); - configuration::NodeRef aParentRoot = aParentTree->getRootNode(); - if (NodeElement* pParentRootElement = makeElement(aParentTree,aParentRoot) ) - { - aParentRelease = uno::Reference<uno::XInterface>(pParentRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - pParentContext = &getImplementation(*pParentRootElement); - } - } - - SetElement * pResult = 0; - if (!pSetElementTemplate) - { - OSetElementGroupInfo * pNewObject = new OSetElementGroupInfo(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OSetElementSetInfo * pNewObject = new OSetElementSetInfo(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - return pResult; -} -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// class UpdateObjectFactory -//----------------------------------------------------------------------------- - -UpdateObjectFactory::UpdateObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry) -: Factory(pRegistry) -, m_rProvider(rProvider) -{ -} -//----------------------------------------------------------------------------- - -UpdateObjectFactory::~UpdateObjectFactory() -{ -} -//----------------------------------------------------------------------------- - -bool UpdateObjectFactory::implIsReadOnly(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) -{ - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create an object without a tree"); - OSL_ENSURE(aNode.isValid(), "ERROR: trying to create an object without a node"); - OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create an object"); - - return aTree->getAttributes(aNode).isReadonly(); -} -//----------------------------------------------------------------------------- - -NodeElement* UpdateObjectFactory::doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate) -{ - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a group member without a tree"); - OSL_ENSURE(aNode.isValid(), "ERROR: trying to create a group member without a node"); - OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create a group"); - - NodeElement* pRootElement = makeElement(aTree,aTree->getRootNode()); - OSL_ENSURE(pRootElement, "Could not create root element of tree - cannot create group member object"); - if (!pRootElement) - return 0; - - uno::Reference<uno::XInterface> aRootRelease(pRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - ApiTreeImpl& rRootContext = getImplementation(*pRootElement); - - NodeElement * pResult = 0; - - if (implIsReadOnly(aTree,aNode)) - { - if (!pSetElementTemplate) - { - OInnerGroupInfo * pNewObject = new OInnerGroupInfo(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OInnerSetInfo * pNewObject = new OInnerSetInfo(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - else - { - if (!pSetElementTemplate) - { - OInnerGroupUpdate * pNewObject = new OInnerGroupUpdate(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else if (pSetElementTemplate->isInstanceValue()) - { - OInnerValueSetUpdate * pNewObject = new OInnerValueSetUpdate(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OInnerTreeSetUpdate * pNewObject = new OInnerTreeSetUpdate(rRootContext, aNode); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - - return pResult; -} -//----------------------------------------------------------------------------- - -TreeElement* UpdateObjectFactory::doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions) -{ - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a root object without a tree"); - - TreeElement * pResult = 0; - if (implIsReadOnly(aTree,aTree->getRootNode())) - { - OSL_ENSURE(false, "WARNING: Trying to create an 'Update Access' on a read-only tree/node"); - if (!pSetElementTemplate) - { - ORootElementGroupInfo * pNewObject = new ORootElementGroupInfo(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - ORootElementSetInfo * pNewObject = new ORootElementSetInfo(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - else - { - if (!pSetElementTemplate) - { - ORootElementGroupUpdate * pNewObject = new ORootElementGroupUpdate(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else if (pSetElementTemplate->isInstanceValue()) - { - ORootElementValueSetUpdate * pNewObject = new ORootElementValueSetUpdate(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - ORootElementTreeSetUpdate * pNewObject = new ORootElementTreeSetUpdate(m_rProvider, aTree, _xOptions); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - - return pResult; -} - -//----------------------------------------------------------------------------- -SetElement* UpdateObjectFactory::doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree, configuration::Template* pSetElementTemplate) -{ - OSL_ENSURE(aElementTree.is(), "ERROR: trying to create a set element object without a tree"); - - rtl::Reference< configuration::Tree > aTree( aElementTree.get() ); - OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a set element object without a tree"); - - ApiTreeImpl * pParentContext = 0; - uno::Reference<uno::XInterface> aParentRelease; - - rtl::Reference< configuration::Tree > aParentTree = aTree->getContextTree(); - if (!configuration::isEmpty(aParentTree.get())) - { - //configuration::NodeRef aParentNode = aTree.getContextNode(); - configuration::NodeRef aParentRoot = aParentTree->getRootNode(); - if (NodeElement* pParentRootElement = makeElement(aParentTree,aParentRoot) ) - { - aParentRelease = uno::Reference<uno::XInterface>(pParentRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - pParentContext = &getImplementation(*pParentRootElement); - } - } - - SetElement * pResult = 0; - if (implIsReadOnly(aTree,aTree->getRootNode())) - { - if (!pSetElementTemplate) - { - OSetElementGroupInfo * pNewObject = new OSetElementGroupInfo(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OSetElementSetInfo * pNewObject = new OSetElementSetInfo(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - else - { - if (!pSetElementTemplate) - { - OSetElementGroupUpdate * pNewObject = new OSetElementGroupUpdate(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else if (pSetElementTemplate->isInstanceValue()) - { - OSetElementValueSetUpdate * pNewObject = new OSetElementValueSetUpdate(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - else - { - OSetElementTreeSetUpdate * pNewObject = new OSetElementTreeSetUpdate(aTree,m_rProvider,pParentContext); - pNewObject->acquire(); - pResult = &pNewObject->getElementClass(); - } - } - return pResult; -} -//----------------------------------------------------------------------------- - } -} - diff --git a/configmgr/source/api2/apifactoryimpl.hxx b/configmgr/source/api2/apifactoryimpl.hxx deleted file mode 100644 index 7f9408dd60f2..000000000000 --- a/configmgr/source/api2/apifactoryimpl.hxx +++ /dev/null @@ -1,68 +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_API_FACTORYIMPL_HXX_ -#define CONFIGMGR_API_FACTORYIMPL_HXX_ - -#include "apifactory.hxx" - -namespace configmgr -{ - namespace configapi - { - class ApiProvider; - // used to create UNO objects - class ReadOnlyObjectFactory : public Factory - { - ApiProvider& m_rProvider; - public: - ReadOnlyObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry); - ~ReadOnlyObjectFactory(); - - virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate); - virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions); - virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate); - }; - // used to create UNO objects - class UpdateObjectFactory : public Factory - { - ApiProvider& m_rProvider; - public: - UpdateObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry); - ~UpdateObjectFactory(); - - virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate); - virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions); - virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate); - private: - bool implIsReadOnly(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); - }; - - } -} - -#endif // CONFIGMGR_API_FACTORYIMPL_HXX_ diff --git a/configmgr/source/api2/apinodeaccess.cxx b/configmgr/source/api2/apinodeaccess.cxx deleted file mode 100644 index 1c064efadec4..000000000000 --- a/configmgr/source/api2/apinodeaccess.cxx +++ /dev/null @@ -1,178 +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 "apinodeaccess.hxx" - -#include "apitreeimplobj.hxx" -#include "apifactory.hxx" - -#include "apitreeaccess.hxx" -#include "noderef.hxx" - -#include "anynoderef.hxx" -#include "valueref.hxx" - -#include "configset.hxx" -#include "configpath.hxx" -#include "confignotifier.hxx" - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------- - -NodeAccess::~NodeAccess() -{ -} -//----------------------------------------------------------------------------- - -configuration::NodeRef NodeAccess::getNodeRef() const -{ - return doGetNode(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Tree > NodeAccess::getTreeRef() const -{ - return getApiTree().getTree(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Tree > NodeAccess::getTree() const -{ - return getApiTree().getTree(); -} -//----------------------------------------------------------------------------- - -void NodeAccess::checkAlive() const -{ - getApiTree().checkAlive(); -} -//----------------------------------------------------------------------------- - -void NodeAccess::disposeNode() -{ - getApiTree().disposeNode(getNodeRef(), getUnoInstance()); -} -//----------------------------------------------------------------------------- - - -Factory& NodeAccess::getFactory() const -{ - return getApiTree().getFactory(); -} -//----------------------------------------------------------------------------- - -Notifier NodeAccess::getNotifier() const -{ - return getApiTree().getNotifier(); -} - -//----------------------------------------------------------------------------- - -uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::AnyNodeRef const& aNode) -{ - if (!configuration::isEmpty(aTree.get()) && aNode.isValid()) - { - if (aNode.isNode()) - { - configuration::NodeRef aInnerNode = aNode.toNode(); - - if (configuration::isStructuralNode(aTree,aInnerNode)) - return uno::makeAny( rFactory.makeUnoElement(aTree,aInnerNode) ); - - else - return configuration::getSimpleElementValue(aTree,aInnerNode); - } - else - { - return configuration::getSimpleValue(aTree,aNode.toValue()); - } - } - - return uno::Any(); -} -//----------------------------------------------------------------------------- - -uno::Any makeInnerElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) -{ - if (!configuration::isEmpty(aTree.get()) && aNode.isValid()) - { - OSL_ENSURE(configuration::isStructuralNode(aTree,aNode), "Trying to makeInnerElement for a simple value"); - - return uno::makeAny( rFactory.makeUnoElement(aTree,aNode) ); - } - - return uno::Any(); -} -//----------------------------------------------------------------------------- - -uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aTree) -{ - if (aTree.is()) - { - return uno::makeAny( rFactory.makeUnoSetElement(aTree) ); - } - - return uno::Any(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::ElementTree > extractElementTree(configapi::Factory& rFactory, uno::Any const& aElement, rtl::Reference< configuration::Template > const& aTemplate ) -{ - OSL_ENSURE(aTemplate.is(), "ERROR: Need a template to extract a matching set element"); - - if (SetElement* pSetElement = rFactory.extractSetElement(aElement)) - { - rtl::Reference<configuration::Template> aFoundTemplate = pSetElement->getTemplateInfo(); - if (aFoundTemplate.is()) - { - if (aFoundTemplate != aTemplate) - throw configuration::TypeMismatch(aFoundTemplate->getPathString(), aTemplate->getPathString()); - - return pSetElement->getElementRef( ); - } - } - return rtl::Reference< configuration::ElementTree >(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Template > NodeSetInfoAccess::getElementInfo() const -{ - rtl::Reference<configuration::Template> aTemplate = getTree()->extractElementInfo(getNodeRef()); - - OSL_ENSURE(aTemplate.is(), "ERROR: Set must have an element template"); - - return aTemplate; -} - -} -} diff --git a/configmgr/source/api2/apinodeaccess.hxx b/configmgr/source/api2/apinodeaccess.hxx deleted file mode 100644 index 39ad1b120f05..000000000000 --- a/configmgr/source/api2/apinodeaccess.hxx +++ /dev/null @@ -1,172 +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_API_NODEACCESS_HXX_ -#define CONFIGMGR_API_NODEACCESS_HXX_ - -#include "sal/config.h" - -#include "boost/utility.hpp" - -#include "datalock.hxx" -#include "utility.hxx" -#include "noderef.hxx" - -namespace osl { class Mutex; } - -namespace configmgr -{ - namespace configuration - { - class AnyNodeRef; - class NodeRef; - class Tree; - } - namespace configapi - { - class Factory; - class Notifier; - class SetElement; - - class ApiTreeImpl; - - namespace uno = com::sun::star::uno; - - // API object implementation wrappers - // these objects just provide the pieces needed to navigate and manipulate trees and nodes - - // The common part of all nodes, provides all you need to read and listen - class NodeAccess : private boost::noncopyable - { - public: - virtual ~NodeAccess(); - - // model access - configuration::NodeRef getNodeRef() const; - rtl::Reference< configuration::Tree > getTreeRef() const; - rtl::Reference< configuration::Tree > getTree() const; - - // self-locked methods for dispose handling - void checkAlive() const; - void disposeNode(); - - // api object handling - uno::XInterface* getUnoInstance() const - { return doGetUnoInstance(); } - Factory& getFactory() const; - Notifier getNotifier() const; - - protected: - virtual configuration::NodeRef doGetNode() const = 0; - virtual uno::XInterface* doGetUnoInstance() const = 0; - virtual ApiTreeImpl& getApiTree() const = 0; - }; - - /** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing node <var>aNode</var>. - <p> Uses the <type scope='configmgr::configapi'>Factory</type> provided - to create service implementations wrapping inner nodes</p> - <p> returns VOID if <var>aNode</var> is empty.</p> - */ - uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::AnyNodeRef const& aNode); - - /** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing inner node <var>aNode</var>. - <p> Uses the <type scope='configmgr::configapi'>Factory</type> provided - to create service implementations wrapping inner nodes</p> - <p> returns VOID if <var>aNode</var> is empty.</p> - */ - uno::Any makeInnerElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); - - /** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing set element <var>aElement</var>. - <p> Uses the <type scope='configmgr::configapi'>Factory</type> provided - to create service implementations wrapping inner nodes</p> - <p> returns VOID if <var>aNode</var> is empty.</p> - */ - uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aTree); - - - // Info interfaces for Group Nodes - class NodeGroupInfoAccess : public NodeAccess - { - public: - // currently only used for tagging group nodes - }; - - // Info interfaces for Set Nodes - class NodeSetInfoAccess : public NodeAccess - { - friend class SetElement; - public: - rtl::Reference< configuration::Template > getElementInfo() const; - }; - - /** extracts a <type scope='configmgr::configuration'>ElementTree</type> from a <type scope='com::sun::star::uno'>Any</type> - which must contain an object which wraps an instance of the template available in <var>aTemplate</var>. - <p> Uses the <type scope='configmgr::configapi'>Factory</type> provided - to resolve inner nodes (which may suppose that the object was created using the same factory)</p> - <p> returns an empty tree if <var>aElement</var> is empty.</p> - <p> May throw exceptions if the type doesn't match the template.</p> - */ - rtl::Reference< configuration::ElementTree > extractElementTree(Factory& rFactory, uno::Any const& aElement, rtl::Reference< configuration::Template > const& aTemplate ); - - /// wraps a NodeAccess; provides both object and provider (read) locks, - // ensures object was not disposed - template <class Access> - class GuardedNodeData - { - UnoApiLock m_aLock; - Access & m_rNode; - public: - GuardedNodeData(Access& rNode); - public: - Access& get() const { return m_rNode; } - - rtl::Reference< configuration::Tree > getTree() const; - configuration::NodeRef getNode() const; - }; - - template <class Access> - GuardedNodeData<Access>::GuardedNodeData(Access& rNode) - : m_rNode(rNode) - { - rNode.checkAlive(); - } - - template <class Access> - rtl::Reference< configuration::Tree > GuardedNodeData<Access>::getTree() const - { - return m_rNode.getTree(); - } - - template <class Access> - configuration::NodeRef GuardedNodeData<Access>::getNode() const - { - return m_rNode.getNodeRef(); - } - } -} - -#endif // CONFIGMGR_API_NODEACCESS_HXX_ diff --git a/configmgr/source/api2/apinodeupdate.cxx b/configmgr/source/api2/apinodeupdate.cxx deleted file mode 100644 index 9251520bbe05..000000000000 --- a/configmgr/source/api2/apinodeupdate.cxx +++ /dev/null @@ -1,169 +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 "apinodeupdate.hxx" -#include "apitreeimplobj.hxx" -#include "apitreeaccess.hxx" -#include "noderef.hxx" -#include "configset.hxx" -#include "configgroup.hxx" -#include "configpath.hxx" -#include "apifactory.hxx" - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------- - -NodeGroupAccess& withDefaultData(NodeGroupAccess& _aGroup) -{ - configuration::GroupDefaulter::ensureDataAvailable(_aGroup.getTreeRef(),_aGroup.getNodeRef(), - _aGroup.getApiTree().getDefaultProvider()); - return _aGroup; -} -//----------------------------------------------------------------------------- - -configuration::GroupUpdater NodeGroupAccess::getNodeUpdater() -{ - return configuration::GroupUpdater(getTree(),getNodeRef(), getApiTree().getProvider().getTypeConverter()); -} -//----------------------------------------------------------------------------- - -configuration::GroupDefaulter NodeGroupAccess::getNodeDefaulter() -{ - return configuration::GroupDefaulter(getTree(),getNodeRef(), getApiTree().getDefaultProvider()); -} -//----------------------------------------------------------------------------- - -configuration::SetElementFactory NodeTreeSetAccess::getElementFactory() -{ - configuration::TemplateProvider aProvider = configuration::SetElementFactory::findTemplateProvider(getTree(),getNodeRef()); - return configuration::SetElementFactory(aProvider); -} -//----------------------------------------------------------------------------- - -configuration::SetDefaulter NodeSetAccess::getNodeDefaulter() -{ - return configuration::SetDefaulter(getTree(),getNodeRef(), getApiTree().getDefaultProvider()); -} -//----------------------------------------------------------------------------- - -configuration::TreeSetUpdater NodeTreeSetAccess::getNodeUpdater() -{ - return configuration::TreeSetUpdater(getTree(),getNodeRef(),getElementInfo()); -} -//----------------------------------------------------------------------------- - - -configuration::ValueSetUpdater NodeValueSetAccess::getNodeUpdater() -{ - return configuration::ValueSetUpdater(getTree(),getNodeRef(),getElementInfo(), getApiTree().getProvider().getTypeConverter()); -} -//----------------------------------------------------------------------------- - -void attachSetElement(NodeTreeSetAccess& aSet, SetElement& aElement) -{ - OSL_ENSURE( configuration::NodeID(aSet.getTreeRef(),aSet.getNodeRef()) == - configuration::NodeID(rtl::Reference< configuration::Tree >(aElement.getTreeRef()->getContextTree()),aElement.getTreeRef()->getContextNodeRef()), - "ERROR: Attaching an unrelated SetElement to a SetInfoAccess"); - - aElement.haveNewParent(&aSet); -} -//----------------------------------------------------------------------------- - -bool attachSetElement(NodeTreeSetAccess& aSet, rtl::Reference< configuration::ElementTree > const& aElementTree) -{ - OSL_ENSURE( configuration::NodeID(aSet.getTreeRef(),aSet.getNodeRef()) == - configuration::NodeID(rtl::Reference< configuration::Tree >(aElementTree->getContextTree()), aElementTree->getContextNodeRef()), - "ERROR: Attaching an unrelated ElementTree to a SetInfoAccess"); - - Factory& rFactory = aSet.getFactory(); - if (SetElement* pSetElement = rFactory.findSetElement(aElementTree)) - { - // the factory always does an extra acquire - uno::Reference<uno::XInterface> xReleaseSetElement(pSetElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - - attachSetElement(aSet, *pSetElement); - return true; - } - else - return false; - -} -//----------------------------------------------------------------------------- - -void detachSetElement(SetElement& aElement) -{ - OSL_ENSURE( configuration::isEmpty(aElement.getTreeRef()->getContextTree()), - "ERROR: Detaching a SetElement that has a parent"); - - aElement.haveNewParent(0); -} -//----------------------------------------------------------------------------- - -bool detachSetElement(Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aElementTree) -{ - OSL_ENSURE( configuration::isEmpty(aElementTree->getContextTree()), - "ERROR: Detaching an ElementTree that has a parent"); - - if (SetElement* pSetElement = rFactory.findSetElement(aElementTree)) - { - // the factory always does an extra acquire - uno::Reference<uno::XInterface> xReleaseSetElement(pSetElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - - detachSetElement(*pSetElement); - return true; - } - else - return false; - -} -//----------------------------------------------------------------------------- - -UpdateGuardImpl::UpdateGuardImpl(NodeGroupAccess& rNode) -: m_rNode(rNode) -{ - rNode.checkAlive(); -} -//----------------------------------------------------------------------------- - -UpdateGuardImpl::UpdateGuardImpl(NodeSetAccess& rNode) -: m_rNode(rNode) -{ -} -//----------------------------------------------------------------------------- - -UpdateGuardImpl::~UpdateGuardImpl() throw () -{ -} -//----------------------------------------------------------------------------- - } -} diff --git a/configmgr/source/api2/apinodeupdate.hxx b/configmgr/source/api2/apinodeupdate.hxx deleted file mode 100644 index 23c5a32257c9..000000000000 --- a/configmgr/source/api2/apinodeupdate.hxx +++ /dev/null @@ -1,174 +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_API_NODEUPDATE_HXX_ -#define CONFIGMGR_API_NODEUPDATE_HXX_ - -#include "sal/config.h" - -#include "boost/utility.hpp" - -#include "apinodeaccess.hxx" -#include "utility.hxx" - -namespace configmgr -{ - namespace configuration - { - class GroupUpdater; - class GroupDefaulter; - class TreeSetUpdater; - class ValueSetUpdater; - class SetDefaulter; - class SetElementFactory; - - class NodeUpdate; - } - namespace configapi - { - class SetElement; - - // API object implementation wrappers - // these objects just provide the pieces needed to navigate and manipulate trees and nodes - - // Updating access for Group Nodes - class NodeGroupAccess : public NodeGroupInfoAccess - { - public: - typedef configuration::GroupUpdater NodeUpdater; - typedef configuration::GroupDefaulter NodeDefaulter; - NodeUpdater getNodeUpdater(); - NodeDefaulter getNodeDefaulter(); - - /** ensures that the default data for a group is loaded (if possible) - <p>Must be called outside of any locks !</p> - */ - friend NodeGroupAccess& withDefaultData(NodeGroupAccess& aGroup); - }; - - // Updating access for Set Nodes - class NodeSetAccess : public NodeSetInfoAccess - { - public: - typedef struct SetUpdater_PlaceHolder NodeUpdater; - typedef configuration::SetDefaulter NodeDefaulter; - NodeDefaulter getNodeDefaulter(); - }; - - // Updating access for Set Nodes containing whole trees - class NodeTreeSetAccess : public NodeSetAccess - { - public: - typedef configuration::TreeSetUpdater NodeUpdater; - NodeUpdater getNodeUpdater(); - - configuration::SetElementFactory getElementFactory(); - }; - - // Updating access for Set Nodes containing simple values - class NodeValueSetAccess : public NodeSetAccess - { - public: - typedef configuration::ValueSetUpdater NodeUpdater; - NodeUpdater getNodeUpdater(); - }; - - /// informs a <type>SetElement</type> that it should now link to the given SetElement - void attachSetElement(NodeTreeSetAccess& aSet, SetElement& aElement); - - /// informs a <type>SetElement</type> that it should now link to the given SetElement - bool attachSetElement(NodeTreeSetAccess& aSet, rtl::Reference< configuration::ElementTree > const& aElementTree); - - /// informs a <type>SetElement</type> that it should now unlink from its owning SetElement - void detachSetElement(SetElement& aElement); - - /// informs a <type>SetElement</type> that it should now unlink from its owning SetElement - bool detachSetElement(Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aElementTree); - - /// Guarding and locking implementations - /// guards a NodeGroupAccess, or NodeSetAccess; provides an object (write)/provider(read) lock; ensures object was not disposed - class UpdateGuardImpl : private boost::noncopyable - { - NodeAccess& m_rNode; - public: - UpdateGuardImpl(NodeGroupAccess& rNode); - UpdateGuardImpl(NodeSetAccess& rNode); - ~UpdateGuardImpl() throw (); - public: - NodeAccess& get() const { return m_rNode; } - - void downgrade() { } - }; - - // Thin Wrappers around NodeAccesses: Provide guarding and convenient access - /// wraps a NodeAccess; provides an object (write)/provider(read) lock, ensures object was not disposed - template <class Access> - class GuardedNodeUpdate - { - UnoApiLock m_aLock; - UpdateGuardImpl m_aImpl; - public: - GuardedNodeUpdate(Access& rNode) : m_aImpl(rNode) {} - public: - Access& get() const { return static_cast<Access&>(m_aImpl.get()); } - - rtl::Reference< configuration::Tree > getTree() const; - configuration::NodeRef getNode() const; - - typename Access::NodeUpdater getNodeUpdater() const; - typename Access::NodeDefaulter getNodeDefaulter() const; - - void clearForBroadcast() { m_aImpl.downgrade(); } - }; - - template <class Access> - rtl::Reference< configuration::Tree > GuardedNodeUpdate<Access>::getTree() const - { - return get().getTree(); - } - - template <class Access> - configuration::NodeRef GuardedNodeUpdate<Access>::getNode() const - { - return get().getNodeRef(); - } - - template <class Access> - typename Access::NodeUpdater GuardedNodeUpdate<Access>::getNodeUpdater() const - { - return get().getNodeUpdater(); - } - - template <class Access> - typename Access::NodeDefaulter GuardedNodeUpdate<Access>::getNodeDefaulter() const - { - return get().getNodeDefaulter(); - } - } -} - -#endif // CONFIGMGR_API_NODEUPDATE_HXX_ diff --git a/configmgr/source/api2/apinotifierimpl.cxx b/configmgr/source/api2/apinotifierimpl.cxx deleted file mode 100644 index 2bffaef03381..000000000000 --- a/configmgr/source/api2/apinotifierimpl.cxx +++ /dev/null @@ -1,329 +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 "apinotifierimpl.hxx" -#include "apinodeaccess.hxx" -#include "noderef.hxx" -#include "valueref.hxx" -#include "confignotifier.hxx" -#include "configexcept.hxx" -#include <osl/diagnose.h> - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------------- - namespace lang = css::lang; - namespace util = css::util; - namespace beans = css::beans; - -// Generic Notifier Support Implementations -//----------------------------------------------------------------------------------- - -/// add a Listener to the notifier of a NodeAccess -template <class Listener> -inline -void genericAddListener(NodeAccess& rNode, const uno::Reference< Listener >& xListener ) -{ - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - aGuardedNotifier->add(rNode.getNodeRef(), xListener); -} - -/// remove a Listener from the notifier of a NodeAccess -template <class Listener> -inline -void genericRemoveListener(NodeAccess& rNode, const uno::Reference< Listener >& xListener ) -{ - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - aGuardedNotifier->remove(rNode.getNodeRef(), xListener); -} - - -/** add a Listener for all or some children of a NodeAccess to its notifier - <p> If the name given is empty, the listener will be added to all children of the node</p> - @returns - <TRUE/> if the node was found, or the name was empty - <FALSE/> if the named node wasn't found -*/ -template <class Listener> -inline -bool genericAddChildListener(NodeGroupInfoAccess& rNode, const uno::Reference< Listener >& xListener, const rtl::OUString& sName ) -{ - if (sName.getLength() != 0) - { - GuardedNodeData<NodeAccess> aGuardedNode( rNode ); // guard access to children - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - - rtl::Reference< configuration::Tree > aTree( aGuardedNode.getTree() ); - configuration::NodeRef aNode( aGuardedNode.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode); - - if (!aTree->hasChild(aNode,aChildName)) return false; - - aGuardedNotifier->addForOne(aNode, xListener, aChildName); - } - else - { - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - - aGuardedNotifier->addForAll(rNode.getNodeRef(), xListener); - - // always ok, as we addreess no specific NodeRef - } - return true; -} - -/** remove a Listener from all or some children of a NodeAccess to its notifier - <p> If the name given is empty, the listener will be removed from any children of the node</p> - @returns - <TRUE/> if the node was found, or the name was empty - <FALSE/> if the named node wasn't found -*/ -template <class Listener> -inline -bool genericRemoveChildListener(NodeGroupInfoAccess& rNode, const uno::Reference< Listener >& xListener, const rtl::OUString& sName ) -{ - if (sName.getLength() != 0) - { - GuardedNodeData<NodeAccess> aGuardedNode( rNode ); // guard access to children - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - - rtl::Reference< configuration::Tree > aTree( aGuardedNode.getTree() ); - configuration::NodeRef aNode( aGuardedNode.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode); - - if (!aTree->hasChild(aNode,aChildName)) return false; - - aGuardedNotifier->removeForOne(aNode, xListener, aChildName); - } - else - { - GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier - - aGuardedNotifier->removeForAll(rNode.getNodeRef(), xListener); - - // always ok, as we addreess no specific NodeRef - } - return true; -} - - - -// XComponent -//----------------------------------------------------------------------------------- -void implAddListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - genericAddListener(rNode,xListener); -} - -void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - genericRemoveListener(rNode,xListener); -} - -// XContainer -//----------------------------------------------------------------------------------- -void implAddListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - genericAddListener(rNode,xListener); -} - -void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - genericRemoveListener(rNode,xListener); -} - -// XChangesNotifier -//----------------------------------------------------------------------------------- - -void implAddListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - genericAddListener(rNode,xListener); -} - -void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - genericRemoveListener(rNode,xListener); -} - -// XMultiPropertySet -//----------------------------------------------------------------------------------- - -void implAddListener( NodeAccess& rNode, const uno::Reference< beans::XPropertiesChangeListener >& xListener, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException) -{ - - GuardedNotifier impl( rNode ); - - // TODO: is an exception for unknown names allowed/needed ? - impl->add(rNode.getNodeRef(), xListener, aPropertyNames); -} - - -void implRemoveListener( NodeAccess& rNode, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException) -{ - genericRemoveListener(rNode,xListener); -} - -// XPropertySet (manages listeners associated with named child node) -//----------------------------------------------------------------------------------- - -// XPropertySet - VetoableChangeListeners -//----------------------------------------------------------------------------------- - -void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - if (!genericAddChildListener(rNode,xListener,sPropertyName)) - { - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found !")), - rNode.getUnoInstance() ); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found:")) += ex.message(), - rNode.getUnoInstance() ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - -} - - -void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - if (!genericRemoveChildListener(rNode,xListener,sPropertyName)) - { - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found !")), - rNode.getUnoInstance() ); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found:")) += ex.message(), - rNode.getUnoInstance() ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -// XPropertySet - PropertyChangeListeners -//----------------------------------------------------------------------------------- - -void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - if (!genericAddChildListener(rNode,xListener,sPropertyName)) - { - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found !")), - rNode.getUnoInstance() ); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found:")) += ex.message(), - rNode.getUnoInstance() ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - if (!genericRemoveChildListener(rNode,xListener,sPropertyName)) - { - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found !")), - rNode.getUnoInstance() ); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - throw css::beans::UnknownPropertyException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found:")) += ex.message(), - rNode.getUnoInstance() ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -//----------------------------------------------------------------------------------- - } // namespace configapi - -} // namespace configmgr - - diff --git a/configmgr/source/api2/apinotifierimpl.hxx b/configmgr/source/api2/apinotifierimpl.hxx deleted file mode 100644 index c5ca7217aad1..000000000000 --- a/configmgr/source/api2/apinotifierimpl.hxx +++ /dev/null @@ -1,102 +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_API_NOTIFIERIMPL_HXX_ -#define CONFIGMGR_API_NOTIFIERIMPL_HXX_ - -#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif -#include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/util/XChangesNotifier.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XMultiPropertySet.hpp> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - /* implementations of the event notification interfaces - supported by a node within the configuration tree. - */ - namespace configapi - { - class NodeAccess; - class NodeSetInfoAccess; - class NodeGroupInfoAccess; - - // Notification support - - // XComponent - void implAddListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException); - - void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException); - - // XContainer - void implAddListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - // XChangesNotifier - void implAddListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - // XPropertySet - VetoableChangeListeners - void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XPropertySet - void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName ) - throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - void implAddListener( NodeAccess& rNode, const uno::Reference< css::beans::XPropertiesChangeListener >& xListener, const uno::Sequence< rtl::OUString >& sPropertyNames ) - throw(uno::RuntimeException); - - void implRemoveListener( NodeAccess& rNode, const uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException); - - } - -} -#endif // CONFIGMGR_API_NOTIFIERIMPL_HXX_ - - diff --git a/configmgr/source/api2/apiserviceinfo.cxx b/configmgr/source/api2/apiserviceinfo.cxx deleted file mode 100644 index 4aed033127e4..000000000000 --- a/configmgr/source/api2/apiserviceinfo.cxx +++ /dev/null @@ -1,337 +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 "apiserviceinfo.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//======================================================================== -//= service names -//======================================================================== - -//======================================================================== -//= service infos -//======================================================================== - -//-- ACCESS (CONTAINER) ROLES ----------------------------- - -#define CFG_SVCLIST_SETACCESS \ - "com.sun.star.configuration.ConfigurationAccess", \ - "com.sun.star.configuration.SetAccess", \ - "com.sun.star.configuration.HierarchyAccess", \ - "com.sun.star.configuration.SimpleSetAccess" - -#define CFG_SVCLIST_GROUPACCESS \ - "com.sun.star.configuration.ConfigurationAccess", \ - "com.sun.star.configuration.GroupAccess", \ - "com.sun.star.configuration.HierarchyAccess", \ - "com.sun.star.configuration.PropertyHierarchy" - -#define CFG_SVCLIST_SETUPDATE \ - "com.sun.star.configuration.ConfigurationUpdateAccess", \ - "com.sun.star.configuration.SetUpdate", \ - "com.sun.star.configuration.SimpleSetUpdate", \ - "com.sun.star.configuration.ConfigurationContainer", /* Obsolete */ \ - CFG_SVCLIST_SETACCESS - -#define CFG_SVCLIST_GROUPUPDATE \ - "com.sun.star.configuration.ConfigurationUpdateAccess", \ - "com.sun.star.configuration.GroupUpdate", \ - CFG_SVCLIST_GROUPACCESS - -//-- ELEMENT ROLES ---------------------------------------- - -#define CFG_SVCLIST_SETELEMENT \ - "com.sun.star.configuration.SetElement", \ - "com.sun.star.configuration.HierarchyElement" - -#define CFG_SVCLIST_GROUPELEMENT \ - "com.sun.star.configuration.GroupElement", \ - "com.sun.star.configuration.HierarchyElement" - -#define CFG_SVCLIST_ACCESSROOTELEMENT \ - "com.sun.star.configuration.AccessRootElement", \ - "com.sun.star.configuration.HierarchyElement" - -#define CFG_SVCLIST_UPDATEROOTELEMENT \ - "com.sun.star.configuration.UpdateRootElement", \ - CFG_SVCLIST_ACCESSROOTELEMENT - -//----------------------------------------------------------------------------- - -sal_Char const * const c_aNoServices[] = -{ - NULL -}; - -//----------------------------------------------------------------------------- - -sal_Char const * const c_aCreateAccessServiceNames[] = -{ - "com.sun.star.configuration.ConfigurationAccess", - "com.sun.star.configuration.HierarchyAccess", - "com.sun.star.configuration.HierarchyElement", - NULL -}; - -sal_Char const * const c_aCreateUpdateServiceNames[] = -{ - "com.sun.star.configuration.ConfigurationUpdateAccess", - "com.sun.star.configuration.ConfigurationAccess", - "com.sun.star.configuration.HierarchyAccess", - "com.sun.star.configuration.HierarchyElement", - NULL -}; - -//----------------------------------------------------------------------------- - -sal_Char const * const c_aUserAdministrationServices[] = -{ - "com.sun.star.configuration.UserAdministration", - "com.sun.star.configuration.SimpleSetUpdate", - "com.sun.star.configuration.SimpleSetAccess", - "com.sun.star.configuration.ConfigurationContainer", // Obsolete - NULL -}; - -sal_Char const * const c_aGroupAdministrationServices[] = -{ - "com.sun.star.configuration.GroupAdministration", - "com.sun.star.configuration.SimpleSetUpdate", - "com.sun.star.configuration.SimpleSetAccess", - "com.sun.star.configuration.ConfigurationContainer", // Obsolete - NULL -}; - -//-- ROLE COMBINATIONS ------------------ - -//-- GroupElements - -sal_Char const * const c_aInnerGroupAccessServices[] = -{ - CFG_SVCLIST_GROUPACCESS, - CFG_SVCLIST_GROUPELEMENT, - NULL -}; - -sal_Char const * const c_aInnerGroupUpdateServices[] = -{ - CFG_SVCLIST_GROUPUPDATE, - CFG_SVCLIST_GROUPELEMENT, - NULL -}; - -sal_Char const * const c_aInnerSetAccessServices[] = -{ - CFG_SVCLIST_SETACCESS, - CFG_SVCLIST_GROUPELEMENT, - NULL -}; - -sal_Char const * const c_aInnerSetUpdateServices[] = -{ - CFG_SVCLIST_SETUPDATE, - CFG_SVCLIST_GROUPELEMENT, - NULL -}; - -//-- SetElements - -sal_Char const * const c_aSetElementGroupAccessServices[] = -{ - CFG_SVCLIST_GROUPACCESS, - CFG_SVCLIST_SETELEMENT, - NULL -}; - -sal_Char const * const c_aSetElementGroupUpdateServices[] = -{ - CFG_SVCLIST_GROUPUPDATE, - CFG_SVCLIST_SETELEMENT, - NULL -}; - -sal_Char const * const c_aSetElementSetAccessServices[] = -{ - CFG_SVCLIST_SETACCESS, - CFG_SVCLIST_SETELEMENT, - NULL -}; - -sal_Char const * const c_aSetElementSetUpdateServices[] = -{ - CFG_SVCLIST_SETUPDATE, - CFG_SVCLIST_SETELEMENT, - NULL -}; - -//-- RootElements - -sal_Char const * const c_aRootGroupAccessServices[] = -{ - CFG_SVCLIST_GROUPACCESS, - CFG_SVCLIST_ACCESSROOTELEMENT, - NULL -}; - -sal_Char const * const c_aRootGroupUpdateServices[] = -{ - CFG_SVCLIST_GROUPUPDATE, - CFG_SVCLIST_UPDATEROOTELEMENT, - NULL -}; - -sal_Char const * const c_aRootSetAccessServices[] = -{ - CFG_SVCLIST_SETACCESS, - CFG_SVCLIST_ACCESSROOTELEMENT, - NULL -}; - -sal_Char const * const c_aRootSetUpdateServices[] = -{ - CFG_SVCLIST_SETUPDATE, - CFG_SVCLIST_UPDATEROOTELEMENT, - NULL -}; -//----------------------------------------------------------------------------- - -ServiceImplementationInfo const aInnerGroupInfoSI = -{ - "com.sun.star.comp.configuration.OInnerGroupInfoAccess", - c_aInnerGroupAccessServices, - NULL -}; -ServiceImplementationInfo const aInnerGroupUpdateSI = -{ - "com.sun.star.comp.configuration.OInnerGroupUpdateAccess", - c_aInnerGroupUpdateServices, - NULL -}; -ServiceImplementationInfo const aInnerSetInfoSI = -{ - "com.sun.star.comp.configuration.OInnerSetInfoAccess", - c_aInnerSetAccessServices, - NULL -}; -ServiceImplementationInfo const aInnerTreeSetSI = -{ - "com.sun.star.comp.configuration.OInnerTreeSetUpdateAccess", - c_aInnerSetUpdateServices, - NULL -}; -ServiceImplementationInfo const aInnerValueSetSI = -{ - "com.sun.star.comp.configuration.OInnerValueSetUpdateAccess", - c_aInnerSetUpdateServices, - NULL -}; -//----------------------------------------------------------------------------- - -ServiceImplementationInfo const aSetElementGroupInfoSI = -{ - "com.sun.star.comp.configuration.OSetElementGroupInfoAccess", - c_aSetElementGroupUpdateServices, - NULL -}; -ServiceImplementationInfo const aSetElementGroupUpdateSI = -{ - "com.sun.star.comp.configuration.OSetElementGroupUpdateAccess", - c_aSetElementGroupUpdateServices, - NULL -}; -ServiceImplementationInfo const aSetElementSetInfoSI = -{ - "com.sun.star.comp.configuration.OSetElementSetInfoAccess", - c_aSetElementSetAccessServices, - NULL -}; -ServiceImplementationInfo const aSetElementTreeSetSI = -{ - "com.sun.star.comp.configuration.OSetElementTreeSetUpdateAccess", - c_aSetElementSetUpdateServices, - NULL -}; -ServiceImplementationInfo const aSetElementValueSetSI = -{ - "com.sun.star.comp.configuration.OSetElementValueSetUpdateAccess", - c_aSetElementSetUpdateServices, - NULL -}; -//----------------------------------------------------------------------------- - -ServiceImplementationInfo const aRootElementGroupInfoSI = -{ - "com.sun.star.comp.configuration.ORootElementGroupInfoAccess", - c_aRootGroupAccessServices, - NULL -}; -ServiceImplementationInfo const aRootElementGroupUpdateSI = -{ - "com.sun.star.comp.configuration.ORootElementGroupUpdateAccess", - c_aRootGroupUpdateServices, - NULL -}; -ServiceImplementationInfo const aRootElementSetInfoSI = -{ - "com.sun.star.comp.configuration.ORootElementSetInfoAccess", - c_aRootSetAccessServices, - NULL -}; -ServiceImplementationInfo const aRootElementTreeSetUpdateSI = -{ - "com.sun.star.comp.configuration.ORootElementTreeSetUpdateAccess", - c_aRootSetUpdateServices, - NULL -}; -ServiceImplementationInfo const aRootElementValueSetUpdateSI = -{ - "com.sun.star.comp.configuration.ORootElementValueSetUpdateAccess", - c_aRootSetUpdateServices, - NULL -}; -//----------------------------------------------------------------------------- - -ServiceRegistrationInfo const aCreateReadAccessSI = -{ - NULL, //"com.sun.star.comp.configuration.ORootElementReadAccess", - c_aCreateAccessServiceNames -}; -ServiceRegistrationInfo const aCreateUpdateAccessSI = -{ - NULL, //"com.sun.star.comp.configuration.ORootElementUpdateAccess", - c_aCreateUpdateServiceNames -}; -//----------------------------------------------------------------------------- - - } -} diff --git a/configmgr/source/api2/apiserviceinfo.hxx b/configmgr/source/api2/apiserviceinfo.hxx deleted file mode 100644 index 3b529e864547..000000000000 --- a/configmgr/source/api2/apiserviceinfo.hxx +++ /dev/null @@ -1,69 +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_API_SERVICEINFO_HXX_ -#define CONFIGMGR_API_SERVICEINFO_HXX_ - -#include "serviceinfohelper.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - - extern sal_Char const * const c_aUserAdministrationServices[]; - extern sal_Char const * const c_aGroupAdministrationServices[]; - -//----------------------------------------------------------------------------- - extern ServiceImplementationInfo const aInnerGroupInfoSI; - extern ServiceImplementationInfo const aInnerGroupUpdateSI; - extern ServiceImplementationInfo const aInnerSetInfoSI; - extern ServiceImplementationInfo const aInnerTreeSetSI; - extern ServiceImplementationInfo const aInnerValueSetSI; - extern ServiceImplementationInfo const aSetElementGroupInfoSI; - extern ServiceImplementationInfo const aSetElementGroupUpdateSI; - extern ServiceImplementationInfo const aSetElementSetInfoSI; - extern ServiceImplementationInfo const aSetElementTreeSetSI; - extern ServiceImplementationInfo const aSetElementValueSetSI; - extern ServiceImplementationInfo const aRootElementGroupInfoSI; - extern ServiceImplementationInfo const aRootElementGroupUpdateSI; - extern ServiceImplementationInfo const aRootElementSetInfoSI; - extern ServiceImplementationInfo const aRootElementTreeSetUpdateSI; - extern ServiceImplementationInfo const aRootElementValueSetUpdateSI; - -//----------------------------------------------------------------------------- - extern ServiceRegistrationInfo const aCreateReadAccessSI; - extern ServiceRegistrationInfo const aCreateUpdateAccessSI; - -//----------------------------------------------------------------------------- - } -} -//----------------------------------------------------------------------------- - -#endif // CONFIGMGR_API_SERVICEINFO_HXX_ diff --git a/configmgr/source/api2/apitreeaccess.cxx b/configmgr/source/api2/apitreeaccess.cxx deleted file mode 100644 index 59fed7215bd3..000000000000 --- a/configmgr/source/api2/apitreeaccess.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 "apitreeaccess.hxx" - -#include "apitreeimplobj.hxx" -#include "configset.hxx" -#include "confignotifier.hxx" -#include "committer.hxx" -#include "apinodeaccess.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - - // self-locked methods for dispose handling -void NodeElement::checkAlive() const -{ - getApiTree().checkAlive(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Tree > TreeElement::getTree() const -{ - return getTreeRef(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Tree > TreeElement::getTreeRef() const -{ - return getApiTree().getTree(); -} -//----------------------------------------------------------------------------- - // self-locked methods for dispose handling -bool SetElement::disposeTree(bool bForce) -{ - return getApiTree().disposeTree(bForce); -} -//----------------------------------------------------------------------------- -Factory& TreeElement::getFactory() -{ - return getApiTree().getFactory(); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::ElementTree > SetElement::getElementRef() const -{ - return dynamic_cast< configuration::ElementTree * >(getTreeRef().get()); -} -//----------------------------------------------------------------------------- - -rtl::Reference< configuration::Template > SetElement::getTemplateInfo() const -{ - rtl::Reference< configuration::ElementTree > aTree(dynamic_cast< configuration::ElementTree * >(getTreeRef().get())); - OSL_ENSURE(aTree.is(), "This really must be a set element"); - return aTree->getTemplate(); -} -//----------------------------------------------------------------------------- - -void SetElement::haveNewParent(NodeSetInfoAccess* pNewParent) -{ - ApiTreeImpl* pNewParentImpl = pNewParent ? &pNewParent->getApiTree() : 0; - - this->getApiTree().haveNewParent( pNewParentImpl ); -} -//----------------------------------------------------------------------------- - -bool RootElement::disposeTree() -{ - return getRootTree().disposeTree(); -} -//----------------------------------------------------------------------------- - -Committer UpdateRootElement::getCommitter() -{ - return Committer(getRootTree()); -} - } -} - diff --git a/configmgr/source/api2/apitreeaccess.hxx b/configmgr/source/api2/apitreeaccess.hxx deleted file mode 100644 index 4c350779d7d0..000000000000 --- a/configmgr/source/api2/apitreeaccess.hxx +++ /dev/null @@ -1,176 +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_API_TREEACCESS_HXX_ -#define CONFIGMGR_API_TREEACCESS_HXX_ - -#include "sal/config.h" - -#include "boost/utility.hpp" -#include "rtl/ref.hxx" - -#include "datalock.hxx" -#include "options.hxx" -#include "utility.hxx" - -namespace osl { class Mutex; } - -namespace configmgr -{ -//----------------------------------------------------------------------------- - struct ServiceImplementationInfo; -//----------------------------------------------------------------------------- - namespace configuration - { - class ElementTree; - class Template; - class Tree; - } -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - namespace uno = com::sun::star::uno; -//----------------------------------------------------------------------------- - class Factory; - class Notifier; - class Committer; - class NodeSetInfoAccess; -//----------------------------------------------------------------------------- - // API object implementation wrappers - //------------------------------------------------------------------------- - class ApiTreeImpl; - class ApiRootTreeImpl; - - // these objects just provide the pieces needed to navigate and manipulate trees and nodes - - // A common base class for 'element' classes - class NodeElement: private boost::noncopyable - { - public: - virtual ~NodeElement() {} - - // self-locked methods for dispose handling - void checkAlive() const; - - // api object handling - uno::XInterface* getUnoInstance() const - { return doGetUnoInstance(); } - - ServiceImplementationInfo const * getServiceInfo() const - { return doGetServiceInfo(); } - private: - virtual uno::XInterface* doGetUnoInstance() const = 0; - virtual ServiceImplementationInfo const* doGetServiceInfo() const = 0; - virtual ApiTreeImpl& getApiTree() const = 0; - - friend class Factory; - }; -//----------------------------------------------------------------------------- - - // A class for tagging inner nodes - class InnerElement : public NodeElement - { - public: - // Only used as a tag - }; -//----------------------------------------------------------------------------- - - // A common base class for tree-owning elemnt classes - class TreeElement : public NodeElement - { - public: - // model access - rtl::Reference< configuration::Tree > getTreeRef() const; - rtl::Reference< configuration::Tree > getTree() const; - - // api object handling - Factory& getFactory(); - - protected: - virtual ApiTreeImpl& getApiTree() const = 0; - }; -//----------------------------------------------------------------------------- - - // Info interfaces for Set Elements - class SetElement : public TreeElement - { - public: - // self-locked methods for dispose handling - bool disposeTree(bool bForceDispose); - - void haveNewParent(NodeSetInfoAccess* pNewParent); - - rtl::Reference< configuration::ElementTree > getElementRef() const; - rtl::Reference< configuration::Template > getTemplateInfo() const; - }; -//----------------------------------------------------------------------------- - - // Info interfaces for Set Elements - class RootElement : public TreeElement - { - public: - bool disposeTree(); - protected: - virtual ApiRootTreeImpl& getRootTree() = 0; - }; -//----------------------------------------------------------------------------- - - // Info interfaces for Set Elements - class UpdateRootElement : public RootElement - { - public: - Committer getCommitter(); - }; - - // Thin Wrappers around TreeElements: Provide guarding and convenient access - /// wraps a TreeElement; provides an object (read) lock, ensures object was not disposed - class GuardedTreeElement { - UnoApiLock m_aLock; - TreeElement & m_rTree; - - public: - explicit GuardedTreeElement(TreeElement & rTree): m_rTree(rTree) - { rTree.checkAlive(); } - - TreeElement & get() const { return m_rTree; } - }; - - class GuardedRootElement { - UnoApiLock m_aLock; - RootElement & m_rTree; - - public: - explicit GuardedRootElement(RootElement & rTree): m_rTree(rTree) - { rTree.checkAlive(); } - - RootElement & get() const { return m_rTree; } - }; - } -} - -#endif // CONFIGMGR_API_TREEACCESS_HXX_ diff --git a/configmgr/source/api2/apitreeimplobj.cxx b/configmgr/source/api2/apitreeimplobj.cxx deleted file mode 100644 index e74c142c1b91..000000000000 --- a/configmgr/source/api2/apitreeimplobj.cxx +++ /dev/null @@ -1,1001 +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 "apitreeimplobj.hxx" -#include "confignotifier.hxx" -#include "notifierimpl.hxx" -#include "apifactory.hxx" -#include "apitreeaccess.hxx" -#include "nodechangeinfo.hxx" -#include "broadcaster.hxx" -#include "change.hxx" -#include "providerimpl.hxx" -#include "roottree.hxx" -#include "noderef.hxx" -#include "anynoderef.hxx" -#include "tracer.hxx" -#include "treemanager.hxx" -#include <cppuhelper/queryinterface.hxx> -#include <vos/refernce.hxx> - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - namespace lang = ::com::sun::star::lang; -//----------------------------------------------------------------------------- - class Factory; - class Notifier; -//----------------------------------------------------------------------------- -class ApiTreeImpl::ComponentAdapter : public lang::XEventListener -{ - vos::ORefCount m_refs; - - ApiTreeImpl* pOwner; - - uno::Reference< lang::XComponent > xProvider; - uno::Reference< lang::XComponent > xParent; -public: - ComponentAdapter(ApiTreeImpl& rParent) : pOwner(&rParent) {} - virtual ~ComponentAdapter() {} - - void clear(); - - void setProvider(uno::Reference< lang::XComponent > const& xProvider); - void setParent(uno::Reference< lang::XComponent > const& xParent); - uno::Reference< lang::XComponent > getProvider() const; - -// XEventListener - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); -private: - void setComponent(uno::Reference< lang::XComponent >& rxSlot,uno::Reference< lang::XComponent > const& xComp); - uno::Reference< lang::XComponent > getComponent(uno::Reference< lang::XComponent > const& rxSlot) const; - - virtual uno::Any SAL_CALL queryInterface(uno::Type const& rType) throw(); - virtual void SAL_CALL disposing(com::sun::star::lang::EventObject const& rEvt) throw(); -}; -//----------------------------------------------------------------------------- -inline -uno::Reference< lang::XComponent > - ApiTreeImpl::ComponentAdapter::getComponent( - uno::Reference< lang::XComponent > const& rxSlot - ) const -{ - return rxSlot; -} -//----------------------------------------------------------------------------- -inline -void ApiTreeImpl::ComponentAdapter::setComponent( - uno::Reference< lang::XComponent >& rxSlot, - uno::Reference< lang::XComponent > const& xComp - ) -{ - UnoApiLockClearable aGuard; - - uno::Reference< lang::XComponent > xOld = rxSlot; - if (xOld != xComp) - { - rxSlot = xComp; - - aGuard.clear(); - - if (xOld.is()) try { xOld->removeEventListener(this); } catch (uno::Exception & ) {} - if (xComp.is()) xComp->addEventListener(this); - } -} -//----------------------------------------------------------------------------- -uno::Reference< lang::XComponent > ApiTreeImpl::ComponentAdapter::getProvider() const -{ - return this->getComponent( this->xProvider ); -} -void ApiTreeImpl::ComponentAdapter::setProvider(uno::Reference< lang::XComponent > const& rProvider) -{ - this->setComponent( this->xProvider, rProvider); -} -void ApiTreeImpl::ComponentAdapter::setParent(uno::Reference< lang::XComponent > const& rParent) -{ - this->setComponent( this->xParent, rParent); -} -//----------------------------------------------------------------------------- - -void SAL_CALL ApiTreeImpl::ComponentAdapter::acquire() throw() -{ - ++m_refs; -} -//------------------------------------------------------------------------- - -void SAL_CALL ApiTreeImpl::ComponentAdapter::release() throw() -{ - if (--m_refs == 0) - delete this; -} -//------------------------------------------------------------------------- - -uno::Any SAL_CALL ApiTreeImpl::ComponentAdapter::queryInterface(uno::Type const& rType) throw() -{ - return cppu::queryInterface( rType - , static_cast< com::sun::star::lang::XEventListener*>(this) - , static_cast< uno::XInterface*>(this) - ); -} -//------------------------------------------------------------------------- - -void SAL_CALL ApiTreeImpl::ComponentAdapter::disposing(com::sun::star::lang::EventObject const& rEvt) throw() -{ - UnoApiLockClearable aGuard; - - if (this->pOwner != NULL) - { - CFG_TRACE_INFO("ApiTreeImpl:ComponentAdapter: Providing UNO object is disposed - relaying to my owner"); - // ensure our owner stays alive - uno::Reference<uno::XInterface> xKeepOwnerAlive( this->pOwner->getUnoInstance() ); - // and we stay alive too - rtl::Reference< ApiTreeImpl::ComponentAdapter > xKeepAlive( this ); - - aGuard.clear(); - - pOwner->disposing( rEvt ); - - UnoApiLock aClearGuard; - if (rEvt.Source == this->xParent) this->xParent.clear(); - if (rEvt.Source == this->xProvider) this->xProvider.clear(); - } - else - CFG_TRACE_INFO("ApiTreeImpl:ComponentAdapter: Providing UNO object is disposed - but my owner is already gone"); -} - -//------------------------------------------------------------------------- - -void ApiTreeImpl::ComponentAdapter::clear() -{ - UnoApiLockClearable aGuard; - - this->pOwner = 0; - - uno::Reference< lang::XComponent > aProvider = this->xProvider; - uno::Reference< lang::XComponent > aParent = this->xParent; - this->xProvider = 0; - this->xParent = 0; - - aGuard.clear(); - - if (aParent.is()) try { aParent ->removeEventListener(this); } catch (uno::Exception & ) {} - if (aProvider.is()) try { aProvider->removeEventListener(this); } catch (uno::Exception & ) {} -} - -//----------------------------------------------------------------------------- -class ApiRootTreeImpl::NodeListener : public INodeListener -{ - ApiRootTreeImpl* pParent; - TreeManager * pSource; - - vos::ORef< OOptions > m_xOptions; - configuration::AbsolutePath m_aLocationPath; -public: - NodeListener(ApiRootTreeImpl& _rParent) - : pParent(&_rParent) - , pSource(NULL) - , m_aLocationPath( configuration::AbsolutePath::root() ) - {} - ~NodeListener() - { - unbind(); - } - - TreeManager * getSource() - { - UnoApiLock aGuard; - return pSource; - } - - void setSource(TreeManager * pNew) - { - UnoApiLock aGuard; - if (pParent) - { - if (pNew != pSource) - { - OSL_ENSURE(m_xOptions.isValid(),"Cannot set IConfigListener without Options"); - if (m_xOptions.isValid()) - { - if (pSource) - pSource->removeListener(m_xOptions->getRequestOptions(), this); - - pSource = pNew; - if (pNew) - { - OSL_ENSURE(!m_aLocationPath.isRoot(), "Cannot register for notifications: no location set"); - pNew->addListener(m_aLocationPath, m_xOptions->getRequestOptions(), this); - } - } - else - pSource = 0; - } - } - } - - void setLocation(configuration::AbsolutePath const& _aLocation, vos::ORef< OOptions > const& _xOptions) - { - OSL_ASSERT(_xOptions.isValid()); - - UnoApiLock aGuard; - - if (pSource && pParent) - { - OSL_ASSERT(m_xOptions.isValid()); - pSource->removeListener(m_xOptions->getRequestOptions(), this); - } - - m_aLocationPath = _aLocation; - m_xOptions = _xOptions; - - if (pSource && pParent) - pSource->addListener(m_aLocationPath, m_xOptions->getRequestOptions(), this); - } - - void unbind() - { - UnoApiLock aGuard; - OSL_ASSERT(pParent == 0); - pParent = 0; - if (pSource) - { - OSL_ASSERT(m_xOptions.isValid()); - pSource->removeListener(m_xOptions->getRequestOptions(), this); - m_xOptions.unbind(); - m_aLocationPath = configuration::AbsolutePath::root(); - } - - } - - void clearParent() - { - UnoApiLockClearable aGuard; - if (pParent) - { - pParent = 0; - - if (pSource) - { - TreeManager * pOrgSource = pSource; - vos::ORef< OOptions > xOptions = m_xOptions; - - pSource = 0; - m_xOptions.unbind(); - m_aLocationPath = configuration::AbsolutePath::root(); - - aGuard.clear(); - - OSL_ASSERT(xOptions.isValid()); - pOrgSource->removeListener(xOptions->getRequestOptions(), this); - } - } - } - - // Interfaces - virtual void disposing(TreeManager * pSource); - virtual void nodeChanged(Change const& aChange, configuration::AbsolutePath const& sPath, TreeManager * pSource); - virtual void nodeDeleted(configuration::AbsolutePath const& sPath, TreeManager * pSource); -}; - -//------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// API object implementation wrappers -//------------------------------------------------------------------------- -ApiProvider::ApiProvider(Factory& rFactory, OProviderImpl& rProviderImpl ) - : m_rFactory(rFactory) - , m_rProviderImpl(rProviderImpl) -{} -//------------------------------------------------------------------------- - -uno::Reference<com::sun::star::script::XTypeConverter> ApiProvider::getTypeConverter() const -{ - return m_rProviderImpl.getTypeConverter(); -} -//------------------------------------------------------------------------- -static -inline -configuration::DefaultProvider createDefaultProvider( - ApiProvider& rProvider, - rtl::Reference< configuration::Tree > const& aTree, - vos::ORef< OOptions > const& _xOptions - ) -{ - OProviderImpl& rProviderImpl = rProvider.getProviderImpl(); - rtl::Reference< TreeManager > xDefaultProvider = rProviderImpl.getDefaultProvider(); - - OSL_ASSERT(_xOptions.isValid()); - RequestOptions const aOptions = _xOptions.isValid() ? _xOptions->getRequestOptions() : RequestOptions(); - - return configuration::DefaultProvider::create(aTree,aOptions,xDefaultProvider,&rProviderImpl); -} -//------------------------------------------------------------------------- -static -inline -configuration::DefaultProvider extractDefaultProvider(ApiTreeImpl* pParentTree) -{ - if (pParentTree) - return pParentTree->getDefaultProvider(); - - else - return configuration::DefaultProvider::createEmpty(); -} -//------------------------------------------------------------------------- -ApiTreeImpl::ApiTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, ApiTreeImpl* pParentTree) -: m_aTree(aTree) -, m_aNotifier(new NotifierImpl(aTree)) -, m_aDefaultProvider(extractDefaultProvider(pParentTree)) -, m_xProvider() -, m_rProvider(rProvider) -, m_pParentTree(0) -, m_pInstance(pInstance) -{ - OSL_ENSURE(pParentTree == NULL || &rProvider == &pParentTree->m_rProvider,"WARNING: Parent tree has a different provider - trouble may be ahead"); - setNodeInstance(aTree->getRootNode(), pInstance); - init(pParentTree); -} -//------------------------------------------------------------------------- -ApiTreeImpl::ApiTreeImpl(uno::XInterface* _pInstance, ApiProvider& _rProvider, rtl::Reference< configuration::Tree > const& _aTree, configuration::DefaultProvider const& _aDefaultProvider) -: m_aTree(_aTree) -, m_aNotifier(new NotifierImpl(_aTree)) -, m_aDefaultProvider(_aDefaultProvider) -, m_xProvider() -, m_rProvider(_rProvider) -, m_pParentTree(0) -, m_pInstance(_pInstance) -{ - setNodeInstance(_aTree->getRootNode(), _pInstance); - init(NULL); -} -//------------------------------------------------------------------------- - -ApiTreeImpl::~ApiTreeImpl() -{ - OSL_ENSURE(m_aNotifier->m_aListeners.isDisposed(),"ApiTree Object was not disposed properly"); - deinit(); -} -//------------------------------------------------------------------------- - -ApiRootTreeImpl::ApiRootTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions > const& _xOptions) -: m_aTreeImpl(pInstance, rProvider, aTree, createDefaultProvider(rProvider, aTree, _xOptions)) -, m_aLocationPath( configuration::Path::Rep() ) -, m_pNotificationListener(NULL) -, m_xOptions(_xOptions) -{ - implSetLocation(aTree); - enableNotification(true); -} -//------------------------------------------------------------------------- -ApiRootTreeImpl::~ApiRootTreeImpl() -{ - if (m_pNotificationListener.is()) - { - m_pNotificationListener->setSource(0); - m_pNotificationListener->clearParent(); - } -} -//------------------------------------------------------------------------- - -void ApiTreeImpl::setNodeInstance(configuration::NodeRef const& aNode, uno::XInterface* pInstance) -{ - OSL_ENSURE(aNode.isValid(),"ERROR: adding invalid node to ApiTree"); - OSL_ENSURE(m_aTree->isValidNode(aNode.getOffset()),"ERROR: foreign node being added to ApiTree"); - m_aNotifier->m_aListeners.setObjectAt( configuration::NodeID(m_aTree, aNode).toIndex(), pInstance ); -} - -//------------------------------------------------------------------------- - -bool ApiTreeImpl::isAlive() const -{ - return m_aNotifier->m_aListeners.isAlive(); -} -//------------------------------------------------------------------------- -void ApiTreeImpl::checkAlive() const -{ - m_aNotifier->m_aListeners.checkAlive( getUnoInstance() ); -} - -//------------------------------------------------------------------------- - -Notifier ApiTreeImpl::getNotifier() const -{ - return Notifier(m_aNotifier,this); -} -//------------------------------------------------------------------------- - -bool ApiRootTreeImpl::enableNotification(bool bEnable) -{ - TreeManager * pSource = bEnable ? getApiTree().getProvider().getProviderImpl().getNotifier() : 0; - - TreeManager * pOld = this->implSetNotificationSource(pSource); - - return pOld != 0; -} -//------------------------------------------------------------------------- - -bool ApiTreeImpl::disposeTree(bool bForce) -{ - CFG_TRACE_INFO("ApiTreeImpl: Disposing Tree (may throw if already disposed)"); - - // ensure our provider stays alive - uno::Reference<uno::XInterface> xKeepParentAlive(this->getParentComponent()); - // ensure we stay alive too - uno::Reference<uno::XInterface> xKeepAlive(this->getUnoInstance()); - - // #109077# If already disposed, we may have no source data or data lock - if (!isAlive()) - return false; - - if (!bForce) - { - if (m_pParentTree != 0) - return false; - - // recheck after having the mutex - checkAlive(); // may throw - } - else if (m_pParentTree) - setParentTree(NULL); - - implDisposeTree(); - OSL_ASSERT(!isAlive()); // post condition - - return true; -} -//------------------------------------------------------------------------- - -bool ApiTreeImpl::disposeTreeNow() -{ - CFG_TRACE_INFO("ApiTreeImpl: Disposing Tree Now (unless disposed)"); - if (isAlive() ) - return implDisposeTree(); - else - return false; -} -//------------------------------------------------------------------------- -bool ApiRootTreeImpl::disposeTree() -{ - CFG_TRACE_INFO("Api Root Tree: Disposing Tree And Releasing (unless disposed)"); - // ensure our provider stays alive - uno::Reference<uno::XInterface> xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - - rtl::Reference<NodeListener> xListener = m_pNotificationListener; - if (xListener.is()) - { - xListener->clearParent(); - xListener.clear(); - } - - bool bDisposed = m_aTreeImpl.disposeTreeNow(); - - if (bDisposed) releaseData(); - - if (!m_xOptions.isEmpty()) - { - OSL_ENSURE(!bDisposed, "Disposing/Releasing should clear the options"); - CFG_TRACE_INFO2("Api Root Tree: data was not released in disposeTree"); - } - - return bDisposed; -} -//------------------------------------------------------------------------- -bool ApiTreeImpl::implDisposeTree() -{ - OSL_ENSURE(m_pParentTree == 0,"WARNING: Disposing a tree that still has a parent tree set"); - - SpecialListenerContainer <configuration::SubNodeID,SubNodeHash,SubNodeEq,SubNodeToIndex>& aContainer = m_aNotifier->m_aListeners; - if (aContainer.beginDisposing()) - { - CFG_TRACE_INFO("ApiTreeImpl: Tree is now disposed"); - - Factory& rFactory = getFactory(); - - std::vector<configuration::NodeID> aChildNodes; - configuration::getAllContainedNodes( m_aTree, aChildNodes); - - for (std::vector<configuration::NodeID>::reverse_iterator it = aChildNodes.rbegin(), stop = aChildNodes.rend(); - it != stop; - ++it) - { - rFactory.revokeElement( *it ); - } - - CFG_TRACE_INFO_NI("ApiTreeImpl: Listeners are now informed"); - aContainer.notifyDisposing(); - - OSL_ASSERT(!aContainer.isDisposed()); - - CFG_TRACE_INFO_NI("ApiTreeImpl: Deinitializing"); - deinit(); // releases the provider and parent - aContainer.endDisposing(); - - OSL_ASSERT(aContainer.isDisposed()); - - return true; - } - else - { - CFG_TRACE_INFO("ApiTreeImpl: Tree was already disposed."); - return false; - } -} -//------------------------------------------------------------------------- -void ApiTreeImpl::disposeNode(configuration::NodeRef const& aNode, uno::XInterface* pInstance) -{ - // This used to contain 3 nested 'isAlive()' calls; why !? - if (isAlive()) - implDisposeNode(aNode,pInstance); -} -//------------------------------------------------------------------------- -void ApiTreeImpl::implDisposeNode(configuration::NodeRef const& aNode, uno::XInterface* ) -{ - CFG_TRACE_INFO("ApiTreeImpl: Disposing a single node."); - OSL_ENSURE(aNode.isValid(),"INTERNAL ERROR: Disposing NULL node"); - OSL_ENSURE(m_aTree->isValidNode(aNode.getOffset()),"INTERNAL ERROR: Disposing: node does not match tree"); - OSL_ENSURE( !m_aTree->isRootNode(aNode),"INTERNAL ERROR: Disposing the root node of the tree"); - - configuration::NodeID aNodeID(m_aTree,aNode); - - if (m_aNotifier->m_aListeners.disposeOne(aNodeID.toIndex()) ) - { - getFactory().revokeElement(aNodeID); - } -} -//------------------------------------------------------------------------- -void ApiTreeImpl::init(ApiTreeImpl* pParentTree) -{ - m_xProvider = new ComponentAdapter(*this); - m_xProvider->setProvider( this->getProviderComponent() ); - - OSL_ENSURE(m_xProvider->getProvider().is(),"WARNING: Provider is no Component - Lifetime trouble ahead"); - - OSL_ASSERT(m_pParentTree == 0); - setParentTree(pParentTree); -} -//------------------------------------------------------------------------- -void ApiTreeImpl::deinit() -{ - setParentTree(0); - - uno::Reference<ComponentAdapter> xAdapter = m_xProvider; - m_xProvider.clear(); - - if (xAdapter.is()) - xAdapter->clear(); -} -//------------------------------------------------------------------------- -void ApiTreeImpl::haveNewParent(ApiTreeImpl* pNewParent) // public interface -{ - setParentTree(pNewParent); -} - -//------------------------------------------------------------------------- - -ApiTreeImpl const* ApiTreeImpl::getRootTreeImpl() const -{ - ApiTreeImpl const* pRet = this; - while (pRet->m_pParentTree) - pRet = pRet->m_pParentTree; - - return pRet; -} - -//------------------------------------------------------------------------- -void ApiTreeImpl::setParentTree(ApiTreeImpl* pParentTree) // internal implementation -{ -#if OSL_DEBUG_LEVEL > 0 - if (pParentTree) - { - rtl::Reference< configuration::Tree > aContext = m_aTree->getContextTree(); - rtl::Reference< configuration::Tree > aParent = pParentTree->m_aTree; - - configuration::NodeID aContextID( aContext, aContext->getRootNode() ); - configuration::NodeID aParentID( aParent, aParent->getRootNode() ); - - OSL_ENSURE( aContextID == aParentID, "Parent relationship mismatch !"); - } -#endif - - if (m_pParentTree != pParentTree) - { - uno::Reference<ComponentAdapter> xAdapter = m_xProvider; - - m_pParentTree = pParentTree; - - uno::Reference<com::sun::star::lang::XComponent> xNew = getParentComponent(); - OSL_ENSURE( xNew.is() == (pParentTree != 0), "WARNING: Parent Tree is no Component"); - - if (xAdapter.is()) - xAdapter->setParent(xNew); - else - OSL_ENSURE( pParentTree == 0, "ERROR: Setting New Parent at deinitialized ApiTreeImpl"); - - } -} -//------------------------------------------------------------------------- - -uno::Reference<uno::XInterface> ApiTreeImpl::getUnoProviderInstance() const -{ - uno::Reference<ComponentAdapter> xAdapter = m_xProvider; - - uno::Reference<uno::XInterface> xReturn; - if (xAdapter.is()) - xReturn = xAdapter->getProvider(); - return xReturn; -} - -//------------------------------------------------------------------------- -uno::Reference<com::sun::star::lang::XComponent> ApiTreeImpl::getParentComponent() -{ - uno::XInterface* pInterface = m_pParentTree ? m_pParentTree->getUnoInstance() : 0; - return uno::Reference<com::sun::star::lang::XComponent>::query(pInterface); -} -//------------------------------------------------------------------------- - -uno::Reference<com::sun::star::lang::XComponent> ApiTreeImpl::getProviderComponent() -{ - uno::XInterface* pInterface = m_rProvider.getProviderImpl().getProviderInstance(); - return uno::Reference<com::sun::star::lang::XComponent>::query(pInterface); -} - -//------------------------------------------------------------------------- - -void ApiTreeImpl::disposing(com::sun::star::lang::EventObject const& ) throw() -{ - // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call - CFG_TRACE_INFO("ApiTreeImpl: Providing UNO object is disposed - disposing the tree"); - - // Tree write Lock should be set by sender - - CFG_TRACE_INFO_NI("Clearing parent reference"); - setParentTree(0); - - CFG_TRACE_INFO_NI("Trying to dispose"); - //implDisposeTree(); - disposeTreeNow(); - - CFG_TRACE_INFO_NI("Done disposing Tree"); - // uno::Reference<com::sun::star::lang::XComponent> xThis(getUnoInstance(),UNO_QUERY); - // if (xThis.is()) xThis->dispose(); -} -//------------------------------------------------------------------------- -TreeManager * ApiRootTreeImpl::implSetNotificationSource(TreeManager * pNew) -{ - TreeManager * pOld = m_pNotificationListener.is() ? m_pNotificationListener->getSource() : 0; - if (pOld != pNew) - { - OSL_ENSURE(m_xOptions.isValid(), "Cannot change notification source without options"); - - if (!m_pNotificationListener.is()) - m_pNotificationListener = new NodeListener(*this); - - m_pNotificationListener->setSource(pNew); - - } - return pOld; -} -// --------------------------------------------------------------------------------------------------- - -void ApiRootTreeImpl::implSetLocation(rtl::Reference< configuration::Tree > const& _aTree) -{ - OSL_ASSERT(_aTree == getApiTree().getTree()); - if (!configuration::isEmpty(_aTree.get())) - { - m_aLocationPath = _aTree->getRootPath(); - OSL_ENSURE(!m_aLocationPath.isRoot(), "Setting up a root tree without location"); - } - else - { - OSL_ENSURE(false, "Setting up a root tree without data"); - m_aLocationPath = configuration::AbsolutePath::root(); - } - - if (!m_pNotificationListener.is()) - m_pNotificationListener = new NodeListener(*this); - - OSL_ENSURE(!m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Cannot reregister for notifications: setting empty location"); - OSL_ENSURE( m_xOptions.isValid(), "Cannot reregister for notifications: no options available" ); - - m_pNotificationListener->setLocation(m_aLocationPath, m_xOptions); -} -// --------------------------------------------------------------------------------------------------- - -void ApiRootTreeImpl::releaseData() -{ - CFG_TRACE_INFO("Api Root Tree at %s: releasing the Data",OUSTRING2ASCII(m_aLocationPath.toString())); - rtl::Reference< configuration::Tree > aTree( m_aTreeImpl.getTree() ); - - if (aTree.is()) { - aTree->disposeData(); - } - OSL_ASSERT(configuration::isEmpty(aTree.get())); - - OSL_ENSURE( !m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Location still needed to release data" ); - OSL_ENSURE( m_xOptions.isValid(), "Options still needed to release data" ); - - getApiTree().getProvider().getProviderImpl().releaseSubtree(m_aLocationPath,m_xOptions->getRequestOptions()); - m_xOptions.unbind(); - - m_aLocationPath = configuration::AbsolutePath::detachedRoot(); -} -// --------------------------------------------------------------------------------------------------- - -void ApiRootTreeImpl::NodeListener::disposing(TreeManager * _pSource) -{ - UnoApiLockClearable aGuard; - - OSL_ASSERT( !pSource || _pSource == pSource ); - if (pParent) - { - // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call - uno::Reference<uno::XInterface> xKeepAlive( pParent->m_aTreeImpl.getUnoInstance() ); - ApiRootTreeImpl* pKeepParent = pParent; - aGuard.clear(); - - pKeepParent->disposing(_pSource); - } -} -void ApiRootTreeImpl::disposing(TreeManager *) -{ - CFG_TRACE_INFO("Api Root Tree at %s: Cache data is disposed - dispose and release own data", - OUSTRING2ASCII(m_aLocationPath.toString())); - // ensure our provider stays alive - uno::Reference<uno::XInterface> xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - - rtl::Reference<NodeListener> xListener = m_pNotificationListener; - if (xListener.is()) - { - xListener->clearParent(); - xListener.clear(); - } - - if (m_aTreeImpl.disposeTreeNow()) - releaseData(); // not really needed: the whole data is going away anyways -} -// --------------------------------------------------------------------------------------------------- - -static -void disposeOneRemovedNode(configuration::NodeChangeInformation const& aRemoveInfo, Factory& aFactory) -{ - if (aRemoveInfo.change.element.oldValue.is()) - { - OSL_ENSURE(aRemoveInfo.change.element.isDataChange(), "ERROR: Disposing replaced element: Element did not really change !"); - - rtl::Reference< configuration::ElementTree > aElementRef( aRemoveInfo.change.element.oldValue.get() ); - - SetElement* pSetElement = aFactory.findSetElement(aElementRef ); - if (pSetElement) - { - // factory always does an extra acquire - uno::Reference<uno::XInterface> xReleaseSetElement(pSetElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE); - - pSetElement->haveNewParent(0); - pSetElement->disposeTree(true); - } - } - else - { - // This must apply to a node for which no element tree had been loaded in this view - // thus there should not be one now after the change (even if the change was replacing) - OSL_ENSURE(!aRemoveInfo.change.element.newValue.is(), "Cannot dispose replaced element: No tree object available"); - } -} -// --------------------------------------------------------------------------------------------------- - -static -void disposeRemovedNodes(configuration::NodeChangesInformation const& aChanges, Factory& aFactory) -{ - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != aChanges.end(); ++it) - { - switch (it->change.type) - { - case configuration::NodeChangeData::eReplaceElement: - // check if element is actually unchanged ! - // (cannot dispose of the tree, if it is still in use) - if (! it->change.element.isDataChange()) break; - - // else dispose the old one: fall thru - - case configuration::NodeChangeData::eRemoveElement: - disposeOneRemovedNode( *it, aFactory ); - break; - - default: break; - } - } -} -// --------------------------------------------------------------------------------------------------- -//INodeListener : IConfigListener -void ApiRootTreeImpl::NodeListener::nodeChanged(Change const& aChange, configuration::AbsolutePath const& sPath, TreeManager * _pSource) -{ - UnoApiLockClearable aGuard; - - OSL_ASSERT( !pSource || _pSource == pSource ); - if (pParent) - { - // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call - uno::Reference<uno::XInterface> xKeepAlive( pParent->m_aTreeImpl.getUnoInstance() ); - ApiRootTreeImpl* pKeepParent = pParent; - aGuard.clear(); - - pKeepParent->nodeChanged(aChange,sPath,_pSource); - } -} -// --------------------------------------------------------------------------------------------------- - -//INodeListener : IConfigListener -void ApiRootTreeImpl::nodeChanged(Change const& aChange, configuration::AbsolutePath const& aChangePath, TreeManager *) -{ - // do not dipatch if we are dying/dead anyway - if (m_aTreeImpl.isAlive()) - try - { - rtl::Reference< configuration::Tree > aTree(m_aTreeImpl.getTree()); - - OSL_ENSURE(configuration::Path::hasPrefix(aChangePath, m_aLocationPath), - "'changed' Path does not indicate this tree or its context: "); - - configuration::RelativePath aLocalChangePath = configuration::Path::stripPrefix(aChangePath,m_aLocationPath); - - // find the node and change - configuration::NodeRef aNode; - - if ( !aLocalChangePath.isEmpty() ) - { - configuration::NodeRef aBaseNode = aTree->getRootNode(); - -#ifdef DBG_UTIL - try { - configuration::RelativePath aLocalPathOld = configuration::validateAndReducePath(aChangePath.toString(), aTree, aBaseNode); - OSL_ENSURE( configuration::matches(aLocalPathOld,aLocalChangePath), - "New local path different from validateAndReducePath(...) result in notification dispatch"); - } - catch (configuration::Exception& e) { - rtl::OString sMsg("Cannot validate new path handling for notification dispatch: "); - sMsg += e.what(); - OSL_ENSURE(false, sMsg.getStr() ); - } -#endif // DBG_UTIL - - configuration::AnyNodeRef aFoundNode = configuration::getDeepDescendant(aTree, aBaseNode, aLocalChangePath); - if ( aFoundNode.isValid() ) - { - if (aFoundNode.isNode()) - { - aNode = aFoundNode.toNode(); - } - else - { - // TODO: Notify using parent node and temporary dummy change - OSL_ENSURE( false, "Notification broken: Node being adressed is a Value"); - } - } - } - else - { - aNode = aTree->getRootNode(); - } - - SubtreeChange const* pTreeChange = NULL; - if (aNode.isValid()) - { - pTreeChange = dynamic_cast<SubtreeChange const*>(&aChange); - OSL_ENSURE(pTreeChange != 0, "Notification broken: Change to inner node is not a subtree change"); // TODO: Notify set change using parent (if available) and temporary dummy change - } - - if (pTreeChange != NULL) // implies aNode.isValid() - { - OSL_ENSURE( aChange.getNodeName() == aTree->getSimpleNodeName(aNode.getOffset()), - "Change's node-name does not match found node's name - erratic notification"); - - configuration::NodeChangesInformation aChanges; - - if (configuration::adjustToChanges(aChanges, aTree,aNode, *pTreeChange)) - { - OSL_ASSERT(aChanges.size() > 0); - - Broadcaster aSender(m_aTreeImpl.getNotifier(),aChanges,false); - - // Should be improved later. Maybe this is the wrong lock for disposeTree ? - // aLocalGuard.downgrade(); // partial clear for broadcast - - aSender.notifyListeners(aChanges, false); - - disposeRemovedNodes(aChanges, m_aTreeImpl.getFactory()); - } - } - } - catch (configuration::InvalidName& i) - { - rtl::OString sMsg("Cannot locate change within this tree: "); - sMsg += i.what(); - OSL_ENSURE(false, sMsg.getStr() ); - } - catch (configuration::Exception& e) - { - rtl::OString sMsg("Unexpected error trying to react on update: "); - sMsg += e.what(); - OSL_ENSURE(false, sMsg.getStr() ); - } -} -// --------------------------------------------------------------------------------------------------- - -void ApiRootTreeImpl::NodeListener::nodeDeleted(configuration::AbsolutePath const& _aPath, TreeManager * _pSource) -{ - UnoApiLockClearable aGuard; - - OSL_ASSERT( !pSource || _pSource == pSource ); - if (pParent) - { - // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call - uno::Reference<uno::XInterface> xKeepAlive( pParent->m_aTreeImpl.getUnoInstance() ); - ApiRootTreeImpl* pKeepParent = pParent; - aGuard.clear(); - - pKeepParent->nodeDeleted(_aPath,_pSource); - } -} -// --------------------------------------------------------------------------------------------------- -void ApiRootTreeImpl::nodeDeleted(configuration::AbsolutePath const& _aDeletedPath, TreeManager *) -{ - { (void)_aDeletedPath; } - - // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call - uno::Reference<uno::XInterface> xKeepAlive( m_aTreeImpl.getUnoInstance() ); - -#ifdef DBG_UTIL - OSL_ENSURE(configuration::Path::hasPrefix(m_aLocationPath, _aDeletedPath), - "'deleted' Path does not indicate this tree or its context: "); -#endif - // ensure our provider stays alive - uno::Reference<uno::XInterface> xKeepProvider( m_aTreeImpl.getUnoProviderInstance() ); - - rtl::Reference<NodeListener> xListener = m_pNotificationListener; - if (xListener.is()) - { - xListener->clearParent(); - xListener.clear(); - } - - if (m_aTreeImpl.disposeTreeNow()) - releaseData(); -} - -// --------------------------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- - } -} - diff --git a/configmgr/source/api2/apitreeimplobj.hxx b/configmgr/source/api2/apitreeimplobj.hxx deleted file mode 100644 index 9b93e2c79458..000000000000 --- a/configmgr/source/api2/apitreeimplobj.hxx +++ /dev/null @@ -1,189 +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_API_TREEIMPLOBJECTS_HXX_ -#define CONFIGMGR_API_TREEIMPLOBJECTS_HXX_ - -#include "noderef.hxx" -#include "configset.hxx" -#include "configdefaultprovider.hxx" -#include "confevents.hxx" -#include "options.hxx" -#include "utility.hxx" -#include <boost/utility.hpp> -#include <vos/ref.hxx> -#include <rtl/ref.hxx> -#include <osl/mutex.hxx> - -#ifndef INCLUDED_MEMORY -#include <memory> -#define INCLUDED_MEMORY -#endif -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XComponent.hpp> - -namespace com { namespace sun { namespace star { - namespace script { class XTypeConverter; } -} } } - -namespace configmgr -{ -//----------------------------------------------------------------------------- - class OProviderImpl; -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - class Factory; - class Notifier; - class NotifierImpl; -//----------------------------------------------------------------------------- - class ObjectRegistry; -//----------------------------------------------------------------------------- -// API object implementation wrappers -//------------------------------------------------------------------------- - class ApiProvider: private boost::noncopyable - { - Factory& m_rFactory; - OProviderImpl& m_rProviderImpl; - public: - ApiProvider(Factory& rFactory, OProviderImpl& rProviderImpl ); - - ~ApiProvider() - {} - - uno::Reference<com::sun::star::script::XTypeConverter> getTypeConverter() const; - Factory& getFactory() { return m_rFactory; } - OProviderImpl& getProviderImpl() { return m_rProviderImpl; } - }; - - //----------------------------------------------------------------------------- - - //------------------------------------------------------------------------- - class ApiTreeImpl: private boost::noncopyable - { - class ComponentAdapter; - - rtl::Reference< configuration::Tree > m_aTree; - vos::ORef<NotifierImpl> m_aNotifier; - configuration::DefaultProvider m_aDefaultProvider; - uno::Reference<ComponentAdapter> m_xProvider; - ApiProvider& m_rProvider; - ApiTreeImpl* m_pParentTree; - uno::XInterface* m_pInstance; - - public: - explicit ApiTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, ApiTreeImpl* pParentTree); - explicit ApiTreeImpl(uno::XInterface* _pInstance, ApiProvider& _rProvider, rtl::Reference< configuration::Tree > const& _aTree, configuration::DefaultProvider const & _aDefaultProvider); - ~ApiTreeImpl(); - - // initialization - void setNodeInstance(configuration::NodeRef const& aNode, uno::XInterface* pInstance); - - // model access - rtl::Reference< configuration::Tree > getTree() const { return m_aTree; } - - // self-locked methods for dispose handling - bool isAlive() const; - void checkAlive() const; - bool disposeTree(bool bForce); - bool disposeTreeNow(); - void disposeNode(configuration::NodeRef const& aNode, uno::XInterface* pInstance); - - // api object handling - Factory& getFactory() const { return m_rProvider.getFactory(); } - Notifier getNotifier() const; - configuration::DefaultProvider getDefaultProvider() const { return m_aDefaultProvider; } - - // needs external locking - ApiTreeImpl const* getRootTreeImpl() const; - - uno::XInterface* getUnoInstance() const { return m_pInstance; } - ApiProvider& getProvider() { return m_rProvider; } - uno::Reference<uno::XInterface> getUnoProviderInstance() const; // { return m_xProvider; } - - /// wire this to a new parent tree - void haveNewParent(ApiTreeImpl* pNewParent); - private: - void init(ApiTreeImpl* pParentTree); - void setParentTree(ApiTreeImpl* pNewParentTree); - void deinit(); - - bool implDisposeTree(); - void implDisposeNode(configuration::NodeRef const& aNode, uno::XInterface* pInstance); - - friend class ComponentAdapter; - void disposing(com::sun::star::lang::EventObject const& rEvt) throw(); - uno::Reference<com::sun::star::lang::XComponent> getProviderComponent(); - uno::Reference<com::sun::star::lang::XComponent> getParentComponent(); - - }; - - //----------------------------------------------------------------------------- - class ApiRootTreeImpl - { - public: - explicit ApiRootTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions > const& _xOptions); - ~ApiRootTreeImpl(); - - ApiTreeImpl& getApiTree() { return m_aTreeImpl; } - ApiTreeImpl const& getApiTree() const { return m_aTreeImpl; } - - configuration::AbsolutePath const & getLocation() const { return m_aLocationPath; } - vos::ORef< OOptions > getOptions() const { return m_xOptions; } - - // self-locked methods for dispose handling - bool disposeTree(); - - /// toggle whether this object relays notifications from the base provider - bool enableNotification(bool bEnable); - private: - TreeManager * implSetNotificationSource(TreeManager * pNew); - void implSetLocation(rtl::Reference< configuration::Tree > const& _aTree); - void releaseData(); - - private: - class NodeListener; - friend class NodeListener; - - // IConfigListener - void disposing(TreeManager * pSource) ; - //INodeListener : IConfigListener - void nodeChanged(Change const& aChange, configuration::AbsolutePath const& aPath, TreeManager * pSource); - void nodeDeleted(configuration::AbsolutePath const& aPath, TreeManager * pSource); - - private: - ApiTreeImpl m_aTreeImpl; - configuration::AbsolutePath m_aLocationPath; - rtl::Reference<NodeListener> m_pNotificationListener; - vos::ORef< OOptions > m_xOptions; - }; -//----------------------------------------------------------------------------- - } -} - -#endif // CONFIGMGR_API_TREEIMPLOBJECTS_HXX_ diff --git a/configmgr/source/api2/broadcaster.cxx b/configmgr/source/api2/broadcaster.cxx deleted file mode 100644 index 0a3abc01e81d..000000000000 --- a/configmgr/source/api2/broadcaster.cxx +++ /dev/null @@ -1,1226 +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 "broadcaster.hxx" -#include "notifierimpl.hxx" -#include "confignotifier.hxx" -#include "noderef.hxx" -#include "nodechange.hxx" -#include "nodechangeinfo.hxx" -#include "translatechanges.hxx" -#include "apifactory.hxx" -#include "apitreeaccess.hxx" -#include "apitreeimplobj.hxx" -#include <vos/refernce.hxx> - -#ifndef INCLUDED_MAP -#include <map> -#define INCLUDED_MAP -#endif -#ifndef INCLUDED_SET -#include <set> -#define INCLUDED_SET -#endif -#ifndef INCLUDED_FUNCTIONAL -#include <functional> -#define INCLUDED_FUNCTIONAL -#endif - -namespace configmgr -{ - namespace configapi - { -// --------------------------------------------------------------------------------------------------- -// Broadcaster implementation -// --------------------------------------------------------------------------------------------------- - class BroadcasterHelper - { - public: - static vos::ORef<NotifierImpl> getImpl(Notifier const& aNotifier) { return aNotifier.m_aImpl; } - }; -// --------------------------------------------------------------------------------------------------- - - namespace - { - // ----------------------------------------------------------------------------------------------- - template <class T> - struct LessORefBodyPtr - { - bool operator()(vos::ORef<T> const& lhs, vos::ORef<T> const& rhs) const - { - return ptr_less(lhs.getBodyPtr(), rhs.getBodyPtr()); - } - - std::less<T*> ptr_less; - }; - // ----------------------------------------------------------------------------------------------- - class ApiTreeRef - { - ApiTreeImpl const* m_pApiTree; - uno::Reference<uno::XInterface> m_xKeepAlive; - public: - explicit ApiTreeRef(ApiTreeImpl const* _pApiTree = NULL) - : m_pApiTree(_pApiTree) - , m_xKeepAlive() - { - if (m_pApiTree) m_xKeepAlive = m_pApiTree->getUnoInstance(); - } - - bool is() const - { - OSL_ASSERT(!m_pApiTree == !m_xKeepAlive.is()); - return m_pApiTree != NULL; - } - - ApiTreeImpl const* get() const { return m_pApiTree; } - ApiTreeImpl const* operator->() const { return m_pApiTree; } - - friend bool operator==(ApiTreeRef const& lhs,ApiTreeRef const& rhs) - { return lhs.m_pApiTree == rhs.m_pApiTree; } - - friend bool operator!=(ApiTreeRef const& lhs,ApiTreeRef const& rhs) - { return lhs.m_pApiTree != rhs.m_pApiTree; } - }; - // ----------------------------------------------------------------------------------------------- - typedef std::map< vos::ORef<NotifierImpl>, ApiTreeRef, LessORefBodyPtr<NotifierImpl> > NotifierSet; - // ----------------------------------------------------------------------------------------------- - - } -// --------------------------------------------------------------------------------------------------- -// class Broadcaster::Impl -// --------------------------------------------------------------------------------------------------- - class Broadcaster::Impl : public vos::OReference - { - private: - NotifierSet::value_type m_aNotifierData; - public: - Impl(NotifierSet::value_type const& aNotifierData) : m_aNotifierData(aNotifierData) {} - - NotifierSet::value_type getNotifierData() const { return m_aNotifierData; } - - bool translateChanges(configuration::NodeChangesInformation& aInfos, configuration::NodeChanges const& aChanges, bool bSingleBase) const; - bool translateChanges(configuration::NodeChangesInformation& aInfos, configuration::NodeChangesInformation const& aChanges, bool bSingleBase) const; - - void queryConstraints(configuration::NodeChangesInformation const& aChanges) { this->doQueryConstraints(aChanges); } - void notifyListeners(configuration::NodeChangesInformation const& aChanges) { this->doNotifyListeners(aChanges); } - - void notifyRootListeners(configuration::NodeChangesInformation const& aChanges); - - static vos::ORef<Impl> create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChange const& aChange, bool bLocal); - static vos::ORef<Impl> create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChanges const& aChange, bool bLocal); - static vos::ORef<Impl> create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChangeInformation const& aChange, bool bLocal); - static vos::ORef<Impl> create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChangesInformation const& aChange, bool bLocal); - - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges) = 0; - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges) = 0; - }; -// --------------------------------------------------------------------------------------------------- - namespace - { - // ----------------------------------------------------------------------------------------------- - - class EmptyBroadcaster_Impl : public Broadcaster::Impl - { - EmptyBroadcaster_Impl(NotifierSet::value_type const& rNotifierData) - : Broadcaster::Impl(rNotifierData) - { - } - public: - static - vos::ORef< Broadcaster::Impl > create(NotifierSet::value_type const& rRootNotifier) - { - return new EmptyBroadcaster_Impl(rRootNotifier); - } - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges); - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges); - }; - - void EmptyBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation const&) {} - void EmptyBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation const&) {} - // ----------------------------------------------------------------------------------------------- - - class NodeLocalBroadcaster_Impl : public Broadcaster::Impl - { - configuration::NodeID aAffectedNode; - - public: - NodeLocalBroadcaster_Impl(NotifierSet::value_type const& rTreeNotifierData, configuration::NodeID const& aAffectedID) - : Broadcaster::Impl(rTreeNotifierData) - , aAffectedNode(aAffectedID) - { - } - - configuration::NodeID getAffectedNodeID() const { return aAffectedNode; } - unsigned int getNodeIndex() const { return aAffectedNode.toIndex(); } - - protected: - void querySingleConstraint(configuration::NodeChangeInformation const& aChange, bool bMore); - void notifySingleChange(configuration::NodeChangeInformation const& aChange, bool bMore, css::beans::PropertyChangeEvent*& pCurEvent); - }; - // ----------------------------------------------------------------------------------------------- - - class SingleChangeBroadcaster_Impl : public NodeLocalBroadcaster_Impl - { - configuration::SubNodeID m_aChangingValue; - - SingleChangeBroadcaster_Impl(NotifierSet::value_type const& rTreeNotifierData, configuration::NodeID const& aAffectedID, configuration::SubNodeID const& aChangedValue); - - public: - static - NodeLocalBroadcaster_Impl* create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangeLocation const& aChange); - static - NodeLocalBroadcaster_Impl* create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedID, - configuration::NodeChangeLocation const& aChange); - static - NodeLocalBroadcaster_Impl* create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedID, - configuration::SubNodeID const& aChangedNode, - configuration::NodeChangeLocation const& aChange); - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges); - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges); - }; - - // ----------------------------------------------------------------------------------------------- - class MultiChangeBroadcaster_Impl : public NodeLocalBroadcaster_Impl - { - std::set< configuration::SubNodeID > m_aChangingNodes; - - MultiChangeBroadcaster_Impl(NotifierSet::value_type const& rTreeNotifierData, configuration::NodeID const& aAffectedID, std::set< configuration::SubNodeID >& aChangedNodes); - - public: - static - NodeLocalBroadcaster_Impl* create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangesInformation const& aChanges); - static - NodeLocalBroadcaster_Impl* create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedID, - configuration::NodeChangesInformation const& aChanges); - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges); - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges); - }; - // ----------------------------------------------------------------------------------------------- - class SingleTreeBroadcaster_Impl : public Broadcaster::Impl - { - std::vector< vos::ORef<NodeLocalBroadcaster_Impl> > m_aBroadcasters; - - SingleTreeBroadcaster_Impl(NotifierSet::value_type const& rTreeNotifierData, std::vector< vos::ORef<NodeLocalBroadcaster_Impl> >& aBroadcasters); - - public: - //-------------------------- - static - vos::ORef< Broadcaster::Impl > create( - NotifierSet::value_type const& rRootNotifier, - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangesInformation const& aChanges); - - static bool selectChanges(configuration::NodeChangesInformation& rSelected, configuration::NodeChangesInformation const& aOriginal, configuration::NodeID const& aSelector); - //-------------------------- - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges); - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges); - }; - // ----------------------------------------------------------------------------------------------- - class MultiTreeBroadcaster_Impl : public Broadcaster::Impl - { - std::vector< vos::ORef< Broadcaster::Impl > > m_aBroadcasters; - - MultiTreeBroadcaster_Impl(NotifierSet::value_type const& rRootNotifierData, std::vector< vos::ORef< Broadcaster::Impl > >& aBroadcasters); - public: - //-------------------------- - static - vos::ORef< Broadcaster::Impl > create( - NotifierSet::value_type const& rRootNotifier, - NotifierSet const& rNotifiers, - configuration::NodeChangesInformation const& aChanges); - - static bool selectChanges(configuration::NodeChangesInformation& rSelected, configuration::NodeChangesInformation const& aOriginal, NotifierSet::value_type const& aSelector); - //-------------------------- - private: - virtual void doQueryConstraints(configuration::NodeChangesInformation const& aChanges); - virtual void doNotifyListeners(configuration::NodeChangesInformation const& aChanges); - }; - - // ----------------------------------------------------------------------------------------------- - - inline configuration::NodeID makeRootID( rtl::Reference< configuration::Tree > const& aTree ) { return configuration::NodeID( aTree, aTree->getRootNode() ); } - inline configuration::NodeID makeRootID( ApiTreeRef const& pTreeImpl ) { return makeRootID( pTreeImpl->getTree() ); } - // ----------------------------------------------------------------------------------------------- - NotifierSet::value_type findNotifier(configuration::NodeChangeLocation const& aChange, ApiTreeRef const& pTreeImpl) - { - OSL_ENSURE(aChange.isValidData(),"Invalid change location - cannot find notifier"); - - configuration::NodeID aAffectedNode = aChange.getAffectedNodeID(); - if (aAffectedNode.isEmpty()) - return NotifierSet::value_type(); - - ApiTreeRef aAffectedImpl( Factory::findDescendantTreeImpl(aAffectedNode, pTreeImpl.get()) ); - if (aAffectedImpl.is()) - { - vos::ORef<NotifierImpl> aAffectedNotifier = BroadcasterHelper::getImpl(aAffectedImpl->getNotifier()); - - return NotifierSet::value_type(aAffectedNotifier, aAffectedImpl); - } - else - return NotifierSet::value_type(); - } - // ----------------------------------------------------------------------------------------------- - inline - NotifierSet::value_type findNotifier(configuration::NodeChangeInformation const& aChange, ApiTreeRef const& pTreeImpl) - { - return findNotifier(aChange.location,pTreeImpl); - } - // ----------------------------------------------------------------------------------------------- - - void findNotifiers(NotifierSet& aNotifiers, configuration::NodeChangesInformation const& aChanges, ApiTreeRef const& pTreeImpl ) - { - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != aChanges.end(); ++it) - { - NotifierSet::value_type aNotifierData( findNotifier(*it,pTreeImpl) ); - - if (aNotifierData.first.isValid()) - { - aNotifiers.insert( aNotifierData ); - OSL_ENSURE( aNotifiers[aNotifierData.first] == aNotifierData.second, "Different Api Trees for the same notifier" ); - } - } - } - // ----------------------------------------------------------------------------------------------- - // NodeLocalBroadcaster_Impl - // ----------------------------------------------------------------------------------------------- - void NodeLocalBroadcaster_Impl::querySingleConstraint(configuration::NodeChangeInformation const& aChange, bool bMore) - { - uno::Reference< css::beans::XVetoableChangeListener > const * const SelectListener = 0; - - vos::ORef<NotifierImpl> pNotifierImpl = getNotifierData().first; - - cppu::OInterfaceContainerHelper* pListeners = pNotifierImpl->m_aListeners.getContainer( getNodeIndex(), getCppuType(SelectListener) ); - cppu::OInterfaceContainerHelper* pSpecial = pNotifierImpl->m_aListeners.getSpecialContainer( aChange.location.getChangingValueID() ); - - if (pSpecial || pListeners) - { - css::beans::PropertyChangeEvent aEvent; - aEvent.Source = pNotifierImpl->m_aListeners.getObjectAt( getNodeIndex() ); - - if (configapi::fillEventDataFromResolved(aEvent,aChange,bMore)) - { - // Catch only RuntimeExceptions here: vetoableChange issues its veto by throwing - // a PropertyVetoException (which is not a RuntimeException) - if (pListeners) - { - ListenerContainerIterator< css::beans::XVetoableChangeListener > aIterator(*pListeners); - - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try - { - aIterator.next()->vetoableChange(aEvent); - } - catch (uno::RuntimeException & ) - {} - } - if (pSpecial) - { - ListenerContainerIterator< css::beans::XVetoableChangeListener > aIterator(*pSpecial); - - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try - { - aIterator.next()->vetoableChange(aEvent); - } - catch (uno::RuntimeException & ) - {} - } - } - } - - } - // ----------------------------------------------------------------------------------------------- - void NodeLocalBroadcaster_Impl::notifySingleChange(configuration::NodeChangeInformation const& aChange, bool bMore, css::beans::PropertyChangeEvent*& pCurEvent) - { - uno::Reference< css::beans::XPropertyChangeListener > const * const SelectPropertyListener = 0; - uno::Reference< css::container::XContainerListener > const * const SelectContainerListener = 0; - - vos::ORef<NotifierImpl> pNotifierImpl = getNotifierData().first; - - cppu::OInterfaceContainerHelper* pContainerListeners = pNotifierImpl->m_aListeners.getContainer( getNodeIndex(), getCppuType(SelectContainerListener) ); - - if (pContainerListeners) - { - css::container::ContainerEvent aEvent; - aEvent.Source = pNotifierImpl->m_aListeners.getObjectAt( getNodeIndex() ); - - if (configapi::fillEventDataFromResolved(aEvent,aChange)) - { - - ListenerContainerIterator< css::container::XContainerListener > aIterator(*pContainerListeners); - - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try - { - uno::Reference<css::container::XContainerListener> xListener( aIterator.next() ); - OSL_ASSERT( xListener.is() ); - - switch (aChange.change.type) - { - case configuration::NodeChangeData::eSetValue: - case configuration::NodeChangeData::eSetDefault: - case configuration::NodeChangeData::eReplaceElement: - xListener->elementReplaced(aEvent); - break; - - case configuration::NodeChangeData::eInsertElement: - xListener->elementInserted(aEvent); - break; - - case configuration::NodeChangeData::eRemoveElement: - xListener->elementRemoved(aEvent); - break; - - - case configuration::NodeChangeData::eResetSetDefault: - case configuration::NodeChangeData::eRenameElementTree: - case configuration::NodeChangeData::eNoChange: - OSL_ASSERT(false); - break; - } - } - catch (uno::Exception &) - {} - } - } - - - OSL_ASSERT(pCurEvent); - css::beans::PropertyChangeEvent& rEvent = *pCurEvent; - - rEvent.Source = pNotifierImpl->m_aListeners.getObjectAt( getNodeIndex() ); - - if (configapi::fillEventDataFromResolved(rEvent,aChange,bMore)) - { - cppu::OInterfaceContainerHelper* pPropertyListeners = pNotifierImpl->m_aListeners.getContainer( getNodeIndex(), getCppuType(SelectPropertyListener) ); - if (pPropertyListeners) - { - ListenerContainerIterator< css::beans::XPropertyChangeListener > aIterator(*pPropertyListeners); - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try { aIterator.next()->propertyChange(rEvent); } catch (uno::Exception & ) {} - } - - cppu::OInterfaceContainerHelper* pSpecialListeners = pNotifierImpl->m_aListeners.getSpecialContainer( aChange.location.getChangingValueID() ); - if (pSpecialListeners) - { - ListenerContainerIterator< css::beans::XPropertyChangeListener > aIterator(*pSpecialListeners); - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try { aIterator.next()->propertyChange(rEvent); } catch (uno::Exception & ) {} - } - - ++pCurEvent; - } - - } - // ----------------------------------------------------------------------------------------------- - - // ----------------------------------------------------------------------------------------------- - // SingleBroadcaster_Impl - // ----------------------------------------------------------------------------------------------- - SingleChangeBroadcaster_Impl::SingleChangeBroadcaster_Impl( - NotifierSet::value_type const& rTreeNotifierData, - configuration::NodeID const& aAffectedID, configuration::SubNodeID const& aChangedNode - ) - : NodeLocalBroadcaster_Impl(rTreeNotifierData,aAffectedID) - , m_aChangingValue(aChangedNode) - { - } - // ----------------------------------------------------------------------------------------------- - NodeLocalBroadcaster_Impl* SingleChangeBroadcaster_Impl::create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangeLocation const& aChange) - { - OSL_ENSURE(rLocalNotifier.second->getTree() == aChange.getAffectedTreeRef(), - "ERROR: Tree Mismatch creating Single Broadcaster"); - - OSL_ENSURE(aChange.isValidData(), "ERROR: Invalid Change Location for Broadcaster"); - - configuration::NodeID aAffectedNodeID = aChange.getAffectedNodeID(); - if (aAffectedNodeID.isEmpty()) - return 0; - - return create(rLocalNotifier,aAffectedNodeID,aChange.getChangingValueID(),aChange); - } - // ----------------------------------------------------------------------------------------------- - NodeLocalBroadcaster_Impl* SingleChangeBroadcaster_Impl::create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedID, - configuration::NodeChangeLocation const& aChange) - { - - return create(rLocalNotifier,aAffectedID,aChange.getChangingValueID(),aChange); - } - // ----------------------------------------------------------------------------------------------- - NodeLocalBroadcaster_Impl* SingleChangeBroadcaster_Impl::create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedID, - configuration::SubNodeID const& aChangedNodeID, - configuration::NodeChangeLocation const& aChange) - { - { (void)aChange; } - OSL_ENSURE(aChange.isValidData(), "ERROR: Invalid Change Location for Broadcaster"); - OSL_ENSURE(aAffectedID.isValidNode(),"Cannot broadcast without affected node"); - - OSL_ENSURE(rLocalNotifier.second->getTree() == aChange.getAffectedTreeRef(), - "ERROR: Tree Mismatch creating Single Broadcaster"); - OSL_ENSURE( aChange.getAffectedNodeID() == aAffectedID, - "ERROR: Node Mismatch creating Single Broadcaster"); - OSL_ENSURE( aChange.getChangingValueID() == aChangedNodeID, - "ERROR: Value Node Mismatch creating Single Broadcaster"); - - return new SingleChangeBroadcaster_Impl(rLocalNotifier,aAffectedID,aChangedNodeID); - } - // ----------------------------------------------------------------------------------------------- - void SingleChangeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation const& aChanges) - { - OSL_ASSERT(aChanges.size() <= 1); - if (!aChanges.empty()) - { - std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); - - OSL_ENSURE( m_aChangingValue == it->location.getChangingValueID(), "Broadcasting unanticipated change"); - - querySingleConstraint(*it, false); - } - - } - // ----------------------------------------------------------------------------------------------- - void SingleChangeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation const& aChanges) - { - OSL_ASSERT(aChanges.size() <= 1); - if (!aChanges.empty()) - { - css::beans::PropertyChangeEvent aEvent; - css::beans::PropertyChangeEvent * pEventNext = &aEvent; - - std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); - - OSL_ENSURE( m_aChangingValue == it->location.getChangingValueID(), "Broadcasting unanticipated change"); - - notifySingleChange(*it, false, pEventNext); - - if (pEventNext != &aEvent) - { - uno::Sequence< css::beans::PropertyChangeEvent > aPropertyEvents(&aEvent,1); - - uno::Reference< css::beans::XPropertiesChangeListener > const * const SelectListener = 0; - - vos::ORef<NotifierImpl> pNotifierImpl = getNotifierData().first; - - cppu::OInterfaceContainerHelper* pContainer = pNotifierImpl->m_aListeners.getContainer( getNodeIndex(), getCppuType(SelectListener) ); - - if (pContainer) - { - ListenerContainerIterator< css::beans::XPropertiesChangeListener > aIterator(*pContainer); - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try { aIterator.next()->propertiesChange(aPropertyEvents); } catch (uno::Exception & ) {} - } - } - } - } - - // ----------------------------------------------------------------------------------------------- - // MultiChangeBroadcaster_Impl - // ----------------------------------------------------------------------------------------------- - - MultiChangeBroadcaster_Impl::MultiChangeBroadcaster_Impl( - NotifierSet::value_type const& rTreeNotifierData, - configuration::NodeID const& aAffectedID, std::set< configuration::SubNodeID >& aChangedNodes - ) - : NodeLocalBroadcaster_Impl(rTreeNotifierData,aAffectedID) - , m_aChangingNodes() - { - m_aChangingNodes.swap(aChangedNodes); - } - // ----------------------------------------------------------------------------------------------- - NodeLocalBroadcaster_Impl* MultiChangeBroadcaster_Impl::create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangesInformation const& aChanges) - { - if (aChanges.empty()) - return 0; - - OSL_ENSURE(aChanges.begin()->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster"); - - configuration::NodeID aAffectedNodeID = aChanges.begin()->location.getAffectedNodeID(); - if (aAffectedNodeID.isEmpty()) - return 0; - - return create(rLocalNotifier, aAffectedNodeID, aChanges); - } - // ----------------------------------------------------------------------------------------------- - NodeLocalBroadcaster_Impl* MultiChangeBroadcaster_Impl::create( - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeID const& aAffectedNodeID, - configuration::NodeChangesInformation const& aChanges) - { - if (aChanges.empty()) - return 0; - - else if (aChanges.size() == 1) - return SingleChangeBroadcaster_Impl::create(rLocalNotifier,aAffectedNodeID,aChanges.begin()->location); - - else - { - OSL_ENSURE(aAffectedNodeID.isValidNode(),"Cannot broadcast without affected node"); - - std::set< configuration::SubNodeID > aChangedNodes; - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != aChanges.end(); ++it) - { - OSL_ENSURE(it->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster"); - - OSL_ENSURE(it->location.getAffectedNodeID() == aAffectedNodeID, "ERROR: Change is not local to affected node (as advertised)"); - OSL_ENSURE(rLocalNotifier.second->getTree() == it->location.getAffectedTreeRef(), - "ERROR: Tree Mismatch creating Multi Change Broadcaster"); - - configuration::SubNodeID aChangedValueID = it->location.getChangingValueID(); - - aChangedNodes.insert(aChangedValueID); - } - OSL_ENSURE(!aChangedNodes.empty(), "Changes don't affect any nodes"); - - if (aChangedNodes.size() == 1) OSL_TRACE("WARNING: Different changes all affect the same node !"); - - return new MultiChangeBroadcaster_Impl(rLocalNotifier, aAffectedNodeID, aChangedNodes); - } - } - // ----------------------------------------------------------------------------------------------- - void MultiChangeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation const& aChanges) - { - std::vector< configuration::NodeChangeInformation >::const_iterator const stop = aChanges.end(), last = stop-1; - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != stop; ++it) - { - OSL_ENSURE( m_aChangingNodes.find( it->location.getChangingValueID() ) != m_aChangingNodes.end(), "Broadcasting unanticipated change"); - - querySingleConstraint(*it, it != last); - } - - } - // ----------------------------------------------------------------------------------------------- - void MultiChangeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation const& aChanges) - { - uno::Sequence< css::beans::PropertyChangeEvent > aPropertyEvents(aChanges.size()); - - css::beans::PropertyChangeEvent * const pEventStart = aPropertyEvents.getArray(); - css::beans::PropertyChangeEvent * pEventNext = pEventStart; - - std::vector< configuration::NodeChangeInformation >::const_iterator const stop = aChanges.end(), last = stop-1; - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != stop; ++it) - { - // #92463# Skip nodes that are not in the tree - if (it->location.getAffectedNodeID().isEmpty()) continue; - - OSL_ENSURE( m_aChangingNodes.find( it->location.getChangingValueID() ) != m_aChangingNodes.end(), "Broadcasting unanticipated change"); - - notifySingleChange(*it, it != last, pEventNext); - } - - sal_Int32 nPropertyEvents = pEventNext-pEventStart; - - if (nPropertyEvents > 0) - { - OSL_ASSERT(nPropertyEvents <= aPropertyEvents.getLength()); - if (nPropertyEvents != aPropertyEvents.getLength()) - aPropertyEvents.realloc(nPropertyEvents); - - uno::Reference< css::beans::XPropertiesChangeListener > const * const SelectListener = 0; - - vos::ORef<NotifierImpl> pNotifierImpl = getNotifierData().first; - - cppu::OInterfaceContainerHelper* pContainer = pNotifierImpl->m_aListeners.getContainer( getNodeIndex(), getCppuType(SelectListener) ); - - if (pContainer) - { - ListenerContainerIterator< css::beans::XPropertiesChangeListener > aIterator(*pContainer); - UnoApiLockReleaser aGuardReleaser; - while (aIterator.hasMoreElements()) - try { aIterator.next()->propertiesChange(aPropertyEvents); } catch (uno::Exception & ) {} - } - } - } - // ----------------------------------------------------------------------------------------------- - // TreeLocalBroadcaster_Impl - // ----------------------------------------------------------------------------------------------- - - SingleTreeBroadcaster_Impl::SingleTreeBroadcaster_Impl( - NotifierSet::value_type const& aTreeNotifierData, - std::vector< vos::ORef<NodeLocalBroadcaster_Impl> >& aBroadcasters - ) - : Broadcaster::Impl(aTreeNotifierData) - , m_aBroadcasters() - { - m_aBroadcasters.swap(aBroadcasters); - } - - // ----------------------------------------------------------------------------------------------- - - bool SingleTreeBroadcaster_Impl::selectChanges(configuration::NodeChangesInformation& rSelected, configuration::NodeChangesInformation const& aOriginal, configuration::NodeID const& aSelector) - { - OSL_ASSERT(rSelected.empty()); // nothing in there yet - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aOriginal.begin(); it != aOriginal.end(); ++it) - { - if ( it->location.getAffectedNodeID() == aSelector ) - { - rSelected.push_back(*it); - } - } - return !rSelected.empty(); - } - // ----------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > SingleTreeBroadcaster_Impl::create( - NotifierSet::value_type const& rRootNotifier, - NotifierSet::value_type const& rLocalNotifier, - configuration::NodeChangesInformation const& aChanges) - { - std::set< configuration::NodeID > aNodes; - for (std::vector< configuration::NodeChangeInformation >::const_iterator itChanges = aChanges.begin(); itChanges != aChanges.end(); ++itChanges) - { - OSL_ENSURE(itChanges->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster"); - - configuration::NodeID aAffectedNodeID = itChanges->location.getAffectedNodeID(); - if (!aAffectedNodeID.isEmpty()) - aNodes.insert(aAffectedNodeID); - } - - std::vector< vos::ORef<NodeLocalBroadcaster_Impl> > aNodecasters; - for (std::set< configuration::NodeID >::const_iterator itNodes = aNodes.begin(); itNodes != aNodes.end(); ++itNodes) - { - OSL_ASSERT(itNodes->isValidNode()); // filtered empty ones above - - configuration::NodeChangesInformation aSelectedChanges; - if ( selectChanges(aSelectedChanges, aChanges, *itNodes)) - { - NodeLocalBroadcaster_Impl* pSelectedImpl = MultiChangeBroadcaster_Impl::create(rLocalNotifier, *itNodes, aSelectedChanges); - if (pSelectedImpl) - aNodecasters.push_back(pSelectedImpl); - } - } - - if (aNodecasters.empty()) - return 0; - - else if (aNodecasters.size() == 1) - return aNodecasters.begin()->getBodyPtr(); - - else - return new SingleTreeBroadcaster_Impl(rRootNotifier, aNodecasters); - } - // ----------------------------------------------------------------------------------------------- - void SingleTreeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation const& aChanges) - { - for(std::vector< vos::ORef<NodeLocalBroadcaster_Impl> >::iterator it = m_aBroadcasters.begin(); it != m_aBroadcasters.end(); ++it) - { - configuration::NodeChangesInformation aSelectedInfos; - if ( selectChanges(aSelectedInfos, aChanges, (*it)->getAffectedNodeID()) ) - (*it)->queryConstraints(aSelectedInfos); - } - } - // ----------------------------------------------------------------------------------------------- - void SingleTreeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation const& aChanges) - { - for(std::vector< vos::ORef<NodeLocalBroadcaster_Impl> >::iterator it = m_aBroadcasters.begin(); it != m_aBroadcasters.end(); ++it) - { - configuration::NodeChangesInformation aSelectedInfos; - if ( selectChanges(aSelectedInfos, aChanges, (*it)->getAffectedNodeID()) ) - (*it)->notifyListeners(aSelectedInfos); - } - } - // ----------------------------------------------------------------------------------------------- - // MultiTreeBroadcaster_Impl - // ----------------------------------------------------------------------------------------------- - MultiTreeBroadcaster_Impl::MultiTreeBroadcaster_Impl(NotifierSet::value_type const& aRootSelector, std::vector< vos::ORef< Broadcaster::Impl > >& aBroadcasters) - : Broadcaster::Impl(aRootSelector) - , m_aBroadcasters() - { - m_aBroadcasters.swap(aBroadcasters); - } - - // ----------------------------------------------------------------------------------------------- - - bool MultiTreeBroadcaster_Impl::selectChanges(configuration::NodeChangesInformation& rSelected, configuration::NodeChangesInformation const& aOriginal, NotifierSet::value_type const& aSelector) - { - OSL_ASSERT(aSelector.first.isValid()); - OSL_ASSERT(aSelector.second.is()); - - OSL_ASSERT(rSelected.empty()); // nothing in there yet - - rtl::Reference< configuration::Tree > const aSelectedTree( aSelector.second->getTree() ); - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aOriginal.begin(); it != aOriginal.end(); ++it) - { - if (it->location.getAffectedTreeRef() == aSelectedTree) - { - rSelected.push_back(*it); - } - } - return !rSelected.empty(); - } - // ------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > MultiTreeBroadcaster_Impl::create(NotifierSet::value_type const& rRootNotifier, NotifierSet const& rNotifiers, configuration::NodeChangesInformation const& aChanges) - { - std::vector< vos::ORef< Broadcaster::Impl > > aTreecasters; - for (NotifierSet::const_iterator it = rNotifiers.begin(); it != rNotifiers.end(); ++it) - { - configuration::NodeChangesInformation aSelectedChanges; - if ( selectChanges(aSelectedChanges, aChanges, *it)) - { - vos::ORef< Broadcaster::Impl > pSelectedImpl = SingleTreeBroadcaster_Impl::create(rRootNotifier, *it, aSelectedChanges); - if (pSelectedImpl.isValid()) - aTreecasters.push_back(pSelectedImpl); - } - } - - if (aTreecasters.empty()) - return 0; - - else if (aTreecasters.size() == 1) - return *aTreecasters.begin(); - - else - return new MultiTreeBroadcaster_Impl(rRootNotifier, aTreecasters); - } - // ------------------------------------------------------------------------------------------- - - void MultiTreeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation const& aChanges) - { - for(std::vector< vos::ORef< Broadcaster::Impl > >::iterator it = m_aBroadcasters.begin(); it != m_aBroadcasters.end(); ++it) - { - configuration::NodeChangesInformation aSelectedInfos; - if ( selectChanges(aSelectedInfos, aChanges, (*it)->getNotifierData()) ) - (*it)->queryConstraints(aSelectedInfos); - } - } - // ------------------------------------------------------------------------------------------- - - void MultiTreeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation const& aChanges) - { - for(std::vector< vos::ORef< Broadcaster::Impl > >::iterator it = m_aBroadcasters.begin(); it != m_aBroadcasters.end(); ++it) - { - configuration::NodeChangesInformation aSelectedInfos; - if ( selectChanges(aSelectedInfos, aChanges, (*it)->getNotifierData()) ) - (*it)->notifyListeners(aSelectedInfos); - } - } - // ----------------------------------------------------------------------------------------------- - } -// --------------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > Broadcaster::Impl::create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChange const& aChange, bool bLocal) - { - OSL_ASSERT(pTreeImpl.is()); - - vos::ORef< Broadcaster::Impl > pRet; - - configuration::NodeChangeLocation aLocation; - if (aChange.getChangeLocation(aLocation)) - { - if (bLocal) - { - pRet = SingleChangeBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl,pTreeImpl), aLocation); - } - else - { - NotifierSet::value_type aAffectedNotifier( findNotifier(aLocation, pTreeImpl) ); - if (aAffectedNotifier.second.is()) // only if we found a notifier we are able to create a broadcaster (DG) - pRet = SingleChangeBroadcaster_Impl::create( aAffectedNotifier, aLocation); - } - } - else - { - OSL_ENSURE(false, "Invalid change location set in node change - cannot broadcast"); - // can't create a matching change - must still create an empty one - } - - if (pRet.isEmpty()) - pRet = EmptyBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl,pTreeImpl) ); - - return pRet; - } -// --------------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > Broadcaster::Impl::create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChanges const& aChanges, bool bLocal) - { - NotifierSet::value_type aRootData(rNotifierImpl, pTreeImpl); - - configuration::NodeChangesInformation aChangeInfos; - if (aChanges.getChangesInfos(aChangeInfos)) - { - return create(rNotifierImpl,pTreeImpl,aChangeInfos,bLocal); - } - else - { - OSL_ENSURE(aChanges.isEmpty(), "Cannot get information for changes - cannot notify"); - - // make an empty one below - vos::ORef< Broadcaster::Impl > pRet = EmptyBroadcaster_Impl::create( aRootData ); - - return pRet; - } - - } -// --------------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > Broadcaster::Impl::create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChangeInformation const& aChange, bool bLocal) - { - OSL_ASSERT(pTreeImpl.is()); - - vos::ORef< Broadcaster::Impl > pRet; - - if (aChange.hasValidLocation()) - { - if (bLocal) - { - pRet = SingleChangeBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl,pTreeImpl), aChange.location); - } - else - { - NotifierSet::value_type aAffectedNotifier( findNotifier(aChange.location, pTreeImpl) ); - if (aAffectedNotifier.second.is()) // only if we found a notifier we are able to create a broadcaster (DG) - pRet = SingleChangeBroadcaster_Impl::create( aAffectedNotifier, aChange.location); - } - } - else - { - OSL_ENSURE(false, "Invalid change location set in node change - cannot broadcast"); - // can't create a matching change - must still create an empty one - } - - if (pRet.isEmpty()) - pRet = EmptyBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl,pTreeImpl) ); - - return pRet; - } -// --------------------------------------------------------------------------------------------------- - - vos::ORef< Broadcaster::Impl > Broadcaster::Impl::create(vos::ORef<NotifierImpl> const& rNotifierImpl, ApiTreeRef const& pTreeImpl, configuration::NodeChangesInformation const& aChanges, bool bLocal) - { - vos::ORef< Broadcaster::Impl > pRet; - - NotifierSet::value_type aRootData(rNotifierImpl, pTreeImpl); - - if (aChanges.size() == 1) - { - pRet = create(rNotifierImpl, pTreeImpl, *aChanges.begin(), bLocal); - } - else if (bLocal) - { - pRet = MultiChangeBroadcaster_Impl::create( aRootData, aChanges); - } - else - { - NotifierSet aNotifiers; - findNotifiers( aNotifiers, aChanges, pTreeImpl); - - if (aNotifiers.size() > 1) - { - pRet = MultiTreeBroadcaster_Impl::create(aRootData, aNotifiers, aChanges); - } - else if (!aNotifiers.empty()) - { - pRet = SingleTreeBroadcaster_Impl::create(aRootData, *aNotifiers.begin(), aChanges); - } - // else: empty - } - - if (pRet.isEmpty()) - pRet = EmptyBroadcaster_Impl::create( aRootData ); - - return pRet; - } -// --------------------------------------------------------------------------------------------------- - - bool Broadcaster::Impl::translateChanges(configuration::NodeChangesInformation& _rInfos, configuration::NodeChanges const& aChanges, bool /*bSingleBase*/) const - { - rtl::Reference< configuration::Tree > aBaseTree = m_aNotifierData.second->getTree(); - Factory& rFactory = m_aNotifierData.second->getFactory(); - - configuration::NodeChangesInformation aRawInfos; - - sal_uInt32 nChanges = aChanges.getChangesInfos(aRawInfos); - - OSL_ENSURE(nChanges, "Cannot get info(s) for change - skipping for notification"); - OSL_ENSURE(nChanges == aRawInfos.size(), "Incorrect change count returned"); - - configuration::NodeChangesInformation aNewInfos; - aNewInfos.reserve(nChanges); - - for (std::vector< configuration::NodeChangeInformation >::const_iterator pos = aRawInfos.begin(); pos != aRawInfos.end(); ++pos) - { - configuration::NodeChangeInformation aInfo = *pos; - if( !configapi::rebaseChange(aInfo.location,aBaseTree) ) - { - OSL_TRACE("Change is not within expected tree - skipping for notification"); - continue; - } - - OSL_ENSURE(!pos->isEmptyChange(), "Empty Change Found for Notification"); - // it actually is expected that elements may not be found - thus ignoring result - configapi::resolveToUno(aInfo.change, rFactory); - - aNewInfos.push_back( aInfo ); - } - - aNewInfos.swap(_rInfos); - - return !_rInfos.empty(); - } - -// --------------------------------------------------------------------------------------------------- - - bool Broadcaster::Impl::translateChanges(configuration::NodeChangesInformation& aInfos, configuration::NodeChangesInformation const& aChanges, bool /*bSingleBase*/) const - { - configuration::NodeChangesInformation aNewInfos; - aNewInfos.reserve( aChanges.size() ); - - rtl::Reference< configuration::Tree > aBaseTree = m_aNotifierData.second->getTree(); - Factory& rFactory = m_aNotifierData.second->getFactory(); - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != aChanges.end(); ++it) - { - configuration::NodeChangeInformation aInfo(*it); - if( !configapi::rebaseChange(aInfo.location,aBaseTree) ) - { - OSL_TRACE("Change is not within expected tree - skipping for notification"); - continue; - } - - if( !configapi::resolveToUno(aInfo.change,rFactory) ) - { - // it actually is expected that elements may not be found - // OSL_TRACE("Cannot find affected elements of Change"); - } - - aNewInfos.push_back( aInfo ); - } - - aNewInfos.swap(aInfos); - return !aInfos.empty(); - } - -// --------------------------------------------------------------------------------------------------- - void Broadcaster::Impl::notifyRootListeners(configuration::NodeChangesInformation const& aChanges) - { - if (aChanges.empty()) return; - - ApiTreeRef pRootTree( m_aNotifierData.second->getRootTreeImpl() ); - if (pRootTree.is()) - { - vos::ORef<NotifierImpl> aRootNotifier = BroadcasterHelper::getImpl(pRootTree->getNotifier()); - if (aRootNotifier.isValid()) - { - uno::Reference< css::util::XChangesListener > const * const pSelect = 0; - - configuration::NodeID aNotifiedNode = makeRootID( pRootTree ); - - if (cppu::OInterfaceContainerHelper* pContainer = aRootNotifier->m_aListeners.getContainer(aNotifiedNode.toIndex(), ::getCppuType(pSelect)) ) - { - css::util::ChangesEvent aEvent; - aEvent.Source = pRootTree->getUnoInstance(); - - uno::Reference<uno::XInterface> xBaseInstance = m_aNotifierData.second->getUnoInstance(); - aEvent.Base <<= xBaseInstance; - - // translate and collect the changes - aEvent.Changes.realloc(aChanges.size()); - css::util::ElementChange* pChange = aEvent.Changes.getArray(); - - for (std::vector< configuration::NodeChangeInformation >::const_iterator it = aChanges.begin(); it != aChanges.end(); ++it) - { - fillChangeFromResolved(*pChange, *it); - ++pChange; - } - - // now notify - ListenerContainerIterator< css::util::XChangesListener > aIter(*pContainer); - - UnoApiLockReleaser aGuardReleaser; - while (aIter.hasMoreElements()) - try { aIter.next()->changesOccurred(aEvent); } catch (uno::Exception & ) {} - } - } - } - } - -// --------------------------------------------------------------------------------------------------- -// class Broadcaster -// --------------------------------------------------------------------------------------------------- -Broadcaster::Broadcaster(Notifier const& aNotifier, configuration::NodeChange const& aChange, bool bLocal) -: m_pImpl( Impl::create(aNotifier.m_aImpl,ApiTreeRef(aNotifier.m_pTree),aChange,bLocal) ) -{ - OSL_ASSERT(m_pImpl.isValid()); -} -// --------------------------------------------------------------------------------------------------- -Broadcaster::Broadcaster(Notifier const& aNotifier, configuration::NodeChanges const& aChanges, bool bLocal) -: m_pImpl( Impl::create(aNotifier.m_aImpl,ApiTreeRef(aNotifier.m_pTree),aChanges,bLocal) ) -{ - OSL_ASSERT(m_pImpl.isValid()); -} -// --------------------------------------------------------------------------------------------------- -Broadcaster::Broadcaster(Notifier const& aNotifier, configuration::NodeChangesInformation const& aChanges, bool bLocal) -: m_pImpl( Impl::create(aNotifier.m_aImpl,ApiTreeRef(aNotifier.m_pTree),aChanges,bLocal) ) -{ - OSL_ASSERT(m_pImpl.isValid()); -} -// --------------------------------------------------------------------------------------------------- - -Broadcaster::Broadcaster(Broadcaster const& aOther) -: m_pImpl(aOther.m_pImpl) -{ - OSL_ASSERT(m_pImpl.isValid()); -} -// --------------------------------------------------------------------------------------------------- - -Broadcaster::~Broadcaster() -{ -} -// --------------------------------------------------------------------------------------------------- - -void Broadcaster::queryConstraints(configuration::NodeChange const& aChange) throw(beans::PropertyVetoException) -{ - OSL_ENSURE(aChange.isChange(),"Constraint query without a change !"); - - configuration::NodeChanges aChanges; - aChanges.add(aChange); - this->queryConstraints(aChanges,true); -} -// --------------------------------------------------------------------------------------------------- - -void Broadcaster::queryConstraints(configuration::NodeChanges const& aChanges, bool bSingleBase) throw(beans::PropertyVetoException) -{ - OSL_ENSURE(!aChanges.isEmpty(),"Constraint query without a change !"); - - try - { - configuration::NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges,bSingleBase)) - { - m_pImpl->queryConstraints(aInfos); - } - } - catch (beans::PropertyVetoException & ) - { - throw; - } - catch (uno::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); - } - catch (configuration::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); - } -} -// --------------------------------------------------------------------------------------------------- - -void Broadcaster::notifyListeners(configuration::NodeChange const& aChange) throw() -{ - OSL_ENSURE(aChange.isChange(),"Notifying without a change !"); - - configuration::NodeChanges aChanges; - aChanges.add(aChange); - this->notifyListeners(aChanges, true); -} -// --------------------------------------------------------------------------------------------------- - -void Broadcaster::notifyListeners(configuration::NodeChanges const& aChanges, bool bSingleBase) throw() -{ - OSL_ENSURE(!aChanges.isEmpty(),"Notifying without a change !"); - - try - { - configuration::NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) - { - m_pImpl->notifyListeners(aInfos); - m_pImpl->notifyRootListeners(aInfos); - } - } - catch (uno::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); - } - catch (configuration::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); - } -} -// --------------------------------------------------------------------------------------------------- - -void Broadcaster::notifyListeners(configuration::NodeChangesInformation const& aChanges, bool bSingleBase) throw() -{ - OSL_ENSURE(!aChanges.empty(),"Notifying without a change !"); - - try - { - configuration::NodeChangesInformation aInfos; - if (m_pImpl->translateChanges(aInfos,aChanges, bSingleBase)) - { - m_pImpl->notifyListeners(aInfos); - m_pImpl->notifyRootListeners(aInfos); - } - } - catch (uno::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners"); - } - catch (configuration::Exception & ) - { - OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners"); - } -} -// --------------------------------------------------------------------------------------------------- - } -} diff --git a/configmgr/source/api2/broadcaster.hxx b/configmgr/source/api2/broadcaster.hxx deleted file mode 100644 index c247750dcfe4..000000000000 --- a/configmgr/source/api2/broadcaster.hxx +++ /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. - * - ************************************************************************/ - -#ifndef CONFIGMGR_API_BROADCASTER_HXX_ -#define CONFIGMGR_API_BROADCASTER_HXX_ - -#include <com/sun/star/beans/PropertyVetoException.hpp> - -#include <vos/ref.hxx> - -namespace configmgr -{ - namespace configuration - { -// --------------------------------------------------------------------------------------------------- - class NodeChange; - class NodeChanges; - class NodeChangeInformation; - class NodeChangesInformation; - } -// --------------------------------------------------------------------------------------------------- - namespace configapi - { - class Notifier; - - namespace css = ::com::sun::star; -// --------------------------------------------------------------------------------------------------- - - /// broadcasts events for changes to a single config node or several sibling nodes - class Broadcaster - { - public: - /// construct a broadcaster - Broadcaster(Notifier const& aNotifier, configuration::NodeChange const& aChange, bool bLocal); - Broadcaster(Notifier const& aNotifier, configuration::NodeChanges const& aChanges, bool bLocal); - Broadcaster(Notifier const& aNotifier, configuration::NodeChangesInformation const& aChanges, bool bLocal); - Broadcaster(Broadcaster const& aOther); - ~Broadcaster(); - - /// give all property veto listeners on the affected node a chance to veto - void queryConstraints(configuration::NodeChange const& aChange) throw(css::beans::PropertyVetoException); - /// give all property veto listeners on any of the affected nodes a chance to veto - void queryConstraints(configuration::NodeChanges const& aChanges, bool bSingleBase = true) throw(css::beans::PropertyVetoException); - - /// notify all listeners which are affected by this change - void notifyListeners(configuration::NodeChange const& aChange) throw(); - /// notify all listeners which are affected by any of these changes (potentially from many different bases) - void notifyListeners(configuration::NodeChanges const& aChanges, bool bSingleBase) throw(); - /// notify all listeners which are affected by any of these changes (potentially from many different bases) - void notifyListeners(configuration::NodeChangesInformation const& aChanges, bool bSingleBase = false) throw(); - - class Impl; - private: - vos::ORef<Impl> m_pImpl; - private: - void operator=(Broadcaster const& aOther); - }; - -// --------------------------------------------------------------------------------------------------- - - } -} - -#endif // CONFIGMGR_API_BROADCASTER_HXX_ diff --git a/configmgr/source/api2/committer.cxx b/configmgr/source/api2/committer.cxx deleted file mode 100644 index a19743c79f3c..000000000000 --- a/configmgr/source/api2/committer.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 <stdio.h> -#include "committer.hxx" -#include "apitreeimplobj.hxx" -#include "providerimpl.hxx" -#include "roottree.hxx" -#include "treechangelist.hxx" - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- -namespace -{ - //------------------------------------------------------------------------- - struct NotifyDisabler - { - ApiRootTreeImpl& m_rTree; - bool m_bOldState; - - NotifyDisabler(ApiRootTreeImpl& rTree) - : m_rTree(rTree) - , m_bOldState(rTree .enableNotification(false) ) - { - } - - ~NotifyDisabler() - { - m_rTree.enableNotification(m_bOldState); - } - }; - //------------------------------------------------------------------------- -} - -//----------------------------------------------------------------------------- -// class Committer -//----------------------------------------------------------------------------- - -Committer::Committer(ApiRootTreeImpl& rTree) -: m_rTree(rTree) -{} -//----------------------------------------------------------------------------- - -OProviderImpl * Committer::getUpdateProvider() -{ - return &m_rTree.getApiTree().getProvider().getProviderImpl(); -} - -//----------------------------------------------------------------------------- -void Committer::commit() -{ - ApiTreeImpl& rApiTree = m_rTree.getApiTree(); - - OSL_PRECOND(!m_rTree.getLocation().isRoot(),"INTERNAL ERROR: Empty location used."); - OSL_PRECOND(m_rTree.getOptions().isValid(),"INTERNAL ERROR: Invalid Options used."); - - if (!m_rTree.getOptions().isValid()) return; - - RequestOptions aOptions = m_rTree.getOptions()->getRequestOptions(); - - OProviderImpl * pUpdateProvider = getUpdateProvider(); - OSL_ASSERT(pUpdateProvider); - - rtl::Reference< configuration::Tree > aTree( rApiTree.getTree()); - if (!aTree->hasChanges()) return; - - TreeChangeList aChangeList(aOptions, - aTree->getRootPath(), - aTree->getAttributes(aTree->getRootNode())); - - // now do the commit - configuration::CommitHelper aHelper(rApiTree.getTree()); - if (aHelper.prepareCommit(aChangeList)) - try - { - pUpdateProvider->updateTree(aChangeList); - - aHelper.finishCommit(aChangeList); - - NotifyDisabler aDisableNotify(m_rTree); // do not notify self - pUpdateProvider->saveAndNotifyUpdate(aChangeList); - } - catch(...) - { - // should be a special clean-up routine, but for now we just need a consistent state - try - { - aHelper.failedCommit(aChangeList); - } - catch(configuration::Exception&) - { - OSL_ENSURE(false, "Cleanup really should not throw"); - } - throw; - } -} -//----------------------------------------------------------------------------- - } -} - diff --git a/configmgr/source/api2/committer.hxx b/configmgr/source/api2/committer.hxx deleted file mode 100644 index 895321235ddf..000000000000 --- a/configmgr/source/api2/committer.hxx +++ /dev/null @@ -1,57 +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_API_COMMITTER_HXX_ -#define CONFIGMGR_API_COMMITTER_HXX_ - -namespace configmgr -{ - class OProviderImpl; -//----------------------------------------------------------------------------- - namespace configapi - { -//----------------------------------------------------------------------------- - - class ApiRootTreeImpl; -//----------------------------------------------------------------------------- - - /// allows to update values of a simple type within a <type>NodeRef</type> that refers to a Group - class Committer - { - ApiRootTreeImpl& m_rTree; - public: - Committer(ApiRootTreeImpl& rTree); - - void commit(); - private: - OProviderImpl * getUpdateProvider(); - }; -//----------------------------------------------------------------------------- - } -} - -#endif // CONFIGMGR_API_COMMITTER_HXX_ diff --git a/configmgr/source/api2/confignotifier.cxx b/configmgr/source/api2/confignotifier.cxx deleted file mode 100644 index 2de91c9775ed..000000000000 --- a/configmgr/source/api2/confignotifier.cxx +++ /dev/null @@ -1,243 +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 "confignotifier.hxx" - -#include "notifierimpl.hxx" -#include "broadcaster.hxx" - -#include "noderef.hxx" -#include "valueref.hxx" -#include "nodechange.hxx" - -#include "apinodeaccess.hxx" -#include "apitreeaccess.hxx" -#include "apitreeimplobj.hxx" - -#include <set> -#include <functional> - -namespace configmgr -{ - namespace configapi - { -// --------------------------------------------------------------------------------------------------- -// class Notifier (-Impl) -// --------------------------------------------------------------------------------------------------- - -Notifier::Notifier(vos::ORef<NotifierImpl> const& aImpl,ApiTreeImpl const* pTree) -: m_aImpl(aImpl) -, m_pTree(pTree) -{ - OSL_ENSURE(aImpl.isValid(),"Invalid initialization of a Notifier: No impl"); - OSL_ENSURE(pTree,"Invalid initialization of a Notifier: No tree"); -} -// --------------------------------------------------------------------------------------------------- - -Notifier::Notifier(Notifier const& aOther) -: m_aImpl(aOther.m_aImpl) -, m_pTree(aOther.m_pTree) -{ -} -// --------------------------------------------------------------------------------------------------- - -Notifier::~Notifier() -{ -} -// --------------------------------------------------------------------------------------------------- - -Broadcaster Notifier::makeBroadcaster(configuration::NodeChange const& aChange, bool bLocal) const -{ - return Broadcaster(*this,aChange,bLocal); -} -// --------------------------------------------------------------------------------------------------- - -Broadcaster Notifier::makeBroadcaster(configuration::NodeChanges const& aChanges, bool bLocal) const -{ - OSL_ENSURE(!aChanges.isEmpty(),"Creating broadcaster for no changes"); - return Broadcaster(*this,aChanges,bLocal); -} -// --------------------------------------------------------------------------------------------------- - -NotifierImpl::NotifierImpl(rtl::Reference< configuration::Tree > const& aTree) -: m_aListeners(aTree->nodeCount(), SubNodeToIndex(aTree)) -{ -} -// --------------------------------------------------------------------------------------------------- - -NotifierImpl::~NotifierImpl() -{ -} - -// --------------------------------------------------------------------------------------------------- - -void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->addForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const -{ - if (xListener.is()) - m_aImpl->addNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->addForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const -{ - if (xListener.is()) - m_aImpl->addNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence<rtl::OUString> const& aNames) const -{ - if (xListener.is()) - { - if (aNames.getLength() > 0) - m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener, aNames); - else - m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); - } -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->removeForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const -{ - if (xListener.is()) - m_aImpl->removeNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->removeForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const -{ - if (xListener.is()) - m_aImpl->removeNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener ); -} -// --------------------------------------------------------------------------------------------------- - -void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) const -{ - if (xListener.is()) - m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener ); -} - -// --------------------------------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------------------- - -DisposeGuardImpl::DisposeGuardImpl(Notifier const&) throw() -{ -} -// --------------------------------------------------------------------------------------------------- -DisposeGuardImpl::~DisposeGuardImpl() throw () -{ -} -// --------------------------------------------------------------------------------------------------- -GuardedNotifier::GuardedNotifier(NodeAccess& rNode) throw() -: m_aNotifier(rNode.getNotifier()) -, m_aImpl(m_aNotifier) -{ -} -// --------------------------------------------------------------------------------------------------- - -DisposeGuard::DisposeGuard(NodeAccess& rNode) throw(css::lang::DisposedException) -: m_aImpl(rNode.getNotifier()) -{ - rNode.checkAlive(); -} -// --------------------------------------------------------------------------------------------------- - } -} - diff --git a/configmgr/source/api2/confignotifier.hxx b/configmgr/source/api2/confignotifier.hxx deleted file mode 100644 index 0e3a35841bbf..000000000000 --- a/configmgr/source/api2/confignotifier.hxx +++ /dev/null @@ -1,197 +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_CONFIGNOTIFIER_HXX_ -#define CONFIGMGR_CONFIGNOTIFIER_HXX_ - -#include "configexcept.hxx" -#include "configpath.hxx" -#include "datalock.hxx" -#include "utility.hxx" -#include <boost/utility.hpp> -#include <vos/ref.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -namespace com { namespace sun { namespace star { - namespace beans - { - class XPropertyChangeListener; - class XVetoableChangeListener; - class XPropertiesChangeListener; - class PropertyVetoException; - } - namespace lang - { - class XEventListener; - struct EventObject; - } - namespace container { class XContainerListener; } - namespace util { class XChangesListener; } - namespace uno { class RuntimeException; } -} } } -namespace osl { class Mutex; } - -namespace configmgr -{ - namespace configuration - { -// --------------------------------------------------------------------------------------------------- - class NodeRef; - class ValueRef; - class NodeChange; - class NodeChanges; - } -// --------------------------------------------------------------------------------------------------- - namespace configapi - { -// --------------------------------------------------------------------------------------------------- - class Broadcaster; - class NotifierImpl; - class ApiTreeImpl; - - namespace css = ::com::sun::star; -// --------------------------------------------------------------------------------------------------- - /// manages collections of event listeners observing a config tree, thread-safe - class Notifier - { - friend class Broadcaster; - friend class BroadcasterHelper; - vos::ORef<NotifierImpl> m_aImpl; - ApiTreeImpl const*const m_pTree; - public: - /// construct this around the given Implementation, for the given tree - explicit Notifier(vos::ORef<NotifierImpl> const & aImpl, ApiTreeImpl const* pTree); - Notifier(Notifier const& aOther); - ~Notifier(); - - // --------------------------------------------------------------------------------------------------- - /// create a broadcaster for a single change (either local or (possibly) nested) - Broadcaster makeBroadcaster(configuration::NodeChange const& aChange, bool bLocal) const; - /// create a broadcaster for a collection of changes (either local or (possibly) nested) - Broadcaster makeBroadcaster(configuration::NodeChanges const& aChange, bool bLocal) const; - - // --------------------------------------------------------------------------------------------------- - bool checkAlive(uno::XInterface* pObject) const throw(css::lang::DisposedException); - - // --------------------------------------------------------------------------------------------------- - /// Add a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>. - void add(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const; - - /// Add a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>. - void add(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const; - - /// Add a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants. - void add(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const; - - /// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing all children of <var>aNode</var>. - void addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const; - /// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing only the child named <var>aName</var> of <var>aNode</var>. - void addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const; - /// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining all children of <var>aNode</var>. - void addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const; - /// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining only the child named <var>aName</var> of <var>aNode</var>. - void addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const; - - /** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type> - observing the properties of <var>aNode</var> (optimally only those given by <var>aNames</var>. - */ - void add(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence<rtl::OUString> const& aNames) const; - - // --------------------------------------------------------------------------------------------------- - /// Remove a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>. - void remove(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const; - - /// Remove a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>. - void remove(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const; - - /// Remove a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants. - void remove(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const; - - /// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>. - void removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const; - /// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing the child named <var>aName</var> of <var>aNode</var>. - void removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const; - /// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const; - /// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining the child named <var>aName</var> of <var>aNode</var>. - void removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const; - - /// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const; - /** Remove a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type> - observing any properties of <var>aNode</var>. - */ - void remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) const; - // --------------------------------------------------------------------------------------------------- - private: - void operator=(Notifier const& aOther); - }; -// --------------------------------------------------------------------------------------------------- - -// Thin Wrappers around Notifiers: Provide guarding and convenient access - // Guarding and locking implementations - class NodeAccess; - class TreeElement; - - /// guards a NodeAccess; provides a simple lock for non-data access, does not check for disposed state - class DisposeGuardImpl: private boost::noncopyable - { - public: - DisposeGuardImpl(Notifier const& rNotifier) throw(); - ~DisposeGuardImpl() throw (); - }; - - /// wraps a Notifier (from a node or tree); provides a simple lock for notifier access, does not check for disposed state - class GuardedNotifier - { - UnoApiLock m_aLock; - Notifier m_aNotifier; - DisposeGuardImpl m_aImpl; - public: - GuardedNotifier(NodeAccess& rNode) throw(); - public: - Notifier const& get() const { return m_aNotifier; } - - Notifier const& operator *() const { return get(); } - Notifier const* operator->() const { return &get(); } - }; - - /// guards a Node or Tree provides a simple lock for non-data access, does (!) check for disposed state - class DisposeGuard - { - DisposeGuardImpl m_aImpl; - UnoApiLock m_aLock; - public: - DisposeGuard(NodeAccess& rNode) throw(css::lang::DisposedException); - }; - -// --------------------------------------------------------------------------------------------------- - } -} - -#endif // CONFIGMGR_CONFIGNOTIFIER_HXX_ diff --git a/configmgr/source/api2/elementaccess.cxx b/configmgr/source/api2/elementaccess.cxx deleted file mode 100644 index 2b533550968c..000000000000 --- a/configmgr/source/api2/elementaccess.cxx +++ /dev/null @@ -1,486 +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 "elementaccess.hxx" - -#include "elementimpl.hxx" -#include "apinotifierimpl.hxx" - -#include "apitreeaccess.hxx" - -//----------------------------------------------------------------------------------- -namespace configmgr -{ -//----------------------------------------------------------------------------------- - - namespace uno = com::sun::star::uno; - -//----------------------------------------------------------------------------------- -// XInterface (but not method queryInterface) -//----------------------------------------------------------------------------------- - -// acuire doesn't really do anything but forward. OTOH it should always be overridden when release() is -void SAL_CALL BasicInnerElement ::acquire() throw() { cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::acquire(); } -void SAL_CALL BasicSetElement ::acquire() throw() { cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::acquire(); } -void SAL_CALL BasicRootElement ::acquire() throw() { cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::acquire(); } -void SAL_CALL BasicUpdateElement::acquire() throw() { cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::acquire(); } -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicInnerElement::release() throw() -{ - // FIXME: this looks highly flaky wrt. weak-refs etc. - bool bLastRef = (1 == m_refCount); - if (bLastRef) - { - UnoApiLock::acquire(); - configapi::implDisposeObject( getNodeAccess(), getElementClass() ); - } - cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::release(); - if (bLastRef) - UnoApiLock::release(); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSetElement::release() throw() -{ - // FIXME: this looks highly flaky wrt. weak-refs etc. - bool bLastRef = (1 == m_refCount); - if (bLastRef) - { - UnoApiLock::acquire(); - configapi::implDisposeObject( getNodeAccess(), getElementClass() ); - } - cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::release(); - if (bLastRef) - UnoApiLock::release(); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::release() throw() -{ - // FIXME: this looks highly flaky wrt. weak-refs etc. - bool bLastRef = (1 == m_refCount); - if (bLastRef) - { - UnoApiLock::acquire(); - configapi::implDisposeObject( getNodeAccess(), getElementClass() ); - } - cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::release(); - if (bLastRef) - UnoApiLock::release(); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::release() throw() -{ - // FIXME: this looks highly flaky wrt. weak-refs etc. - bool bLastRef = (1 == m_refCount); - if (bLastRef) - { - UnoApiLock::acquire(); - configapi::implDisposeObject( getNodeAccess(), getElementClass() ); - } - cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::release(); - if (bLastRef) - UnoApiLock::release(); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XTypeProvider (but not method getTypes) -//----------------------------------------------------------------------------------- - -uno::Sequence<sal_Int8> SAL_CALL BasicInnerElement::getImplementationId( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence<sal_Int8> SAL_CALL BasicSetElement::getImplementationId( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence<sal_Int8> SAL_CALL BasicRootElement::getImplementationId( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence<sal_Int8> SAL_CALL BasicUpdateElement::getImplementationId( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationId( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XChild (not for root elements) -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > SAL_CALL BasicInnerElement::getParent( ) throw(uno::RuntimeException) -{ - return configapi::implGetParent( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > SAL_CALL BasicSetElement::getParent( ) throw(uno::RuntimeException) -{ - return configapi::implGetParent( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicInnerElement::setParent( const uno::Reference< uno::XInterface >& xParent ) - throw(css::lang::NoSupportException, uno::RuntimeException) -{ - configapi::implSetParent( getNodeAccess(), getElementClass(), xParent ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSetElement::setParent( const uno::Reference< uno::XInterface >& xParent ) - throw(css::lang::NoSupportException, uno::RuntimeException) -{ - configapi::implSetParent( getNodeAccess(), getElementClass(), xParent ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XNamed -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicInnerElement::getName( ) throw(uno::RuntimeException) -{ - return configapi::implGetName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicSetElement::getName( ) throw(uno::RuntimeException) -{ - return configapi::implGetName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicRootElement::getName( ) throw(uno::RuntimeException) -{ - return configapi::implGetName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicUpdateElement::getName( ) throw(uno::RuntimeException) -{ - return configapi::implGetName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicInnerElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException) -{ - configapi::implSetName( getNodeAccess(), getElementClass(), aName ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSetElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException) -{ - configapi::implSetName( getNodeAccess(), getElementClass(), aName ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException) -{ - configapi::implSetName( getNodeAccess(), getElementClass(), aName ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException) -{ - configapi::implSetName( getNodeAccess(), getElementClass(), aName ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XChangesNotifier -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicRootElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XComponent -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSetElement::dispose( ) throw(uno::RuntimeException) -{ - configapi::implDispose( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::dispose( ) throw(uno::RuntimeException) -{ - configapi::implDispose( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::dispose( ) throw(uno::RuntimeException) -{ - configapi::implDispose( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicSetElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicSetElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicRootElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNodeAccess(), xListener ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XServiceInfo -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicInnerElement::getImplementationName( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicSetElement::getImplementationName( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicRootElement::getImplementationName( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicUpdateElement::getImplementationName( ) throw(uno::RuntimeException) -{ - return configapi::implGetImplementationName( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL BasicInnerElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException) -{ - return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); -} -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicSetElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException) -{ - return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); -} -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicRootElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException) -{ - return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); -} -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicUpdateElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException) -{ - return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -uno::Sequence< rtl::OUString > SAL_CALL BasicInnerElement::getSupportedServiceNames( ) throw(uno::RuntimeException) -{ - return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence< rtl::OUString > SAL_CALL BasicSetElement::getSupportedServiceNames( ) throw(uno::RuntimeException) -{ - return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence< rtl::OUString > SAL_CALL BasicRootElement::getSupportedServiceNames( ) throw(uno::RuntimeException) -{ - return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence< rtl::OUString > SAL_CALL BasicUpdateElement::getSupportedServiceNames( ) throw(uno::RuntimeException) -{ - return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() ); -} -//----------------------------------------------------------------------------------- - -// ONLY set elements -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XTemplateInstance -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicSetElement::getTemplateName( ) throw(uno::RuntimeException) -{ - return configapi::implGetTemplateName( getElementClass() ); -} - -//----------------------------------------------------------------------------------- -// XUnoTunnel -//----------------------------------------------------------------------------------- - -sal_Int64 SAL_CALL BasicSetElement::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier ) - throw(uno::RuntimeException) -{ - return configapi::implGetSomething( getElementClass(), aIdentifier); -} - -//----------------------------------------------------------------------------------- - -// ONLY root elements -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XLocalizable -//----------------------------------------------------------------------------------- - -css::lang::Locale SAL_CALL BasicRootElement::getLocale( ) throw(uno::RuntimeException) -{ - return configapi::implGetLocale( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -css::lang::Locale SAL_CALL BasicUpdateElement::getLocale( ) throw(uno::RuntimeException) -{ - return configapi::implGetLocale( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicRootElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException) -{ - configapi::implSetLocale( getElementClass(), eLocale ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException) -{ - configapi::implSetLocale( getElementClass(), eLocale ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// XChangesBatch (only on update root) -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicUpdateElement::commitChanges( ) throw(css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implCommitChanges( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicUpdateElement::hasPendingChanges( ) throw(uno::RuntimeException) -{ - return configapi::implHasPendingChanges( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -uno::Sequence< css::util::ElementChange > SAL_CALL BasicUpdateElement::getPendingChanges( ) throw(uno::RuntimeException) -{ - return configapi::implGetPendingChanges( getElementClass() ); -} -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -} // namespace configmgr - - diff --git a/configmgr/source/api2/elementaccess.hxx b/configmgr/source/api2/elementaccess.hxx deleted file mode 100644 index 2241acc91bdd..000000000000 --- a/configmgr/source/api2/elementaccess.hxx +++ /dev/null @@ -1,383 +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_API_ELEMENTACCESS_HXX_ -#define CONFIGMGR_API_ELEMENTACCESS_HXX_ - -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/configuration/XTemplateInstance.hpp> -#include <com/sun/star/lang/XLocalizable.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/util/XChangesNotifier.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/implbase5.hxx> -#include <cppuhelper/implbase6.hxx> - -namespace configmgr -{ -//----------------------------------------------------------------------------- - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - -//----------------------------------------------------------------------------- - namespace configapi - { - class NodeAccess; - class InnerElement; - class SetElement; - class RootElement; - class UpdateRootElement; - } -//----------------------------------------------------------------------------- - - /** implements the interfaces supported by a inner node - within the configuration tree that is a plain node (group member). - <p> Is an interface adapter around - <type scope='configmgr::configapi'>NodeAccess</type> and - <type scope='configmgr::configapi'>InnerElement</type>.</p> - */ - class BasicInnerElement : public cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo > - { - protected: - // Destructors - virtual ~BasicInnerElement() {} - - public: - // Interface methods - // XInterface ('dispose' management) - partial implementation - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XTypeProvider (from implhelper) - partial implementation - virtual uno::Sequence<sal_Int8> SAL_CALL - getImplementationId( ) - throw(uno::RuntimeException); - - // XChild - virtual uno::Reference< uno::XInterface > SAL_CALL - getParent( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // not supported - setParent( const uno::Reference< uno::XInterface >& Parent ) - throw(css::lang::NoSupportException, css::uno::RuntimeException); - - // XNamed - virtual rtl::OUString SAL_CALL - getName( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // not supported (! - missing exception) - setName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XServiceInfo - virtual rtl::OUString SAL_CALL - getImplementationName( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - supportsService( const rtl::OUString& ServiceName ) - throw(uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames( ) - throw(uno::RuntimeException); - - protected: - virtual configapi::InnerElement& getElementClass() = 0; - virtual configapi::NodeAccess& getNodeAccess() = 0; - }; -//----------------------------------------------------------------------------- - - /** implements the interfaces supported by a node - within the configuration tree that is a set element (or floating free). - <p> Is an interface adapter around - <type scope='configmgr::configapi'>NodeAccess</type> and - <type scope='configmgr::configapi'>SetElement</type>.</p> - */ - class BasicSetElement : public cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel > - { - protected: - // Destructors - virtual ~BasicSetElement() {} - - public: - // Interface methods - // XInterface ('dispose' management) - partial implementation - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XTypeProvider (from implhelper) - partial implementation - virtual uno::Sequence<sal_Int8> SAL_CALL - getImplementationId( ) - throw(uno::RuntimeException); - - // XChild - virtual uno::Reference< uno::XInterface > SAL_CALL - getParent( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // currently not supported - setParent( const uno::Reference< uno::XInterface >& Parent ) - throw(css::lang::NoSupportException, css::uno::RuntimeException); - - // XNamed - virtual rtl::OUString SAL_CALL - getName( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // generally not supported (! - missing exception) - setName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XComponent - virtual void SAL_CALL - dispose( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener ) - throw(uno::RuntimeException); - - // XServiceInfo - virtual rtl::OUString SAL_CALL - getImplementationName( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - supportsService( const rtl::OUString& ServiceName ) - throw(uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames( ) - throw(uno::RuntimeException); - - // XTemplateInstance - virtual rtl::OUString SAL_CALL - getTemplateName( ) - throw(uno::RuntimeException); - - // XUnoTunnel - virtual sal_Int64 SAL_CALL - getSomething( const uno::Sequence< sal_Int8 >& aIdentifier ) - throw(uno::RuntimeException); - - protected: - virtual configapi::SetElement& getElementClass() = 0; - virtual configapi::NodeAccess& getNodeAccess() = 0; - }; -//----------------------------------------------------------------------------- - - /** implements the interfaces supported by a node - within the configuration that is the root of a read-only access - <p> Is an interface adapter around - <type scope='configmgr::configapi'>NodeAccess</type> and - <type scope='configmgr::configapi'>SetElement</type>.</p> - */ - class BasicRootElement : public cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable > - { - protected: - // Destructors - virtual ~BasicRootElement() {} - - public: - // Interface methods - // XInterface ('dispose' management) - partial implementation - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XTypeProvider (from implhelper) - partial implementation - virtual uno::Sequence<sal_Int8> SAL_CALL - getImplementationId( ) - throw(uno::RuntimeException); - - // XNamed - virtual rtl::OUString SAL_CALL - getName( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // generally not supported (! - missing exception) - setName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XChangesNotifier - virtual void SAL_CALL - addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - // XComponent - virtual void SAL_CALL - dispose( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener ) - throw(uno::RuntimeException); - - // XServiceInfo - virtual rtl::OUString SAL_CALL - getImplementationName( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - supportsService( const rtl::OUString& ServiceName ) - throw(uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames( ) - throw(uno::RuntimeException); - - // XLocalizable - virtual css::lang::Locale SAL_CALL - getLocale( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // maybe not supported (! - missing exception) - setLocale( const css::lang::Locale& eLocale ) - throw(uno::RuntimeException); - - protected: - virtual configapi::RootElement& getElementClass() = 0; - virtual configapi::NodeAccess& getNodeAccess() = 0; - }; -//----------------------------------------------------------------------------- - - /** implements the interfaces supported by a node - within the configuration that is the root of an update access - <p> Is an interface adapter around - <type scope='configmgr::configapi'>NodeAccess</type> and - <type scope='configmgr::configapi'>SetElement</type>.</p> - */ - class BasicUpdateElement : public cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch > - { - protected: - // Destructors - virtual ~BasicUpdateElement() {} - - public: - // Interface methods - // XInterface ('dispose' management) - partial implementation - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XTypeProvider (from implhelper) - partial implementation - virtual uno::Sequence<sal_Int8> SAL_CALL - getImplementationId( ) - throw(uno::RuntimeException); - - // XNamed - virtual rtl::OUString SAL_CALL - getName( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // generally not supported (! - missing exception) - setName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XChangesNotifier - virtual void SAL_CALL - addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener ) - throw(uno::RuntimeException); - - // XComponent - virtual void SAL_CALL - dispose( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - addEventListener( const uno::Reference< css::lang::XEventListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener ) - throw(uno::RuntimeException); - - // XServiceInfo - virtual rtl::OUString SAL_CALL - getImplementationName( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - supportsService( const rtl::OUString& ServiceName ) - throw(uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames( ) - throw(uno::RuntimeException); - - // XChangesBatch - virtual void SAL_CALL - commitChanges( ) - throw(css::lang::WrappedTargetException, uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasPendingChanges( ) - throw(uno::RuntimeException); - - virtual uno::Sequence< css::util::ElementChange > SAL_CALL - getPendingChanges( ) - throw(uno::RuntimeException); - - // XLocalizable - virtual css::lang::Locale SAL_CALL - getLocale( ) - throw(uno::RuntimeException); - - virtual void SAL_CALL // maybe not supported (! - missing exception) - setLocale( const css::lang::Locale& eLocale ) - throw(uno::RuntimeException); - - protected: - virtual configapi::UpdateRootElement& getElementClass() = 0; - virtual configapi::NodeAccess& getNodeAccess() = 0; - }; -//----------------------------------------------------------------------------- -} -#endif // CONFIGMGR_API_ELEMENTACCESS_HXX_ - - diff --git a/configmgr/source/api2/elementimpl.cxx b/configmgr/source/api2/elementimpl.cxx deleted file mode 100644 index b9e9ee0466d0..000000000000 --- a/configmgr/source/api2/elementimpl.cxx +++ /dev/null @@ -1,588 +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 "elementimpl.hxx" -#include "apitreeaccess.hxx" -#include "apinodeaccess.hxx" -#include "apifactory.hxx" -#include "noderef.hxx" -#include "nodechange.hxx" -#include "nodechangeinfo.hxx" -#include "translatechanges.hxx" -#include "apitypes.hxx" -#include "configset.hxx" -#include "confignotifier.hxx" -#include "confsvccomponent.hxx" -#include "committer.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/configuration/XTemplateContainer.hpp> -#include <osl/diagnose.h> - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------------- - namespace lang = css::lang; - namespace util = css::util; - -//----------------------------------------------------------------------------------- - -// Interface methods -//----------------------------------------------------------------------------------- - -// XChild -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, InnerElement&) throw(uno::RuntimeException) -{ - uno::Reference<uno::XInterface> xRet; - - try - { - GuardedNodeData<NodeAccess> impl( rNode ); // no provider lock needed - tree must be prebuilt already - - rtl::Reference< configuration::Tree > aTree(impl.getTree()); - configuration::NodeRef aParentNode = aTree->getParent(impl.getNode()); - - uno::Any aAny = configapi::makeInnerElement( rNode.getFactory(), aTree, aParentNode ); - - if (!(aAny >>= xRet)) // no parent available - { - OSL_ASSERT(!xRet.is()); // make sure we return NULL - OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicElement::getParent: could not extract parent - node is not an object"); - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return xRet; -} - -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, SetElement& /*rElement*/) throw(uno::RuntimeException) -{ - uno::Reference<uno::XInterface> xRet; - - try - { - // assume shared lock for connected trees - GuardedNodeData<NodeAccess> impl( rNode ); // no provider lock needed - tree must be prebuilt already - - rtl::Reference< configuration::Tree > aTree(impl.getTree()); - - rtl::Reference< configuration::Tree > aParentTree( aTree->getContextTree() ); - - if (!configuration::isEmpty(aParentTree.get())) - { - configuration::NodeRef aParentNode( aTree->getContextNodeRef() ); - - // assume shared factory for connected trees - uno::Any aAny = configapi::makeInnerElement( rNode.getFactory(), aParentTree, aParentNode ); - - if (!(aAny >>= xRet)) // no parent available - { - // should occur only if the any is void - OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicSetElement::getParent: could not extract parent - node is not an object"); - OSL_ASSERT(!xRet.is()); // make sure we return NULL - } - } - else - { - OSL_ASSERT(!xRet.is()); // make sure we return NULL - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return xRet; -} -//----------------------------------------------------------------------------------- - -// UNSUPPORTED method -void implSetParent(NodeAccess& rNode, InnerElement& /*rElement*/, const uno::Reference< uno::XInterface >& /*xParent*/ ) - throw(lang::NoSupportException, uno::RuntimeException) -{ - UnoApiLock aLock; - - rNode.checkAlive(); // Does locking internally, checks for disposed nodes - - // TODO(?): allow for xParent == getParent() - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("configmgr: BasicElement::setParent: cannot move Entry")), - rNode.getUnoInstance() ); -} -//----------------------------------------------------------------------------------- - -// preliminary implementation -void implSetParent(NodeAccess& rNode, SetElement& rElement, const uno::Reference< uno::XInterface >& xParent ) - throw(lang::NoSupportException, uno::RuntimeException) -{ - UnoApiLock aLock; - - //implSetParent(rNode,xParent); - // TODO: lock the whole transaction ???? - would need Uno Tunneling ? - uno::Reference< uno::XInterface > xGotParent( implGetParent(rNode,rElement) ); - uno::Reference< css::container::XNameContainer > xOldParent( xGotParent, uno::UNO_QUERY ); - uno::Reference< css::container::XNameContainer > xNewParent( xParent, uno::UNO_QUERY ); - - if (xGotParent.is() && !xOldParent.is()) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: this is not element of a container")), - rNode.getUnoInstance() ); - } - if (xParent.is() && !xNewParent.is()) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: new parent is no container")), - rNode.getUnoInstance() ); - } - - uno::Reference< uno::XInterface > xThis(rNode.getUnoInstance()); - OSL_ASSERT(xThis.is()); - - if (xOldParent != xNewParent) - { - rtl::OUString const sName( implGetName(rNode,rElement) ); - - if (xParent.is()) - { - rtl::OUString const sTemplate( implGetTemplateName(rElement) ); - - if (sTemplate.getLength() == 0) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: object has no recognizable type")), - xThis ); - } - - uno::Reference< css::configuration::XTemplateContainer > xNewTemplate( xParent, uno::UNO_QUERY ); - if (!xNewTemplate.is()) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: new parent has no element template")), - xThis ); - } - - if ( sTemplate != xNewTemplate->getElementTemplateName()) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: object has wrong type")), - xThis ); - } - - if ( xNewParent->hasByName( sName ) ) - { - throw lang::NoSupportException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: an object of this name already exists in new parent")), - xThis ); - } - - // TODO: check for circularity (i.e. that This is not one of new parent's ancestors) !! - } - - // now do it - - try - { - if ( xOldParent.is()) xOldParent->removeByName(sName); - if ( xNewParent.is()) xNewParent->insertByName(sName, uno::makeAny(xThis)); - } - catch (uno::Exception& e) - { - e.Message = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: changing parent failed: ")) - += e.Message; - - if (xOldParent.is()) - try - { - xOldParent->insertByName(sName, uno::makeAny(xThis)); - } - catch(uno::Exception& bad) - { - e.Message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\t ! Could not restore old parent: ")) += bad.Message; - } - - throw uno::RuntimeException(e.Message,xThis); - } - - } -} -//----------------------------------------------------------------------------- - - -// XNamed -//----------------------------------------------------------------------------- -rtl::OUString implGetName(NodeAccess& rNode, NodeElement& ) throw(uno::RuntimeException) -{ - rtl::OUString sRet; - try - { - GuardedNodeData<NodeAccess> impl( rNode ); // maybe passive only ? - - rtl::Reference< configuration::Tree > aTree(impl.getTree()); - configuration::NodeRef aNode(impl.getNode()); - - sRet = aTree->getSimpleNodeName(aNode.getOffset()); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return sRet; -} -//----------------------------------------------------------------------------- - -// UNSUPPORTED method -void implSetName(NodeAccess & rNode, NodeElement& /*rElement*/, const rtl::OUString& /*aName*/ ) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - rNode.checkAlive(); // Does locking internally, checks for disposed nodes - - // TODO(?): allow for aName == getName() - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("configmgr: BasicElement::setName: cannot rename Entry")), - rNode.getUnoInstance() ); -} -//----------------------------------------------------------------------------- - -// TODO: Implementations for elements to be added to a container node -void implSetName(NodeAccess& rNode, SetElement& rElement, const rtl::OUString& aName ) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - // TODO: Implement - NodeElement& rDelegate = rElement; - implSetName(rNode,rDelegate,aName); // delegate to unsupported version -} -//----------------------------------------------------------------------------- - -// XComponent & XInterface -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- - -void implDispose( SetElement& rElement) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - if (!rElement.disposeTree(false)) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Can't dispose an object that has an owner")), - rElement.getUnoInstance() ); - } -} -//----------------------------------------------------------------------------- - -void implDispose( RootElement& rElement) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - if (!rElement.disposeTree()) - { - throw lang::DisposedException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Can't dispose an object that already was disposed")), - rElement.getUnoInstance() ); - } -} -//----------------------------------------------------------------------------- - -void implDisposeObject( NodeAccess& ,SetElement& rElement) throw(uno::RuntimeException) -{ - UnoApiLock aLock; -// FIXME: should we hold a ref on the element over this ? -// call apitreeaccess.hxx (doGetUnoInterface) & hold a ref / unref ? -// [or!] - call getApiTree & ref/unref on that ? -// [or!] - hold the ref inside the dispose method itself ... - rElement.disposeTree(true); -} -//----------------------------------------------------------------------------- - -void implDisposeObject( NodeAccess& , RootElement& rElement) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - rElement.disposeTree(); -} -//----------------------------------------------------------------------------- - -void implDisposeObject( NodeAccess& rNode, InnerElement& ) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - rNode.disposeNode(); -} -//----------------------------------------------------------------------------- - - -// XTypeProvider -//----------------------------------------------------------------------------- - -uno::Sequence<sal_Int8> implGetImplementationId(NodeAccess& rNode, NodeElement& rElement) - throw(uno::RuntimeException) -{ - DisposeGuard aLock(rNode); - ServiceImplementationInfo const* pInfo = rElement.getServiceInfo(); - - OSL_ENSURE(pInfo, "Configuration: Object has no implementation (service) info - cannot get implementation id"); - if (!pInfo) - throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Object has no implementation information - cannot get implementation id")),rElement.getUnoInstance() ); - - return ServiceComponentImpl::getStaticImplementationId(pInfo); -} -//----------------------------------------------------------------------------- - -// XServiceInfo -//----------------------------------------------------------------------------- - -rtl::OUString implGetImplementationName( NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException) -{ - DisposeGuard aLock(rNode); - ServiceImplementationInfo const* pInfo = rElement.getServiceInfo(); - OSL_ENSURE(pInfo, "Configuration: Object has no service info"); - - return ServiceInfoHelper(pInfo).getImplementationName(); -} -//----------------------------------------------------------------------------- - -sal_Bool implSupportsService( NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& ServiceName ) throw(uno::RuntimeException) -{ - DisposeGuard aLock(rNode); - ServiceImplementationInfo const* pInfo = rElement.getServiceInfo(); - OSL_ENSURE(pInfo, "Configuration: Object has no service info"); - - return ServiceInfoHelper(pInfo).supportsService(ServiceName); -} -//----------------------------------------------------------------------------- - -uno::Sequence< rtl::OUString > implGetSupportedServiceNames( NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException) -{ - DisposeGuard aLock(rNode); - ServiceImplementationInfo const* pInfo = rElement.getServiceInfo(); - OSL_ENSURE(pInfo, "Configuration: Object has no service info"); - - return ServiceInfoHelper(pInfo).getSupportedServiceNames(); -} -//----------------------------------------------------------------------------- - -// Root only ------------------------------------------------------------------ - -// XLocalizable -// TODO: Implement locale support -//----------------------------------------------------------------------------- - -lang::Locale implGetLocale( RootElement& rElement ) throw(uno::RuntimeException) -{ - GuardedRootElement aLocked(rElement); - - OSL_ENSURE(false,"CONFIGURATION: Locale information is not yetsupported."); - return lang::Locale(); -} -//----------------------------------------------------------------------------- - -void implSetLocale( RootElement& rElement, const css::lang::Locale& /*eLocale*/ ) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - // TODO: Implement if possible - rElement.checkAlive(); - - OSL_ENSURE(false,"CONFIGURATION: Changing the set Locale is not supported."); - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Changing the locale is currently not supported")), - rElement.getUnoInstance() - ); -} -//----------------------------------------------------------------------------- - -// XChangesBatch -//----------------------------------------------------------------------------- - -void implCommitChanges( UpdateRootElement& rElement ) throw(css::lang::WrappedTargetException, uno::RuntimeException) -{ - UnoApiLock aLock; - - // quick check to avoid big locks for nothing (has its own locking) - if (!implHasPendingChanges(rElement)) return; - - try - { - rElement.getCommitter().commit(); - } - - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rElement.getUnoInstance() ); - e.unhandled(); - } - - // filter/wrap uno::Exceptions - catch (lang::WrappedTargetException& ) { throw; } - catch (uno::RuntimeException& ) { throw; } - catch (uno::Exception& ex) - { - uno::Reference<uno::XInterface> xContext( rElement.getUnoInstance() ); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration: can't commit Changes: ") ); - throw lang::WrappedTargetException( sMessage += ex.Message, xContext, uno::makeAny(ex)); - } -} -//----------------------------------------------------------------------------- - -sal_Bool implHasPendingChanges( RootElement& rElement ) throw(uno::RuntimeException) -{ - try - { - GuardedRootElement aLocked(rElement); - return aLocked.get().getTree()->hasChanges(); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rElement.getUnoInstance() ); - e.unhandled(); - } - - OSL_ENSURE(false,"Unreachable Code"); - return false; -} -//----------------------------------------------------------------------------- - -uno::Sequence< css::util::ElementChange > implGetPendingChanges( RootElement& rElement ) - throw(uno::RuntimeException) -{ - std::vector<css::util::ElementChange> aResult; - try - { - GuardedRootElement aLocked(rElement); - - rtl::Reference< configuration::Tree > aTree( aLocked.get().getTree() ); - - configuration::NodeChangesInformation aInfos; - - { - configuration::NodeChanges aChanges; - if (aTree->collectChanges(aChanges)) - { - aChanges.getChangesInfos(aInfos); - } - } - - Factory& rFactory = rElement.getFactory(); - - for(std::vector< configuration::NodeChangeInformation >::const_iterator it = aInfos.begin(), stop = aInfos.end(); - it != stop; - ++it) - { - css::util::ElementChange aChange; - fillChange(aChange,*it,aTree,rFactory); - aResult.push_back(aChange); - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rElement.getUnoInstance() ); - e.unhandled(); - } - - return makeSequence(aResult); -} -//----------------------------------------------------------------------------- - -// Set only ------------------------------------------------------------------------- - -// XTemplateInstance -//----------------------------------------------------------------------------------- - -rtl::OUString implGetTemplateName(SetElement& rElement) - throw(uno::RuntimeException) -{ - try - { - GuardedTreeElement aLocked(rElement); - return rElement.getTemplateInfo()->getPathString(); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rElement.getUnoInstance() ); - e.unhandled(); - } - - OSL_ENSURE(false,"Unreachable Code"); - return rtl::OUString(); -} -//----------------------------------------------------------------------------------- - -// XUnoTunnel -//----------------------------------------------------------------------------------- -sal_Int64 implGetSomething(SetElement& rElement, const uno::Sequence< sal_Int8 >& aIdentifier ) - throw(uno::RuntimeException) -{ - sal_Int64 nSomething = 0; - try - { - GuardedTreeElement aLocked(rElement); - - if (!rElement.getFactory().tunnelSetElement(nSomething, rElement, aIdentifier)) - OSL_ASSERT(nSomething == 0); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rElement.getUnoInstance() ); - e.unhandled(); - } - - return nSomething; -} -//----------------------------------------------------------------------------------- - - } // namespace configapi - -} // namespace configmgr - - diff --git a/configmgr/source/api2/elementimpl.hxx b/configmgr/source/api2/elementimpl.hxx deleted file mode 100644 index a20eab92098b..000000000000 --- a/configmgr/source/api2/elementimpl.hxx +++ /dev/null @@ -1,157 +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_API_ELEMENTIMPL_HXX_ -#define CONFIGMGR_API_ELEMENTIMPL_HXX_ - -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/configuration/XTemplateInstance.hpp> -#include <com/sun/star/lang/XLocalizable.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - /* implementations of the interfaces supported by a (parent) node - within the configuration tree. - (read-only operation) - */ - namespace configapi - { - //------------------------------------------------------------------------- - class NodeAccess; - class NodeElement; - class InnerElement; - class TreeElement; - class SetElement; - class RootElement; - class UpdateRootElement; - //------------------------------------------------------------------------- - - // XComponent and XInterface (EOL handling) - //--------------------------------------------------------------------- - void implDispose( SetElement& rElement) - throw(uno::RuntimeException); - - void implDispose( RootElement& rElement) - throw(uno::RuntimeException); - - void implDisposeObject( NodeAccess& aNode, SetElement& rElement) - throw(uno::RuntimeException); - - void implDisposeObject( NodeAccess& aNode, RootElement& rElement) - throw(uno::RuntimeException); - - void implDisposeObject( NodeAccess& aNode, InnerElement& rElement) - throw(uno::RuntimeException); - - // XTypeProvider - //--------------------------------------------------------------------- - uno::Sequence<sal_Int8> implGetImplementationId(NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException); - - // XChild - //--------------------------------------------------------------------- - uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, InnerElement& rElement) - throw(uno::RuntimeException); - - uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, SetElement& rElement) - throw(uno::RuntimeException); - - void implSetParent(NodeAccess& rNode, InnerElement& rElement, const uno::Reference< uno::XInterface >& Parent ) // generally not supported - throw(css::lang::NoSupportException, css::uno::RuntimeException); - - void implSetParent(NodeAccess& rNode, SetElement& rElement, const uno::Reference< uno::XInterface >& Parent ) // maybe supported - throw(css::lang::NoSupportException, css::uno::RuntimeException); - - // XNamed - //--------------------------------------------------------------------- - rtl::OUString implGetName(NodeAccess& rNode, NodeElement& rElement) - throw(uno::RuntimeException); - - void implSetName(NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& aName ) // generally not supported (! - missing exception) - throw(uno::RuntimeException); - - void implSetName(NodeAccess& rNode, SetElement& rElement, const rtl::OUString& aName ) // maybe supported - throw(uno::RuntimeException); - - // XServiceInfo - //--------------------------------------------------------------------- - rtl::OUString implGetImplementationName( NodeAccess& rNode, NodeElement& rElement ) - throw(uno::RuntimeException); - - sal_Bool implSupportsService( NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& ServiceName ) - throw(uno::RuntimeException); - - uno::Sequence< rtl::OUString > implGetSupportedServiceNames( NodeAccess& rNode, NodeElement& rElement ) - throw(uno::RuntimeException); - - // Root only only - //------------------------------------------------------------------------- - - // XLocalizable - //--------------------------------------------------------------------- - - css::lang::Locale implGetLocale( RootElement& rElement ) - throw(uno::RuntimeException); - - void implSetLocale( RootElement& rElement, const css::lang::Locale& eLocale ) - throw(uno::RuntimeException); - - // XChangesBatch - //--------------------------------------------------------------------- - - void implCommitChanges( UpdateRootElement& rElement ) - throw(css::lang::WrappedTargetException, uno::RuntimeException); - - sal_Bool implHasPendingChanges( RootElement& rElement ) - throw(uno::RuntimeException); - - uno::Sequence< css::util::ElementChange > implGetPendingChanges( RootElement& rElement ) - throw(uno::RuntimeException); - - // Set only - //------------------------------------------------------------------------- - // XTemplateInstance - //--------------------------------------------------------------------- - rtl::OUString implGetTemplateName(SetElement& rElement) - throw(uno::RuntimeException); - - // XUnoTunnel - //--------------------------------------------------------------------- - sal_Int64 implGetSomething(SetElement& rElement, const uno::Sequence< sal_Int8 >& aIdentifier ) - throw(uno::RuntimeException); - - //------------------------------------------------------------------------- - } - -} -#endif // CONFIGMGR_API_BASEACCESSIMPL_HXX_ - - diff --git a/configmgr/source/api2/groupaccess.cxx b/configmgr/source/api2/groupaccess.cxx deleted file mode 100644 index a6491871bd51..000000000000 --- a/configmgr/source/api2/groupaccess.cxx +++ /dev/null @@ -1,144 +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 "groupaccess.hxx" -#include "accessimpl.hxx" -#include "apinotifierimpl.hxx" -#include "apinodeaccess.hxx" - -namespace configmgr -{ - -// XHierarchicalName -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString SAL_CALL BasicGroupAccess::getHierarchicalName( ) throw(uno::RuntimeException) -{ - return configapi::implGetHierarchicalName( getNode() ); -} - -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString SAL_CALL BasicGroupAccess::composeHierarchicalName( const rtl::OUString& sRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException) -{ - return configapi::implComposeHierarchicalName( getNode(), sRelativeName ); -} - -//------------------------------------------------------------------------------------------------------------------ - -// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? ) -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -uno::Type SAL_CALL BasicGroupAccess::getElementType( ) throw(uno::RuntimeException) -{ - return configapi::implGetElementType( getNode() ); -} - -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL BasicGroupAccess::hasElements( ) throw(uno::RuntimeException) -{ - return configapi::implHasElements( getNode() ); -} - -// XExactName -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicGroupAccess::getExactName( const rtl::OUString& rApproximateName ) throw(uno::RuntimeException) -{ - return configapi::implGetExactName( getNode(), rApproximateName); -} - -// XProperty -//----------------------------------------------------------------------------------- - -css::beans::Property SAL_CALL BasicGroupAccess::getAsProperty( ) throw(uno::RuntimeException) -{ - return configapi::implGetAsProperty( getNode() ); -} - -// XNameAccess -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicGroupAccess::hasByName( const rtl::OUString& sName ) throw(uno::RuntimeException) -{ - return configapi::implHasByName( getNode(), sName); -} - -//----------------------------------------------------------------------------------- -uno::Any SAL_CALL BasicGroupAccess::getByName( const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetByName( getNode(), sName ); -} - -//----------------------------------------------------------------------------------- -uno::Sequence< rtl::OUString > SAL_CALL BasicGroupAccess::getElementNames( ) throw( uno::RuntimeException) -{ - return configapi::implGetElementNames( getNode() ); -} - -// XHierarchicalNameAccess -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL BasicGroupAccess::hasByHierarchicalName( const rtl::OUString& sName ) throw(uno::RuntimeException) -{ - return configapi::implHasByHierarchicalName( getNode(), sName); -} - -//----------------------------------------------------------------------------------- -uno::Any SAL_CALL BasicGroupAccess::getByHierarchicalName( const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, uno::RuntimeException) -{ - return configapi::implGetByHierarchicalName( getNode(), sName ); -} - - -// XContainer -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicGroupAccess::addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNode(), xListener ); -} - -//----------------------------------------------------------------------------------- -void SAL_CALL BasicGroupAccess::removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNode(), xListener ); -} - - - -//----------------------------------------------------------------------------------- - -} // namespace configmgr - - diff --git a/configmgr/source/api2/groupaccess.hxx b/configmgr/source/api2/groupaccess.hxx deleted file mode 100644 index 9c00f1817b8d..000000000000 --- a/configmgr/source/api2/groupaccess.hxx +++ /dev/null @@ -1,135 +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_API_GROUPACCESS_HXX_ -#define CONFIGMGR_API_GROUPACCESS_HXX_ - -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/beans/XProperty.hpp> -#include <cppuhelper/implbase6.hxx> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - namespace configapi { class NodeGroupInfoAccess; } - - /** implements the (read-only) interfaces supported by a group node - within the configuration tree. - <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p> - */ - class BasicGroupAccess - : public ::cppu::ImplHelper6 - < css::container::XNameAccess - , css::container::XHierarchicalName - , css::container::XHierarchicalNameAccess - , css::container::XContainer - , css::beans::XExactName - , css::beans::XProperty - > - { - protected: - // Destructors - virtual ~BasicGroupAccess() {} - - public: - // Interface methods - - // XHierarchicalName - virtual rtl::OUString SAL_CALL - getHierarchicalName( ) - throw(uno::RuntimeException); - - virtual rtl::OUString SAL_CALL - composeHierarchicalName( const rtl::OUString& aRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, - uno::RuntimeException); - - // XElementAccess, base class of XNameAccess - virtual uno::Type SAL_CALL - getElementType( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasElements( ) - throw(uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL - getByName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, - uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getElementNames( ) - throw( uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasByName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XHierarchicalNameAccess - virtual uno::Any SAL_CALL - getByHierarchicalName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasByHierarchicalName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XContainer - virtual void SAL_CALL - addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - // XExactName - virtual ::rtl::OUString SAL_CALL - getExactName( const rtl::OUString& aApproximateName ) - throw(uno::RuntimeException); - - // XProperty - virtual css::beans::Property SAL_CALL - getAsProperty( ) - throw(uno::RuntimeException); - - protected: - virtual configapi::NodeGroupInfoAccess& getNode() = 0; - }; - -} -#endif // CONFIGMGR_API_GROUPACCESS_HXX_ - - diff --git a/configmgr/source/api2/groupobjects.cxx b/configmgr/source/api2/groupobjects.cxx deleted file mode 100644 index f31c3d6092ef..000000000000 --- a/configmgr/source/api2/groupobjects.cxx +++ /dev/null @@ -1,407 +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 "groupobjects.hxx" -#include "comphelper/sequence.hxx" - -//........................................................................ -namespace configmgr -{ - -//========================================================================== -//= OInnerGroupInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL OInnerGroupInfo::acquire( ) throw () -{ - BasicInnerElement::acquire(); -} - -void SAL_CALL OInnerGroupInfo::release( ) throw () -{ - BasicInnerElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OInnerGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicInnerElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroupAccess::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OInnerGroupInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicInnerElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes()); -} - -uno::Sequence< sal_Int8 > SAL_CALL OInnerGroupInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicInnerElement::getImplementationId(); -} - - -configapi::NodeAccess& OInnerGroupInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& OInnerGroupInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* OInnerGroupInfo::maybeGetUpdateAccess() -{ - return 0; -} - -configapi::InnerElement& OInnerGroupInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OInnerGroupUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OInnerGroupUpdate::acquire( ) throw () -{ - BasicInnerElement::acquire(); -} - -void SAL_CALL OInnerGroupUpdate::release( ) throw () -{ - BasicInnerElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OInnerGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicInnerElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroup::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OInnerGroupUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicInnerElement::getTypes(), BasicGroup::getTypes(), BasicPropertySet::getTypes()); -} - -uno::Sequence< sal_Int8 > SAL_CALL OInnerGroupUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicInnerElement::getImplementationId(); -} - - -configapi::NodeAccess& OInnerGroupUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& OInnerGroupUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* OInnerGroupUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::InnerElement& OInnerGroupUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OSetElementGroupInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL OSetElementGroupInfo::acquire( ) throw () -{ - BasicSetElement::acquire(); -} - -void SAL_CALL OSetElementGroupInfo::release( ) throw () -{ - BasicSetElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OSetElementGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroupAccess::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OSetElementGroupInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicSetElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OSetElementGroupInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicSetElement::getImplementationId(); -} - - -configapi::NodeAccess& OSetElementGroupInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& OSetElementGroupInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* OSetElementGroupInfo::maybeGetUpdateAccess() -{ - return 0; -} - -configapi::SetElement& OSetElementGroupInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OSetElementGroupUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OSetElementGroupUpdate::acquire( ) throw () -{ - BasicSetElement::acquire(); -} - -void SAL_CALL OSetElementGroupUpdate::release( ) throw () -{ - BasicSetElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OSetElementGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroup::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OSetElementGroupUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicSetElement::getTypes(), BasicGroup::getTypes(), BasicPropertySet::getTypes()); -} - -uno::Sequence< sal_Int8 > SAL_CALL OSetElementGroupUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicSetElement::getImplementationId(); -} - - -configapi::NodeAccess& OSetElementGroupUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& OSetElementGroupUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* OSetElementGroupUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::SetElement& OSetElementGroupUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= ORootElementGroupInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL ORootElementGroupInfo::acquire( ) throw () -{ - BasicRootElement::acquire(); -} - -void SAL_CALL ORootElementGroupInfo::release( ) throw () -{ - BasicRootElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL ORootElementGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicRootElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroupAccess::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL ORootElementGroupInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicRootElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes()); -} - -uno::Sequence< sal_Int8 > SAL_CALL ORootElementGroupInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicRootElement::getImplementationId(); -} - - -configapi::NodeAccess& ORootElementGroupInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& ORootElementGroupInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* ORootElementGroupInfo::maybeGetUpdateAccess() -{ - return 0; -} - -configapi::RootElement& ORootElementGroupInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= ORootElementGroupUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL ORootElementGroupUpdate::acquire( ) throw () -{ - BasicUpdateElement::acquire(); -} - -void SAL_CALL ORootElementGroupUpdate::release( ) throw () -{ - BasicUpdateElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL ORootElementGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicUpdateElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicGroup::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicPropertySet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL ORootElementGroupUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicGroup::getTypes(), BasicPropertySet::getTypes()); -} - -uno::Sequence< sal_Int8 > SAL_CALL ORootElementGroupUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicUpdateElement::getImplementationId(); -} - - -configapi::NodeAccess& ORootElementGroupUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeGroupInfoAccess& ORootElementGroupUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeGroupAccess* ORootElementGroupUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::UpdateRootElement& ORootElementGroupUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//........................................................................ -} // namespace configmgr -//........................................................................ - diff --git a/configmgr/source/api2/groupobjects.hxx b/configmgr/source/api2/groupobjects.hxx deleted file mode 100644 index d7afa5ef01ec..000000000000 --- a/configmgr/source/api2/groupobjects.hxx +++ /dev/null @@ -1,268 +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_API_GROUPOBJECTS_HXX_ -#define CONFIGMGR_API_GROUPOBJECTS_HXX_ - -#include "groupaccess.hxx" -#include "groupupdate.hxx" -#include "propertysetaccess.hxx" -#include "elementaccess.hxx" - -#include "apiaccessobj.hxx" - -//........................................................................ -namespace configmgr -{ -//........................................................................ - -//========================================================================== -//= Inner Group Instances -//========================================================================== - -/** read-only access class for configuration nodes which are inner nodes and groups of other nodes -*/ - class OInnerGroupInfo - : public BasicInnerElement - , public BasicGroupAccess - , public BasicPropertySet - { - public: - // Construction/Destruction - OInnerGroupInfo(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode) - : m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::InnerElement& getElementClass(); - private: - configapi::OInnerElement<configapi::NodeGroupInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are inner nodes and groups of other nodes -*/ - class OInnerGroupUpdate - : public BasicInnerElement - , public BasicGroup - , public BasicPropertySet - { - public: - // Construction/Destruction - OInnerGroupUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode) - : m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::InnerElement& getElementClass(); - private: - configapi::OInnerElement<configapi::NodeGroupAccess> m_aAccessElement; - }; - - -//========================================================================== -//= Set Element Group Instances -//========================================================================== - -/** read-only access class for configuration nodes which are set elements and groups of other nodes -*/ - class OSetElementGroupInfo - : public BasicSetElement - , public BasicGroupAccess - , public BasicPropertySet - { - public: - // Construction/Destruction - OSetElementGroupInfo(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0) - : m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::SetElement& getElementClass(); - private: - configapi::OSetElement<configapi::NodeGroupInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are set elements and groups of other nodes -*/ - class OSetElementGroupUpdate - : public BasicSetElement - , public BasicGroup - , public BasicPropertySet - { - public: - // Construction/Destruction - OSetElementGroupUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0) - : m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::SetElement& getElementClass(); - private: - configapi::OSetElement<configapi::NodeGroupAccess> m_aAccessElement; - }; - - -//========================================================================== -//= Root Element Set Instances -//========================================================================== - -/** read-only access class for configuration nodes which are root nodes and groups of other nodes -*/ - class ORootElementGroupInfo - : public BasicRootElement - , public BasicGroupAccess - , public BasicPropertySet - { - public: - // Construction/Destruction - ORootElementGroupInfo(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::RootElement& getElementClass(); - private: - configapi::OReadRootElement<configapi::NodeGroupInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are root nodes and groups of other nodes -*/ - class ORootElementGroupUpdate - : public BasicUpdateElement - , public BasicGroup - , public BasicPropertySet - { - public: - // Construction/Destruction - ORootElementGroupUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeGroupInfoAccess& getNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess(); - virtual configapi::UpdateRootElement& getElementClass(); - private: - configapi::OUpdateRootElement<configapi::NodeGroupAccess> m_aAccessElement; - }; - - -//........................................................................ -} // namespace configmgr -//........................................................................ - -#endif // CONFIGMGR_API_GROUPOBJECTS_HXX_ - - diff --git a/configmgr/source/api2/groupupdate.cxx b/configmgr/source/api2/groupupdate.cxx deleted file mode 100644 index 84fd40e914b5..000000000000 --- a/configmgr/source/api2/groupupdate.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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include "groupupdate.hxx" -#include "updateimpl.hxx" -#include "apinodeaccess.hxx" -#include "apitypes.hxx" - -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> - -namespace configmgr -{ -////////////////////////////////////////////////////////////////////////////////// -// class BasicGroup -////////////////////////////////////////////////////////////////////////////////// - -// XInterface joining -////////////////////////////////////////////////////////////////////////////////// -uno::Any SAL_CALL BasicGroup::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicGroupAccess::queryInterface( rType ); - if (!aRet.hasValue()) - { - aRet = cppu::queryInterface(rType - , static_cast< css::container::XNameReplace *>(this) - ); - } - return aRet; -} - -// XTypeProvider joining -////////////////////////////////////////////////////////////////////////////////// -uno::Sequence< uno::Type > SAL_CALL BasicGroup::getTypes( ) throw (uno::RuntimeException ) -{ - /*static ?*/ - cppu::OTypeCollection aTypes( - configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), - BasicGroupAccess::getTypes()); - - return aTypes.getTypes(); -} - -//uno::Sequence< sal_Int8 > SAL_CALL BasicGroup::getImplementationId( ) throw (uno::RuntimeException ) = 0; - -////////////////////////////////////////////////////////////////////////////////// - -// safe write access -///////////////////////////////////////////////////////////// -configapi::NodeGroupAccess& BasicGroup::getGroupNode() -{ - configapi::NodeGroupAccess* pAccess = maybeGetUpdateAccess(); - OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException"); - - if (!pAccess) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update interface missing.")), - static_cast< css::container::XNameReplace * >(this) - ); - } - return *pAccess; -} - -// New Interface methods -// XNameReplace -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicGroup::replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implReplaceByName( getGroupNode(), rName, rElement ); -} - -//----------------------------------------------------------------------------------- -} // namespace configmgr - - diff --git a/configmgr/source/api2/groupupdate.hxx b/configmgr/source/api2/groupupdate.hxx deleted file mode 100644 index 3d172a265c12..000000000000 --- a/configmgr/source/api2/groupupdate.hxx +++ /dev/null @@ -1,98 +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_API_GROUPUPDATE_HXX_ -#define CONFIGMGR_API_GROUPUPDATE_HXX_ - -#include "groupaccess.hxx" -#include <com/sun/star/container/XNameReplace.hpp> - -//........................................................................ -namespace configmgr -{ -//........................................................................ - namespace configapi { class NodeGroupAccess; } - -//========================================================================== -//= BasicGroup -//========================================================================== - -/** base class for configuration nodes which are dynamic sets of complex types (trees) -*/ - class BasicGroup - : public BasicGroupAccess - , public css::container::XNameReplace - { - protected: - // Destructors - virtual ~BasicGroup() {} - - public: - // Base class Interface methods - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0; - - // XElementAccess forwarding - virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException) - { return BasicGroupAccess::getElementType(); } - - virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException) - { return BasicGroupAccess::hasElements(); } - - // XNameAccess forwarding - virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) - { return BasicGroupAccess::getByName(aName); } - - virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException) - { return BasicGroupAccess::getElementNames(); } - - virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException) - { return BasicGroupAccess::hasByName(aName); } - - // New Interface methods - // XNameReplace - virtual void SAL_CALL - replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - protected: - configapi::NodeGroupAccess& getGroupNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0; - }; - -//........................................................................ -} // namespace configmgr -//........................................................................ - -#endif // CONFIGMGR_API_GROUPUPDATE_HXX_ - - diff --git a/configmgr/source/api2/listenercontainer.cxx b/configmgr/source/api2/listenercontainer.cxx deleted file mode 100644 index 2b0351be684b..000000000000 --- a/configmgr/source/api2/listenercontainer.cxx +++ /dev/null @@ -1,80 +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 "listenercontainer.hxx" -#include <com/sun/star/lang/XEventListener.hpp> - -#include <osl/diagnose.h> - -namespace configmgr -{ - namespace configapi - { -///////////////////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// class DisposeNotifier -//----------------------------------------------------------------------------- - -void DisposeNotifier::appendAndClearContainer(cppu::OInterfaceContainerHelper* pContainer) -{ - if (pContainer) - { - { - cppu::OInterfaceIteratorHelper aIterator(*pContainer); - while (aIterator.hasMoreElements()) - { - aListeners.push_back(uno::Reference< lang::XEventListener >::query(aIterator.next())); - } - } - pContainer->clear(); - } -} -//----------------------------------------------------------------------------- -void DisposeNotifier::notify() -{ - for(std::vector< uno::Reference< lang::XEventListener > >::iterator it = aListeners.begin(); it != aListeners.end(); ++it) - { - if (it->is()) - { - try { (*it)->disposing(aEvent); } catch (uno::Exception & ) {} - it->clear(); - } - } - aListeners.clear(); -} - -//----------------------------------------------------------------------------- - -///////////////////////////////////////////////////////////////////////////////////////////// - } -} - - diff --git a/configmgr/source/api2/listenercontainer.hxx b/configmgr/source/api2/listenercontainer.hxx deleted file mode 100644 index 72598f0ab223..000000000000 --- a/configmgr/source/api2/listenercontainer.hxx +++ /dev/null @@ -1,581 +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_API_LISTENERCONTAINER_HXX_ -#define CONFIGMGR_API_LISTENERCONTAINER_HXX_ - -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <cppuhelper/interfacecontainer.hxx> -#include "datalock.hxx" -#include "utility.hxx" - -#include <osl/diagnose.h> - -namespace configmgr -{ - namespace configapi - { -///////////////////////////////////////////////////////////////////////////////////////////// - - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; -//----------------------------------------------------------------------------- - template <class Listener> - class ListenerContainerIterator - { - public: - /** - * Create an iterator over the elements of the container. The iterator - * copies the elements of the conatainer. A change to the container does not - * affect the iterator.<BR> - * Remark: The copy is on demand. The iterator copy the elements only if the container - * change the contens. It is not allowed to destroy the container if a iterator exist. - * - * @param rCont the container of the elements. - */ - ListenerContainerIterator( cppu::OInterfaceContainerHelper& rCont ) - : m_aIter(rCont) - , m_xNext() - { advance(); } - - /** - * Release the connection to the container. - */ - ~ListenerContainerIterator() {} - - /** Return true, if there are more elements in the iterator. */ - sal_Bool hasMoreElements() const { return m_xNext.is() != 0; } - - /** Return the next element of the iterator. Call this method if - * hasMoreElements return false, is an error. - */ - uno::Reference<Listener> next(); - - private: - void advance(); - - cppu::OInterfaceIteratorHelper m_aIter; - uno::Reference<Listener> m_xNext; - }; -//----------------------------------------------------------------------------- - class DisposeNotifier - { - lang::EventObject aEvent; - std::vector< uno::Reference< lang::XEventListener > > aListeners; - public: - explicit - DisposeNotifier(uno::Reference<uno::XInterface> const& aInterface) : aEvent(aInterface) {} - - void appendAndClearContainer(cppu::OInterfaceContainerHelper* pContainer); - void notify(); - }; -//----------------------------------------------------------------------------- - struct BasicContainerInfo - { - uno::XInterface* pInterface; - cppu::OMultiTypeInterfaceContainerHelper* pContainer; - BasicContainerInfo() : pInterface(0), pContainer(0) {} - }; - - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - class SpecialListenerContainer - { - public: - /** - * Create a container of interface containers. - */ - SpecialListenerContainer(std::vector<BasicContainerInfo>::size_type nCount, KeyToIndex_ aMapper) - : m_aSpecialHelper(UnoApiLock::getLock()) - , m_aContainers(nCount) - , m_aMapper(aMapper) - , m_bDisposeLock(false) - {} - - ~SpecialListenerContainer() - { - OSL_ENSURE(isDisposed(), "ERROR: Object was not disposed properly"); - } - public: - /** - * check whether this is disposed or still alive - * @param pObject - * an interface on the object on which's behalf the operation was started - * @return <FALSE/> - * if the object is being disposed - * @throw com::sun::star::lang::DisposedException - * if the object was disposed completely - */ - bool checkAlive(uno::XInterface* pObject = 0) volatile const throw(lang::DisposedException); - - /// return whether the object is completely alive - bool isAlive() volatile const throw(); - /// return whether the object is currently being disposed - bool isDisposing()volatile const throw(); - /// return whether the object is completely disposed - bool isDisposed()volatile const throw(); - - /// return whether the object is present in this container - bool isAvailable(std::vector<BasicContainerInfo>::size_type nIndex) const throw() - { - return nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface; - } - - std::vector<BasicContainerInfo>::size_type getSize() const - { - return m_aContainers.size(); - } - - /// return the interface associated with an index - void setObjectAt(std::vector<BasicContainerInfo>::size_type nIndex, uno::XInterface* pInterface) - { - OSL_ENSURE( !isDisposed(), "object is disposed" ); - - if (isAlive()) - { - OSL_ENSURE( nIndex < m_aContainers.size(), " Invalid Index into Notifier"); - OSL_ENSURE( pInterface, "Invalid NULL Interface passed into Notifier"); - - if ( nIndex < m_aContainers.size() && pInterface != NULL) - { - OSL_ENSURE( m_aContainers[nIndex].pInterface == NULL, "Interface already set"); - if (m_aContainers[nIndex].pInterface == NULL) - m_aContainers[nIndex].pInterface = pInterface; - } - } - } - - - /// return the interface associated with an index - uno::Reference<uno::XInterface> getObjectAt(std::vector<BasicContainerInfo>::size_type nIndex) const - { - uno::Reference<uno::XInterface> xRet( nIndex < m_aContainers.size() ? m_aContainers[nIndex].pInterface : 0 ); - return xRet; - } - - /// return the interface associated with an index - uno::Reference<uno::XInterface> getObjectForKey(Key_ const& aKey ) const - { - std::vector<BasicContainerInfo>::size_type nIndex = m_aMapper.findIndexForKey(aKey); - uno::Reference<uno::XInterface> xRet( nIndex < m_aContainers.size() ? m_aContainers[nIndex].pInterface : 0 ); - return xRet; - } - - /** - * Call disposing on all object in all the container for anIndex - * and in the containers for the associated indices - * support XEventListener. Then clear the container. - */ - bool disposeOne( std::vector<BasicContainerInfo>::size_type anIndex ) throw(); - - /** - * Start disposing this object - * @return <TRUE/> - * if disposing has been started - * @return <FALSE/> - * if disposing had already been started before - */ - bool beginDisposing() throw(); - /** - * Continue disposing this object - * <p> Call disposing on all object in all the containers that - * support XEventListener. Then clear the container. - * </p> - * @return <TRUE/> - * if disposing has been started - * @return <FALSE/> - * if disposing had already been started before - */ - void notifyDisposing() throw(); - - /// mark the end of the dispose processing - void endDisposing() throw(); - - public: - /** - * Return the specuial container created under this key. - * @return the container created under this key. If the container - * was not created, null was returned. - */ - cppu::OInterfaceContainerHelper * getSpecialContainer( const Key_ & aKey) const - { return m_aSpecialHelper.aLC.getContainer(aKey); } - - /** - * Return the containerhelper created under this index. - * @return the container helper created under this key. If the container helper - * was not created, null was returned. - */ - cppu::OMultiTypeInterfaceContainerHelper * getContainerHelper( std::vector<BasicContainerInfo>::size_type nIndex) const - { - return ((nIndex < m_aContainers.size()) ? m_aContainers[nIndex].pContainer : 0 ); - } - /** - * Return the container for the given type created under this index. - * @return the container created under this key. If the container - * was not created, null was returned. - */ - cppu::OInterfaceContainerHelper * getContainer( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type & aType) const - { - cppu::OMultiTypeInterfaceContainerHelper* pContainer = (nIndex < m_aContainers.size()) ? m_aContainers[nIndex].pContainer : 0 ; - - return pContainer ? pContainer->getContainer(aType) : 0; - } - - /** - * Insert an element in the container specified with the index and type. The position is not specified. - * The interface at the given index must be set already. - * @param aKey the id of the container. - * @param xListener the added interface. It is allowed to insert null or - * the same pointer more than once. - * @return the new count of elements in the container (or 0 if the object is ready being disposed). - */ - sal_Int32 addListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, uno::Reference< lang::XEventListener > const& xListener) throw(); - - /** - * Remove an element from the container specified with the index and type. - * It uses the equal definition of uno objects to remove the interfaces. - * @param aKey the id of the container. - * @param xListener the removed interface. - * @return the new count of elements in the container (or 0 if the object is ready being disposed). - */ - sal_Int32 removeListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, uno::Reference< lang::XEventListener > const& xListener) throw(); - - - /** - * Insert an element in the special container specified with the key. The position is not specified. - * The interface at the given index must be set already. - * @param aKey the id of the container. - * @param xListener the added interface. It is allowed to insert null or - * the same pointer more than once. - * @return the new count of elements in the container (or 0 if the object is ready being disposed). - */ - sal_Int32 addSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(); - - /** - * Remove an element from the container specified with the key. - * It uses the equal definition of uno objects to remove the interfaces. - * @param aKey the id of the container. - * @param xListener the removed interface. - * @return the new count of elements in the container (or 0 if the object is ready being disposed). - */ - sal_Int32 removeSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw(); - - private: - void implFillDisposer(DisposeNotifier& aNotifier, std::vector<BasicContainerInfo>::size_type nIndex); - - cppu::OBroadcastHelperVar< cppu::OMultiTypeInterfaceContainerHelperVar< Key_,KeyHash_,KeyEq_ >, Key_ > m_aSpecialHelper; - std::vector<BasicContainerInfo> m_aContainers; - KeyToIndex_ m_aMapper; - bool m_bDisposeLock; - }; -//----------------------------------------------------------------------------- - -///////////////////////////////////////////////////////////////////////////////////////////// - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::checkAlive(uno::XInterface* pObject) volatile const throw(lang::DisposedException) - { - bool bAlive = !m_aSpecialHelper.bInDispose; - if (m_aSpecialHelper.bDisposed) - { - throw lang::DisposedException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The object has already been disposed")),pObject); - } - return bAlive; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - inline - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isAlive() volatile const throw() - { - return !m_aSpecialHelper.bInDispose && !m_aSpecialHelper.bDisposed; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - inline - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isDisposing() volatile const throw() - { - return !!m_aSpecialHelper.bInDispose; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - inline - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isDisposed() volatile const throw() - { - return !!m_aSpecialHelper.bDisposed; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeOne(std::vector<BasicContainerInfo>::size_type nIndex) throw() - { - // OSL_ENSURE(!isDisposed(),"Object is already disposed in toto"); - if (isAlive()) - { - if (nIndex < m_aContainers.size()) - { - if (uno::XInterface* pObject = m_aContainers[nIndex].pInterface) - { - DisposeNotifier aNotifier(pObject); - - implFillDisposer(aNotifier, nIndex); - m_aContainers[nIndex].pInterface = 0; - delete m_aContainers[nIndex].pContainer; - - aNotifier.notify(); - } - } - return true; - } - else - return false; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::beginDisposing() throw() - { - if (isAlive()) - { - m_aSpecialHelper.bInDispose = sal_True; - m_bDisposeLock = true; - - return true; - } - return false; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::notifyDisposing() throw() - { - OSL_ENSURE(isDisposing(),"Disposing isn't in progress on this object"); - OSL_ENSURE(m_bDisposeLock,"Duplicate call for dispose notification or disposing is not taking place"); - - if (m_bDisposeLock) - { - OSL_ASSERT(m_aSpecialHelper.bInDispose); - - lang::EventObject aBaseEvt; - std::vector<DisposeNotifier> aNotifiers; - - if (std::vector<BasicContainerInfo>::size_type size = m_aContainers.size()) - { - aNotifiers.reserve(m_aContainers.size()); - - aBaseEvt.Source = m_aContainers[0].pInterface; - for(std::vector<BasicContainerInfo>::size_type ix = 0; ix < size; ++ix) - { - if (m_aContainers[ix].pInterface) - { - aNotifiers.push_back(DisposeNotifier(m_aContainers[ix].pInterface)); - implFillDisposer(aNotifiers.back(), ix); - m_aContainers[ix].pInterface = 0; - delete m_aContainers[ix].pContainer; - } - } - } - - m_bDisposeLock = false; - - for(std::vector<BasicContainerInfo>::size_type jx = 0, count = aNotifiers.size(); jx < count; ++jx) - { - aNotifiers[jx].notify(); - } - // in case we missed something - m_aSpecialHelper.aLC.disposeAndClear( aBaseEvt ); - } - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::endDisposing() throw() - { - OSL_ENSURE(isDisposing(),"Disposing isn't in progress on this object"); - - if (!isAlive()) - { - OSL_ENSURE(!m_bDisposeLock,"Did you forget to notify ?"); - - m_aSpecialHelper.bDisposed = sal_True; - m_aSpecialHelper.bInDispose = sal_False; - - if (m_bDisposeLock) - { - m_bDisposeLock = false; - } - } - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, const uno::Reference< lang::XEventListener > & xListener ) throw() - { - if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface ) - { - if ( isAlive() ) - { - if (m_aContainers[nIndex].pContainer == 0) - m_aContainers[nIndex].pContainer = new cppu::OMultiTypeInterfaceContainerHelper(UnoApiLock::getLock()); - - return m_aContainers[nIndex].pContainer->addInterface(aType,xListener); - } - - else if (xListener.is()) - { - lang::EventObject aEvent(m_aContainers[nIndex].pInterface); - try { xListener->disposing(aEvent); } catch (uno::Exception & ) {} - } - - } - else - OSL_ENSURE(false, "Invalid index or interface not set"); - - return 0; - } -//----------------------------------------------------------------------------- - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw() - { - std::vector<BasicContainerInfo>::size_type nIndex = m_aMapper.findIndexForKey(aKey); - if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface ) - { - if ( isAlive() ) - { - return m_aSpecialHelper.aLC.addInterface(aKey,xListener); - } - - else if (xListener.is()) - { - lang::EventObject aEvent(m_aContainers[nIndex].pInterface); - try { xListener->disposing(aEvent); } catch (uno::Exception & ) {} - } - } - else - OSL_ENSURE(false, "Invalid index or interface not set"); - - return 0; - } -//----------------------------------------------------------------------------- - - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, const uno::Reference< lang::XEventListener > & xListener ) throw() - { - OSL_ENSURE( !isDisposed(), "object is disposed" ); - - if ( isAlive() ) - { - if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pContainer ) - { - return m_aContainers[nIndex].pContainer->removeInterface(aType,xListener); - } - } - return 0; - } -//----------------------------------------------------------------------------- - - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw() - { - OSL_ENSURE( !isDisposed(), "object is disposed" ); - - if ( isAlive() ) - return m_aSpecialHelper.aLC.removeInterface(aKey, xListener ); - - else - return 0; - } -//----------------------------------------------------------------------------- - // relation function. Uses KeyToIndex -/* template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::Index - SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::findIndexForKey(Key const& aKey) - { - m_aMapper.findIndexForKey(aKey); - } -//----------------------------------------------------------------------------- - // relation function. Uses KeyToIndex - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::findKeysForIndex(std::vector<BasicContainerInfo>::size_type nIndex, std::vector<Key_> & aKeys) - { - aKeys.clear(); - m_aMapper.findKeysForIndex(nIndex,aKeys); - return !aKeys.empty(); - } -*///----------------------------------------------------------------------------- - // relation function. Uses KeyToIndex - template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_> - void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::implFillDisposer(DisposeNotifier& aNotifier, std::vector<BasicContainerInfo>::size_type nIndex) - { - if (cppu::OMultiTypeInterfaceContainerHelper* pMultiContainer = m_aContainers[nIndex].pContainer) - { - uno::Sequence< uno::Type > aTypes(pMultiContainer->getContainedTypes()); - for (sal_Int32 ix = 0; ix < aTypes.getLength(); ++ix) - { - cppu::OInterfaceContainerHelper* pContainer = pMultiContainer->getContainer(aTypes[ix]); - OSL_ENSURE(pContainer,"No container, but the type ?"); - if (pContainer) - aNotifier.appendAndClearContainer(pContainer); - } - } - std::vector<Key_> aKeys; - if (m_aMapper.findKeysForIndex(nIndex,aKeys)) - { - for(typename std::vector<Key_>::iterator it = aKeys.begin(); it != aKeys.end(); ++it) - { - if (cppu::OInterfaceContainerHelper* pContainer = m_aSpecialHelper.aLC.getContainer(*it)) - { - aNotifier.appendAndClearContainer(pContainer); - } - } - } - } -//----------------------------------------------------------------------------- - -///////////////////////////////////////////////////////////////////////////////////////////// - - template <class Listener> - inline - void ListenerContainerIterator<Listener>::advance() - { - while (!m_xNext.is() && m_aIter.hasMoreElements()) - { - m_xNext = m_xNext.query( m_aIter.next() ); - } - } -//----------------------------------------------------------------------------- - - template <class Listener> - uno::Reference<Listener> ListenerContainerIterator<Listener>::next() - { - uno::Reference<Listener> xRet(m_xNext); - m_xNext.clear(); - advance(); - return xRet; - } -//----------------------------------------------------------------------------- - -///////////////////////////////////////////////////////////////////////////////////////////// - } -} -#endif // CONFIGMGR_API_LISTENERCONTAINER_HXX_ - - diff --git a/configmgr/source/api2/makefile.mk b/configmgr/source/api2/makefile.mk deleted file mode 100644 index 314ca98752bd..000000000000 --- a/configmgr/source/api2/makefile.mk +++ /dev/null @@ -1,79 +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$/inc -PRJNAME=configmgr -TARGET=api2 - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ---------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/makefile.pmk - -# --- Files ------------------------------------- - -SLOFILES= \ - $(SLO)$/broadcaster.obj \ - $(SLO)$/listenercontainer.obj \ - $(SLO)$/provider.obj \ - $(SLO)$/providerimpl.obj \ - $(SLO)$/accessimpl.obj \ - $(SLO)$/apiaccessobj.obj \ - $(SLO)$/apiserviceinfo.obj \ - $(SLO)$/apifactory.obj \ - $(SLO)$/apifactoryimpl.obj \ - $(SLO)$/apinodeaccess.obj \ - $(SLO)$/apinodeupdate.obj \ - $(SLO)$/apinotifierimpl.obj \ - $(SLO)$/apitreeaccess.obj \ - $(SLO)$/apitreeimplobj.obj \ - $(SLO)$/confignotifier.obj \ - $(SLO)$/committer.obj \ - $(SLO)$/elementaccess.obj \ - $(SLO)$/elementimpl.obj \ - $(SLO)$/groupaccess.obj \ - $(SLO)$/groupobjects.obj \ - $(SLO)$/groupupdate.obj \ - $(SLO)$/propertiesfilterednotifier.obj \ - $(SLO)$/propertyinfohelper.obj \ - $(SLO)$/propertysetaccess.obj \ - $(SLO)$/propsetaccessimpl.obj \ - $(SLO)$/setaccess.obj \ - $(SLO)$/setobjects.obj \ - $(SLO)$/setupdate.obj \ - $(SLO)$/translatechanges.obj \ - $(SLO)$/treeiterators.obj \ - $(SLO)$/updateimpl.obj \ - - -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - diff --git a/configmgr/source/api2/notifierimpl.hxx b/configmgr/source/api2/notifierimpl.hxx deleted file mode 100644 index 6b4a9965ae6c..000000000000 --- a/configmgr/source/api2/notifierimpl.hxx +++ /dev/null @@ -1,238 +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_API_NOTIFIERIMPL_HXX_ -#define CONFIGMGR_API_NOTIFIERIMPL_HXX_ - -#include "listenercontainer.hxx" - -#include "noderef.hxx" -#include "valueref.hxx" - -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/beans/XVetoableChangeListener.hpp> -#include <com/sun/star/beans/XPropertiesChangeListener.hpp> -#include <com/sun/star/beans/PropertyVetoException.hpp> -#include <com/sun/star/container/XContainerListener.hpp> -#include <com/sun/star/util/XChangesListener.hpp> - -#include "propertiesfilterednotifier.hxx" - -#include <vos/refernce.hxx> - -namespace configmgr -{ - namespace configapi - { -// --------------------------------------------------------------------------------------------------- - - struct SubNodeHash - { - size_t operator() (const configuration::SubNodeID& rKey) const {return rKey.hashCode();} - }; - struct SubNodeEq - { - bool operator() (const configuration::SubNodeID& lhs,const configuration::SubNodeID& rhs) const {return lhs == rhs;} - }; - struct SubNodeToIndex - { - rtl::Reference< configuration::Tree > aTree; - - SubNodeToIndex( rtl::Reference< configuration::Tree > const& rTree ) : aTree(rTree) {} - - bool findKeysForIndex(unsigned int nNode, std::vector<configuration::SubNodeID>& aList) - { - aList.clear(); - configuration::getAllChildrenHelper(configuration::findNodeFromIndex(aTree,nNode), aList); - return !aList.empty(); - } - unsigned int findIndexForKey(configuration::SubNodeID const& aNode) - { - return aNode.getParentID().toIndex(); - } - }; - - /// manages collections of event listeners observing a whole config tree, thread-safe - class NotifierImpl : public vos::OReference - { - public: - SpecialListenerContainer <configuration::SubNodeID,SubNodeHash,SubNodeEq,SubNodeToIndex> m_aListeners; - - public: - /// construct this around the given Implementation, for the given tree - explicit - NotifierImpl(rtl::Reference< configuration::Tree > const& aTree); - ~NotifierImpl(); - - /// Add a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>. - void add(configuration::NodeID const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Add a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>. - void add(configuration::NodeID const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Add a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants. - void add(configuration::NodeID const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>. - void addNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addSpecialListener(aNode,xListener.get()); - } - /// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>. - void addForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - /// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void addNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addSpecialListener(aNode,xListener.get()); - } - /// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void addForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type> - observing all properties of <var>aNode</var>. - */ - void add(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - - // ignore the names for now - m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type> - observing the properties of <var>aNode</var> (optimally only those given by <var>aNames</var>. - */ - void add(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence< rtl::OUString> const& aNames) - { - OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener"); - OSL_PRECOND(aNames.getLength() > 0, "ERROR: Unexpected empty sequence"); - - uno::Reference< css::beans::XPropertiesChangeListener > xForwarder( new PropertiesFilteredNotifier(xListener,aNames) ); - // ignore the names for now - add(aNode,xForwarder); - } - - // --------------------------------------------------------------------------------------------------- - /// Remove a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>. - void remove(configuration::NodeID const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Remove a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>. - void remove(configuration::NodeID const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Remove a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants. - void remove(configuration::NodeID const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - /// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>. - void removeNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeSpecialListener(aNode,xListener.get()); - } - /// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>. - void removeForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - /// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void removeNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeSpecialListener(aNode,xListener.get()); - } - /// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>. - void removeForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - - - /** Remove a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type> - observing any properties of <var>aNode</var>. - */ - void remove(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) - { - // ignore the names for now - m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get()); - } - // --------------------------------------------------------------------------------------------------- - }; - -// --------------------------------------------------------------------------------------------------- - } -} - -#endif // CONFIGMGR_API_NOTIFIERIMPL_HXX_ diff --git a/configmgr/source/api2/objectregistry.hxx b/configmgr/source/api2/objectregistry.hxx deleted file mode 100644 index 461120aa993b..000000000000 --- a/configmgr/source/api2/objectregistry.hxx +++ /dev/null @@ -1,95 +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_API_OBJECTREGISTRY_HXX_ -#define CONFIGMGR_API_OBJECTREGISTRY_HXX_ - -#include "noderef.hxx" - -#include <osl/mutex.hxx> -#include <vos/refernce.hxx> - -#include <hash_map> -#include "tracer.hxx" - -namespace configmgr -{ - namespace configapi - { - - class NodeElement; - - class ObjectRegistry : public vos::OReference - { - public: - static NodeElement* notFound() { return 0; } - - struct KeyHash - { - size_t operator() (const configuration::NodeID& rKey) const {return rKey.hashCode();} - }; - struct KeyEq - { - bool operator() (const configuration::NodeID& lhs,const configuration::NodeID& rhs) const {return lhs == rhs;} - }; - typedef std::hash_map<configuration::NodeID,NodeElement*,KeyHash, KeyEq> ObjectMap; - public: - ObjectRegistry() {} - ~ObjectRegistry(); - - NodeElement* findElement(configuration::NodeID const& aNode) const - { - ObjectMap::const_iterator aFound = m_aMap.find(aNode); - - return (aFound != m_aMap.end()) ? aFound->second : notFound(); - } - void registerElement(configuration::NodeID const& aNode, NodeElement* aElement) - { - OSL_ENSURE(m_aMap.find(aNode) == m_aMap.end(), "ERROR: Node is already registered"); - - m_aMap[aNode] = aElement; - } - void revokeElement(configuration::NodeID const& aNode, NodeElement* aElement) - { - ObjectMap::iterator aFound = m_aMap.find(aNode); - - if (aFound != m_aMap.end()) - { - OSL_ENSURE(aFound->second == aElement,"Found unexpected element in map"); - - if (aFound->second == aElement) - m_aMap.erase(aFound); - } - } - private: - ObjectMap m_aMap; - }; -//----------------------------------------------------------------------------- - } -} - -#endif // CONFIGMGR_API_FACTORY_HXX_ diff --git a/configmgr/source/api2/propertiesfilterednotifier.cxx b/configmgr/source/api2/propertiesfilterednotifier.cxx deleted file mode 100644 index a8cd0a50cd81..000000000000 --- a/configmgr/source/api2/propertiesfilterednotifier.cxx +++ /dev/null @@ -1,151 +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 "propertiesfilterednotifier.hxx" - -#include <cppuhelper/queryinterface.hxx> - -namespace configmgr -{ - namespace uno = ::com::sun::star::uno; - namespace lang = ::com::sun::star::lang; - namespace beans = ::com::sun::star::beans; - -//----------------------------------------------------------------------------- -// class PropertiesFilteredNotifier -//----------------------------------------------------------------------------- - -PropertiesFilteredNotifier::PropertiesFilteredNotifier( - uno::Reference< beans::XPropertiesChangeListener >const& xTarget, - uno::Sequence< rtl::OUString > const& aFilterNames -) -: m_aRefCount() -, m_xTarget(xTarget) -, m_aFilterNames(aFilterNames) -{ - OSL_ENSURE(xTarget.is(),"PropertiesFilteredNotifier: FORWARDING TO NULL LISTENER"); - OSL_ENSURE(aFilterNames.getLength() > 0,"PropertiesFilteredNotifier: FILTER IS EMPTY (no target)"); -} -//----------------------------------------------------------------------------- - -PropertiesFilteredNotifier::~PropertiesFilteredNotifier() -{ -} -//----------------------------------------------------------------------------- - -void SAL_CALL PropertiesFilteredNotifier::acquire() throw() -{ - m_aRefCount.acquire(); -} -//----------------------------------------------------------------------------- - -void SAL_CALL PropertiesFilteredNotifier::release( ) throw() -{ - if (m_aRefCount.release() == 0) - delete this; -} -//----------------------------------------------------------------------------- - -uno::Any SAL_CALL PropertiesFilteredNotifier::queryInterface( const uno::Type& aType ) - throw(uno::RuntimeException) -{ - return cppu::queryInterface(aType - , static_cast< beans::XPropertiesChangeListener *>(this) - , static_cast< lang::XEventListener *>(this) - , static_cast< uno::XInterface *>(this) - ); -} -//----------------------------------------------------------------------------- - -void SAL_CALL PropertiesFilteredNotifier::disposing( const lang::EventObject& Source ) - throw(uno::RuntimeException) -{ - if (m_xTarget.is()) - m_xTarget->disposing(Source); -} -//----------------------------------------------------------------------------- - -inline // private and only used twice -bool PropertiesFilteredNotifier::implAccept(const ::com::sun::star::beans::PropertyChangeEvent& evt) const -{ - // todo: optimize by presorting and binary searching - sal_Int32 const nCount = m_aFilterNames.getLength(); - - for (sal_Int32 i = 0; i<nCount; ++i) - if (evt.PropertyName == m_aFilterNames[i]) - return true; - return false; -} -//----------------------------------------------------------------------------- - -// private and only used once -uno::Sequence< beans::PropertyChangeEvent > PropertiesFilteredNotifier::implFilter(const uno::Sequence< beans::PropertyChangeEvent >& evt) const -{ - sal_Int32 const nSize = evt.getLength(); - sal_Int32 nAccepted = 0; - - while ( nAccepted < nSize && implAccept(evt[nAccepted]) ) - ++nAccepted; - - if (nAccepted == nSize) // all accepted - return evt; - - // create a modified copy - uno::Sequence< beans::PropertyChangeEvent > aResult(evt); - for (sal_Int32 nCur = nAccepted+1; nCur<nSize; ++nCur) - { - if (implAccept(evt[nCur])) - { - aResult[nAccepted++] = evt[nCur]; - } - } - aResult.realloc(nAccepted); - OSL_ASSERT(aResult.getLength() == nAccepted); - - return aResult; -} -//----------------------------------------------------------------------------- - -void SAL_CALL PropertiesFilteredNotifier::propertiesChange( const uno::Sequence< beans::PropertyChangeEvent >& evt ) - throw(uno::RuntimeException) -{ - uno::Sequence< beans::PropertyChangeEvent > aFilteredEvt( implFilter(evt) ); - - if (aFilteredEvt.getLength() > 0) - { - if (m_xTarget.is()) - m_xTarget->propertiesChange(aFilteredEvt); - } -} -//----------------------------------------------------------------------------- - -} - - diff --git a/configmgr/source/api2/propertiesfilterednotifier.hxx b/configmgr/source/api2/propertiesfilterednotifier.hxx deleted file mode 100644 index 50b668542f47..000000000000 --- a/configmgr/source/api2/propertiesfilterednotifier.hxx +++ /dev/null @@ -1,76 +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_PROPERTIESFILTEREDNOTIFIER_HXX_ -#define CONFIGMGR_PROPERTIESFILTEREDNOTIFIER_HXX_ - -#include <com/sun/star/beans/XPropertiesChangeListener.hpp> - -#include <vos/refernce.hxx> - -namespace configmgr -{ - class PropertiesFilteredNotifier - : public ::com::sun::star::beans::XPropertiesChangeListener - { - public: - PropertiesFilteredNotifier( - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > const& xTarget, - ::com::sun::star::uno::Sequence< ::rtl::OUString > const& aFilterNames - ); - virtual ~PropertiesFilteredNotifier(); - - public: - virtual void SAL_CALL acquire( ) throw(); - virtual void SAL_CALL release( ) throw(); - - virtual ::com::sun::star::uno::Any SAL_CALL - queryInterface( const ::com::sun::star::uno::Type& aType ) - throw(::com::sun::star::uno::RuntimeException); - - virtual void SAL_CALL - disposing( const ::com::sun::star::lang::EventObject& Source ) - throw(::com::sun::star::uno::RuntimeException) ; - - virtual void SAL_CALL - propertiesChange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt ) - throw(::com::sun::star::uno::RuntimeException); - private: - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent > - implFilter(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt) - const; - - bool implAccept(const ::com::sun::star::beans::PropertyChangeEvent& evt) const; - - ::vos::ORefCount m_aRefCount; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > m_xTarget; - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aFilterNames; - }; -} - -#endif // CONFIGMGR_PROPERTIESFILTEREDNOTIFIER_HXX_ - diff --git a/configmgr/source/api2/propertyinfohelper.cxx b/configmgr/source/api2/propertyinfohelper.cxx deleted file mode 100644 index 099fd48ff54c..000000000000 --- a/configmgr/source/api2/propertyinfohelper.cxx +++ /dev/null @@ -1,72 +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 "propertyinfohelper.hxx" -#include "configpath.hxx" -#include "attributes.hxx" - -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HDL_ -#include <com/sun/star/beans/PropertyAttribute.hdl> -#endif - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - namespace beans = ::com::sun::star::beans; - - namespace configapi - { -//----------------------------------------------------------------------------- -beans::Property helperMakeProperty(rtl::OUString const& aName, - node::Attributes const aAttributes, - uno::Type const& aType, - bool bDefaultable ) - throw(uno::RuntimeException) -{ - namespace PropertyAttribute = com::sun::star::beans::PropertyAttribute; - - sal_Int16 nPropAttributes = 0; - if (aAttributes.isReadonly()) nPropAttributes |= PropertyAttribute::READONLY; - if (aAttributes.isNullable()) nPropAttributes |= PropertyAttribute::MAYBEVOID; - /*if ( aAttributes.bNotified)*/ nPropAttributes |= PropertyAttribute::BOUND; - /*if ( aAttributes.bConstrained)nPropAttributes |= PropertyAttribute::CONSTRAINED;*/ - - if ( aAttributes.isRemovable()) nPropAttributes |= PropertyAttribute::REMOVABLE; - if ( bDefaultable) nPropAttributes |= PropertyAttribute::MAYBEDEFAULT; - - return beans::Property(aName, -1, aType, nPropAttributes); -} -//----------------------------------------------------------------------------- - } - -} - - diff --git a/configmgr/source/api2/propertyinfohelper.hxx b/configmgr/source/api2/propertyinfohelper.hxx deleted file mode 100644 index 5f56596847bf..000000000000 --- a/configmgr/source/api2/propertyinfohelper.hxx +++ /dev/null @@ -1,56 +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_API_PROPERTYINFOIMPL_HXX_ -#define CONFIGMGR_API_PROPERTYINFOIMPL_HXX_ - -#include <com/sun/star/beans/Property.hpp> -#include <com/sun/star/uno/RuntimeException.hpp> - -namespace configmgr -{ - namespace uno = ::com::sun::star::uno; - namespace beans = ::com::sun::star::beans; - - /* implementations of the interfaces supported by a (parent) node - within the configuration tree. - (read-only operation) - */ - namespace node { struct Attributes; } - - namespace configapi - { - // translation helper - beans::Property helperMakeProperty( rtl::OUString const& aName, node::Attributes const aAttributes, uno::Type const& aType, bool bDefaultable ) - throw(uno::RuntimeException); - - } - -} -#endif // CONFIGMGR_API_PROPERTYINFOIMPL_HXX_ - - diff --git a/configmgr/source/api2/propertysetaccess.cxx b/configmgr/source/api2/propertysetaccess.cxx deleted file mode 100644 index 98176016cf29..000000000000 --- a/configmgr/source/api2/propertysetaccess.cxx +++ /dev/null @@ -1,275 +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 "propertysetaccess.hxx" -#include "propsetaccessimpl.hxx" -#include "apinotifierimpl.hxx" -#include "apinodeaccess.hxx" -#include "apinodeupdate.hxx" - -namespace configmgr -{ -////////////////////////////////////////////////////////////////////////////////// -// class BasicPropertySet -////////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////////// -// getting Property Metadata -////////////////////////////////////////////////////////////////////////////////// - -// XPropertySet & XMultiPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Reference< beans::XPropertySetInfo > SAL_CALL BasicPropertySet::getPropertySetInfo( ) - throw(uno::RuntimeException) -{ - return configapi::implGetPropertySetInfo( getNode(), NULL != maybeGetUpdateAccess() ); -} - -// XHierarchicalPropertySet & XHierarchicalMultiPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Reference< beans::XHierarchicalPropertySetInfo > SAL_CALL BasicPropertySet::getHierarchicalPropertySetInfo( ) - throw(uno::RuntimeException) -{ - return configapi::implGetHierarchicalPropertySetInfo( getNode() ); -} - -////////////////////////////////////////////////////////////////////////////////// -// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets -////////////////////////////////////////////////////////////////////////////////// - -/// get the access for updating, check that it is present -configapi::NodeGroupAccess& BasicPropertySet::getGroupNode() -{ - configapi::NodeGroupAccess* pAccess = maybeGetUpdateAccess(); - OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with PropertyVetoException"); - - if (!pAccess) - { - throw beans::PropertyVetoException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: INTERNAL VETO - Write operation invoked on a read-only node access")), - static_cast< beans::XPropertySet * >(this) - ); - } - return *pAccess; -} - -// XPropertySet -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetPropertyValue( getGroupNode(), aPropertyName, aValue ); -} - -// XMultiPropertySet -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::setPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetPropertyValues( getGroupNode(), PropertyNames, Values ); -} - -// XHierarchicalPropertySet -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::setHierarchicalPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetHierarchicalPropertyValue( getGroupNode(), aPropertyName, aValue ); -} - -// XMultiHierarchicalPropertySet -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::setHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetHierarchicalPropertyValues( getGroupNode(), PropertyNames, Values ); -} - - -////////////////////////////////////////////////////////////////////////////////// -// getting values -////////////////////////////////////////////////////////////////////////////////// -// XPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Any SAL_CALL BasicPropertySet::getPropertyValue( const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetPropertyValue( getNode(), aPropertyName ); -} - -// XMultiPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException) -{ - return configapi::implGetPropertyValues( getNode(), aPropertyNames ); -} - -// XHierarchicalPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Any SAL_CALL BasicPropertySet::getHierarchicalPropertyValue( const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetHierarchicalPropertyValue( getNode(), aPropertyName ); -} - -// XMultiHierarchicalPropertySet -////////////////////////////////////////////////////////////////////////////////// -uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException) -{ - return configapi::implGetHierarchicalPropertyValues( getNode(), aPropertyNames ); -} - -////////////////////////////////////////////////////////////////////////////////// -// adding/removing listeners -////////////////////////////////////////////////////////////////////////////////// - -void SAL_CALL BasicPropertySet::addVetoableChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implAddListener( getNode(), xListener, aPropertyName ); -} - -void SAL_CALL BasicPropertySet::addPropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implAddListener( getNode(), xListener, aPropertyName ); -} - -void SAL_CALL BasicPropertySet::addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNode(), xListener, aPropertyNames ); -} - -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::removeVetoableChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implRemoveListener( getNode(), xListener, aPropertyName ); -} -//--------------------------------------------------------------------------------- - -void SAL_CALL BasicPropertySet::removePropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implRemoveListener( getNode(), xListener, aPropertyName ); -} -//--------------------------------------------------------------------------------- - -void SAL_CALL BasicPropertySet::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNode(), xListener ); -} -//--------------------------------------------------------------------------------- - - -////////////////////////////////////////////////////////////////////////////////// -// SPECIAL: XMultiPropertySet::firePropertiesChangeEvent -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicPropertySet::firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implFirePropertiesChangeEvent( getNode(),aPropertyNames , xListener ); -} - -////////////////////////////////////////////////////////////////////////////////// -// XPropertyState / XMultiPropertyStates -////////////////////////////////////////////////////////////////////////////////// - -// getting property states -////////////////////////////////////////////////////////////////////////////////// - -beans::PropertyState SAL_CALL BasicPropertySet::getPropertyState( const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - return configapi::implGetPropertyState( getNode(), sPropertyName); -} -//--------------------------------------------------------------------------------- - -uno::Sequence< beans::PropertyState > SAL_CALL BasicPropertySet::getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - return configapi::implGetPropertyStates( getNode(), aPropertyNames ); -} -//--------------------------------------------------------------------------------- - -// setting to default state -////////////////////////////////////////////////////////////////////////////////// - -void SAL_CALL BasicPropertySet::setPropertyToDefault( const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - configapi::implSetPropertyToDefault( getGroupNode(), sPropertyName); -} -//--------------------------------------------------------------------------------- - -void SAL_CALL BasicPropertySet::setPropertiesToDefault( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, uno::RuntimeException) -{ - configapi::implSetPropertiesToDefault( getGroupNode(), aPropertyNames); -} -//--------------------------------------------------------------------------------- - -void SAL_CALL BasicPropertySet::setAllPropertiesToDefault( ) - throw (uno::RuntimeException) -{ - configapi::implSetAllPropertiesToDefault( getGroupNode() ); -} -//--------------------------------------------------------------------------------- - -// getting defaults -////////////////////////////////////////////////////////////////////////////////// - -uno::Any SAL_CALL BasicPropertySet::getPropertyDefault( const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - -{ - return configapi::implGetPropertyDefault( getNode(), sPropertyName); -} -//--------------------------------------------------------------------------------- - -uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyDefaults( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetPropertyDefaults( getNode(), aPropertyNames); -} -//--------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -} // namespace configmgr - - diff --git a/configmgr/source/api2/propertysetaccess.hxx b/configmgr/source/api2/propertysetaccess.hxx deleted file mode 100644 index 9ab9dbd99361..000000000000 --- a/configmgr/source/api2/propertysetaccess.hxx +++ /dev/null @@ -1,215 +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_API_PROPERTYSET_HXX_ -#define CONFIGMGR_API_PROPERTYSET_HXX_ - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XHierarchicalPropertySet.hpp> -#include <com/sun/star/beans/XMultiPropertySet.hpp> -#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> -#include <com/sun/star/beans/XMultiPropertyStates.hpp> -#include <cppuhelper/implbase6.hxx> - -namespace configmgr -{ -///////////////////////////////////////////////////////////////////////////////////////////// - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - namespace beans = css::beans; - - namespace configapi - { - class NodeGroupAccess; - class NodeGroupInfoAccess; - } - -///////////////////////////////////////////////////////////////////////////////////////////// - -/** implements the interfaces supported by a group node, viewed as a property set - within the configuration tree. - <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeGroup(Info)Access</type>.</p> -*/ -class BasicPropertySet -: public ::cppu::ImplHelper6 - < beans::XPropertySet - , beans::XMultiPropertySet - , beans::XHierarchicalPropertySet - , beans::XMultiHierarchicalPropertySet - , beans::XPropertyState - , beans::XMultiPropertyStates - > -{ -protected: -// Constructors & Destructors - virtual ~BasicPropertySet() {} - -public: -// getting Property Metadata - // XPropertySet & XMultiPropertySet - virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo( ) - throw(uno::RuntimeException); - - // XHierarchicalPropertySet & XHierarchicalMultiPropertySet - virtual uno::Reference< beans::XHierarchicalPropertySetInfo > SAL_CALL - getHierarchicalPropertySetInfo( ) - throw(uno::RuntimeException); - -// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets - // XPropertySet - virtual void SAL_CALL - setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - virtual void SAL_CALL - setPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XHierarchicalPropertySet - virtual void SAL_CALL - setHierarchicalPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XMultiHierarchicalPropertySet - virtual void SAL_CALL - setHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - -// getting values - // XPropertySet - virtual uno::Any SAL_CALL - getPropertyValue( const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - virtual uno::Sequence< uno::Any > SAL_CALL - getPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException); - - // XHierarchicalPropertySet - virtual uno::Any SAL_CALL - getHierarchicalPropertyValue( const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiHierarchicalPropertySet - virtual uno::Sequence< uno::Any > SAL_CALL - getHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException); - -// adding listeners - // XPropertySet - virtual void SAL_CALL - addPropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - virtual void SAL_CALL - addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException); - -// removing listeners - // XPropertySet - virtual void SAL_CALL - removePropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - virtual void SAL_CALL - removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& Listener ) - throw(uno::RuntimeException); - -// SPECIAL: support for VetoableChangeListeners - // XPropertySet - virtual void SAL_CALL - addVetoableChangeListener( const rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - virtual void SAL_CALL - removeVetoableChangeListener( const rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - -// SPECIAL: firePropertiesChangeEvent - // XMultiPropertySet - virtual void SAL_CALL - firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException); - -// XPropertyState - virtual beans::PropertyState SAL_CALL - getPropertyState( const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - // see below: - // virtual uno::Sequence< beans::PropertyState > SAL_CALL - // getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyName ) - // throw(beans::UnknownPropertyException, uno::RuntimeException); - - virtual void SAL_CALL - setPropertyToDefault( const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - virtual uno::Any SAL_CALL - getPropertyDefault( const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - -// XMultiPropertyStates - virtual uno::Sequence< beans::PropertyState > SAL_CALL - getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyName ) - throw (beans::UnknownPropertyException, uno::RuntimeException); - - virtual void SAL_CALL - setAllPropertiesToDefault( ) - throw (uno::RuntimeException); - - virtual void SAL_CALL - setPropertiesToDefault( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, uno::RuntimeException); - - virtual uno::Sequence< uno::Any > SAL_CALL - getPropertyDefaults( const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - -protected: - virtual configapi::NodeGroupInfoAccess& getNode() = 0; - configapi::NodeGroupAccess& getGroupNode(); - virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0; -}; - -//-------------------------------------------------------------------------- - -} -#endif // CONFIGMGR_API_PROPERTYSET_HXX_ - - diff --git a/configmgr/source/api2/propsetaccessimpl.cxx b/configmgr/source/api2/propsetaccessimpl.cxx deleted file mode 100644 index 14f8309e8690..000000000000 --- a/configmgr/source/api2/propsetaccessimpl.cxx +++ /dev/null @@ -1,1284 +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 "propsetaccessimpl.hxx" -#include "propertyinfohelper.hxx" -#include "apinodeaccess.hxx" -#include "apinodeupdate.hxx" -#include "noderef.hxx" -#include "valueref.hxx" -#include "anynoderef.hxx" -#include "nodechange.hxx" -#include "configgroup.hxx" -#include "confignotifier.hxx" -#include "broadcaster.hxx" -#include "apitypes.hxx" -#include "attributes.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <osl/diagnose.h> -#include <cppuhelper/implbase1.hxx> - -#ifndef INCLUDED_ALGORITHM -#include <algorithm> -#define INCLUDED_ALGORITHM -#endif - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------------- - namespace lang = css::lang; - namespace beans = css::beans; - -//----------------------------------------------------------------------------------- -// a helper class -//----------------------------------------------------------------------------------- - -class CollectProperties : configuration::NodeVisitor -{ - std::vector< beans::Property > m_aProperties; - sal_Bool m_bReadonly; -public: - CollectProperties(sal_Bool _bReadonly) - : m_bReadonly(_bReadonly) - { } - CollectProperties(sal_Bool _bReadonly, sal_Int32 _nCount) - : m_bReadonly(_bReadonly) - { m_aProperties.reserve(_nCount); } - - uno::Sequence<beans::Property> forChildren(rtl::Reference< configuration::Tree > const& _aPropertyTree, configuration::NodeRef const& _rNode) - { - OSL_ENSURE( _rNode.isValid() && _aPropertyTree->isValidNode(_rNode.getOffset()), "Node to retrieve properties from does not match tree"); - reset(); - _aPropertyTree->dispatchToChildren(_rNode, *this); - return makeSequence(m_aProperties); - } - -private: - void reset() { m_aProperties.clear(); } - - node::Attributes adjustAttributes(node::Attributes nNodeAttr); - - Result handle(rtl::Reference< configuration::Tree > const& _aTree, configuration::NodeRef const& _rValue); - Result handle(rtl::Reference< configuration::Tree > const& _aTree, configuration::ValueRef const& _rValue); -}; - -//----------------------------------------------------------------------------------- -node::Attributes CollectProperties::adjustAttributes(node::Attributes nNodeAttr) -{ - if (m_bReadonly) nNodeAttr.markReadonly(); - - return nNodeAttr; -} - -//----------------------------------------------------------------------------------- -CollectProperties::Result CollectProperties::handle(rtl::Reference< configuration::Tree > const& _aTree, configuration::ValueRef const& _rValue) -{ - // can be default ? - m_aProperties.push_back( - helperMakeProperty( _rValue.m_sNodeName, - adjustAttributes(_aTree->getAttributes(_rValue)), - _aTree->getUnoType(_rValue), - _aTree->hasNodeDefault(_rValue) - ) - ); - - return CONTINUE; -} - -//----------------------------------------------------------------------------------- -CollectProperties::Result CollectProperties::handle(rtl::Reference< configuration::Tree > const& _aTree, configuration::NodeRef const& _rNode) -{ - // can be default ? - OSL_ENSURE( configuration::isStructuralNode(_aTree,_rNode), - "Unexpected value element node. Cannot get proper type for this node as property" ); - - m_aProperties.push_back( - helperMakeProperty( _aTree->getSimpleNodeName(_rNode.getOffset()), - adjustAttributes(_aTree->getAttributes(_rNode)), - getUnoInterfaceType(), - _aTree->hasNodeDefault(_rNode) - ) - ); - - return CONTINUE; -} - -//----------------------------------------------------------------------------------- -// yet another helper class (more robust, but can't well be extended to be a HierarchicalPropertySetInfo though) -//----------------------------------------------------------------------------------- - -class NodePropertySetInfo - :public ::cppu::WeakImplHelper1< beans::XPropertySetInfo > -{ - uno::Sequence< beans::Property > const m_aProperties; - -public: - NodePropertySetInfo(uno::Sequence< beans::Property > const& _aProperties) throw(uno::RuntimeException) - : m_aProperties(_aProperties) - { - } - - static NodePropertySetInfo* create(NodeGroupInfoAccess& _rNode, sal_Bool _bReadonly ) throw(uno::RuntimeException); - beans::Property const* begin() const throw() { return m_aProperties.getConstArray(); } - beans::Property const* end() const throw() { return m_aProperties.getConstArray() + m_aProperties.getLength(); } - - beans::Property const* find(const rtl::OUString& _rPropertyName) const throw(uno::RuntimeException); - - // XPropertySetInfo - virtual uno::Sequence< beans::Property > SAL_CALL getProperties() throw(uno::RuntimeException); - virtual beans::Property SAL_CALL getPropertyByName(const rtl::OUString& _rPropertyName) throw(beans::UnknownPropertyException, uno::RuntimeException); - virtual sal_Bool SAL_CALL hasPropertyByName(const rtl::OUString& _rPropertyName) throw(uno::RuntimeException); -}; - -//----------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------- -NodePropertySetInfo* NodePropertySetInfo::create(NodeGroupInfoAccess& _rNode, sal_Bool _bReadonly ) throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - rtl::Reference< configuration::Tree > aTree( _rNode.getTree() ); - OSL_ENSURE( !configuration::isEmpty(aTree.get()), "WARNING: Getting Tree information requires a valid tree"); - if (configuration::isEmpty(aTree.get())) return NULL; - - configuration::NodeRef aNode( _rNode.getNodeRef() ); - OSL_ENSURE( aNode.isValid() && aTree->isValidNode(aNode.getOffset()), "ERROR: Tree does not match node"); - - uno::Sequence< beans::Property > aProperties = CollectProperties(_bReadonly).forChildren(aTree,aNode); - OSL_ENSURE( aProperties.getLength() > 0, "ERROR: PropertySet (Configuration group) has no Properties"); - - return new NodePropertySetInfo( aProperties ); -} - -//----------------------------------------------------------------------------------- -struct MatchName // : std::unary_function< beans::Property, bool > -{ - rtl::OUString sName; - MatchName(rtl::OUString const& _sName) throw(uno::RuntimeException) - : sName(_sName) - { - } - - bool operator()(beans::Property const& _aProperty) const - { - return !!(_aProperty.Name == this->sName); - } -}; - -beans::Property const* NodePropertySetInfo::find(const rtl::OUString& _rPropertyName) const throw(uno::RuntimeException) -{ - beans::Property const* const first = this->begin(); - beans::Property const* const last = this->end(); - - return std::find_if(first,last,MatchName(_rPropertyName)); -} - -//----------------------------------------------------------------------------------- -uno::Sequence< beans::Property > SAL_CALL NodePropertySetInfo::getProperties() throw(uno::RuntimeException) -{ - return m_aProperties; -} -//----------------------------------------------------------------------------------- -beans::Property SAL_CALL NodePropertySetInfo::getPropertyByName(const rtl::OUString& _rPropertyName) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - UnoApiLock aLock; - - beans::Property const* pFound = find(_rPropertyName); - - if (pFound == this->end()) - { - rtl::OUString sMessage = rtl::OUString::createFromAscii("Configuration - "); - sMessage += rtl::OUString::createFromAscii("No Property named '"); - sMessage += _rPropertyName; - sMessage += rtl::OUString::createFromAscii("' in this PropertySetInfo"); - throw beans::UnknownPropertyException(sMessage, static_cast<XPropertySetInfo*>(this)); - } - - return *pFound; -} - -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL NodePropertySetInfo::hasPropertyByName(const rtl::OUString& _rPropertyName) - throw(uno::RuntimeException) -{ - UnoApiLock aLock; - - beans::Property const* pFound = find(_rPropertyName); - - return (pFound != this->end()); -} - -// Interface methods -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// getting Property Metadata -//----------------------------------------------------------------------------------- - -// XPropertySet & XMultiPropertySet -//----------------------------------------------------------------------------------- -uno::Reference< beans::XPropertySetInfo > implGetPropertySetInfo( NodeGroupInfoAccess& rNode, sal_Bool _bWriteable ) - throw(uno::RuntimeException) -{ - GuardedNodeData<NodeAccess> lock( rNode ); - return NodePropertySetInfo::create(rNode, !_bWriteable); -} - -// XHierarchicalPropertySet & XHierarchicalMultiPropertySet -//----------------------------------------------------------------------------------- -uno::Reference< beans::XHierarchicalPropertySetInfo > implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess& /*rNode*/ ) - throw(uno::RuntimeException) -{ - // TODO: Implement - return 0; -} - -//----------------------------------------------------------------------------------- -// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets -//----------------------------------------------------------------------------------- - -// XPropertySet -//----------------------------------------------------------------------------------- -void implSetPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& sPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeGroupAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(sPropertyName,aTree,aNode); - - configuration::ValueRef aChild( aTree->getChildValue(aNode, aChildName) ); - - if (!aChild.isValid()) - { - if ( configuration::hasChildOrElement(aTree, aNode, aChildName) ) - { - OSL_ENSURE(aTree->hasChildNode(aNode, aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += sPropertyName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage, xContext ); - } - else - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += sPropertyName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue( aChild, aValue ); - if (aChange.test().isChange()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - aSender.queryConstraints(aChange); - - aTree->integrate(aChange, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -// XMultiPropertySet -//----------------------------------------------------------------------------------- -void implSetPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeGroupAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::NodeChanges aChanges; - for(sal_Int32 i = 0, count= aValues.getLength(); i < count; ++i) - { - rtl::OUString aChildName( aPropertyNames[i] ); // not validated - - configuration::ValueRef aChild( aTree->getChildValue(aNode, aChildName) ); - - if (!aChild.isValid()) - { - if ( configuration::hasChildOrElement(aTree, aNode, aChildName) ) - { - OSL_ENSURE(aTree->hasChildNode(aNode, aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Values.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += aChildName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage, xContext ); - } - - OSL_TRACE("Configuration: MultiPropertySet: trying to set unknown property - ignored"); - continue; - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue( aChild, aValues[i] ); - if (aChange.maybeChange()) - { - aChanges.add(aChange); - } - } - - if (!aChanges.test().compact().isEmpty()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChanges,true)); - - aSender.queryConstraints(aChanges); - - aTree->integrate(aChanges, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChanges, true); - } - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -// XHierarchicalPropertySet -//----------------------------------------------------------------------------------- -void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeGroupAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::RelativePath const aRelPath = configuration::validateRelativePath( aPropertyName, aTree, aNode ); - - configuration::AnyNodeRef aNestedValue = configuration::getLocalDescendant( aTree, aNode, aRelPath ); - - if (!aNestedValue.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") ); - sMessage += aRelPath.toString(); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' was not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - if (aNestedValue.isNode()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") ); - sMessage += aRelPath.toString(); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value property.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue( aNestedValue.toValue(), aValue ); - if (aChange.test().isChange()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,false)); - - aSender.queryConstraints(aChange); - - aTree->integrate(aChange, aNode, false); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -// XMultiHierarchicalPropertySet -//----------------------------------------------------------------------------------- -void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeGroupAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::NodeChanges aChanges; - for(sal_Int32 i = 0, count= aValues.getLength(); i < count; ++i) - try - { - configuration::RelativePath aRelPath = configuration::validateRelativePath( aPropertyNames[i], aTree, aNode ); - - configuration::AnyNodeRef aNestedValue = configuration::getLocalDescendant( aTree, aNode, aRelPath ); - - if (!aNestedValue.isValid()) - { - OSL_TRACE("Configuration: MultiPropertySet: trying to set unknown property - ignored"); - continue; - } - if ( aNestedValue.isNode() ) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Values.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += aRelPath.toString(); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value property.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue( aNestedValue.toValue(), aValues[i] ); - if (aChange.maybeChange()) - { - aChanges.add(aChange); - } - } - catch (configuration::InvalidName& ) - { - OSL_TRACE("Configuration: MultiHierarchicalPropertySet: trying to set property <invalid path> - ignored"); - continue; - } - - if (!aChanges.test().compact().isEmpty()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChanges,false)); - - aSender.queryConstraints(aChanges); - - aTree->integrate(aChanges, aNode, false); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChanges, true); // if we use 'false' we don't need 'Deep' change objects - } - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::PropertyVetoException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -//----------------------------------------------------------------------------------- -// getting values -//----------------------------------------------------------------------------------- - -// XPropertySet -//----------------------------------------------------------------------------------- -uno::Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(aPropertyName,aTree,aNode); - - configuration::AnyNodeRef aChild( aTree->getAnyChild(aNode, aChildName) ); - - if (!aChild.isValid()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") ); - sMessage += aPropertyName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - - return configapi::makeElement( rNode.getFactory(), aTree, aChild ); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return uno::Any(); -} - -// XMultiPropertySet -//----------------------------------------------------------------------------------- -uno::Sequence< uno::Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException) -{ - sal_Int32 const count = aPropertyNames.getLength(); - uno::Sequence<uno::Any> aRet(count); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - for(sal_Int32 i = 0; i < count; ++i) - { - rtl::OUString aChildName( aPropertyNames[i] ); // not validated - - configuration::AnyNodeRef aChild( aTree->getAnyChild(aNode, aChildName) ); - - if (aChild.isValid()) - { - aRet[i] = configapi::makeElement( rNode.getFactory(), aTree, aChild ); - } - else - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - OSL_TRACE("Configuration: MultiPropertySet: trying to get unknown property - returning void"); - } - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return aRet; -} - -// XHierarchicalPropertySet -//----------------------------------------------------------------------------------- -uno::Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::RelativePath aRelPath = configuration::validateRelativePath( aPropertyName, aTree, aNode ); - - configuration::AnyNodeRef aNestedNode = configuration::getLocalDescendant( aTree, aNode, aRelPath ); - - if (!aNestedNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") ); - sMessage += aRelPath.toString(); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - return configapi::makeElement( rNode.getFactory(), aTree, aNestedNode ); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return uno::Any(); -} - -// XMultiHierarchicalPropertySet -//----------------------------------------------------------------------------------- -uno::Sequence< uno::Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException) -{ - sal_Int32 const count = aPropertyNames.getLength(); - uno::Sequence<uno::Any> aRet(count); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - for(sal_Int32 i = 0; i < count; ++i) - try - { - configuration::RelativePath aRelPath = configuration::validateRelativePath( aPropertyNames[i], aTree, aNode ); - - configuration::AnyNodeRef aNestedValue = configuration::getLocalDescendant( aTree, aNode, aRelPath ); - - if (aNestedValue.isValid()) - { - aRet[i] = configapi::makeElement( rNode.getFactory(), aTree, aNestedValue ); - } - else - { - OSL_TRACE("Configuration: MultiPropertySet: trying to get unknown property - returning void"); - } - } - catch (configuration::InvalidName& ) - { - OSL_TRACE("Configuration: MultiPropertySet: trying to get property from unknown path - returning void"); - OSL_ASSERT(!aRet[i].hasValue()); - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return aRet; -} - -//------------------------------------------------------------------------------------------------------------------ -// SPECIAL: XMultiPropertySet::firePropertiesChangeEvent -//------------------------------------------------------------------------------------------------------------------ - -void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException) -{ - OSL_ENSURE(xListener.is(), "ERROR: requesting to fire Events to a NULL listener."); - if (!xListener.is()) - { - return; // should this be an exception ?? - } - - sal_Int32 const count = aPropertyNames.getLength(); - uno::Sequence<beans::PropertyChangeEvent> aEvents(count); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - configapi::Factory& rFactory = rNode.getFactory(); - - sal_Int32 nFire = 0; - - for(sal_Int32 i = 0; i < count; ++i) - { - rtl::OUString aChildName( aPropertyNames[i] ); // not validated - - configuration::AnyNodeRef aChild( aTree->getAnyChild(aNode, aChildName) ); - - if (aChild.isValid()) - { - aEvents[nFire].Source = rNode.getUnoInstance(); - aEvents[nFire].PropertyName = aChildName; - aEvents[nFire].PropertyHandle = -1; - - aEvents[nFire].NewValue = aEvents[nFire].OldValue = configapi::makeElement( rFactory, aTree, aChild ); - nFire++; - } - else - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - OSL_TRACE("Configuration: MultiPropertySet: request to fire unknown property - skipping"); - } - } - - if (nFire < count) aEvents.realloc(nFire);; - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - xListener->propertiesChange(aEvents); -} - -//------------------------------------------------------------------------------------------------------------------ -// XPropertyState -//------------------------------------------------------------------------------------------------------------------ - -beans::PropertyState implGetPropertyState( NodeAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildOrElementName(sPropertyName,aTree,aNode); - - configuration::AnyNodeRef aChild = configuration::getChildOrElement(aTree,aNode,aChildName); - if (!aChild.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyState. Property '") ); - sMessage += sPropertyName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - return aTree->isNodeDefault(aChild) ? beans::PropertyState_DEFAULT_VALUE : - aChild.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE : - beans::PropertyState_DIRECT_VALUE; - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - // unreachable, but still there to make some compilers happy - OSL_ASSERT(!"Unreachable code"); - return beans::PropertyState_AMBIGUOUS_VALUE; -} - -//----------------------------------------------------------------------------------- -uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - sal_Int32 const count = aPropertyNames.getLength(); - uno::Sequence<beans::PropertyState> aRet(count); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - for(sal_Int32 i = 0; i < count; ++i) - { - rtl::OUString aChildName = configuration::validateChildOrElementName(aPropertyNames[i],aTree,aNode); - - rtl::Reference< configuration::Tree > aChildTree( aTree); - - configuration::AnyNodeRef aChildNode = configuration::getChildOrElement(aChildTree,aNode,aChildName); - if (!aChildNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyStates. Property '") ); - sMessage += aPropertyNames[i]; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aChildNode.isValid()); - - aRet[i] = aChildTree->isNodeDefault(aChildNode) ? beans::PropertyState_DEFAULT_VALUE : - aChildNode.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE : - beans::PropertyState_DIRECT_VALUE; - } - - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return aRet; -} - -//----------------------------------------------------------------------------------- -static inline configuration::NodeChange validateSetToDefaultHelper(configuration::GroupDefaulter& _rDefaulter, configuration::AnyNodeRef _aNode) -{ - if (!_aNode.isNode()) - return _rDefaulter.validateSetToDefaultValue( _aNode.toValue() ); - - else - return _rDefaulter.validateSetToDefaultState( _aNode.toNode() ); -} -//----------------------------------------------------------------------------------- -void implSetPropertyToDefault( NodeGroupAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - try - { - UnoApiLock aWithDefaultLock; - GuardedNodeUpdate<NodeGroupAccess> lock( withDefaultData( rNode ) ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::GroupDefaulter aDefaulter = lock.getNodeDefaulter(); - - rtl::OUString aChildName = configuration::validateChildName(sPropertyName,aTree,aNode); - - configuration::AnyNodeRef aChild( aTree->getAnyChild(aNode, aChildName) ); - - configuration::NodeChange aChange = validateSetToDefaultHelper( aDefaulter, aChild ); - - const bool bLocal = !aDefaulter.hasDoneSet(); - - if (aChange.test().isChange() ) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,bLocal)); - - aSender.queryConstraints(aChange); - - aTree->integrate(aChange, aNode, bLocal); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} -//----------------------------------------------------------------------------------- -void implSetPropertiesToDefault( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, uno::RuntimeException) -{ - try - { - UnoApiLock aWithDefaultLock; - GuardedNodeUpdate<NodeGroupAccess> lock( withDefaultData( rNode ) ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::GroupDefaulter aDefaulter = lock.getNodeDefaulter(); - - configuration::NodeChanges aChanges; - for(sal_Int32 i = 0, count= aPropertyNames.getLength(); i < count; ++i) - { - rtl::OUString aChildName = configuration::validateChildName( aPropertyNames[i], aTree, aNode ); // validated - - configuration::AnyNodeRef aChild( aTree->getAnyChild(aNode, aChildName) ); - - if (!aChild.isValid()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree, aNode, aChildName),"ERROR: Configuration: Existing Property not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += aChildName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - if (!aTree->hasNodeDefault(aChild)) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") ); - sMessage += aChildName; - - if (aChild.isNode()) - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") ); - - else - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' does not have a default value.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - - configuration::NodeChange aChildChange = validateSetToDefaultHelper(aDefaulter, aChild ); - if (aChildChange.maybeChange()) - aChanges.add(aChildChange); - } - - const bool bLocal = !aDefaulter.hasDoneSet(); - - if (!aChanges.test().compact().isEmpty()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChanges,bLocal)); - - aSender.queryConstraints(aChanges); - - aTree->integrate(aChanges, aNode, bLocal); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChanges, bLocal); - } - - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -//----------------------------------------------------------------------------------- -void implSetAllPropertiesToDefault( NodeGroupAccess& rNode ) - throw(uno::RuntimeException) -{ - try - { - UnoApiLock aWithDefaultLock; - GuardedNodeUpdate<NodeGroupAccess> lock( withDefaultData( rNode ) ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::GroupDefaulter aDefaulter = lock.getNodeDefaulter(); - - configuration::NodeChanges aChanges = aDefaulter.validateSetAllToDefault( ); - - const bool bLocal = !aDefaulter.hasDoneSet(); - - if (!aChanges.test().compact().isEmpty()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChanges,bLocal)); - - aSender.queryConstraints(aChanges); - - aTree->integrate(aChanges, aNode, bLocal); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChanges, bLocal); - } - - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -//----------------------------------------------------------------------------------- -uno::Any implGetPropertyDefault( NodeGroupInfoAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - uno::Any aDefault; - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(sPropertyName,aTree,aNode); - - configuration::AnyNodeRef aChildNode = aTree->getAnyChild(aNode, aChildName); - if (!aChildNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") ); - sMessage += sPropertyName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - if (!aChildNode.isNode()) - { - aDefault = aTree->getNodeDefaultValue(aChildNode.toValue()); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return aDefault; -} - -//----------------------------------------------------------------------------------- -uno::Sequence< uno::Any > implGetPropertyDefaults( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) -{ - sal_Int32 const count = aPropertyNames.getLength(); - uno::Sequence<uno::Any> aDefaults(count); - - try - { - GuardedNodeData<NodeAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - for(sal_Int32 i = 0; i < count; ++i) - { - rtl::OUString aChildName = configuration::validateChildName(aPropertyNames[i],aTree,aNode); - - configuration::AnyNodeRef aChildNode = aTree->getAnyChild(aNode, aChildName); - if (!aChildNode.isValid()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") ); - sMessage += aPropertyNames[i]; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage, xContext ); - } - OSL_ASSERT(aNode.isValid()); - - if (!aChildNode.isNode()) - { - aDefaults[i] = aTree->getNodeDefaultValue(aChildNode.toValue()); - } - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( e.message(), xContext ); - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw beans::UnknownPropertyException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return aDefaults; -} - -//----------------------------------------------------------------------------------- - } // namespace configapi - -} // namespace configmgr - - diff --git a/configmgr/source/api2/propsetaccessimpl.hxx b/configmgr/source/api2/propsetaccessimpl.hxx deleted file mode 100644 index 7c580dfd3022..000000000000 --- a/configmgr/source/api2/propsetaccessimpl.hxx +++ /dev/null @@ -1,138 +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_API_PROPERTYSETIMPL_HXX_ -#define CONFIGMGR_API_PROPERTYSETIMPL_HXX_ - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XHierarchicalPropertySet.hpp> -#include <com/sun/star/beans/XMultiPropertySet.hpp> -#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp> - -#ifndef CONFIGMGR_NO_PROPERTYSTATE -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_ -#include <com/sun/star/beans/XPropertyState.hpp> -#endif -#endif - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - namespace lang = ::com::sun::star::lang; - namespace beans = ::com::sun::star::beans; - - /* implementations of the interfaces supported by a (parent) node - within the configuration tree. - (read-only operation) - */ - namespace configapi - { - class NodeAccess; - class NodeGroupInfoAccess; - class NodeGroupAccess; - - // getting Property Metadata - // XPropertySet & XMultiPropertySet - uno::Reference< beans::XPropertySetInfo > implGetPropertySetInfo( NodeGroupInfoAccess& rNode, sal_Bool _bWriteable ) - throw(uno::RuntimeException); - - // XHierarchicalPropertySet & XHierarchicalMultiPropertySet - uno::Reference< beans::XHierarchicalPropertySetInfo > implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess& rNode ) - throw(uno::RuntimeException); - - // setting values - may all throw (PropertyVeto)Exceptions on read-only property sets - // XPropertySet - void implSetPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - void implSetPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XHierarchicalPropertySet - void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // XMultiHierarchicalPropertySet - void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException); - - // getting values - // XPropertySet - uno::Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertySet - uno::Sequence< uno::Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException); - - // XHierarchicalPropertySet - uno::Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const rtl::OUString& PropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiHierarchicalPropertySet - uno::Sequence< uno::Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(uno::RuntimeException); - - // SPECIAL: firePropertiesChangeEvent - // XMultiPropertySet - void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener ) - throw(uno::RuntimeException); - - // XPropertyState - beans::PropertyState implGetPropertyState( NodeAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - void implSetPropertyToDefault( NodeGroupAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - uno::Any implGetPropertyDefault( NodeGroupInfoAccess& rNode, const rtl::OUString& sPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - - // XMultiPropertyState - uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - void implSetPropertiesToDefault( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, uno::RuntimeException); - - void implSetAllPropertiesToDefault( NodeGroupAccess& rNode ) - throw(uno::RuntimeException); - - uno::Sequence< uno::Any > implGetPropertyDefaults( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); - } - -} -#endif // CONFIGMGR_API_PROPERTYSETIMPL_HXX_ - - diff --git a/configmgr/source/api2/provider.cxx b/configmgr/source/api2/provider.cxx deleted file mode 100644 index c6d24f5e3e2f..000000000000 --- a/configmgr/source/api2/provider.cxx +++ /dev/null @@ -1,711 +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 "apiserviceinfo.hxx" -#include "confapifactory.hxx" -#include "configpath.hxx" -#include "datalock.hxx" -#include "provider.hxx" -#include "providerimpl.hxx" -#include "tracer.hxx" -#include "bootstrap.hxx" -#include "wrapexception.hxx" -#include <osl/mutex.hxx> -#include <rtl/ustrbuf.hxx> -#ifndef __SGI_STL_ALGORITHM -#include <algorithm> -#endif -#include <comphelper/sequence.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <cppuhelper/typeprovider.hxx> -#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> -#include <com/sun/star/lang/XEventListener.hpp> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - namespace beans = css::beans; - - namespace - { - //------------------------------------------------------------------------ - sal_Char const * const aConfigProviderServices[] = - { - "com.sun.star.configuration.ConfigurationProvider", - 0 - }; - sal_Char const * const aAdminProviderServices[] = - { - "com.sun.star.configuration.AdministrationProvider", - 0 - }; - //------------------------------------------------------------------------ - - ServiceImplementationInfo const aConfigProviderInfo = - { - "com.sun.star.comp.configuration.ConfigurationProvider", - aConfigProviderServices, - 0 - }; - ServiceImplementationInfo const aAdminProviderInfo = - { - "com.sun.star.comp.configuration.AdministrationProvider", - aAdminProviderServices, - aConfigProviderServices - }; - //------------------------------------------------------------------------ - - sal_Char const * const - aDefaultProviderServiceAndImplName = A_DefaultProviderServiceAndImplName; - - //------------------------------------------------------------------------ - - sal_Char const * const aDefaultProviderServices[] = - { - aDefaultProviderServiceAndImplName, - 0 - }; - //------------------------------------------------------------------------ - - ServiceRegistrationInfo const aDefaultProviderInfo = - { - aDefaultProviderServiceAndImplName, - aDefaultProviderServices - }; - SingletonRegistrationInfo const aDefaultProviderSingletonInfo = - { - A_DefaultProviderSingletonName, - aDefaultProviderServiceAndImplName, - aDefaultProviderServiceAndImplName, - 0 - }; - //------------------------------------------------------------------------ - typedef uno::Reference< uno::XInterface > (OProviderImpl::*CreatorFunc)(const uno::Sequence< uno::Any >& aArguments); - struct ServiceCreationInfo - { - ServiceRegistrationInfo const* info; - CreatorFunc create; - }; - - static sal_Int32 getCreateServiceDataCount() - { - return 2; - } - - static const ServiceCreationInfo* getCreateServiceData() - { - static ServiceCreationInfo const createServiceData[] = - { - { &configapi::aCreateReadAccessSI, &OProviderImpl::createReadAccess }, - { &configapi::aCreateUpdateAccessSI, &OProviderImpl::createUpdateAccess }, - }; - OSL_ENSURE(sizeof(createServiceData)/sizeof(createServiceData[0]) == getCreateServiceDataCount(), - "getCreateServiceData : inconsistent data !"); - return createServiceData; - } - //------------------------------------------------------------------------ - } - - static ServiceCreationInfo const* findCreationInfo( const rtl::OUString& aServiceSpecifier ) - { - for (int i= 0; i<getCreateServiceDataCount(); ++i) - { - ServiceCreationInfo const& rCreationInfo = getCreateServiceData()[i]; - - ServiceRegistrationInfo const* pInfo = rCreationInfo.info; - if (!pInfo) - continue; - - if (sal_Char const * pImplName = pInfo->implementationName) - { - if (0 == aServiceSpecifier.compareToAscii(pImplName)) - return &rCreationInfo; - } - - if (sal_Char const * const* pNames = pInfo->registeredServiceNames) - { - while(*pNames) - { - if (0 == aServiceSpecifier.compareToAscii(*pNames)) - return &rCreationInfo; - - ++pNames; - } - } - } - // not found - return 0; - } - - //#define ID_PREFETCH 1 - static const int ID_PREFETCH=1; - static const int ID_ENABLEASYNC=2; - - static inline - rtl::OUString getPrefetchPropName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrefetchNodes") ); } - static inline - rtl::OUString getEnableAsyncPropName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("EnableAsync") ); } - //============================================================================= - //= OProvider - //============================================================================= - // service info export - const ServiceRegistrationInfo* getConfigurationProviderServiceInfo() - { - return getRegistrationInfo(&aConfigProviderInfo); - } - - const ServiceRegistrationInfo* getAdminProviderServiceInfo() - { - return getRegistrationInfo(&aAdminProviderInfo); - } - - const ServiceRegistrationInfo* getDefaultProviderServiceInfo() - { - return &aDefaultProviderInfo; - } - - const SingletonRegistrationInfo* getDefaultProviderSingletonInfo() - { - return &aDefaultProviderSingletonInfo; - } - - //----------------------------------------------------------------------------- - uno::Reference<uno::XInterface> SAL_CALL - getDefaultConfigProviderSingleton( uno::Reference< uno::XComponentContext > const& xContext ) - { - OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" ); - - UnoContextTunnel aTunnel; - aTunnel.passthru( xContext ); - - uno::Reference<uno::XInterface> xResult; - - if (xContext.is()) - try - { - rtl::OUString aSingletonName = SINGLETON(A_DefaultProviderSingletonName); - uno::Any aResult = xContext->getValueByName(aSingletonName); - aResult >>= xResult; - } - catch (uno::Exception & ) - { - // to do: really use the tunneled failure when that is set properly - if ( aTunnel.recoverFailure(true).hasValue() ) - { - // have a failure, but can't recover it - // -> try to regenerate - instantiateDefaultProvider(xContext); - - OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error"); - } - // cannot recover any failure - throw; - } - - return xResult; - } - // ------------------------------------------------------------------------ - // ---------------------------------------------------------------------------- - #define TUNNEL_ALL_EXCEPTIONS() \ - WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( UnoContextTunnel::tunnelFailure, true) - - // ---------------------------------------------------------------------------- - // ------------------------------------------------------------------------ - - uno::Reference< uno::XInterface > SAL_CALL instantiateDefaultProvider( uno::Reference< uno::XComponentContext > const & xTargetContext ) - { - uno::Reference< uno::XComponentContext > xContext = UnoContextTunnel::recoverContext(xTargetContext); - - ServiceImplementationInfo const * pProviderInfo = - ContextReader::testAdminService(xContext,true) ? &aAdminProviderInfo : &aConfigProviderInfo; - - OProvider* pNewProvider = new OProvider(xContext,pProviderInfo); - uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider ); - - try - { - pNewProvider->connect(); - } - TUNNEL_ALL_EXCEPTIONS() - - return uno::Reference< uno::XInterface >( aRet, uno::UNO_QUERY ); - } - - // ----------------------------------------------------------------------------- - class OProviderDisposingListener : public cppu::WeakImplHelper1<lang::XEventListener> - { - OProvider* m_pProvider; - - public: - OProviderDisposingListener(OProvider* pProvider) - :m_pProvider(pProvider){} - - virtual void SAL_CALL disposing(com::sun::star::lang::EventObject const& rEvt) throw() - { - CFG_TRACE_INFO("Service Manager or context disposed, disposing the provider"); - if (OProvider* pProvider = m_pProvider) - { - m_pProvider = NULL; - pProvider->disposing(rEvt); - } - } - }; - - //============================================================================= - //= OProvider - //============================================================================= - //----------------------------------------------------------------------------- - OProvider::OProvider(uno::Reference< uno::XComponentContext > const & xContext, ServiceImplementationInfo const* pInfo) - :ServiceComponentImpl(pInfo) - ,OPropertyContainer(ServiceComponentImpl::rBHelper) - ,m_xContext(xContext) - ,m_pImpl(NULL) - ,m_bEnableAsync(false) - { - OSL_ENSURE(m_xContext.is(), "Creating a provider without a context"); - attachToContext(); - registerProperty(getPrefetchPropName(), ID_PREFETCH, 0,&m_aPrefetchNodes, ::getCppuType(&m_aPrefetchNodes)); - registerProperty(getEnableAsyncPropName(), ID_ENABLEASYNC, 0, &m_bEnableAsync, ::getBooleanCppuType()); - } - - //----------------------------------------------------------------------------- - OProvider::~OProvider() - { - delete m_pImpl; - discardContext(releaseContext()); - } - - //----------------------------------------------------------------------------- - void OProvider::connect() throw (uno::Exception) - { - OSL_ENSURE( m_pImpl == NULL, "Error: Configuration Provider already is connected"); - - std::auto_ptr<OProviderImpl> pNewImpl( new OProviderImpl(this, m_xContext) ); - - implConnect(*pNewImpl,ContextReader(m_xContext)); - - m_pImpl = pNewImpl.release(); - if (m_pImpl) - { - sal_Bool isEnabled = m_pImpl->getDefaultOptions().isAsyncEnabled(); - this->setPropertyValue( getEnableAsyncPropName(), uno::makeAny(isEnabled) ); - } - } - - //----------------------------------------------------------------------------- - void OProvider::attachToContext() - { - UnoApiLock aLock; - ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); - OSL_ASSERT(!m_xDisposeListener.is()); - if (m_xContext.is()) - { - uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY); - uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY); - - m_xDisposeListener = new OProviderDisposingListener(this); - - if (xContextComp.is()) xContextComp ->addEventListener(m_xDisposeListener); - if (xServiceMgrComp.is()) xServiceMgrComp->addEventListener(m_xDisposeListener); - - OSL_ENSURE(xServiceMgrComp.is() || xContextComp.is(), - "Provider cannot detect shutdown -> no XComponent found"); - } - } - - //----------------------------------------------------------------------------- - uno::Reference< lang::XComponent > OProvider::releaseContext() - { - UnoApiLock aLock; - ::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex); - - uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY); - if (m_xDisposeListener.is() && m_xContext.is()) - { - uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY); - - if (xContextComp.is()) - { - try { xContextComp ->removeEventListener(m_xDisposeListener); } - catch (uno::Exception & ) {} - } - - if (xServiceMgrComp.is()) - { - try { xServiceMgrComp->removeEventListener(m_xDisposeListener); } - catch (uno::Exception & ) {} - } - } - m_xDisposeListener = NULL; - m_xContext = NULL; - - return xContextComp; - } - //----------------------------------------------------------------------------- - - void OProvider::discardContext(uno::Reference< lang::XComponent > const & xContext) - { - UnoApiLock aLock; - if (xContext.is()) - { - uno::Reference< uno::XComponentContext > xCC(xContext,uno::UNO_QUERY); - OSL_ASSERT(xCC.is()); - - if (BootstrapContext::isWrapper(xCC)) - { - try { xContext->dispose(); } - catch (uno::Exception & ) {} - } - } - } - //----------------------------------------------------------------------------- - // XTypeProvider - //----------------------------------------------------------------------------- - uno::Sequence< uno::Type > SAL_CALL OProvider::getTypes( ) throw(uno::RuntimeException) - { - cppu::OTypeCollection aCollection(::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ), - ::getCppuType( (const uno::Reference< beans::XFastPropertySet > *)0 ), - ::getCppuType( (const uno::Reference< beans::XMultiPropertySet > *)0 ), - ::comphelper::concatSequences(ServiceComponentImpl::getTypes(), cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable >::getTypes())); - return aCollection.getTypes(); - } - - // XPropertySet - //----------------------------------------------------------------------------- - uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OProvider::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) - { - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); - } - - //----------------------------------------------------------------------------- - uno::Reference< uno::XInterface > SAL_CALL OProvider::createInstance( const rtl::OUString& aServiceSpecifier ) - throw(uno::Exception, uno::RuntimeException) - { - UnoApiLock aLock; - // same as creating with empty sequence of arguments - return this->createInstanceWithArguments( aServiceSpecifier, uno::Sequence< uno::Any >() ); - } - - //----------------------------------------------------------------------------- - uno::Reference< uno::XInterface > SAL_CALL - OProvider::createInstanceWithArguments( const rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& aArguments ) - throw(uno::Exception, uno::RuntimeException) - { - UnoApiLock aLock; - - OSL_ENSURE(m_pImpl, "OProvider: no implementation available"); - - if (ServiceCreationInfo const* pInfo = findCreationInfo(aServiceSpecifier)) - { - // it's a known service name - try to create without args - if (CreatorFunc create = pInfo->create) - { - return (m_pImpl->*create)(aArguments); - } - } - - rtl::OUStringBuffer sMsg; - sMsg.appendAscii("ConfigurationProvider: Cannot create view - "); - sMsg.append( aServiceSpecifier ) .appendAscii(" is not a valid configuration access service. "); - - throw lang::ServiceNotRegisteredException(sMsg.makeStringAndClear(),*this); - } - - //----------------------------------------------------------------------------- - uno::Sequence< rtl::OUString > SAL_CALL OProvider::getAvailableServiceNames( ) - throw(uno::RuntimeException) - { - UnoApiLock aLock; - - sal_Int32 nCount = 0; - { - for (int i= 0; i< getCreateServiceDataCount(); ++i) - nCount += countServices(getCreateServiceData()[i].info); - } - - uno::Sequence< rtl::OUString > aNames(nCount); - if (nCount > 0) - { - sal_Int32 n = 0; - for (int i= 0; i<getCreateServiceDataCount(); ++i) - { - ServiceRegistrationInfo const* pInfo = getCreateServiceData()[i].info; - sal_Char const * const* pNames = pInfo ? pInfo->registeredServiceNames : 0; - - if (pNames) - { - while(*pNames) - { - aNames[n] = rtl::OUString::createFromAscii(*pNames); - ++n; - ++pNames; - } - } - } - } - - return aNames; - } - - // XLocalizable - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::setLocale( const lang::Locale& eLocale ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - - OSL_ENSURE(m_pImpl, "OProvider: no implementation available"); - - m_pImpl->setDefaultLocale( eLocale ); - } - - //----------------------------------------------------------------------------- - lang::Locale SAL_CALL OProvider::getLocale() - throw (uno::RuntimeException) - { - UnoApiLock aLock; - - OSL_ENSURE(m_pImpl, "OProvider: no implementation available"); - - return m_pImpl->getDefaultOptions().getUnoLocale(); - } - - //XRefreshable - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::refresh() - throw (uno::RuntimeException) - { - UnoApiLock aLock; - - OSL_ENSURE(m_pImpl, "OProvider: no implementation available"); - - try - { - m_pImpl->refreshAll(); - } - catch (uno::RuntimeException& ) { throw; } - catch (uno::Exception& e) - { - // FIXME: use getCaughtException() - throw lang::WrappedTargetRuntimeException(e.Message, *this, uno::makeAny(e)); - } - //Broadcast the changes - uno::Reference< css::util::XRefreshListener > const * const pRefresh = 0; - cppu::OInterfaceContainerHelper * aInterfaceContainer= - getBroadcastHelper().getContainer (::getCppuType(pRefresh)); - - if(aInterfaceContainer) - { - lang::EventObject aEventObject(*this); - - cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer); - while(aIterator.hasMoreElements()) - { - uno::Reference< uno::XInterface > xIface = aIterator.next(); - uno::Reference< util::XRefreshListener > xRefresh (xIface, uno::UNO_QUERY); - if (xRefresh.is()) - { - xRefresh->refreshed(aEventObject); - } - } - } - } - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::addRefreshListener( - const uno::Reference< util::XRefreshListener >& aListener ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - getBroadcastHelper().addListener(::getCppuType(&aListener), aListener); - } - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::removeRefreshListener( - const uno::Reference< util::XRefreshListener >& aListener ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener); - } - //XFlushable - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::flush( ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - OSL_ENSURE(m_pImpl, "OProvider: no implementation available"); - m_pImpl->flushAll(); - - //Broadcast the changes - uno::Reference< css::util::XFlushListener > const * const pFlush = 0; - cppu::OInterfaceContainerHelper * aInterfaceContainer= - getBroadcastHelper().getContainer(::getCppuType(pFlush)); - - if(aInterfaceContainer) - { - lang::EventObject aEventObject(*this); - - cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer); - while(aIterator.hasMoreElements()) - { - uno::Reference< uno::XInterface > xIface = aIterator.next(); - uno::Reference< util::XFlushListener > xFlush (xIface, uno::UNO_QUERY); - if (xFlush.is()) - { - xFlush->flushed(aEventObject); - } - } - } - } - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::addFlushListener( - const uno::Reference< util::XFlushListener >& aListener ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - getBroadcastHelper().addListener(::getCppuType(&aListener), aListener); - } - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::removeFlushListener( - const uno::Reference< util::XFlushListener >& aListener ) - throw (uno::RuntimeException) - { - UnoApiLock aLock; - getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener); - } - - // XInterface - //----------------------------------------------------------------------------- - uno::Any SAL_CALL OProvider::queryInterface(uno::Type const& rType) throw(uno::RuntimeException) - { - UnoApiLock aLock; - uno::Any aRet( ServiceComponentImpl::queryInterface(rType) ); - if ( !aRet.hasValue() ) - aRet = cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable >::queryInterface(rType); - if ( !aRet.hasValue() ) - aRet = queryPropertyInterface(rType); - return aRet; - } - - //----------------------------------------------------------------------------- - void OProvider::implConnect(OProviderImpl& _rFreshProviderImpl, const ContextReader& _rSettings) throw(uno::Exception) - { - UnoApiLock aLock; - if (!_rFreshProviderImpl.initSession(_rSettings)) - throw uno::Exception(::rtl::OUString::createFromAscii("Could not connect to the configuration. Please check your settings."), static_cast< ::cppu::OWeakObject* >(this) ); - } - - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::disposing(com::sun::star::lang::EventObject const& /*rEvt*/) throw() - { - UnoApiLock aLock; - releaseContext(); - this->dispose(); - } - - //----------------------------------------------------------------------------- - void SAL_CALL OProvider::disposing() - { - UnoApiLock aLock; - - if (m_pImpl) - m_pImpl->dispose(); - - uno::Reference< lang::XComponent > xComp = releaseContext(); - - ServiceComponentImpl::disposing(); - OPropertyContainer::disposing(); - - discardContext( xComp ); - } - - // OPropertyArrayUsageHelper - // ------------------------------------------------------------------------- - ::cppu::IPropertyArrayHelper* OProvider::createArrayHelper( ) const - { - UnoApiLock aLock; - uno::Sequence< beans::Property > aProps; - describeProperties(aProps); - return new ::cppu::OPropertyArrayHelper(aProps); - } - // ------------------------------------------------------------------------- - ::cppu::IPropertyArrayHelper & OProvider::getInfoHelper() - { - UnoApiLock aLock; - return *getArrayHelper(); - } - - void SAL_CALL OProvider::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) - throw (::com::sun::star::uno::Exception) - { - UnoApiLock aLock; - - OPropertyContainer::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - - switch(nHandle) - { - case ID_PREFETCH: - { - uno::Sequence< rtl::OUString > aNodeList; - rValue >>= aNodeList; - - RequestOptions const aOptions = m_pImpl->getDefaultOptions(); - - for (sal_Int32 i = 0; i < aNodeList.getLength(); i++) - { - configuration::AbsolutePath aModulePath = configuration::AbsolutePath::makeModulePath(aNodeList[i]); - m_pImpl->fetchSubtree(aModulePath , aOptions); - } - }break; - - case ID_ENABLEASYNC: - { - //Forward to TreeManager - sal_Bool bAsync; - if (rValue >>= bAsync) - { - m_pImpl->enableAsync(bAsync); - if (!bAsync) - this->flush(); - } - else - OSL_ENSURE(false, "Unexpected type of new property value"); - } - break; - default: - { - OSL_ENSURE(false, "OProvider::setFastPropertyValue_NoBroadcast -unknown property"); - } - - } - } -} // namespace configmgr diff --git a/configmgr/source/api2/provider.hxx b/configmgr/source/api2/provider.hxx deleted file mode 100644 index 596e602c01d7..000000000000 --- a/configmgr/source/api2/provider.hxx +++ /dev/null @@ -1,198 +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_API_PROVIDER_HXX_ -#define CONFIGMGR_API_PROVIDER_HXX_ - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XLocalizable.hpp> -#include <com/sun/star/util/XRefreshable.hpp> -#include <com/sun/star/util/XFlushable.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HDL_ -#include <com/sun/star/lang/IllegalArgumentException.hdl> -#endif -#include "confsvccomponent.hxx" -#include <rtl/ustring.hxx> -#include <vos/ref.hxx> -#include <cppuhelper/implbase4.hxx> -#include <comphelper/proparrhlp.hxx> -#include <comphelper/propertycontainer.hxx> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - namespace beans = css::beans; - namespace util = css::util; - - class Module; - class ContextReader; - class OProviderImpl; - - //========================================================================== - //= OProvider - //========================================================================== - /** Base class to receive access to the configuration data. A provider for configuration is - a factory for service which allow a readonly or update access to the configuration trees. - */ - class OProvider: - private ServiceComponentImpl, private comphelper::OPropertyContainer, - public comphelper::OPropertyArrayUsageHelper< OProvider > - // don't want to allow our derivees to access the mutex of ServiceComponentImpl - // (this helps to prevent deadlocks: The mutex of the base class is used by the OComponentHelper to - // protect addEvenetListener calls. Unfortunately these calls are made from within API object we create, - // too, which can lead do deadlocks ....) - , public cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable > - { - private: - friend class OProviderDisposingListener; - - uno::Reference< uno::XComponentContext > m_xContext; - uno::Reference< lang::XEventListener > m_xDisposeListener; - OProviderImpl * m_pImpl; - uno::Sequence< ::rtl::OUString > m_aPrefetchNodes; - sal_Bool m_bEnableAsync; - - public: - // make ServiceComponentImpl allocation functions public - static void * SAL_CALL operator new( size_t nSize ) throw() - { return ServiceComponentImpl::operator new( nSize ); } - static void SAL_CALL operator delete( void * pMem ) throw() - { ServiceComponentImpl::operator delete( pMem ); } - - OProvider(uno::Reference< uno::XComponentContext > const & xContext, ServiceImplementationInfo const* pInfo); - virtual ~OProvider(); - - void connect() throw (uno::Exception); - - /// XTypeOProvider - virtual uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw(uno::RuntimeException); - - /// XInterface - virtual void SAL_CALL acquire() throw() { ServiceComponentImpl::acquire(); } - virtual void SAL_CALL release() throw() { ServiceComponentImpl::release(); } - virtual uno::Any SAL_CALL queryInterface(uno::Type const& rType) throw (uno::RuntimeException); - - // XPropertySet - virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(uno::RuntimeException); - - /// XMultiServiceFactory - virtual uno::Reference< uno::XInterface > SAL_CALL - createInstance( const rtl::OUString& aServiceSpecifier ) - throw(uno::Exception, uno::RuntimeException); - - virtual uno::Reference< uno::XInterface > SAL_CALL - createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) - throw(uno::Exception, uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getAvailableServiceNames( ) - throw(uno::RuntimeException); - - /// XLocalizable - virtual void SAL_CALL - setLocale( const lang::Locale& eLocale ) - throw (uno::RuntimeException); - - virtual lang::Locale SAL_CALL - getLocale( ) - throw (uno::RuntimeException); - - - //XRefreshable - virtual void SAL_CALL - refresh( ) - throw (uno::RuntimeException); - virtual void SAL_CALL - addRefreshListener( - const uno::Reference< util::XRefreshListener >& aListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL - removeRefreshListener( - const uno::Reference< util::XRefreshListener >& aListener ) - throw (uno::RuntimeException); - //XFlushable - virtual void SAL_CALL - flush( ) - throw (uno::RuntimeException); - virtual void SAL_CALL - addFlushListener( - const uno::Reference< util::XFlushListener >& aListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL - removeFlushListener( - const uno::Reference< util::XFlushListener >& aListener ) - throw (uno::RuntimeException); - - // OPropertSetHelper - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, const uno::Any& rValue) throw (uno::Exception); - - static sal_Int32 countServices(ServiceRegistrationInfo const* aInfo) { return ServiceRegistrationHelper(aInfo).countServices(); } - - private: - // creates a new session - void implConnect(OProviderImpl& rFreshProviderImpl, const ContextReader& _rSettings) throw (uno::Exception); - - // disambuiguated access - cppu::OBroadcastHelper & getBroadcastHelper() - { return ServiceComponentImpl::rBHelper; } - - /// Component Helper override - virtual void SAL_CALL disposing(); - virtual void SAL_CALL disposing(lang::EventObject const& rEvt) throw(); - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; - - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - // OPropertyContainer - void registerProperty(const rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, - void* _pPointerToMember, const uno::Type& _rMemberType) - { OPropertyContainer::registerProperty(_rName, _nHandle, _nAttributes, _pPointerToMember, _rMemberType);} - - void describeProperties(uno::Sequence< beans::Property >& /* [out] */ _rProps) const - { OPropertyContainer::describeProperties(_rProps);} - - - uno::Any SAL_CALL queryPropertyInterface(uno::Type const& rType) throw (uno::RuntimeException) - { return OPropertyContainer::queryInterface(rType);} - - void attachToContext(); - uno::Reference< lang::XComponent > releaseContext(); - void discardContext(uno::Reference< lang::XComponent > const & xContext); - }; - -} // namespace configmgr - -#endif // CONFIGMGR_API_PROVIDER_HXX_ - - diff --git a/configmgr/source/api2/providerimpl.cxx b/configmgr/source/api2/providerimpl.cxx deleted file mode 100644 index 106838dd5ca0..000000000000 --- a/configmgr/source/api2/providerimpl.cxx +++ /dev/null @@ -1,893 +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 "providerimpl.hxx" -#include "options.hxx" -#include "apifactoryimpl.hxx" -#include "apitreeimplobj.hxx" -#include "apitreeaccess.hxx" -#include "roottree.hxx" -#include "node.hxx" -#include "noderef.hxx" -#include "objectregistry.hxx" -#include "bootstrap.hxx" -#include "cachefactory.hxx" -#include "provider.hxx" -#include "treemanager.hxx" -#include "tracer.hxx" -#include <osl/interlck.h> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/lang/Locale.hpp> -#include <rtl/ustrbuf.hxx> -#include <rtl/logfile.hxx> - -#define RTL_LOGFILE_OU2A(rtlOUString) (::rtl::OUStringToOString((rtlOUString), RTL_TEXTENCODING_ASCII_US).getStr()) - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace beans = css::beans; - - namespace configapi - { - - class ApiProviderInstances - { - rtl::Reference<ObjectRegistry> m_aObjectRegistry; - ReadOnlyObjectFactory m_aReaderFactory; - UpdateObjectFactory m_aWriterFactory; - ApiProvider m_aReaderProvider; - ApiProvider m_aWriterProvider; - public: - ApiProviderInstances(OProviderImpl& rProviderImpl) - : m_aObjectRegistry(new ObjectRegistry()) - , m_aReaderFactory(m_aReaderProvider,m_aObjectRegistry) - , m_aWriterFactory(m_aWriterProvider,m_aObjectRegistry) - , m_aReaderProvider(m_aReaderFactory,rProviderImpl) - , m_aWriterProvider(m_aWriterFactory,rProviderImpl) - { - } - - ~ApiProviderInstances() - {} - - ApiProvider& getReaderProvider() { return m_aReaderProvider; } - ApiProvider& getWriterProvider() { return m_aWriterProvider; } - Factory& getReaderFactory() { return m_aReaderFactory; } - Factory& getWriterFactory() { return m_aWriterFactory; } - }; - } - - //============================================================================= - - //============================================================================= - //= OProviderImpl - //============================================================================= - //----------------------------------------------------------------------------- - OProviderImpl::OProviderImpl(OProvider* _pProvider, uno::Reference< uno::XComponentContext > const & _xContext) - :m_pProvider(_pProvider) - ,m_xTypeConverter() - ,m_aDefaultOptions() - ,m_pNewProviders(NULL) - ,m_aTreeManagerMutex() - ,m_pTreeManager(NULL) - { - OSL_ENSURE(_xContext.is(), "OProviderImpl : NULL context !"); - - uno::Reference< lang::XMultiComponentFactory > xFactory = _xContext->getServiceManager(); - OSL_ENSURE(xFactory.is(), "OProviderImpl : missing service factory !"); - - m_xTypeConverter = m_xTypeConverter.query( - xFactory->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )), - _xContext)); - - OSL_ENSURE(m_xTypeConverter.is(), "Module::Module : could not create an instance of the type converter !"); - } - //----------------------------------------------------------------------------- - rtl::Reference< TreeManager > OProviderImpl::maybeGetTreeManager() const SAL_THROW(()) - { - osl::MutexGuard aGuard(m_aTreeManagerMutex); - rtl::Reference< TreeManager > xResult(m_pTreeManager); - return xResult; - } - //----------------------------------------------------------------------------- - rtl::Reference< TreeManager > OProviderImpl::getTreeManager() const SAL_THROW((com::sun::star::uno::RuntimeException)) - { - osl::MutexGuard aGuard(m_aTreeManagerMutex); - if (m_pTreeManager == NULL) - { - rtl::OUString sMsg = rtl::OUString::createFromAscii("OProviderImpl: No cache available - provider was already disposed."); - throw com::sun::star::lang::DisposedException(sMsg,static_cast<lang::XMultiServiceFactory*>(m_pProvider)); - } - rtl::Reference< TreeManager > xResult(m_pTreeManager); - return xResult; - } - //----------------------------------------------------------------------------- - void OProviderImpl::setTreeManager(TreeManager * pTreeManager) SAL_THROW((com::sun::star::uno::RuntimeException)) - { - osl::MutexGuard aGuard(m_aTreeManagerMutex); - - OSL_PRECOND(m_pTreeManager == NULL, "OProviderImpl: TreeManager is already set"); - OSL_PRECOND(pTreeManager != NULL, "OProviderImpl: Trying to set a NULL TreeManager"); - - if (pTreeManager == NULL) - { - rtl::OUString sMsg = rtl::OUString::createFromAscii("OProviderImpl: No cache available - cache creation failed."); - throw com::sun::star::uno::RuntimeException(sMsg,NULL); - } - - (m_pTreeManager = pTreeManager) -> acquire(); - } - //----------------------------------------------------------------------------- - void OProviderImpl::clearTreeManager() SAL_THROW(()) - { - osl::ClearableMutexGuard aGuard(m_aTreeManagerMutex); - if (TreeManager * pTM = m_pTreeManager) - { - m_pTreeManager = NULL; - pTM->release(); - } - } - //----------------------------------------------------------------------------- - bool OProviderImpl::initSession(const ContextReader& _rSettings) - { - bool bNeedProfile = false; - rtl::Reference< TreeManager > xNewTreeManager; - if (_rSettings.isUnoBackend()) - { - this->implInitFromSettings(_rSettings,bNeedProfile); - - xNewTreeManager = CacheFactory::instance().createCacheManager(_rSettings.getBaseContext()); - } - else - { - throw com::sun::star::uno::RuntimeException(rtl::OUString::createFromAscii("OProviderImpl: Only UNO Backends Supported"),NULL); - } - - setTreeManager( xNewTreeManager.get() ); - OSL_ASSERT( xNewTreeManager.get() ); - - // put out of line to get rid of the order dependency (and to have a acquired configuration) - m_pNewProviders = new configapi::ApiProviderInstances(*this); - - // now complete our state from the user's profile, if necessary - if (bNeedProfile) - try - { - static ::rtl::OUString ssUserProfile(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")); - configuration::AbsolutePath aProfileModule = configuration::AbsolutePath::makeModulePath(ssUserProfile); - - sharable::Node * profileTree = xNewTreeManager->requestSubtree(aProfileModule, m_aDefaultOptions); - if (profileTree != 0) - { - implInitFromProfile(profileTree); - - // should we clean this up ? - // xNewTreeManager->releaseSubtree(aProfileModule, xTempOptions); - } - } - catch (uno::Exception& e) - { - // could not read profile - (void)e; - CFG_TRACE_ERROR_NI("Provider bootstrapping: Caught an exception trying to get 'Setup' data: %s", OUSTRING2ASCII(e.Message)); - } - - return true; - } - //----------------------------------------------------------------------------- - - // these can be overridden. default does nothing - void OProviderImpl::initFromSettings(const ContextReader& , bool& ) - { - } - //----------------------------------------------------------------------------- - void OProviderImpl::initFromProfile(sharable::Node *) - { - } - //----------------------------------------------------------------------------- - // these implement the base class behavior - void OProviderImpl::implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile) - { - bool bIntrinsicNeedProfile = true; - - if (_rSettings.hasLocale()) - { - bIntrinsicNeedProfile = false; - rtl::OUString sDefaultLocale = _rSettings.getLocale(); - m_aDefaultOptions.setIsoLocale(sDefaultLocale); - } - else if (_rSettings.isAdminService()) - { - bIntrinsicNeedProfile = false; - m_aDefaultOptions.setAllLocales(); - } - else - OSL_ASSERT(!m_aDefaultOptions.hasLocale()); - - if (_rSettings.hasAsyncSetting()) - { - m_aDefaultOptions.enableAsync( !!_rSettings.getAsyncSetting() ); - } - - - // call the template method - this->initFromSettings(_rSettings, rNeedProfile); - - if (bIntrinsicNeedProfile) - rNeedProfile = true; // to get locale - } - //----------------------------------------------------------------------------- - void OProviderImpl::implInitFromProfile(sharable::Node * profile) - { - OSL_ASSERT(profile != 0); - - sharable::GroupNode * profileNode = sharable::GroupNode::from(profile); - - OSL_ASSERT(profileNode != 0); - - // read the default locale for the user - if (!m_aDefaultOptions.hasLocale()) - { - static rtl::OUString ssSubGroup(RTL_CONSTASCII_USTRINGPARAM("L10N")); - static rtl::OUString ssLocale(RTL_CONSTASCII_USTRINGPARAM("ooLocale")); - - sharable::GroupNode * l10nNode = sharable::GroupNode::from(profileNode->getChild(ssSubGroup)); - if (l10nNode != 0) - { - sharable::ValueNode * value = sharable::ValueNode::from(l10nNode->getChild(ssLocale)); - - if (value != 0) - { - rtl::OUString sDefaultLocale; - if (value->getValue() >>= sDefaultLocale) - { - m_aDefaultOptions.setIsoLocale(sDefaultLocale); - } - else - OSL_ENSURE(false, "Could not extract locale parameter into string"); - } - } - } - - // call the template method - this->initFromProfile(profile); - - // last fallback, if there is no locale - even in ooLocale - m_aDefaultOptions.ensureLocaleSet(); - } - - //----------------------------------------------------------------------------- - void OProviderImpl::setDefaultLocale( com::sun::star::lang::Locale const & aLocale ) - { - m_aDefaultOptions.setLocale( aLocale ); - // ensure that the locale is never cleared to 'empty' - m_aDefaultOptions.ensureLocaleSet(); - } - - //----------------------------------------------------------------------------- - OProviderImpl::~OProviderImpl() - { - UnoApiLock aLock; // hmm... - clearTreeManager(); - - delete m_pNewProviders; - } - - // --------------------------------- disposing --------------------------------- - void SAL_CALL OProviderImpl::dispose() throw() - { - try - { - rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); - - if (xTM.is()) - xTM->dispose(); - - clearTreeManager(); - } - catch (uno::Exception& e) - { - (void)e; - CFG_TRACE_ERROR("Disposing the TreeManager or closing the session caused an exception: %s", OUSTRING2ASCII(e.Message)); - clearTreeManager(); - } - } - - //----------------------------------------------------------------------------- - // access to the raw notifications - TreeManager * OProviderImpl::getNotifier() SAL_THROW(()) - { - rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); - return xTM.get(); - } - - // DefaultProvider access - //----------------------------------------------------------------------------- - rtl::Reference< TreeManager > OProviderImpl::getDefaultProvider() const SAL_THROW((com::sun::star::uno::RuntimeException)) - { - return getTreeManager().get(); - } - - //----------------------------------------------------------------------------- - sharable::Node * OProviderImpl::requestSubtree( configuration::AbsolutePath const& aSubtreePath, - RequestOptions const & _aOptions - ) SAL_THROW((com::sun::star::uno::Exception)) - { - rtl::Reference< TreeManager > xTreeManager = getTreeManager(); - - sharable::Node * tree = 0; - try - { - tree = xTreeManager->requestSubtree(aSubtreePath, _aOptions); - } - catch(uno::Exception&e) - { - ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions); - // append the error message given by the tree provider - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe backend returned the following error:\n")); - sMessage += e.Message; - - throw lang::WrappedTargetException(sMessage, getProviderInstance(), uno::makeAny(e)); - } - - if (tree == 0) - { - ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions); - - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nNo backend error message available\n")); - - throw uno::Exception(sMessage, getProviderInstance()); - } - - return tree; - } - - //----------------------------------------------------------------------------- - void OProviderImpl::updateTree(TreeChangeList& aChanges) SAL_THROW((com::sun::star::uno::Exception)) - { - getTreeManager()->updateTree(aChanges); - } - - //----------------------------------------------------------------------------- - void OProviderImpl::releaseSubtree( configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions ) SAL_THROW(()) - { - rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); - if (xTM.is()) - xTM->releaseSubtree(aSubtreePath, _aOptions); - } - - //----------------------------------------------------------------------------- - void OProviderImpl::saveAndNotifyUpdate(TreeChangeList const& aChanges) SAL_THROW((com::sun::star::uno::Exception)) - { - getTreeManager()->saveAndNotifyUpdate(aChanges); - } - - //----------------------------------------------------------------------------- - void OProviderImpl::fetchSubtree(configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) SAL_THROW(()) - { - rtl::Reference< TreeManager > xTM = maybeGetTreeManager(); - if (xTM.is()) - xTM->fetchSubtree(aSubtreePath, _aOptions); - } - - //----------------------------------------------------------------------------- - sal_Bool OProviderImpl::fetchDefaultData(configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) SAL_THROW((com::sun::star::uno::Exception)) - { - return getTreeManager()->fetchDefaultData(aSubtreePath, _aOptions); - } - //----------------------------------------------------------------------------------- - void OProviderImpl::refreshAll()SAL_THROW((com::sun::star::uno::Exception)) - { - m_pTreeManager->refreshAll(); - } - //----------------------------------------------------------------------------------- - void OProviderImpl::flushAll()SAL_THROW(()) - { - m_pTreeManager->flushAll(); - } - //----------------------------------------------------------------------------------- - void OProviderImpl::enableAsync(const sal_Bool& bEnableAsync) SAL_THROW(()) - { - m_pTreeManager->enableAsync(bEnableAsync); - } - //----------------------------------------------------------------------------- - uno::XInterface* OProviderImpl::getProviderInstance() - { - return static_cast<com::sun::star::lang::XMultiServiceFactory*>(m_pProvider); - } - - //----------------------------------------------------------------------------------- - rtl::OUString OProviderImpl::getErrorMessage(configuration::AbsolutePath const& _rAccessor, RequestOptions const& _aOptions) - { - rtl::OUString const sAccessor = _rAccessor.toString(); - - CFG_TRACE_ERROR("config provider: the cache manager could not provide the tree (neither from the cache nor from the session)"); - ::rtl::OUString sMessage; - ::rtl::OUString sEntity(_aOptions.getEntity()); - ::rtl::OUString sLocale(_aOptions.getLocale()); - CFG_TRACE_INFO_NI("config provider: the entity we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sEntity), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(sAccessor)); - sMessage += sAccessor; - - if (sEntity.getLength()) - { - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for entity ")); - sMessage += sEntity; - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); - } - - if (sLocale.getLength()) - { - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for locale ")); - sMessage += sLocale; - sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); - } - - sMessage += ::rtl::OUString::createFromAscii(" could not be created. Unable to retrieve the node from the configuration server."); - return sMessage; - } - - // actual factory methods - //----------------------------------------------------------------------------------- - configapi::NodeElement* OProviderImpl::buildReadAccess(rtl::OUString const& _rAccessor, RequestOptions const& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception)) - { - CFG_TRACE_INFO("config provider: requesting the tree from the cache manager"); - - OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels); - - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderImpl", "jb99855", "configmgr::OProviderImpl::buildReadAccess()"); - RTL_LOGFILE_CONTEXT_TRACE1(aLog, "request path: %s", RTL_LOGFILE_OU2A(_rAccessor) ); - - try - { - configuration::AbsolutePath aAccessorPath = configuration::AbsolutePath::parse(_rAccessor); - - sharable::Node * tree = requestSubtree(aAccessorPath,_aOptions); - - RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" ); - - unsigned int nDepth = (nMinLevels == treeop::ALL_LEVELS) ? configuration::C_TreeDepthAll : (unsigned int)(nMinLevels); - - RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "configmgr: createReadOnlyTree()"); - - rtl::Reference< configuration::Tree > aRootTree( configuration::createReadOnlyTree( - aAccessorPath, tree, nDepth, - configuration::TemplateProvider( getTreeManager(), _aOptions ) - )); - - return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _aOptions); - } - catch (configuration::Exception& e) - { - configapi::ExceptionMapper ec(e); - ec.setContext(this->getProviderInstance()); - //ec.unhandled(); - throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any()); - } - } - - - //----------------------------------------------------------------------------------- - configapi::NodeElement* OProviderImpl::buildUpdateAccess(rtl::OUString const& _rAccessor, RequestOptions const& _aOptions, - sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception)) - { - CFG_TRACE_INFO("config provider: requesting the tree from the cache manager"); - OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels); - - RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderImpl", "jb99855", "configmgr: buildUpdateAccess()"); - RTL_LOGFILE_CONTEXT_TRACE1(aLog, "request path: %s", RTL_LOGFILE_OU2A(_rAccessor) ); - - try - { - configuration::AbsolutePath aAccessorPath = configuration::AbsolutePath::parse(_rAccessor); - - sharable::Node * tree = requestSubtree(aAccessorPath, _aOptions); - - RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" ); - - unsigned int nDepth = (nMinLevels == treeop::ALL_LEVELS) ? configuration::C_TreeDepthAll : (unsigned int)(nMinLevels); - - RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "createUpdatableTree()"); - - rtl::Reference< configuration::Tree > aRootTree( configuration::createUpdatableTree( - aAccessorPath, tree, nDepth, - configuration::TemplateProvider( getTreeManager(), _aOptions ) - )); - - - return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _aOptions); - } - catch (configuration::Exception& e) - { - configapi::ExceptionMapper ec(e); - ec.setContext(this->getProviderInstance()); - //ec.unhandled(); - throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any()); - } - } - - //============================================================================= - //= OProvider::FactoryArguments - //============================================================================= - - sal_Char const * const OProviderImpl::FactoryArguments::asciiArgumentNames[] = - { - "nodepath", // ARG_NODEPATH, // requested node path - "depth", // ARG_DEPTH, // depth of the tree - "user", // ARG_USER_DEPRECATED, // name of the user - only for admin - "locale", // ARG_LOCALE, // desired locale - "nocache", // ARG_NOCACHE_OBSOLETE, // cache disabling - "lazywrite", // ARG_ASYNC_DEPRECATED, // lasy write data - "enableasync", // ARG_ASYNC, // lasy write data - "entity", // ARG_ENTITY, // name of the entity to be manipulated - only for admin - "reload", //ARG_REFRESH // refresh component - - }; - - OProviderImpl::FactoryArguments::Argument - OProviderImpl::FactoryArguments::lookupArgument(const rtl::OUString& rName) - SAL_THROW(()) - { - rtl::OUString sCheck( rName.toAsciiLowerCase() ); - - sal_Char const * const * const pFirst = asciiArgumentNames; - sal_Char const * const * const pLast = pFirst + _arg_count; - - sal_Char const * const * it = pFirst; - - for(; it != pLast; ++it) - { - if (0 == sCheck.compareToAscii(*it)) - { - break; - } - } - - OSL_ASSERT( Argument(pLast-pFirst) == ARG_NOT_FOUND ); - return static_cast<Argument>(it - pFirst); - } - - //----------------------------------------------------------------------------------- - bool OProviderImpl::FactoryArguments::extractOneArgument( - rtl::OUString const& aName, uno::Any const& aValue, - rtl::OUString& /* [out] */ _rNodeAccessor, - sal_Int32& /* [out] */ _nLevels, - RequestOptions& /* [in/out] */ _rOptions ) - SAL_THROW(()) - { - switch ( lookupArgument(aName) ) - { - case ARG_NODEPATH: - { - rtl::OUString sStringVal; - if (aValue >>= sStringVal) - _rNodeAccessor = sStringVal; - else - return false; - } - break; - - case ARG_DEPTH: - { - sal_Int32 nIntVal = 0; - if (aValue >>= nIntVal) - _nLevels = nIntVal; - else - return false; - } - break; - - case ARG_ENTITY: - case ARG_USER_DEPRECATED: - { - rtl::OUString sStringVal; - if (aValue >>= sStringVal) - _rOptions.setEntity(sStringVal); - else - return false; - } - break; - - case ARG_LOCALE: - { - rtl::OUString sStringVal; - if (aValue >>= sStringVal) - { - _rOptions.setIsoLocale(sStringVal); - break; - } - - lang::Locale aLocale; - if (aValue >>= aLocale) - { - _rOptions.setLocale(aLocale); - break; - } - - return false; - } - - case ARG_NOCACHE_OBSOLETE: - { - sal_Bool bBoolVal; - if (aValue >>= bBoolVal) - OSL_ENSURE(false,"ConfigurationProvider: Parameter \"nocache\" is obsolete and has no effect"); - else - return false; - } - break; - - case ARG_ASYNC: - case ARG_ASYNC_DEPRECATED: - { - sal_Bool bBoolVal = sal_False; - if (aValue >>= bBoolVal) - _rOptions.enableAsync(!!bBoolVal); - else - return false; - } - break; - case ARG_REFRESH: - { - sal_Bool bBoolVal = sal_False; - if (aValue >>= bBoolVal) - _rOptions.forceRefresh(!!bBoolVal); - else - return false; - } - break; - - case ARG_NOT_FOUND: - { - rtl::OString sMessage(RTL_CONSTASCII_STRINGPARAM("Unknown argument \"")); - sMessage += rtl::OUStringToOString(aName, RTL_TEXTENCODING_ASCII_US); - sMessage += rtl::OString(RTL_CONSTASCII_STRINGPARAM("\" !\n- Parameter will be ignored -\n")); - CFG_TRACE_WARNING( "provider: %s", sMessage.getStr() ); - #ifdef DBG_UTIL - OSL_ENSURE(false, sMessage.getStr()); - #endif - } - break; - - default: - CFG_TRACE_ERROR( "Known argument is not handled" ); - OSL_ENSURE(false, "Known argument is not handled"); - break; - } - return true; - } - - //----------------------------------------------------------------------------------- - static - void failInvalidArg(uno::Any const & aArg, sal_Int32 _nArg = -1) - SAL_THROW((lang::IllegalArgumentException)) - { - OSL_ENSURE( sal_Int16(_nArg) == _nArg, "Argument number out of range. Raising imprecise exception."); - - rtl::OUStringBuffer sMessage; - sMessage.appendAscii("Configuration Provider: An argument"); - sMessage.appendAscii(" has the wrong type."); - sMessage.appendAscii("\n- Expected a NamedValue or PropertyValue"); - sMessage.appendAscii("\n- Found type ").append( aArg.getValueType().getTypeName() ); - - throw lang::IllegalArgumentException( sMessage.makeStringAndClear(), - uno::Reference<uno::XInterface>(), - sal_Int16(_nArg+1)); - } - - //----------------------------------------------------------------------------------- - static - void failInvalidArgValue(rtl::OUString const & aName, uno::Any const & aValue, sal_Int32 _nArg = -1) - SAL_THROW((lang::IllegalArgumentException)) - { - OSL_ENSURE( sal_Int16(_nArg) == _nArg, "Argument number out of range. Raising imprecise exception."); - - rtl::OUStringBuffer sMessage; - sMessage.appendAscii("Configuration Provider: The argument ").append(aName); - sMessage.appendAscii(" has the wrong type."); - sMessage.appendAscii("\n- Found type ").append( aValue.getValueType().getTypeName() ); - - throw lang::IllegalArgumentException( sMessage.makeStringAndClear(), - uno::Reference<uno::XInterface>(), - sal_Int16(_nArg+1)); - } - - //----------------------------------------------------------------------------------- - static - bool extractLegacyArguments( const uno::Sequence<uno::Any>& _rArgs, - rtl::OUString& /* [out] */ _rNodeAccessor, - sal_Int32& /* [out] */ _nLevels ) - SAL_THROW((lang::IllegalArgumentException)) - { - OSL_ASSERT( _rArgs.getLength() != 0 ); - - // compatibility : formerly, you could specify the node path as first arg and the (optional) depth - // as second arg - if (! (_rArgs[0] >>= _rNodeAccessor) ) - return false; - - switch (_rArgs.getLength() ) - { - case 1: - // valid single argument - return true; - - case 2: - // valid second argument - if (_rArgs[1] >>= _nLevels) - return true; - - break; - - default: - if (_rArgs[1] >>= _nLevels) - { - // valid second argument, but too many arguments altogether - throw lang::IllegalArgumentException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Configuration Provider: Too many arguments. " - "Additional arguments are not supported when passing the node path as string (deprecated convention).")), - uno::Reference<uno::XInterface>(), - sal_Int16(3) - ); - } - - break; - - } - // here we have an invalid second argument - - if (_rArgs[1].getValueTypeClass() != uno::TypeClass_STRUCT) - { - // completely invalid second argument - failInvalidArgValue(rtl::OUString::createFromAscii("<depth>"),_rArgs[1],1); - } - - // Assume PropertyValue or NamedValue, - // which should be handled consistently by caller - return false; - } - - //----------------------------------------------------------------------------------- - void OProviderImpl::FactoryArguments::extractArgs( const uno::Sequence<uno::Any>& _rArgs, - rtl::OUString& /* [out] */ _rNodeAccessor, - sal_Int32& /* [out] */ _nLevels, - RequestOptions & /* [in/out] */ _aOptions ) - SAL_THROW((lang::IllegalArgumentException)) - { - UnoApiLock aLock; - - _nLevels = treeop::ALL_LEVELS; // setting a fallback - - // the args have to be a sequence of property or named values - beans::NamedValue aNV; - beans::PropertyValue aPV; - for (sal_Int32 i=0; i<_rArgs.getLength(); ++i) - { - if (_rArgs[i] >>= aPV) - { - if ( !extractOneArgument(aPV.Name,aPV.Value,_rNodeAccessor,_nLevels,_aOptions) ) - failInvalidArgValue(aPV.Name,aPV.Value,i); - } - else if (_rArgs[i] >>= aNV) - { - if ( !extractOneArgument(aNV.Name,aNV.Value,_rNodeAccessor,_nLevels,_aOptions) ) - failInvalidArgValue(aNV.Name,aNV.Value,i); - } - else - { - if (i == 0)// try compatibility format - if ( extractLegacyArguments(_rArgs,_rNodeAccessor,_nLevels)) - break; - - failInvalidArg(_rArgs[i],i); - OSL_ASSERT(false); - } - } - - if (_rNodeAccessor.getLength() == 0) - { - rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM("Configuration Provider: Missing argument: no nodepath was provided")); - throw lang::IllegalArgumentException(sMessage,uno::Reference<uno::XInterface>(),0); - } - } - - //-------------------------------------------------------------------------- - uno::Reference<uno::XInterface> OProviderImpl::createReadAccess( uno::Sequence<uno::Any> const& aArgs) - SAL_THROW((com::sun::star::uno::Exception)) - { - CFG_TRACE_INFO("config provider: going to create a read access instance"); - - // extract the args - rtl::OUString sPath; - sal_Int32 nLevels; - - RequestOptions aOptions = getDefaultOptions(); - - OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions); - - CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath)); - CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels); - - // create the access object - uno::Reference< uno::XInterface > xReturn; - - configapi::NodeElement* pElement = buildReadAccess(sPath, aOptions, nLevels); - if (pElement != 0) - { - xReturn = pElement->getUnoInstance(); - if (xReturn.is()) - // acquired once by buildReadAccess - xReturn->release(); - } - - return xReturn; - } - - //----------------------------------------------------------------------------------- - uno::Reference<uno::XInterface> OProviderImpl::createUpdateAccess( uno::Sequence<uno::Any> const& aArgs) - SAL_THROW((com::sun::star::uno::Exception)) - { - CFG_TRACE_INFO("config provider: going to create an update access instance"); - - // extract the args - rtl::OUString sPath; - sal_Int32 nLevels; - - RequestOptions aOptions = getDefaultOptions(); - - OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions); - - CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath)); - CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels); - - // create the access object - uno::Reference< uno::XInterface > xReturn; - - configapi::NodeElement* pElement = buildUpdateAccess(sPath, aOptions, nLevels); - if (pElement != 0) - { - xReturn = pElement->getUnoInstance(); - if (xReturn.is()) - // acquired once by buildReadAccess - xReturn->release(); - } - - return xReturn; - } -//----------------------------------------------------------------------------------- - - -} // namespace configmgr - - diff --git a/configmgr/source/api2/providerimpl.hxx b/configmgr/source/api2/providerimpl.hxx deleted file mode 100644 index 37608184631c..000000000000 --- a/configmgr/source/api2/providerimpl.hxx +++ /dev/null @@ -1,228 +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_API_PROVIDERIMPL_HXX_ -#define CONFIGMGR_API_PROVIDERIMPL_HXX_ - -#include "defaultprovider.hxx" -#include "requestoptions.hxx" -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/script/XTypeConverter.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <cppuhelper/implbase1.hxx> -#include <osl/mutex.hxx> - -namespace com { namespace sun { namespace star { - namespace uno - { - class Any; - class XInterface; - template <class> class Sequence; - template <class> class Reference; - } - namespace beans - { - struct PropertyValue; - } -} } } - -namespace rtl -{ - class OUString; - template <class RCType> class Reference; -} - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace script = css::script; - namespace lang = css::lang; - namespace beans = css::beans; - - class ISubtree; - struct TreeChangeList; - class TreeManager; - class ContextReader; - class OProvider; - - namespace configapi - { - class NodeElement; - class ApiProviderInstances; - class Factory; - } - namespace sharable { union Node; } - - // ----------------------------------------------------------------------------- - class OProviderImpl : public IDefaultableTreeManager - { - friend class OProvider; - public: - //========================================================================== - //= FactoryArguments - //========================================================================== - /** Helper class for evaluation of the arguments for creating a service instance.*/ - struct FactoryArguments - { - /// possible arguments, given only in small letters. - enum Argument - { - ARG_NODEPATH, // requested node path - ARG_DEPTH, // depth of the tree - ARG_USER_DEPRECATED, // name of the entity to be manipulated - deprecated version - ARG_LOCALE, // desired locale - ARG_NOCACHE_OBSOLETE, // cache disabling - obsolete and nonfunctional - ARG_ASYNC_DEPRECATED, // lasy write data - deprecated version - ARG_ASYNC, // lazy write data - ARG_ENTITY, // name of the entity to be manipulated - only for admin - ARG_REFRESH, // force refresh of data into cache - - _arg_count, - ARG_NOT_FOUND = _arg_count - }; - static sal_Char const * const asciiArgumentNames[]; - - static Argument lookupArgument(rtl::OUString const& sArgumentName) SAL_THROW(()); - public: - /** extracts arguments from the argument sequence into to the parameter variables - - <p>unknown arguments are ignored</p> - - @throws com::sun::star::lang::IllegalArgumentException - if an element of _rArgs had the wrong type or - if the value of a known argument has the wrong type or - if the value of a known argument is out of range (sometimes) - or if no non-empty node path argument could be extracted, - */ - static void extractArgs( const uno::Sequence<uno::Any>& _rArgs, - rtl::OUString& /* [out] */ _rNodeAccessor, - sal_Int32& /* [out] */ _nLevels, - RequestOptions& /* [in/out] */ xOptions) - SAL_THROW((lang::IllegalArgumentException)); - - static bool extractOneArgument( rtl::OUString const& aName, uno::Any const& aValue, - rtl::OUString& /* [out] */ _rNodeAccessor, - sal_Int32& /* [out] */ _nLevels, - RequestOptions& /* [in/out] */ xOptions - ) SAL_THROW(()); - - }; - - private: - OProvider* m_pProvider; /// used for ref counting, uno representation - - uno::Reference< script::XTypeConverter > m_xTypeConverter; - RequestOptions m_aDefaultOptions; - configapi::ApiProviderInstances* m_pNewProviders; - mutable osl::Mutex m_aTreeManagerMutex; - TreeManager* m_pTreeManager; /// the tree cache. Will hold a reference to us as long as it life - - rtl::Reference< TreeManager > maybeGetTreeManager() const SAL_THROW(()); - rtl::Reference< TreeManager > getTreeManager() const SAL_THROW((com::sun::star::uno::RuntimeException)); - void setTreeManager(TreeManager * pTreeManager) SAL_THROW((com::sun::star::uno::RuntimeException)); - void clearTreeManager() SAL_THROW(()); - - OProviderImpl(OProvider* _pProvider, - uno::Reference< uno::XComponentContext > const & xContext); - - public: - virtual ~OProviderImpl(); - - /** request that the tree named by a path is added to the collection of managed trees - respecting certain options and requiring a specific loading depth. - Return a reference to that managed tree. - The reference must later be released by calling releaseSubtree with the same path and options. - */ - sharable::Node * requestSubtree(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) SAL_THROW((com::sun::star::uno::Exception)); - - /// update the managed data according to a changes list - update the changes list accordingly with old values - void updateTree(TreeChangeList& aChanges) SAL_THROW((com::sun::star::uno::Exception)); - - // bookkeeping support - void releaseSubtree( configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions ) SAL_THROW(()); - - // notification - void saveAndNotifyUpdate(TreeChangeList const& aChanges) SAL_THROW((com::sun::star::uno::Exception)); - - /** request that the tree named by a path is added to the collection of managed trees - respecting certain options and requiring a specific loading depth. - */ - void fetchSubtree(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) SAL_THROW(()); - - //Refresh all components in the cache - void refreshAll() SAL_THROW((com::sun::star::uno::Exception)); - - //Flush all components in the cache - void flushAll() SAL_THROW(()); - - //Enable/Disable Asynchronous write-back to cache - void enableAsync(const sal_Bool& bEnableAsync) SAL_THROW(()); - - /// IDefaultableTreeManager - virtual sal_Bool fetchDefaultData(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions - ) SAL_THROW((com::sun::star::uno::Exception)); - - // DefaultProvider access - rtl::Reference< TreeManager > getDefaultProvider() const SAL_THROW((com::sun::star::uno::RuntimeException)); - - protected: - static rtl::OUString getErrorMessage(configuration::AbsolutePath const& _rAccessor, const RequestOptions& _aOptions); - - void SAL_CALL dispose() throw(); - public: - void setDefaultLocale( com::sun::star::lang::Locale const & aLocale ); - - RequestOptions const& getDefaultOptions() const {return m_aDefaultOptions;} - uno::Reference< script::XTypeConverter > getTypeConverter() const {return m_xTypeConverter;} - TreeManager * getNotifier() SAL_THROW(()); - uno::XInterface* getProviderInstance(); - - // actual factory methods - // the returned object (if any) has to be acquired once) - configapi::NodeElement* buildReadAccess( rtl::OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception)); - // the returned object (if any) has to be acquired once) - configapi::NodeElement* buildUpdateAccess(rtl::OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception)); - // factory methods - uno::Reference<uno::XInterface> createReadAccess( uno::Sequence<uno::Any> const& aArgs) SAL_THROW((com::sun::star::uno::Exception)); - uno::Reference<uno::XInterface> createUpdateAccess( uno::Sequence<uno::Any> const& aArgs) SAL_THROW((com::sun::star::uno::Exception)); - - private: - bool initSession(const ContextReader& _rSettings); - private: - void implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile); - void implInitFromProfile(sharable::Node * aProfile); - - void initFromSettings(const ContextReader& _rSettings, bool& rNeedProfile); - void initFromProfile(sharable::Node * aProfile); - }; -} // namespace configmgr - -#endif // CONFIGMGR_API_PROVIDERIMPL_HXX_ - - diff --git a/configmgr/source/api2/setaccess.cxx b/configmgr/source/api2/setaccess.cxx deleted file mode 100644 index 8c964a140f8b..000000000000 --- a/configmgr/source/api2/setaccess.cxx +++ /dev/null @@ -1,185 +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 "setaccess.hxx" -#include "accessimpl.hxx" -#include "apinotifierimpl.hxx" -#include "apinodeaccess.hxx" - -namespace configmgr -{ - -// XHierarchicalName -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString SAL_CALL BasicSetAccess::getHierarchicalName( ) throw(uno::RuntimeException) -{ - return configapi::implGetHierarchicalName( getNode() ); -} - -//------------------------------------------------------------------------------------------------------------------ -rtl::OUString SAL_CALL BasicSetAccess::composeHierarchicalName( const rtl::OUString& sRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException) -{ - return configapi::implComposeHierarchicalName( getNode(), sRelativeName ); -} - -//------------------------------------------------------------------------------------------------------------------ - -// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? ) -//----------------------------------------------------------------------------------- - -uno::Type SAL_CALL BasicSetAccess::getElementType( ) throw(uno::RuntimeException) -{ - return configapi::implGetElementType( getNode() ); -} - -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL BasicSetAccess::hasElements( ) throw(uno::RuntimeException) -{ - return configapi::implHasElements( getNode() ); -} - -// XExactName -//----------------------------------------------------------------------------------- - -rtl::OUString SAL_CALL BasicSetAccess::getExactName( const rtl::OUString& rApproximateName ) throw(uno::RuntimeException) -{ - return configapi::implGetExactName( getNode(), rApproximateName); -} - -// XProperty -//----------------------------------------------------------------------------------- - -css::beans::Property SAL_CALL BasicSetAccess::getAsProperty( ) throw(uno::RuntimeException) -{ - return configapi::implGetAsProperty( getNode() ); -} - -// XPropertySetInfo -//----------------------------------------------------------------------------------- - -uno::Sequence< css::beans::Property > SAL_CALL BasicSetAccess::getProperties( ) throw (uno::RuntimeException) -{ - return configapi::implGetProperties( getNode() ); -} - -css::beans::Property SAL_CALL BasicSetAccess::getPropertyByName( const rtl::OUString& aName ) - throw (css::beans::UnknownPropertyException, uno::RuntimeException) -{ - return configapi::implGetPropertyByName( getNode(), aName ); -} - -sal_Bool SAL_CALL BasicSetAccess::hasPropertyByName( const rtl::OUString& name ) throw (uno::RuntimeException) -{ - return configapi::implHasPropertyByName( getNode(), name ); -} - - -// XNameAccess -//----------------------------------------------------------------------------------- - -sal_Bool SAL_CALL BasicSetAccess::hasByName( const rtl::OUString& sName ) throw(uno::RuntimeException) -{ - return configapi::implHasByName( getNode(), sName); -} - -//----------------------------------------------------------------------------------- -uno::Any SAL_CALL BasicSetAccess::getByName( const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetByName( getNode(), sName ); -} - -//----------------------------------------------------------------------------------- -uno::Sequence< rtl::OUString > SAL_CALL BasicSetAccess::getElementNames( ) throw( uno::RuntimeException) -{ - return configapi::implGetElementNames( getNode() ); -} - -// XHierarchicalNameAccess -//----------------------------------------------------------------------------------- -sal_Bool SAL_CALL BasicSetAccess::hasByHierarchicalName( const rtl::OUString& sName ) throw(uno::RuntimeException) -{ - return configapi::implHasByHierarchicalName( getNode(), sName); -} - -//----------------------------------------------------------------------------------- -uno::Any SAL_CALL BasicSetAccess::getByHierarchicalName( const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, uno::RuntimeException) -{ - return configapi::implGetByHierarchicalName( getNode(), sName ); -} - - -// XContainer -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSetAccess::addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implAddListener( getNode(), xListener ); -} - -void SAL_CALL BasicSetAccess::removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException) -{ - configapi::implRemoveListener( getNode(), xListener ); -} - -//----------------------------------------------------------------------------------- -// Set-specific interfaces -//----------------------------------------------------------------------------------- - -// XTemplateContainer -//----------------------------------------------------------------------------------- -rtl::OUString SAL_CALL BasicSetAccess::getElementTemplateName( ) - throw(uno::RuntimeException) -{ - return configapi::implGetElementTemplateName( getNode() ); -} - -// XStringEscape -//----------------------------------------------------------------------------------- -rtl::OUString SAL_CALL BasicSetAccess::escapeString( const rtl::OUString& aString ) - throw(css::lang::IllegalArgumentException, uno::RuntimeException) -{ - return aString; -} - -rtl::OUString SAL_CALL BasicSetAccess::unescapeString( const rtl::OUString& aEscapedString ) - throw(css::lang::IllegalArgumentException, uno::RuntimeException) -{ - return aEscapedString; -} - -//----------------------------------------------------------------------------------- -} // namespace configmgr - - diff --git a/configmgr/source/api2/setaccess.hxx b/configmgr/source/api2/setaccess.hxx deleted file mode 100644 index ba4a961cca05..000000000000 --- a/configmgr/source/api2/setaccess.hxx +++ /dev/null @@ -1,167 +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_API_SETACCESS_HXX_ -#define CONFIGMGR_API_SETACCESS_HXX_ - -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/configuration/XTemplateContainer.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/beans/XProperty.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/util/XStringEscape.hpp> -#include <cppuhelper/implbase9.hxx> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - namespace configapi { class NodeSetInfoAccess; } - - /** implements the (read-only) interfaces supported by a set node - within the configuration tree. - <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p> - */ - class BasicSetAccess - : public ::cppu::ImplHelper9 - < css::container::XNameAccess - , css::container::XHierarchicalName - , css::container::XHierarchicalNameAccess - , css::container::XContainer - , css::beans::XExactName - , css::beans::XProperty - , css::beans::XPropertySetInfo - , css::configuration::XTemplateContainer - , css::util::XStringEscape - > - { - protected: - // Destructors - virtual ~BasicSetAccess() {} - - public: - // Interface methods - // XHierarchicalName - virtual rtl::OUString SAL_CALL - getHierarchicalName( ) - throw(uno::RuntimeException); - - virtual rtl::OUString SAL_CALL - composeHierarchicalName( const rtl::OUString& aRelativeName ) - throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, - uno::RuntimeException); - - // XElementAccess, base class of XNameAccess - virtual uno::Type SAL_CALL - getElementType( ) - throw(uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasElements( ) - throw(uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL - getByName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, - uno::RuntimeException); - - virtual uno::Sequence< rtl::OUString > SAL_CALL - getElementNames( ) - throw( uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasByName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XHierarchicalNameAccess - virtual uno::Any SAL_CALL - getByHierarchicalName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasByHierarchicalName( const rtl::OUString& aName ) - throw(uno::RuntimeException); - - // XContainer - virtual void SAL_CALL - addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - virtual void SAL_CALL - removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener ) - throw(uno::RuntimeException); - - // XExactName - virtual rtl::OUString SAL_CALL - getExactName( const rtl::OUString& aApproximateName ) - throw(uno::RuntimeException); - - // XProperty - virtual css::beans::Property SAL_CALL - getAsProperty( ) - throw(uno::RuntimeException); - - // XPropertySetInfo - virtual uno::Sequence< css::beans::Property > SAL_CALL - getProperties( ) - throw (uno::RuntimeException); - - virtual css::beans::Property SAL_CALL - getPropertyByName( const rtl::OUString& aName ) - throw (css::beans::UnknownPropertyException, uno::RuntimeException); - - virtual sal_Bool SAL_CALL - hasPropertyByName( const rtl::OUString& name ) - throw (uno::RuntimeException); - - // XTemplateContainer - rtl::OUString SAL_CALL - getElementTemplateName( ) - throw(uno::RuntimeException); - - // XStringEscape - rtl::OUString SAL_CALL - escapeString( const rtl::OUString& aString ) - throw(css::lang::IllegalArgumentException, uno::RuntimeException); - - rtl::OUString SAL_CALL - unescapeString( const rtl::OUString& aEscapedString ) - throw(css::lang::IllegalArgumentException, uno::RuntimeException); - - protected: - virtual configapi::NodeSetInfoAccess& getNode() = 0; - }; - -} -#endif // CONFIGMGR_API_SETACCESS_HXX_ - - diff --git a/configmgr/source/api2/setobjects.cxx b/configmgr/source/api2/setobjects.cxx deleted file mode 100644 index b32c1d108cdb..000000000000 --- a/configmgr/source/api2/setobjects.cxx +++ /dev/null @@ -1,547 +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 "setobjects.hxx" -#include "comphelper/sequence.hxx" - -//........................................................................ -namespace configmgr -{ - -//========================================================================== -//= OInnerSetInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL OInnerSetInfo::acquire( ) throw () -{ - BasicInnerElement::acquire(); -} - -void SAL_CALL OInnerSetInfo::release( ) throw () -{ - BasicInnerElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OInnerSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicInnerElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSetAccess::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OInnerSetInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicSetAccess::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OInnerSetInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicInnerElement::getImplementationId(); -} - - -configapi::NodeAccess& OInnerSetInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OInnerSetInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::InnerElement& OInnerSetInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OInnerTreeSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OInnerTreeSetUpdate::acquire( ) throw () -{ - BasicInnerElement::acquire(); -} - -void SAL_CALL OInnerTreeSetUpdate::release( ) throw () -{ - BasicInnerElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OInnerTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicInnerElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OInnerTreeSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OInnerTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicInnerElement::getImplementationId(); -} - - -configapi::NodeAccess& OInnerTreeSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OInnerTreeSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeTreeSetAccess* OInnerTreeSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::InnerElement& OInnerTreeSetUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OInnerValueSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OInnerValueSetUpdate::acquire( ) throw () -{ - BasicInnerElement::acquire(); -} - -void SAL_CALL OInnerValueSetUpdate::release( ) throw () -{ - BasicInnerElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OInnerValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicInnerElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicValueSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OInnerValueSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicValueSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OInnerValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicInnerElement::getImplementationId(); -} - - -configapi::NodeAccess& OInnerValueSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OInnerValueSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeValueSetAccess* OInnerValueSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::InnerElement& OInnerValueSetUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OSetElementSetInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL OSetElementSetInfo::acquire( ) throw () -{ - BasicSetElement::acquire(); -} - -void SAL_CALL OSetElementSetInfo::release( ) throw () -{ - BasicSetElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OSetElementSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSetAccess::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OSetElementSetInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicSetElement::getTypes(),BasicSetAccess::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OSetElementSetInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicSetElement::getImplementationId(); -} - - -configapi::NodeAccess& OSetElementSetInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OSetElementSetInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::SetElement& OSetElementSetInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OSetElementTreeSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OSetElementTreeSetUpdate::acquire( ) throw () -{ - BasicSetElement::acquire(); -} - -void SAL_CALL OSetElementTreeSetUpdate::release( ) throw () -{ - BasicSetElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OSetElementTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OSetElementTreeSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicSetElement::getTypes(),BasicSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OSetElementTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicSetElement::getImplementationId(); -} - - -configapi::NodeAccess& OSetElementTreeSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OSetElementTreeSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeTreeSetAccess* OSetElementTreeSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::SetElement& OSetElementTreeSetUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= OSetElementValueSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL OSetElementValueSetUpdate::acquire( ) throw () -{ - BasicSetElement::acquire(); -} - -void SAL_CALL OSetElementValueSetUpdate::release( ) throw () -{ - BasicSetElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL OSetElementValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicValueSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL OSetElementValueSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicSetElement::getTypes(),BasicValueSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL OSetElementValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicSetElement::getImplementationId(); -} - - -configapi::NodeAccess& OSetElementValueSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& OSetElementValueSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeValueSetAccess* OSetElementValueSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::SetElement& OSetElementValueSetUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= ORootElementSetInfo -//========================================================================== - -// XInterface refcounting -void SAL_CALL ORootElementSetInfo::acquire( ) throw () -{ - BasicRootElement::acquire(); -} - -void SAL_CALL ORootElementSetInfo::release( ) throw () -{ - BasicRootElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL ORootElementSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicRootElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSetAccess::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL ORootElementSetInfo::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicRootElement::getTypes(),BasicSetAccess::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL ORootElementSetInfo::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicRootElement::getImplementationId(); -} - - -configapi::NodeAccess& ORootElementSetInfo::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& ORootElementSetInfo::getNode() -{ - return m_aAccessElement; -} - -configapi::RootElement& ORootElementSetInfo::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= ORootElementTreeSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL ORootElementTreeSetUpdate::acquire( ) throw () -{ - BasicUpdateElement::acquire(); -} - -void SAL_CALL ORootElementTreeSetUpdate::release( ) throw () -{ - BasicUpdateElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL ORootElementTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicUpdateElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL ORootElementTreeSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL ORootElementTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicUpdateElement::getImplementationId(); -} - - -configapi::NodeAccess& ORootElementTreeSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& ORootElementTreeSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeTreeSetAccess* ORootElementTreeSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::UpdateRootElement& ORootElementTreeSetUpdate::getElementClass() -{ - return m_aAccessElement; -} - -//========================================================================== -//= ORootElementValueSetUpdate -//========================================================================== - -// XInterface refcounting -void SAL_CALL ORootElementValueSetUpdate::acquire( ) throw () -{ - BasicUpdateElement::acquire(); -} - -void SAL_CALL ORootElementValueSetUpdate::release( ) throw () -{ - BasicUpdateElement::release(); -} - -// XInterface joining -uno::Any SAL_CALL ORootElementValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicUpdateElement::queryInterface(rType); - - if (!aRet.hasValue()) - aRet = BasicValueSet::queryInterface(rType); - - return aRet; -} - -// XTypeProvider joining -uno::Sequence< uno::Type > SAL_CALL ORootElementValueSetUpdate::getTypes( ) throw (uno::RuntimeException ) -{ - return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicValueSet::getTypes() ); -} - -uno::Sequence< sal_Int8 > SAL_CALL ORootElementValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException ) -{ - return BasicUpdateElement::getImplementationId(); -} - - -configapi::NodeAccess& ORootElementValueSetUpdate::getNodeAccess() -{ - return m_aAccessElement; -} - -configapi::NodeSetInfoAccess& ORootElementValueSetUpdate::getNode() -{ - return m_aAccessElement; -} - -configapi::NodeValueSetAccess* ORootElementValueSetUpdate::maybeGetUpdateAccess() -{ - return &m_aAccessElement; -} - -configapi::UpdateRootElement& ORootElementValueSetUpdate::getElementClass() -{ - return m_aAccessElement; -} -//........................................................................ -} // namespace configmgr -//........................................................................ - diff --git a/configmgr/source/api2/setobjects.hxx b/configmgr/source/api2/setobjects.hxx deleted file mode 100644 index 4f1ee0861c5a..000000000000 --- a/configmgr/source/api2/setobjects.hxx +++ /dev/null @@ -1,358 +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_API_SETOBJECTS_HXX_ -#define CONFIGMGR_API_SETOBJECTS_HXX_ - -#include "setaccess.hxx" -#include "setupdate.hxx" -#include "elementaccess.hxx" - -#include "apiaccessobj.hxx" - -//........................................................................ -namespace configmgr -{ -//........................................................................ - -//========================================================================== -//= Inner Set Instances -//========================================================================== - -/** read-only access class for configuration nodes which are inner nodes and dynamic sets -*/ - class OInnerSetInfo - : public BasicInnerElement - , public BasicSetAccess - { - public: - // Construction/Destruction - OInnerSetInfo(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode) - : m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::InnerElement& getElementClass(); - private: - configapi::OInnerElement<configapi::NodeSetInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are inner nodes and dynamic sets of complex types (trees) -*/ - class OInnerTreeSetUpdate - : public BasicInnerElement - , public BasicSet - { - public: - // Construction/Destruction - OInnerTreeSetUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode) - : m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess(); - virtual configapi::InnerElement& getElementClass(); - private: - configapi::OInnerElement<configapi::NodeTreeSetAccess> m_aAccessElement; - }; - - -/** update access class for configuration nodes which are inner nodes and dynamic sets of simple types (values) -*/ - class OInnerValueSetUpdate - : public BasicInnerElement - , public BasicValueSet - { - public: - // Construction/Destruction - OInnerValueSetUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode) - : m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess(); - virtual configapi::InnerElement& getElementClass(); - private: - configapi::OInnerElement<configapi::NodeValueSetAccess> m_aAccessElement; - }; - -//========================================================================== -//= Set Element Set Instances -//========================================================================== - -/** read-only access class for configuration nodes which are set elements and dynamic sets -*/ - class OSetElementSetInfo - : public BasicSetElement - , public BasicSetAccess - { - public: - // Construction/Destruction - OSetElementSetInfo(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0) - : m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::SetElement& getElementClass(); - private: - configapi::OSetElement<configapi::NodeSetInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are set elements and dynamic sets of complex types (trees) -*/ - class OSetElementTreeSetUpdate - : public BasicSetElement - , public BasicSet - { - public: - // Construction/Destruction - OSetElementTreeSetUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0) - : m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess(); - virtual configapi::SetElement& getElementClass(); - private: - configapi::OSetElement<configapi::NodeTreeSetAccess> m_aAccessElement; - }; - - -/** update access class for configuration nodes which are set elements and dynamic sets of simple types (values) -*/ - class OSetElementValueSetUpdate - : public BasicSetElement - , public BasicValueSet - { - public: - // Construction/Destruction - OSetElementValueSetUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0) - : m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess(); - virtual configapi::SetElement& getElementClass(); - private: - configapi::OSetElement<configapi::NodeValueSetAccess> m_aAccessElement; - }; - -//========================================================================== -//= Root Element Set Instances -//========================================================================== - -/** read-only access class for configuration nodes which are root nodes and dynamic sets -*/ - class ORootElementSetInfo - : public BasicRootElement - , public BasicSetAccess - { - public: - // Construction/Destruction - ORootElementSetInfo(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree,_xOptions) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::RootElement& getElementClass(); - private: - configapi::OReadRootElement<configapi::NodeSetInfoAccess> m_aAccessElement; - }; - -/** updating access class for configuration nodes which are root nodes and dynamic sets of complex types (trees) -*/ - class ORootElementTreeSetUpdate - : public BasicUpdateElement - , public BasicSet - { - public: - // Construction/Destruction - ORootElementTreeSetUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess(); - virtual configapi::UpdateRootElement& getElementClass(); - private: - configapi::OUpdateRootElement<configapi::NodeTreeSetAccess> m_aAccessElement; - }; - - -/** update access class for configuration nodes which are root nodes and dynamic sets of simple types (values) -*/ - class ORootElementValueSetUpdate - : public BasicUpdateElement - , public BasicValueSet - { - public: - // Construction/Destruction - ORootElementValueSetUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions) - : m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree,_xOptions) - { - } - - // XInterface refcounting - void SAL_CALL acquire( ) throw (); - void SAL_CALL release( ) throw (); - - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ); - - // Base class implementation - virtual configapi::NodeAccess& getNodeAccess(); - virtual configapi::NodeSetInfoAccess& getNode(); - virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess(); - virtual configapi::UpdateRootElement& getElementClass(); - private: - configapi::OUpdateRootElement<configapi::NodeValueSetAccess> m_aAccessElement; - }; - - -//........................................................................ -} // namespace configmgr -//........................................................................ - -#endif // CONFIGMGR_API_SETOBJECTS_HXX_ - - diff --git a/configmgr/source/api2/setupdate.cxx b/configmgr/source/api2/setupdate.cxx deleted file mode 100644 index 4a2d5f0071d0..000000000000 --- a/configmgr/source/api2/setupdate.cxx +++ /dev/null @@ -1,241 +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 "setupdate.hxx" -#include "accessimpl.hxx" -#include "updateimpl.hxx" -#include "apinodeupdate.hxx" -#include "apitypes.hxx" -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> - -namespace configmgr -{ -////////////////////////////////////////////////////////////////////////////////// -// classes BasicSet / BasicValueSet -////////////////////////////////////////////////////////////////////////////////// - -// XInterface joining -////////////////////////////////////////////////////////////////////////////////// -uno::Any SAL_CALL BasicSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetAccess::queryInterface( rType ); - if (!aRet.hasValue()) - { - aRet = cppu::queryInterface(rType - , static_cast< css::container::XNameContainer *>(this) - , static_cast< css::container::XNameReplace *>(this) - , static_cast< css::beans::XPropertyWithState *>(this) - , static_cast< css::lang::XSingleServiceFactory *>(this) - ); - } - return aRet; -} -//.............................................................................. - -uno::Any SAL_CALL BasicValueSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ) -{ - uno::Any aRet = BasicSetAccess::queryInterface( rType ); - if (!aRet.hasValue()) - { - aRet = cppu::queryInterface(rType - , static_cast< css::container::XNameContainer *>(this) - , static_cast< css::container::XNameReplace *>(this) - , static_cast< css::beans::XPropertyWithState *>(this) - ); - } - return aRet; -} - -// XTypeProvider joining -////////////////////////////////////////////////////////////////////////////////// -uno::Sequence< uno::Type > SAL_CALL BasicSet::getTypes( ) throw (uno::RuntimeException ) -{ - /*static ?*/ - cppu::OTypeCollection aTypes( - configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)), - configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), - configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)), - configapi::getReferenceType(static_cast< css::lang::XSingleServiceFactory *>(this)), - BasicSetAccess::getTypes()); - - return aTypes.getTypes(); -} -//.............................................................................. - -uno::Sequence< uno::Type > SAL_CALL BasicValueSet::getTypes( ) throw (uno::RuntimeException ) -{ - /*static ?*/ - cppu::OTypeCollection aTypes( - configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)), - configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)), - configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)), - BasicSetAccess::getTypes()); - - return aTypes.getTypes(); -} - -//uno::Sequence< sal_Int8 > SAL_CALL BasicSet::getImplementationId( ) throw (uno::RuntimeException ) = 0; -//uno::Sequence< sal_Int8 > SAL_CALL BasicValueSet::getImplementationId( ) throw (uno::RuntimeException ) = 0; - -// safe write access -////////////////////////////////////////////////////////////////////////////////// -configapi::NodeTreeSetAccess& BasicSet::getSetNode() -{ - configapi::NodeTreeSetAccess* pAccess = maybeGetUpdateAccess(); - OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException"); - - if (!pAccess) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")), - static_cast< css::container::XNameReplace * >(this) - ); - } - return *pAccess; -} - -configapi::NodeValueSetAccess& BasicValueSet::getSetNode() -{ - configapi::NodeValueSetAccess* pAccess = maybeGetUpdateAccess(); - OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException"); - - if (!pAccess) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")), - static_cast< css::container::XNameReplace* >(this) - ); - } - return *pAccess; -} - -// New Interface methods -// XNameReplace -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implReplaceByName( getSetNode(), rName, rElement ); -} -//.............................................................................. - -void SAL_CALL BasicValueSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implReplaceByName( getSetNode(), rName, rElement ); -} - -// XNameContainer -////////////////////////////////////////////////////////////////////////////////// -void SAL_CALL BasicSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implInsertByName( getSetNode(), rName, rElement ); -} -//.............................................................................. - -void SAL_CALL BasicValueSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implInsertByName( getSetNode(), rName, rElement ); -} - -//---------------------------------------------------------------------------------- -void SAL_CALL BasicSet::removeByName( const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implRemoveByName( getSetNode(), rName ); -} -//.............................................................................. - -void SAL_CALL BasicValueSet::removeByName( const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implRemoveByName( getSetNode(), rName ); -} - -// XPropertyWithState -////////////////////////////////////////////////////////////////////////////////// - -css::beans::PropertyState SAL_CALL BasicSet::getStateAsProperty() throw (uno::RuntimeException) -{ - return configapi::implGetStateAsProperty( getSetNode() ); -} -//.............................................................................. - -css::beans::PropertyState SAL_CALL BasicValueSet::getStateAsProperty() throw (uno::RuntimeException) -{ - return configapi::implGetStateAsProperty( getSetNode() ); -} -//----------------------------------------------------------------------------------- - -void SAL_CALL BasicSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetToDefaultAsProperty( getSetNode() ); -} -//.............................................................................. - -void SAL_CALL BasicValueSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - configapi::implSetToDefaultAsProperty( getSetNode() ); -} -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > SAL_CALL BasicSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetDefaultAsProperty( getSetNode() ); -} -//.............................................................................. - -uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - return configapi::implGetDefaultAsProperty( getSetNode() ); -} - -// XSingleServiceFactory (not for ValueSet) -////////////////////////////////////////////////////////////////////////////////// -uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstance( ) - throw(uno::Exception, uno::RuntimeException) -{ - return configapi::implCreateElement( getSetNode() ); -} - -//---------------------------------------------------------------------------------- -uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) - throw(uno::Exception, uno::RuntimeException) -{ - return configapi::implCreateElement( getSetNode(), aArguments ); -} - -//----------------------------------------------------------------------------------- -} // namespace configmgr - - diff --git a/configmgr/source/api2/setupdate.hxx b/configmgr/source/api2/setupdate.hxx deleted file mode 100644 index 33656c49b08c..000000000000 --- a/configmgr/source/api2/setupdate.hxx +++ /dev/null @@ -1,208 +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_API_SETUPDATE_HXX_ -#define CONFIGMGR_API_SETUPDATE_HXX_ - -#include "setaccess.hxx" -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/beans/XPropertyWithState.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -//........................................................................ -namespace configmgr -{ -//........................................................................ - namespace configapi { class NodeTreeSetAccess; class NodeValueSetAccess; } - -//========================================================================== -//= BasicSet -//========================================================================== - -/** base class for configuration nodes which are dynamic sets of complex types (trees) -*/ - class BasicSet - : public BasicSetAccess - , public css::container::XNameContainer - , public css::beans::XPropertyWithState - , public css::lang::XSingleServiceFactory - { - protected: - // Destructors - virtual ~BasicSet() {} - - public: - // Base class Interface methods - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0; - - // XElementAccess forwarding - virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException) - { return BasicSetAccess::getElementType(); } - - virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException) - { return BasicSetAccess::hasElements(); } - - // XNameAccess forwarding - virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) - { return BasicSetAccess::getByName(aName); } - - virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException) - { return BasicSetAccess::getElementNames(); } - - virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException) - { return BasicSetAccess::hasByName(aName); } - - // New Interface methods - // XNameReplace - virtual void SAL_CALL - replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XNameContainer - virtual void SAL_CALL - insertByName( const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException); - - virtual void SAL_CALL - removeByName( const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XPropertyWithState - virtual css::beans::PropertyState SAL_CALL - getStateAsProperty( ) - throw (uno::RuntimeException); - - virtual void SAL_CALL - setToDefaultAsProperty( ) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - virtual uno::Reference< uno::XInterface > SAL_CALL - getDefaultAsProperty( ) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - // XSingleServiceFactory - virtual uno::Reference< uno::XInterface > SAL_CALL - createInstance( ) - throw(uno::Exception, uno::RuntimeException); - - virtual uno::Reference< uno::XInterface > SAL_CALL - createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) - throw(uno::Exception, uno::RuntimeException); - - protected: - configapi::NodeTreeSetAccess& getSetNode(); - virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess() = 0; - }; - -//========================================================================== -//= BasicValueSet -//========================================================================== - -/** class for configuration nodes which are dynamic sets of simple types (values) -*/ - class BasicValueSet - : public BasicSetAccess - , public css::beans::XPropertyWithState - , public css::container::XNameContainer - { - protected: - // Destructors - virtual ~BasicValueSet() {} - - public: - // Base class Interface methods - // XInterface joining - uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException ); - - // XTypeProvider joining - uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException ); - uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0; - - // XElementAccess forwarding - virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException) - { return BasicSetAccess::getElementType(); } - - virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException) - { return BasicSetAccess::hasElements(); } - - // XNameAccess forwarding - virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException) - { return BasicSetAccess::getByName(aName); } - - virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException) - { return BasicSetAccess::getElementNames(); } - - virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException) - { return BasicSetAccess::hasByName(aName); } - - // New Interface methods - // XNameReplace - virtual void SAL_CALL - replaceByName( const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XNameContainer - virtual void SAL_CALL - insertByName( const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException); - - virtual void SAL_CALL - removeByName( const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XPropertyWithState - virtual css::beans::PropertyState SAL_CALL - getStateAsProperty( ) - throw (uno::RuntimeException); - - virtual void SAL_CALL - setToDefaultAsProperty( ) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - virtual uno::Reference< uno::XInterface > SAL_CALL - getDefaultAsProperty( ) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - protected: - configapi::NodeValueSetAccess& getSetNode(); - virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess() = 0; - }; - -//........................................................................ -} // namespace configmgr -//........................................................................ - -#endif // CONFIGMGR_API_VALUESETACCESS_HXX_ - - diff --git a/configmgr/source/api2/translatechanges.cxx b/configmgr/source/api2/translatechanges.cxx deleted file mode 100644 index 520bd04b36d8..000000000000 --- a/configmgr/source/api2/translatechanges.cxx +++ /dev/null @@ -1,283 +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 "translatechanges.hxx" -#include "noderef.hxx" -#include "nodechange.hxx" -#include "nodechangeinfo.hxx" -#include "apifactory.hxx" - -namespace configmgr -{ -// --------------------------------------------------------------------------------------------------- - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - namespace util = css::util; - namespace beans = css::beans; - namespace container = css::container; -// --------------------------------------------------------------------------------------------------- - - namespace configuration - { - class NodeChange; - class NodeChanges; - class NodeRef; - class NodeID; - } -// --------------------------------------------------------------------------------------------------- - - namespace configapi - { -// --------------------------------------------------------------------------------------------------- - //interpreting NodeChanges -// resolve the relative path from a given base to the changed node -bool resolveChangeLocation(configuration::RelativePath& aPath, configuration::NodeChangeLocation const& aChange, rtl::Reference< configuration::Tree > const& aBaseTree, configuration::NodeRef const& aBaseNode) -{ - OSL_ENSURE(aChange.isValidLocation(), "Trying to resolve against change location that wasn't set up properly"); - - namespace Path = configuration::Path; - - rtl::Reference< configuration::Tree > aChangeBaseTree = aChange.getBaseTree(); - - configuration::AbsolutePath aOuterBasePath = aBaseTree->getAbsolutePath(aBaseNode); - configuration::AbsolutePath aChangeBasePath = aChangeBaseTree->getAbsolutePath(aChange.getBaseNode()); - - std::vector<configuration::Path::Component>::const_reverse_iterator aChangeIt = aChangeBasePath.begin(), aChangeEnd = aChangeBasePath.end(); - std::vector<configuration::Path::Component>::const_reverse_iterator aOuterIt = aOuterBasePath.begin(), aOuterEnd = aOuterBasePath.end(); - - // First by resolve the base node pathes - while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd) - { - if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch - ++aOuterIt; - ++aChangeIt; - } - - // Next consider the stored accessor - if (aChangeIt != aChangeEnd) // stepping outward - prepend - { - Path::Rep aRemaining(aChangeIt, aChangeEnd); - - aPath = configuration::RelativePath(aRemaining).compose(aChange.getAccessor()); - } - else if (aOuterIt == aOuterEnd) // exact match outside - { - aPath = aChange.getAccessor(); - } - else //(aChangeIt == aChangeEnd) but outer left - { - configuration::RelativePath aAccessor = aChange.getAccessor(); - aChangeIt = aAccessor.begin(); - aChangeEnd = aAccessor.end(); - - // resolve the outer path against the change accessor - while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd) - { - if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch - ++aOuterIt; - ++aChangeIt; - } - - if (aOuterIt == aOuterEnd) - { - Path::Rep aRemaining(aChangeIt, aChangeEnd); - - aPath = configuration::RelativePath( aRemaining ); - } - } - - return (aOuterIt == aOuterEnd); // resolved completely and assigned ?? - -} - -// --------------------------------------------------------------------------------------------------- -// change path and base settings to start from the given base -bool rebaseChange(configuration::NodeChangeLocation& aChange, rtl::Reference< configuration::Tree > const& _aBaseTreeRef) -{ - return rebaseChange(aChange,_aBaseTreeRef,_aBaseTreeRef->getRootNode()); -} -bool rebaseChange(configuration::NodeChangeLocation& aChange, rtl::Reference< configuration::Tree > const& _aBaseTreeRef, configuration::NodeRef const& aBaseNode) -{ - OSL_ENSURE(aChange.isValidLocation(), "Trying to rebase change location that wasn't set up properly"); - - rtl::Reference< configuration::Tree > aBaseTree(_aBaseTreeRef); - - configuration::RelativePath aNewPath; - if (resolveChangeLocation(aNewPath,aChange,aBaseTree,aBaseNode)) - { - aChange.setBase( aBaseTree, aBaseNode); - aChange.setAccessor( aNewPath ); - return true; - } - else - return false; -} -// --------------------------------------------------------------------------------------------------- -// resolve non-uno elements to Uno Objects -bool resolveUnoObjects(UnoChange& aUnoChange, configuration::NodeChangeData const& aChange, - Factory& rFactory) -{ - if (aChange.isSetChange()) - { - //Check we have ElementTree - if ((aChange.element.newValue == NULL) && - (aChange.element.oldValue == NULL)) - { - if( ( aChange.unoData.newValue.getValue()!=NULL) || - ( aChange.unoData.newValue.getValue()!=NULL)) - { - return true; - } - else return false; - } - - //Check if complex or simple type - rtl::Reference< configuration::Tree > aTree = aChange.isRemoveSetChange()? - aChange.getOldElementTree(): - aChange.getNewElementTree(); - - configuration::NodeRef aNodeRef = aTree->getRootNode(); - - if (configuration::isStructuralNode(aTree, aNodeRef)) - { - uno::Reference<uno::XInterface> aNewUnoObject = rFactory.findUnoElement(aChange.getNewElementNodeID()); - uno::Reference<uno::XInterface> aOldUnoObject = rFactory.findUnoElement(aChange.getOldElementNodeID()); - - bool bFound = aNewUnoObject.is() || aOldUnoObject.is(); - aUnoChange.newValue <<= aNewUnoObject; - aUnoChange.oldValue <<= aOldUnoObject; - return bFound; - } - else - { - aUnoChange.newValue = configuration::getSimpleElementValue(aTree, aNodeRef); - - if (aChange.isReplaceSetChange() ) - { - rtl::Reference< configuration::Tree > aOldTree = aChange.getOldElementTree(); - - aNodeRef = aOldTree->getRootNode(); - OSL_ENSURE(!configuration::isStructuralNode(aOldTree, aNodeRef), "resolveUnoObject types mismatch"); - aUnoChange.oldValue = configuration::getSimpleElementValue(aOldTree, aNodeRef); - } - bool bFound = aUnoChange.newValue.hasValue() || aUnoChange.oldValue.hasValue(); - return bFound; - } - } - else if (aChange.isValueChange()) - { - aUnoChange.newValue = aChange.unoData.newValue; - aUnoChange.oldValue = aChange.unoData.oldValue; - return true; - } - else - { - return false; - } -} -// --------------------------------------------------------------------------------------------------- -// resolve non-uno elements to Uno Objects inplace -bool resolveToUno(configuration::NodeChangeData& aChange, Factory& rFactory) -{ - struct UnoChange aUnoChange; - if (resolveUnoObjects(aUnoChange,aChange, rFactory)) - { - aChange.unoData.newValue = aUnoChange.newValue; - aChange.unoData.oldValue = aUnoChange.oldValue; - return true; - } - else - return false; -} -// --------------------------------------------------------------------------------------------------- - -/// fill a change info from a NodeChangeInfo -void fillChange(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo, rtl::Reference< configuration::Tree > const& aBaseTree, Factory& rFactory) -{ - fillChange(rChange,aInfo,aBaseTree,aBaseTree->getRootNode(),rFactory); -} -/// fill a change info from a NodeChangeInfo -void fillChange(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo, rtl::Reference< configuration::Tree > const& aBaseTree, configuration::NodeRef const& aBaseNode, Factory& rFactory) -{ - configuration::RelativePath aRelativePath; - if (!resolveChangeLocation(aRelativePath, aInfo.location, aBaseTree, aBaseNode)) - OSL_ENSURE(false, "WARNING: Change is not part of the given Tree"); - - UnoChange aUnoChange; - - if (!resolveUnoObjects(aUnoChange, aInfo.change, rFactory)) - OSL_ENSURE(false, "WARNING: Cannot find out old/new UNO objects involved in change"); - - rChange.Accessor <<= aRelativePath.toString(); - rChange.Element = aUnoChange.newValue; - rChange.ReplacedElement = aUnoChange.oldValue; -} -// --------------------------------------------------------------------------------------------------- -/// fill a change info from a NodeChangeInfo (base,path and uno objects are assumed to be resolved already) -void fillChangeFromResolved(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo) -{ - rChange.Accessor <<= aInfo.location.getAccessor().toString(); - rChange.Element = aInfo.change.unoData.newValue; - rChange.ReplacedElement = aInfo.change.unoData.oldValue; -} -// --------------------------------------------------------------------------------------------------- -/// fill a event from a NodeChangeInfo (uno objects are assumed to be resolved already) -bool fillEventDataFromResolved(container::ContainerEvent& rEvent, configuration::NodeChangeInformation const& aInfo) -{ - rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().getName(); - rEvent.Element = aInfo.change.unoData.newValue; - rEvent.ReplacedElement = aInfo.change.unoData.oldValue; - - return !aInfo.isEmptyChange(); -} -// --------------------------------------------------------------------------------------------------- -/// fill a event from a NodeChangeInfo(uno objects are assumed to be resolved already) -bool fillEventDataFromResolved(beans::PropertyChangeEvent& rEvent, configuration::NodeChangeInformation const& aInfo, bool bMore) -{ - if (!aInfo.isValueChange()) - return false; - - rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().getName(); - - rEvent.NewValue = aInfo.change.unoData.newValue; - rEvent.OldValue = aInfo.change.unoData.oldValue; - - rEvent.PropertyHandle = -1; - rEvent.Further = bMore; - - return !aInfo.isEmptyChange(); -} -// --------------------------------------------------------------------------------------------------- -// --------------------------------------------------------------------------------------------------- - } -// --------------------------------------------------------------------------------------------------- -} - diff --git a/configmgr/source/api2/translatechanges.hxx b/configmgr/source/api2/translatechanges.hxx deleted file mode 100644 index 3939333a5fbb..000000000000 --- a/configmgr/source/api2/translatechanges.hxx +++ /dev/null @@ -1,117 +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_API_TRANSLATECHANGES_HXX_ -#define CONFIGMGR_API_TRANSLATECHANGES_HXX_ - -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/beans/XVetoableChangeListener.hpp> -#include <com/sun/star/beans/XPropertiesChangeListener.hpp> -#include <com/sun/star/container/XContainerListener.hpp> -#include <com/sun/star/util/XChangesListener.hpp> -#include "rtl/ref.hxx" - -namespace configmgr -{ -// --------------------------------------------------------------------------------------------------- - namespace css = ::com::sun::star; - namespace uno = css::uno; - namespace lang = css::lang; - namespace util = css::util; - namespace beans = css::beans; - namespace container = css::container; -// --------------------------------------------------------------------------------------------------- - - namespace configuration - { - class NodeChangeInformation; - class NodeChangeData; - class NodeChangeLocation; - - //class NodeChange; - //class NodeChanges; - class Tree; - class NodeRef; - class NodeID; - class RelativePath; - } -// --------------------------------------------------------------------------------------------------- - - namespace configapi - { - class NotifierImpl; - class Factory; - - struct UnoChange { uno::Any newValue, oldValue; }; - - //interpreting NodeChanges - // resolve the relative path from a given base node to the changed node - bool resolveChangeLocation( configuration::RelativePath& aPath, - configuration::NodeChangeLocation const& aChange, - rtl::Reference< configuration::Tree > const& aBaseTree, - configuration::NodeRef const& aBaseNode); - - // change path and base settings to start from the given base tree (root) - bool rebaseChange( configuration::NodeChangeLocation& aChange, - rtl::Reference< configuration::Tree > const& _aBaseTreeRef); - // change path and base settings to start from the given base node - bool rebaseChange( configuration::NodeChangeLocation& aChange, - rtl::Reference< configuration::Tree > const& _aBaseTreeRef, - configuration::NodeRef const& aBaseNode); - // resolve non-uno elements to Uno Objects - bool resolveUnoObjects(UnoChange& aUnoChange, - configuration::NodeChangeData const& aChange, - Factory& rFactory); - // resolve non-uno elements to Uno Objects inplace - bool resolveToUno(configuration::NodeChangeData& aChange, - Factory& rFactory); - - // building events - - /// fill a change info from a NodeChangeInfo - void fillChange(util::ElementChange& rChange, - configuration::NodeChangeInformation const& aInfo, - rtl::Reference< configuration::Tree > const& aBaseTree, - Factory& rFactory); - /// fill a change info from a NodeChangeInfo - void fillChange(util::ElementChange& rChange, - configuration::NodeChangeInformation const& aInfo, - rtl::Reference< configuration::Tree > const& aBaseTree, - configuration::NodeRef const& aBaseNode, - Factory& rFactory); - /// fill a change info from a NodeChangeInfo (base,path and uno objects are assumed to be resolved already) - void fillChangeFromResolved(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo); - - /// fill a event from a NodeChangeInfo (uno objects are assumed to be resolved already) - bool fillEventDataFromResolved(container::ContainerEvent& rEvent, configuration::NodeChangeInformation const& aInfo); - /// fill a event from a NodeChangeInfo(uno objects are assumed to be resolved already) - returns false if this isn't a property change - bool fillEventDataFromResolved(beans::PropertyChangeEvent& rEvent, configuration::NodeChangeInformation const& aInfo, bool bMore); - } -// --------------------------------------------------------------------------------------------------- -} - -#endif // CONFIGMGR_API_TRANSLATECHANGES_HXX_ diff --git a/configmgr/source/api2/treeiterators.cxx b/configmgr/source/api2/treeiterators.cxx deleted file mode 100644 index a66c211d3b92..000000000000 --- a/configmgr/source/api2/treeiterators.cxx +++ /dev/null @@ -1,93 +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 "treeiterators.hxx" - -#include "apitypes.hxx" -#include "configpath.hxx" -#include "attributes.hxx" -#include "valueref.hxx" -#include "propertyinfohelper.hxx" - -// ....................................................................... -namespace configmgr -{ -// ....................................................................... - namespace configapi - { - // =================================================================== - // = CollectNodeNames - // =================================================================== - // ------------------------------------------------------------------- - CollectPropertyInfo::Result CollectNodeNames::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) - { - m_aList.push_back(aTree->getSimpleNodeName(aNode.getOffset())); - return CONTINUE; - } - - // ------------------------------------------------------------------- - CollectPropertyInfo::Result CollectNodeNames::handle(rtl::Reference< configuration::Tree > const&, configuration::ValueRef const& aNode) - { - m_aList.push_back(aNode.m_sNodeName); - return CONTINUE; - } - - // =================================================================== - // = CollectPropertyInfo - // =================================================================== - // ------------------------------------------------------------------- - CollectNodeNames::Result CollectPropertyInfo::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode) - { - rtl::OUString aName = aTree->getSimpleNodeName(aNode.getOffset()); - node::Attributes aAttributes = aTree->getAttributes(aNode); - uno::Type aApiType = getUnoInterfaceType(); - - m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree->hasNodeDefault(aNode)) ); - return CONTINUE; - } - - // ------------------------------------------------------------------- - CollectNodeNames::Result CollectPropertyInfo::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode) - { - rtl::OUString aName = aNode.m_sNodeName; - node::Attributes aAttributes = aTree->getAttributes(aNode); - uno::Type aApiType = aTree->getUnoType(aNode); - - m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree->hasNodeDefault(aNode)) ); - return CONTINUE; - } -// ....................................................................... - } // namespace configapi - -// ....................................................................... -} // namespace configmgr -// ....................................................................... - diff --git a/configmgr/source/api2/treeiterators.hxx b/configmgr/source/api2/treeiterators.hxx deleted file mode 100644 index 42aaaae7fcb8..000000000000 --- a/configmgr/source/api2/treeiterators.hxx +++ /dev/null @@ -1,85 +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_TREEITERATORS_HXX_ -#define CONFIGMGR_TREEITERATORS_HXX_ - -#include "tree.hxx" -#include <com/sun/star/beans/Property.hpp> -#include <rtl/ustring.hxx> - -#ifndef INCLUDED_VECTOR -#include <vector> -#define INCLUDED_VECTOR -#endif - -// ....................................................................... -namespace configmgr -{ -// ....................................................................... - namespace configapi - { - // =================================================================== - // = CollectNodeNames - // =================================================================== - class CollectNodeNames : public configuration::NodeVisitor - { - protected: - std::vector<rtl::OUString> m_aList; - - public: - CollectNodeNames() { } - - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); // NodeVisitor - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode); // NodeVisitor - - std::vector<rtl::OUString> const& list() const { return m_aList; } - }; - - // =================================================================== - // = CollectPropertyInfo - // =================================================================== - class CollectPropertyInfo : public configuration::NodeVisitor - { - protected: - std::vector<com::sun::star::beans::Property> m_aList; - - public: - CollectPropertyInfo() { } - - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); // NodeVisitor - virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode); // NodeVisitor - - std::vector<com::sun::star::beans::Property> const& list() const { return m_aList; } - }; - } -// ....................................................................... -} // namespace configmgr -// ....................................................................... - -#endif // _CONFIGMGR_TREEITERATORS_HXX_ - diff --git a/configmgr/source/api2/updateimpl.cxx b/configmgr/source/api2/updateimpl.cxx deleted file mode 100644 index 027a84a6ab4f..000000000000 --- a/configmgr/source/api2/updateimpl.cxx +++ /dev/null @@ -1,647 +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 "updateimpl.hxx" -#include "accessimpl.hxx" -#include "apinodeaccess.hxx" -#include "apinodeupdate.hxx" -#include "noderef.hxx" -#include "valueref.hxx" -#include "nodechange.hxx" -#include "configset.hxx" -#include "configgroup.hxx" -#include "confignotifier.hxx" -#include "broadcaster.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/beans/PropertyVetoException.hpp> -#include <osl/diagnose.h> - -namespace configmgr -{ - namespace configapi - { -//----------------------------------------------------------------------------------- - namespace lang = css::lang; - namespace util = css::util; - namespace container = css::container; - -// Interface methods -//----------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------- -// Update methods -//----------------------------------------------------------------------------------- - -// XNameReplace -//----------------------------------------------------------------------------------- -void implReplaceByName(NodeGroupAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement ) - throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeGroupAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode); - - configuration::ValueRef aChildValue( aTree->getChildValue(aNode, aChildName) ); - - if (!aChildValue.isValid()) - { - if (aTree->hasChildNode(aNode, aChildName)) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Node '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw lang::IllegalArgumentException( sMessage, xContext, 2 ); - } - else - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing child node not found by implementation"); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Value '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage, xContext ); - } - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue(aChildValue, rElement); - - if (aChange.test().isChange()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); -// lock.clearForBroadcast(); - - aSender.queryConstraints(aChange); - - aTree->integrate(aChange, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( e.message(), xContext ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - catch (css::beans::PropertyVetoException& ex) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Change was Vetoed: ") ); - throw lang::WrappedTargetException( sMessage += ex.Message, rNode.getUnoInstance(), uno::makeAny(ex) ); - } -} -//----------------------------------------------------------------------------------- - -void implReplaceByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement ) - throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) ); - - if (!aElement.is()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage, xContext ); - } - - rtl::Reference< configuration::ElementTree > aElementTree = configapi::extractElementTree(rNode.getFactory(), rElement, rNode.getElementInfo()); - if (!aElementTree.is()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Replacing object was not created from this set's template") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw lang::IllegalArgumentException( sMessage, xContext, 2 ); - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateReplaceElement( aElement, aElementTree ); - - if (aChange.test().isChange()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - attachSetElement(rNode, aElementTree); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( e.message(), xContext ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} -//----------------------------------------------------------------------------------- - -void implReplaceByName(NodeValueSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement ) - throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeValueSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) ); - - if (!aElement.is()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage, xContext ); - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateReplaceElement( aElement, rElement ); - - if (aChange.test().isChange()) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( e.message(), xContext ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } -} - -// XNameContainer -//----------------------------------------------------------------------------------- -void implInsertByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement) - throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - if( aTree->hasElement(aNode,aChildName) ) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::ElementExistException( sMessage, xContext ); - } - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - rtl::Reference< configuration::ElementTree > aElementTree = configapi::extractElementTree(rNode.getFactory(), rElement, rNode.getElementInfo()); - if (!aElementTree.is()) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set: ") ); - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Inserted object was not created from this set's template") ); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw lang::IllegalArgumentException( sMessage, xContext, 2 ); - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateInsertElement(aChildName, aElementTree); - - aChange.test(); // make sure old values are set up correctly - OSL_ENSURE(aChange.isChange(), "ERROR: Adding a node validated as empty change"); - - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - attachSetElement(rNode, aElementTree); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument( 1 ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - -} - -//----------------------------------------------------------------------------------- - -void implInsertByName(NodeValueSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement) - throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeValueSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - if( aTree->hasElement(aNode,aChildName) ) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::ElementExistException( sMessage, xContext ); - } - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - configuration::NodeChange aChange = lock.getNodeUpdater().validateInsertElement(aChildName, rElement); - - aChange.test(); // make sure old values are set up correctly - OSL_ENSURE(aChange.isChange(), "ERROR: Adding a node validated as empty change"); - - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument( 1 ); - } - catch (configuration::TypeMismatch& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::ConstraintViolation& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.illegalArgument(2); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - -} - -//----------------------------------------------------------------------------------- -void implRemoveByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) ); - - if (!aElement.is()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage, xContext ); - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateRemoveElement(aElement); - - aChange.test(); // make sure old values are set up correctly - OSL_ENSURE(aChange.isChange(), "ERROR: Removing a node validated as empty change"); - - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - detachSetElement(rNode.getFactory(), aElement); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - -} -//----------------------------------------------------------------------------------- -void implRemoveByName(NodeValueSetAccess& rNode, const rtl::OUString& sName ) - throw(css::container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeValueSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode); - - rtl::Reference< configuration::ElementTree > aElement = aTree->getElement(aNode,aChildName); - if (!aElement.is()) - { - OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation"); - - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") ); - sMessage += sName; - sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") ); - sMessage += aTree->getAbsolutePath(aNode).toString(); - - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage, xContext ); - } - - configuration::NodeChange aChange = lock.getNodeUpdater().validateRemoveElement(aElement); - - aChange.test(); // make sure old values are set up correctly - OSL_ENSURE(aChange.isChange(), "ERROR: Removing a node validated as empty change"); - - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true)); - - //aSender.queryConstraints(); - N/A: no external constraints on set children possible - - aTree->integrate(aChange, aNode, true); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - catch (configuration::InvalidName& ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - throw container::NoSuchElementException( sMessage += e.message(), xContext ); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - -} -//----------------------------------------------------------------------------------- - -// XPropertyWithState -//----------------------------------------------------------------------------------- - -void implSetToDefaultAsProperty(NodeSetAccess& rNode) - throw (css::lang::WrappedTargetException, uno::RuntimeException) -{ - try - { - GuardedNodeUpdate<NodeSetAccess> lock( rNode ); - - rtl::Reference< configuration::Tree > const aTree( lock.getTree() ); - configuration::NodeRef const aNode( lock.getNode() ); - - configuration::SetDefaulter aDefaulter = lock.getNodeDefaulter(); - - configuration::NodeChange aChange = aDefaulter.validateSetToDefaultState(); - - const bool bLocal = true; - - if (aChange.test().isChange() ) - { - Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,bLocal)); - - aSender.queryConstraints(aChange); - - aTree->integrate(aChange, aNode, bLocal); - - lock.clearForBroadcast(); - aSender.notifyListeners(aChange); - } - } - catch (configuration::ConstraintViolation & ex) - { - ExceptionMapper e(ex); - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - - throw lang::WrappedTargetException( sMessage += e.message(), xContext, uno::Any()); - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - catch (lang::WrappedTargetException& ) { throw;} - catch (uno::RuntimeException& ) { throw;} - catch (uno::Exception& e) - { - rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") ); - uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() ); - - throw lang::WrappedTargetException( sMessage += e.Message, xContext, uno::makeAny(e)); - } -} -//----------------------------------------------------------------------------------- - -// XSingleServiceFactory -//----------------------------------------------------------------------------------- -uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode ) - throw(uno::Exception, uno::RuntimeException) -{ - uno::Reference< uno::XInterface > xRet; - try - { - GuardedNodeData<NodeSetAccess> lock( rNode ); // no provider lock needed ? => if template lock is separate - OK - - rtl::Reference< configuration::ElementTree > aNewElement( rNode.getElementFactory().instantiateTemplate(rNode.getElementInfo()) ); - - uno::Any aAny = configapi::makeElement( rNode.getFactory(), aNewElement ); - if (!(aAny >>= xRet)) // no parent available - { - OSL_ASSERT(!xRet.is()); // make sure we return NULL - OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicSetElement::getParent: could not extract parent - node is not an object"); - } - } - catch (configuration::Exception& ex) - { - ExceptionMapper e(ex); - e.setContext( rNode.getUnoInstance() ); - e.unhandled(); - } - - return xRet; -} -//----------------------------------------------------------------------------------- - -uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode, const uno::Sequence< uno::Any >& aArguments ) - throw(uno::Exception, uno::RuntimeException) -{ - { (void)aArguments; } - OSL_ENSURE(aArguments.getLength() == 0, "ConfigurationContainer: createInstance: Arguments not supported - ignoring ..."); - return implCreateElement(rNode); -} - -//----------------------------------------------------------------------------------- - } // namespace configapi - -} // namespace configmgr - - diff --git a/configmgr/source/api2/updateimpl.hxx b/configmgr/source/api2/updateimpl.hxx deleted file mode 100644 index c8ed6f25c978..000000000000 --- a/configmgr/source/api2/updateimpl.hxx +++ /dev/null @@ -1,95 +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_API_BASEUPDATEIMPL_HXX_ -#define CONFIGMGR_API_BASEUPDATEIMPL_HXX_ - -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/beans/XPropertyWithState.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -namespace configmgr -{ - namespace css = ::com::sun::star; - namespace uno = ::com::sun::star::uno; - - /* implementations of the interfaces supported by a (parent) node - within the configuration tree. - (updating operation) - */ - namespace configapi - { - class NodeSetAccess; - class NodeTreeSetAccess; - class NodeValueSetAccess; - class NodeGroupAccess; - - // XNameReplace - //--------------------------------------------------------------------- - void implReplaceByName(NodeGroupAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implReplaceByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implReplaceByName(NodeValueSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement ) - throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XNameContainer - //--------------------------------------------------------------------- - void implInsertByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implInsertByName(NodeValueSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement) - throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implRemoveByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - void implRemoveByName(NodeValueSetAccess& rNode, const rtl::OUString& rName ) - throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException); - - // XPropertyWithState - updating operation only - //--------------------------------------------------------------------- - void implSetToDefaultAsProperty(NodeSetAccess& rNode) - throw (css::lang::WrappedTargetException, uno::RuntimeException); - - // XSingleServiceFactory - //--------------------------------------------------------------------- - uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode ) - throw(uno::Exception, uno::RuntimeException); - - uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode, const uno::Sequence< uno::Any >& aArguments ) - throw(uno::Exception, uno::RuntimeException); - - //--------------------------------------------------------------------- - } - -} -#endif // CONFIGMGR_API_BASEUPDATEIMPL_HXX_ - - |