Update ooo320-m1
[ooovba.git] / jvmfwk / source / libxmlutil.cxx
blob8542889a7cbd008e19210bd5de661267eaac53fc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: libxmlutil.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_jvmfwk.hxx"
33 #include "libxmlutil.hxx"
35 namespace jfw
38 CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* aObject)
39 : _object(aObject)
43 CXPathObjectPtr::CXPathObjectPtr():_object(NULL)
47 CXPathObjectPtr::~CXPathObjectPtr()
49 xmlXPathFreeObject(_object);
51 CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj)
53 if (_object == pObj)
54 return *this;
56 xmlXPathFreeObject(_object);
57 _object = pObj;
58 return *this;
60 xmlXPathObject* CXPathObjectPtr::operator ->()
63 return _object;
65 CXPathObjectPtr::operator xmlXPathObject*()
67 return _object;
69 //===========================================================
70 CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext)
71 : _object(aContext)
75 CXPathContextPtr::CXPathContextPtr():_object(NULL)
79 CXPathContextPtr::~CXPathContextPtr()
81 xmlXPathFreeContext(_object);
84 CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj)
86 if (_object == pObj)
87 return *this;
88 xmlXPathFreeContext(_object);
89 _object = pObj;
90 return *this;
92 xmlXPathContext* CXPathContextPtr::operator ->()
94 return _object;
97 CXPathContextPtr::operator xmlXPathContext*()
99 return _object;
101 //===========================================================
102 CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc)
103 : _object(aDoc)
107 CXmlDocPtr::CXmlDocPtr():_object(NULL)
111 CXmlDocPtr::~CXmlDocPtr()
113 xmlFreeDoc(_object);
115 CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj)
117 if (_object == pObj)
118 return *this;
119 xmlFreeDoc(_object);
120 _object = pObj;
121 return *this;
124 xmlDoc* CXmlDocPtr::operator ->()
126 return _object;
129 CXmlDocPtr::operator xmlDoc*()
131 return _object;
134 //===========================================================
135 CXmlCharPtr::CXmlCharPtr(xmlChar * aChar)
136 : _object(aChar)
140 CXmlCharPtr::CXmlCharPtr(const ::rtl::OUString & s):
141 _object(NULL)
143 ::rtl::OString o = ::rtl::OUStringToOString(s, RTL_TEXTENCODING_UTF8);
144 _object = xmlCharStrdup(o.getStr());
146 CXmlCharPtr::CXmlCharPtr():_object(NULL)
150 CXmlCharPtr::~CXmlCharPtr()
152 xmlFree(_object);
155 CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj)
157 if (pObj == _object)
158 return *this;
159 xmlFree(_object);
160 _object = pObj;
161 return *this;
164 CXmlCharPtr::operator xmlChar*()
166 return _object;
169 CXmlCharPtr::operator ::rtl::OUString()
171 ::rtl::OUString ret;
172 if (_object != NULL)
174 ::rtl::OString aOStr((sal_Char*)_object);
175 ret = ::rtl::OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
177 return ret;
180 CXmlCharPtr::operator ::rtl::OString()
182 return ::rtl::OString((sal_Char*) _object);