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_CONTEXTHANDLER_HXX
21 #define OOX_CORE_CONTEXTHANDLER_HXX
23 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <cppuhelper/implbase1.hxx>
26 #include <rtl/ref.hxx>
27 #include "oox/token/namespaces.hxx"
28 #include "oox/token/tokens.hxx"
29 #include "oox/dllapi.h"
31 namespace com
{ namespace sun
{ namespace star
{
32 namespace xml
{ namespace sax
{ class XLocator
; } }
35 namespace oox
{ class SequenceInputStream
; }
41 class FragmentHandler
;
45 // ============================================================================
48 typedef ::rtl::Reference
< ContextHandler
> ContextHandlerRef
;
50 struct FragmentBaseData
;
51 typedef ::boost::shared_ptr
< FragmentBaseData
> FragmentBaseDataRef
;
53 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::xml::sax::XFastContextHandler
> ContextHandler_BASE
;
55 class OOX_DLLPUBLIC ContextHandler
: public ContextHandler_BASE
58 explicit ContextHandler( const ContextHandler
& rParent
);
59 virtual ~ContextHandler();
61 /** Returns the filter instance. */
62 XmlFilterBase
& getFilter() const;
63 /** Returns the relations of the current fragment. */
64 const Relations
& getRelations() const;
65 /** Returns the full path of the current fragment. */
66 const OUString
& getFragmentPath() const;
68 /** Returns the full fragment path for the target of the passed relation. */
69 OUString
getFragmentPathFromRelation( const Relation
& rRelation
) const;
70 /** Returns the full fragment path for the passed relation identifier. */
71 OUString
getFragmentPathFromRelId( const OUString
& rRelId
) const;
72 /** Returns the full fragment path for the first relation of the passed type. */
73 OUString
getFragmentPathFromFirstType( const OUString
& rType
) const;
75 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
77 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
);
78 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
);
79 virtual void SAL_CALL
endFastElement( ::sal_Int32 Element
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
80 virtual void SAL_CALL
endUnknownElement( const OUString
& Namespace
, const OUString
& Name
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
81 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
);
82 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
);
83 virtual void SAL_CALL
characters( const OUString
& aChars
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
84 virtual void SAL_CALL
ignorableWhitespace( const OUString
& aWhitespaces
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
85 virtual void SAL_CALL
processingInstruction( const OUString
& aTarget
, const OUString
& aData
) throw (::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
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( const FragmentBaseDataRef
& rxBaseData
);
97 void implSetLocator( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
>& rxLocator
);
100 ContextHandler() {} // workaround
104 ContextHandler
& operator=( const ContextHandler
& );
107 FragmentBaseDataRef mxBaseData
; ///< Base data of the fragment.
110 // ============================================================================
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */