bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / transform / DeepTContext.cxx
blob4137c5924e7c8a93baa5afa5713e06da94bf2982
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"
27 #include <osl/diagnose.h>
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::xml::sax;
32 TYPEINIT1( XMLPersElemContentTContext, XMLPersAttrListTContext );
34 void XMLPersElemContentTContext::AddContent( XMLTransformerContext *pContext )
36 OSL_ENSURE( pContext && pContext->IsPersistent(),
37 "non-persistent context" );
38 XMLTransformerContextVector::value_type aVal( pContext );
39 m_aChildContexts.push_back( aVal );
42 XMLPersElemContentTContext::XMLPersElemContentTContext(
43 XMLTransformerBase& rImp,
44 const OUString& rQName ) :
45 XMLPersAttrListTContext( rImp, rQName )
49 XMLPersElemContentTContext::XMLPersElemContentTContext(
50 XMLTransformerBase& rImp,
51 const OUString& rQName,
52 sal_uInt16 nActionMap ) :
53 XMLPersAttrListTContext( rImp, rQName, nActionMap )
57 XMLPersElemContentTContext::XMLPersElemContentTContext(
58 XMLTransformerBase& rImp,
59 const OUString& rQName,
60 sal_uInt16 nPrefix,
61 ::xmloff::token::XMLTokenEnum eToken ) :
62 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
66 XMLPersElemContentTContext::XMLPersElemContentTContext(
67 XMLTransformerBase& rImp,
68 const OUString& rQName,
69 sal_uInt16 nPrefix,
70 ::xmloff::token::XMLTokenEnum eToken,
71 sal_uInt16 nActionMap ) :
72 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
76 XMLPersElemContentTContext::~XMLPersElemContentTContext()
80 XMLTransformerContext *XMLPersElemContentTContext::CreateChildContext(
81 sal_uInt16 nPrefix,
82 const OUString& rLocalName,
83 const OUString& rQName,
84 const Reference< XAttributeList >& )
86 XMLTransformerContext *pContext = 0;
88 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
89 XMLTransformerActions::const_iterator aIter =
90 GetTransformer().GetElemActions().find( aKey );
92 if( !(aIter == GetTransformer().GetElemActions().end()) )
94 switch( (*aIter).second.m_nActionType )
96 case XML_ETACTION_COPY:
97 pContext = new XMLPersMixedContentTContext( GetTransformer(),
98 rQName );
99 break;
100 case XML_ETACTION_COPY_TEXT:
101 pContext = new XMLPersMixedContentTContext( GetTransformer(),
102 rQName );
103 break;
104 case XML_ETACTION_RENAME_ELEM:
105 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
106 (*aIter).second.GetQNamePrefixFromParam1(),
107 (*aIter).second.GetQNameTokenFromParam1() );
108 break;
109 case XML_ETACTION_RENAME_ELEM_PROC_ATTRS:
110 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
111 (*aIter).second.GetQNamePrefixFromParam1(),
112 (*aIter).second.GetQNameTokenFromParam1(),
113 static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
114 break;
115 case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR:
117 XMLPersMixedContentTContext *pMC =
118 new XMLPersMixedContentTContext( GetTransformer(), rQName,
119 (*aIter).second.GetQNamePrefixFromParam1(),
120 (*aIter).second.GetQNameTokenFromParam1(),
121 static_cast< sal_uInt16 >(
122 (*aIter).second.m_nParam3 >> 16 ) );
123 pMC->AddAttribute(
124 (*aIter).second.GetQNamePrefixFromParam2(),
125 (*aIter).second.GetQNameTokenFromParam2(),
126 static_cast< ::xmloff::token::XMLTokenEnum >(
127 (*aIter).second.m_nParam3 & 0xffff ) );
128 pContext = pMC;
130 break;
131 case XML_ETACTION_PROC_ATTRS:
132 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
133 static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
134 break;
135 default:
136 pContext = GetTransformer().CreateUserDefinedContext(
137 (*aIter).second, rQName, true );
138 OSL_ENSURE( pContext && pContext->IsPersistent(),
139 "unknown or not persistent action" );
140 if( pContext && !pContext->IsPersistent() )
142 delete pContext;
143 pContext = 0;
145 break;
149 // default is copying
150 if( !pContext )
151 pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName );
152 XMLTransformerContextVector::value_type aVal( pContext );
153 m_aChildContexts.push_back( aVal );
155 return pContext;
158 void XMLPersElemContentTContext::ExportContent()
160 XMLTransformerContextVector::iterator aIter = m_aChildContexts.begin();
162 for( ; aIter != m_aChildContexts.end(); ++aIter )
164 (*aIter)->Export();
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */