LibreOffice Module unoxml (master) 1
entity.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "entity.hxx"
21
22#include <osl/diagnose.h>
23
24#include <string.h>
25
26using namespace css::uno;
27using namespace css::xml::dom;
28
29namespace DOM
30{
31
32 CEntity::CEntity(CDocument const& rDocument, ::osl::Mutex const& rMutex,
33 xmlEntityPtr const pEntity)
34 : CEntity_Base(rDocument, rMutex,
35 NodeType_ENTITY_NODE, reinterpret_cast<xmlNodePtr>(pEntity))
36 , m_aEntityPtr(pEntity)
37 {
38 }
39
40 bool CEntity::IsChildTypeAllowed(NodeType const nodeType, NodeType const*const)
41 {
42 switch (nodeType) {
43 case NodeType_ELEMENT_NODE:
44 case NodeType_PROCESSING_INSTRUCTION_NODE:
45 case NodeType_COMMENT_NODE:
46 case NodeType_TEXT_NODE:
47 case NodeType_CDATA_SECTION_NODE:
48 case NodeType_ENTITY_REFERENCE_NODE:
49 return true;
50 default:
51 return false;
52 }
53 }
54
58 OUString SAL_CALL CEntity::getNotationName()
59 {
60 OSL_ENSURE(false,
61 "CEntity::getNotationName: not implemented (#i113683#)");
62 return OUString();
63 }
64
68 OUString SAL_CALL CEntity::getPublicId()
69 {
70 ::osl::MutexGuard const g(m_rMutex);
71
72 OUString aID;
73 if(m_aEntityPtr != nullptr)
74 {
75 aID = OUString(reinterpret_cast<char const *>(m_aEntityPtr->ExternalID), strlen(reinterpret_cast<char const *>(m_aEntityPtr->ExternalID)), RTL_TEXTENCODING_UTF8);
76 }
77 return aID;
78 }
79
83 OUString SAL_CALL CEntity::getSystemId()
84 {
85 ::osl::MutexGuard const g(m_rMutex);
86
87 OUString aID;
88 if(m_aEntityPtr != nullptr)
89 {
90 aID = OUString(reinterpret_cast<char const *>(m_aEntityPtr->SystemID), strlen(reinterpret_cast<char const *>(m_aEntityPtr->SystemID)), RTL_TEXTENCODING_UTF8);
91 }
92 return aID;
93 }
94 OUString SAL_CALL CEntity::getNodeName()
95 {
96 ::osl::MutexGuard const g(m_rMutex);
97
98 OUString aName;
99 if (m_aNodePtr != nullptr)
100 {
101 const xmlChar* pName = m_aNodePtr->name;
102 aName = OUString(reinterpret_cast<char const *>(pName), strlen(reinterpret_cast<char const *>(pName)), RTL_TEXTENCODING_UTF8);
103 }
104 return aName;
105 }
106 OUString SAL_CALL CEntity::getNodeValue()
107 {
108 return OUString();
109 }
110}
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
virtual OUString SAL_CALL getPublicId() override
The public identifier associated with the entity, if specified.
Definition: entity.cxx:68
xmlEntityPtr m_aEntityPtr
Definition: entity.hxx:42
virtual OUString SAL_CALL getNodeValue() override
Definition: entity.cxx:106
virtual bool IsChildTypeAllowed(css::xml::dom::NodeType const nodeType, css::xml::dom::NodeType const *) override
Definition: entity.cxx:40
virtual OUString SAL_CALL getNodeName() override
Definition: entity.cxx:94
virtual OUString SAL_CALL getNotationName() override
For unparsed entities, the name of the notation for the entity.
Definition: entity.cxx:58
virtual OUString SAL_CALL getSystemId() override
The system identifier associated with the entity, if specified.
Definition: entity.cxx:83
CEntity(CDocument const &rDocument, ::osl::Mutex const &rMutex, xmlEntityPtr const pEntity)
Definition: entity.cxx:32
::osl::Mutex & m_rMutex
OUString aName
Definition: attr.cxx:38
::cppu::ImplInheritanceHelper< CNode, css::xml::dom::XEntity > CEntity_Base
Definition: entity.hxx:34
NodeType