LibreOffice Module jvmfwk (master) 1
elements.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_JVMFWK_SOURCE_ELEMENTS_HXX
20#define INCLUDED_JVMFWK_SOURCE_ELEMENTS_HXX
21
22#include <sal/config.h>
23
24#include <memory>
25#include <vector>
26#include "fwkutil.hxx"
27#include <rtl/ustring.hxx>
28#include <rtl/byteseq.hxx>
29#include <libxml/parser.h>
30#include <optional>
31
32struct JavaInfo;
33
34#define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
35#define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
36
37namespace jfw
38{
41OString getElementUpdated();
42
49void createSettingsStructure(xmlDoc* document, bool* bNeedsSave);
50
56{
57public:
59
73 bool bNil;
81 OUString sVendor;
82 OUString sLocation;
83 OUString sVersion;
84 sal_uInt64 nRequirements;
85 ::rtl::ByteSequence arVendorData;
86
91 void loadFromNode(xmlDoc* pDoc, xmlNode* pJavaInfo);
96 void writeToNode(xmlDoc* pDoc, xmlNode* pJavaInfo) const;
97
100 std::unique_ptr<JavaInfo> makeJavaInfo() const;
101};
102
114{
115public:
116 enum Layer
117 {
119 SHARED
120 };
121
122private:
133 bool prepareSettingsDocument() const;
134
137 bool createSettingsDocument() const;
138
143 OString getSettingsPath() const;
144
147 OUString getSettingsURL() const;
148
151 static jfw::FileStatus checkSettingsFileStatus(OUString const& sURL);
152
157
162 std::optional<sal_Bool> m_enabled;
163
168 std::optional<OUString> m_userClassPath;
173 std::optional<CNodeJavaInfo> m_javaInfo;
178 std::optional<::std::vector<OUString>> m_vmParameters;
183 std::optional<::std::vector<OUString>> m_JRELocations;
184
185public:
186 explicit NodeJava(Layer theLayer);
187
191 void setEnabled(bool bEnabled);
192
195 void setUserClassPath(const OUString& sClassPath);
196
202 void setJavaInfo(const JavaInfo* pInfo, bool bAutoSelect);
203
210 void setVmParameters(std::vector<OUString> const& arParameters);
211
215 void addJRELocation(OUString const& sLocation);
216
219 void write() const;
220
223 void load();
224
227 const std::optional<sal_Bool>& getEnabled() const { return m_enabled; }
230 const std::optional<OUString>& getUserClassPath() const { return m_userClassPath; }
231
234 const std::optional<CNodeJavaInfo>& getJavaInfo() const { return m_javaInfo; }
235
238 const std::optional<::std::vector<OUString>>& getVmParameters() const { return m_vmParameters; }
239
242 const std::optional<::std::vector<OUString>>& getJRELocations() const { return m_JRELocations; }
243};
244
265class MergedSettings final
266{
267private:
270
271 void merge(const NodeJava& share, const NodeJava& user);
272
274
275 OUString m_sClassPath;
276
277 ::std::vector<OUString> m_vmParams;
278
279 ::std::vector<OUString> m_JRELocations;
280
282
283public:
286
289 bool getEnabled() const { return m_bEnabled; }
290
291 const OUString& getUserClassPath() const { return m_sClassPath; }
292
293 ::std::vector<OString> getVmParametersUtf8() const;
299 std::unique_ptr<JavaInfo> createJavaInfo() const;
300
304
305#ifdef _WIN32
311 bool getJavaInfoAttrAutoSelect() const;
312#endif
313
314 void getVmParametersArray(std::vector<OUString>* parParameters) const;
315
316 const ::std::vector<OUString>& getJRELocations() const { return m_JRELocations; }
317};
318
320{
321 ::std::vector<OUString> vecExcludeVersions;
322 OUString sMinVersion;
323 OUString sMaxVersion;
324};
325
326} //end namespace
327#endif
328
329/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
represents the settings saved in the /java/javaInfo element.
Definition: elements.hxx:56
bool bAutoSelect
contains the value of the /java/javaInfo@autoSelect attribute.
Definition: elements.hxx:80
::rtl::ByteSequence arVendorData
Definition: elements.hxx:85
std::unique_ptr< JavaInfo > makeJavaInfo() const
returns NULL if javaInfo is nil.
Definition: elements.cxx:883
OUString sVersion
Definition: elements.hxx:83
bool bNil
contains the nil value of the /java/javaInfo@xsi:nil attribute.
Definition: elements.hxx:73
OString sAttrVendorUpdate
Contains the value of the <updated> element of the javavendors.xml after loadFromNode was called.
Definition: elements.hxx:69
sal_uInt64 nRequirements
Definition: elements.hxx:84
void writeToNode(xmlDoc *pDoc, xmlNode *pJavaInfo) const
The attribute nil will be set to false.
Definition: elements.cxx:783
bool m_bEmptyNode
if true, then javaInfo is empty.
Definition: elements.hxx:63
OUString sLocation
Definition: elements.hxx:82
void loadFromNode(xmlDoc *pDoc, xmlNode *pJavaInfo)
reads the node /java/javaInfo.
Definition: elements.cxx:681
OUString sVendor
Definition: elements.hxx:81
merges the settings for shared, user and installation during construction.
Definition: elements.hxx:266
const ::std::vector< OUString > & getJRELocations() const
Definition: elements.hxx:316
::std::vector< OUString > m_JRELocations
Definition: elements.hxx:279
bool getEnabled() const
the default is true.
Definition: elements.hxx:289
::std::vector< OString > getVmParametersUtf8() const
Definition: elements.cxx:939
const OUString & getUserClassPath() const
Definition: elements.hxx:291
::std::vector< OUString > m_vmParams
Definition: elements.hxx:277
MergedSettings(MergedSettings const &)=delete
MergedSettings & operator=(MergedSettings const &)=delete
void merge(const NodeJava &share, const NodeJava &user)
Definition: elements.cxx:908
CNodeJavaInfo m_javaInfo
Definition: elements.hxx:281
OUString m_sClassPath
Definition: elements.hxx:275
std::unique_ptr< JavaInfo > createJavaInfo() const
returns a JavaInfo structure representing the node /java/javaInfo.
Definition: elements.cxx:950
OString const & getJavaInfoAttrVendorUpdate() const
returns the value of the attribute /java/javaInfo[@vendorUpdate].
Definition: elements.hxx:303
void getVmParametersArray(std::vector< OUString > *parParameters) const
Definition: elements.cxx:960
this class represents the java settings based on a particular settings file.
Definition: elements.hxx:114
const std::optional<::std::vector< OUString > > & getVmParameters() const
returns the parameters from the element /java/vmParameters/param.
Definition: elements.hxx:238
void setUserClassPath(const OUString &sClassPath)
sets m_sUserClassPath.
Definition: elements.cxx:538
const std::optional< CNodeJavaInfo > & getJavaInfo() const
returns the value of the element /java/javaInfo.
Definition: elements.hxx:234
std::optional<::std::vector< OUString > > m_vmParameters
User configurable option.
Definition: elements.hxx:178
Layer m_layer
Determines the layer for which the instance the loads and writes the data.
Definition: elements.hxx:156
const std::optional< sal_Bool > & getEnabled() const
returns the value of the element /java/enabled
Definition: elements.hxx:227
OString getSettingsPath() const
returns the system path to the data file which is to be used.
Definition: elements.cxx:325
bool createSettingsDocument() const
helper function for prepareSettingsDocument.
Definition: elements.cxx:622
OUString getSettingsURL() const
returns the file URL to the data file which is to be used.
Definition: elements.cxx:338
void load()
load the values of the settings file.
Definition: elements.cxx:178
bool prepareSettingsDocument() const
creates settings file and fills it with default values.
Definition: elements.cxx:351
const std::optional< OUString > & getUserClassPath() const
returns the value of the element /java/userClassPath.
Definition: elements.hxx:230
void addJRELocation(OUString const &sLocation)
adds a location to the already existing locations.
Definition: elements.cxx:575
std::optional<::std::vector< OUString > > m_JRELocations
User configurable option.
Definition: elements.hxx:183
static jfw::FileStatus checkSettingsFileStatus(OUString const &sURL)
Verifies if the respective settings file exist.
Definition: elements.cxx:587
void setEnabled(bool bEnabled)
sets m_enabled.
Definition: elements.cxx:532
void write() const
writes the data to user settings.
Definition: elements.cxx:376
void setJavaInfo(const JavaInfo *pInfo, bool bAutoSelect)
sets m_aInfo.
Definition: elements.cxx:543
void setVmParameters(std::vector< OUString > const &arParameters)
sets the /java/vmParameters/param elements.
Definition: elements.cxx:570
std::optional< sal_Bool > m_enabled
User configurable option.
Definition: elements.hxx:162
const std::optional<::std::vector< OUString > > & getJRELocations() const
returns the parameters from the element /java/jreLocations/location.
Definition: elements.hxx:242
NodeJava(Layer theLayer)
Definition: elements.cxx:166
std::optional< OUString > m_userClassPath
User configurable option.
Definition: elements.hxx:168
std::optional< CNodeJavaInfo > m_javaInfo
User configurable option.
Definition: elements.hxx:173
Definition: elements.cxx:47
OString getElementUpdated()
gets the value of the updated element from the javavendors.xml.
Definition: elements.cxx:79
void createSettingsStructure(xmlDoc *document, bool *bNeedsSave)
create the child elements within the root structure for each platform.
Definition: elements.cxx:85
FileStatus
Definition: fwkutil.hxx:52
an instance of this struct represents an installation of a Java Runtime Environment (JRE).
::std::vector< OUString > vecExcludeVersions
Definition: elements.hxx:321
OUString sMinVersion
Definition: elements.hxx:322
OUString sMaxVersion
Definition: elements.hxx:323