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 .
23 #include <xmloff/xmlimp.hxx>
24 #include <comphelper/errcode.hxx>
30 namespace com::sun::star
39 typedef std::deque
<std::unique_ptr
<SmNode
>> SmNodeStack
;
41 class SmXMLImportWrapper
43 rtl::Reference
<SmModel
> m_xModel
;
46 // Use customized entities
47 bool m_bUseHTMLMLEntities
;
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
; }
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
);
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
;
81 sal_Int16 mnSmSyntaxVersion
;
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(
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
; }
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: */