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