LibreOffice Module xmloff (master) 1
DeepTContext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "DeepTContext.hxx"
24#include "TransformerBase.hxx"
25#include <osl/diagnose.h>
26
27using namespace ::com::sun::star::uno;
28using namespace ::com::sun::star::xml::sax;
29
31{
32 OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
33 "non-persistent context" );
34 m_aChildContexts.push_back(pContext);
35}
36
39 const OUString& rQName ) :
40 XMLPersAttrListTContext( rImp, rQName )
41{
42}
43
46 const OUString& rQName,
47 sal_uInt16 nActionMap ) :
48 XMLPersAttrListTContext( rImp, rQName, nActionMap )
49{
50}
51
54 const OUString& rQName,
55 sal_uInt16 nPrefix,
57 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
58{
59}
60
63 const OUString& rQName,
64 sal_uInt16 nPrefix,
66 sal_uInt16 nActionMap ) :
67 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
68{
69}
70
72{
73}
74
76 sal_uInt16 nPrefix,
77 const OUString& rLocalName,
78 const OUString& rQName,
79 const Reference< XAttributeList >& )
80{
82
83 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
84 XMLTransformerActions::const_iterator aIter =
85 GetTransformer().GetElemActions().find( aKey );
86
87 if( aIter != GetTransformer().GetElemActions().end() )
88 {
89 switch( (*aIter).second.m_nActionType )
90 {
93 rQName ));
94 break;
97 rQName ));
98 break;
100 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
101 (*aIter).second.GetQNamePrefixFromParam1(),
102 (*aIter).second.GetQNameTokenFromParam1() ));
103 break;
105 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
106 (*aIter).second.GetQNamePrefixFromParam1(),
107 (*aIter).second.GetQNameTokenFromParam1(),
108 static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) ));
109 break;
111 {
114 (*aIter).second.GetQNamePrefixFromParam1(),
115 (*aIter).second.GetQNameTokenFromParam1(),
116 static_cast< sal_uInt16 >(
117 (*aIter).second.m_nParam3 >> 16 ) ));
118 pMC->AddAttribute(
119 (*aIter).second.GetQNamePrefixFromParam2(),
120 (*aIter).second.GetQNameTokenFromParam2(),
121 static_cast< ::xmloff::token::XMLTokenEnum >(
122 (*aIter).second.m_nParam3 & 0xffff ) );
123 pContext = pMC;
124 }
125 break;
127 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
128 static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) ));
129 break;
130 default:
132 (*aIter).second, rQName, true );
133 OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
134 "unknown or not persistent action" );
135 if( pContext.is() && !pContext->IsPersistent() )
136 {
137 pContext.clear();
138 }
139 break;
140 }
141 }
142
143 // default is copying
144 if( !pContext.is() )
145 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName ));
146 m_aChildContexts.push_back(pContext);
147
148 return pContext;
149}
150
152{
153 for (auto const & i: m_aChildContexts)
154 {
155 i->Export();
156 }
157}
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR
@ XML_ETACTION_RENAME_ELEM
@ XML_ETACTION_RENAME_ELEM_PROC_ATTRS
@ XML_ETACTION_COPY_TEXT
@ XML_ETACTION_COPY
@ XML_ETACTION_PROC_ATTRS
virtual ~XMLPersElemContentTContext() override
void AddContent(rtl::Reference< XMLTransformerContext > const &pContent)
virtual void ExportContent() override
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
std::vector< rtl::Reference< XMLTransformerContext > > m_aChildContexts
XMLPersElemContentTContext(XMLTransformerBase &rTransformer, const OUString &rQName)
XMLTransformerActions & GetElemActions()
virtual XMLTransformerContext * CreateUserDefinedContext(const TransformerAction_Impl &rAction, const OUString &rQName, bool bPersistent=false)=0
XMLTransformerBase & GetTransformer()
int i
end
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
XMLTokenEnum eToken
Definition: xmltoken.cxx:40