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