bump product version to 7.2.5.1
[LibreOffice.git] / starmath / inc / mathml / mathmlimport.hxx
blob4e5444945f7ea9dcf3ac7238c2e1805b16c09295
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 #pragma once
22 #include <xmloff/xmlimp.hxx>
23 #include <vcl/errcode.hxx>
25 #include <deque>
27 class SmNode;
28 class SfxMedium;
29 namespace com::sun::star
31 namespace beans
33 class XPropertySet;
37 typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack;
39 class SmXMLImportWrapper
41 css::uno::Reference<css::frame::XModel> xModel;
43 private:
44 // Use customized entities
45 bool m_bUseHTMLMLEntities;
47 public:
48 explicit SmXMLImportWrapper(css::uno::Reference<css::frame::XModel> const& rRef)
49 : xModel(rRef)
50 , m_bUseHTMLMLEntities(false)
54 ErrCode Import(SfxMedium& rMedium);
55 void useHTMLMLEntities(bool bUseHTMLMLEntities) { m_bUseHTMLMLEntities = bUseHTMLMLEntities; }
57 static ErrCode
58 ReadThroughComponent(const css::uno::Reference<css::io::XInputStream>& xInputStream,
59 const css::uno::Reference<css::lang::XComponent>& xModelComponent,
60 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
61 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
62 const char* pFilterName, bool bEncrypted, bool bUseHTMLMLEntities);
64 static ErrCode
65 ReadThroughComponent(const css::uno::Reference<css::embed::XStorage>& xStorage,
66 const css::uno::Reference<css::lang::XComponent>& xModelComponent,
67 const char* pStreamName,
68 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
69 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
70 const char* pFilterName, bool bUseHTMLMLEntities);
73 class SmXMLImport : public SvXMLImport
75 SmNodeStack aNodeStack;
76 bool bSuccess;
77 int nParseDepth;
78 OUString aText;
79 sal_uInt16 mnSmSyntaxVersion;
81 public:
82 SmXMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
83 OUString const& implementationName, SvXMLImportFlags nImportFlags);
84 virtual ~SmXMLImport() noexcept override;
86 // XUnoTunnel
87 sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override;
88 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() noexcept;
90 void SAL_CALL endDocument() override;
92 SvXMLImportContext* CreateFastContext(
93 sal_Int32 nElement,
94 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
96 SmNodeStack& GetNodeStack() { return aNodeStack; }
98 bool GetSuccess() const { return bSuccess; }
99 [[nodiscard]] const OUString& GetText() const { return aText; }
100 void SetText(const OUString& rStr) { aText = rStr; }
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;
107 void IncParseDepth() { ++nParseDepth; }
108 bool TooDeep() const { return nParseDepth >= 2048; }
109 void DecParseDepth() { --nParseDepth; }
110 void SetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion) { mnSmSyntaxVersion = nSmSyntaxVersion; }
111 sal_uInt16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; }
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */