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 .
22 #include <xmloff/xmlimp.hxx>
23 #include <vcl/errcode.hxx>
29 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 // Use customized entities
45 bool m_bUseHTMLMLEntities
;
48 explicit SmXMLImportWrapper(css::uno::Reference
<css::frame::XModel
> const& rRef
)
50 , m_bUseHTMLMLEntities(false)
54 ErrCode
Import(SfxMedium
& rMedium
);
55 void useHTMLMLEntities(bool bUseHTMLMLEntities
) { m_bUseHTMLMLEntities
= bUseHTMLMLEntities
; }
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
);
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
;
79 sal_uInt16 mnSmSyntaxVersion
;
82 SmXMLImport(const css::uno::Reference
<css::uno::XComponentContext
>& rContext
,
83 OUString
const& implementationName
, SvXMLImportFlags nImportFlags
);
84 virtual ~SmXMLImport() noexcept override
;
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(
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
; }
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: */