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 "TransformerActions.hxx"
22 #include "ElemTransformerAction.hxx"
23 #include "PersMixedContentTContext.hxx"
24 #include "TransformerBase.hxx"
25 #include <osl/diagnose.h>
27 using namespace ::com::sun::star::uno
;
28 using namespace ::com::sun::star::xml::sax
;
30 void XMLPersElemContentTContext::AddContent( rtl::Reference
<XMLTransformerContext
> const & pContext
)
32 OSL_ENSURE( pContext
.is() && pContext
->IsPersistent(),
33 "non-persistent context" );
34 m_aChildContexts
.push_back(pContext
);
37 XMLPersElemContentTContext::XMLPersElemContentTContext(
38 XMLTransformerBase
& rImp
,
39 const OUString
& rQName
) :
40 XMLPersAttrListTContext( rImp
, rQName
)
44 XMLPersElemContentTContext::XMLPersElemContentTContext(
45 XMLTransformerBase
& rImp
,
46 const OUString
& rQName
,
47 sal_uInt16 nActionMap
) :
48 XMLPersAttrListTContext( rImp
, rQName
, nActionMap
)
52 XMLPersElemContentTContext::XMLPersElemContentTContext(
53 XMLTransformerBase
& rImp
,
54 const OUString
& rQName
,
56 ::xmloff::token::XMLTokenEnum eToken
) :
57 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
)
61 XMLPersElemContentTContext::XMLPersElemContentTContext(
62 XMLTransformerBase
& rImp
,
63 const OUString
& rQName
,
65 ::xmloff::token::XMLTokenEnum eToken
,
66 sal_uInt16 nActionMap
) :
67 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
, nActionMap
)
71 XMLPersElemContentTContext::~XMLPersElemContentTContext()
75 rtl::Reference
<XMLTransformerContext
> XMLPersElemContentTContext::CreateChildContext(
77 const OUString
& rLocalName
,
78 const OUString
& rQName
,
79 const Reference
< XAttributeList
>& )
81 rtl::Reference
<XMLTransformerContext
> pContext
;
83 XMLTransformerActions::key_type
aKey( nPrefix
, rLocalName
);
84 XMLTransformerActions::const_iterator aIter
=
85 GetTransformer().GetElemActions().find( aKey
);
87 if( aIter
!= GetTransformer().GetElemActions().end() )
89 switch( (*aIter
).second
.m_nActionType
)
91 case XML_ETACTION_COPY
:
92 case XML_ETACTION_COPY_TEXT
:
93 pContext
.set(new XMLPersMixedContentTContext( GetTransformer(),
96 case XML_ETACTION_RENAME_ELEM
:
97 pContext
.set(new XMLPersMixedContentTContext( GetTransformer(), rQName
,
98 (*aIter
).second
.GetQNamePrefixFromParam1(),
99 (*aIter
).second
.GetQNameTokenFromParam1() ));
101 case XML_ETACTION_RENAME_ELEM_PROC_ATTRS
:
102 pContext
.set(new XMLPersMixedContentTContext( GetTransformer(), rQName
,
103 (*aIter
).second
.GetQNamePrefixFromParam1(),
104 (*aIter
).second
.GetQNameTokenFromParam1(),
105 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam2
) ));
107 case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR
:
109 rtl::Reference
<XMLPersMixedContentTContext
> pMC(
110 new XMLPersMixedContentTContext( GetTransformer(), rQName
,
111 (*aIter
).second
.GetQNamePrefixFromParam1(),
112 (*aIter
).second
.GetQNameTokenFromParam1(),
113 static_cast< sal_uInt16
>(
114 (*aIter
).second
.m_nParam3
>> 16 ) ));
116 (*aIter
).second
.GetQNamePrefixFromParam2(),
117 (*aIter
).second
.GetQNameTokenFromParam2(),
118 static_cast< ::xmloff::token::XMLTokenEnum
>(
119 (*aIter
).second
.m_nParam3
& 0xffff ) );
123 case XML_ETACTION_PROC_ATTRS
:
124 pContext
.set(new XMLPersMixedContentTContext( GetTransformer(), rQName
,
125 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam1
) ));
128 pContext
= GetTransformer().CreateUserDefinedContext(
129 (*aIter
).second
, rQName
, true );
130 OSL_ENSURE( pContext
.is() && pContext
->IsPersistent(),
131 "unknown or not persistent action" );
132 if( pContext
.is() && !pContext
->IsPersistent() )
140 // default is copying
142 pContext
.set(new XMLPersMixedContentTContext( GetTransformer(), rQName
));
143 m_aChildContexts
.push_back(pContext
);
148 void XMLPersElemContentTContext::ExportContent()
150 for (auto const & i
: m_aChildContexts
)
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */