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/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>
32 
33 namespace com::sun::star::xml::sax { class XAttributeList; }
34 
35 class SvXMLImport;
36 
38 
40 
45 class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHandler,
46  public css::lang::XTypeProvider
47 
48 {
49  friend class SvXMLImport;
50 
52  oslInterlockedCount m_nRefCount;
53 
54 protected:
55 
56  SvXMLImport& GetImport() { return mrImport; }
57  const SvXMLImport& GetImport() const { return mrImport; }
58 
59 public:
60 
65  SvXMLImportContext( SvXMLImport& rImport );
66 
71  virtual ~SvXMLImportContext();
72 
73  // css::xml::sax::XFastContextHandler:
74  virtual void SAL_CALL startFastElement (sal_Int32 Element,
75  const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override;
76 
77  virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
78  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
79 
83  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
84 
85  virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
86 
87  virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
88  const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
89 
90  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
91  const OUString & Namespace, const OUString & Name,
92  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
93 
96  virtual void SAL_CALL characters(const OUString & aChars) override;
97 
98  // XInterface
99  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
100  virtual void SAL_CALL acquire() throw () final override
101  { osl_atomic_increment(&m_nRefCount); }
102  virtual void SAL_CALL release() throw () final override
103  { if (osl_atomic_decrement(&m_nRefCount) == 0) delete this; }
104 
105  // XTypeProvider
106  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
107  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
108 };
109 
110 #define XMLOFF_WARN_UNKNOWN(area, rIter) \
111  SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(rIter.getToken()) << " value=" << rIter.toString());
112 
113 #define XMLOFF_WARN_UNKNOWN_ATTR(area, token, value) \
114  SAL_WARN(area, "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(token) << "=" << value);
115 
116 #define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token) \
117  SAL_WARN(area, "unknown element " << SvXMLImport::getPrefixAndNameFromToken(token));
118 
119 #endif // INCLUDED_XMLOFF_XMLICTXT_HXX
120 
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & mrImport
Definition: xmlictxt.hxx:51
const SvXMLImport & GetImport() const
Definition: xmlictxt.hxx:57
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
Definition: xmlimp.cxx:840
signed char sal_Int8
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:56
virtual void SAL_CALL endUnknownElement(const OUString &Namespace, const OUString &Name) override
Definition: xmlimp.cxx:854
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:744
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:869
virtual void SAL_CALL acquire() final override
Definition: xmlictxt.hxx:100
friend class SvXMLImportContext
Definition: xmlimp.hxx:186
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString &Namespace, const OUString &Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:876
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
oslInterlockedCount m_nRefCount
Definition: xmlictxt.hxx:52
rtl::Reference< SvXMLImportContext > SvXMLImportContextRef
Definition: xmlictxt.hxx:37
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:728
virtual void SAL_CALL startUnknownElement(const OUString &Namespace, const OUString &Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:803
virtual void SAL_CALL release() final override
Definition: xmlictxt.hxx:102