xref: /trunk/main/unoxml/source/dom/documenttype.cxx (revision e9cbe144)
1*e9cbe144SAndrew Rist /**************************************************************
2*e9cbe144SAndrew Rist  *
3*e9cbe144SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e9cbe144SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e9cbe144SAndrew Rist  * distributed with this work for additional information
6*e9cbe144SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e9cbe144SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e9cbe144SAndrew Rist  * "License"); you may not use this file except in compliance
9*e9cbe144SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e9cbe144SAndrew Rist  *
11*e9cbe144SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e9cbe144SAndrew Rist  *
13*e9cbe144SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e9cbe144SAndrew Rist  * software distributed under the License is distributed on an
15*e9cbe144SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e9cbe144SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e9cbe144SAndrew Rist  * specific language governing permissions and limitations
18*e9cbe144SAndrew Rist  * under the License.
19*e9cbe144SAndrew Rist  *
20*e9cbe144SAndrew Rist  *************************************************************/
21*e9cbe144SAndrew Rist 
22*e9cbe144SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <documenttype.hxx>
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <string.h>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <entitiesmap.hxx>
29cdf0e10cSrcweir #include <notationsmap.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace DOM
33cdf0e10cSrcweir {
34cdf0e10cSrcweir 
CDocumentType(CDocument const & rDocument,::osl::Mutex const & rMutex,xmlDtdPtr const pDtd)35cdf0e10cSrcweir     CDocumentType::CDocumentType(
36cdf0e10cSrcweir             CDocument const& rDocument, ::osl::Mutex const& rMutex,
37cdf0e10cSrcweir             xmlDtdPtr const pDtd)
38cdf0e10cSrcweir         : CDocumentType_Base(rDocument, rMutex,
39cdf0e10cSrcweir             NodeType_DOCUMENT_TYPE_NODE, reinterpret_cast<xmlNodePtr>(pDtd))
40cdf0e10cSrcweir         , m_aDtdPtr(pDtd)
41cdf0e10cSrcweir     {
42cdf0e10cSrcweir     }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     /**
45cdf0e10cSrcweir     A NamedNodeMap containing the general entities, both external and
46cdf0e10cSrcweir     internal, declared in the DTD.
47cdf0e10cSrcweir     */
getEntities()48cdf0e10cSrcweir     Reference< XNamedNodeMap > SAL_CALL CDocumentType::getEntities() throw (RuntimeException)
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         ::osl::MutexGuard const g(m_rMutex);
51cdf0e10cSrcweir 
52cdf0e10cSrcweir         Reference< XNamedNodeMap > aMap;
53cdf0e10cSrcweir         if (m_aDtdPtr != NULL)
54cdf0e10cSrcweir         {
55cdf0e10cSrcweir             aMap.set(new CEntitiesMap(this, m_rMutex));
56cdf0e10cSrcweir         }
57cdf0e10cSrcweir         return aMap;
58cdf0e10cSrcweir     }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     /**
61cdf0e10cSrcweir     The internal subset as a string, or null if there is none.
62cdf0e10cSrcweir     */
getInternalSubset()63cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getInternalSubset() throw (RuntimeException)
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         OSL_ENSURE(false,
66cdf0e10cSrcweir             "CDocumentType::getInternalSubset: not implemented (#i113683#)");
67cdf0e10cSrcweir         return OUString();
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     /**
71cdf0e10cSrcweir     The name of DTD; i.e., the name immediately following the DOCTYPE
72cdf0e10cSrcweir     keyword.
73cdf0e10cSrcweir     */
getName()74cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getName() throw (RuntimeException)
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         ::osl::MutexGuard const g(m_rMutex);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         OUString aName;
79cdf0e10cSrcweir         if (m_aDtdPtr != NULL)
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             aName = OUString((sal_Char*)m_aDtdPtr->name, strlen((char*)m_aDtdPtr->name), RTL_TEXTENCODING_UTF8);
82cdf0e10cSrcweir         }
83cdf0e10cSrcweir         return aName;
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     /**
87cdf0e10cSrcweir     A NamedNodeMap containing the notations declared in the DTD.
88cdf0e10cSrcweir     */
getNotations()89cdf0e10cSrcweir     Reference< XNamedNodeMap > SAL_CALL CDocumentType::getNotations() throw (RuntimeException)
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         ::osl::MutexGuard const g(m_rMutex);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         Reference< XNamedNodeMap > aMap;
94cdf0e10cSrcweir         if (m_aDtdPtr != NULL)
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             aMap.set(new CNotationsMap(this, m_rMutex));
97cdf0e10cSrcweir         }
98cdf0e10cSrcweir         return aMap;
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     /**
102cdf0e10cSrcweir     The public identifier of the external subset.
103cdf0e10cSrcweir     */
getPublicId()104cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getPublicId() throw (RuntimeException)
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         ::osl::MutexGuard const g(m_rMutex);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         OUString aId;
109cdf0e10cSrcweir         if (m_aDtdPtr != NULL)
110cdf0e10cSrcweir         {
111cdf0e10cSrcweir             aId = OUString((sal_Char*)m_aDtdPtr->name, strlen((char*)m_aDtdPtr->ExternalID), RTL_TEXTENCODING_UTF8);
112cdf0e10cSrcweir         }
113cdf0e10cSrcweir         return aId;
114cdf0e10cSrcweir     }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     /**
117cdf0e10cSrcweir     The system identifier of the external subset.
118cdf0e10cSrcweir     */
getSystemId()119cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getSystemId() throw (RuntimeException)
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir         ::osl::MutexGuard const g(m_rMutex);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         OUString aId;
124cdf0e10cSrcweir         if (m_aDtdPtr != NULL)
125cdf0e10cSrcweir         {
126cdf0e10cSrcweir             aId = OUString((sal_Char*)m_aDtdPtr->name, strlen((char*)m_aDtdPtr->SystemID), RTL_TEXTENCODING_UTF8);
127cdf0e10cSrcweir         }
128cdf0e10cSrcweir         return aId;
129cdf0e10cSrcweir     }
130cdf0e10cSrcweir 
getNodeName()131cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getNodeName()throw (RuntimeException)
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         return getName();
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir 
getNodeValue()136cdf0e10cSrcweir     OUString SAL_CALL CDocumentType::getNodeValue() throw (RuntimeException)
137cdf0e10cSrcweir     {
138cdf0e10cSrcweir         return OUString();
139cdf0e10cSrcweir     }
140cdf0e10cSrcweir }
141