Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/XMLChangeElementImportContext.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 "XMLChangeElementImportContext.hxx"
21
#include "XMLChangedRegionImportContext.hxx"
22
#include "XMLChangeInfoContext.hxx"
23
#include <com/sun/star/uno/Reference.h>
24
#include <utility>
25
#include <xmloff/xmlimp.hxx>
26
#include <xmloff/xmlnamespace.hxx>
27
#include <xmloff/xmltoken.hxx>
28
29
30
using ::com::sun::star::uno::Reference;
31
using ::xmloff::token::XML_CHANGE_INFO;
32
33
34
XMLChangeElementImportContext::XMLChangeElementImportContext(
35
    SvXMLImport& rImport,
36
    bool bAccContent,
37
    XMLChangedRegionImportContext& rParent,
38
    OUString aType) :
39
0
        SvXMLImportContext(rImport),
40
0
        bAcceptContent(bAccContent),
41
0
        maType(std::move(aType)),
42
0
        rChangedRegion(rParent)
43
0
{
44
0
}
45
46
css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChangeElementImportContext::createFastChildContext(
47
    sal_Int32 nElement,
48
    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
49
0
{
50
0
    SvXMLImportContextRef xContext;
51
52
0
    if ( nElement == XML_ELEMENT(OFFICE, XML_CHANGE_INFO) )
53
0
    {
54
0
        xContext = new XMLChangeInfoContext(GetImport(),
55
0
                                            rChangedRegion, maType);
56
0
    }
57
0
    else
58
0
    {
59
        // import into redline -> create XText
60
0
        rChangedRegion.UseRedlineText();
61
62
0
        xContext = GetImport().GetTextImport()->CreateTextChildContext(
63
0
            GetImport(), nElement, xAttrList,
64
0
            XMLTextType::ChangedRegion);
65
66
0
        if (!xContext)
67
0
        {
68
            // no text element
69
            // illegal element content! TODO: discard this redline!
70
            // for the moment -> use default
71
0
        }
72
0
    }
73
74
0
    return xContext;
75
0
}
76
77
void XMLChangeElementImportContext::startFastElement( sal_Int32, const Reference< css::xml::sax::XFastAttributeList >& )
78
0
{
79
0
    if(bAcceptContent)
80
0
    {
81
0
        GetImport().GetTextImport()->SetInsideDeleteContext(true);
82
0
    }
83
0
}
84
85
void XMLChangeElementImportContext::endFastElement(sal_Int32 )
86
0
{
87
0
    if(bAcceptContent)
88
0
    {
89
0
        GetImport().GetTextImport()->SetInsideDeleteContext(false);
90
0
    }
91
0
}
92
93
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */