bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / transform / PersAttrListTContext.cxx
blob6b0112119f415b27399287025cece8d92f8ad81b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/util/XCloneable.hpp>
21 #include "IgnoreTContext.hxx"
22 #include "TransformerBase.hxx"
23 #include "MutableAttrList.hxx"
24 #include <xmloff/nmspmap.hxx>
25 #include "PersAttrListTContext.hxx"
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::util;
30 using namespace ::com::sun::star::xml::sax;
32 TYPEINIT1( XMLPersAttrListTContext, XMLTransformerContext );
34 void XMLPersAttrListTContext::AddAttribute(
35 sal_uInt16 nAPrefix,
36 ::xmloff::token::XMLTokenEnum eAToken,
37 ::xmloff::token::XMLTokenEnum eVToken )
39 OUString aAttrValue( ::xmloff::token::GetXMLToken( eVToken ) );
40 AddAttribute( nAPrefix, eAToken, aAttrValue );
43 void XMLPersAttrListTContext::AddAttribute(
44 sal_uInt16 nAPrefix,
45 ::xmloff::token::XMLTokenEnum eAToken,
46 const OUString & rValue )
48 OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
49 nAPrefix, ::xmloff::token::GetXMLToken( eAToken ) ) );
50 OUString aAttrValue( rValue );
52 XMLMutableAttributeList *pMutableAttrList;
53 if( m_xAttrList.is() )
55 pMutableAttrList =
56 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() );
58 else
60 pMutableAttrList = new XMLMutableAttributeList ;
61 m_xAttrList = pMutableAttrList;
64 pMutableAttrList->AddAttribute( aAttrQName, aAttrValue );
67 XMLPersAttrListTContext::XMLPersAttrListTContext(
68 XMLTransformerBase& rImp,
69 const OUString& rQName ) :
70 XMLTransformerContext( rImp, rQName ),
71 m_aElemQName( rQName ),
72 m_nActionMap( INVALID_ACTIONS )
76 XMLPersAttrListTContext::XMLPersAttrListTContext(
77 XMLTransformerBase& rImp,
78 const OUString& rQName,
79 sal_uInt16 nActionMap ) :
80 XMLTransformerContext( rImp, rQName ),
81 m_aElemQName( rQName ),
82 m_nActionMap( nActionMap )
86 XMLPersAttrListTContext::XMLPersAttrListTContext(
87 XMLTransformerBase& rImp,
88 const OUString& rQName,
89 sal_uInt16 nPrefix,
90 ::xmloff::token::XMLTokenEnum eToken ) :
91 XMLTransformerContext( rImp, rQName ),
92 m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( nPrefix,
93 ::xmloff::token::GetXMLToken( eToken ) ) ),
94 m_nActionMap( INVALID_ACTIONS )
98 XMLPersAttrListTContext::XMLPersAttrListTContext(
99 XMLTransformerBase& rImp,
100 const OUString& rQName,
101 sal_uInt16 nPrefix,
102 ::xmloff::token::XMLTokenEnum eToken,
103 sal_uInt16 nActionMap ) :
104 XMLTransformerContext( rImp, rQName ),
105 m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( nPrefix,
106 ::xmloff::token::GetXMLToken( eToken ) ) ),
107 m_nActionMap( nActionMap )
111 XMLPersAttrListTContext::~XMLPersAttrListTContext()
115 XMLTransformerContext *XMLPersAttrListTContext::CreateChildContext(
116 sal_uInt16 /*nPrefix*/,
117 const OUString& /*rLocalName*/,
118 const OUString& rQName,
119 const Reference< XAttributeList >& )
121 // ignore all child elements
122 return new XMLIgnoreTransformerContext( GetTransformer(),
123 rQName, true, true );
126 void XMLPersAttrListTContext::StartElement(
127 const Reference< XAttributeList >& rAttrList )
129 XMLMutableAttributeList *pMutableAttrList = 0;
131 Reference< XAttributeList > xAttrList( rAttrList );
132 if( m_nActionMap != INVALID_ACTIONS )
134 pMutableAttrList =
135 GetTransformer().ProcessAttrList( xAttrList, m_nActionMap,
136 true );
139 if( m_xAttrList.is() )
141 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
142 ->AppendAttributeList( xAttrList );
144 else if( pMutableAttrList )
146 m_xAttrList = xAttrList;
148 else
150 m_xAttrList = new XMLMutableAttributeList( rAttrList, true );
154 void XMLPersAttrListTContext::EndElement()
156 // ignore for now
159 void XMLPersAttrListTContext::Characters( const OUString& )
163 bool XMLPersAttrListTContext::IsPersistent() const
165 return true;
168 void XMLPersAttrListTContext::Export()
170 GetTransformer().GetDocHandler()->startElement( m_aElemQName, m_xAttrList );
171 ExportContent();
172 GetTransformer().GetDocHandler()->endElement( m_aElemQName );
175 void XMLPersAttrListTContext::ExportContent()
177 // nothing to export
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */