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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <com/sun/star/xml/sax/SAXParseException.hpp>
27 #include <com/sun/star/xml/sax/SAXException.hpp>
28 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
29 #include <com/sun/star/xml/sax/XAttributeList.hpp>
30 #include <xmloff/nmspmap.hxx>
31
32 #ifndef _XMLOFF_TRANSFOERMERBASE_HXX
33 #include "TransformerBase.hxx"
34 #endif
35
36 #ifndef _XMLOFF_TRANSFOERMERCONTEXT_HXX
37 #include "TransformerContext.hxx"
38 #endif
39
40 using ::rtl::OUString;
41
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::xml::sax;
44
45 TYPEINIT0( XMLTransformerContext );
46
HasQName(sal_uInt16 nPrefix,::xmloff::token::XMLTokenEnum eToken) const47 sal_Bool XMLTransformerContext::HasQName( sal_uInt16 nPrefix,
48 ::xmloff::token::XMLTokenEnum eToken ) const
49 {
50 OUString aLocalName;
51 return GetTransformer().GetNamespaceMap().GetKeyByAttrName( m_aQName,
52 &aLocalName ) == nPrefix &&
53 ::xmloff::token::IsXMLToken( aLocalName, eToken );
54 }
55
HasNamespace(sal_uInt16 nPrefix) const56 sal_Bool XMLTransformerContext::HasNamespace( sal_uInt16 nPrefix ) const
57 {
58 return GetTransformer().GetNamespaceMap().GetKeyByAttrName( m_aQName ) == nPrefix;
59 }
60
XMLTransformerContext(XMLTransformerBase & rImp,const OUString & rQName)61 XMLTransformerContext::XMLTransformerContext( XMLTransformerBase& rImp,
62 const OUString& rQName ) :
63 m_rTransformer( rImp ),
64 m_aQName( rQName ),
65 m_pRewindMap( 0 )
66 {
67 }
68
~XMLTransformerContext()69 XMLTransformerContext::~XMLTransformerContext()
70 {
71 }
72
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const OUString & rQName,const Reference<XAttributeList> &)73 XMLTransformerContext *XMLTransformerContext::CreateChildContext( sal_uInt16 nPrefix,
74 const OUString& rLocalName,
75 const OUString& rQName,
76 const Reference< XAttributeList >& )
77 {
78 return m_rTransformer.CreateContext( nPrefix, rLocalName, rQName );
79 }
80
StartElement(const Reference<XAttributeList> & rAttrList)81 void XMLTransformerContext::StartElement( const Reference< XAttributeList >& rAttrList )
82 {
83 m_rTransformer.GetDocHandler()->startElement( m_aQName, rAttrList );
84 }
85
EndElement()86 void XMLTransformerContext::EndElement()
87 {
88 m_rTransformer.GetDocHandler()->endElement( m_aQName );
89 }
90
Characters(const OUString & rChars)91 void XMLTransformerContext::Characters( const OUString& rChars )
92 {
93 m_rTransformer.GetDocHandler()->characters( rChars );
94 }
95
IsPersistent() const96 sal_Bool XMLTransformerContext::IsPersistent() const
97 {
98 return sal_False;
99 }
100
Export()101 void XMLTransformerContext::Export()
102 {
103 OSL_ENSURE( !this, "context is not persistent" );
104 }
105
ExportContent()106 void XMLTransformerContext::ExportContent()
107 {
108 OSL_ENSURE( !this, "context is not persistent" );
109 }
110