merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / backend / componentdatahelper.hxx
blobf482274fca982d85223d007561885c3f43ce0549
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: componentdatahelper.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 /* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */
33 #ifndef CONFIGMGR_BACKEND_COMPONENTDATAHELPER_HXX
34 #define CONFIGMGR_BACKEND_COMPONENTDATAHELPER_HXX
36 #include "valuenode.hxx"
37 #include "utility.hxx"
38 #include "stack.hxx"
39 #include <com/sun/star/configuration/backend/TemplateIdentifier.hpp>
40 #include <com/sun/star/configuration/backend/MalformedDataException.hpp>
41 #include <com/sun/star/uno/RuntimeException.hpp>
43 #ifndef INCLUDED_MEMORY
44 #include <memory>
45 #define INCLUDED_MEMORY
46 #endif
47 #include "mergeddataprovider.hxx"
48 #ifndef CONFIGMGR_LOGGER_HXX_
49 #include "logger.hxx"
50 #endif
51 #include "request.hxx"
53 namespace configmgr
55 // -----------------------------------------------------------------------------
56 class OTreeNodeFactory;
57 // -----------------------------------------------------------------------------
58 namespace backend
60 // -----------------------------------------------------------------------------
61 namespace uno = ::com::sun::star::uno;
62 namespace backenduno = ::com::sun::star::configuration::backend;
64 // -----------------------------------------------------------------------------
66 class DataBuilderContext
68 Logger m_aLogger;
69 Stack< ISubtree * > m_aParentStack;
70 rtl::OUString m_aActiveComponent;
71 uno::XInterface * m_pContext;
72 rtl::OUString m_aExpectedComponentName;
73 ITemplateDataProvider * m_aTemplateProvider;
74 public:
75 explicit DataBuilderContext(uno::Reference< uno::XComponentContext > const & xContext);
76 DataBuilderContext(uno::Reference< uno::XComponentContext > const & xContext, uno::XInterface * _pContext , ITemplateDataProvider* aTemplateProvider = NULL);
77 DataBuilderContext(uno::Reference< uno::XComponentContext > const & xContext, uno::XInterface * _pContext, const rtl::OUString& aExpectedComponentName,ITemplateDataProvider* aTemplateProvider = NULL );
78 DataBuilderContext(DataBuilderContext const & aBaseContext, uno::XInterface * _pContext);
79 ~DataBuilderContext();
81 bool isDone() const;
83 bool hasActiveComponent() const { return m_aActiveComponent.getLength() != 0; }
84 rtl::OUString getActiveComponent() const { return m_aActiveComponent; }
86 ISubtree & getCurrentParent()
87 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
88 { return implGetCurrentParent(); }
90 ISubtree const & getCurrentParent() const
91 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
92 { return implGetCurrentParent(); }
94 node::Attributes getCurrentAttributes() const
95 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
96 { return implGetCurrentParent().getAttributes(); }
98 ITemplateDataProvider * getTemplateProvider() const
99 { return m_aTemplateProvider; }
101 rtl::OUString getTemplateComponent(backenduno::TemplateIdentifier const & aItemType ) const;
103 backenduno::TemplateIdentifier completeComponent(backenduno::TemplateIdentifier const & aItemType ) const;
105 backenduno::TemplateIdentifier getCurrentItemType() const
106 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
107 backenduno::TemplateIdentifier getValidItemType(backenduno::TemplateIdentifier const & aItemType) const
108 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
110 void startActiveComponent(rtl::OUString const & _aComponent)
111 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
112 void endActiveComponent()
113 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
115 bool isProperty(INode * pProp) const
116 SAL_THROW((com::sun::star::uno::RuntimeException));
118 bool isNode(INode * pNode) const SAL_THROW((com::sun::star::uno::RuntimeException))
119 { return !isProperty(pNode); }
121 void pushNode(ISubtree * pTree)
122 SAL_THROW((com::sun::star::uno::RuntimeException));
123 void popNode()
124 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
126 INode * findProperty(rtl::OUString const & _aName)
127 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
128 ISubtree * findNode(rtl::OUString const & _aName)
129 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
131 bool isWritable(INode const * pNode) const
132 SAL_THROW(());
133 bool isRemovable(ISubtree const * pItem) const
134 SAL_THROW(());
136 ISubtree * addNodeToCurrent(std::auto_ptr<ISubtree> _aNode)
137 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
138 ISubtree * addLocalizedToCurrent(std::auto_ptr<ISubtree> _aNode)
139 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
140 ValueNode * addPropertyToCurrent(std::auto_ptr<ValueNode> _aNode, bool _bMayReplace = false)
141 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
143 void markCurrentMerged();
145 // Logging support
146 Logger const & getLogger() const { return m_aLogger; }
148 rtl::OUString getNodeParentagePath() const;
149 rtl::OUString getNodePath(rtl::OUString const & aNodeName) const;
151 // Exception support
152 void raiseMalformedDataException (sal_Char const * _pText) const
153 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
154 void raiseIllegalArgumentException (sal_Char const * _pText, sal_Int16 _nPos = 0) const
155 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
156 void raiseElementExistException (sal_Char const * _pText, rtl::OUString const & _sElement) const
157 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
158 void raiseNoSuchElementException (sal_Char const * _pText, rtl::OUString const & _sElement) const
159 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
160 void raisePropertyExistException (sal_Char const * _pText, rtl::OUString const & _sElement) const
161 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
162 void raiseIllegalTypeException (sal_Char const * _pText) const
163 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
164 ResultHolder< TemplateInstance > getTemplateData (TemplateRequest const & _aRequest );
165 private:
166 INode * findChild(rtl::OUString const & _aName)
167 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
169 rtl::OUString makeMessageWithPath(sal_Char const * _pText) const
170 SAL_THROW((com::sun::star::uno::RuntimeException));
172 rtl::OUString makeMessageWithName(sal_Char const * _pText, rtl::OUString const & _aName) const
173 SAL_THROW((com::sun::star::uno::RuntimeException));
175 ISubtree & implGetCurrentParent() const
176 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException));
179 // -----------------------------------------------------------------------------
181 class ComponentDataFactory
183 OTreeNodeFactory & m_rNodeFactory;
184 public:
185 ComponentDataFactory();
187 ComponentDataFactory(OTreeNodeFactory & _rNodeFactory)
188 : m_rNodeFactory(_rNodeFactory)
191 public:
192 OTreeNodeFactory& getNodeFactory() const { return m_rNodeFactory; }
194 std::auto_ptr<ISubtree> createGroup(rtl::OUString const & _aName,
195 bool _bExtensible,
196 node::Attributes const & _aAttributes) const;
198 std::auto_ptr<ISubtree> createSet( rtl::OUString const & _aName,
199 backenduno::TemplateIdentifier const & aItemType,
200 bool _bExtensible,
201 node::Attributes const & _aAttributes) const;
203 std::auto_ptr<ISubtree> createLocalizedContainer(rtl::OUString const & _aName,
204 uno::Type const & _aValueType,
205 node::Attributes const & _aAttributes) const;
207 std::auto_ptr<ISubtree> createPlaceHolder(rtl::OUString const & _aName,
208 backenduno::TemplateIdentifier const & _aInstanceType) const;
210 static bool isInstancePlaceHolder(ISubtree const & _aInstanceTree);
211 static backenduno::TemplateIdentifier getInstanceType(ISubtree const & _aInstanceTree);
213 // -----------------------------------------------------------------------------
214 } // namespace backend
215 // -----------------------------------------------------------------------------
217 } // namespace configmgr
218 #endif