remove assert looking for new compatibilityMode DOCX
[LibreOffice.git] / xmloff / source / transform / DeepTContext.cxx
blobd01b6b327c36871c53a45958e4c9999e2fbf09d5
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 "TransformerActions.hxx"
22 #include "ElemTransformerAction.hxx"
23 #include "PersMixedContentTContext.hxx"
24 #include "TransformerBase.hxx"
25 #include <osl/diagnose.h>
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::xml::sax;
30 void XMLPersElemContentTContext::AddContent( rtl::Reference<XMLTransformerContext> const & pContext )
32 OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
33 "non-persistent context" );
34 m_aChildContexts.push_back(pContext);
37 XMLPersElemContentTContext::XMLPersElemContentTContext(
38 XMLTransformerBase& rImp,
39 const OUString& rQName ) :
40 XMLPersAttrListTContext( rImp, rQName )
44 XMLPersElemContentTContext::XMLPersElemContentTContext(
45 XMLTransformerBase& rImp,
46 const OUString& rQName,
47 sal_uInt16 nActionMap ) :
48 XMLPersAttrListTContext( rImp, rQName, nActionMap )
52 XMLPersElemContentTContext::XMLPersElemContentTContext(
53 XMLTransformerBase& rImp,
54 const OUString& rQName,
55 sal_uInt16 nPrefix,
56 ::xmloff::token::XMLTokenEnum eToken ) :
57 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
61 XMLPersElemContentTContext::XMLPersElemContentTContext(
62 XMLTransformerBase& rImp,
63 const OUString& rQName,
64 sal_uInt16 nPrefix,
65 ::xmloff::token::XMLTokenEnum eToken,
66 sal_uInt16 nActionMap ) :
67 XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
71 XMLPersElemContentTContext::~XMLPersElemContentTContext()
75 rtl::Reference<XMLTransformerContext> XMLPersElemContentTContext::CreateChildContext(
76 sal_uInt16 nPrefix,
77 const OUString& rLocalName,
78 const OUString& rQName,
79 const Reference< XAttributeList >& )
81 rtl::Reference<XMLTransformerContext> pContext;
83 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
84 XMLTransformerActions::const_iterator aIter =
85 GetTransformer().GetElemActions().find( aKey );
87 if( aIter != GetTransformer().GetElemActions().end() )
89 switch( (*aIter).second.m_nActionType )
91 case XML_ETACTION_COPY:
92 case XML_ETACTION_COPY_TEXT:
93 pContext.set(new XMLPersMixedContentTContext( GetTransformer(),
94 rQName ));
95 break;
96 case XML_ETACTION_RENAME_ELEM:
97 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
98 (*aIter).second.GetQNamePrefixFromParam1(),
99 (*aIter).second.GetQNameTokenFromParam1() ));
100 break;
101 case XML_ETACTION_RENAME_ELEM_PROC_ATTRS:
102 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
103 (*aIter).second.GetQNamePrefixFromParam1(),
104 (*aIter).second.GetQNameTokenFromParam1(),
105 static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) ));
106 break;
107 case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR:
109 rtl::Reference<XMLPersMixedContentTContext> pMC(
110 new XMLPersMixedContentTContext( GetTransformer(), rQName,
111 (*aIter).second.GetQNamePrefixFromParam1(),
112 (*aIter).second.GetQNameTokenFromParam1(),
113 static_cast< sal_uInt16 >(
114 (*aIter).second.m_nParam3 >> 16 ) ));
115 pMC->AddAttribute(
116 (*aIter).second.GetQNamePrefixFromParam2(),
117 (*aIter).second.GetQNameTokenFromParam2(),
118 static_cast< ::xmloff::token::XMLTokenEnum >(
119 (*aIter).second.m_nParam3 & 0xffff ) );
120 pContext = pMC;
122 break;
123 case XML_ETACTION_PROC_ATTRS:
124 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
125 static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) ));
126 break;
127 default:
128 pContext = GetTransformer().CreateUserDefinedContext(
129 (*aIter).second, rQName, true );
130 OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
131 "unknown or not persistent action" );
132 if( pContext.is() && !pContext->IsPersistent() )
134 pContext.clear();
136 break;
140 // default is copying
141 if( !pContext.is() )
142 pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName ));
143 m_aChildContexts.push_back(pContext);
145 return pContext;
148 void XMLPersElemContentTContext::ExportContent()
150 for (auto const & i: m_aChildContexts)
152 i->Export();
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */