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 "ProcAddAttrTContext.hxx"
31 #include "MutableAttrList.hxx"
32 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
33 #include "TransformerBase.hxx"
34 #endif
35 #include <xmloff/nmspmap.hxx>
36 
37 using ::rtl::OUString;
38 
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::xml::sax;
41 using namespace ::xmloff::token;
42 
43 TYPEINIT1( XMLProcAddAttrTransformerContext, XMLProcAttrTransformerContext);
44 
45 XMLProcAddAttrTransformerContext::XMLProcAddAttrTransformerContext(
46 		XMLTransformerBase& rImp,
47 		const OUString& rQName,
48 	    sal_uInt16 nPrefix,
49 		::xmloff::token::XMLTokenEnum eToken,
50 	    sal_uInt16 nActionMap,
51 		sal_uInt16 nAPrefix,
52 	   	::xmloff::token::XMLTokenEnum eAToken,
53 	   	::xmloff::token::XMLTokenEnum eVToken ) :
54 	XMLProcAttrTransformerContext( rImp, rQName, nPrefix,  eToken, nActionMap ),
55 	m_aAttrQName( rImp.GetNamespaceMap().GetQNameByKey( nAPrefix,
56 									::xmloff::token::GetXMLToken( eAToken ) ) ),
57 	m_aAttrValue( ::xmloff::token::GetXMLToken( eVToken ) )
58 {
59 }
60 
61 XMLProcAddAttrTransformerContext::~XMLProcAddAttrTransformerContext()
62 {
63 }
64 
65 void XMLProcAddAttrTransformerContext::StartElement(
66 		const Reference< XAttributeList >& rAttrList )
67 {
68 	Reference< XAttributeList > xAttrList( rAttrList );
69 	XMLMutableAttributeList *pMutableAttrList =
70 		GetTransformer().ProcessAttrList( xAttrList, GetActionMap(),
71 										  sal_False );
72 	if( !pMutableAttrList )
73 	{
74 		pMutableAttrList = new XMLMutableAttributeList;
75 		xAttrList = pMutableAttrList;
76 	}
77 	pMutableAttrList->AddAttribute( m_aAttrQName, m_aAttrValue );
78 	GetTransformer().GetDocHandler()->startElement( GetElemQName(), xAttrList );
79 }
80 
81