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