LibreOffice Module xmloff (master) 1
xmlictxt.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_XMLOFF_XMLICTXT_HXX
21#define INCLUDED_XMLOFF_XMLICTXT_HXX
22
23#include <sal/config.h>
24#include <xmloff/dllapi.h>
25#include <sal/log.hxx>
26#include <sal/types.h>
27#include <com/sun/star/xml/sax/XFastContextHandler.hpp>
28#include <com/sun/star/lang/XTypeProvider.hpp>
29#include <rtl/ustring.hxx>
31#include <optional>
32
33namespace com::sun::star::xml::sax { class XAttributeList; }
34
35class SvXMLImport;
36
38
40
45class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHandler,
46 public css::lang::XTypeProvider
47
48{
49 friend class SvXMLImport;
50
51 SvXMLImport& mrImport;
52 oslInterlockedCount m_nRefCount;
53 std::optional<SvXMLNamespaceMap> m_xRewindMap;
54
55 SAL_DLLPRIVATE std::optional<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_xRewindMap); }
56 SAL_DLLPRIVATE void PutRewindMap(std::optional<SvXMLNamespaceMap>&& p) { m_xRewindMap = std::move(p); }
57
58protected:
59
60 SvXMLImport& GetImport() { return mrImport; }
61 const SvXMLImport& GetImport() const { return mrImport; }
62
63public:
64
69 SvXMLImportContext( SvXMLImport& rImport );
70
75 virtual ~SvXMLImportContext();
76
77 // css::xml::sax::XFastContextHandler:
78 virtual void SAL_CALL startFastElement (sal_Int32 Element,
79 const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override;
80
81 virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
82 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
83
87 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
88
89 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
90
91 virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
92 const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
93
94 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
95 const OUString & Namespace, const OUString & Name,
96 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
97
100 virtual void SAL_CALL characters(const OUString & aChars) override;
101
102 // XInterface
103 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
104 virtual void SAL_CALL acquire() noexcept final override
105 { osl_atomic_increment(&m_nRefCount); }
106 virtual void SAL_CALL release() noexcept final override
107 { if (osl_atomic_decrement(&m_nRefCount) == 0) delete this; }
108
109 // XTypeProvider
110 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
111 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
112};
113
114#define XMLOFF_WARN_UNKNOWN(area, rIter) \
115 SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(rIter.getToken()) << " value=" << rIter.toString());
116
117#define XMLOFF_WARN_UNKNOWN_ATTR(area, token, value) \
118 SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(token) << "=" << value);
119
120#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token) \
121 SAL_WARN(area, "unknown element " << SvXMLImport::getPrefixAndNameFromToken(token));
122
123#define XMLOFF_INFO_UNKNOWN_ELEMENT(area, token) \
124 SAL_INFO(area, "unknown element " << SvXMLImport::getPrefixAndNameFromToken(token));
125
126#endif // INCLUDED_XMLOFF_XMLICTXT_HXX
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SAL_DLLPRIVATE void PutRewindMap(std::optional< SvXMLNamespaceMap > &&p)
Definition: xmlictxt.hxx:56
const SvXMLImport & GetImport() const
Definition: xmlictxt.hxx:61
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual void SAL_CALL acquire() noexcept final override
Definition: xmlictxt.hxx:104
virtual void SAL_CALL release() noexcept final override
Definition: xmlictxt.hxx:106
oslInterlockedCount m_nRefCount
Definition: xmlictxt.hxx:52
std::optional< SvXMLNamespaceMap > m_xRewindMap
Definition: xmlictxt.hxx:53
SAL_DLLPRIVATE std::optional< SvXMLNamespaceMap > TakeRewindMap()
Definition: xmlictxt.hxx:55
SvXMLImport & mrImport
Definition: xmlictxt.hxx:51
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
void * p
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
signed char sal_Int8
rtl::Reference< SvXMLImportContext > SvXMLImportContextRef
Definition: xmlictxt.hxx:37