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 <memory>
31 
32 namespace com::sun::star::xml::sax { class XAttributeList; }
33 
34 class SvXMLImport;
35 
37 
39 
44 class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHandler,
45  public css::lang::XTypeProvider
46 
47 {
48  friend class SvXMLImport;
49 
51  OUString maLocalName;
52  std::unique_ptr<SvXMLNamespaceMap> m_pRewindMap;
53  oslInterlockedCount m_nRefCount;
54  sal_uInt16 mnPrefix;
56 
57  SAL_DLLPRIVATE std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_pRewindMap); }
58  SAL_DLLPRIVATE void PutRewindMap(std::unique_ptr<SvXMLNamespaceMap> p) { m_pRewindMap = std::move(p); }
59 
60 protected:
61 
62  SvXMLImport& GetImport() { return mrImport; }
63  const SvXMLImport& GetImport() const { return mrImport; }
64 
65 public:
66 
67  bool IsPrefixFilledIn() const { return mnPrefix != 0; }
68  sal_uInt16 GetPrefix() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context"); return mnPrefix; }
69  const OUString& GetLocalName() const { assert(mbPrefixAndLocalNameFilledIn && "those fields not filled, probably fast-parser context"); return maLocalName; }
70 
75  SvXMLImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
76  const OUString& rLName );
77 
78  SvXMLImportContext( SvXMLImport& rImport );
79 
84  virtual ~SvXMLImportContext();
85 
88  virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix,
89  const OUString& rLocalName,
90  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
91 
95  virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
96 
100  virtual void EndElement();
101 
104  virtual void Characters( const OUString& rChars );
105 
106  // css::xml::sax::XFastContextHandler:
107  virtual void SAL_CALL startFastElement (sal_Int32 Element,
108  const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override;
109 
110  virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
111  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
112 
113  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
114 
115  virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
116 
117  virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
118  const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
119 
120  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
121  const OUString & Namespace, const OUString & Name,
122  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
123 
124  virtual void SAL_CALL characters(const OUString & aChars) override;
125 
126  // XInterface
127  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
128  virtual void SAL_CALL acquire() throw () final override
129  { osl_atomic_increment(&m_nRefCount); }
130  virtual void SAL_CALL release() throw () final override
131  { if (osl_atomic_decrement(&m_nRefCount) == 0) delete this; }
132 
133  // XTypeProvider
134  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
135  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
136 };
137 
138 #endif // INCLUDED_XMLOFF_XMLICTXT_HXX
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Characters(const OUString &aChars)
Definition: xmlimp.cxx:825
SvXMLImport & mrImport
Definition: xmlictxt.hxx:50
const SvXMLImport & GetImport() const
Definition: xmlictxt.hxx:63
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
Definition: xmlimp.cxx:927
signed char sal_Int8
sal_uInt16 mnPrefix
Definition: xmlictxt.hxx:54
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
bool IsPrefixFilledIn() const
Definition: xmlictxt.hxx:67
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const OUString & GetLocalName() const
Definition: xmlictxt.hxx:69
SAL_DLLPRIVATE std::unique_ptr< SvXMLNamespaceMap > TakeRewindMap()
Definition: xmlictxt.hxx:57
virtual void SAL_CALL endUnknownElement(const OUString &Namespace, const OUString &Name) override
Definition: xmlimp.cxx:937
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:844
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:945
bool mbPrefixAndLocalNameFilledIn
Definition: xmlictxt.hxx:55
virtual void SAL_CALL acquire() final override
Definition: xmlictxt.hxx:128
friend class SvXMLImportContext
Definition: xmlimp.hxx:184
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:952
std::unique_ptr< SvXMLNamespaceMap > m_pRewindMap
Definition: xmlictxt.hxx:52
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
oslInterlockedCount m_nRefCount
Definition: xmlictxt.hxx:53
rtl::Reference< SvXMLImportContext > SvXMLImportContextRef
Definition: xmlictxt.hxx:36
OUString maLocalName
Definition: xmlictxt.hxx:51
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
sal_uInt16 GetPrefix() const
Definition: xmlictxt.hxx:68
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:813
virtual void SAL_CALL startUnknownElement(const OUString &Namespace, const OUString &Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlimp.cxx:907
SAL_DLLPRIVATE void PutRewindMap(std::unique_ptr< SvXMLNamespaceMap > p)
Definition: xmlictxt.hxx:58
virtual void SAL_CALL release() final override
Definition: xmlictxt.hxx:130