Bug Summary

File:jvmfwk/source/elements.cxx
Location:line 1145, column 5
Description:Dereference of null pointer (loaded from variable 'parLocations')

Annotated Source Code

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
20#include "elements.hxx"
21#include "osl/mutex.hxx"
22#include "osl/file.hxx"
23#include "fwkutil.hxx"
24#include "fwkbase.hxx"
25#include "framework.hxx"
26#include "libxmlutil.hxx"
27#include "osl/thread.hxx"
28#include <algorithm>
29#include "libxml/parser.h"
30#include "libxml/xpath.h"
31#include "libxml/xpathInternals.h"
32#include "rtl/bootstrap.hxx"
33#include "boost/optional.hpp"
34#include <string.h>
35
36
37using namespace osl;
38namespace jfw
39{
40
41rtl::OString getElement(::rtl::OString const & docPath,
42 xmlChar const * pathExpression, bool bThrowIfEmpty)
43{
44 //Prepare the xml document and context
45 OSL_ASSERT(!docPath.isEmpty())do { if (true && (!(!docPath.isEmpty()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "45" ": "), "OSL_ASSERT: %s", "!docPath.isEmpty()"); } }
while (false)
;
46 jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr()));
47 if (doc == NULL__null)
48 throw FrameworkException(
49 JFW_E_ERROR,
50 rtl::OString("[Java framework] Error in function getElement "
51 "(elements.cxx)"));
52
53 jfw::CXPathContextPtr context(xmlXPathNewContext(doc));
54 if (xmlXPathRegisterNs(context, (xmlChar*) "jf",
55 (xmlChar*) NS_JAVA_FRAMEWORK"http://openoffice.org/2004/java/framework/1.0") == -1)
56 throw FrameworkException(
57 JFW_E_ERROR,
58 rtl::OString("[Java framework] Error in function getElement "
59 "(elements.cxx)"));
60
61 CXPathObjectPtr pathObj;
62 pathObj = xmlXPathEvalExpression(pathExpression, context);
63 rtl::OString sValue;
64 if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
65 {
66 if (bThrowIfEmpty)
67 throw FrameworkException(
68 JFW_E_ERROR,
69 rtl::OString("[Java framework] Error in function getElement "
70 "(elements.cxx)"));
71 }
72 else
73 {
74 sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content;
75 }
76 return sValue;
77}
78
79rtl::OString getElementUpdated()
80{
81 return getElement(jfw::getVendorSettingsPath(),
82 (xmlChar*)"/jf:javaSelection/jf:updated/text()", true);
83}
84
85void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
86{
87 rtl::OString sExcMsg("[Java framework] Error in function createSettingsStructure "
88 "(elements.cxx).");
89 xmlNode * root = xmlDocGetRootElement(document);
90 if (root == NULL__null)
91 throw FrameworkException(JFW_E_ERROR, sExcMsg);
92 bool bFound = false;
93 xmlNode * cur = root->children;
94 while (cur != NULL__null)
95 {
96 if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
97 {
98 bFound = true;
99 break;
100 }
101 cur = cur->next;
102 }
103 if (bFound)
104 {
105 *bNeedsSave = false;
106 return;
107 }
108 //We will modify this document
109 *bNeedsSave = true;
110 // Now we create the child elements ------------------
111 //Get xsi:nil namespace
112 xmlNs* nsXsi = xmlSearchNsByHref(
113 document, root,(xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
114
115 //<enabled xsi:nil="true"
116 xmlNode * nodeEn = xmlNewTextChild(
117 root,NULL__null, (xmlChar*) "enabled", (xmlChar*) "");
118 if (nodeEn == NULL__null)
119 throw FrameworkException(JFW_E_ERROR, sExcMsg);
120 xmlSetNsProp(nodeEn,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
121 //add a new line
122 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
123 xmlAddChild(root, nodeCrLf);
124
125 //<userClassPath xsi:nil="true">
126 xmlNode * nodeUs = xmlNewTextChild(
127 root,NULL__null, (xmlChar*) "userClassPath", (xmlChar*) "");
128 if (nodeUs == NULL__null)
129 throw FrameworkException(JFW_E_ERROR, sExcMsg);
130 xmlSetNsProp(nodeUs,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
131 //add a new line
132 nodeCrLf = xmlNewText((xmlChar*) "\n");
133 xmlAddChild(root, nodeCrLf);
134
135 //<vmParameters xsi:nil="true">
136 xmlNode * nodeVm = xmlNewTextChild(
137 root,NULL__null, (xmlChar*) "vmParameters", (xmlChar*) "");
138 if (nodeVm == NULL__null)
139 throw FrameworkException(JFW_E_ERROR, sExcMsg);
140 xmlSetNsProp(nodeVm,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
141 //add a new line
142 nodeCrLf = xmlNewText((xmlChar*) "\n");
143 xmlAddChild(root, nodeCrLf);
144
145 //<jreLocations xsi:nil="true">
146 xmlNode * nodeJre = xmlNewTextChild(
147 root,NULL__null, (xmlChar*) "jreLocations", (xmlChar*) "");
148 if (nodeJre == NULL__null)
149 throw FrameworkException(JFW_E_ERROR, sExcMsg);
150 xmlSetNsProp(nodeJre,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
151 //add a new line
152 nodeCrLf = xmlNewText((xmlChar*) "\n");
153 xmlAddChild(root, nodeCrLf);
154
155 //<javaInfo xsi:nil="true">
156 xmlNode * nodeJava = xmlNewTextChild(
157 root,NULL__null, (xmlChar*) "javaInfo", (xmlChar*) "");
158 if (nodeJava == NULL__null)
159 throw FrameworkException(JFW_E_ERROR, sExcMsg);
160 xmlSetNsProp(nodeJava,nsXsi,(xmlChar*) "nil",(xmlChar*) "true");
161 //add a new line
162 nodeCrLf = xmlNewText((xmlChar*) "\n");
163 xmlAddChild(root, nodeCrLf);
164}
165
166
167//====================================================================
168VersionInfo::VersionInfo(): arVersions(NULL__null)
169{
170}
171
172VersionInfo::~VersionInfo()
173{
174 delete [] arVersions;
175}
176
177void VersionInfo::addExcludeVersion(const rtl::OUString& sVersion)
178{
179 vecExcludeVersions.push_back(sVersion);
180}
181
182rtl_uString** VersionInfo::getExcludeVersions()
183{
184 osl::MutexGuard guard(FwkMutex::get());
185 if (arVersions != NULL__null)
186 return arVersions;
187
188 arVersions = new rtl_uString*[vecExcludeVersions.size()];
189 int j=0;
190 typedef std::vector<rtl::OUString>::const_iterator it;
191 for (it i = vecExcludeVersions.begin(); i != vecExcludeVersions.end();
192 ++i, ++j)
193 {
194 arVersions[j] = vecExcludeVersions[j].pData;
195 }
196 return arVersions;
197}
198
199sal_Int32 VersionInfo::getExcludeVersionSize()
200{
201 return vecExcludeVersions.size();
202}
203//==================================================================
204
205NodeJava::NodeJava(Layer layer):
206 m_layer(layer)
207{
208 //This class reads and write to files which should only be done in
209 //application mode
210 if (getMode() == JFW_MODE_DIRECT)
211 throw FrameworkException(
212 JFW_E_DIRECT_MODE,
213 "[Java framework] Trying to access settings files in direct mode.");
214}
215
216
217void NodeJava::load()
218{
219 const rtl::OString sExcMsg("[Java framework] Error in function NodeJava::load"
220 "(elements.cxx).");
221 if (SHARED == m_layer)
222 {
223 //we do not support yet to write into the shared installation
224
225 //check if shared settings exist at all.
226 jfw::FileStatus s = checkFileURL(BootParams::getSharedData());
227 if (s == FILE_INVALID)
228 throw FrameworkException(
229 JFW_E_ERROR,
230 "[Java framework] Invalid file for shared Java settings.");
231 else if (s == FILE_DOES_NOT_EXIST)
232 //Writing shared data is not supported yet.
233 return;
234 }
235 else if (USER == m_layer)
236 {
237 prepareSettingsDocument();
238 }
239 else
240 {
241 OSL_FAIL("[Java framework] Unknown enum used.")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "241" ": "), "%s", "[Java framework] Unknown enum used."
); } } while (false)
;
242 }
243
244
245 //Read the user elements
246 rtl::OString sSettingsPath = getSettingsPath();
247 //There must not be a share settings file
248 CXmlDocPtr docUser(xmlParseFile(sSettingsPath.getStr()));
249 if (docUser == NULL__null)
250 throw FrameworkException(JFW_E_ERROR, sExcMsg);
251
252 xmlNode * cur = xmlDocGetRootElement(docUser);
253 if (cur == NULL__null || cur->children == NULL__null)
254 throw FrameworkException(JFW_E_ERROR, sExcMsg);
255
256 CXmlCharPtr sNil;
257 cur = cur->children;
258 while (cur != NULL__null)
259 {
260 if (xmlStrcmp(cur->name, (xmlChar*) "enabled") == 0)
261 {
262 //only overwrite share settings if xsi:nil="false"
263 sNil = xmlGetNsProp(
264 cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
265 if (sNil == NULL__null)
266 throw FrameworkException(JFW_E_ERROR, sExcMsg);;
267 if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
268 {
269 CXmlCharPtr sEnabled( xmlNodeListGetString(
270 docUser, cur->children, 1));
271 if (xmlStrcmp(sEnabled, (xmlChar*) "true") == 0)
272 m_enabled = boost::optional<sal_Bool>(sal_True((sal_Bool)1));
273 else if (xmlStrcmp(sEnabled, (xmlChar*) "false") == 0)
274 m_enabled = boost::optional<sal_Bool>(sal_False((sal_Bool)0));
275 }
276 }
277 else if (xmlStrcmp(cur->name, (xmlChar*) "userClassPath") == 0)
278 {
279 sNil = xmlGetNsProp(
280 cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
281 if (sNil == NULL__null)
282 throw FrameworkException(JFW_E_ERROR, sExcMsg);
283 if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
284 {
285 CXmlCharPtr sUser(xmlNodeListGetString(
286 docUser, cur->children, 1));
287 m_userClassPath = boost::optional<rtl::OUString>(rtl::OUString(sUser));
288 }
289 }
290 else if (xmlStrcmp(cur->name, (xmlChar*) "javaInfo") == 0)
291 {
292 sNil = xmlGetNsProp(
293 cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
294 if (sNil == NULL__null)
295 throw FrameworkException(JFW_E_ERROR, sExcMsg);
296
297 if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
298 {
299 if (! m_javaInfo)
300 m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
301 m_javaInfo->loadFromNode(docUser, cur);
302 }
303 }
304 else if (xmlStrcmp(cur->name, (xmlChar*) "vmParameters") == 0)
305 {
306 sNil = xmlGetNsProp(
307 cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
308 if (sNil == NULL__null)
309 throw FrameworkException(JFW_E_ERROR, sExcMsg);
310 if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
311 {
312 if ( ! m_vmParameters)
313 m_vmParameters = boost::optional<std::vector<rtl::OUString> >(
314 std::vector<rtl::OUString> ());
315
316 xmlNode * pOpt = cur->children;
317 while (pOpt != NULL__null)
318 {
319 if (xmlStrcmp(pOpt->name, (xmlChar*) "param") == 0)
320 {
321 CXmlCharPtr sOpt;
322 sOpt = xmlNodeListGetString(
323 docUser, pOpt->children, 1);
324 m_vmParameters->push_back(sOpt);
325 }
326 pOpt = pOpt->next;
327 }
328 }
329 }
330 else if (xmlStrcmp(cur->name, (xmlChar*) "jreLocations") == 0)
331 {
332 sNil = xmlGetNsProp(
333 cur, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
334 if (sNil == NULL__null)
335 throw FrameworkException(JFW_E_ERROR, sExcMsg);
336 if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
337 {
338 if (! m_JRELocations)
339 m_JRELocations = boost::optional<std::vector<rtl::OUString> >(
340 std::vector<rtl::OUString>());
341
342 xmlNode * pLoc = cur->children;
343 while (pLoc != NULL__null)
344 {
345 if (xmlStrcmp(pLoc->name, (xmlChar*) "location") == 0)
346 {
347 CXmlCharPtr sLoc;
348 sLoc = xmlNodeListGetString(
349 docUser, pLoc->children, 1);
350 m_JRELocations->push_back(sLoc);
351 }
352 pLoc = pLoc->next;
353 }
354 }
355 }
356 cur = cur->next;
357 }
358}
359
360::rtl::OString NodeJava::getSettingsPath() const
361{
362 ::rtl::OString ret;
363 switch (m_layer)
364 {
365 case USER: ret = getUserSettingsPath(); break;
366 case SHARED: ret = getSharedSettingsPath(); break;
367 default:
368 OSL_FAIL("[Java framework] NodeJava::getSettingsPath()")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "368" ": "), "%s", "[Java framework] NodeJava::getSettingsPath()"
); } } while (false)
;
369 }
370 return ret;
371}
372
373::rtl::OUString NodeJava::getSettingsURL() const
374{
375 ::rtl::OUString ret;
376 switch (m_layer)
377 {
378 case USER: ret = BootParams::getUserData(); break;
379 case SHARED: ret = BootParams::getSharedData(); break;
380 default:
381 OSL_FAIL("[Java framework] NodeJava::getSettingsURL()")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "381" ": "), "%s", "[Java framework] NodeJava::getSettingsURL()"
); } } while (false)
;
382 }
383 return ret;
384}
385
386void NodeJava::prepareSettingsDocument() const
387{
388 rtl::OString sExcMsg(
389 "[Java framework] Error in function prepareSettingsDocument"
390 " (elements.cxx).");
391 createSettingsDocument();
392 rtl::OString sSettings = getSettingsPath();
393 CXmlDocPtr doc(xmlParseFile(sSettings.getStr()));
394 if (!doc)
395 throw FrameworkException(JFW_E_ERROR, sExcMsg);
396
397 bool bNeedsSave = false;
398 createSettingsStructure(doc, & bNeedsSave);
399 if (bNeedsSave)
400 {
401 if (xmlSaveFormatFileEnc(
402 sSettings.getStr(), doc,"UTF-8", 1) == -1)
403 throw FrameworkException(JFW_E_ERROR, sExcMsg);
404 }
405}
406
407void NodeJava::write() const
408{
409 rtl::OString sExcMsg("[Java framework] Error in function NodeJava::writeSettings "
410 "(elements.cxx).");
411 CXmlDocPtr docUser;
412 CXPathContextPtr contextUser;
413 CXPathObjectPtr pathObj;
414
415 prepareSettingsDocument();
416
417 //Read the user elements
418 rtl::OString sSettingsPath = getSettingsPath();
419 docUser = xmlParseFile(sSettingsPath.getStr());
420 if (docUser == NULL__null)
421 throw FrameworkException(JFW_E_ERROR, sExcMsg);
422 contextUser = xmlXPathNewContext(docUser);
423 if (xmlXPathRegisterNs(contextUser, (xmlChar*) "jf",
424 (xmlChar*) NS_JAVA_FRAMEWORK"http://openoffice.org/2004/java/framework/1.0") == -1)
425 throw FrameworkException(JFW_E_ERROR, sExcMsg);
426
427 xmlNode * root = xmlDocGetRootElement(docUser);
428 //Get xsi:nil namespace
429 xmlNs* nsXsi = xmlSearchNsByHref(docUser,
430 root,
431 (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
432
433 //set the <enabled> element
434 //The element must exist
435 if (m_enabled)
436 {
437 rtl::OString sExpression= rtl::OString(
438 "/jf:java/jf:enabled");
439 pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
440 contextUser);
441 if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
442 throw FrameworkException(JFW_E_ERROR, sExcMsg);
443
444 xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
445 xmlSetNsProp(nodeEnabled,
446 nsXsi,
447 (xmlChar*) "nil",
448 (xmlChar*) "false");
449
450 if (m_enabled == boost::optional<sal_Bool>(sal_True((sal_Bool)1)))
451 xmlNodeSetContent(nodeEnabled,(xmlChar*) "true");
452 else
453 xmlNodeSetContent(nodeEnabled,(xmlChar*) "false");
454 }
455
456 //set the <userClassPath> element
457 //The element must exist
458 if (m_userClassPath)
459 {
460 rtl::OString sExpression= rtl::OString(
461 "/jf:java/jf:userClassPath");
462 pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
463 contextUser);
464 if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
465 throw FrameworkException(JFW_E_ERROR, sExcMsg);
466
467 xmlNode * nodeEnabled = pathObj->nodesetval->nodeTab[0];
468 xmlSetNsProp(nodeEnabled, nsXsi, (xmlChar*) "nil",(xmlChar*) "false");
469 xmlNodeSetContent(nodeEnabled,(xmlChar*) CXmlCharPtr(*m_userClassPath));
470 }
471
472 //set <javaInfo> element
473 if (m_javaInfo)
474 {
475 rtl::OString sExpression= rtl::OString(
476 "/jf:java/jf:javaInfo");
477 pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
478 contextUser);
479 if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
480 throw FrameworkException(JFW_E_ERROR, sExcMsg);
481 m_javaInfo->writeToNode(
482 docUser, pathObj->nodesetval->nodeTab[0]);
483 }
484
485 //set <vmParameters> element
486 if (m_vmParameters)
487 {
488 rtl::OString sExpression= rtl::OString(
489 "/jf:java/jf:vmParameters");
490 pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
491 contextUser);
492 if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
493 throw FrameworkException(JFW_E_ERROR, sExcMsg);
494 xmlNode* vmParameters = pathObj->nodesetval->nodeTab[0];
495 //set xsi:nil = false;
496 xmlSetNsProp(vmParameters, nsXsi,(xmlChar*) "nil",
497 (xmlChar*) "false");
498
499 //remove option elements
500 xmlNode* cur = vmParameters->children;
501 while (cur != NULL__null)
502 {
503 xmlNode* lastNode = cur;
504 cur = cur->next;
505 xmlUnlinkNode(lastNode);
506 xmlFreeNode(lastNode);
507 }
508 //add a new line after <vmParameters>
509 if (m_vmParameters->size() > 0)
510 {
511 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
512 xmlAddChild(vmParameters, nodeCrLf);
513 }
514
515 typedef std::vector<rtl::OUString>::const_iterator cit;
516 for (cit i = m_vmParameters->begin(); i != m_vmParameters->end(); ++i)
517 {
518 xmlNewTextChild(vmParameters, NULL__null, (xmlChar*) "param",
519 CXmlCharPtr(*i));
520 //add a new line
521 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
522 xmlAddChild(vmParameters, nodeCrLf);
523 }
524 }
525
526 //set <jreLocations> element
527 if (m_JRELocations)
528 {
529 rtl::OString sExpression= rtl::OString(
530 "/jf:java/jf:jreLocations");
531 pathObj = xmlXPathEvalExpression((xmlChar*) sExpression.getStr(),
532 contextUser);
533 if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)(((pathObj->nodesetval) == __null) || ((pathObj->nodesetval
)->nodeNr == 0) || ((pathObj->nodesetval)->nodeTab ==
__null))
)
534 throw FrameworkException(JFW_E_ERROR, sExcMsg);
535 xmlNode* jreLocationsNode = pathObj->nodesetval->nodeTab[0];
536 //set xsi:nil = false;
537 xmlSetNsProp(jreLocationsNode, nsXsi,(xmlChar*) "nil",
538 (xmlChar*) "false");
539
540 //remove option elements
541 xmlNode* cur = jreLocationsNode->children;
542 while (cur != NULL__null)
543 {
544 xmlNode* lastNode = cur;
545 cur = cur->next;
546 xmlUnlinkNode(lastNode);
547 xmlFreeNode(lastNode);
548 }
549 //add a new line after <vmParameters>
550 if (m_JRELocations->size() > 0)
551 {
552 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
553 xmlAddChild(jreLocationsNode, nodeCrLf);
554 }
555
556 typedef std::vector<rtl::OUString>::const_iterator cit;
557 for (cit i = m_JRELocations->begin(); i != m_JRELocations->end(); ++i)
558 {
559 xmlNewTextChild(jreLocationsNode, NULL__null, (xmlChar*) "location",
560 CXmlCharPtr(*i));
561 //add a new line
562 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
563 xmlAddChild(jreLocationsNode, nodeCrLf);
564 }
565 }
566
567 if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1)
568 throw FrameworkException(JFW_E_ERROR, sExcMsg);
569}
570
571void NodeJava::setEnabled(sal_Bool bEnabled)
572{
573 m_enabled = boost::optional<sal_Bool>(bEnabled);
574}
575
576
577void NodeJava::setUserClassPath(const rtl::OUString & sClassPath)
578{
579 m_userClassPath = boost::optional<rtl::OUString>(sClassPath);
580}
581
582void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)
583{
584 if (!m_javaInfo)
585 m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
586 m_javaInfo->bAutoSelect = bAutoSelect;
587 m_javaInfo->bNil = false;
588
589 if (pInfo != NULL__null)
590 {
591 m_javaInfo->m_bEmptyNode = false;
592 m_javaInfo->sVendor = pInfo->sVendor;
593 m_javaInfo->sLocation = pInfo->sLocation;
594 m_javaInfo->sVersion = pInfo->sVersion;
595 m_javaInfo->nFeatures = pInfo->nFeatures;
596 m_javaInfo->nRequirements = pInfo->nRequirements;
597 m_javaInfo->arVendorData = pInfo->arVendorData;
598 }
599 else
600 {
601 m_javaInfo->m_bEmptyNode = true;
602 rtl::OUString sEmpty;
603 m_javaInfo->sVendor = sEmpty;
604 m_javaInfo->sLocation = sEmpty;
605 m_javaInfo->sVersion = sEmpty;
606 m_javaInfo->nFeatures = 0;
607 m_javaInfo->nRequirements = 0;
608 m_javaInfo->arVendorData = rtl::ByteSequence();
609 }
610}
611
612void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size)
613{
614 OSL_ASSERT( !(arOptions == 0 && size != 0))do { if (true && (!(!(arOptions == 0 && size !=
0)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx" ":"
"614" ": "), "OSL_ASSERT: %s", "!(arOptions == 0 && size != 0)"
); } } while (false)
;
615 if ( ! m_vmParameters)
616 m_vmParameters = boost::optional<std::vector<rtl::OUString> >(
617 std::vector<rtl::OUString>());
618 m_vmParameters->clear();
619 if (arOptions != NULL__null)
620 {
621 for (int i = 0; i < size; i++)
622 {
623 const rtl::OUString sOption(static_cast<rtl_uString*>(arOptions[i]));
624 m_vmParameters->push_back(sOption);
625 }
626 }
627}
628
629void NodeJava::setJRELocations(rtl_uString * * arLocations, sal_Int32 size)
630{
631 OSL_ASSERT( !(arLocations == 0 && size != 0))do { if (true && (!(!(arLocations == 0 && size
!= 0)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN),
("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "631" ": "), "OSL_ASSERT: %s", "!(arLocations == 0 && size != 0)"
); } } while (false)
;
632 if (! m_JRELocations)
633 m_JRELocations = boost::optional<std::vector<rtl::OUString> > (
634 std::vector<rtl::OUString>());
635 m_JRELocations->clear();
636 if (arLocations != NULL__null)
637 {
638 for (int i = 0; i < size; i++)
639 {
640 const rtl::OUString & sLocation = static_cast<rtl_uString*>(arLocations[i]);
641
642 //only add the path if not already present
643 std::vector<rtl::OUString>::const_iterator it =
644 std::find(m_JRELocations->begin(), m_JRELocations->end(),
645 sLocation);
646 if (it == m_JRELocations->end())
647 m_JRELocations->push_back(sLocation);
648 }
649 }
650}
651
652void NodeJava::addJRELocation(rtl_uString * sLocation)
653{
654 OSL_ASSERT( sLocation)do { if (true && (!(sLocation))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "654" ": "), "OSL_ASSERT: %s", "sLocation"); } } while (
false)
;
655 if (!m_JRELocations)
656 m_JRELocations = boost::optional<std::vector<rtl::OUString> >(
657 std::vector<rtl::OUString> ());
658 //only add the path if not already present
659 std::vector<rtl::OUString>::const_iterator it =
660 std::find(m_JRELocations->begin(), m_JRELocations->end(),
661 rtl::OUString(sLocation));
662 if (it == m_JRELocations->end())
663 m_JRELocations->push_back(rtl::OUString(sLocation));
664}
665
666const boost::optional<sal_Bool> & NodeJava::getEnabled() const
667{
668 return m_enabled;
669}
670
671const boost::optional<std::vector<rtl::OUString> >&
672NodeJava::getJRELocations() const
673{
674 return m_JRELocations;
675}
676
677const boost::optional<rtl::OUString> & NodeJava::getUserClassPath() const
678{
679 return m_userClassPath;
680}
681
682const boost::optional<std::vector<rtl::OUString> > & NodeJava::getVmParameters() const
683{
684 return m_vmParameters;
685}
686
687const boost::optional<CNodeJavaInfo> & NodeJava::getJavaInfo() const
688{
689 return m_javaInfo;
690}
691
692jfw::FileStatus NodeJava::checkSettingsFileStatus() const
693{
694 jfw::FileStatus ret = FILE_DOES_NOT_EXIST;
695
696 const rtl::OUString sURL = getSettingsURL();
697 //check the file time
698 ::osl::DirectoryItem item;
699 File::RC rc = ::osl::DirectoryItem::get(sURL, item);
700 if (File::E_None == rc)
701 {
702 ::osl::FileStatus stat(osl_FileStatus_Mask_Validate0x80000000);
703 File::RC rc_stat = item.getFileStatus(stat);
704 if (File::E_None == rc_stat)
705 {
706 ret = FILE_OK;
707 }
708 else if (File::E_NOENT == rc_stat)
709 {
710 ret = FILE_DOES_NOT_EXIST;
711 }
712 else
713 {
714 ret = FILE_INVALID;
715 }
716 }
717 else if(File::E_NOENT == rc)
718 {
719 ret = FILE_DOES_NOT_EXIST;
720 }
721 else
722 {
723 ret = FILE_INVALID;
724 }
725 return ret;
726}
727
728void NodeJava::createSettingsDocument() const
729{
730 const rtl::OUString sURL = getSettingsURL();
731 //make sure there is a user directory
732 rtl::OString sExcMsg("[Java framework] Error in function createSettingsDocument "
733 "(elements.cxx).");
734 // check if javasettings.xml already exist
735 if (FILE_OK == checkSettingsFileStatus())
736 return;
737
738 //make sure that the directories are created in case they do not exist
739 FileBase::RC rcFile = Directory::createPath(getDirFromFile(sURL));
740 if (rcFile != FileBase::E_EXIST && rcFile != FileBase::E_None)
741 throw FrameworkException(JFW_E_ERROR, sExcMsg);
742
743 //javasettings.xml does not exist yet
744 CXmlDocPtr doc(xmlNewDoc((xmlChar *)"1.0"));
745 if (! doc)
746 throw FrameworkException(JFW_E_ERROR, sExcMsg);
747 //Create a comment
748 xmlNewDocComment(
749 doc, (xmlChar *) "This is a generated file. Do not alter this file!");
750
751 //Create the root element and name spaces
752 xmlNodePtr root = xmlNewDocNode(
753 doc, NULL__null, (xmlChar *) "java", (xmlChar *) "\n");
754
755 if (root == NULL__null)
756 throw FrameworkException(JFW_E_ERROR, sExcMsg);
757
758 if (xmlNewNs(root, (xmlChar *) NS_JAVA_FRAMEWORK"http://openoffice.org/2004/java/framework/1.0",NULL__null) == NULL__null)
759 throw FrameworkException(JFW_E_ERROR, sExcMsg);
760 if (xmlNewNs(root,(xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance",(xmlChar*)"xsi") == NULL__null)
761 throw FrameworkException(JFW_E_ERROR, sExcMsg);
762 xmlDocSetRootElement(doc, root);
763
764 //Create a comment
765 xmlNodePtr com = xmlNewComment(
766 (xmlChar *) "This is a generated file. Do not alter this file!");
767 if (com == NULL__null)
768 throw FrameworkException(JFW_E_ERROR, sExcMsg);
769
770 if (xmlAddPrevSibling(root, com) == NULL__null)
771 throw FrameworkException(JFW_E_ERROR, sExcMsg);
772
773 const rtl::OString path = getSettingsPath();
774 if (xmlSaveFormatFileEnc(path.getStr(), doc,"UTF-8", 1) == -1)
775 throw FrameworkException(JFW_E_ERROR, sExcMsg);
776}
777
778//=====================================================================
779CNodeJavaInfo::CNodeJavaInfo() :
780 m_bEmptyNode(false), bNil(true), bAutoSelect(true),
781 nFeatures(0), nRequirements(0)
782{
783}
784
785CNodeJavaInfo::~CNodeJavaInfo()
786{
787}
788
789void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo)
790{
791 rtl::OString sExcMsg("[Java framework] Error in function NodeJavaInfo::loadFromNode "
792 "(elements.cxx).");
793
794 OSL_ASSERT(pJavaInfo && pDoc)do { if (true && (!(pJavaInfo && pDoc))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "794" ": "), "OSL_ASSERT: %s", "pJavaInfo && pDoc"
); } } while (false)
;
795 if (pJavaInfo->children == NULL__null)
796 return;
797 //Get the xsi:nil attribute;
798 CXmlCharPtr sNil;
799 sNil = xmlGetNsProp(
800 pJavaInfo, (xmlChar*) "nil", (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
801 if ( ! sNil)
802 throw FrameworkException(JFW_E_ERROR, sExcMsg);
803
804 if (xmlStrcmp(sNil, (xmlChar*) "true") == 0)
805 bNil = true;
806 else if (xmlStrcmp(sNil, (xmlChar*) "false") == 0)
807 bNil = false;
808 else
809 throw FrameworkException(JFW_E_ERROR, sExcMsg);
810 if (bNil == true)
811 return;
812
813 //Get javaInfo@manuallySelected attribute
814 CXmlCharPtr sAutoSelect;
815 sAutoSelect = xmlGetProp(
816 pJavaInfo, (xmlChar*) "autoSelect");
817 if ( ! sAutoSelect)
818 throw FrameworkException(JFW_E_ERROR, sExcMsg);
819
820 if (xmlStrcmp(sAutoSelect, (xmlChar*) "true") == 0)
821 bAutoSelect = true;
822 else if (xmlStrcmp(sAutoSelect, (xmlChar*) "false") == 0)
823 bAutoSelect = false;
824 else
825 throw FrameworkException(JFW_E_ERROR, sExcMsg);
826
827 xmlNode * cur = pJavaInfo->children;
828
829 while (cur != NULL__null)
830 {
831 if (xmlStrcmp(cur->name, (xmlChar*) "vendor") == 0)
832 {
833 CXmlCharPtr xmlVendor;
834 xmlVendor = xmlNodeListGetString(
835 pDoc, cur->children, 1);
836 if (! xmlVendor)
837 return;
838 sVendor = xmlVendor;
839 }
840 else if (xmlStrcmp(cur->name, (xmlChar*) "location") == 0)
841 {
842 CXmlCharPtr xmlLocation;
843 xmlLocation = xmlNodeListGetString(
844 pDoc, cur->children, 1);
845 sLocation = xmlLocation;
846 }
847 else if (xmlStrcmp(cur->name, (xmlChar*) "version") == 0)
848 {
849 CXmlCharPtr xmlVersion;
850 xmlVersion = xmlNodeListGetString(
851 pDoc, cur->children, 1);
852 sVersion = xmlVersion;
853 }
854 else if (xmlStrcmp(cur->name, (xmlChar*) "features")== 0)
855 {
856 CXmlCharPtr xmlFeatures;
857 xmlFeatures = xmlNodeListGetString(
858 pDoc, cur->children, 1);
859 rtl::OUString sFeatures = xmlFeatures;
860 nFeatures = sFeatures.toInt64(16);
861 }
862 else if (xmlStrcmp(cur->name, (xmlChar*) "requirements") == 0)
863 {
864 CXmlCharPtr xmlRequire;
865 xmlRequire = xmlNodeListGetString(
866 pDoc, cur->children, 1);
867 rtl::OUString sRequire = xmlRequire;
868 nRequirements = sRequire.toInt64(16);
869#ifdef MACOSX
870 //javaldx is not used anymore in the mac build. In case the Java
871 //corresponding to the saved settings does not exist anymore the
872 //javavm services will look for an existing Java after creation of
873 //the JVM failed. See stoc/source/javavm/javavm.cxx. Only if
874 //nRequirements does not have the flag JFW_REQUIRE_NEEDRESTART the
875 //jvm of the new selected JRE will be started. Old settings (before
876 //OOo 3.3) still contain the flag which can be safely ignored.
877 nRequirements &= ~JFW_REQUIRE_NEEDRESTART0x1l;
878#endif
879 }
880 else if (xmlStrcmp(cur->name, (xmlChar*) "vendorData") == 0)
881 {
882 CXmlCharPtr xmlData;
883 xmlData = xmlNodeListGetString(
884 pDoc, cur->children, 1);
885 xmlChar* _data = (xmlChar*) xmlData;
886 if (_data)
887 {
888 rtl::ByteSequence seq((sal_Int8*) _data, strlen((char*)_data));
889 arVendorData = decodeBase16(seq);
890 }
891 }
892 cur = cur->next;
893 }
894
895 if (sVendor.isEmpty())
896 m_bEmptyNode = true;
897 //Get the javainfo attributes
898 CXmlCharPtr sVendorUpdate;
899 sVendorUpdate = xmlGetProp(pJavaInfo,
900 (xmlChar*) "vendorUpdate");
901 if ( ! sVendorUpdate)
902 throw FrameworkException(JFW_E_ERROR, sExcMsg);
903 sAttrVendorUpdate = sVendorUpdate;
904}
905
906
907void CNodeJavaInfo::writeToNode(xmlDoc* pDoc,
908 xmlNode* pJavaInfoNode) const
909
910{
911 OSL_ASSERT(pJavaInfoNode && pDoc)do { if (true && (!(pJavaInfoNode && pDoc))) {
sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx" ":"
"911" ": "), "OSL_ASSERT: %s", "pJavaInfoNode && pDoc"
); } } while (false)
;
912 rtl::OString sExcMsg("[Java framework] Error in function NodeJavaInfo::writeToNode "
913 "(elements.cxx).");
914
915 //write the attribute vendorSettings
916
917 //javaInfo@vendorUpdate
918 //creates the attribute if necessary
919 rtl::OString sUpdated = getElementUpdated();
920
921 xmlSetProp(pJavaInfoNode, (xmlChar*)"vendorUpdate",
922 (xmlChar*) sUpdated.getStr());
923
924 //javaInfo@autoSelect
925 xmlSetProp(pJavaInfoNode, (xmlChar*)"autoSelect",
926 (xmlChar*) (bAutoSelect == true ? "true" : "false"));
927
928 //Set xsi:nil in javaInfo element to false
929 //the xmlNs pointer must not be destroyed
930 xmlNs* nsXsi = xmlSearchNsByHref((xmlDoc*) pDoc,
931 pJavaInfoNode,
932 (xmlChar*) NS_SCHEMA_INSTANCE"http://www.w3.org/2001/XMLSchema-instance");
933
934 xmlSetNsProp(pJavaInfoNode,
935 nsXsi,
936 (xmlChar*) "nil",
937 (xmlChar*) "false");
938
939 //Delete the children of JavaInfo
940 xmlNode* cur = pJavaInfoNode->children;
941 while (cur != NULL__null)
942 {
943 xmlNode* lastNode = cur;
944 cur = cur->next;
945 xmlUnlinkNode(lastNode);
946 xmlFreeNode(lastNode);
947 }
948
949 //If the JavaInfo was set with an empty value,
950 //then we are done.
951 if (m_bEmptyNode)
952 return;
953
954 //add a new line after <javaInfo>
955 xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
956 xmlAddChild(pJavaInfoNode, nodeCrLf);
957
958 //Create the vendor element
959 xmlNewTextChild(pJavaInfoNode, NULL__null, (xmlChar*) "vendor",
960 CXmlCharPtr(sVendor));
961 //add a new line for better readability
962 nodeCrLf = xmlNewText((xmlChar*) "\n");
963 xmlAddChild(pJavaInfoNode, nodeCrLf);
964
965 //Create the location element
966 xmlNewTextChild(pJavaInfoNode, NULL__null, (xmlChar*) "location",
967 CXmlCharPtr(sLocation));
968 //add a new line for better readability
969 nodeCrLf = xmlNewText((xmlChar*) "\n");
970 xmlAddChild(pJavaInfoNode, nodeCrLf);
971
972 //Create the version element
973 xmlNewTextChild(pJavaInfoNode, NULL__null, (xmlChar*) "version",
974 CXmlCharPtr(sVersion));
975 //add a new line for better readability
976 nodeCrLf = xmlNewText((xmlChar*) "\n");
977 xmlAddChild(pJavaInfoNode, nodeCrLf);
978
979 //Create the features element
980 rtl::OUString sFeatures = rtl::OUString::valueOf(
981 (sal_Int64)nFeatures, 16);
982 xmlNewTextChild(pJavaInfoNode, NULL__null, (xmlChar*) "features",
983 CXmlCharPtr(sFeatures));
984 //add a new line for better readability
985 nodeCrLf = xmlNewText((xmlChar*) "\n");
986 xmlAddChild(pJavaInfoNode, nodeCrLf);
987
988
989 //Create the requirements element
990 rtl::OUString sRequirements = rtl::OUString::valueOf(
991 (sal_Int64) nRequirements, 16);
992 xmlNewTextChild(pJavaInfoNode, NULL__null, (xmlChar*) "requirements",
993 CXmlCharPtr(sRequirements));
994 //add a new line for better readability
995 nodeCrLf = xmlNewText((xmlChar*) "\n");
996 xmlAddChild(pJavaInfoNode, nodeCrLf);
997
998
999 //Create the features element
1000 rtl::ByteSequence data = encodeBase16(arVendorData);
1001 xmlNode* dataNode = xmlNewChild(pJavaInfoNode, NULL__null,
1002 (xmlChar*) "vendorData",
1003 (xmlChar*) "");
1004 xmlNodeSetContentLen(dataNode,
1005 (xmlChar*) data.getArray(), data.getLength());
1006 //add a new line for better readability
1007 nodeCrLf = xmlNewText((xmlChar*) "\n");
1008 xmlAddChild(pJavaInfoNode, nodeCrLf);
1009}
1010
1011JavaInfo * CNodeJavaInfo::makeJavaInfo() const
1012{
1013 if (bNil == true || m_bEmptyNode == true)
1014 return NULL__null;
1015 JavaInfo * pInfo = (JavaInfo*) rtl_allocateMemory(sizeof(JavaInfo));
1016 if (pInfo == NULL__null)
1017 return NULL__null;
1018 memset(pInfo, 0, sizeof(JavaInfo));
1019 pInfo->sVendor = sVendor.pData;
1020 rtl_uString_acquire(pInfo->sVendor);
1021 pInfo->sLocation = sLocation.pData;
1022 rtl_uString_acquire(pInfo->sLocation);
1023 pInfo->sVersion = sVersion.pData;
1024 rtl_uString_acquire(pInfo->sVersion);
1025 pInfo->nFeatures = nFeatures;
1026 pInfo->nRequirements = nRequirements;
1027 pInfo->arVendorData = arVendorData.getHandle();
1028 rtl_byte_sequence_acquire(pInfo->arVendorData);
1029 return pInfo;
1030}
1031
1032//================================================================================
1033MergedSettings::MergedSettings():
1034 m_bEnabled(sal_False((sal_Bool)0)),
1035 m_sClassPath(),
1036 m_vmParams(),
1037 m_JRELocations(),
1038 m_javaInfo()
1039{
1040 NodeJava settings(NodeJava::USER);
1041 settings.load();
1042 NodeJava sharedSettings(NodeJava::SHARED);
1043 sharedSettings.load();
1044 merge(sharedSettings, settings);
1045}
1046
1047MergedSettings::~MergedSettings()
1048{
1049}
1050
1051void MergedSettings::merge(const NodeJava & share, const NodeJava & user)
1052{
1053 if (user.getEnabled())
1054 m_bEnabled = * user.getEnabled();
1055 else if (share.getEnabled())
1056 m_bEnabled = * share.getEnabled();
1057 else
1058 m_bEnabled = sal_True((sal_Bool)1);
1059
1060 if (user.getUserClassPath())
1061 m_sClassPath = * user.getUserClassPath();
1062 else if (share.getUserClassPath())
1063 m_sClassPath = * share.getUserClassPath();
1064
1065 if (user.getJavaInfo())
1066 m_javaInfo = * user.getJavaInfo();
1067 else if (share.getJavaInfo())
1068 m_javaInfo = * share.getJavaInfo();
1069
1070 if (user.getVmParameters())
1071 m_vmParams = * user.getVmParameters();
1072 else if (share.getVmParameters())
1073 m_vmParams = * share.getVmParameters();
1074
1075 if (user.getJRELocations())
1076 m_JRELocations = * user.getJRELocations();
1077 else if (share.getJRELocations())
1078 m_JRELocations = * share.getJRELocations();
1079}
1080
1081sal_Bool MergedSettings::getEnabled() const
1082{
1083 return m_bEnabled;
1084}
1085const rtl::OUString& MergedSettings::getUserClassPath() const
1086{
1087 return m_sClassPath;
1088}
1089
1090::std::vector< ::rtl::OString> MergedSettings::getVmParametersUtf8() const
1091{
1092 ::std::vector< ::rtl::OString> ret;
1093 typedef ::std::vector< ::rtl::OUString>::const_iterator cit;
1094 for (cit i = m_vmParams.begin(); i != m_vmParams.end(); ++i)
1095 {
1096 ret.push_back( ::rtl::OUStringToOString(*i, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))));
1097 }
1098 return ret;
1099}
1100
1101const ::rtl::OString & MergedSettings::getJavaInfoAttrVendorUpdate() const
1102{
1103 return m_javaInfo.sAttrVendorUpdate;
1104}
1105
1106
1107JavaInfo * MergedSettings::createJavaInfo() const
1108{
1109 return m_javaInfo.makeJavaInfo();
1110}
1111#ifdef WNT
1112bool MergedSettings::getJavaInfoAttrAutoSelect() const
1113{
1114 return m_javaInfo.bAutoSelect;
1115}
1116#endif
1117void MergedSettings::getVmParametersArray(
1118 rtl_uString *** parParams, sal_Int32 * size) const
1119{
1120 osl::MutexGuard guard(FwkMutex::get());
1121 OSL_ASSERT(parParams != NULL && size != NULL)do { if (true && (!(parParams != __null && size
!= __null))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "1121" ": "), "OSL_ASSERT: %s", "parParams != NULL && size != NULL"
); } } while (false)
;
1122
1123 *parParams = (rtl_uString **)
1124 rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size());
1125 if (*parParams == NULL__null)
1126 return;
1127
1128 int j=0;
1129 typedef std::vector<rtl::OUString>::const_iterator it;
1130 for (it i = m_vmParams.begin(); i != m_vmParams.end();
1131 ++i, ++j)
1132 {
1133 (*parParams)[j] = i->pData;
1134 rtl_uString_acquire(i->pData);
1135 }
1136 *size = m_vmParams.size();
1137}
1138
1139void MergedSettings::getJRELocations(
1140 rtl_uString *** parLocations, sal_Int32 * size) const
1141{
1142 osl::MutexGuard guard(FwkMutex::get());
1143 OSL_ASSERT(parLocations != NULL && size != NULL)do { if (true && (!(parLocations != __null &&
size != __null))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/usr/local/src/libreoffice/jvmfwk/source/elements.cxx"
":" "1143" ": "), "OSL_ASSERT: %s", "parLocations != NULL && size != NULL"
); } } while (false)
;
1
Within the expansion of the macro 'OSL_ASSERT':
a
Assuming pointer value is null
1144
1145 *parLocations = (rtl_uString **)
2
Dereference of null pointer (loaded from variable 'parLocations')
1146 rtl_allocateMemory(sizeof(rtl_uString*) * m_JRELocations.size());
1147 if (*parLocations == NULL__null)
1148 return;
1149
1150 int j=0;
1151 typedef std::vector<rtl::OUString>::const_iterator it;
1152 for (it i = m_JRELocations.begin(); i != m_JRELocations.end();
1153 ++i, ++j)
1154 {
1155 (*parLocations)[j] = i->pData;
1156 rtl_uString_acquire(i->pData);
1157 }
1158 *size = m_JRELocations.size();
1159}
1160const std::vector<rtl::OUString> & MergedSettings::getJRELocations() const
1161{
1162 return m_JRELocations;
1163}
1164}
1165
1166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */