Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
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"
26 : :
27 : : using ::rtl::OUString;
28 : :
29 : : using namespace ::com::sun::star::uno;
30 : : using namespace ::com::sun::star::util;
31 : : using namespace ::com::sun::star::xml::sax;
32 : :
33 [ # # ][ # # ]: 0 : TYPEINIT1( XMLPersAttrListTContext, XMLTransformerContext );
34 : :
35 : 0 : void XMLPersAttrListTContext::AddAttribute(
36 : : sal_uInt16 nAPrefix,
37 : : ::xmloff::token::XMLTokenEnum eAToken,
38 : : ::xmloff::token::XMLTokenEnum eVToken )
39 : : {
40 [ # # ]: 0 : OUString aAttrValue( ::xmloff::token::GetXMLToken( eVToken ) );
41 [ # # ]: 0 : AddAttribute( nAPrefix, eAToken, aAttrValue );
42 : 0 : }
43 : :
44 : 0 : void XMLPersAttrListTContext::AddAttribute(
45 : : sal_uInt16 nAPrefix,
46 : : ::xmloff::token::XMLTokenEnum eAToken,
47 : : const ::rtl::OUString & rValue )
48 : : {
49 : 0 : OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
50 [ # # # # ]: 0 : nAPrefix, ::xmloff::token::GetXMLToken( eAToken ) ) );
51 : 0 : OUString aAttrValue( rValue );
52 : :
53 : : XMLMutableAttributeList *pMutableAttrList;
54 [ # # ]: 0 : if( m_xAttrList.is() )
55 : : {
56 : : pMutableAttrList =
57 [ # # ][ # # ]: 0 : static_cast< XMLMutableAttributeList * >( m_xAttrList.get() );
58 : : }
59 : : else
60 : : {
61 [ # # ]: 0 : pMutableAttrList = new XMLMutableAttributeList ;
62 [ # # ][ # # ]: 0 : m_xAttrList = pMutableAttrList;
63 : : }
64 : :
65 [ # # ]: 0 : pMutableAttrList->AddAttribute( aAttrQName, aAttrValue );
66 : 0 : }
67 : :
68 : 2276 : XMLPersAttrListTContext::XMLPersAttrListTContext(
69 : : XMLTransformerBase& rImp,
70 : : const OUString& rQName ) :
71 : : XMLTransformerContext( rImp, rQName ),
72 : : m_aElemQName( rQName ),
73 : 2276 : m_nActionMap( INVALID_ACTIONS )
74 : : {
75 : 2276 : }
76 : :
77 : 44 : XMLPersAttrListTContext::XMLPersAttrListTContext(
78 : : XMLTransformerBase& rImp,
79 : : const OUString& rQName,
80 : : sal_uInt16 nActionMap ) :
81 : : XMLTransformerContext( rImp, rQName ),
82 : : m_aElemQName( rQName ),
83 : 44 : m_nActionMap( nActionMap )
84 : : {
85 : 44 : }
86 : :
87 : 506 : XMLPersAttrListTContext::XMLPersAttrListTContext(
88 : : XMLTransformerBase& rImp,
89 : : const OUString& rQName,
90 : : sal_uInt16 nPrefix,
91 : : ::xmloff::token::XMLTokenEnum eToken ) :
92 : : XMLTransformerContext( rImp, rQName ),
93 : 506 : m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( nPrefix,
94 [ + - ]: 506 : ::xmloff::token::GetXMLToken( eToken ) ) ),
95 [ + - ]: 1012 : m_nActionMap( INVALID_ACTIONS )
96 : : {
97 : 506 : }
98 : :
99 : 0 : XMLPersAttrListTContext::XMLPersAttrListTContext(
100 : : XMLTransformerBase& rImp,
101 : : const OUString& rQName,
102 : : sal_uInt16 nPrefix,
103 : : ::xmloff::token::XMLTokenEnum eToken,
104 : : sal_uInt16 nActionMap ) :
105 : : XMLTransformerContext( rImp, rQName ),
106 : 0 : m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( nPrefix,
107 [ # # ]: 0 : ::xmloff::token::GetXMLToken( eToken ) ) ),
108 [ # # ]: 0 : m_nActionMap( nActionMap )
109 : : {
110 : 0 : }
111 : :
112 : 2826 : XMLPersAttrListTContext::~XMLPersAttrListTContext()
113 : : {
114 [ - + ]: 2832 : }
115 : :
116 : 0 : XMLTransformerContext *XMLPersAttrListTContext::CreateChildContext(
117 : : sal_uInt16 /*nPrefix*/,
118 : : const OUString& /*rLocalName*/,
119 : : const OUString& rQName,
120 : : const Reference< XAttributeList >& )
121 : : {
122 : : // ignore all child elements
123 : 0 : return new XMLIgnoreTransformerContext( GetTransformer(),
124 [ # # ]: 0 : rQName, sal_True, sal_True );
125 : : }
126 : :
127 : 452 : void XMLPersAttrListTContext::StartElement(
128 : : const Reference< XAttributeList >& rAttrList )
129 : : {
130 : 452 : XMLMutableAttributeList *pMutableAttrList = 0;
131 : :
132 : 452 : Reference< XAttributeList > xAttrList( rAttrList );
133 [ + + ]: 452 : if( m_nActionMap != INVALID_ACTIONS )
134 : : {
135 : : pMutableAttrList =
136 : 44 : GetTransformer().ProcessAttrList( xAttrList, m_nActionMap,
137 [ + - ]: 44 : sal_True );
138 : : }
139 : :
140 [ - + ]: 452 : if( m_xAttrList.is() )
141 : : {
142 [ # # ]: 0 : static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
143 [ # # ][ # # ]: 0 : ->AppendAttributeList( xAttrList );
144 : : }
145 [ + + ]: 452 : else if( pMutableAttrList )
146 : : {
147 [ + - ]: 10 : m_xAttrList = xAttrList;
148 : : }
149 : : else
150 : : {
151 [ + - ][ + - ]: 442 : m_xAttrList = new XMLMutableAttributeList( rAttrList, sal_True );
[ + - ]
152 : 452 : }
153 : 452 : }
154 : :
155 : 1236 : void XMLPersAttrListTContext::EndElement()
156 : : {
157 : : // ignore for now
158 : 1236 : }
159 : :
160 : 0 : void XMLPersAttrListTContext::Characters( const OUString& )
161 : : {
162 : 0 : }
163 : :
164 : 0 : sal_Bool XMLPersAttrListTContext::IsPersistent() const
165 : : {
166 : 0 : return sal_True;
167 : : }
168 : :
169 : 457 : void XMLPersAttrListTContext::Export()
170 : : {
171 : 457 : GetTransformer().GetDocHandler()->startElement( m_aElemQName, m_xAttrList );
172 : 457 : ExportContent();
173 : 457 : GetTransformer().GetDocHandler()->endElement( m_aElemQName );
174 : 457 : }
175 : :
176 : 6 : void XMLPersAttrListTContext::ExportContent()
177 : : {
178 : : // nothing to export
179 : 6 : }
180 : :
181 : 6 : Reference< XAttributeList > XMLPersAttrListTContext::GetAttrList() const
182 : : {
183 : 6 : return m_xAttrList;
184 : : }
185 : :
186 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|