Line data Source code
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 :
29 : using namespace css::uno;
30 : using namespace css::xml::dom;
31 :
32 : namespace DOM
33 : {
34 :
35 0 : CDocumentType::CDocumentType(
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 0 : , m_aDtdPtr(pDtd)
41 : {
42 0 : }
43 :
44 : /**
45 : A NamedNodeMap containing the general entities, both external and
46 : internal, declared in the DTD.
47 : */
48 0 : css::uno::Reference< XNamedNodeMap > SAL_CALL CDocumentType::getEntities() throw (RuntimeException, std::exception)
49 : {
50 0 : ::osl::MutexGuard const g(m_rMutex);
51 :
52 0 : css::uno::Reference< XNamedNodeMap > aMap;
53 0 : if (m_aDtdPtr != NULL)
54 : {
55 0 : aMap.set(new CEntitiesMap(this));
56 : }
57 0 : return aMap;
58 : }
59 :
60 : /**
61 : The internal subset as a string, or null if there is none.
62 : */
63 0 : OUString SAL_CALL CDocumentType::getInternalSubset() throw (RuntimeException, std::exception)
64 : {
65 : OSL_ENSURE(false,
66 : "CDocumentType::getInternalSubset: not implemented (#i113683#)");
67 0 : return OUString();
68 : }
69 :
70 : /**
71 : The name of DTD; i.e., the name immediately following the DOCTYPE
72 : keyword.
73 : */
74 0 : OUString SAL_CALL CDocumentType::getName() throw (RuntimeException, std::exception)
75 : {
76 0 : ::osl::MutexGuard const g(m_rMutex);
77 :
78 0 : OUString aName;
79 0 : if (m_aDtdPtr != NULL)
80 : {
81 0 : aName = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->name)), RTL_TEXTENCODING_UTF8);
82 : }
83 0 : return aName;
84 : }
85 :
86 : /**
87 : A NamedNodeMap containing the notations declared in the DTD.
88 : */
89 0 : css::uno::Reference< XNamedNodeMap > SAL_CALL CDocumentType::getNotations() throw (RuntimeException, std::exception)
90 : {
91 0 : ::osl::MutexGuard const g(m_rMutex);
92 :
93 0 : css::uno::Reference< XNamedNodeMap > aMap;
94 0 : if (m_aDtdPtr != NULL)
95 : {
96 0 : aMap.set(new CNotationsMap(this));
97 : }
98 0 : return aMap;
99 : }
100 :
101 : /**
102 : The public identifier of the external subset.
103 : */
104 0 : OUString SAL_CALL CDocumentType::getPublicId() throw (RuntimeException, std::exception)
105 : {
106 0 : ::osl::MutexGuard const g(m_rMutex);
107 :
108 0 : OUString aId;
109 0 : if (m_aDtdPtr != NULL)
110 : {
111 0 : aId = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->ExternalID)), RTL_TEXTENCODING_UTF8);
112 : }
113 0 : return aId;
114 : }
115 :
116 : /**
117 : The system identifier of the external subset.
118 : */
119 0 : OUString SAL_CALL CDocumentType::getSystemId() throw (RuntimeException, std::exception)
120 : {
121 0 : ::osl::MutexGuard const g(m_rMutex);
122 :
123 0 : OUString aId;
124 0 : if (m_aDtdPtr != NULL)
125 : {
126 0 : aId = OUString(reinterpret_cast<char const *>(m_aDtdPtr->name), strlen(reinterpret_cast<char const *>(m_aDtdPtr->SystemID)), RTL_TEXTENCODING_UTF8);
127 : }
128 0 : return aId;
129 : }
130 :
131 0 : OUString SAL_CALL CDocumentType::getNodeName()throw (RuntimeException, std::exception)
132 : {
133 0 : return getName();
134 : }
135 :
136 0 : OUString SAL_CALL CDocumentType::getNodeValue() throw (RuntimeException, std::exception)
137 : {
138 0 : return OUString();
139 : }
140 : }
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|