Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/chart/contexts.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 <xmloff/xmltoken.hxx>
21
#include <xmloff/xmlnamespace.hxx>
22
#include <xmloff/xmlmetai.hxx>
23
#include <xmloff/xmlstyle.hxx>
24
#include <SchXMLImport.hxx>
25
#include "SchXMLCalculationSettingsContext.hxx"
26
27
#include "contexts.hxx"
28
29
#include <sal/log.hxx>
30
31
using namespace com::sun::star;
32
using namespace ::xmloff::token;
33
34
namespace {
35
36
class SchXMLBodyContext_Impl : public SvXMLImportContext
37
{
38
private:
39
    SchXMLImportHelper& mrImportHelper;
40
41
public:
42
43
    SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper,
44
                SvXMLImport& rImport );
45
46
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
47
        sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
48
};
49
50
}
51
52
SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
53
        SchXMLImportHelper& rImpHelper, SvXMLImport& rImport ) :
54
0
    SvXMLImportContext( rImport ),
55
0
    mrImportHelper( rImpHelper )
56
0
{
57
0
}
58
59
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLBodyContext_Impl::createFastChildContext(
60
    sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
61
0
{
62
0
    return new SchXMLBodyContext( mrImportHelper, GetImport(), nElement );
63
0
}
64
65
SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
66
                                    SvXMLImport& rImport,
67
                                    sal_Int32 nElement ) :
68
0
        SvXMLImportContext( rImport ),
69
0
        mrImportHelper( rImpHelper )
70
0
{
71
0
    SAL_WARN_IF(( nElement != XML_ELEMENT( OFFICE, XML_DOCUMENT ) &&
72
0
          nElement != XML_ELEMENT( OFFICE, XML_DOCUMENT_META ) &&
73
0
          nElement != XML_ELEMENT( OFFICE, XML_DOCUMENT_STYLES ) &&
74
0
          nElement != XML_ELEMENT( OFFICE, XML_DOCUMENT_CONTENT ) ), "xmloff.chart", "SchXMLDocContext instantiated with no <office:document> element" );
75
0
}
Unexecuted instantiation: SchXMLDocContext::SchXMLDocContext(SchXMLImportHelper&, SvXMLImport&, int)
Unexecuted instantiation: SchXMLDocContext::SchXMLDocContext(SchXMLImportHelper&, SvXMLImport&, int)
76
77
SchXMLDocContext::~SchXMLDocContext()
78
0
{}
79
80
81
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::createFastChildContext(
82
    sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
83
0
{
84
0
    SvXMLImportFlags nFlags = GetImport().getImportFlags();
85
0
    switch (nElement)
86
0
    {
87
0
        case XML_ELEMENT(OFFICE, XML_BODY):
88
0
            if( nFlags & SvXMLImportFlags::CONTENT )
89
0
                return new SchXMLBodyContext_Impl( mrImportHelper, GetImport() );
90
0
            break;
91
0
        case XML_ELEMENT(OFFICE, XML_STYLES):
92
            // for draw styles containing gradients/hatches/markers and dashes
93
0
            if( nFlags & SvXMLImportFlags::STYLES )
94
0
                return new SvXMLStylesContext( GetImport() );
95
0
            break;
96
0
        case  XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
97
0
            if( nFlags & SvXMLImportFlags::AUTOSTYLES )
98
                // not nice, but this is safe, as the SchXMLDocContext class can only by
99
                // instantiated by the chart import class SchXMLImport (header is not exported)
100
0
                return
101
0
                    static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext();
102
0
            break;
103
0
        case XML_ELEMENT(OFFICE, XML_META):
104
            // we come here in the flat ODF file format,
105
            // if XDocumentPropertiesSupplier is not supported at the model
106
0
            break;
107
0
    }
108
0
    return nullptr;
109
0
}
110
111
SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(
112
        SchXMLImportHelper& i_rImpHelper,
113
        SchXMLImport& i_rImport,
114
        sal_Int32 i_nElement,
115
        const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
116
0
    SvXMLImportContext(i_rImport),
117
0
    SchXMLDocContext(i_rImpHelper, i_rImport, i_nElement),
118
0
    SvXMLMetaDocumentContext(i_rImport, i_xDocProps)
119
0
{
120
0
}
Unexecuted instantiation: SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(SchXMLImportHelper&, SchXMLImport&, int, com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties> const&)
Unexecuted instantiation: SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(SchXMLImportHelper&, SchXMLImport&, int, com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties> const&)
121
122
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLFlatDocContext_Impl::createFastChildContext(
123
    sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
124
0
{
125
    // behave like meta base class iff we encounter office:meta
126
0
    if ( nElement == XML_ELEMENT( OFFICE, XML_META ) ) {
127
0
        return SvXMLMetaDocumentContext::createFastChildContext(
128
0
                    nElement, xAttrList );
129
0
    } else {
130
0
        return SchXMLDocContext::createFastChildContext(
131
0
                    nElement, xAttrList );
132
0
    }
133
0
}
134
135
SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
136
                                      SvXMLImport& rImport,
137
                                      sal_Int32 nElement ) :
138
0
        SvXMLImportContext( rImport ),
139
0
        mrImportHelper( rImpHelper )
140
0
{
141
0
    SAL_WARN_IF( nElement != XML_ELEMENT(OFFICE, XML_CHART), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" );
142
0
}
143
144
SchXMLBodyContext::~SchXMLBodyContext()
145
0
{}
146
147
css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLBodyContext::createFastChildContext(
148
    sal_Int32 nElement,
149
    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
150
0
{
151
0
    css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
152
153
    // <chart:chart> element
154
0
    if( nElement == XML_ELEMENT(CHART, XML_CHART) )
155
0
    {
156
0
        xContext = mrImportHelper.CreateChartContext( GetImport(), GetImport().GetModel() );
157
0
    }
158
0
    else if(nElement == XML_ELEMENT(TABLE, XML_CALCULATION_SETTINGS ))
159
0
    {
160
        // i99104 handle null date correctly
161
0
        xContext = new SchXMLCalculationSettingsContext ( GetImport(), xAttrList);
162
0
    }
163
0
    else
164
0
        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
165
166
0
    return xContext;
167
0
}
168
169
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */