1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_jvmfwk.hxx" 30 #include "libxmlutil.hxx" 31 32 namespace jfw 33 { 34 35 CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* aObject) 36 : _object(aObject) 37 { 38 } 39 40 CXPathObjectPtr::CXPathObjectPtr():_object(NULL) 41 { 42 } 43 44 CXPathObjectPtr::~CXPathObjectPtr() 45 { 46 xmlXPathFreeObject(_object); 47 } 48 CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj) 49 { 50 if (_object == pObj) 51 return *this; 52 53 xmlXPathFreeObject(_object); 54 _object = pObj; 55 return *this; 56 } 57 xmlXPathObject* CXPathObjectPtr::operator ->() 58 59 { 60 return _object; 61 } 62 CXPathObjectPtr::operator xmlXPathObject*() 63 { 64 return _object; 65 } 66 //=========================================================== 67 CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext) 68 : _object(aContext) 69 { 70 } 71 72 CXPathContextPtr::CXPathContextPtr():_object(NULL) 73 { 74 } 75 76 CXPathContextPtr::~CXPathContextPtr() 77 { 78 xmlXPathFreeContext(_object); 79 } 80 81 CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj) 82 { 83 if (_object == pObj) 84 return *this; 85 xmlXPathFreeContext(_object); 86 _object = pObj; 87 return *this; 88 } 89 xmlXPathContext* CXPathContextPtr::operator ->() 90 { 91 return _object; 92 } 93 94 CXPathContextPtr::operator xmlXPathContext*() 95 { 96 return _object; 97 } 98 //=========================================================== 99 CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc) 100 : _object(aDoc) 101 { 102 } 103 104 CXmlDocPtr::CXmlDocPtr():_object(NULL) 105 { 106 } 107 108 CXmlDocPtr::~CXmlDocPtr() 109 { 110 xmlFreeDoc(_object); 111 } 112 CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj) 113 { 114 if (_object == pObj) 115 return *this; 116 xmlFreeDoc(_object); 117 _object = pObj; 118 return *this; 119 } 120 121 xmlDoc* CXmlDocPtr::operator ->() 122 { 123 return _object; 124 } 125 126 CXmlDocPtr::operator xmlDoc*() 127 { 128 return _object; 129 } 130 131 //=========================================================== 132 CXmlCharPtr::CXmlCharPtr(xmlChar * aChar) 133 : _object(aChar) 134 { 135 } 136 137 CXmlCharPtr::CXmlCharPtr(const ::rtl::OUString & s): 138 _object(NULL) 139 { 140 ::rtl::OString o = ::rtl::OUStringToOString(s, RTL_TEXTENCODING_UTF8); 141 _object = xmlCharStrdup(o.getStr()); 142 } 143 CXmlCharPtr::CXmlCharPtr():_object(NULL) 144 { 145 } 146 147 CXmlCharPtr::~CXmlCharPtr() 148 { 149 xmlFree(_object); 150 } 151 152 CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj) 153 { 154 if (pObj == _object) 155 return *this; 156 xmlFree(_object); 157 _object = pObj; 158 return *this; 159 } 160 161 CXmlCharPtr::operator xmlChar*() 162 { 163 return _object; 164 } 165 166 CXmlCharPtr::operator ::rtl::OUString() 167 { 168 ::rtl::OUString ret; 169 if (_object != NULL) 170 { 171 ::rtl::OString aOStr((sal_Char*)_object); 172 ret = ::rtl::OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8); 173 } 174 return ret; 175 } 176 177 CXmlCharPtr::operator ::rtl::OString() 178 { 179 return ::rtl::OString((sal_Char*) _object); 180 } 181 182 183 184 } 185