bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / transform / DeepTContext.cxx
blob7fb2d0f53aa987d8aeacb8a3abb3e486bef6aeee
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 "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,
59 sal_uInt16 nPrefix,
60 ::xmloff::token::XMLTokenEnum eToken ) :
61 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
65 XMLPersElemContentTContext::XMLPersElemContentTContext(
66 XMLTransformerBase& rImp,
67 const OUString& rQName,
68 sal_uInt16 nPrefix,
69 ::xmloff::token::XMLTokenEnum eToken,
70 sal_uInt16 nActionMap ) :
71 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
75 XMLPersElemContentTContext::~XMLPersElemContentTContext()
79 XMLTransformerContext *XMLPersElemContentTContext::CreateChildContext(
80 sal_uInt16 nPrefix,
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(),
97 rQName );
98 break;
99 case XML_ETACTION_COPY_TEXT:
100 pContext = new XMLPersMixedContentTContext( GetTransformer(),
101 rQName );
102 break;
103 case XML_ETACTION_RENAME_ELEM:
104 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
105 (*aIter).second.GetQNamePrefixFromParam1(),
106 (*aIter).second.GetQNameTokenFromParam1() );
107 break;
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 ) );
113 break;
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 ) );
122 pMC->AddAttribute(
123 (*aIter).second.GetQNamePrefixFromParam2(),
124 (*aIter).second.GetQNameTokenFromParam2(),
125 static_cast< ::xmloff::token::XMLTokenEnum >(
126 (*aIter).second.m_nParam3 & 0xffff ) );
127 pContext = pMC;
129 break;
130 case XML_ETACTION_PROC_ATTRS:
131 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
132 static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
133 break;
134 default:
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() )
141 delete pContext;
142 pContext = 0;
144 break;
148 // default is copying
149 if( !pContext )
150 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName );
151 XMLTransformerContextVector::value_type aVal( pContext );
152 m_aChildContexts.push_back( aVal );
154 return pContext;
157 void XMLPersElemContentTContext::ExportContent()
159 XMLTransformerContextVector::iterator aIter = m_aChildContexts.begin();
161 for( ; aIter != m_aChildContexts.end(); ++aIter )
163 (*aIter)->Export();
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */