update dev300-m58
[ooovba.git] / jvmfwk / source / elements.hxx
blob8d094561f2196cf03646abfbd083acb3e197c538
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: elements.hxx,v $
10 * $Revision: 1.13 $
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 ************************************************************************/
30 #if !defined INCLUDED_JVMFWK_ELEMENTS_HXX
31 #define INCLUDED_JVMFWK_ELEMENTS_HXX
33 #include <vector>
34 #include "jvmfwk/framework.h"
35 #include "fwkutil.hxx"
36 #include "rtl/ustring.hxx"
37 #include "rtl/byteseq.hxx"
38 #include "libxml/parser.h"
39 #include "boost/optional.hpp"
41 #define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
42 #define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
44 namespace jfw
47 /** gets the value of the updated element from the javavendors.xml.
49 rtl::OString getElementUpdated();
51 /** create the child elements within the root structure for each platform.
53 @param bNeedsSave
54 [out]If true then the respective structure of elements was added and the
55 document needs to be saved.
57 void createSettingsStructure(
58 xmlDoc * document, bool * bNeedsSave);
61 /** represents the settings saved in the /java/javaInfo element.
62 It is used within class NodeJava which determines the settings
63 file.
65 class CNodeJavaInfo
67 public:
68 CNodeJavaInfo();
69 ~CNodeJavaInfo();
71 /** if true, then javaInfo is empty. When writeToNode is called
72 then all child elements are deleted.
74 bool m_bEmptyNode;
75 /** Contains the value of the <updated> element of
76 the javavendors.xml after loadFromNode was called.
77 It is not used, when the javaInfo node is written.
78 see writeToNode
80 ::rtl::OString sAttrVendorUpdate;
81 /** contains the nil value of the /java/javaInfo@xsi:nil attribute.
82 Default is true;
84 bool bNil;
85 /** contains the value of the /java/javaInfo@autoSelect attribute.
86 Default is true. If it is false then the user has modified the JRE
87 selection by actively choosing a JRE from the options dialog. That is,
88 the function jfw_setSelectedJRE was called. Contrary, the function
89 jfw_findAndSelectJRE sets the attribute to true.
91 bool bAutoSelect;
92 ::rtl::OUString sVendor;
93 ::rtl::OUString sLocation;
94 ::rtl::OUString sVersion;
95 sal_uInt64 nFeatures;
96 sal_uInt64 nRequirements;
97 ::rtl::ByteSequence arVendorData;
99 /** reads the node /java/javaInfo.
100 If javaInfo@xsi:nil = true then member bNil is set to true
101 an no further elements are read.
103 void loadFromNode(xmlDoc * pDoc,xmlNode * pJavaInfo);
104 /** The attribut nil will be set to false. The function gets the value
105 javaSettings/updated from the javavendors.xml and writes it to
106 javaInfo@vendorUpdate in javasettings.xml
108 void writeToNode(xmlDoc * pDoc, xmlNode * pJavaInfo) const;
110 /** returns NULL if javaInfo is nil.
112 JavaInfo * makeJavaInfo() const;
115 /** this class represents the java settings based on a particular
116 settings file.
118 Which settings file is used is determined by the value passed into the
119 constructo and the values of the bootstrap parameters UNO_JAVA_JFW_USER_DATA,
120 UNO_JAVA_JFW_SHARED_DATA,_JAVA_JFW_INSTALL_DATA.
122 If the value is USER_OR_INSTALL then it depends of the bootstrap parameter
123 UNO_JAVA_JFW_INSTALL_DATA. If it has as value then it is used. Otherwise the
124 value from UNO_JAVA_JFW_USER_DATA is used.
126 The method load reads the data from the settings file.
127 The method write stores the data into the settings file.
129 class NodeJava
131 public:
132 enum Layer { USER_OR_INSTALL, USER, SHARED, INSTALL };
133 private:
135 /** creates settings file and fills it with default values.
137 When this function is called then it creates the
138 settings file at the possition determined by the bootstrap parameters
139 (UNO_JAVA_JFW_USER_DATA, UNO_JAVA_JFW_SHARED_DATA,
140 UNO_JAVA_JFW_INSTALL_DATA) and m_layer, unless the file already exists
141 (see createSettingsDocument).
143 @return
144 JFW_E_CONFIG_READWRITE
146 void prepareSettingsDocument() const;
148 /** helper function for prepareSettingsDocument.
150 void createSettingsDocument() const;
152 /** returns the system path to the data file which is to be used. The value
153 depends on
154 the the member m_layer and the bootstrap paramters UNO_JAVA_JFW_USER_DATA,
155 UNO_JAVA_JFW_SHARED_DATA and UNO_JAVA_JFW_INSTALL_DATA which this may be.
157 ::rtl::OString getSettingsPath() const;
159 /** returns the file URL to the data file which is to be used. See getSettingsPath.
161 ::rtl::OUString getSettingsURL() const;
163 /** Verifies if the respective settings file exist. In case UNO_JAVA_JFW_INSTALL_DATA
164 is used, the age is checked. If the file is too old then we assume that it does not
165 exist and wipe its contents. Then still FILE_DOES_NOT_EXIST is returned.
167 jfw::FileStatus checkSettingsFileStatus() const;
169 /** Determines the layer for which the instance the loads and writes the
170 data.
172 Layer m_layer;
174 /** User configurable option. /java/enabled
175 If /java/enabled@xsi:nil == true then the value will be uninitialized
176 after a call to load().
178 boost::optional<sal_Bool> m_enabled;
180 /** User configurable option. /java/userClassPath
181 If /java/userClassPath@xsi:nil == true then the value is uninitialized
182 after a call to load().
184 boost::optional< ::rtl::OUString> m_userClassPath;
185 /** User configurable option. /java/javaInfo
186 If /java/javaInfo@xsi:nil == true then the value is uninitialized
187 after a call to load.
189 boost::optional<CNodeJavaInfo> m_javaInfo;
190 /** User configurable option. /java/vmParameters
191 If /java/vmParameters@xsi:nil == true then the value is uninitialized
192 after a call to load.
194 boost::optional< ::std::vector< ::rtl::OUString> > m_vmParameters;
195 /** User configurable option. /java/jreLocations
196 If /java/jreLocaltions@xsi:nil == true then the value is uninitialized
197 after a call to load.
199 boost::optional< ::std::vector< ::rtl::OUString> > m_JRELocations;
201 public:
203 NodeJava(Layer theLayer = USER_OR_INSTALL);
205 /** sets m_enabled.
206 /java/enabled@xsi:nil will be set to false when write is called.
208 void setEnabled(sal_Bool bEnabled);
210 /** sets m_sUserClassPath. See setEnabled.
212 void setUserClassPath(const ::rtl::OUString & sClassPath);
214 /** sets m_aInfo. See setEnabled.
215 @param bAutoSelect
216 true- called by jfw_setSelectedJRE
217 false called by jfw_findAndSelectJRE
219 void setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect);
221 /** sets the /java/vmParameters/param elements.
222 When this method all previous values are removed and replaced
223 by those in arParameters.
224 /java/vmParameters@xsi:nil will be set to true when write() is
225 called.
227 void setVmParameters(rtl_uString * * arParameters, sal_Int32 size);
229 /** sets the /java/jreLocations/location elements.
230 When this method is called then all previous values are removed
231 and replaced by those in arParamters.
232 /java/jreLocations@xsi:nil will be set to true write() is called.
234 void setJRELocations(rtl_uString * * arParameters, sal_Int32 size);
236 /** adds a location to the already existing locations.
237 Note: call load() before, then add the location and then call write().
239 void addJRELocation(rtl_uString * sLocation);
241 /** writes the data to user settings.
243 void write() const;
245 /** load the values of the settings file.
247 void load();
249 /** returns the value of the element /java/enabled
251 const boost::optional<sal_Bool> & getEnabled() const;
252 /** returns the value of the element /java/userClassPath.
254 const boost::optional< ::rtl::OUString> & getUserClassPath() const;
256 /** returns the value of the element /java/javaInfo.
258 const boost::optional<CNodeJavaInfo> & getJavaInfo() const;
260 /** returns the parameters from the element /java/vmParameters/param.
262 const boost::optional< ::std::vector< ::rtl::OUString> > & getVmParameters() const;
264 /** returns the parameters from the element /java/jreLocations/location.
266 const boost::optional< ::std::vector< ::rtl::OUString> > & getJRELocations() const;
269 /** merges the settings for shared, user and installation during construction.
270 The class uses a simple merge mechanism for the javasettings.xml files in share and
271 user. The following elements completly overwrite the corresponding elements
272 from share:
273 /java/enabled
274 /java/userClassPath
275 /java/vmParameters
276 /java/jreLocations
277 /java/javaInfo
279 In case of an installation, the shared and user settings are completely
280 disregarded.
282 The locations of the different settings files is obtained through the
283 bootstrap variables:
284 UNO_JAVA_JFW_USER_DATA
285 UNO_JAVA_JFW_SHARED_DATA
286 UNO_JAVA_JFW_INSTALL_DATA
288 The class also determines useful default values for settings which have not been made.
290 class MergedSettings
292 private:
293 const MergedSettings& operator = (MergedSettings&);
294 MergedSettings(MergedSettings&);
296 void merge(const NodeJava & share, const NodeJava & user);
298 sal_Bool m_bEnabled;
300 ::rtl::OUString m_sClassPath;
302 ::std::vector< ::rtl::OUString> m_vmParams;
304 ::std::vector< ::rtl::OUString> m_JRELocations;
306 CNodeJavaInfo m_javaInfo;
308 public:
309 MergedSettings();
310 virtual ~MergedSettings();
312 /** the default is true.
314 sal_Bool getEnabled() const;
316 const ::rtl::OUString & getUserClassPath() const;
318 ::std::vector< ::rtl::OString> getVmParametersUtf8() const;
319 /** returns a JavaInfo structure representing the node
320 /java/javaInfo. Every time a new JavaInfo structure is created
321 which needs to be freed by the caller.
322 If both, user and share settings are nil, then NULL is returned.
324 JavaInfo * createJavaInfo() const;
326 /** returns the value of the attribute /java/javaInfo[@vendorUpdate].
328 ::rtl::OString const & getJavaInfoAttrVendorUpdate() const;
330 #ifdef WNT
331 /** returns the javaInfo@autoSelect attribute.
332 Before calling this function loadFromSettings must be called.
333 It uses the javaInfo@autoSelect attribute to determine
334 the return value;
336 bool getJavaInfoAttrAutoSelect() const;
337 #endif
339 /** returns an array.
340 Caller must free the strings and the array.
342 void getVmParametersArray(rtl_uString *** parParameters, sal_Int32 * size) const;
344 /** returns an array.
345 Caller must free the strings and the array.
347 void getJRELocations(rtl_uString *** parLocations, sal_Int32 * size) const;
349 const ::std::vector< ::rtl::OUString> & getJRELocations() const;
353 class VersionInfo
355 ::std::vector< ::rtl::OUString> vecExcludeVersions;
356 rtl_uString ** arVersions;
358 public:
359 VersionInfo();
360 ~VersionInfo();
362 void addExcludeVersion(const ::rtl::OUString& sVersion);
364 ::rtl::OUString sMinVersion;
365 ::rtl::OUString sMaxVersion;
367 /** The caller DOES NOT get ownership of the strings. That is he
368 does not need to release the strings.
369 The array exists as long as this object exists.
372 rtl_uString** getExcludeVersions();
373 sal_Int32 getExcludeVersionSize();
376 struct PluginLibrary
378 PluginLibrary()
381 PluginLibrary(rtl::OUString vendor,::rtl::OUString path) :
382 sVendor(vendor), sPath(path)
385 /** contains the vendor string which is later userd in the xml API
387 ::rtl::OUString sVendor;
388 /** File URL the plug-in library
390 ::rtl::OUString sPath;
393 } //end namespace
394 #endif