1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xpathobject.cxx,v $
10 * $Revision: 1.4.20.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "xpathobject.hxx"
33 #include "nodelist.hxx"
37 CXPathObject::CXPathObject(xmlXPathObjectPtr xpathObj
)
38 : m_pXPathObj(xpathObj
, xmlXPathFreeObject
)
40 switch (m_pXPathObj
->type
)
43 m_xPathObjectType
= XPathObjectType_XPATH_UNDEFINED
;
46 m_xPathObjectType
= XPathObjectType_XPATH_NODESET
;
49 m_xPathObjectType
= XPathObjectType_XPATH_BOOLEAN
;
52 m_xPathObjectType
= XPathObjectType_XPATH_NUMBER
;
55 m_xPathObjectType
= XPathObjectType_XPATH_STRING
;
58 m_xPathObjectType
= XPathObjectType_XPATH_POINT
;
61 m_xPathObjectType
= XPathObjectType_XPATH_RANGE
;
63 case XPATH_LOCATIONSET
:
64 m_xPathObjectType
= XPathObjectType_XPATH_LOCATIONSET
;
67 m_xPathObjectType
= XPathObjectType_XPATH_USERS
;
70 m_xPathObjectType
= XPathObjectType_XPATH_XSLT_TREE
;
73 m_xPathObjectType
= XPathObjectType_XPATH_UNDEFINED
;
81 XPathObjectType
CXPathObject::getObjectType() throw (RuntimeException
)
83 return m_xPathObjectType
;
87 get the nodes from a nodelist type object
89 Reference
< XNodeList
> SAL_CALL
CXPathObject::getNodeList() throw (RuntimeException
)
91 return Reference
< XNodeList
>(new CNodeList(m_pXPathObj
));
95 get value of a boolean object
97 sal_Bool SAL_CALL
CXPathObject::getBoolean() throw (RuntimeException
)
99 return (sal_Bool
) xmlXPathCastToBoolean(m_pXPathObj
.get());
105 sal_Int8 SAL_CALL
CXPathObject::getByte() throw (RuntimeException
)
107 return (sal_Int8
) xmlXPathCastToNumber(m_pXPathObj
.get());
113 sal_Int16 SAL_CALL
CXPathObject::getShort() throw (RuntimeException
)
115 return (sal_Int16
) xmlXPathCastToNumber(m_pXPathObj
.get());
121 sal_Int32 SAL_CALL
CXPathObject::getLong() throw (RuntimeException
)
123 return (sal_Int32
) xmlXPathCastToNumber(m_pXPathObj
.get());
129 sal_Int64 SAL_CALL
CXPathObject::getHyper() throw (RuntimeException
)
131 return (sal_Int64
) xmlXPathCastToNumber(m_pXPathObj
.get());
137 float SAL_CALL
CXPathObject::getFloat() throw (RuntimeException
)
139 return (float) xmlXPathCastToNumber(m_pXPathObj
.get());
145 double SAL_CALL
CXPathObject::getDouble() throw (RuntimeException
)
147 return xmlXPathCastToNumber(m_pXPathObj
.get());
153 OUString SAL_CALL
CXPathObject::getString() throw (RuntimeException
)
155 const sal_Char
* x1
= (sal_Char
*) xmlXPathCastToString(m_pXPathObj
.get());
156 return OUString(x1
, strlen(x1
), RTL_TEXTENCODING_UTF8
);