Update ooo320-m1
[ooovba.git] / configmgr / source / inc / configset.hxx
blob62651a963f38e269d404c10c618a13db3c9de207
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: configset.hxx,v $
10 * $Revision: 1.18 $
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_CONFIGSET_HXX_
32 #define CONFIGMGR_CONFIGSET_HXX_
34 #include "configexcept.hxx"
35 #include "configdefaultprovider.hxx"
36 #include "template.hxx"
37 #include "noderef.hxx"
38 #include <rtl/ref.hxx>
40 #ifndef INCLUDED_MEMORY
41 #include <memory>
42 #define INCLUDED_MEMORY
43 #endif
45 namespace com { namespace sun { namespace star {
46 namespace script { class XTypeConverter; }
47 } } }
49 namespace configmgr
51 namespace data { class TreeSegment; }
53 namespace configuration
55 namespace Path { class Component; }
56 //---------------------------------------------------------------------
58 class ElementTree;
60 class NodeChange;
61 class Template;
63 class SetElementFactory
65 TemplateProvider m_aProvider;
66 public:
67 SetElementFactory(TemplateProvider const& aProvider);
68 SetElementFactory(SetElementFactory const& aOther);
69 SetElementFactory& operator=(SetElementFactory const& aOther);
70 ~SetElementFactory();
72 rtl::Reference< ElementTree > instantiateTemplate(rtl::Reference<Template> const& aTemplate);
73 rtl::Reference< ElementTree > instantiateOnDefault(rtl::Reference< data::TreeSegment > const& _aTree, rtl::Reference<Template> const& aDummyTemplate);
75 static TemplateProvider findTemplateProvider(rtl::Reference< Tree > const& aTree, NodeRef const& aNode);
78 //-----------------------------------------------------------------------------
80 /// allows to insert,remove and replace an element of a <type>Node</type> that is a Container ("set") of full-fledged trees.
81 class TreeSetUpdater
83 rtl::Reference< Tree > m_aParentTree;
84 NodeRef m_aSetNode;
85 rtl::Reference<Template> m_aTemplate;
86 public:
87 TreeSetUpdater(rtl::Reference< Tree > const& aParentTree, NodeRef const& aSetNode, rtl::Reference< Template > const& aTemplate);
89 NodeChange validateInsertElement (rtl::OUString const& aName, rtl::Reference< ElementTree > const& aNewElement);
91 NodeChange validateReplaceElement(rtl::Reference< ElementTree > const& aElement, rtl::Reference< ElementTree > const& aNewElement);
93 NodeChange validateRemoveElement (rtl::Reference< ElementTree > const& aElement);
94 private:
95 void implValidateSet();
96 Path::Component implValidateElement(rtl::Reference< ElementTree > const& aElement, bool bReqRemovable);
97 void implValidateTree(rtl::Reference< ElementTree > const& aElementTree);
99 //-----------------------------------------------------------------------------
100 /// allows to insert,remove and replace an element of a <type>Node</type> that is a Container ("set") of simple values.
101 class ValueSetUpdater
103 rtl::Reference< Tree > m_aParentTree;
104 NodeRef m_aSetNode;
105 rtl::Reference<Template> m_aTemplate;
106 com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter> m_xTypeConverter;
107 public:
108 ValueSetUpdater(rtl::Reference< Tree > const& aParentTree, NodeRef const& aSetNode,
109 rtl::Reference< Template > const& aTemplate, com::sun::star::uno::Reference<com::sun::star::script::XTypeConverter> const& xConverter);
111 NodeChange validateInsertElement (rtl::OUString const& aName, com::sun::star::uno::Any const& aNewValue);
113 NodeChange validateReplaceElement(rtl::Reference< ElementTree > const& aElement, com::sun::star::uno::Any const& aNewValue);
115 NodeChange validateRemoveElement (rtl::Reference< ElementTree > const& aElement);
116 private:
117 void implValidateSet();
118 Path::Component implValidateElement(rtl::Reference< ElementTree > const& aElement, bool bReqRemovable);
119 com::sun::star::uno::Any implValidateValue(rtl::Reference< Tree > const& aElementTree, com::sun::star::uno::Any const& aValue);
120 com::sun::star::uno::Any implValidateValue(com::sun::star::uno::Any const& aValue);
122 rtl::Reference<ElementTree> makeValueElement(rtl::OUString const& aName, rtl::Reference< Tree > const& aElementTree, com::sun::star::uno::Any const& aValue, bool bInserting);
123 rtl::Reference<ElementTree> makeValueElement(rtl::OUString const& aName, com::sun::star::uno::Any const& aValue, bool bInserting);
124 rtl::Reference< Tree > extractElementNode(rtl::Reference< ElementTree > const& aElement);
126 //-----------------------------------------------------------------------------
128 /// allows to restore to its default state a <type>Node</type> that is a Container ("set") of full-fledged trees.
129 class SetDefaulter
131 rtl::Reference< Tree > m_aParentTree;
132 NodeRef m_aSetNode;
133 DefaultProvider m_aDefaultProvider;
134 public:
135 SetDefaulter(rtl::Reference< Tree > const& aParentTree, NodeRef const& aSetNode, DefaultProvider const& aDefaultProvider);
137 NodeChange validateSetToDefaultState();
139 private:
140 void implValidateSet();
142 //-----------------------------------------------------------------------------
146 #endif // CONFIGMGR_CONFIGSET_HXX_