Line data Source code
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/XAttributeList.hpp>
27 : #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
28 : #include <tools/ref.hxx>
29 : #include <rtl/ustring.hxx>
30 : #include <tools/rtti.hxx>
31 : #include <cppuhelper/implbase1.hxx>
32 :
33 : class SvXMLNamespaceMap;
34 : class SvXMLImport;
35 :
36 12 : class XMLOFF_DLLPUBLIC SvXMLImportContext : public SvRefBase,
37 : public ::cppu::WeakImplHelper1< ::css::xml::sax::XFastContextHandler >
38 : {
39 : friend class SvXMLImport;
40 :
41 : SvXMLImport& mrImport;
42 :
43 : sal_uInt16 mnPrefix;
44 : OUString maLocalName;
45 :
46 : SvXMLNamespaceMap *mpRewindMap;
47 :
48 329936 : SAL_DLLPRIVATE SvXMLNamespaceMap *GetRewindMap() const
49 329936 : { return mpRewindMap; }
50 3936 : SAL_DLLPRIVATE void SetRewindMap( SvXMLNamespaceMap *p ) { mpRewindMap = p; }
51 :
52 : protected:
53 :
54 1515341 : SvXMLImport& GetImport() { return mrImport; }
55 32018 : const SvXMLImport& GetImport() const { return mrImport; }
56 :
57 : public:
58 : TYPEINFO();
59 :
60 15952 : sal_uInt16 GetPrefix() const { return mnPrefix; }
61 30184 : const OUString& GetLocalName() const { return maLocalName; }
62 :
63 : /** A contexts constructor does anything that is required if an element
64 : * starts. Namespace processing has been done already.
65 : * Note that virtual methods cannot be used inside constructors. Use
66 : * StartElement instead if this is required. */
67 : SvXMLImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
68 : const OUString& rLName );
69 :
70 : SvXMLImportContext( SvXMLImport& rImport );
71 :
72 : /** A contexts destructor does anything that is required if an element
73 : * ends. By default, nothing is done.
74 : * Note that virtual methods cannot be used inside destructors. Use
75 : * EndElement instead if this is required. */
76 : virtual ~SvXMLImportContext();
77 :
78 : /** Create a children element context. By default, the import's
79 : * CreateContext method is called to create a new default context. */
80 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
81 : const OUString& rLocalName,
82 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
83 :
84 : /** StartElement is called after a context has been constructed and
85 : * before a elements context is parsed. It may be used for actions that
86 : * require virtual methods. The default is to do nothing. */
87 : virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
88 :
89 : /** EndElement is called before a context will be destructed, but
90 : * after a elements context has been parsed. It may be used for actions
91 : * that require virtual methods. The default is to do nothing. */
92 : virtual void EndElement();
93 :
94 : /** This method is called for all characters that are contained in the
95 : * current element. The default is to ignore them. */
96 : virtual void Characters( const OUString& rChars );
97 :
98 : // ::com::sun::star::xml::sax::XFastContextHandler:
99 : virtual void SAL_CALL startFastElement (sal_Int32 Element,
100 : const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs)
101 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
102 :
103 : virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name,
104 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
105 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
106 :
107 : virtual void SAL_CALL endFastElement(sal_Int32 Element)
108 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
109 :
110 : virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name)
111 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
112 :
113 : virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element,
114 : const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs)
115 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
116 :
117 : virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(
118 : const OUString & Namespace, const OUString & Name,
119 : const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
120 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
121 :
122 : virtual void SAL_CALL characters(const OUString & aChars)
123 : throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
124 :
125 : // #i124143# allow to copy evtl. useful data from another temporary import context, e.g. used to
126 : // support multiple images and to rescue evtl. GluePoints imported with one of the
127 : // to be deprecated contents
128 : virtual void onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate );
129 : };
130 :
131 : typedef tools::SvRef<SvXMLImportContext> SvXMLImportContextRef;
132 :
133 : #endif // INCLUDED_XMLOFF_XMLICTXT_HXX
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|