LibreOffice Module xmloff (master)  1
TransformerContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <com/sun/star/xml/sax/SAXException.hpp>
21 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
22 #include <com/sun/star/xml/sax/XAttributeList.hpp>
23 #include <osl/diagnose.h>
24 
25 #include "TransformerBase.hxx"
26 
27 #include "TransformerContext.hxx"
28 
29 
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::xml::sax;
32 
33 bool XMLTransformerContext::HasQName( sal_uInt16 nPrefix,
35 {
36  OUString aLocalName;
38  &aLocalName ) == nPrefix &&
39  ::xmloff::token::IsXMLToken( aLocalName, eToken );
40 }
41 
42 bool XMLTransformerContext::HasNamespace( sal_uInt16 nPrefix ) const
43 {
45 }
46 
48  const OUString& rQName )
49  : m_rTransformer(rImp)
50  , m_aQName(rQName)
51 {
52 }
53 
55  const OUString& rLocalName,
56  const OUString& rQName,
57  const Reference< XAttributeList >& )
58 {
59  return m_rTransformer.CreateContext( nPrefix, rLocalName, rQName );
60 }
61 
62 void XMLTransformerContext::StartElement( const Reference< XAttributeList >& rAttrList )
63 {
64  m_rTransformer.GetDocHandler()->startElement( m_aQName, rAttrList );
65 }
66 
68 {
69  GetTransformer().GetDocHandler()->endElement( m_aQName );
70 }
71 
72 void XMLTransformerContext::Characters( const OUString& rChars )
73 {
74  m_rTransformer.GetDocHandler()->characters( rChars );
75 }
76 
78 {
79  return false;
80 }
81 
83 {
84  OSL_ENSURE( false, "context is not persistent" );
85 }
86 
88 {
89  OSL_ENSURE( false, "context is not persistent" );
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
XMLTransformerBase & m_rTransformer
SvXMLNamespaceMap & GetNamespaceMap()
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
bool HasQName(sal_uInt16 nPrefix,::xmloff::token::XMLTokenEnum eToken) const
bool HasNamespace(sal_uInt16 nPrefix) const
virtual void Characters(const OUString &rChars)
XMLTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
XMLTransformerBase & GetTransformer()
XMLTransformerContext * CreateContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName)
virtual bool IsPersistent() const
XMLTokenEnum eToken
Definition: xmltoken.cxx:40
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)