Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/transform/DeepTContext.cxx
Line
Count
Source
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"
21
#include "TransformerActions.hxx"
22
#include "ElemTransformerAction.hxx"
23
#include "PersMixedContentTContext.hxx"
24
#include "TransformerBase.hxx"
25
#include <osl/diagnose.h>
26
27
using namespace ::com::sun::star::uno;
28
using namespace ::com::sun::star::xml::sax;
29
30
void XMLPersElemContentTContext::AddContent( rtl::Reference<XMLTransformerContext> const & pContext )
31
0
{
32
0
    OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
33
0
                "non-persistent context" );
34
0
    m_aChildContexts.push_back(pContext);
35
0
}
36
37
XMLPersElemContentTContext::XMLPersElemContentTContext(
38
        XMLTransformerBase& rImp,
39
        const OUString& rQName ) :
40
0
    XMLPersAttrListTContext( rImp, rQName )
41
0
{
42
0
}
43
44
XMLPersElemContentTContext::XMLPersElemContentTContext(
45
        XMLTransformerBase& rImp,
46
        const OUString& rQName,
47
       sal_uInt16 nActionMap ) :
48
0
    XMLPersAttrListTContext( rImp, rQName, nActionMap )
49
0
{
50
0
}
51
52
XMLPersElemContentTContext::XMLPersElemContentTContext(
53
        XMLTransformerBase& rImp,
54
        const OUString& rQName,
55
        sal_uInt16 nPrefix,
56
        ::xmloff::token::XMLTokenEnum eToken ) :
57
0
    XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
58
0
{
59
0
}
60
61
XMLPersElemContentTContext::XMLPersElemContentTContext(
62
        XMLTransformerBase& rImp,
63
        const OUString& rQName,
64
        sal_uInt16 nPrefix,
65
        ::xmloff::token::XMLTokenEnum eToken,
66
       sal_uInt16 nActionMap ) :
67
0
    XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
68
0
{
69
0
}
70
71
XMLPersElemContentTContext::~XMLPersElemContentTContext()
72
0
{
73
0
}
74
75
rtl::Reference<XMLTransformerContext> XMLPersElemContentTContext::CreateChildContext(
76
        sal_uInt16 nPrefix,
77
        const OUString& rLocalName,
78
        const OUString& rQName,
79
        const Reference< XAttributeList >& )
80
0
{
81
0
    rtl::Reference<XMLTransformerContext> pContext;
82
83
0
    XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
84
0
    XMLTransformerActions::const_iterator aIter =
85
0
        GetTransformer().GetElemActions().find( aKey );
86
87
0
    if( aIter != GetTransformer().GetElemActions().end() )
88
0
    {
89
0
        switch( (*aIter).second.m_nActionType )
90
0
        {
91
0
        case XML_ETACTION_COPY:
92
0
        case XML_ETACTION_COPY_TEXT:
93
0
            pContext.set(new XMLPersMixedContentTContext( GetTransformer(),
94
0
                                                       rQName ));
95
0
            break;
96
0
        case XML_ETACTION_RENAME_ELEM:
97
0
            pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
98
0
                    (*aIter).second.GetQNamePrefixFromParam1(),
99
0
                    (*aIter).second.GetQNameTokenFromParam1() ));
100
0
            break;
101
0
        case XML_ETACTION_RENAME_ELEM_PROC_ATTRS:
102
0
            pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
103
0
                    (*aIter).second.GetQNamePrefixFromParam1(),
104
0
                    (*aIter).second.GetQNameTokenFromParam1(),
105
0
                       static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) ));
106
0
            break;
107
0
        case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR:
108
0
            {
109
0
                rtl::Reference<XMLPersMixedContentTContext> pMC(
110
0
                    new XMLPersMixedContentTContext( GetTransformer(), rQName,
111
0
                        (*aIter).second.GetQNamePrefixFromParam1(),
112
0
                        (*aIter).second.GetQNameTokenFromParam1(),
113
0
                        static_cast< sal_uInt16 >(
114
0
                            (*aIter).second.m_nParam3  >> 16 ) ));
115
0
                pMC->AddAttribute(
116
0
                    (*aIter).second.GetQNamePrefixFromParam2(),
117
0
                    (*aIter).second.GetQNameTokenFromParam2(),
118
0
                       static_cast< ::xmloff::token::XMLTokenEnum >(
119
0
                        (*aIter).second.m_nParam3 & 0xffff ) );
120
0
                pContext = pMC;
121
0
            }
122
0
            break;
123
0
        case XML_ETACTION_PROC_ATTRS:
124
0
            pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName,
125
0
                       static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) ));
126
0
            break;
127
0
        default:
128
0
            pContext = GetTransformer().CreateUserDefinedContext(
129
0
                            (*aIter).second, rQName, true );
130
0
            OSL_ENSURE( pContext.is() && pContext->IsPersistent(),
131
0
                        "unknown or not persistent action" );
132
0
            if( pContext.is() && !pContext->IsPersistent() )
133
0
            {
134
0
                pContext.clear();
135
0
            }
136
0
            break;
137
0
        }
138
0
    }
139
140
    // default is copying
141
0
    if( !pContext.is() )
142
0
        pContext.set(new XMLPersMixedContentTContext( GetTransformer(), rQName ));
143
0
    m_aChildContexts.push_back(pContext);
144
145
0
    return pContext;
146
0
}
147
148
void XMLPersElemContentTContext::ExportContent()
149
0
{
150
0
    for (auto const & i: m_aChildContexts)
151
0
    {
152
0
        i->Export();
153
0
    }
154
0
}
155
156
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */