1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "DeepTContext.hxx"
21 #include "FlatTContext.hxx"
22 #include "EventOOoTContext.hxx"
23 #include "TransformerActions.hxx"
24 #include "ElemTransformerAction.hxx"
25 #include "PersMixedContentTContext.hxx"
26 #include "TransformerBase.hxx"
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::xml::sax
;
31 TYPEINIT1( XMLPersElemContentTContext
, XMLPersAttrListTContext
);
33 void XMLPersElemContentTContext::AddContent( XMLTransformerContext
*pContext
)
35 OSL_ENSURE( pContext
&& pContext
->IsPersistent(),
36 "non-persistent context" );
37 XMLTransformerContextVector::value_type
aVal( pContext
);
38 m_aChildContexts
.push_back( aVal
);
41 XMLPersElemContentTContext::XMLPersElemContentTContext(
42 XMLTransformerBase
& rImp
,
43 const OUString
& rQName
) :
44 XMLPersAttrListTContext( rImp
, rQName
)
48 XMLPersElemContentTContext::XMLPersElemContentTContext(
49 XMLTransformerBase
& rImp
,
50 const OUString
& rQName
,
51 sal_uInt16 nActionMap
) :
52 XMLPersAttrListTContext( rImp
, rQName
, nActionMap
)
56 XMLPersElemContentTContext::XMLPersElemContentTContext(
57 XMLTransformerBase
& rImp
,
58 const OUString
& rQName
,
60 ::xmloff::token::XMLTokenEnum eToken
) :
61 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
)
65 XMLPersElemContentTContext::XMLPersElemContentTContext(
66 XMLTransformerBase
& rImp
,
67 const OUString
& rQName
,
69 ::xmloff::token::XMLTokenEnum eToken
,
70 sal_uInt16 nActionMap
) :
71 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
, nActionMap
)
75 XMLPersElemContentTContext::~XMLPersElemContentTContext()
79 XMLTransformerContext
*XMLPersElemContentTContext::CreateChildContext(
81 const OUString
& rLocalName
,
82 const OUString
& rQName
,
83 const Reference
< XAttributeList
>& )
85 XMLTransformerContext
*pContext
= 0;
87 XMLTransformerActions::key_type
aKey( nPrefix
, rLocalName
);
88 XMLTransformerActions::const_iterator aIter
=
89 GetTransformer().GetElemActions().find( aKey
);
91 if( !(aIter
== GetTransformer().GetElemActions().end()) )
93 switch( (*aIter
).second
.m_nActionType
)
95 case XML_ETACTION_COPY
:
96 pContext
= new XMLPersMixedContentTContext( GetTransformer(),
99 case XML_ETACTION_COPY_TEXT
:
100 pContext
= new XMLPersMixedContentTContext( GetTransformer(),
103 case XML_ETACTION_RENAME_ELEM
:
104 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
105 (*aIter
).second
.GetQNamePrefixFromParam1(),
106 (*aIter
).second
.GetQNameTokenFromParam1() );
108 case XML_ETACTION_RENAME_ELEM_PROC_ATTRS
:
109 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
110 (*aIter
).second
.GetQNamePrefixFromParam1(),
111 (*aIter
).second
.GetQNameTokenFromParam1(),
112 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam2
) );
114 case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR
:
116 XMLPersMixedContentTContext
*pMC
=
117 new XMLPersMixedContentTContext( GetTransformer(), rQName
,
118 (*aIter
).second
.GetQNamePrefixFromParam1(),
119 (*aIter
).second
.GetQNameTokenFromParam1(),
120 static_cast< sal_uInt16
>(
121 (*aIter
).second
.m_nParam3
>> 16 ) );
123 (*aIter
).second
.GetQNamePrefixFromParam2(),
124 (*aIter
).second
.GetQNameTokenFromParam2(),
125 static_cast< ::xmloff::token::XMLTokenEnum
>(
126 (*aIter
).second
.m_nParam3
& 0xffff ) );
130 case XML_ETACTION_PROC_ATTRS
:
131 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
132 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam1
) );
135 pContext
= GetTransformer().CreateUserDefinedContext(
136 (*aIter
).second
, rQName
, sal_True
);
137 OSL_ENSURE( pContext
&& pContext
->IsPersistent(),
138 "unknown or not persistent action" );
139 if( pContext
&& !pContext
->IsPersistent() )
148 // default is copying
150 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
);
151 XMLTransformerContextVector::value_type
aVal( pContext
);
152 m_aChildContexts
.push_back( aVal
);
157 void XMLPersElemContentTContext::ExportContent()
159 XMLTransformerContextVector::iterator aIter
= m_aChildContexts
.begin();
161 for( ; aIter
!= m_aChildContexts
.end(); ++aIter
)
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */