nss: upgrade to release 3.73
[LibreOffice.git] / include / xmloff / xmlictxt.hxx
blob3e6f25329d988e03530f7d9b3f5b7b4d9172f4b2
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 #ifndef INCLUDED_XMLOFF_XMLICTXT_HXX
21 #define INCLUDED_XMLOFF_XMLICTXT_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
26 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <rtl/ustring.hxx>
29 #include <xmloff/namespacemap.hxx>
30 #include <sax/fastattribs.hxx>
31 #include <memory>
33 namespace com::sun::star::xml::sax { class XAttributeList; }
35 class SvXMLImport;
37 class SvXMLImportContext;
39 typedef rtl::Reference<SvXMLImportContext> SvXMLImportContextRef;
41 /**
42 This class deliberately does not support XWeak, to improve performance when loading
43 large documents.
45 class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHandler,
46 public css::lang::XTypeProvider
49 friend class SvXMLImport;
51 SvXMLImport& mrImport;
52 OUString maLocalName;
53 oslInterlockedCount m_nRefCount;
54 sal_uInt16 mnPrefix;
55 bool mbPrefixAndLocalNameFilledIn;
56 std::unique_ptr<SvXMLNamespaceMap> m_pRewindMap;
58 SAL_DLLPRIVATE std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_pRewindMap); }
59 SAL_DLLPRIVATE void PutRewindMap(std::unique_ptr<SvXMLNamespaceMap> p) { m_pRewindMap = std::move(p); }
61 protected:
63 SvXMLImport& GetImport() { return mrImport; }
64 const SvXMLImport& GetImport() const { return mrImport; }
66 public:
68 bool IsPrefixFilledIn() const { return mnPrefix != 0; }
69 sal_uInt16 GetPrefix() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context"); return mnPrefix; }
70 const OUString& GetLocalName() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context"); return maLocalName; }
72 /** A contexts constructor does anything that is required if an element
73 * starts. Namespace processing has been done already.
74 * Note that virtual methods cannot be used inside constructors. Use
75 * StartElement instead if this is required. */
76 SvXMLImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
77 const OUString& rLName );
79 SvXMLImportContext( SvXMLImport& rImport );
81 /** A contexts destructor does anything that is required if an element
82 * ends. By default, nothing is done.
83 * Note that virtual methods cannot be used inside destructors. Use
84 * EndElement instead if this is required. */
85 virtual ~SvXMLImportContext();
87 /** Create a children element context. By default, the import's
88 * CreateContext method is called to create a new default context. */
89 virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
90 const OUString& rLocalName,
91 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
93 /** StartElement is called after a context has been constructed and
94 * before an elements context is parsed. It may be used for actions that
95 * require virtual methods. The default is to do nothing. */
96 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
98 // css::xml::sax::XFastContextHandler:
99 virtual void SAL_CALL startFastElement (sal_Int32 Element,
100 const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override;
102 virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
103 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
105 /** endFastElement is called before a context will be destructed, but
106 * after an elements context has been parsed. It may be used for actions
107 * that require virtual methods. The default is to do nothing. */
108 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
110 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
112 virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
113 const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
115 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
116 const OUString & Namespace, const OUString & Name,
117 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
119 /** This method is called for all characters that are contained in the
120 * current element. The default is to ignore them. */
121 virtual void SAL_CALL characters(const OUString & aChars) override;
123 // XInterface
124 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
125 virtual void SAL_CALL acquire() throw () final override
126 { osl_atomic_increment(&m_nRefCount); }
127 virtual void SAL_CALL release() throw () final override
128 { if (osl_atomic_decrement(&m_nRefCount) == 0) delete this; }
130 // XTypeProvider
131 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
132 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
135 #define XMLOFF_WARN_UNKNOWN(area, rIter) \
136 SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(rIter.getToken()) << " value=" << rIter.toString());
138 #define XMLOFF_WARN_UNKNOWN_ATTR(area, token, value) \
139 SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(token) << "=" << value);
141 #define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token) \
142 SAL_WARN(area, "unknown element " << SvXMLImport::getPrefixAndNameFromToken(token));
144 #endif // INCLUDED_XMLOFF_XMLICTXT_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */