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_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 XFastContextHandler
; }
38 namespace xml::sax
{ class XLocator
; }
45 /** Base data of a fragment.
47 This data is stored in a separate struct to make it accessible in every
48 child context handler of the fragment.
50 struct FragmentBaseData
52 XmlFilterBase
& mrFilter
;
53 const OUString maFragmentPath
;
54 css::uno::Reference
< css::xml::sax::XLocator
>
56 RelationsRef mxRelations
;
58 explicit FragmentBaseData(
59 XmlFilterBase
& rFilter
,
60 OUString aFragmentPath
,
61 RelationsRef xRelations
);
65 /** Describes record identifiers used to create contexts in a binary stream.
67 If a record is used to start a new context, usually the record identifier
68 increased by 1 is used to mark the end of this context, e.g. the Excel
69 record SHEETDATA == 0x0091 starts the <sheetData> context, and the record
70 SHEETDATA_END == 0x0092 ends this context. But some records are used to
71 start a new context, though there is no identifier to end this context,
72 e.g. the ROW or EXTROW records. These record identifiers can be marked by
73 setting the mnEndRecId member of this struct to -1.
77 sal_Int32 mnStartRecId
; ///< Record identifier for context start.
78 sal_Int32 mnEndRecId
; ///< Record identifier for context end, -1 = no record.
82 typedef ::cppu::ImplInheritanceHelper
< ContextHandler
, css::xml::sax::XFastDocumentHandler
> FragmentHandler_BASE
;
84 class OOX_DLLPUBLIC FragmentHandler
: public FragmentHandler_BASE
87 explicit FragmentHandler( XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
);
88 virtual ~FragmentHandler() override
;
90 FragmentHandler(FragmentHandler
const &) = default;
91 FragmentHandler(FragmentHandler
&&) = default;
92 FragmentHandler
& operator =(FragmentHandler
const &) = delete; // due to ContextHandler
93 FragmentHandler
& operator =(FragmentHandler
&&) = delete; // due to ContextHandler
95 /** Returns the com.sun.star.xml.sax.XFastContextHandler interface of this context. */
96 css::uno::Reference
< css::xml::sax::XFastContextHandler
>
97 getFastContextHandler() { return static_cast< ContextHandler
* >( this ); }
99 // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
101 virtual void SAL_CALL
startDocument() override
;
102 virtual void SAL_CALL
endDocument() override
;
103 virtual void SAL_CALL
processingInstruction( const OUString
& rTarget
, const OUString
& rData
) override
;
104 virtual void SAL_CALL
setDocumentLocator( const css::uno::Reference
< css::xml::sax::XLocator
>& rxLocator
) override
;
106 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
108 virtual void SAL_CALL
startFastElement( ::sal_Int32 Element
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
109 virtual void SAL_CALL
startUnknownElement( const OUString
& Namespace
, const OUString
& Name
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
110 virtual void SAL_CALL
endFastElement( ::sal_Int32 Element
) override
;
111 virtual void SAL_CALL
endUnknownElement( const OUString
& Namespace
, const OUString
& Name
) override
;
112 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 Element
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& Attribs
) override
;
113 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
;
114 virtual void SAL_CALL
characters( const OUString
& aChars
) override
;
116 // XML stream handling ----------------------------------------------------
118 /** Opens the fragment stream referred by the own fragment path. Derived
119 classes may provide specialized stream implementations. */
120 virtual css::uno::Reference
< css::io::XInputStream
>
121 openFragmentStream() const;
123 // binary records ---------------------------------------------------------
125 virtual const RecordInfo
* getRecordInfos() const;
128 explicit FragmentHandler( XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
, RelationsRef xRelations
);
131 typedef ::rtl::Reference
< FragmentHandler
> FragmentHandlerRef
;
134 } // namespace oox::core
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */