Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / oox / core / contexthandler.hxx
blob89bdb2b9affdcc521b9a5b8adaa3af21e1fe73ed
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_OOX_CORE_CONTEXTHANDLER_HXX
21 #define INCLUDED_OOX_CORE_CONTEXTHANDLER_HXX
23 #include <memory>
24 #include <string_view>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
30 #include <cppuhelper/implbase.hxx>
31 #include <oox/dllapi.h>
32 #include <rtl/ref.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
36 namespace com::sun::star {
37 namespace xml::sax { class XFastAttributeList; }
38 namespace xml::sax { class XLocator; }
41 namespace oox { class SequenceInputStream; }
43 namespace oox::core {
45 class XmlFilterBase;
46 struct Relation;
47 class Relations;
49 class ContextHandler;
50 typedef ::rtl::Reference< ContextHandler > ContextHandlerRef;
52 struct FragmentBaseData;
53 typedef std::shared_ptr< FragmentBaseData > FragmentBaseDataRef;
55 typedef ::cppu::WeakImplHelper< css::xml::sax::XFastContextHandler > ContextHandler_BASE;
57 class OOX_DLLPUBLIC ContextHandler : public ContextHandler_BASE
59 public:
60 explicit ContextHandler( const ContextHandler& rParent );
61 virtual ~ContextHandler() override;
63 /** Returns the filter instance. */
64 XmlFilterBase& getFilter() const;
65 /** Returns the relations of the current fragment. */
66 const Relations& getRelations() const;
67 /** Returns the full path of the current fragment. */
68 const OUString& getFragmentPath() const;
70 /** Returns the full fragment path for the target of the passed relation. */
71 OUString getFragmentPathFromRelation( const Relation& rRelation ) const;
72 /** Returns the full fragment path for the passed relation identifier. */
73 OUString getFragmentPathFromRelId( const OUString& rRelId ) const;
74 /** Returns the full fragment path for the first relation of the passed type. */
75 OUString getFragmentPathFromFirstType( std::u16string_view rType ) const;
76 OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType ) const;
78 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
80 virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
81 virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
82 virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) override;
83 virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) override;
84 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
85 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;
86 virtual void SAL_CALL characters( const OUString& aChars ) override;
88 // record context interface -----------------------------------------------
90 virtual ContextHandlerRef createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
91 virtual void startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
92 virtual void endRecord( sal_Int32 nRecId );
94 protected:
95 /** Helper constructor for the FragmentHandler. */
96 explicit ContextHandler( FragmentBaseDataRef rxBaseData );
98 void implSetLocator( const css::uno::Reference< css::xml::sax::XLocator >& rxLocator );
100 #ifdef _MSC_VER
101 ContextHandler() {} // workaround
102 #endif
104 private:
105 ContextHandler& operator=( const ContextHandler& ) = delete;
107 private:
108 FragmentBaseDataRef mxBaseData; ///< Base data of the fragment.
111 } // namespace oox::core
113 #endif
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */