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 OOX_CORE_FRAGMENTHANDLER_HXX
21 #define OOX_CORE_FRAGMENTHANDLER_HXX
23 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
24 #include <cppuhelper/implbase1.hxx>
25 #include "oox/core/contexthandler.hxx"
26 #include "oox/core/relations.hxx"
27 #include "oox/dllapi.h"
29 namespace com
{ namespace sun
{ namespace star
{
30 namespace io
{ class XInputStream
; }
36 // ============================================================================
38 /** Base data of a fragment.
40 This data is stored in a separate struct to make it accessible in every
41 child context handler of the fragment.
43 struct FragmentBaseData
45 XmlFilterBase
& mrFilter
;
46 const OUString maFragmentPath
;
47 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
>
49 RelationsRef mxRelations
;
51 explicit FragmentBaseData(
52 XmlFilterBase
& rFilter
,
53 const OUString
& rFragmentPath
,
54 RelationsRef xRelations
);
57 // ============================================================================
59 /** Describes record identifiers used to create contexts in a binary stream.
61 If a record is used to start a new context, usually the record identifier
62 increased by 1 is used to mark the end of this context, e.g. the Excel
63 record SHEETDATA == 0x0091 starts the <sheetData> context, and the record
64 SHEETDATA_END == 0x0092 ends this context. But some records are used to
65 start a new context, though there is no identifier to end this context,
66 e.g. the ROW or EXTROW records. These record identifiers can be marked by
67 setting the mnEndRecId member of this struct to -1.
71 sal_Int32 mnStartRecId
; ///< Record identifier for context start.
72 sal_Int32 mnEndRecId
; ///< Record identifier for context end, -1 = no record.
75 // ============================================================================
77 typedef ::cppu::ImplInheritanceHelper1
< ContextHandler
, ::com::sun::star::xml::sax::XFastDocumentHandler
> FragmentHandler_BASE
;
79 class OOX_DLLPUBLIC FragmentHandler
: public FragmentHandler_BASE
82 explicit FragmentHandler( XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
);
83 virtual ~FragmentHandler();
85 /** Returns the com.sun.star.xml.sax.XFastContextHandler interface of this context. */
86 inline ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
>
87 getFastContextHandler() { return static_cast< ContextHandler
* >( this ); }
89 // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
91 virtual void SAL_CALL
startDocument() throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
endDocument() throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
93 virtual void SAL_CALL
setDocumentLocator( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
>& rxLocator
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
95 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
97 virtual void SAL_CALL
startFastElement( ::sal_Int32 Element
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& Attribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
startUnknownElement( const OUString
& Namespace
, const OUString
& Name
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& Attribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
99 virtual void SAL_CALL
endFastElement( ::sal_Int32 Element
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
100 virtual void SAL_CALL
endUnknownElement( const OUString
& Namespace
, const OUString
& Name
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
101 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 Element
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& Attribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
102 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastContextHandler
> SAL_CALL
createUnknownChildContext( const OUString
& Namespace
, const OUString
& Name
, const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XFastAttributeList
>& Attribs
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
103 virtual void SAL_CALL
characters( const OUString
& aChars
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
ignorableWhitespace( const OUString
& aWhitespaces
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
105 virtual void SAL_CALL
processingInstruction( const OUString
& aTarget
, const OUString
& aData
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
107 // XML stream handling ----------------------------------------------------
109 /** Opens the fragment stream referred by the own fragment path. Derived
110 classes may provide specilized stream implementations. */
111 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
>
112 openFragmentStream() const;
114 // binary records ---------------------------------------------------------
116 virtual const RecordInfo
* getRecordInfos() const;
119 explicit FragmentHandler( XmlFilterBase
& rFilter
, const OUString
& rFragmentPath
, RelationsRef xRelations
);
122 typedef ::rtl::Reference
< FragmentHandler
> FragmentHandlerRef
;
124 // ============================================================================
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */