1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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 XLocator
; }
40 namespace oox
{ class SequenceInputStream
; }
49 typedef ::rtl::Reference
< ContextHandler
> ContextHandlerRef
;
51 struct FragmentBaseData
;
52 typedef std::shared_ptr
< FragmentBaseData
> FragmentBaseDataRef
;
54 typedef ::cppu::WeakImplHelper
< css::xml::sax::XFastContextHandler
> ContextHandler_BASE
;
56 class OOX_DLLPUBLIC ContextHandler
: public ContextHandler_BASE
59 explicit ContextHandler( const ContextHandler
& rParent
);
60 virtual ~ContextHandler() override
;
62 /** Returns the filter instance. */
63 XmlFilterBase
& getFilter() const;
64 /** Returns the relations of the current fragment. */
65 const Relations
& getRelations() const;
66 /** Returns the full path of the current fragment. */
67 const OUString
& getFragmentPath() const;
69 /** Returns the full fragment path for the target of the passed relation. */
70 OUString
getFragmentPathFromRelation( const Relation
& rRelation
) const;
71 /** Returns the full fragment path for the passed relation identifier. */
72 OUString
getFragmentPathFromRelId( const OUString
& rRelId
) const;
73 /** Returns the full fragment path for the first relation of the passed type. */
74 OUString
getFragmentPathFromFirstType( std::u16string_view rType
) const;
75 OUString
getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rType
) const;
77 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
79 virtual void SAL_CALL
startFastElement( ::sal_Int32 Element
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
80 virtual void SAL_CALL
startUnknownElement( const OUString
& Namespace
, const OUString
& Name
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
81 virtual void SAL_CALL
endFastElement( ::sal_Int32 Element
) override
;
82 virtual void SAL_CALL
endUnknownElement( const OUString
& Namespace
, const OUString
& Name
) override
;
83 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 Element
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
84 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
;
85 virtual void SAL_CALL
characters( const OUString
& aChars
) override
;
87 // record context interface -----------------------------------------------
89 virtual ContextHandlerRef
createRecordContext( sal_Int32 nRecId
, SequenceInputStream
& rStrm
);
90 virtual void startRecord( sal_Int32 nRecId
, SequenceInputStream
& rStrm
);
91 virtual void endRecord( sal_Int32 nRecId
);
94 /** Helper constructor for the FragmentHandler. */
95 explicit ContextHandler( FragmentBaseDataRef rxBaseData
);
97 void implSetLocator( const css::uno::Reference
< css::xml::sax::XLocator
>& rxLocator
);
100 ContextHandler() {} // workaround
104 ContextHandler
& operator=( const ContextHandler
& ) = delete;
107 FragmentBaseDataRef mxBaseData
; ///< Base data of the fragment.
110 } // namespace oox::core
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */