LibreOffice Module unoxml (master) 1
documenttype.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 "documenttype.hxx"
21
22#include <string.h>
23
24#include <osl/diagnose.h>
25
26#include "entitiesmap.hxx"
27#include "notationsmap.hxx"
28
29using namespace css::uno;
30using namespace css::xml::dom;
31
32namespace DOM
33{
34
36 CDocument const& rDocument, ::osl::Mutex const& rMutex,
37 xmlDtdPtr const pDtd)
38 : CDocumentType_Base(rDocument, rMutex,
39 NodeType_DOCUMENT_TYPE_NODE, reinterpret_cast<xmlNodePtr>(pDtd))
40 , m_aDtdPtr(pDtd)
41 {
42 }
43
48 css::uno::Reference< XNamedNodeMap > SAL_CALL CDocumentType::getEntities()
49 {
50 ::osl::MutexGuard const g(m_rMutex);
51
52 css::uno::Reference< XNamedNodeMap > aMap;
53 if (m_aDtdPtr != nullptr)
54 {
55 aMap.set(new CEntitiesMap);
56 }
57 return aMap;
58 }
59
64 {
65 OSL_ENSURE(false,
66 "CDocumentType::getInternalSubset: not implemented (#i113683#)");
67 return OUString();
68 }
69
74 OUString SAL_CALL CDocumentType::getName()
75 {
76 ::osl::MutexGuard const g(m_rMutex);
77
78 OUString aName;
79 if (m_aDtdPtr != nullptr)
80 {
81 aName = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->name)), RTL_TEXTENCODING_UTF8);
82 }
83 return aName;
84 }
85
89 css::uno::Reference< XNamedNodeMap > SAL_CALL CDocumentType::getNotations()
90 {
91 ::osl::MutexGuard const g(m_rMutex);
92
93 css::uno::Reference< XNamedNodeMap > aMap;
94 if (m_aDtdPtr != nullptr)
95 {
96 aMap.set(new CNotationsMap);
97 }
98 return aMap;
99 }
100
104 OUString SAL_CALL CDocumentType::getPublicId()
105 {
106 ::osl::MutexGuard const g(m_rMutex);
107
108 OUString aId;
109 if (m_aDtdPtr != nullptr)
110 {
111 aId = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->ExternalID)), RTL_TEXTENCODING_UTF8);
112 }
113 return aId;
114 }
115
119 OUString SAL_CALL CDocumentType::getSystemId()
120 {
121 ::osl::MutexGuard const g(m_rMutex);
122
123 OUString aId;
124 if (m_aDtdPtr != nullptr)
125 {
126 aId = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->SystemID)), RTL_TEXTENCODING_UTF8);
127 }
128 return aId;
129 }
130
131 OUString SAL_CALL CDocumentType::getNodeName()
132 {
133 return getName();
134 }
135
136 OUString SAL_CALL CDocumentType::getNodeValue()
137 {
138 return OUString();
139 }
140}
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString SAL_CALL getPublicId() override
The public identifier of the external subset.
CDocumentType(CDocument const &rDocument, ::osl::Mutex const &rMutex, xmlDtdPtr const pDtd)
virtual OUString SAL_CALL getName() override
The name of DTD; i.e., the name immediately following the DOCTYPE keyword.
virtual css::uno::Reference< css::xml::dom::XNamedNodeMap > SAL_CALL getNotations() override
A NamedNodeMap containing the notations declared in the DTD.
virtual OUString SAL_CALL getNodeValue() override
virtual css::uno::Reference< css::xml::dom::XNamedNodeMap > SAL_CALL getEntities() override
A NamedNodeMap containing the general entities, both external and internal, declared in the DTD.
virtual OUString SAL_CALL getSystemId() override
The system identifier of the external subset.
virtual OUString SAL_CALL getNodeName() override
virtual OUString SAL_CALL getInternalSubset() override
The internal subset as a string, or null if there is none.
::osl::Mutex & m_rMutex
OUString aName
Definition: attr.cxx:38
::cppu::ImplInheritanceHelper< CNode, css::xml::dom::XDocumentType > CDocumentType_Base
HashMap_OWString_Interface aMap