update dev300-m58
[ooovba.git] / configmgr / source / api2 / apifactory.hxx
blob62b8d410654efeb4a468cb3d81d625b7ccdeb31f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: apifactory.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_API_FACTORY_HXX_
32 #define CONFIGMGR_API_FACTORY_HXX_
34 #include "options.hxx"
35 #include "utility.hxx"
36 #include <boost/utility.hpp>
37 #include <rtl/ref.hxx>
38 #include <vos/ref.hxx>
39 #include <cppuhelper/typeprovider.hxx>
41 namespace configmgr
43 namespace configuration
45 class NodeID;
46 class NodeRef;
47 class ElementTree;
48 class Template;
49 class Tree;
51 namespace configapi
53 namespace uno = com::sun::star::uno;
55 class ApiTreeImpl;
56 class NodeElement;
57 class InnerElement;
58 class TreeElement;
59 class SetElement;
60 class RootElement;
62 // used to register objects
63 class ObjectRegistry;
65 // used to create UNO objects
66 class Factory : private boost::noncopyable
68 rtl::Reference<ObjectRegistry> m_pRegistry;
69 cppu::OImplementationId const m_aTunnelID;
71 private:
72 /// return the element _without_ acquiring it
73 NodeElement* implFind(configuration::NodeID const& aNode);
75 public:
76 Factory(rtl::Reference<ObjectRegistry> pRegistry);
77 virtual ~Factory();
79 uno::Reference< uno::XInterface > makeUnoElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
80 uno::Reference< uno::XInterface > findUnoElement(configuration::NodeID const& aNode);
82 uno::Reference< uno::XInterface > makeUnoSetElement(rtl::Reference< configuration::ElementTree > const& aTree);
84 NodeElement* makeElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
85 NodeElement* findElement(configuration::NodeID const& aNode);
87 TreeElement* makeAccessRoot(rtl::Reference< configuration::Tree > const& aTree, RequestOptions const& _aOptions);
88 SetElement* makeSetElement(rtl::Reference< configuration::ElementTree > const& aTree);
90 SetElement* findSetElement(rtl::Reference< configuration::ElementTree > const& aElement);
92 /// check for the existence of an element
93 sal_Bool hasElement(configuration::NodeID const& _rNode) { return NULL != implFind(_rNode); }
95 void revokeElement(configuration::NodeID const& aNode);
97 SetElement* extractSetElement(uno::Any const& aElement);
98 bool tunnelSetElement(sal_Int64& nSomething, SetElement& rElement, uno::Sequence< sal_Int8 > const& aTunnelID);
99 // registry operations
101 static ApiTreeImpl const* findDescendantTreeImpl(configuration::NodeID const& aNode, ApiTreeImpl const* pImpl);
102 protected:
103 void doRegisterElement(configuration::NodeID const& aNode, NodeElement* pElement);
104 void doRevokeElement(configuration::NodeID const& aNode, NodeElement* pElement);
106 uno::Sequence< sal_Int8 > doGetElementTunnelID() const { return m_aTunnelID.getImplementationId(); }
108 virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate) = 0;
109 virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions) = 0;
110 virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate) = 0;
112 static ApiTreeImpl& getImplementation(NodeElement& pElement);
113 private:
114 static rtl::Reference<configuration::Template> implGetSetElementTemplate(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
115 static uno::Reference< uno::XInterface > implToUno(NodeElement* pNode);
116 void implHaveNewElement(configuration::NodeID aNodeID, NodeElement* pNode);
122 #endif // CONFIGMGR_API_FACTORY_HXX_