xref: /AOO41X/main/xmloff/source/transform/IgnoreTContext.cxx (revision 63bba73cc51e0afb45f8a8d578158724bb5afee8)
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 "IgnoreTContext.hxx"
27 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
28 #include "TransformerBase.hxx"
29 #endif
30 
31 using ::rtl::OUString;
32 
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::xml::sax;
35 
36 TYPEINIT1( XMLIgnoreTransformerContext, XMLTransformerContext );
37 
XMLIgnoreTransformerContext(XMLTransformerBase & rImp,const OUString & rQName,sal_Bool bIgnoreChars,sal_Bool bIgnoreElems)38 XMLIgnoreTransformerContext::XMLIgnoreTransformerContext(
39         XMLTransformerBase& rImp,
40         const OUString& rQName,
41         sal_Bool bIgnoreChars,
42         sal_Bool bIgnoreElems ) :
43     XMLTransformerContext( rImp, rQName ),
44     m_bIgnoreCharacters( bIgnoreChars ),
45     m_bIgnoreElements( bIgnoreElems ),
46     m_bRecursiveUse( sal_False )
47 {
48 }
49 
XMLIgnoreTransformerContext(XMLTransformerBase & rTransformer,const::rtl::OUString & rQName,sal_Bool bAllowCharactersRecursive)50 XMLIgnoreTransformerContext::XMLIgnoreTransformerContext(
51         XMLTransformerBase& rTransformer,
52         const ::rtl::OUString& rQName,
53         sal_Bool bAllowCharactersRecursive ) :
54     XMLTransformerContext( rTransformer, rQName ),
55     m_bIgnoreCharacters( sal_False ),
56     m_bIgnoreElements( sal_False ),
57     m_bAllowCharactersRecursive( bAllowCharactersRecursive ),
58     m_bRecursiveUse( sal_True )
59 {
60 }
61 
~XMLIgnoreTransformerContext()62 XMLIgnoreTransformerContext::~XMLIgnoreTransformerContext()
63 {
64 }
65 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const OUString & rQName,const Reference<XAttributeList> & xAttrList)66 XMLTransformerContext *XMLIgnoreTransformerContext::CreateChildContext(
67         sal_uInt16 nPrefix,
68         const OUString& rLocalName,
69         const OUString& rQName,
70         const Reference< XAttributeList >& xAttrList )
71 {
72     XMLTransformerContext *pContext = 0;
73     if( m_bIgnoreElements )
74         pContext = new XMLIgnoreTransformerContext( GetTransformer(),
75                                                     rQName, sal_True,
76                                                     sal_True );
77     else if (m_bRecursiveUse)
78         pContext = new XMLIgnoreTransformerContext( GetTransformer(),
79                                                     rQName, m_bAllowCharactersRecursive );
80     else
81         pContext = XMLTransformerContext::CreateChildContext(
82                         nPrefix, rLocalName, rQName, xAttrList );
83 
84     return pContext;
85 }
86 
StartElement(const Reference<XAttributeList> &)87 void XMLIgnoreTransformerContext::StartElement( const Reference< XAttributeList >& )
88 {
89     // ignore
90 }
91 
EndElement()92 void XMLIgnoreTransformerContext::EndElement()
93 {
94     // ignore
95 }
96 
Characters(const OUString & rChars)97 void XMLIgnoreTransformerContext::Characters( const OUString& rChars )
98 {
99     if( !m_bIgnoreCharacters )
100         GetTransformer().GetDocHandler()->characters( rChars );
101     else if ( m_bRecursiveUse && m_bAllowCharactersRecursive )
102         GetTransformer().GetDocHandler()->characters( rChars );
103 }
104 
105 
106