1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DeepTContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "DeepTContext.hxx"
34 #ifndef _XMLOFF_FLATTTCONTEXT_HXX
35 #include "FlatTContext.hxx"
37 #include "EventOOoTContext.hxx"
38 #include "TransformerActions.hxx"
39 #include "ElemTransformerAction.hxx"
40 #include "PersMixedContentTContext.hxx"
41 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
42 #include "TransformerBase.hxx"
45 using ::rtl::OUString
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::xml::sax
;
49 TYPEINIT1( XMLPersElemContentTContext
, XMLPersAttrListTContext
);
51 void XMLPersElemContentTContext::AddContent( XMLTransformerContext
*pContext
)
53 OSL_ENSURE( pContext
&& pContext
->IsPersistent(),
54 "non-persistent context" );
55 XMLTransformerContextVector::value_type
aVal( pContext
);
56 m_aChildContexts
.push_back( aVal
);
59 XMLPersElemContentTContext::XMLPersElemContentTContext(
60 XMLTransformerBase
& rImp
,
61 const OUString
& rQName
) :
62 XMLPersAttrListTContext( rImp
, rQName
)
66 XMLPersElemContentTContext::XMLPersElemContentTContext(
67 XMLTransformerBase
& rImp
,
68 const OUString
& rQName
,
69 sal_uInt16 nActionMap
) :
70 XMLPersAttrListTContext( rImp
, rQName
, nActionMap
)
74 XMLPersElemContentTContext::XMLPersElemContentTContext(
75 XMLTransformerBase
& rImp
,
76 const OUString
& rQName
,
78 ::xmloff::token::XMLTokenEnum eToken
) :
79 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
)
83 XMLPersElemContentTContext::XMLPersElemContentTContext(
84 XMLTransformerBase
& rImp
,
85 const OUString
& rQName
,
87 ::xmloff::token::XMLTokenEnum eToken
,
88 sal_uInt16 nActionMap
) :
89 XMLPersAttrListTContext( rImp
, rQName
, nPrefix
, eToken
, nActionMap
)
93 XMLPersElemContentTContext::~XMLPersElemContentTContext()
97 XMLTransformerContext
*XMLPersElemContentTContext::CreateChildContext(
99 const OUString
& rLocalName
,
100 const OUString
& rQName
,
101 const Reference
< XAttributeList
>& )
103 XMLTransformerContext
*pContext
= 0;
105 XMLTransformerActions::key_type
aKey( nPrefix
, rLocalName
);
106 XMLTransformerActions::const_iterator aIter
=
107 GetTransformer().GetElemActions().find( aKey
);
109 if( !(aIter
== GetTransformer().GetElemActions().end()) )
111 switch( (*aIter
).second
.m_nActionType
)
113 case XML_ETACTION_COPY
:
114 pContext
= new XMLPersMixedContentTContext( GetTransformer(),
117 case XML_ETACTION_COPY_TEXT
:
118 pContext
= new XMLPersMixedContentTContext( GetTransformer(),
121 case XML_ETACTION_RENAME_ELEM
:
122 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
123 (*aIter
).second
.GetQNamePrefixFromParam1(),
124 (*aIter
).second
.GetQNameTokenFromParam1() );
126 case XML_ETACTION_RENAME_ELEM_PROC_ATTRS
:
127 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
128 (*aIter
).second
.GetQNamePrefixFromParam1(),
129 (*aIter
).second
.GetQNameTokenFromParam1(),
130 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam2
) );
132 case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR
:
134 XMLPersMixedContentTContext
*pMC
=
135 new XMLPersMixedContentTContext( GetTransformer(), rQName
,
136 (*aIter
).second
.GetQNamePrefixFromParam1(),
137 (*aIter
).second
.GetQNameTokenFromParam1(),
138 static_cast< sal_uInt16
>(
139 (*aIter
).second
.m_nParam3
>> 16 ) );
141 (*aIter
).second
.GetQNamePrefixFromParam2(),
142 (*aIter
).second
.GetQNameTokenFromParam2(),
143 static_cast< ::xmloff::token::XMLTokenEnum
>(
144 (*aIter
).second
.m_nParam3
& 0xffff ) );
148 case XML_ETACTION_PROC_ATTRS
:
149 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
,
150 static_cast< sal_uInt16
>( (*aIter
).second
.m_nParam1
) );
153 pContext
= GetTransformer().CreateUserDefinedContext(
154 (*aIter
).second
, rQName
, sal_True
);
155 OSL_ENSURE( pContext
&& pContext
->IsPersistent(),
156 "unknown or not persistent action" );
157 if( pContext
&& !pContext
->IsPersistent() )
166 // default is copying
168 pContext
= new XMLPersMixedContentTContext( GetTransformer(), rQName
);
169 XMLTransformerContextVector::value_type
aVal( pContext
);
170 m_aChildContexts
.push_back( aVal
);
175 void XMLPersElemContentTContext::ExportContent()
177 XMLTransformerContextVector::iterator aIter
= m_aChildContexts
.begin();
179 for( ; aIter
!= m_aChildContexts
.end(); ++aIter
)