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 <entity.hxx> 25 26 #include <string.h> 27 28 29 namespace DOM 30 { 31 CEntity(CDocument const & rDocument,::osl::Mutex const & rMutex,xmlEntityPtr const pEntity)32 CEntity::CEntity(CDocument const& rDocument, ::osl::Mutex const& rMutex, 33 xmlEntityPtr const pEntity) 34 : CEntity_Base(rDocument, rMutex, 35 NodeType_ENTITY_NODE, reinterpret_cast<xmlNodePtr>(pEntity)) 36 , m_aEntityPtr(pEntity) 37 { 38 } 39 IsChildTypeAllowed(NodeType const nodeType)40 bool CEntity::IsChildTypeAllowed(NodeType const nodeType) 41 { 42 switch (nodeType) { 43 case NodeType_ELEMENT_NODE: 44 case NodeType_PROCESSING_INSTRUCTION_NODE: 45 case NodeType_COMMENT_NODE: 46 case NodeType_TEXT_NODE: 47 case NodeType_CDATA_SECTION_NODE: 48 case NodeType_ENTITY_REFERENCE_NODE: 49 return true; 50 default: 51 return false; 52 } 53 } 54 55 /** 56 For unparsed entities, the name of the notation for the entity. 57 */ getNotationName()58 OUString SAL_CALL CEntity::getNotationName() throw (RuntimeException) 59 { 60 OSL_ENSURE(false, 61 "CEntity::getNotationName: not implemented (#i113683#)"); 62 return OUString(); 63 } 64 65 /** 66 The public identifier associated with the entity, if specified. 67 */ getPublicId()68 OUString SAL_CALL CEntity::getPublicId() throw (RuntimeException) 69 { 70 ::osl::MutexGuard const g(m_rMutex); 71 72 OUString aID; 73 if(m_aEntityPtr != NULL) 74 { 75 aID = OUString((sal_Char*)m_aEntityPtr->ExternalID, strlen((char*)m_aEntityPtr->ExternalID), RTL_TEXTENCODING_UTF8); 76 } 77 return aID; 78 } 79 80 /** 81 The system identifier associated with the entity, if specified. 82 */ getSystemId()83 OUString SAL_CALL CEntity::getSystemId() throw (RuntimeException) 84 { 85 ::osl::MutexGuard const g(m_rMutex); 86 87 OUString aID; 88 if(m_aEntityPtr != NULL) 89 { 90 aID = OUString((sal_Char*)m_aEntityPtr->SystemID, strlen((char*)m_aEntityPtr->SystemID), RTL_TEXTENCODING_UTF8); 91 } 92 return aID; 93 } getNodeName()94 OUString SAL_CALL CEntity::getNodeName()throw (RuntimeException) 95 { 96 ::osl::MutexGuard const g(m_rMutex); 97 98 OUString aName; 99 if (m_aNodePtr != NULL) 100 { 101 const xmlChar* xName = m_aNodePtr->name; 102 aName = OUString((sal_Char*)xName, strlen((char*)xName), RTL_TEXTENCODING_UTF8); 103 } 104 return aName; 105 } getNodeValue()106 OUString SAL_CALL CEntity::getNodeValue() throw (RuntimeException) 107 { 108 return OUString(); 109 } 110 } 111