xref: /trunk/main/xmloff/source/transform/ControlOOoTContext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 "ControlOOoTContext.hxx"
31 #include "IgnoreTContext.hxx"
32 #include "MutableAttrList.hxx"
33 #include "xmloff/xmlnmspe.hxx"
34 #include "ActionMapTypesOOo.hxx"
35 #include "ElemTransformerAction.hxx"
36 #include "TransformerActions.hxx"
37 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
38 #include "TransformerBase.hxx"
39 #endif
40 
41 using ::rtl::OUString;
42 
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::xml::sax;
45 using namespace ::xmloff::token;
46 
47 TYPEINIT1( XMLControlOOoTransformerContext, XMLTransformerContext );
48 
49 XMLControlOOoTransformerContext::XMLControlOOoTransformerContext(
50         XMLTransformerBase& rImp,
51         const OUString& rQName ) :
52     XMLTransformerContext( rImp, rQName )
53 {
54 }
55 
56 XMLControlOOoTransformerContext::~XMLControlOOoTransformerContext()
57 {
58 }
59 
60 void XMLControlOOoTransformerContext::StartElement(
61     const Reference< XAttributeList >& rAttrList )
62 {
63     m_xAttrList = new XMLMutableAttributeList( rAttrList, sal_True );
64 }
65 
66 XMLTransformerContext *XMLControlOOoTransformerContext::CreateChildContext(
67         sal_uInt16 /*nPrefix*/,
68         const OUString& /*rLocalName*/,
69         const OUString& rQName,
70         const Reference< XAttributeList >& rAttrList )
71 {
72     XMLTransformerContext *pContext = 0;
73 
74     if( !m_aElemQName.getLength() )
75     {
76         pContext = new XMLIgnoreTransformerContext( GetTransformer(),
77                                                     rQName,
78                                                     sal_False, sal_False );
79         m_aElemQName = rQName;
80         static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
81                 ->AppendAttributeList( rAttrList );
82         GetTransformer().ProcessAttrList( m_xAttrList,
83                                           OOO_FORM_CONTROL_ACTIONS,
84                                           sal_False );
85         GetTransformer().GetDocHandler()->startElement( m_aElemQName,
86                                                         m_xAttrList );
87     }
88     else
89     {
90         pContext = new XMLIgnoreTransformerContext( GetTransformer(),
91                                                     rQName,
92                                                     sal_True, sal_True );
93     }
94     return pContext;
95 }
96 
97 void XMLControlOOoTransformerContext::EndElement()
98 {
99     GetTransformer().GetDocHandler()->endElement( m_aElemQName );
100 }
101 
102 void XMLControlOOoTransformerContext::Characters( const OUString& rChars )
103 {
104     // ignore
105     if( m_aElemQName.getLength() )
106         XMLTransformerContext::Characters( rChars );
107 }
108