tdf#137105: crash in table with Style Inspector active
[LibreOffice.git] / jvmfwk / source / libxmlutil.cxx
blob2619e43331c4183cd17f6b3d0a2235c60a78488a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <libxmlutil.hxx>
22 namespace jfw
25 CXPathObjectPtr::CXPathObjectPtr():_object(nullptr)
28 CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* pObj):_object(pObj)
31 CXPathObjectPtr::~CXPathObjectPtr()
33 xmlXPathFreeObject(_object);
35 CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj)
37 if (_object == pObj)
38 return *this;
40 xmlXPathFreeObject(_object);
41 _object = pObj;
42 return *this;
45 CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext)
46 : _object(aContext)
50 CXPathContextPtr::CXPathContextPtr():_object(nullptr)
54 CXPathContextPtr::~CXPathContextPtr()
56 xmlXPathFreeContext(_object);
59 CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj)
61 if (_object == pObj)
62 return *this;
63 xmlXPathFreeContext(_object);
64 _object = pObj;
65 return *this;
69 CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc)
70 : _object(aDoc)
74 CXmlDocPtr::CXmlDocPtr():_object(nullptr)
78 CXmlDocPtr::~CXmlDocPtr()
80 xmlFreeDoc(_object);
82 CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj)
84 if (_object == pObj)
85 return *this;
86 xmlFreeDoc(_object);
87 _object = pObj;
88 return *this;
92 CXmlCharPtr::CXmlCharPtr(xmlChar * aChar)
93 : _object(aChar)
97 CXmlCharPtr::CXmlCharPtr(const OUString & s):
98 _object(nullptr)
100 OString o = OUStringToOString(s, RTL_TEXTENCODING_UTF8);
101 _object = xmlCharStrdup(o.getStr());
103 CXmlCharPtr::CXmlCharPtr():_object(nullptr)
107 CXmlCharPtr::~CXmlCharPtr()
109 xmlFree(_object);
112 CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj)
114 if (pObj == _object)
115 return *this;
116 xmlFree(_object);
117 _object = pObj;
118 return *this;
122 CXmlCharPtr::operator OUString()
124 OUString ret;
125 if (_object != nullptr)
127 OString aOStr(reinterpret_cast<char*>(_object));
128 ret = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
130 return ret;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */