1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include "DeepTContext.hxx" 27cdf0e10cSrcweir #ifndef _XMLOFF_FLATTTCONTEXT_HXX 28cdf0e10cSrcweir #include "FlatTContext.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include "EventOOoTContext.hxx" 31cdf0e10cSrcweir #include "TransformerActions.hxx" 32cdf0e10cSrcweir #include "ElemTransformerAction.hxx" 33cdf0e10cSrcweir #include "PersMixedContentTContext.hxx" 34cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERBASE_HXX 35cdf0e10cSrcweir #include "TransformerBase.hxx" 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir 38cdf0e10cSrcweir using ::rtl::OUString; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 41cdf0e10cSrcweir 42cdf0e10cSrcweir TYPEINIT1( XMLPersElemContentTContext, XMLPersAttrListTContext ); 43cdf0e10cSrcweir 44cdf0e10cSrcweir void XMLPersElemContentTContext::AddContent( XMLTransformerContext *pContext ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir OSL_ENSURE( pContext && pContext->IsPersistent(), 47cdf0e10cSrcweir "non-persistent context" ); 48cdf0e10cSrcweir XMLTransformerContextVector::value_type aVal( pContext ); 49cdf0e10cSrcweir m_aChildContexts.push_back( aVal ); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir XMLPersElemContentTContext::XMLPersElemContentTContext( 53cdf0e10cSrcweir XMLTransformerBase& rImp, 54cdf0e10cSrcweir const OUString& rQName ) : 55cdf0e10cSrcweir XMLPersAttrListTContext( rImp, rQName ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir XMLPersElemContentTContext::XMLPersElemContentTContext( 60cdf0e10cSrcweir XMLTransformerBase& rImp, 61cdf0e10cSrcweir const OUString& rQName, 62cdf0e10cSrcweir sal_uInt16 nActionMap ) : 63cdf0e10cSrcweir XMLPersAttrListTContext( rImp, rQName, nActionMap ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir XMLPersElemContentTContext::XMLPersElemContentTContext( 68cdf0e10cSrcweir XMLTransformerBase& rImp, 69cdf0e10cSrcweir const OUString& rQName, 70cdf0e10cSrcweir sal_uInt16 nPrefix, 71cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum eToken ) : 72cdf0e10cSrcweir XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir XMLPersElemContentTContext::XMLPersElemContentTContext( 77cdf0e10cSrcweir XMLTransformerBase& rImp, 78cdf0e10cSrcweir const OUString& rQName, 79cdf0e10cSrcweir sal_uInt16 nPrefix, 80cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum eToken, 81cdf0e10cSrcweir sal_uInt16 nActionMap ) : 82cdf0e10cSrcweir XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir XMLPersElemContentTContext::~XMLPersElemContentTContext() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir XMLTransformerContext *XMLPersElemContentTContext::CreateChildContext( 91cdf0e10cSrcweir sal_uInt16 nPrefix, 92cdf0e10cSrcweir const OUString& rLocalName, 93cdf0e10cSrcweir const OUString& rQName, 94cdf0e10cSrcweir const Reference< XAttributeList >& ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir XMLTransformerContext *pContext = 0; 97cdf0e10cSrcweir 98cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, rLocalName ); 99cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter = 100cdf0e10cSrcweir GetTransformer().GetElemActions().find( aKey ); 101cdf0e10cSrcweir 102cdf0e10cSrcweir if( !(aIter == GetTransformer().GetElemActions().end()) ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir switch( (*aIter).second.m_nActionType ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir case XML_ETACTION_COPY: 107cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), 108cdf0e10cSrcweir rQName ); 109cdf0e10cSrcweir break; 110cdf0e10cSrcweir case XML_ETACTION_COPY_TEXT: 111cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), 112cdf0e10cSrcweir rQName ); 113cdf0e10cSrcweir break; 114cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM: 115cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName, 116cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 117cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1() ); 118cdf0e10cSrcweir break; 119cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_PROC_ATTRS: 120cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName, 121cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 122cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(), 123cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) ); 124cdf0e10cSrcweir break; 125cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR: 126cdf0e10cSrcweir { 127cdf0e10cSrcweir XMLPersMixedContentTContext *pMC = 128cdf0e10cSrcweir new XMLPersMixedContentTContext( GetTransformer(), rQName, 129cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 130cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(), 131cdf0e10cSrcweir static_cast< sal_uInt16 >( 132cdf0e10cSrcweir (*aIter).second.m_nParam3 >> 16 ) ); 133cdf0e10cSrcweir pMC->AddAttribute( 134cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam2(), 135cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam2(), 136cdf0e10cSrcweir static_cast< ::xmloff::token::XMLTokenEnum >( 137cdf0e10cSrcweir (*aIter).second.m_nParam3 & 0xffff ) ); 138cdf0e10cSrcweir pContext = pMC; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir break; 141cdf0e10cSrcweir case XML_ETACTION_PROC_ATTRS: 142cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName, 143cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) ); 144cdf0e10cSrcweir break; 145cdf0e10cSrcweir default: 146cdf0e10cSrcweir pContext = GetTransformer().CreateUserDefinedContext( 147cdf0e10cSrcweir (*aIter).second, rQName, sal_True ); 148cdf0e10cSrcweir OSL_ENSURE( pContext && pContext->IsPersistent(), 149cdf0e10cSrcweir "unknown or not persistent action" ); 150cdf0e10cSrcweir if( pContext && !pContext->IsPersistent() ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir delete pContext; 153cdf0e10cSrcweir pContext = 0; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir break; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir // default is copying 160cdf0e10cSrcweir if( !pContext ) 161cdf0e10cSrcweir pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName ); 162cdf0e10cSrcweir XMLTransformerContextVector::value_type aVal( pContext ); 163cdf0e10cSrcweir m_aChildContexts.push_back( aVal ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir return pContext; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir void XMLPersElemContentTContext::ExportContent() 169cdf0e10cSrcweir { 170cdf0e10cSrcweir XMLTransformerContextVector::iterator aIter = m_aChildContexts.begin(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir for( ; aIter != m_aChildContexts.end(); ++aIter ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir (*aIter)->Export(); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178