sw: clean up Start/EndAction in SwViewShell hierarchy
[LibreOffice.git] / starmath / inc / mathml / mathmlimport.hxx
blob3e2b5d2a991d3159b97c8a2a5e287b823157f73e
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 <utility>
23 #include <xmloff/xmlimp.hxx>
24 #include <comphelper/errcode.hxx>
26 #include <deque>
28 class SmNode;
29 class SfxMedium;
30 namespace com::sun::star
32 namespace beans
34 class XPropertySet;
37 class SmModel;
39 typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack;
41 class SmXMLImportWrapper
43 rtl::Reference<SmModel> m_xModel;
45 private:
46 // Use customized entities
47 bool m_bUseHTMLMLEntities;
49 public:
50 explicit SmXMLImportWrapper(rtl::Reference<SmModel> xRef)
51 : m_xModel(std::move(xRef))
52 , m_bUseHTMLMLEntities(false)
56 ErrCode Import(SfxMedium& rMedium);
57 void useHTMLMLEntities(bool bUseHTMLMLEntities) { m_bUseHTMLMLEntities = bUseHTMLMLEntities; }
59 static ErrCode
60 ReadThroughComponent(const css::uno::Reference<css::io::XInputStream>& xInputStream,
61 const css::uno::Reference<css::lang::XComponent>& xModelComponent,
62 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
63 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
64 const char* pFilterName, bool bEncrypted, bool bUseHTMLMLEntities);
66 static ErrCode
67 ReadThroughComponent(const css::uno::Reference<css::embed::XStorage>& xStorage,
68 const css::uno::Reference<css::lang::XComponent>& xModelComponent,
69 const char* pStreamName,
70 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
71 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
72 const char* pFilterName, bool bUseHTMLMLEntities);
75 class SmXMLImport final : public SvXMLImport
77 SmNodeStack aNodeStack;
78 bool bSuccess;
79 int nParseDepth;
80 OUString aText;
81 sal_Int16 mnSmSyntaxVersion;
83 public:
84 SmXMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
85 OUString const& implementationName, SvXMLImportFlags nImportFlags);
86 virtual ~SmXMLImport() noexcept override;
88 void SAL_CALL endDocument() override;
90 SvXMLImportContext* CreateFastContext(
91 sal_Int32 nElement,
92 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
94 SmNodeStack& GetNodeStack() { return aNodeStack; }
96 bool GetSuccess() const { return bSuccess; }
97 [[nodiscard]] const OUString& GetText() const { return aText; }
98 void SetText(const OUString& rStr) { aText = rStr; }
100 virtual void
101 SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
102 virtual void SetConfigurationSettings(
103 const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
105 void IncParseDepth() { ++nParseDepth; }
106 bool TooDeep() const { return nParseDepth >= 2048; }
107 void DecParseDepth() { --nParseDepth; }
108 void SetSmSyntaxVersion(sal_Int16 nSmSyntaxVersion) { mnSmSyntaxVersion = nSmSyntaxVersion; }
109 sal_Int16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; }
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */