1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include <com/sun/star/xml/sax/SAXParseException.hpp> 31 #include <com/sun/star/xml/sax/SAXException.hpp> 32 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 33 #include <com/sun/star/xml/sax/XAttributeList.hpp> 34 #include <xmloff/nmspmap.hxx> 35 36 #ifndef _XMLOFF_TRANSFOERMERBASE_HXX 37 #include "TransformerBase.hxx" 38 #endif 39 40 #ifndef _XMLOFF_TRANSFOERMERCONTEXT_HXX 41 #include "TransformerContext.hxx" 42 #endif 43 44 using ::rtl::OUString; 45 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::xml::sax; 48 49 TYPEINIT0( XMLTransformerContext ); 50 51 sal_Bool XMLTransformerContext::HasQName( sal_uInt16 nPrefix, 52 ::xmloff::token::XMLTokenEnum eToken ) const 53 { 54 OUString aLocalName; 55 return GetTransformer().GetNamespaceMap().GetKeyByAttrName( m_aQName, 56 &aLocalName ) == nPrefix && 57 ::xmloff::token::IsXMLToken( aLocalName, eToken ); 58 } 59 60 sal_Bool XMLTransformerContext::HasNamespace( sal_uInt16 nPrefix ) const 61 { 62 return GetTransformer().GetNamespaceMap().GetKeyByAttrName( m_aQName ) == nPrefix; 63 } 64 65 XMLTransformerContext::XMLTransformerContext( XMLTransformerBase& rImp, 66 const OUString& rQName ) : 67 m_rTransformer( rImp ), 68 m_aQName( rQName ), 69 m_pRewindMap( 0 ) 70 { 71 } 72 73 XMLTransformerContext::~XMLTransformerContext() 74 { 75 } 76 77 XMLTransformerContext *XMLTransformerContext::CreateChildContext( sal_uInt16 nPrefix, 78 const OUString& rLocalName, 79 const OUString& rQName, 80 const Reference< XAttributeList >& ) 81 { 82 return m_rTransformer.CreateContext( nPrefix, rLocalName, rQName ); 83 } 84 85 void XMLTransformerContext::StartElement( const Reference< XAttributeList >& rAttrList ) 86 { 87 m_rTransformer.GetDocHandler()->startElement( m_aQName, rAttrList ); 88 } 89 90 void XMLTransformerContext::EndElement() 91 { 92 m_rTransformer.GetDocHandler()->endElement( m_aQName ); 93 } 94 95 void XMLTransformerContext::Characters( const OUString& rChars ) 96 { 97 m_rTransformer.GetDocHandler()->characters( rChars ); 98 } 99 100 sal_Bool XMLTransformerContext::IsPersistent() const 101 { 102 return sal_False; 103 } 104 105 void XMLTransformerContext::Export() 106 { 107 OSL_ENSURE( !this, "context is not persistent" ); 108 } 109 110 void XMLTransformerContext::ExportContent() 111 { 112 OSL_ENSURE( !this, "context is not persistent" ); 113 } 114