tdf#133368: update extensions website URLs and use https
[LibreOffice.git] / include / oox / core / fragmenthandler.hxx
bloba3263ca1f7c5f1c7f92c40f763fd78eefbc8005e
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_FRAGMENTHANDLER_HXX
21 #define INCLUDED_OOX_CORE_FRAGMENTHANDLER_HXX
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <oox/core/contexthandler.hxx>
29 #include <oox/core/relations.hxx>
30 #include <oox/dllapi.h>
31 #include <rtl/ref.hxx>
32 #include <rtl/ustring.hxx>
33 #include <sal/types.h>
35 namespace com::sun::star {
36 namespace io { class XInputStream; }
37 namespace xml::sax { class XFastAttributeList; }
38 namespace xml::sax { class XFastContextHandler; }
39 namespace xml::sax { class XLocator; }
42 namespace oox::core {
44 class XmlFilterBase;
46 /** Base data of a fragment.
48 This data is stored in a separate struct to make it accessible in every
49 child context handler of the fragment.
51 struct FragmentBaseData
53 XmlFilterBase& mrFilter;
54 const OUString maFragmentPath;
55 css::uno::Reference< css::xml::sax::XLocator >
56 mxLocator;
57 RelationsRef mxRelations;
59 explicit FragmentBaseData(
60 XmlFilterBase& rFilter,
61 const OUString& rFragmentPath,
62 RelationsRef const & xRelations );
66 /** Describes record identifiers used to create contexts in a binary stream.
68 If a record is used to start a new context, usually the record identifier
69 increased by 1 is used to mark the end of this context, e.g. the Excel
70 record SHEETDATA == 0x0091 starts the <sheetData> context, and the record
71 SHEETDATA_END == 0x0092 ends this context. But some records are used to
72 start a new context, though there is no identifier to end this context,
73 e.g. the ROW or EXTROW records. These record identifiers can be marked by
74 setting the mnEndRecId member of this struct to -1.
76 struct RecordInfo
78 sal_Int32 mnStartRecId; ///< Record identifier for context start.
79 sal_Int32 mnEndRecId; ///< Record identifier for context end, -1 = no record.
83 typedef ::cppu::ImplInheritanceHelper< ContextHandler, css::xml::sax::XFastDocumentHandler > FragmentHandler_BASE;
85 class OOX_DLLPUBLIC FragmentHandler : public FragmentHandler_BASE
87 public:
88 explicit FragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath );
89 virtual ~FragmentHandler() override;
91 FragmentHandler(FragmentHandler const &) = default;
92 FragmentHandler(FragmentHandler &&) = default;
93 FragmentHandler & operator =(FragmentHandler const &) = delete; // due to ContextHandler
94 FragmentHandler & operator =(FragmentHandler &&) = delete; // due to ContextHandler
96 /** Returns the com.sun.star.xml.sax.XFastContextHandler interface of this context. */
97 css::uno::Reference< css::xml::sax::XFastContextHandler >
98 getFastContextHandler() { return static_cast< ContextHandler* >( this ); }
100 // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
102 virtual void SAL_CALL startDocument() override;
103 virtual void SAL_CALL endDocument() override;
104 virtual void SAL_CALL processingInstruction( const OUString& rTarget, const OUString& rData ) override;
105 virtual void SAL_CALL setDocumentLocator( const css::uno::Reference< css::xml::sax::XLocator >& rxLocator ) override;
107 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
109 virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
110 virtual void SAL_CALL startUnknownElement( const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
111 virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) override;
112 virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const OUString& Name ) override;
113 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs ) override;
114 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;
115 virtual void SAL_CALL characters( const OUString& aChars ) override;
117 // XML stream handling ----------------------------------------------------
119 /** Opens the fragment stream referred by the own fragment path. Derived
120 classes may provide specialized stream implementations. */
121 virtual css::uno::Reference< css::io::XInputStream >
122 openFragmentStream() const;
124 // binary records ---------------------------------------------------------
126 virtual const RecordInfo* getRecordInfos() const;
128 protected:
129 explicit FragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, RelationsRef xRelations );
132 typedef ::rtl::Reference< FragmentHandler > FragmentHandlerRef;
135 } // namespace oox::core
137 #endif
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */