Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
49614181
Kaydet (Commit)
49614181
authored
Nis 19, 2004
tarafından
Joachim Lingner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#i20052# plugin lib for java framework
üst
43cc8abf
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
3456 additions
and
0 deletions
+3456
-0
elements.cxx
jvmfwk/source/elements.cxx
+798
-0
elements.hxx
jvmfwk/source/elements.hxx
+273
-0
framework.cxx
jvmfwk/source/framework.cxx
+736
-0
framework.hxx
jvmfwk/source/framework.hxx
+136
-0
framework.map
jvmfwk/source/framework.map
+21
-0
fwkutil.cxx
jvmfwk/source/fwkutil.cxx
+767
-0
fwkutil.hxx
jvmfwk/source/fwkutil.hxx
+171
-0
javasettings.xsd
jvmfwk/source/javasettings.xsd
+48
-0
libxmlutil.cxx
jvmfwk/source/libxmlutil.cxx
+246
-0
libxmlutil.hxx
jvmfwk/source/libxmlutil.hxx
+161
-0
makefile.mk
jvmfwk/source/makefile.mk
+99
-0
No files found.
jvmfwk/source/elements.cxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: elements.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:54:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "elements.hxx"
#include "osl/mutex.hxx"
#include "fwkutil.hxx"
#include "libxmlutil.hxx"
#include "osl/thread.hxx"
#include "libxml/parser.h"
#include "libxml/xpath.h"
#include "libxml/xpathinternals.h"
#define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
#define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
namespace
jfw
{
//====================================================================
VersionInfo
::
VersionInfo
()
:
arVersions
(
NULL
)
{
}
VersionInfo
::~
VersionInfo
()
{
delete
[]
arVersions
;
}
void
VersionInfo
::
addExcludeVersion
(
const
rtl
::
OUString
&
sVersion
)
{
vecExcludeVersions
.
push_back
(
sVersion
);
}
rtl_uString
**
VersionInfo
::
getExcludeVersions
()
{
osl
::
MutexGuard
guard
(
getFwkMutex
());
if
(
arVersions
!=
NULL
)
return
arVersions
;
arVersions
=
new
rtl_uString
*
[
vecExcludeVersions
.
size
()];
int
j
=
0
;
typedef
std
::
vector
<
rtl
::
OUString
>::
const_iterator
it
;
for
(
it
i
=
vecExcludeVersions
.
begin
();
i
!=
vecExcludeVersions
.
end
();
i
++
,
j
++
)
{
arVersions
[
j
]
=
vecExcludeVersions
[
j
].
pData
;
}
return
arVersions
;
}
sal_Int32
VersionInfo
::
getExcludeVersionSize
()
{
return
vecExcludeVersions
.
size
();
}
//==================================================================
CNodeJava
::
CNodeJava
()
:
m_bEnabled
(
sal_True
),
m_bEnabledModified
(
false
),
m_bUserClassPathModified
(
false
),
m_bJavaInfoModified
(
false
),
m_bVmParametersModified
(
false
)
{
}
void
CNodeJava
::
getVmParametersArray
(
rtl_uString
***
parParams
,
sal_Int32
*
size
)
{
osl
::
MutexGuard
guard
(
getFwkMutex
());
OSL_ASSERT
(
parParams
!=
NULL
&&
size
!=
NULL
);
*
parParams
=
(
rtl_uString
**
)
rtl_allocateMemory
(
sizeof
(
rtl_uString
*
)
*
m_arVmParameters
.
size
());
if
(
*
parParams
==
NULL
)
return
;
int
j
=
0
;
typedef
std
::
vector
<
rtl
::
OString
>::
const_iterator
it
;
for
(
it
i
=
m_arVmParameters
.
begin
();
i
!=
m_arVmParameters
.
end
();
i
++
,
j
++
)
{
rtl
::
OUString
sParam
=
rtl
::
OStringToOUString
(
*
i
,
RTL_TEXTENCODING_UTF8
);
(
*
parParams
)[
j
]
=
sParam
.
pData
;
rtl_uString_acquire
(
sParam
.
pData
);
}
*
size
=
m_arVmParameters
.
size
();
}
javaFrameworkError
CNodeJava
::
loadFromSettings
()
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
// share settings may not be given
errcode
=
loadShareSettings
();
OSL_ASSERT
(
errcode
==
JFW_E_NONE
);
if
(
errcode
==
JFW_E_NONE
)
errcode
=
loadUserSettings
();
return
errcode
;
}
javaFrameworkError
CNodeJava
::
loadUserSettings
()
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
CXmlDocPtr
docUser
;
//Read the user elements
rtl
::
OString
sSettingsPath
=
jfw
::
getUserSettingsPath
();
//There must not be a share settings file
docUser
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
docUser
==
NULL
)
return
JFW_E_CONFIG_READWRITE
;
xmlNode
*
cur
=
xmlDocGetRootElement
(
docUser
);
if
(
cur
==
NULL
||
cur
->
children
==
NULL
)
return
JFW_E_FORMAT_STORE
;
cur
=
cur
->
children
;
while
(
cur
!=
NULL
)
{
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"enabled"
)
==
0
)
{
//only overwrite share settings if xsi:nil="false"
CXmlCharPtr
sNil
=
xmlGetNsProp
(
cur
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
sNil
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_FORMAT_STORE
;
}
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
{
CXmlCharPtr
sEnabled
=
xmlNodeListGetString
(
docUser
,
cur
->
children
,
1
);
if
(
xmlStrcmp
(
sEnabled
,
(
xmlChar
*
)
"true"
)
==
0
)
m_bEnabled
=
sal_True
;
else
if
(
xmlStrcmp
(
sEnabled
,
(
xmlChar
*
)
"false"
)
==
0
)
m_bEnabled
=
sal_False
;
else
m_bEnabled
=
sal_True
;
}
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"classesDirectory"
)
==
0
)
{
CXmlCharPtr
sCls
=
xmlNodeListGetString
(
docUser
,
cur
->
children
,
1
);
m_sClassesDirectory
=
sCls
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"userClassPath"
)
==
0
)
{
CXmlCharPtr
sNil
=
xmlGetNsProp
(
cur
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
sNil
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_FORMAT_STORE
;
}
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
{
CXmlCharPtr
sUser
=
xmlNodeListGetString
(
docUser
,
cur
->
children
,
1
);
m_sUserClassPath
=
sUser
;
}
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"javaInfo"
)
==
0
)
{
CXmlCharPtr
sNil
=
xmlGetNsProp
(
cur
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
sNil
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_FORMAT_STORE
;
}
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
{
m_aInfo
.
loadFromNode
(
docUser
,
cur
);
}
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"vmParameters"
)
==
0
)
{
CXmlCharPtr
sNil
=
xmlGetNsProp
(
cur
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
sNil
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_FORMAT_STORE
;
}
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
{
//throw away share settings
m_arVmParameters
.
clear
();
xmlNode
*
pOpt
=
cur
->
children
;
while
(
pOpt
!=
NULL
)
{
if
(
xmlStrcmp
(
pOpt
->
name
,
(
xmlChar
*
)
"param"
)
==
0
)
{
CXmlCharPtr
sOpt
=
xmlNodeListGetString
(
docUser
,
pOpt
->
children
,
1
);
m_arVmParameters
.
push_back
(
sOpt
);
}
pOpt
=
pOpt
->
next
;
}
}
}
cur
=
cur
->
next
;
}
return
errcode
;
}
javaFrameworkError
CNodeJava
::
loadShareSettings
()
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
CXmlDocPtr
docShare
;
//Read the share elements, do not head the nil attributes
rtl
::
OString
sSettingsPath
=
jfw
::
getSharedSettingsPath
();
//There must not be a share settings file
docShare
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
docShare
==
NULL
)
return
JFW_E_NONE
;
xmlNode
*
cur
=
xmlDocGetRootElement
(
docShare
);
if
(
cur
==
NULL
)
{
OSL_ASSERT
(
cur
);
return
JFW_E_FORMAT_STORE
;
}
if
(
cur
->
children
==
NULL
)
return
JFW_E_NONE
;
cur
=
cur
->
children
;
while
(
cur
!=
NULL
)
{
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"enabled"
)
==
0
)
{
CXmlCharPtr
sEnabled
=
xmlNodeListGetString
(
docShare
,
cur
->
children
,
1
);
if
(
xmlStrcmp
(
sEnabled
,
(
xmlChar
*
)
"true"
)
==
0
)
m_bEnabled
=
sal_True
;
else
if
(
xmlStrcmp
(
sEnabled
,
(
xmlChar
*
)
"false"
)
==
0
)
m_bEnabled
=
sal_False
;
else
m_bEnabled
=
sal_True
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"classesDirectory"
)
==
0
)
{
CXmlCharPtr
sCls
=
xmlNodeListGetString
(
docShare
,
cur
->
children
,
1
);
m_sClassesDirectory
=
sCls
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"userClassPath"
)
==
0
)
{
CXmlCharPtr
sUser
=
xmlNodeListGetString
(
docShare
,
cur
->
children
,
1
);
m_sUserClassPath
=
sUser
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"javaInfo"
)
==
0
)
{
m_aInfo
.
loadFromNode
(
docShare
,
cur
);
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"vmParameters"
)
==
0
)
{
CXmlCharPtr
sNil
=
xmlGetNsProp
(
cur
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
sNil
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_FORMAT_STORE
;
}
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
{
xmlNode
*
pOpt
=
cur
->
children
;
while
(
pOpt
!=
NULL
)
{
if
(
xmlStrcmp
(
pOpt
->
name
,
(
xmlChar
*
)
"param"
)
==
0
)
{
CXmlCharPtr
sOpt
=
xmlNodeListGetString
(
docShare
,
pOpt
->
children
,
1
);
m_arVmParameters
.
push_back
(
sOpt
);
}
pOpt
=
pOpt
->
next
;
}
}
}
cur
=
cur
->
next
;
}
return
errcode
;
}
javaFrameworkError
CNodeJava
::
writeSettings
()
const
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
CXmlDocPtr
docUser
;
CXPathContextPtr
contextUser
;
CXPathObjectPtr
pathObj
;
//Read the user elements
rtl
::
OString
sSettingsPath
=
jfw
::
getUserSettingsPath
();
docUser
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
docUser
==
NULL
)
return
JFW_E_CONFIG_READWRITE
;
contextUser
=
xmlXPathNewContext
(
docUser
);
if
(
xmlXPathRegisterNs
(
contextUser
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
)
==
-
1
)
return
JFW_E_CONFIG_READWRITE
;
xmlNode
*
root
=
xmlDocGetRootElement
(
docUser
);
//Get xsi:nil namespace
xmlNs
*
nsXsi
=
xmlSearchNsByHref
(
docUser
,
root
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
//set the <enabled> element
//The element must exist
if
(
m_bEnabledModified
)
{
rtl
::
OString
sExpression
=
rtl
::
OString
(
"/jf:java/jf:enabled"
);
pathObj
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpression
.
getStr
(),
contextUser
);
if
(
!
pathObj
||
xmlXPathNodeSetIsEmpty
(
pathObj
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
xmlNode
*
nodeEnabled
=
pathObj
->
nodesetval
->
nodeTab
[
0
];
xmlSetNsProp
(
nodeEnabled
,
nsXsi
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
"false"
);
if
(
m_bEnabled
==
sal_True
)
xmlNodeSetContent
(
nodeEnabled
,(
xmlChar
*
)
"true"
);
else
xmlNodeSetContent
(
nodeEnabled
,(
xmlChar
*
)
"false"
);
}
//set the <userClassPath> element
//The element must exist
if
(
m_bUserClassPathModified
)
{
rtl
::
OString
sExpression
=
rtl
::
OString
(
"/jf:java/jf:userClassPath"
);
pathObj
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpression
.
getStr
(),
contextUser
);
if
(
!
pathObj
||
xmlXPathNodeSetIsEmpty
(
pathObj
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
xmlNode
*
nodeEnabled
=
pathObj
->
nodesetval
->
nodeTab
[
0
];
xmlSetNsProp
(
nodeEnabled
,
nsXsi
,
(
xmlChar
*
)
"nil"
,(
xmlChar
*
)
"false"
);
rtl
::
OString
osUserCP
=
rtl
::
OUStringToOString
(
m_sUserClassPath
,
osl_getThreadTextEncoding
());
xmlNodeSetContent
(
nodeEnabled
,(
xmlChar
*
)
osUserCP
.
getStr
());
}
//set <javaInfo> element
if
(
m_bJavaInfoModified
)
{
rtl
::
OString
sExpression
=
rtl
::
OString
(
"/jf:java/jf:javaInfo"
);
pathObj
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpression
.
getStr
(),
contextUser
);
if
(
!
pathObj
||
xmlXPathNodeSetIsEmpty
(
pathObj
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
errcode
=
m_aInfo
.
writeToNode
(
docUser
,
pathObj
->
nodesetval
->
nodeTab
[
0
]);
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
}
//set <vmParameters> element
if
(
m_bVmParametersModified
)
{
rtl
::
OString
sExpression
=
rtl
::
OString
(
"/jf:java/jf:vmParameters"
);
pathObj
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpression
.
getStr
(),
contextUser
);
if
(
!
pathObj
||
xmlXPathNodeSetIsEmpty
(
pathObj
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
xmlNode
*
vmParameters
=
pathObj
->
nodesetval
->
nodeTab
[
0
];
//set xsi:nil = false;
xmlSetNsProp
(
vmParameters
,
nsXsi
,(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
"false"
);
//remove option elements
xmlNode
*
cur
=
vmParameters
->
children
;
while
(
cur
!=
NULL
)
{
xmlNode
*
lastNode
=
cur
;
cur
=
cur
->
next
;
xmlUnlinkNode
(
lastNode
);
xmlFreeNode
(
lastNode
);
}
//add a new line after <vmParameters>
if
(
m_arVmParameters
.
size
()
>
0
)
{
xmlNode
*
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
vmParameters
,
nodeCrLf
);
}
typedef
std
::
vector
<
rtl
::
OString
>::
const_iterator
cit
;
for
(
cit
i
=
m_arVmParameters
.
begin
();
i
!=
m_arVmParameters
.
end
();
i
++
)
{
xmlNewTextChild
(
vmParameters
,
NULL
,
(
xmlChar
*
)
"option"
,
(
xmlChar
*
)
i
->
getStr
());
//add a new line
xmlNode
*
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
vmParameters
,
nodeCrLf
);
}
}
//set <userClassPath>, element must exist
// sExpression =
if
(
xmlSaveFormatFile
(
sSettingsPath
.
getStr
(),
docUser
,
1
)
==
-
1
)
return
JFW_E_CONFIG_READWRITE
;
return
JFW_E_NONE
;
}
void
CNodeJava
::
setEnabled
(
sal_Bool
bEnabled
)
{
m_bEnabled
=
bEnabled
;
m_bEnabledModified
=
true
;
}
sal_Bool
CNodeJava
::
getEnabled
()
const
{
return
m_bEnabled
;
}
void
CNodeJava
::
setUserClassPath
(
const
rtl
::
OUString
&
sClassPath
)
{
m_sUserClassPath
=
sClassPath
;
m_bUserClassPathModified
=
true
;
}
rtl
::
OUString
const
&
CNodeJava
::
getUserClassPath
()
const
{
return
m_sUserClassPath
;
}
void
CNodeJava
::
setJavaInfo
(
const
JavaInfo
*
pInfo
,
const
rtl
::
OUString
&
sVendorUpdate
)
{
OSL_ASSERT
(
sVendorUpdate
.
getLength
()
>
0
);
m_aInfo
.
bNil
=
false
;
m_aInfo
.
sAttrVendorUpdate
=
sVendorUpdate
;
if
(
pInfo
!=
NULL
)
{
m_aInfo
.
m_bEmptyNode
=
false
;
m_aInfo
.
sVendor
=
pInfo
->
sVendor
;
m_aInfo
.
sLocation
=
pInfo
->
sLocation
;
m_aInfo
.
sVersion
=
pInfo
->
sVersion
;
m_aInfo
.
nFeatures
=
pInfo
->
nFeatures
;
m_aInfo
.
nRequirements
=
pInfo
->
nRequirements
;
m_aInfo
.
arVendorData
=
pInfo
->
arVendorData
;
}
else
{
m_aInfo
.
m_bEmptyNode
=
true
;
rtl
::
OUString
sEmpty
;
m_aInfo
.
sVendor
=
sEmpty
;
m_aInfo
.
sLocation
=
sEmpty
;
m_aInfo
.
sVersion
=
sEmpty
;
m_aInfo
.
nFeatures
=
0
;
m_aInfo
.
nRequirements
=
0
;
m_aInfo
.
arVendorData
=
rtl
::
ByteSequence
();
}
m_bJavaInfoModified
=
true
;
}
JavaInfo
*
CNodeJava
::
getJavaInfo
()
const
{
return
m_aInfo
.
makeJavaInfo
();
}
rtl
::
OUString
const
&
CNodeJava
::
getJavaInfoAttrVendorUpdate
()
const
{
return
m_aInfo
.
sAttrVendorUpdate
;
}
const
std
::
vector
<
rtl
::
OString
>
&
CNodeJava
::
getVmParameters
()
{
return
m_arVmParameters
;
}
void
CNodeJava
::
setVmParameters
(
rtl_uString
*
*
arOptions
,
sal_Int32
size
)
{
OSL_ASSERT
(
!
(
arOptions
==
0
&&
size
!=
0
));
m_arVmParameters
.
clear
();
if
(
arOptions
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
const
rtl
::
OUString
usOption
=
(
rtl_uString
*
)
arOptions
[
i
];
rtl
::
OString
osOption
=
rtl
::
OUStringToOString
(
usOption
,
RTL_TEXTENCODING_UTF8
);
m_arVmParameters
.
push_back
(
osOption
);
}
}
m_bVmParametersModified
=
true
;
}
//=====================================================================
CNodeJavaInfo
::
CNodeJavaInfo
()
:
nFeatures
(
0
),
nRequirements
(
0
),
bNil
(
true
),
m_bEmptyNode
(
false
)
{
}
CNodeJavaInfo
::~
CNodeJavaInfo
()
{
}
CNodeJavaInfo
::
CNodeJavaInfo
(
const
JavaInfo
*
pInfo
,
const
rtl
::
OUString
&
sUpdated
)
{
if
(
pInfo
!=
NULL
)
{
sAttrVendorUpdate
=
sUpdated
;
sVendor
=
pInfo
->
sVendor
;
sLocation
=
pInfo
->
sLocation
;
sVersion
=
pInfo
->
sVersion
;
nFeatures
=
pInfo
->
nFeatures
;
nRequirements
=
pInfo
->
nRequirements
;
arVendorData
=
pInfo
->
arVendorData
;
}
}
javaFrameworkError
CNodeJavaInfo
::
loadFromNode
(
xmlDoc
*
pDoc
,
xmlNode
*
pJavaInfo
)
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
OSL_ASSERT
(
pJavaInfo
&&
pDoc
);
if
(
pJavaInfo
->
children
==
NULL
)
return
JFW_E_NONE
;
//Get the xsi:nil attribute;
CXmlCharPtr
sNil
=
xmlGetNsProp
(
pJavaInfo
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
if
(
!
sNil
)
return
JFW_E_FORMAT_STORE
;
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"true"
)
==
0
)
bNil
=
true
;
else
if
(
xmlStrcmp
(
sNil
,
(
xmlChar
*
)
"false"
)
==
0
)
bNil
=
false
;
else
return
JFW_E_FORMAT_STORE
;
if
(
bNil
==
true
)
return
JFW_E_NONE
;
xmlNode
*
cur
=
pJavaInfo
->
children
;
while
(
cur
!=
NULL
)
{
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"vendor"
)
==
0
)
{
CXmlCharPtr
xmlVendor
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
if
(
!
xmlVendor
)
return
JFW_E_NONE
;
sVendor
=
xmlVendor
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"location"
)
==
0
)
{
CXmlCharPtr
xmlLocation
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
sLocation
=
xmlLocation
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"version"
)
==
0
)
{
CXmlCharPtr
xmlVersion
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
sVersion
=
xmlVersion
;
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"features"
)
==
0
)
{
CXmlCharPtr
xmlFeatures
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
rtl
::
OUString
sFeatures
=
xmlFeatures
;
nFeatures
=
sFeatures
.
toInt64
(
16
);
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"requirements"
)
==
0
)
{
CXmlCharPtr
xmlRequire
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
rtl
::
OUString
sRequire
=
xmlRequire
;
nRequirements
=
sRequire
.
toInt64
(
16
);
}
else
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"vendorData"
)
==
0
)
{
CXmlCharPtr
xmlData
=
xmlNodeListGetString
(
pDoc
,
cur
->
children
,
1
);
xmlChar
*
_data
=
(
xmlChar
*
)
xmlData
;
if
(
_data
)
{
rtl
::
ByteSequence
seq
((
sal_Int8
*
)
_data
,
strlen
((
char
*
)
_data
));
arVendorData
=
decodeBase16
(
seq
);
}
}
cur
=
cur
->
next
;
}
//Get the javainfo attributes
CXmlCharPtr
sVendorUpdate
=
xmlGetProp
(
pJavaInfo
,
(
xmlChar
*
)
"vendorUpdate"
);
if
(
!
sVendorUpdate
)
return
JFW_E_FORMAT_STORE
;
sAttrVendorUpdate
=
sVendorUpdate
;
return
errcode
;
}
javaFrameworkError
CNodeJavaInfo
::
writeToNode
(
xmlDoc
*
pDoc
,
xmlNode
*
pJavaInfoNode
)
const
{
OSL_ASSERT
(
pJavaInfoNode
&&
pDoc
);
javaFrameworkError
errcode
=
JFW_E_NONE
;
//write the attribute vendorSettings
rtl
::
OString
osUpdate
=
rtl
::
OUStringToOString
(
sAttrVendorUpdate
,
osl_getThreadTextEncoding
());
//creates the attribute if necessary
xmlSetProp
(
pJavaInfoNode
,
(
xmlChar
*
)
"vendorUpdate"
,
(
xmlChar
*
)
osUpdate
.
getStr
());
//Set xsi:nil in javaInfo element to false
//the xmlNs pointer must not be destroyed
xmlNs
*
nsXsi
=
xmlSearchNsByHref
((
xmlDoc
*
)
pDoc
,
pJavaInfoNode
,
(
xmlChar
*
)
NS_SCHEMA_INSTANCE
);
xmlSetNsProp
(
pJavaInfoNode
,
nsXsi
,
(
xmlChar
*
)
"nil"
,
(
xmlChar
*
)
"false"
);
//Check if the JavaInfo was set with an empty value, then all
//children are deleted
if
(
m_bEmptyNode
&&
pJavaInfoNode
->
children
!=
NULL
)
{
xmlNode
*
cur
=
pJavaInfoNode
->
children
;
while
(
cur
!=
NULL
)
{
xmlNode
*
lastNode
=
cur
;
cur
=
cur
->
next
;
xmlUnlinkNode
(
lastNode
);
xmlFreeNode
(
lastNode
);
}
return
errcode
;
}
//add a new line after <javaInfo>
xmlNode
*
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the vendor element
rtl
::
OString
osVendor
=
rtl
::
OUStringToOString
(
sVendor
,
osl_getThreadTextEncoding
());
xmlNewTextChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"vendor"
,
(
xmlChar
*
)
osVendor
.
getStr
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the location element
rtl
::
OString
osLocation
=
rtl
::
OUStringToOString
(
sLocation
,
osl_getThreadTextEncoding
());
xmlNewTextChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"location"
,
(
xmlChar
*
)
osLocation
.
getStr
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the version element
rtl
::
OString
osVersion
=
rtl
::
OUStringToOString
(
sVersion
,
osl_getThreadTextEncoding
());
xmlNewTextChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"version"
,
(
xmlChar
*
)
osVersion
.
getStr
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the features element
rtl
::
OUString
usFeatures
=
rtl
::
OUString
::
valueOf
(
(
sal_Int64
)
nFeatures
,
16
);
rtl
::
OString
sFeatures
=
rtl
::
OUStringToOString
(
usFeatures
,
osl_getThreadTextEncoding
());
xmlNewTextChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"features"
,
(
xmlChar
*
)
sFeatures
.
getStr
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the requirements element
rtl
::
OUString
usRequirements
=
rtl
::
OUString
::
valueOf
(
(
sal_Int64
)
nRequirements
,
16
);
rtl
::
OString
sRequirements
=
rtl
::
OUStringToOString
(
usRequirements
,
osl_getThreadTextEncoding
());
xmlNewTextChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"requirements"
,
(
xmlChar
*
)
sRequirements
.
getStr
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
//Create the features element
rtl
::
ByteSequence
data
=
encodeBase16
(
arVendorData
);
xmlNode
*
dataNode
=
xmlNewChild
(
pJavaInfoNode
,
NULL
,
(
xmlChar
*
)
"vendorData"
,
(
xmlChar
*
)
""
);
xmlNodeSetContentLen
(
dataNode
,
(
xmlChar
*
)
data
.
getArray
(),
data
.
getLength
());
//add a new line for better readability
nodeCrLf
=
xmlNewText
((
xmlChar
*
)
"
\n
"
);
xmlAddChild
(
pJavaInfoNode
,
nodeCrLf
);
return
JFW_E_NONE
;
}
JavaInfo
*
CNodeJavaInfo
::
makeJavaInfo
()
const
{
if
(
bNil
==
true
)
return
NULL
;
JavaInfo
*
pInfo
=
(
JavaInfo
*
)
rtl_allocateMemory
(
sizeof
JavaInfo
);
if
(
pInfo
==
NULL
)
return
NULL
;
memset
(
pInfo
,
0
,
sizeof
JavaInfo
);
pInfo
->
sVendor
=
sVendor
.
pData
;
rtl_uString_acquire
(
pInfo
->
sVendor
);
pInfo
->
sLocation
=
sLocation
.
pData
;
rtl_uString_acquire
(
pInfo
->
sLocation
);
pInfo
->
sVersion
=
sVersion
.
pData
;
rtl_uString_acquire
(
pInfo
->
sVersion
);
pInfo
->
nFeatures
=
nFeatures
;
pInfo
->
nRequirements
=
nRequirements
;
pInfo
->
arVendorData
=
arVendorData
.
getHandle
();
rtl_byte_sequence_acquire
(
pInfo
->
arVendorData
);
return
pInfo
;
}
}
jvmfwk/source/elements.hxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: elements.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#if !defined INCLUDED_JVMFWK_ELEMENTS_HXX
#define INCLUDED_JVMFWK_ELEMENTS_HXX
#include <vector>
#include "jvmfwk/framework.h"
#include "rtl/ustring.hxx"
#include "rtl/byteseq.hxx"
#include "libxml/parser.h"
namespace
jfw
{
class
CXmlCharPtr
;
class
CNodeJavaInfo
{
public
:
CNodeJavaInfo
();
~
CNodeJavaInfo
();
/**
sUpdated is the value from the <updated> element from the
javavendors.xml.
*/
CNodeJavaInfo
(
const
JavaInfo
*
pInfo
,
const
rtl
::
OUString
&
sUpdated
);
/** if true, then javaInfo is empty. When writeToNode is called
then all child elements are deleted.
*/
bool
m_bEmptyNode
;
/** Contains the value of the <updated> element of
the javavendors.xml
*/
rtl
::
OUString
sAttrVendorUpdate
;
/** contains the nil value of the /java/javaInfo@xsi:nil attribute.
Default is true;
*/
bool
bNil
;
rtl
::
OUString
sVendor
;
rtl
::
OUString
sLocation
;
rtl
::
OUString
sVersion
;
sal_uInt64
nFeatures
;
sal_uInt64
nRequirements
;
rtl
::
ByteSequence
arVendorData
;
/** reads the node /java/javaInfo.
If javaInfo@xsi:nil = true then member bNil is set to true
an no further elements are read.
*/
javaFrameworkError
loadFromNode
(
xmlDoc
*
pDoc
,
xmlNode
*
pJavaInfo
);
/** Only writes user settings. The attribut nil always gets the value
false;
*/
javaFrameworkError
writeToNode
(
xmlDoc
*
pDoc
,
xmlNode
*
pJavaInfo
)
const
;
/** returns NULL if javaInfo is nil in both, user and share, settings.
*/
JavaInfo
*
makeJavaInfo
()
const
;
};
/** this class represents the javasettings.xml file
*/
class
CNodeJava
{
/** Share settings are a special case. Per default
there are only user settings.
*/
javaFrameworkError
loadShareSettings
();
/** This function is called after loadShareSettings. Elements which have been
modified by the user, that is, the attribute xsi:nil = false, overwrite the
values which have been retrieved with loadShareSettings.
*/
javaFrameworkError
loadUserSettings
();
/** User configurable option. /java/enabled
The value is valid after loadFromSettings has been called
successfully.
The value is that of the user setting. If it is nil
(/java/enabled[@xsi:nil = true]) then it represents the share setting.
If there are no share settings or the node is also nil then the default
is true.
*/
sal_Bool
m_bEnabled
;
/** Determines if m_bEnabled has been modified */
bool
m_bEnabledModified
;
/** User configurable option. /java/userClassPath
The value is valid after loadFromSettings has been called successfully.
The value is that of the user setting. If it is nil
(/java/userClassPath[@xsi:nil = true]) then it represents the share setting.
If there are no share settings or the node is also nil then the default
is an empty string.
*/
rtl
::
OUString
m_sUserClassPath
;
/** Determines if m_sUserClassPath has been modified */
bool
m_bUserClassPathModified
;
/** User configurable option. /java/javaInfo
The value is valid after loadFromSettings has been called successfully.
The value is that of the user setting. If it is nil
(/java/javaInfo[@xsi:nil = true]) then it represents the share setting.
If there are no share settings then the structure is regarded as empty.
*/
CNodeJavaInfo
m_aInfo
;
/** Determines if m_aInfo has been modified */
bool
m_bJavaInfoModified
;
/** User configurable option. /java/vmParameters
The value is valid after loadFromSettings has been called successfully.
The value is that of the user setting. If it is nil
(/java/vmParameters[@xsi:nil = true]) then it represents the share setting.
If there are no share settings then array is empty.
*/
std
::
vector
<
rtl
::
OString
>
m_arVmParameters
;
bool
m_bVmParametersModified
;
public
:
// Preset element (cannot be changed. /java/classesDirectory
rtl
::
OUString
m_sClassesDirectory
;
CNodeJava
();
/** sets m_bEnabled. It also sets a flag, that the value has been
modified. This will cause that /java/enabled[@xsi:nil] will be
set to false. The nil value and the value of enabled are only
written when write Settings is called.
*/
void
setEnabled
(
sal_Bool
bEnabled
);
/** returns the value of the element /java/enabled
*/
sal_Bool
getEnabled
()
const
;
/** sets m_sUserClassPath. Analog to setEnabled.
*/
void
setUserClassPath
(
const
rtl
::
OUString
&
sClassPath
);
/** returns the value of the element /java/userClassPath.
*/
rtl
::
OUString
const
&
getUserClassPath
()
const
;
/** sets m_aInfo. Analog to setEnabled.
@param sVendorUpdated
The date string that is written to /java/javaInfo@vendorUpdate
The string is the same as the value of /javaSettings/updated in javavendors.xml
*/
void
setJavaInfo
(
const
JavaInfo
*
pInfo
,
const
rtl
::
OUString
&
sVendorUpdated
);
/** returns a JavaInfo structure representing the node
/java/javaInfo
If both, user and share settings are nil, then NULL is returned.
*/
JavaInfo
*
getJavaInfo
()
const
;
/** returns the value of the attribute /java/javaInfo[@vendorUpdate].
*/
rtl
::
OUString
const
&
getJavaInfoAttrVendorUpdate
()
const
;
/** sets the /java/vmParameters/param elements.
The values are kept in a vector m_arVmParameters. When this method is
called then the vector is cleared and the new values are inserted.
The xsi:nil attribute of vmParameters will be set to true;
*/
void
setVmParameters
(
rtl_uString
*
*
arParameters
,
sal_Int32
size
);
/** returns the parameters from the element /java/vmParameters/param.
*/
const
std
::
vector
<
rtl
::
OString
>
&
getVmParameters
();
/** reads user and share settings. user data supersede
share data. These elements can be changed by the user:
<enabled>, <userClasspath>, <javaInfo>, <vmParameters>
If the user has not changed them then the nil attribute is
set to true;
*/
javaFrameworkError
loadFromSettings
();
/** writes the data to user settings.
*/
javaFrameworkError
writeSettings
()
const
;
/** returns an array.
Caller must free the strings and the array.
*/
void
getVmParametersArray
(
rtl_uString
***
parParameters
,
sal_Int32
*
size
);
};
class
VersionInfo
{
std
::
vector
<
rtl
::
OUString
>
vecExcludeVersions
;
rtl_uString
**
arVersions
;
public
:
VersionInfo
();
~
VersionInfo
();
void
addExcludeVersion
(
const
rtl
::
OUString
&
sVersion
);
rtl
::
OUString
sMinVersion
;
rtl
::
OUString
sMaxVersion
;
/** The caller DOES NOT get ownership of the strings. That is he
does not need to release the strings.
The array exists as long as this object exists.
*/
rtl_uString
**
getExcludeVersions
();
sal_Int32
getExcludeVersionSize
();
};
struct
PluginLibrary
{
/** contains the vendor string which is later userd in the xml API
*/
rtl
::
OString
sVendor
;
/** File URL the plug-in library
*/
rtl
::
OUString
sPath
;
};
}
//end namespace
#endif
jvmfwk/source/framework.cxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: framework.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "external/boost/scoped_array.hpp"
#include "rtl/ustring.hxx"
#include "rtl/ustrbuf.hxx"
#include "osl/thread.hxx"
#include "osl/module.hxx"
#include "sal/config.h"
#include "jvmfwk/framework.h"
#include "jvmfwk/vendorplugin.h"
#include "osl/mutex.hxx"
#include "libxml/parser.h"
#include "libxml/xpath.h"
#include "libxml/xpathinternals.h"
#include <vector>
#include "jni.h"
#include "framework.hxx"
#include "libxmlutil.hxx"
#include "fwkutil.hxx"
#include "elements.hxx"
//#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#ifdef WNT
/** The existence of the file useatjava.txt decides if a Java should be used
that supports accessibility tools.
*/
#define USE_ACCESSIBILITY_FILE "useatjava.txt"
#endif
namespace
{
JavaVM
*
g_pJavaVM
=
NULL
;
}
javaFrameworkError
SAL_CALL
jfw_startJava
(
JavaVMOption
*
arOptions
,
sal_Int32
cOptions
,
JavaVM
**
ppVM
,
JNIEnv
**
ppEnv
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
//We keep this pointer so we can determine if a VM has already
//been created.
if
(
g_pJavaVM
!=
NULL
)
return
JFW_E_RUNNING_JVM
;
if
(
ppVM
==
NULL
)
return
JFW_E_INVALID_ARG
;
jfw
::
CNodeJava
javaSettings
;
if
((
errcode
=
javaSettings
.
loadFromSettings
())
!=
JFW_E_NONE
)
return
errcode
;
//get the current java setting (javaInfo)
jfw
::
CJavaInfo
aInfo
=
javaSettings
.
getJavaInfo
();
//check if a Java has ever been selected
if
(
aInfo
==
NULL
)
return
JFW_E_NO_SELECT
;
//check if the javavendors.xml has changed after a Java was selected
rtl
::
OUString
sVendorUpdate
;
if
((
errcode
=
jfw
::
getElementUpdated
(
sVendorUpdate
))
!=
JFW_E_NONE
)
return
errcode
;
if
(
sVendorUpdate
!=
javaSettings
.
getJavaInfoAttrVendorUpdate
())
return
JFW_E_INVALID_SETTINGS
;
//Check if the selected Java was set in this process. If so it
//must not have the requirments flag JFW_REQUIRE_NEEDRESTART
if
((
aInfo
->
nRequirements
&
JFW_REQUIRE_NEEDRESTART
)
&&
(
jfw
::
wasJavaSelectedInSameProcess
()
==
true
))
return
JFW_E_NEED_RESTART
;
//get the function startJavaVirtualMachine
rtl
::
OUString
sLibPath
;
if
((
errcode
=
jfw
::
getPluginLibrary
(
sLibPath
))
!=
JFW_E_NONE
)
return
errcode
;
osl
::
Module
modulePlugin
(
sLibPath
);
if
(
!
modulePlugin
)
return
JFW_E_NO_PLUGIN
;
rtl
::
OUString
sFunctionName
(
RTL_CONSTASCII_USTRINGPARAM
(
"startJavaVirtualMachine"
));
startJavaVirtualMachine_ptr
pFunc
=
(
startJavaVirtualMachine_ptr
)
osl_getSymbol
(
modulePlugin
,
sFunctionName
.
pData
);
if
(
pFunc
==
NULL
)
return
JFW_E_ERROR
;
//Compose the class path
rtl
::
OUStringBuffer
sBufCP
(
4096
);
//build the class path from the classes directory
rtl
::
OUString
sClassPath
;
errcode
=
jfw
::
buildClassPathFromDirectory
(
javaSettings
.
m_sClassesDirectory
,
sClassPath
);
if
(
errcode
!=
JFW_E_NONE
)
return
JFW_E_ERROR
;
sBufCP
.
append
(
sClassPath
);
// append all user selected jars to the classpath
if
(
javaSettings
.
getUserClassPath
().
getLength
()
!=
0
)
{
char
szSep
[]
=
{
SAL_PATHSEPARATOR
,
0
};
sBufCP
.
appendAscii
(
szSep
);
sBufCP
.
append
(
javaSettings
.
getUserClassPath
());
}
//add the path of the UNO components
rtl
::
OUString
sComponents
=
jfw
::
retrieveClassPath
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"${$PKG_SharedUnoFile:UNO_JAVA_CLASSPATH}"
)));
sBufCP
.
append
(
sComponents
);
sComponents
=
jfw
::
retrieveClassPath
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"${$PKG_UserUnoFile:UNO_JAVA_CLASSPATH}"
)));
sBufCP
.
append
(
sComponents
);
rtl
::
OString
sOptionClassPath
(
"-Djava.class.path="
);
sOptionClassPath
+=
rtl
::
OUStringToOString
(
sBufCP
.
makeStringAndClear
(),
osl_getThreadTextEncoding
());
// create JavaVMOptions array that is passed to the plugin
// it contains the classpath and all options set in the
//options dialog
if
(
cOptions
>
0
&&
arOptions
==
NULL
)
return
JFW_E_INVALID_ARG
;
boost
::
scoped_array
<
JavaVMOption
>
sarJOptions
(
new
JavaVMOption
[
cOptions
+
2
+
javaSettings
.
getVmParameters
().
size
()]);
JavaVMOption
*
arOpt
=
sarJOptions
.
get
();
if
(
!
arOpt
)
return
JFW_E_ERROR
;
//The first argument is the classpath
arOpt
[
0
].
optionString
=
(
char
*
)
sOptionClassPath
.
getStr
();
arOpt
[
0
].
extraInfo
=
NULL
;
// Set a flag that this JVM has been created via the JNI Invocation API
// (used, for example, by UNO remote bridges to share a common thread pool
// factory among Java and native bridge implementations):
arOpt
[
1
].
optionString
=
"-Dorg.openoffice.native="
;
arOpt
[
1
].
extraInfo
=
0
;
//add the options set by options dialog
typedef
std
::
vector
<
rtl
::
OString
>::
const_iterator
cit
;
const
std
::
vector
<
rtl
::
OString
>
&
params
=
javaSettings
.
getVmParameters
();
int
index
=
2
;
for
(
cit
i
=
params
.
begin
();
i
!=
params
.
end
();
i
++
)
{
arOpt
[
index
].
optionString
=
(
char
*
)
i
->
getStr
();
arOpt
[
index
].
extraInfo
=
0
;
index
++
;
}
//add all options of the arOptions argument
for
(
int
i
=
0
;
i
<
cOptions
;
i
++
)
{
arOpt
[
index
].
optionString
=
arOptions
[
i
].
optionString
;
arOpt
[
index
].
extraInfo
=
arOptions
[
i
].
extraInfo
;
index
++
;
}
//start Java
JavaVM
*
pVm
=
NULL
;
javaPluginError
plerr
=
(
*
pFunc
)(
aInfo
,
arOpt
,
index
,
&
pVm
,
ppEnv
);
if
(
plerr
!=
JFW_PLUGIN_E_NONE
)
{
errcode
=
JFW_E_ERROR
;
}
else
{
g_pJavaVM
=
pVm
;
*
ppVM
=
pVm
;
}
return
JFW_E_NONE
;
}
javaFrameworkError
SAL_CALL
jfw_findAndSelectJava
(
JavaInfo
**
pInfo
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
sal_Int64
nFeatureFlags
=
0L
;
jfw
::
CJavaInfo
aCurrentInfo
;
//Prepare the xml document and context
rtl
::
OString
sSettingsPath
=
jfw
::
getVendorSettingsPath
();
jfw
::
CXmlDocPtr
doc
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
doc
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_ERROR
;
}
jfw
::
CXPathContextPtr
context
=
xmlXPathNewContext
(
doc
);
int
reg
=
xmlXPathRegisterNs
(
context
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
);
if
(
reg
==
-
1
)
return
JFW_E_ERROR
;
//Determine if accessibility support is needed
bool
bSupportAccessibility
=
jfw
::
isAccessibilitySupportDesired
();
nFeatureFlags
=
bSupportAccessibility
?
JFW_FEATURE_ACCESSBRIDGE
:
0L
;
//Get a list of services which provide Java information
std
::
vector
<
jfw
::
PluginLibrary
>
vecPlugins
;
errcode
=
jfw
::
getVendorPluginURLs
(
doc
,
context
,
&
vecPlugins
);
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
//Use every plug-in library to get Java installations. At the first usable
//Java the loop will break
typedef
std
::
vector
<
jfw
::
PluginLibrary
>::
const_iterator
ci_pl
;
for
(
ci_pl
i
=
vecPlugins
.
begin
();
i
!=
vecPlugins
.
end
();
i
++
)
{
const
jfw
::
PluginLibrary
&
library
=
*
i
;
jfw
::
VersionInfo
versionInfo
;
errcode
=
jfw
::
getVersionInformation
(
doc
,
context
,
library
.
sVendor
,
&
versionInfo
);
if
(
errcode
!=
JFW_E_NONE
)
return
JFW_E_CONFIG_READWRITE
;
osl
::
Module
pluginLib
(
library
.
sPath
);
if
(
pluginLib
.
is
()
==
sal_False
)
return
JFW_E_NO_PLUGIN
;
getAllJavaInfos_ptr
getAllJavaFunc
=
(
getAllJavaInfos_ptr
)
pluginLib
.
getSymbol
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"getAllJavaInfos"
)));
OSL_ASSERT
(
getAllJavaFunc
);
if
(
getAllJavaFunc
==
NULL
)
continue
;
//get all installations of one vendor according to minVersion,
//maxVersion and excludeVersions
sal_Int32
cInfos
=
0
;
JavaInfo
**
arInfos
=
NULL
;
javaPluginError
plerr
=
(
*
getAllJavaFunc
)(
versionInfo
.
sMinVersion
.
pData
,
versionInfo
.
sMaxVersion
.
pData
,
versionInfo
.
getExcludeVersions
(),
versionInfo
.
getExcludeVersionSize
(),
&
arInfos
,
&
cInfos
);
if
(
plerr
!=
JFW_PLUGIN_E_NONE
)
continue
;
//iterate over all installations to find the best which has
//all features
if
(
cInfos
==
0
)
{
rtl_freeMemory
(
arInfos
);
continue
;
}
bool
bInfoFound
=
false
;
for
(
int
ii
=
0
;
ii
<
cInfos
;
ii
++
)
{
JavaInfo
*
pInfo
=
arInfos
[
ii
];
//We remember the very first installation in aCurrentInfo
if
(
aCurrentInfo
.
getLocation
().
getLength
()
==
0
)
aCurrentInfo
=
pInfo
;
// compare features
// If the user does not require any features (nFeatureFlags = 0)
// then the first installation is used
if
((
pInfo
->
nFeatures
&
nFeatureFlags
)
==
nFeatureFlags
)
{
//the just found Java implements all required features
//currently there is only accessibility!!!
aCurrentInfo
=
pInfo
;
bInfoFound
=
true
;
break
;
}
}
//The array returned by getAllJavaInfos must be freed as well as
//its contents
for
(
int
i
=
0
;
i
<
cInfos
;
i
++
)
jfw_freeJavaInfo
(
arInfos
[
i
]);
rtl_freeMemory
(
arInfos
);
if
(
bInfoFound
==
true
)
break
;
//All Java installations found by the current plug-in lib
//do not provide the required features. Try the next plug-in
}
if
((
JavaInfo
*
)
aCurrentInfo
)
{
rtl
::
OString
sSettings
=
jfw
::
getUserSettingsPath
();
if
(
sSettings
.
getLength
()
==
0
)
return
JFW_E_ERROR
;
// Get the <updated> element from the javavendors.xml
jfw
::
CXPathObjectPtr
pathObjUpdated
=
xmlXPathEvalExpression
(
(
xmlChar
*
)
"/jf:javaSelection/jf:updated/text()"
,
context
);
if
(
xmlXPathNodeSetIsEmpty
(
pathObjUpdated
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
rtl
::
OString
osUpdated
=
(
sal_Char
*
)
pathObjUpdated
->
nodesetval
->
nodeTab
[
0
]
->
content
;
rtl
::
OUString
sUpdated
=
rtl
::
OStringToOUString
(
osUpdated
,
RTL_TEXTENCODING_UTF8
);
// write the Java information to the user settings
errcode
=
jfw
::
writeJavaInfoData
(
aCurrentInfo
,
sUpdated
,
sSettings
);
if
(
errcode
==
JFW_E_NONE
&&
pInfo
!=
NULL
)
{
//copy to out param
*
pInfo
=
aCurrentInfo
.
cloneJavaInfo
();
}
}
else
{
errcode
=
JFW_E_NO_JAVA_FOUND
;
}
return
errcode
;
}
void
SAL_CALL
jfw_freeJavaInfo
(
JavaInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
)
return
;
rtl_uString_release
(
pInfo
->
sVendor
);
rtl_uString_release
(
pInfo
->
sLocation
);
rtl_uString_release
(
pInfo
->
sVersion
);
rtl_byte_sequence_release
(
pInfo
->
arVendorData
);
rtl_freeMemory
(
pInfo
);
}
javaFrameworkError
SAL_CALL
jfw_getSelectedJava
(
JavaInfo
**
ppInfo
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
if
(
ppInfo
==
NULL
)
return
JFW_E_INVALID_ARG
;
jfw
::
CNodeJava
aSettings
;
errcode
=
aSettings
.
loadFromSettings
();
if
(
errcode
==
JFW_E_NONE
)
{
jfw
::
CJavaInfo
aInfo
=
aSettings
.
getJavaInfo
();
if
(
aInfo
==
NULL
)
return
JFW_E_NO_SELECT
;
//If the javavendors.xml has changed, then the current selected
//Java is not valid anymore
// /java/javaInfo/@vendorUpdate != javaSelection/updated (javavendors.xml)
rtl
::
OUString
sUpdated
;
if
((
errcode
=
jfw
::
getElementUpdated
(
sUpdated
))
!=
JFW_E_NONE
)
return
errcode
;
if
(
sUpdated
.
equals
(
aSettings
.
getJavaInfoAttrVendorUpdate
())
==
sal_False
)
return
JFW_E_INVALID_SETTINGS
;
*
ppInfo
=
aSettings
.
getJavaInfo
();
}
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_isJavaRunning
(
sal_Bool
*
bRunning
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
if
(
bRunning
==
NULL
)
return
JFW_E_INVALID_ARG
;
if
(
g_pJavaVM
==
NULL
)
*
bRunning
=
sal_False
;
else
*
bRunning
=
sal_True
;
return
JFW_E_NONE
;
}
javaFrameworkError
SAL_CALL
jfw_getJavaInfoByPath
(
rtl_uString
*
pPath
,
JavaInfo
**
ppInfo
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
if
(
pPath
==
NULL
||
ppInfo
==
NULL
)
return
JFW_E_INVALID_ARG
;
javaFrameworkError
errcode
=
JFW_E_NONE
;
sal_Int64
nFeatureFlags
=
0L
;
jfw
::
CJavaInfo
aCurrentInfo
;
//Prepare the xml document and context
rtl
::
OString
sSettingsPath
=
jfw
::
getVendorSettingsPath
();
jfw
::
CXmlDocPtr
doc
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
doc
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_ERROR
;
}
jfw
::
CXPathContextPtr
context
=
xmlXPathNewContext
(
doc
);
int
reg
=
xmlXPathRegisterNs
(
context
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
);
if
(
reg
==
-
1
)
return
JFW_E_ERROR
;
//Get a list of plugins which provide Java information
std
::
vector
<
jfw
::
PluginLibrary
>
vecPlugins
;
errcode
=
jfw
::
getVendorPluginURLs
(
doc
,
context
,
&
vecPlugins
);
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
//Use every plug-in library to determine if the path represents a
//JRE. If a plugin recognized it then the loop will break
typedef
std
::
vector
<
jfw
::
PluginLibrary
>::
const_iterator
ci_pl
;
for
(
ci_pl
i
=
vecPlugins
.
begin
();
i
!=
vecPlugins
.
end
();
i
++
)
{
const
jfw
::
PluginLibrary
&
library
=
*
i
;
jfw
::
VersionInfo
versionInfo
;
errcode
=
jfw
::
getVersionInformation
(
doc
,
context
,
library
.
sVendor
,
&
versionInfo
);
if
(
errcode
!=
JFW_E_NONE
)
return
JFW_E_CONFIG_READWRITE
;
osl
::
Module
pluginLib
(
library
.
sPath
);
if
(
pluginLib
.
is
()
==
sal_False
)
return
JFW_E_NO_PLUGIN
;
getJavaInfoByPath_ptr
getJavaInfoByPathFunc
=
(
getJavaInfoByPath_ptr
)
pluginLib
.
getSymbol
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"getJavaInfoByPath"
)));
OSL_ASSERT
(
getJavaInfoByPathFunc
);
if
(
getJavaInfoByPathFunc
==
NULL
)
continue
;
//ask the plugin if this is a JRE.
//If so check if it meets the version requirements.
//Only if it does return a JavaInfo
JavaInfo
*
pInfo
=
NULL
;
javaPluginError
plerr
=
(
*
getJavaInfoByPathFunc
)(
pPath
,
versionInfo
.
sMinVersion
.
pData
,
versionInfo
.
sMaxVersion
.
pData
,
versionInfo
.
getExcludeVersions
(),
versionInfo
.
getExcludeVersionSize
(),
&
pInfo
);
if
(
plerr
==
JFW_PLUGIN_E_NONE
)
{
*
ppInfo
=
pInfo
;
break
;
}
else
if
(
plerr
==
JFW_PLUGIN_E_FAILED_REQUIREMENTS
)
{
//found JRE but it has the wrong version
*
ppInfo
=
NULL
;
break
;
}
}
if
(
*
ppInfo
==
NULL
)
errcode
=
JFW_E_NOT_RECOGNIZED
;
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_setSelectedJava
(
JavaInfo
const
*
pInfo
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
jfw
::
CNodeJava
node
;
rtl
::
OUString
sUpdated
;
if
((
errcode
=
jfw
::
getElementUpdated
(
sUpdated
))
!=
JFW_E_NONE
)
return
errcode
;
node
.
setJavaInfo
(
pInfo
,
sUpdated
);
errcode
=
node
.
writeSettings
();
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_setEnabled
(
sal_Bool
bEnabled
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
jfw
::
CNodeJava
node
;
node
.
setEnabled
(
bEnabled
);
errcode
=
node
.
writeSettings
();
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_getEnabled
(
sal_Bool
*
pbEnabled
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
if
(
pbEnabled
==
NULL
)
return
JFW_E_INVALID_ARG
;
jfw
::
CNodeJava
node
;
errcode
=
node
.
loadFromSettings
();
if
(
errcode
==
JFW_E_NONE
)
{
*
pbEnabled
=
node
.
getEnabled
();
}
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_setVMParameters
(
rtl_uString
*
*
arOptions
,
sal_Int32
nLen
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
jfw
::
CNodeJava
node
;
if
(
arOptions
==
NULL
&&
nLen
!=
0
)
return
JFW_E_INVALID_ARG
;
node
.
setVmParameters
(
arOptions
,
nLen
);
errcode
=
node
.
writeSettings
();
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_getVMParameters
(
rtl_uString
***
parOptions
,
sal_Int32
*
pLen
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
if
(
parOptions
==
NULL
||
pLen
==
NULL
)
return
JFW_E_INVALID_ARG
;
jfw
::
CNodeJava
node
;
errcode
=
node
.
loadFromSettings
();
if
(
errcode
==
JFW_E_NONE
)
{
node
.
getVmParametersArray
(
parOptions
,
pLen
);
}
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_setUserClassPath
(
rtl_uString
*
pCp
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
jfw
::
CNodeJava
node
;
if
(
pCp
==
NULL
)
return
JFW_E_INVALID_ARG
;
node
.
setUserClassPath
(
pCp
);
errcode
=
node
.
writeSettings
();
if
(
errcode
!=
JFW_E_NONE
)
return
errcode
;
return
errcode
;
}
javaFrameworkError
SAL_CALL
jfw_getUserClassPath
(
rtl_uString
**
ppCP
)
{
osl
::
MutexGuard
guard
(
jfw
::
getFwkMutex
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
if
(
ppCP
==
NULL
)
return
JFW_E_INVALID_ARG
;
jfw
::
CNodeJava
node
;
errcode
=
node
.
loadFromSettings
();
if
(
errcode
==
JFW_E_NONE
)
{
*
ppCP
=
node
.
getUserClassPath
().
pData
;
rtl_uString_acquire
(
*
ppCP
);
}
return
errcode
;
}
void
SAL_CALL
jfw_lock
()
{
osl
::
Mutex
*
mutex
=
jfw
::
getFwkMutex
();
mutex
->
acquire
();
}
void
SAL_CALL
jfw_unlock
()
{
osl
::
Mutex
*
mutex
=
jfw
::
getFwkMutex
();
mutex
->
release
();
}
namespace
jfw
{
CJavaInfo
::
CJavaInfo
()
:
pInfo
(
0
)
{
}
CJavaInfo
::
CJavaInfo
(
const
::
JavaInfo
*
info
)
:
pInfo
(
0
)
{
pInfo
=
copyJavaInfo
(
info
);
}
CJavaInfo
::~
CJavaInfo
()
{
jfw_freeJavaInfo
(
pInfo
);
}
CJavaInfo
::
operator
::
JavaInfo
*
()
{
return
pInfo
;
}
JavaInfo
*
CJavaInfo
::
copyJavaInfo
(
const
JavaInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
)
return
NULL
;
JavaInfo
*
newInfo
=
(
JavaInfo
*
)
rtl_allocateMemory
(
sizeof
JavaInfo
);
if
(
newInfo
)
{
rtl_copyMemory
(
newInfo
,
pInfo
,
sizeof
(
JavaInfo
));
rtl_uString_acquire
(
pInfo
->
sVendor
);
rtl_uString_acquire
(
pInfo
->
sLocation
);
rtl_uString_acquire
(
pInfo
->
sVersion
);
rtl_byte_sequence_acquire
(
pInfo
->
arVendorData
);
}
return
newInfo
;
}
JavaInfo
*
CJavaInfo
::
cloneJavaInfo
()
const
{
if
(
pInfo
==
NULL
)
return
NULL
;
return
copyJavaInfo
(
pInfo
);
}
CJavaInfo
&
CJavaInfo
::
operator
=
(
const
::
JavaInfo
*
info
)
{
if
(
info
==
pInfo
)
return
*
this
;
jfw_freeJavaInfo
(
pInfo
);
pInfo
=
NULL
;
if
(
info
!=
NULL
)
{
pInfo
=
copyJavaInfo
(
info
);
}
return
*
this
;
}
const
::
JavaInfo
*
CJavaInfo
::
operator
->
()
const
{
return
pInfo
;
}
CJavaInfo
::
operator
JavaInfo
const
*
()
const
{
return
pInfo
;
}
::
JavaInfo
**
CJavaInfo
::
operator
&
()
{
return
&
pInfo
;
}
rtl
::
OUString
CJavaInfo
::
getVendor
()
const
{
if
(
pInfo
)
return
rtl
::
OUString
(
pInfo
->
sVendor
);
else
return
rtl
::
OUString
();
}
rtl
::
OUString
CJavaInfo
::
getLocation
()
const
{
if
(
pInfo
)
return
rtl
::
OUString
(
pInfo
->
sLocation
);
else
return
rtl
::
OUString
();
}
rtl
::
OUString
CJavaInfo
::
getVersion
()
const
{
if
(
pInfo
)
return
rtl
::
OUString
(
pInfo
->
sVersion
);
else
return
rtl
::
OUString
();
}
sal_uInt64
CJavaInfo
::
getFeatures
()
const
{
if
(
pInfo
)
return
pInfo
->
nFeatures
;
else
return
0l
;
}
sal_uInt64
CJavaInfo
::
getRequirements
()
const
{
if
(
pInfo
)
return
pInfo
->
nRequirements
;
else
return
0l
;
}
rtl
::
ByteSequence
CJavaInfo
::
getVendorData
()
const
{
if
(
pInfo
)
return
rtl
::
ByteSequence
(
pInfo
->
arVendorData
);
else
return
rtl
::
ByteSequence
();
}
}
jvmfwk/source/framework.hxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: framework.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#if !defined INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
#define INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
#include "rtl/ustring.hxx"
#include "rtl/byteseq.hxx"
#include "jvmfwk/framework.h"
#include "jvmfwk/vendorplugin.h"
#define NS_JAVA_FRAMEWORK "http://openoffice.org/2004/java/framework/1.0"
#define NS_SCHEMA_INSTANCE "http://www.w3.org/2001/XMLSchema-instance"
/** typedefs for functions from vendorplugin.h
*/
typedef
javaPluginError
(
*
getAllJavaInfos_ptr
)(
rtl_uString
*
sMinVersion
,
rtl_uString
*
sMaxVersion
,
rtl_uString
*
*
arExcludeList
,
sal_Int32
nLenList
,
JavaInfo
***
parJavaInfo
,
sal_Int32
*
nLenInfoList
);
typedef
javaPluginError
(
*
getJavaInfoByPath_ptr
)(
rtl_uString
*
sPath
,
rtl_uString
*
sMinVersion
,
rtl_uString
*
sMaxVersion
,
rtl_uString
*
*
arExcludeList
,
sal_Int32
nLenList
,
JavaInfo
**
ppInfo
);
/** starts a Java Virtual Machine.
<p>
The function shall ensure, that the VM does not abort the process
during instantiation.
</p>
*/
typedef
javaPluginError
(
*
startJavaVirtualMachine_ptr
)(
const
JavaInfo
*
info
,
const
JavaVMOption
*
options
,
sal_Int32
cOptions
,
JavaVM
**
ppVM
,
JNIEnv
**
ppEnv
);
namespace
jfw
{
class
CJavaInfo
{
CJavaInfo
(
const
CJavaInfo
&
);
CJavaInfo
&
operator
=
(
const
CJavaInfo
&
);
static
JavaInfo
*
copyJavaInfo
(
const
JavaInfo
*
pInfo
);
public
:
::
JavaInfo
*
pInfo
;
CJavaInfo
();
CJavaInfo
(
const
::
JavaInfo
*
pInfo
);
~
CJavaInfo
();
CJavaInfo
&
operator
=
(
const
::
JavaInfo
*
info
);
const
::
JavaInfo
*
operator
->
()
const
;
::
JavaInfo
**
operator
&
();
operator
::
JavaInfo
*
();
operator
::
JavaInfo
const
*
()
const
;
::
JavaInfo
*
cloneJavaInfo
()
const
;
rtl
::
OUString
getVendor
()
const
;
rtl
::
OUString
getLocation
()
const
;
rtl
::
OUString
getVersion
()
const
;
sal_uInt64
getFeatures
()
const
;
sal_uInt64
getRequirements
()
const
;
rtl
::
ByteSequence
getVendorData
()
const
;
};
}
#endif
jvmfwk/source/framework.map
0 → 100644
Dosyayı görüntüle @
49614181
UDK_3.1 {
global:
# jvmfwk/framework.h:
jfw_freeJavaInfo;
jfw_findAndSelectJava;
jfw_startJava;
jfw_isJavaRunning;
jfw_getJavaInfoByPath;
jfw_setSelectedJava;
jfw_getSelectedJava;
jfw_setEnabled;
jfw_getEnabled;
jfw_setVMParameters;
jfw_getVMParameters;
jfw_setUserClassPath;
jfw_getUserClassPath;
jfw_lock;
jfw_unlock;
local:
*;
};
jvmfwk/source/fwkutil.cxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: fwkutil.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "libxmlutil.hxx"
#include "osl/mutex.hxx"
#include "osl/module.hxx"
#include "rtl/ustring.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/bootstrap.hxx"
#include "osl/file.hxx"
#include "osl/thread.hxx"
#include "osl/process.h"
#include "rtl/instance.hxx"
#include "rtl/uri.hxx"
#include "rtl/process.h"
#include "osl/getglobalmutex.hxx"
#include "libxml/xpathinternals.h"
#include "framework.hxx"
#include "elements.hxx"
#include "fwkutil.hxx"
#define JAVASETTINGS "javasettings.xml"
#define VENDORSETTINGS "javavendors.xml"
#define USE_ACCESSIBILITY_FILE "useatjava.txt"
/** The vector contains on return file urls to the plugins.
*/
namespace
jfw
{
bool
g_bJavaSet
=
false
;
struct
Init
{
osl
::
Mutex
*
operator
()()
{
static
osl
::
Mutex
aInstance
;
return
&
aInstance
;
}
};
osl
::
Mutex
*
getFwkMutex
()
{
return
rtl_Instance
<
osl
::
Mutex
,
Init
,
::
osl
::
MutexGuard
,
::
osl
::
GetGlobalMutex
>::
create
(
Init
(),
::
osl
::
GetGlobalMutex
());
}
const
rtl
::
Bootstrap
&
getBootstrapHandle
()
{
static
rtl
::
Bootstrap
*
pBootstrap
=
0
;
if
(
!
pBootstrap
)
{
rtl
::
OUString
exe
;
osl_getExecutableFile
(
&
(
exe
.
pData
)
);
sal_Int32
nIndex
=
exe
.
lastIndexOf
(
'/'
);
rtl
::
OUString
ret
;
if
(
exe
.
getLength
()
&&
nIndex
!=
-
1
)
{
rtl
::
OUStringBuffer
buf
(
exe
.
getLength
()
+
10
);
buf
.
append
(
exe
.
getStr
()
,
nIndex
+
1
).
appendAscii
(
SAL_CONFIGFILE
(
"uno"
)
);
ret
=
buf
.
makeStringAndClear
();
}
#if OSL_DEBUG_LEVEL > 1
rtl
::
OString
o
=
rtl
::
OUStringToOString
(
ret
,
RTL_TEXTENCODING_ASCII_US
);
printf
(
"JavaVM: Used ininame %s
\n
"
,
o
.
getStr
()
);
#endif
static
rtl
::
Bootstrap
bootstrap
(
ret
);
pBootstrap
=
&
bootstrap
;
}
return
*
pBootstrap
;
}
rtl
::
OUString
retrieveClassPath
(
::
rtl
::
OUString
const
&
macro
)
{
::
rtl
::
OUString
classpath
(
macro
);
getBootstrapHandle
().
expandMacrosFrom
(
classpath
);
::
rtl
::
OUStringBuffer
buf
;
sal_Int32
index
=
0
;
char
szClassPathSep
[]
=
{
SAL_PATHSEPARATOR
,
0
};
do
{
::
rtl
::
OUString
token
(
classpath
.
getToken
(
0
,
' '
,
index
).
trim
()
);
if
(
token
.
getLength
())
{
if
(
token
.
matchIgnoreAsciiCaseAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"vnd.sun.star.expand:"
)
))
{
token
=
::
rtl
::
Uri
::
decode
(
token
.
copy
(
sizeof
(
"vnd.sun.star.expand:"
)
-
1
),
rtl_UriDecodeWithCharset
,
RTL_TEXTENCODING_UTF8
);
getBootstrapHandle
().
expandMacrosFrom
(
token
);
}
::
rtl
::
OUString
systemPathElement
;
oslFileError
rc
=
osl_getSystemPathFromFileURL
(
token
.
pData
,
&
systemPathElement
.
pData
);
OSL_ASSERT
(
rc
==
osl_File_E_None
);
if
(
rc
==
osl_File_E_None
&&
systemPathElement
.
getLength
()
>
0
)
{
if
(
buf
.
getLength
()
>
0
)
buf
.
appendAscii
(
RTL_CONSTASCII_STRINGPARAM
(
szClassPathSep
)
);
buf
.
append
(
systemPathElement
);
}
}
}
while
(
index
>=
0
);
return
buf
.
makeStringAndClear
();
}
javaFrameworkError
getPluginLibrary
(
rtl
::
OUString
&
sLibUrl
)
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
CNodeJava
javaNode
;
if
((
errcode
=
javaNode
.
loadFromSettings
())
!=
JFW_E_NONE
)
return
errcode
;
CJavaInfo
aInfo
=
javaNode
.
getJavaInfo
();
if
(
aInfo
==
NULL
)
return
JFW_E_NO_SELECT
;
//With the vendor name we can get the associated plugin library
//from the javavendors.xml
rtl
::
OString
sVendorsPath
=
getVendorSettingsPath
();
CXmlDocPtr
docVendor
;
CXPathContextPtr
contextVendor
;
docVendor
=
xmlParseFile
(
sVendorsPath
.
getStr
());
if
(
docVendor
==
NULL
)
return
JFW_E_CONFIG_READWRITE
;
contextVendor
=
xmlXPathNewContext
(
docVendor
);
if
(
xmlXPathRegisterNs
(
contextVendor
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
)
==
-
1
)
return
JFW_E_CONFIG_READWRITE
;
rtl
::
OUStringBuffer
usBuffer
(
256
);
usBuffer
.
appendAscii
(
"/jf:javaSelection/jf:plugins/jf:library[@vendor=
\"
"
);
usBuffer
.
append
(
aInfo
.
getVendor
());
usBuffer
.
appendAscii
(
"
\"
]/text()"
);
rtl
::
OUString
ouExpr
=
usBuffer
.
makeStringAndClear
();
rtl
::
OString
sExpression
=
rtl
::
OUStringToOString
(
ouExpr
,
osl_getThreadTextEncoding
());
CXPathObjectPtr
pathObjVendor
=
xmlXPathEvalExpression
(
(
xmlChar
*
)
sExpression
.
getStr
(),
contextVendor
);
if
(
xmlXPathNodeSetIsEmpty
(
pathObjVendor
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
CXmlCharPtr
xmlCharPlugin
=
xmlNodeListGetString
(
docVendor
,
pathObjVendor
->
nodesetval
->
nodeTab
[
0
],
1
);
//make an absolute file url from the relativ plugin URL
rtl
::
OUString
sLibPath
=
getBaseInstallation
()
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/"
))
+
xmlCharPlugin
;
sLibUrl
=
sLibPath
;
return
errcode
;
}
javaFrameworkError
getVendorPluginURLs
(
const
xmlDocPtr
doc
,
const
xmlXPathContextPtr
context
,
std
::
vector
<
PluginLibrary
>
*
vecPlugins
)
{
OSL_ASSERT
(
vecPlugins
&&
doc
&&
context
);
//get the nodeset for the library elements
jfw
::
CXPathObjectPtr
result
=
xmlXPathEvalExpression
(
(
xmlChar
*
)
"/jf:javaSelection/jf:plugins/jf:library"
,
context
);
if
(
xmlXPathNodeSetIsEmpty
(
result
->
nodesetval
))
{
return
JFW_E_ERROR
;
}
vecPlugins
->
clear
();
//get the values of the library elements + vendor attribute
xmlNode
*
cur
=
result
->
nodesetval
->
nodeTab
[
0
];
while
(
cur
!=
NULL
)
{
//between library elements are also text elements
if
(
cur
->
type
==
XML_ELEMENT_NODE
)
{
jfw
::
CXmlCharPtr
sAttrVendor
=
xmlGetProp
(
cur
,
(
xmlChar
*
)
"vendor"
);
jfw
::
CXmlCharPtr
sTextLibrary
=
xmlNodeListGetString
(
doc
,
cur
->
xmlChildrenNode
,
1
);
PluginLibrary
plugin
;
plugin
.
sVendor
=
rtl
::
OString
((
sal_Char
*
)(
xmlChar
*
)
sAttrVendor
);
//create the file URL to the library
rtl
::
OUString
sBase
=
getBaseInstallation
();
plugin
.
sPath
=
sBase
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/"
))
+
sTextLibrary
;
vecPlugins
->
push_back
(
plugin
);
}
cur
=
cur
->
next
;
}
return
JFW_E_NONE
;
}
/** Get the file URL to the javasettings.xml
*/
rtl
::
OUString
getUserSettingsURL
()
{
//get the system path to the javasettings.xml file
rtl
::
OUString
sUserDir
;
rtl
::
Bootstrap
::
get
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"UserInstallation"
)),
sUserDir
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"${$SYSBINDIR/"
SAL_CONFIGFILE
(
"bootstrap"
)
":UserInstallation}"
)));
if
(
sUserDir
.
getLength
()
==
0
)
return
rtl
::
OUString
();
rtl
::
OUString
sSettings
(
sUserDir
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/user/config/"
))
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
JAVASETTINGS
)));
return
sSettings
;
}
rtl
::
OString
getUserSettingsPath
()
{
rtl
::
OUString
sURL
=
getUserSettingsURL
();
rtl
::
OUString
sSystemPathSettings
;
if
(
osl_getSystemPathFromFileURL
(
sURL
.
pData
,
&
sSystemPathSettings
.
pData
)
!=
osl_File_E_None
)
return
rtl
::
OString
();
rtl
::
OString
osSystemPathSettings
=
rtl
::
OUStringToOString
(
sSystemPathSettings
,
osl_getThreadTextEncoding
());
return
osSystemPathSettings
;
}
rtl
::
OUString
getSharedSettingsURL
()
{
rtl
::
OUString
sBase
=
getBaseInstallation
();
if
(
sBase
.
getLength
()
==
0
)
return
sBase
;
rtl
::
OUStringBuffer
sBufSettings
(
256
);
sBufSettings
.
append
(
sBase
);
sBufSettings
.
appendAscii
(
"/share/config/"
);
sBufSettings
.
appendAscii
(
JAVASETTINGS
);
return
sBufSettings
.
makeStringAndClear
();
}
rtl
::
OString
getSharedSettingsPath
()
{
rtl
::
OUString
sURL
=
getSharedSettingsURL
();
rtl
::
OUString
sSystemPathSettings
;
if
(
osl_getSystemPathFromFileURL
(
sURL
.
pData
,
&
sSystemPathSettings
.
pData
)
!=
osl_File_E_None
)
return
rtl
::
OString
();
rtl
::
OString
osSystemPathSettings
=
rtl
::
OUStringToOString
(
sSystemPathSettings
,
osl_getThreadTextEncoding
());
return
osSystemPathSettings
;
}
rtl
::
OUString
getBaseInstallation
()
{
rtl
::
OUString
sBaseDir
;
rtl
::
Bootstrap
::
get
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"BaseInstallation"
)),
sBaseDir
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"${$SYSBINDIR/"
SAL_CONFIGFILE
(
"bootstrap"
)
":BaseInstallation}"
)));
return
sBaseDir
;
}
rtl
::
OUString
getVendorSettingsURL
()
{
//get the system path to the javavendors.xml file
rtl
::
OUString
sBaseDir
=
getBaseInstallation
();
if
(
sBaseDir
.
getLength
()
==
0
)
return
rtl
::
OUString
();
rtl
::
OUStringBuffer
sSettings
(
256
);
sSettings
.
append
(
sBaseDir
);
sSettings
.
appendAscii
(
"/share/config/"
);
sSettings
.
appendAscii
(
VENDORSETTINGS
);
return
sSettings
.
makeStringAndClear
();
}
rtl
::
OString
getVendorSettingsPath
()
{
rtl
::
OUString
sURL
=
getVendorSettingsURL
();
rtl
::
OUString
sSystemPathSettings
;
if
(
osl_getSystemPathFromFileURL
(
sURL
.
pData
,
&
sSystemPathSettings
.
pData
)
!=
osl_File_E_None
)
return
rtl
::
OString
();
rtl
::
OString
osSystemPathSettings
=
rtl
::
OUStringToOString
(
sSystemPathSettings
,
osl_getThreadTextEncoding
());
return
osSystemPathSettings
;
}
bool
isAccessibilitySupportDesired
()
{
bool
retVal
=
false
;
#ifdef WNT
rtl
::
OUString
usInstallDir
;
rtl
::
Bootstrap
::
get
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"BaseInstallation"
)),
usInstallDir
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"${$SYSBINDIR/"
SAL_CONFIGFILE
(
"bootstrap"
)
":BaseInstallation}"
)));
rtl
::
OUString
urlrcPath
=
usInstallDir
+
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/share/config/"
USE_ACCESSIBILITY_FILE
));
osl
::
DirectoryItem
testFileItem
;
if
(
osl
::
DirectoryItem
::
get
(
urlrcPath
,
testFileItem
)
==
osl
::
FileBase
::
E_None
)
{
retVal
=
true
;
}
#elif UNX
char
buf
[
16
];
// use 2 shells to suppress the eventual "gcontool-2 not found" message
// of the shell trying to execute the command
FILE
*
fp
=
popen
(
"/bin/sh 2>/dev/null -c
\"
gconftool-2 -g /desktop/gnome/interface/accessibility
\"
"
,
"r"
);
if
(
fp
)
{
if
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
)
{
int
nCompare
=
strncasecmp
(
buf
,
"true"
,
4
);
retVal
=
(
nCompare
==
0
?
true
:
false
);
}
pclose
(
fp
);
}
#endif
return
retVal
;
}
javaFrameworkError
getVersionInformation
(
const
xmlDocPtr
doc
,
const
xmlXPathContextPtr
context
,
const
rtl
::
OString
&
sVendor
,
VersionInfo
*
pVersionInfo
)
{
OSL_ASSERT
(
doc
&&
context
&&
sVendor
.
getLength
()
&&
pVersionInfo
);
//Get minVersion
rtl
::
OString
sExpresion
=
rtl
::
OString
(
"/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=
\"
"
)
+
sVendor
+
rtl
::
OString
(
"
\"
]/jf:minVersion"
);
jfw
::
CXPathObjectPtr
xPathObjectMin
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpresion
.
getStr
(),
context
);
if
(
xmlXPathNodeSetIsEmpty
(
xPathObjectMin
->
nodesetval
))
{
pVersionInfo
->
sMinVersion
=
rtl
::
OUString
();
}
else
{
jfw
::
CXmlCharPtr
sVersion
=
xmlNodeListGetString
(
doc
,
xPathObjectMin
->
nodesetval
->
nodeTab
[
0
]
->
xmlChildrenNode
,
1
);
rtl
::
OString
osVersion
((
sal_Char
*
)(
xmlChar
*
)
sVersion
);
pVersionInfo
->
sMinVersion
=
rtl
::
OStringToOUString
(
osVersion
,
RTL_TEXTENCODING_UTF8
);
}
//Get maxVersion
sExpresion
=
rtl
::
OString
(
"/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=
\"
"
)
+
sVendor
+
rtl
::
OString
(
"
\"
]/jf:maxVersion"
);
jfw
::
CXPathObjectPtr
xPathObjectMax
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpresion
.
getStr
(),
context
);
if
(
xmlXPathNodeSetIsEmpty
(
xPathObjectMax
->
nodesetval
))
{
pVersionInfo
->
sMaxVersion
=
rtl
::
OUString
();
}
else
{
jfw
::
CXmlCharPtr
sVersion
=
xmlNodeListGetString
(
doc
,
xPathObjectMax
->
nodesetval
->
nodeTab
[
0
]
->
xmlChildrenNode
,
1
);
rtl
::
OString
osVersion
((
sal_Char
*
)
(
xmlChar
*
)
sVersion
);
pVersionInfo
->
sMaxVersion
=
rtl
::
OStringToOUString
(
osVersion
,
RTL_TEXTENCODING_UTF8
);
}
//Get excludeVersions
sExpresion
=
rtl
::
OString
(
"/jf:javaSelection/jf:vendorInfos/jf:vendor[@name=
\"
"
)
+
sVendor
+
rtl
::
OString
(
"
\"
]/jf:excludeVersions/jf:version"
);
jfw
::
CXPathObjectPtr
xPathObjectVersions
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpresion
.
getStr
(),
context
);
xmlNode
*
cur
=
xPathObjectVersions
->
nodesetval
->
nodeTab
[
0
];
while
(
cur
!=
NULL
)
{
if
(
cur
->
type
==
XML_ELEMENT_NODE
)
{
if
(
xmlStrcmp
(
cur
->
name
,
(
xmlChar
*
)
"version"
)
==
0
)
{
jfw
::
CXmlCharPtr
sVersion
=
xmlNodeListGetString
(
doc
,
cur
->
xmlChildrenNode
,
1
);
rtl
::
OString
osVersion
((
sal_Char
*
)(
xmlChar
*
)
sVersion
);
rtl
::
OUString
usVersion
=
rtl
::
OStringToOUString
(
osVersion
,
RTL_TEXTENCODING_UTF8
);
pVersionInfo
->
addExcludeVersion
(
usVersion
);
}
}
cur
=
cur
->
next
;
}
return
JFW_E_NONE
;
}
rtl
::
ByteSequence
encodeBase16
(
const
rtl
::
ByteSequence
&
rawData
)
{
static
char
EncodingTable
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
sal_Int32
lenRaw
=
rawData
.
getLength
();
char
*
pBuf
=
new
char
[
lenRaw
*
2
];
const
sal_Int8
*
arRaw
=
rawData
.
getConstArray
();
char
*
pCurBuf
=
pBuf
;
for
(
int
i
=
0
;
i
<
lenRaw
;
i
++
)
{
char
curChar
=
arRaw
[
i
];
curChar
>>=
4
;
*
pCurBuf
=
EncodingTable
[
curChar
];
pCurBuf
++
;
curChar
=
arRaw
[
i
];
curChar
&=
0x0F
;
*
pCurBuf
=
EncodingTable
[
curChar
];
pCurBuf
++
;
}
rtl
::
ByteSequence
ret
((
sal_Int8
*
)
pBuf
,
lenRaw
*
2
);
delete
[]
pBuf
;
return
ret
;
}
rtl
::
ByteSequence
decodeBase16
(
const
rtl
::
ByteSequence
&
data
)
{
static
char
decodingTable
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
sal_Int32
lenData
=
data
.
getLength
();
sal_Int32
lenBuf
=
lenData
/
2
;
//always divisable by two
char
*
pBuf
=
new
char
[
lenBuf
];
const
sal_Int8
*
arData
=
data
.
getConstArray
();
char
*
pCurBuf
=
pBuf
;
const
sal_Int8
*
pData
=
arData
;
for
(
int
i
=
0
;
i
<
lenBuf
;
i
++
)
{
sal_Int8
curChar
=
*
pData
;
//find the index of the first 4bits
char
nibble
;
for
(
int
ii
=
0
;
ii
<
16
;
ii
++
)
{
if
(
curChar
==
decodingTable
[
ii
])
{
nibble
=
ii
;
break
;
}
}
nibble
<<=
4
;
pData
++
;
curChar
=
*
pData
;
//find the index for the next 4bits
for
(
int
ii
=
0
;
ii
<
16
;
ii
++
)
{
if
(
curChar
==
decodingTable
[
ii
])
{
nibble
|=
ii
;
break
;
}
}
*
pCurBuf
=
nibble
;
pData
++
;
pCurBuf
++
;
}
rtl
::
ByteSequence
ret
((
sal_Int8
*
)
pBuf
,
lenBuf
);
delete
[]
pBuf
;
return
ret
;
}
javaFrameworkError
writeJavaInfoData
(
const
jfw
::
CJavaInfo
&
aInfo
,
const
rtl
::
OUString
&
sUpdated
,
const
rtl
::
OString
&
sSettings
)
{
OSL_ASSERT
(
sSettings
.
getLength
());
javaFrameworkError
errcode
=
JFW_E_NONE
;
jfw
::
CXmlDocPtr
docUser
;
jfw
::
CXPathContextPtr
contextUser
;
jfw
::
CXPathObjectPtr
pathObjUser
;
docUser
=
xmlParseFile
(
sSettings
.
getStr
());
if
(
docUser
==
NULL
)
return
JFW_E_CONFIG_READWRITE
;
contextUser
=
xmlXPathNewContext
(
docUser
);
if
(
xmlXPathRegisterNs
(
contextUser
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
)
==
-
1
)
return
JFW_E_CONFIG_READWRITE
;
//Get position of javaInfo element
rtl
::
OString
sExpresion
=
rtl
::
OString
(
"/jf:java/jf:javaInfo"
);
pathObjUser
=
xmlXPathEvalExpression
((
xmlChar
*
)
sExpresion
.
getStr
(),
contextUser
);
if
(
!
pathObjUser
||
xmlXPathNodeSetIsEmpty
(
pathObjUser
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
CNodeJavaInfo
infoNode
(
aInfo
,
sUpdated
);
errcode
=
infoNode
.
writeToNode
(
docUser
,
pathObjUser
->
nodesetval
->
nodeTab
[
0
]);
if
(
errcode
==
JFW_E_NONE
)
{
// xmlKeepBlanksDefault(0);
if
(
xmlSaveFormatFile
(
sSettings
.
getStr
(),
docUser
,
1
)
==
-
1
)
return
JFW_E_CONFIG_READWRITE
;
setJavaSelected
();
}
return
errcode
;
}
xmlNode
*
findChildNode
(
const
xmlNode
*
pParent
,
const
xmlChar
*
pName
)
{
xmlNode
*
ret
=
NULL
;
if
(
pParent
)
{
xmlNode
*
cur
=
pParent
->
children
;
while
(
cur
!=
NULL
)
{
if
(
xmlStrcmp
(
cur
->
name
,
pName
)
==
0
)
break
;
cur
=
cur
->
next
;
}
ret
=
cur
;
}
return
ret
;
}
javaFrameworkError
getElementUpdated
(
rtl
::
OUString
&
sValue
)
{
javaFrameworkError
errcode
=
JFW_E_NONE
;
//Prepare the xml document and context
rtl
::
OString
sSettingsPath
=
jfw
::
getVendorSettingsPath
();
jfw
::
CXmlDocPtr
doc
=
xmlParseFile
(
sSettingsPath
.
getStr
());
if
(
doc
==
NULL
)
{
OSL_ASSERT
(
0
);
return
JFW_E_CONFIG_READWRITE
;
}
jfw
::
CXPathContextPtr
context
=
xmlXPathNewContext
(
doc
);
int
reg
=
xmlXPathRegisterNs
(
context
,
(
xmlChar
*
)
"jf"
,
(
xmlChar
*
)
NS_JAVA_FRAMEWORK
);
if
(
reg
==
-
1
)
return
JFW_E_ERROR
;
CXPathObjectPtr
pathObj
=
xmlXPathEvalExpression
(
(
xmlChar
*
)
"/jf:javaSelection/jf:updated/text()"
,
context
);
if
(
xmlXPathNodeSetIsEmpty
(
pathObj
->
nodesetval
))
return
JFW_E_FORMAT_STORE
;
rtl
::
OString
osUpdated
=
(
sal_Char
*
)
pathObj
->
nodesetval
->
nodeTab
[
0
]
->
content
;
sValue
=
rtl
::
OStringToOUString
(
osUpdated
,
RTL_TEXTENCODING_UTF8
);
return
errcode
;
}
javaFrameworkError
buildClassPathFromDirectory
(
const
rtl
::
OUString
&
relPath
,
rtl
::
OUString
&
sClassPath
)
{
rtl
::
OUStringBuffer
sBufRel
(
512
);
sBufRel
.
append
(
getBaseInstallation
());
sBufRel
.
appendAscii
(
"/"
);
sBufRel
.
append
(
relPath
);
rtl
::
OUString
sClassesDir
=
sBufRel
.
makeStringAndClear
();
osl
::
Directory
dir
(
sClassesDir
);
osl
::
FileBase
::
RC
fileErrorCode
;
if
((
fileErrorCode
=
dir
.
open
())
!=
osl
::
FileBase
::
E_None
)
{
return
JFW_E_ERROR
;
}
osl
::
DirectoryItem
dirItem
;
rtl
::
OUStringBuffer
sBuffer
(
2048
);
char
szSep
[]
=
{
SAL_PATHSEPARATOR
,
0
};
//insert the path to the directory, so that .class files can be found
rtl
::
OUString
sDirPath
;
if
((
fileErrorCode
=
osl
::
FileBase
::
getSystemPathFromFileURL
(
sClassesDir
,
sDirPath
))
!=
osl
::
FileBase
::
E_None
)
{
return
JFW_E_ERROR
;
}
sBuffer
.
append
(
sDirPath
);
sBuffer
.
appendAscii
(
szSep
);
rtl
::
OUString
sJarExtension
(
RTL_CONSTASCII_USTRINGPARAM
(
".jar"
));
sal_Int32
nJarExtensionLength
=
sJarExtension
.
getLength
();
for
(;;)
{
fileErrorCode
=
dir
.
getNextItem
(
dirItem
);
if
(
fileErrorCode
==
osl
::
FileBase
::
E_None
)
{
osl
::
FileStatus
stat
(
FileStatusMask_All
);
if
((
fileErrorCode
=
dirItem
.
getFileStatus
(
stat
))
!=
osl
::
FileBase
::
E_None
)
{
return
JFW_E_ERROR
;
}
// check if the item is a file.
switch
(
stat
.
getFileType
())
{
case
osl
:
:
FileStatus
::
Regular
:
break
;
case
osl
:
:
FileStatus
::
Link
:
{
rtl
::
OUString
sLinkURL
=
stat
.
getLinkTargetURL
();
osl
::
DirectoryItem
itemLink
;
if
(
osl
::
DirectoryItem
::
get
(
sLinkURL
,
itemLink
)
!=
osl
::
FileBase
::
E_None
)
{
return
JFW_E_ERROR
;
}
osl
::
FileStatus
statLink
(
FileStatusMask_All
);
if
(
statLink
.
getFileType
()
!=
osl
::
FileStatus
::
Regular
)
continue
;
//ToDo check if the link is also a regular file:
break
;
}
default
:
continue
;
}
//check if the file is a .jar, class files are ignored
rtl
::
OUString
sFileName
=
stat
.
getFileName
();
sal_Int32
len
=
sFileName
.
getLength
();
sal_Int32
nIndex
=
sFileName
.
lastIndexOf
(
sJarExtension
);
if
((
nIndex
==
-
1
)
||
(
nIndex
+
nJarExtensionLength
!=
len
))
continue
;
rtl
::
OUString
sFileURL
=
stat
.
getFileURL
();
rtl
::
OUString
sFilePath
;
if
((
fileErrorCode
=
osl
::
FileBase
::
getSystemPathFromFileURL
(
sFileURL
,
sFilePath
))
!=
osl
::
FileBase
::
E_None
)
{
return
JFW_E_ERROR
;
}
sBuffer
.
append
(
sFilePath
);
sBuffer
.
appendAscii
(
szSep
);
}
else
if
(
fileErrorCode
==
osl
::
FileBase
::
E_NOENT
)
{
break
;
}
else
{
return
JFW_E_ERROR
;
}
}
sClassPath
=
sBuffer
.
makeStringAndClear
();
return
JFW_E_NONE
;
}
void
setJavaSelected
()
{
g_bJavaSet
=
true
;
}
/** Determines if the currently selected Java was set in this process.
@see setProcessId()
*/
bool
wasJavaSelectedInSameProcess
()
{
//g_setJavaProcId not set means no Java selected
if
(
g_bJavaSet
==
true
)
return
true
;
return
false
;
}
// CProcessId::CProcessId():m_bValid(false)
// {
// }
// void CProcessId::set()
// {
// rtl_getGlobalProcessId( m_arId);
// }
// bool CProcessId::operator == (const sal_uInt8 * arId) const
// {
// if (arId == NULL || m_bValid == false)
// return false;
// if (memcmp(arId, m_arId, 16) == 0)
// return true;
// return false;
// }
// bool CProcessId::isValid() const
// {
// return m_bValid;
// }
}
jvmfwk/source/fwkutil.hxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: fwkutil.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#if !defined INCLUDED_JVMFWK_FWKUTIL_HXX
#define INCLUDED_JVMFWK_FWKUTIL_HXX
#include "osl/mutex.hxx"
#include "osl/module.hxx"
#include "rtl/byteseq.hxx"
#include "libxml/parser.h"
#include "libxml/xpath.h"
namespace
jfw
{
osl
::
Mutex
*
getFwkMutex
();
rtl
::
ByteSequence
encodeBase16
(
const
rtl
::
ByteSequence
&
rawData
);
rtl
::
ByteSequence
decodeBase16
(
const
rtl
::
ByteSequence
&
data
);
/** Get the file URL to the javasettings.xml
*/
rtl
::
OUString
getUserSettingsURL
();
rtl
::
OString
getUserSettingsPath
();
rtl
::
OUString
getSharedSettingsURL
();
rtl
::
OString
getSharedSettingsPath
();
rtl
::
OUString
getBaseInstallation
();
rtl
::
OUString
getVendorSettingsURL
();
rtl
::
OString
getVendorSettingsPath
();
xmlNode
*
findChildNode
(
const
xmlNode
*
pParent
,
const
xmlChar
*
pName
);
struct
PluginLibrary
;
class
VersionInfo
;
class
CJavaInfo
;
javaFrameworkError
getVendorPluginURLs
(
const
xmlDocPtr
doc
,
const
xmlXPathContextPtr
context
,
std
::
vector
<
PluginLibrary
>
*
vecPlugins
);
bool
isAccessibilitySupportDesired
();
javaFrameworkError
getVersionInformation
(
const
xmlDocPtr
doc
,
const
xmlXPathContextPtr
context
,
const
rtl
::
OString
&
sVendor
,
VersionInfo
*
pVersionInfo
);
/** gets the value of the updated element from the javavendors.xml.
*/
javaFrameworkError
getElementUpdated
(
rtl
::
OUString
&
sValue
);
/** Gets the file URL to the plubin library for the currently selected Java.
*/
javaFrameworkError
getPluginLibrary
(
rtl
::
OUString
&
sLibPathe
);
//xmlNode* findChildNode(const xmlNode * pParent, const xmlChar* pName);
/**
@param sUpdated
the value of the element /javaSelection/updated from the javavendors.xml
file.
@param sSettings
the system path to the settings xml file.
*/
javaFrameworkError
writeJavaInfoData
(
const
jfw
::
CJavaInfo
&
aInfo
,
const
rtl
::
OUString
&
sUpdated
,
const
rtl
::
OString
&
sSettings
);
/** Called from writeJavaInfoData. It sets the process identifier. When
java is to be started, then the current id is compared to the one set by
this function. If they are identical then the Java was selected in the
same process. If that Java needs a prepared environment, such as a
LD_LIBRARY_PATH, then it must not be started in this process.
*/
void
setJavaSelected
();
/** Determines if the currently selected Java was set in this process.
@see setProcessId()
*/
bool
wasJavaSelectedInSameProcess
();
/**
@param pDoc
must not be freed within the function.
@param pJavaInfoNode
must not be freed within the function.
*/
javaFrameworkError
writeElementJavaInfo
(
xmlDoc
*
pDoc
,
xmlNode
*
pJavaInfoNode
,
const
jfw
::
CJavaInfo
&
aInfo
);
javaFrameworkError
buildClassPathFromDirectory
(
const
rtl
::
OUString
&
relPath
,
rtl
::
OUString
&
sClassPath
);
rtl
::
OUString
retrieveClassPath
(
::
rtl
::
OUString
const
&
macro
);
// class CProcessId
// {
// sal_uInt8 m_arId[16];
// bool m_bValid;
// public:
// CProcessId();
// /**
// If the argument is NULL or the object is invalid then
// false is returned.
// */
// bool operator == (const sal_uInt8 * arId) const;
// void set();
// bool isValid() const;
// };
}
#endif
jvmfwk/source/javasettings.xsd
0 → 100644
Dosyayı görüntüle @
49614181
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : javasettings.xsd
Created on : 25. März 2004, 16:16
Author : jl97489
Description:
Purpose of XML Schema document follows.
-->
<schema
targetNamespace=
"http://openoffice.org/2004/java/framework/1.0"
xmlns:jf=
"http://openoffice.org/2004/java/framework/1.0"
xmlns=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
>
<element
name=
"java"
>
<complexType>
<sequence>
<element
name=
"enabled"
nillable=
"true"
default=
"true"
type=
"boolean"
/>
<element
name=
"classesDirectory"
type=
"string"
/>
<element
name=
"userClassPath"
nillable=
"true"
type=
"string"
/>
<element
name=
"javaInfo"
nillable=
"true"
type=
"jf:javaInfoType"
/>
<element
name=
"vmParameters"
nillable=
"true"
type=
"jf:vmParametersType"
/>
</sequence>
</complexType>
</element>
<complexType
name=
"javaInfoType"
>
<sequence>
<element
name=
"vendor"
type=
"string"
/>
<element
name=
"location"
type=
"string"
/>
<element
name=
"version"
type=
"string"
/>
<element
name=
"features"
default=
"0"
type=
"unsignedLong"
/>
<element
name=
"requirements"
default=
"0"
type=
"unsignedLong"
/>
<element
name=
"vendorData"
type=
"base64Binary"
/>
</sequence>
<attribute
name=
"vendorUpdate"
type=
"date"
/>
</complexType>
<complexType
name=
"vmParametersType"
>
<sequence>
<element
name=
"param"
minOccurs=
"0"
maxOccurs=
"unbounded"
type=
"string"
/>
</sequence>
</complexType>
</schema>
jvmfwk/source/libxmlutil.cxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: libxmlutil.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:55:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "libxmlutil.hxx"
namespace
jfw
{
CXPathObjectPtr
::
CXPathObjectPtr
(
xmlXPathObject
*
aObject
)
:
_object
(
aObject
)
{
}
CXPathObjectPtr
::
CXPathObjectPtr
()
:
_object
(
NULL
)
{
}
CXPathObjectPtr
::~
CXPathObjectPtr
()
{
xmlXPathFreeObject
(
_object
);
}
CXPathObjectPtr
&
CXPathObjectPtr
::
operator
=
(
xmlXPathObject
*
pObj
)
{
if
(
_object
==
pObj
)
return
*
this
;
xmlXPathFreeObject
(
_object
);
_object
=
pObj
;
return
*
this
;
}
xmlXPathObject
*
CXPathObjectPtr
::
operator
->
()
{
return
_object
;
}
CXPathObjectPtr
::
operator
xmlXPathObject
*
()
{
return
_object
;
}
//===========================================================
CXPathContextPtr
::
CXPathContextPtr
(
xmlXPathContext
*
aContext
)
:
_object
(
aContext
)
{
}
CXPathContextPtr
::
CXPathContextPtr
()
:
_object
(
NULL
)
{
}
CXPathContextPtr
::~
CXPathContextPtr
()
{
xmlXPathFreeContext
(
_object
);
}
CXPathContextPtr
&
CXPathContextPtr
::
operator
=
(
xmlXPathContext
*
pObj
)
{
if
(
_object
==
pObj
)
return
*
this
;
xmlXPathFreeContext
(
_object
);
_object
=
pObj
;
return
*
this
;
}
xmlXPathContext
*
CXPathContextPtr
::
operator
->
()
{
return
_object
;
}
CXPathContextPtr
::
operator
xmlXPathContext
*
()
{
return
_object
;
}
//===========================================================
CXmlDocPtr
::
CXmlDocPtr
(
xmlDoc
*
aDoc
)
:
_object
(
aDoc
)
{
}
CXmlDocPtr
::
CXmlDocPtr
()
:
_object
(
NULL
)
{
}
CXmlDocPtr
::~
CXmlDocPtr
()
{
xmlFreeDoc
(
_object
);
}
CXmlDocPtr
&
CXmlDocPtr
::
operator
=
(
xmlDoc
*
pObj
)
{
if
(
_object
==
pObj
)
return
*
this
;
xmlFreeDoc
(
_object
);
_object
=
pObj
;
return
*
this
;
}
xmlDoc
*
CXmlDocPtr
::
operator
->
()
{
return
_object
;
}
CXmlDocPtr
::
operator
xmlDoc
*
()
{
return
_object
;
}
//===========================================================
// CXmlNsPtr::CXmlNsPtr(xmlNs* pNs)
// : _object(pNs)
// {
// }
// CXmlNsPtr::CXmlNsPtr():_object(NULL)
// {
// }
// CXmlNsPtr::~CXmlNsPtr()
// {
// // xmlFreeNs(_object);
// }
// CXmlNsPtr & CXmlNsPtr::operator = (xmlNs* pObj)
// {
// if (_object == pObj)
// return *this;
// xmlFreeNs(_object);
// _object = pObj;
// return *this;
// }
// xmlNs* CXmlNsPtr::operator ->()
// {
// return _object;
// }
// CXmlNsPtr::operator xmlNs*()
// {
// return _object;
// }
//===========================================================
CXmlCharPtr
::
CXmlCharPtr
(
xmlChar
*
aChar
)
:
_object
(
aChar
)
{
}
CXmlCharPtr
::
CXmlCharPtr
()
:
_object
(
NULL
)
{
}
CXmlCharPtr
::~
CXmlCharPtr
()
{
xmlFree
(
_object
);
}
CXmlCharPtr
&
CXmlCharPtr
::
operator
=
(
xmlChar
*
pObj
)
{
if
(
pObj
==
_object
)
return
*
this
;
xmlFree
(
_object
);
_object
=
pObj
;
return
*
this
;
}
xmlChar
*
CXmlCharPtr
::
operator
->
()
{
return
_object
;
}
CXmlCharPtr
::
operator
xmlChar
*
()
{
return
_object
;
}
CXmlCharPtr
::
operator
rtl
::
OUString
()
{
rtl
::
OUString
ret
;
if
(
_object
!=
NULL
)
{
rtl
::
OString
aOStr
((
sal_Char
*
)
_object
);
ret
=
rtl
::
OStringToOUString
(
aOStr
,
RTL_TEXTENCODING_UTF8
);
}
return
ret
;
}
CXmlCharPtr
::
operator
rtl
::
OString
()
{
return
rtl
::
OString
((
sal_Char
*
)
_object
);
}
}
jvmfwk/source/libxmlutil.hxx
0 → 100644
Dosyayı görüntüle @
49614181
/*************************************************************************
*
* $RCSfile: libxmlutil.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: jl $ $Date: 2004-04-19 15:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#if !defined INCLUDED_JVMFWK_LIBXMLUTIL_HXX
#define INCLUDED_JVMFWK_LIBXMLUTIL_HXX
#include "libxml/parser.h"
#include "libxml/xpath.h"
//#include "libxml/xpathinternals.h"
#include "rtl/ustring.hxx"
namespace
jfw
{
class
CXPathObjectPtr
{
xmlXPathObject
*
_object
;
CXPathObjectPtr
&
operator
=
(
const
CXPathObjectPtr
&
);
CXPathObjectPtr
(
const
CXPathObjectPtr
&
);
public
:
CXPathObjectPtr
();
/** Takes ownership of xmlXPathObject
*/
CXPathObjectPtr
(
xmlXPathObject
*
aObject
);
~
CXPathObjectPtr
();
/** Takes ownership of xmlXPathObject
*/
CXPathObjectPtr
&
operator
=
(
xmlXPathObject
*
pObj
);
xmlXPathObject
*
operator
->
();
operator
xmlXPathObject
*
();
};
//===========================================================
class
CXPathContextPtr
{
xmlXPathContext
*
_object
;
CXPathContextPtr
(
const
CXPathContextPtr
&
);
CXPathContextPtr
&
operator
=
(
const
CXPathContextPtr
&
);
public
:
CXPathContextPtr
();
CXPathContextPtr
(
xmlXPathContext
*
aContext
);
CXPathContextPtr
&
operator
=
(
xmlXPathContext
*
pObj
);
~
CXPathContextPtr
();
xmlXPathContext
*
operator
->
();
operator
xmlXPathContext
*
();
};
//===========================================================
class
CXmlDocPtr
{
xmlDoc
*
_object
;
CXmlDocPtr
(
const
CXmlDocPtr
&
);
CXmlDocPtr
&
operator
=
(
const
CXmlDocPtr
&
);
public
:
CXmlDocPtr
();
CXmlDocPtr
(
xmlDoc
*
aDoc
);
/** Takes ownership of xmlDoc
*/
CXmlDocPtr
&
operator
=
(
xmlDoc
*
pObj
);
~
CXmlDocPtr
();
xmlDoc
*
operator
->
();
operator
xmlDoc
*
();
};
//===========================================================
// class CXmlNsPtr
// {
// xmlNs* _object;
// CXmlNsPtr(const CXmlNsPtr&);
// CXmlNsPtr & operator = (const CXmlNsPtr&);
// public:
// CXmlNsPtr();
// CXmlNsPtr(xmlNs* aDoc);
// /** Takes ownership of xmlDoc
// */
// CXmlNsPtr & operator = (xmlNs* pObj);
// ~CXmlNsPtr();
// xmlNs* operator -> ();
// operator xmlNs* ();
// };
//===========================================================
class
CXmlCharPtr
{
xmlChar
*
_object
;
CXmlCharPtr
(
const
CXmlCharPtr
&
);
CXmlCharPtr
&
operator
=
(
const
CXmlCharPtr
&
);
public
:
CXmlCharPtr
();
CXmlCharPtr
(
xmlChar
*
aDoc
);
~
CXmlCharPtr
();
CXmlCharPtr
&
operator
=
(
xmlChar
*
pObj
);
xmlChar
*
operator
->
();
operator
xmlChar
*
();
operator
rtl
::
OUString
();
operator
rtl
::
OString
();
};
}
#endif
jvmfwk/source/makefile.mk
0 → 100644
Dosyayı görüntüle @
49614181
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: jl $ $Date: 2004-04-19 15:56:28 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#*************************************************************************
PRJ
=
..
PRJNAME
=
jvmfwk
FRAMEWORKLIB
=
javafwk
TARGET
=
$(FRAMEWORKLIB)
#LIBTARGET=NO
ENABLE_EXCEPTIONS
=
TRUE
.INCLUDE
:
settings.mk
DLLPRE
=
.IF
"$(SOLAR_JAVA)"
==
""
nojava
:
@echo
"Not building jvmaccess because Java is disabled"
.ENDIF
UNOUCROUT
=
$(OUT)$/
inc
SLOFILES
=
\
$(SLO)$/
framework.obj
\
$(SLO)$/
libxmlutil.obj
\
$(SLO)$/
fwkutil.obj
\
$(SLO)$/
elements.obj
#LIB1TARGET=$(SLB)$/$(FRAMEWORKLIB).lib
SHL1TARGET
=
$(FRAMEWORKLIB)
SHL1DEPN
=
SHL1IMPLIB
=
i
$(FRAMEWORKLIB)
SHL1LIBS
=
$(SLB)$/$(TARGET)
.lib
SHL1STDLIBS
=
$(CPPULIB)
$(CPPUHELPERLIB)
$(SALLIB)
$(SALHELPERLIB)
ixml2.lib
SHL1VERSIONMAP
=
framework.map
SHL1DEF
=
$(MISC)$/$(SHL1TARGET)
.def
DEF1NAME
=
$(SHL1TARGET)
.INCLUDE
:
target.mk
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment