1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OOX_CORE_CONTEXTHANDLER_HXX 25 #define OOX_CORE_CONTEXTHANDLER_HXX 26 27 #include <com/sun/star/xml/sax/XFastContextHandler.hpp> 28 #include <boost/shared_ptr.hpp> 29 #include <cppuhelper/implbase1.hxx> 30 #include <rtl/ref.hxx> 31 #include "oox/token/namespaces.hxx" 32 #include "oox/token/tokens.hxx" 33 34 namespace com { namespace sun { namespace star { 35 namespace xml { namespace sax { class XLocator; } } 36 } } } 37 38 namespace oox { class SequenceInputStream; } 39 40 namespace oox { 41 namespace core { 42 43 class XmlFilterBase; 44 class FragmentHandler; 45 struct Relation; 46 class Relations; 47 48 // ============================================================================ 49 50 class ContextHandler; 51 typedef ::rtl::Reference< ContextHandler > ContextHandlerRef; 52 53 struct FragmentBaseData; 54 typedef ::boost::shared_ptr< FragmentBaseData > FragmentBaseDataRef; 55 56 typedef ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastContextHandler > ContextHandler_BASE; 57 58 class ContextHandler : public ContextHandler_BASE 59 { 60 public: 61 explicit ContextHandler( ContextHandler& rParent ); 62 virtual ~ContextHandler(); 63 64 /** Returns the filter instance. */ 65 XmlFilterBase& getFilter() const; 66 /** Returns the relations of the current fragment. */ 67 const Relations& getRelations() const; 68 /** Returns the full path of the current fragment. */ 69 const ::rtl::OUString& getFragmentPath() const; 70 71 /** Returns the full fragment path for the target of the passed relation. */ 72 ::rtl::OUString getFragmentPathFromRelation( const Relation& rRelation ) const; 73 /** Returns the full fragment path for the passed relation identifier. */ 74 ::rtl::OUString getFragmentPathFromRelId( const ::rtl::OUString& rRelId ) const; 75 /** Returns the full fragment path for the first relation of the passed type. */ 76 ::rtl::OUString getFragmentPathFromFirstType( const ::rtl::OUString& rType ) const; 77 78 // com.sun.star.xml.sax.XFastContextHandler interface --------------------- 79 80 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); 81 virtual void SAL_CALL startUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::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); 82 virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 83 virtual void SAL_CALL endUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 84 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); 85 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext( const ::rtl::OUString& Namespace, const ::rtl::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); 86 virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 87 virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 88 virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 89 90 // record context interface ----------------------------------------------- 91 92 virtual ContextHandlerRef createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm ); 93 virtual void startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ); 94 virtual void endRecord( sal_Int32 nRecId ); 95 96 protected: 97 /** Helper constructor for the FragmentHandler. */ 98 explicit ContextHandler( const FragmentBaseDataRef& rxBaseData ); 99 100 void implSetLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& rxLocator ); 101 102 private: 103 ContextHandler& operator=( const ContextHandler& ); 104 105 private: 106 FragmentBaseDataRef mxBaseData; /// Base data of the fragment. 107 }; 108 109 // ============================================================================ 110 111 } // namespace core 112 } // namespace oox 113 114 #endif 115