1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_STARMATH_SOURCE_MATHMLIMPORT_HXX
21 #define INCLUDED_STARMATH_SOURCE_MATHMLIMPORT_HXX
23 #include <xmloff/xmlimp.hxx>
24 #include <vcl/errcode.hxx>
31 namespace com::sun::star
{
37 typedef std::deque
<std::unique_ptr
<SmNode
>> SmNodeStack
;
39 class SmXMLImportWrapper
41 css::uno::Reference
<css::frame::XModel
> xModel
;
44 explicit SmXMLImportWrapper(css::uno::Reference
<css::frame::XModel
> const &rRef
)
47 ErrCode
Import(SfxMedium
&rMedium
);
49 static ErrCode
ReadThroughComponent(
50 const css::uno::Reference
< css::io::XInputStream
>& xInputStream
,
51 const css::uno::Reference
< css::lang::XComponent
>& xModelComponent
,
52 css::uno::Reference
< css::uno::XComponentContext
> const & rxContext
,
53 css::uno::Reference
< css::beans::XPropertySet
> const & rPropSet
,
54 const char* pFilterName
,
57 static ErrCode
ReadThroughComponent(
58 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
59 const css::uno::Reference
< css::lang::XComponent
>& xModelComponent
,
60 const char* pStreamName
,
61 css::uno::Reference
< css::uno::XComponentContext
> const & rxContext
,
62 css::uno::Reference
< css::beans::XPropertySet
> const & rPropSet
,
63 const char* pFilterName
);
67 class SmXMLImport
: public SvXMLImport
69 SmNodeStack aNodeStack
;
76 const css::uno::Reference
< css::uno::XComponentContext
>& rContext
,
77 OUString
const & implementationName
, SvXMLImportFlags nImportFlags
);
78 virtual ~SmXMLImport() throw () override
;
81 sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& rId
) override
;
82 static const css::uno::Sequence
< sal_Int8
> & getUnoTunnelId() throw();
84 void SAL_CALL
endDocument() override
;
86 SvXMLImportContext
*CreateFastContext( sal_Int32 nElement
,
87 const css::uno::Reference
<
88 css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
90 SmNodeStack
& GetNodeStack() { return aNodeStack
; }
92 bool GetSuccess() const { return bSuccess
; }
93 [[nodiscard
]] const OUString
& GetText() const { return aText
; }
94 void SetText(const OUString
&rStr
) { aText
= rStr
; }
96 virtual void SetViewSettings(const css::uno::Sequence
<css::beans::PropertyValue
>& aViewProps
) override
;
97 virtual void SetConfigurationSettings(const css::uno::Sequence
<css::beans::PropertyValue
>& aViewProps
) override
;
99 void IncParseDepth() { ++nParseDepth
; }
100 bool TooDeep() const { return nParseDepth
>= 2048; }
101 void DecParseDepth() { --nParseDepth
; }
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */