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