Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/starmath/inc/mathml/mathmlimport.hxx
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
#pragma once
21
22
#include <unomodel.hxx>
23
24
#include <utility>
25
#include <xmloff/xmlimp.hxx>
26
#include <comphelper/errcode.hxx>
27
28
#include <deque>
29
30
class SmNode;
31
class SfxMedium;
32
namespace com::sun::star
33
{
34
namespace beans
35
{
36
class XPropertySet;
37
}
38
}
39
class SmModel;
40
41
typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack;
42
43
class SmXMLImportWrapper
44
{
45
    rtl::Reference<SmModel> m_xModel;
46
47
private:
48
    // Use customized entities
49
    bool m_bUseHTMLMLEntities;
50
51
public:
52
    explicit SmXMLImportWrapper(rtl::Reference<SmModel> xRef)
53
0
        : m_xModel(std::move(xRef))
54
0
        , m_bUseHTMLMLEntities(false)
55
0
    {
56
0
    }
57
58
    ErrCode Import(SfxMedium& rMedium);
59
0
    void useHTMLMLEntities(bool bUseHTMLMLEntities) { m_bUseHTMLMLEntities = bUseHTMLMLEntities; }
60
61
    static ErrCode
62
    ReadThroughComponent(const css::uno::Reference<css::io::XInputStream>& xInputStream,
63
                         const css::uno::Reference<css::lang::XComponent>& xModelComponent,
64
                         css::uno::Reference<css::uno::XComponentContext> const& rxContext,
65
                         css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
66
                         const char* pFilterName, bool bEncrypted, bool bUseHTMLMLEntities);
67
68
    static ErrCode
69
    ReadThroughComponent(const css::uno::Reference<css::embed::XStorage>& xStorage,
70
                         const css::uno::Reference<css::lang::XComponent>& xModelComponent,
71
                         const char* pStreamName,
72
                         css::uno::Reference<css::uno::XComponentContext> const& rxContext,
73
                         css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
74
                         const char* pFilterName, bool bUseHTMLMLEntities);
75
};
76
77
class SmXMLImport final : public SvXMLImport
78
{
79
    SmNodeStack aNodeStack;
80
    bool bSuccess;
81
    int nParseDepth;
82
    OUString aText;
83
    sal_Int16 mnSmSyntaxVersion;
84
85
public:
86
    SmXMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
87
                OUString const& implementationName, SvXMLImportFlags nImportFlags);
88
    virtual ~SmXMLImport() noexcept override;
89
90
    void SAL_CALL endDocument() override;
91
92
    SvXMLImportContext* CreateFastContext(
93
        sal_Int32 nElement,
94
        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
95
96
182k
    SmNodeStack& GetNodeStack() { return aNodeStack; }
97
98
2.73k
    bool GetSuccess() const { return bSuccess; }
99
245
    [[nodiscard]] const OUString& GetText() const { return aText; }
100
245
    void SetText(const OUString& rStr) { aText = rStr; }
101
102
    virtual void
103
    SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
104
    virtual void SetConfigurationSettings(
105
        const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
106
107
142k
    void IncParseDepth() { ++nParseDepth; }
108
50.3k
    bool TooDeep() const { return nParseDepth >= 2048; }
109
142k
    void DecParseDepth() { --nParseDepth; }
110
245
    void SetSmSyntaxVersion(sal_Int16 nSmSyntaxVersion) { mnSmSyntaxVersion = nSmSyntaxVersion; }
111
0
    sal_Int16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; }
112
};
113
114
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */