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_RECORDPARSER_HXX 25 #define OOX_CORE_RECORDPARSER_HXX 26 27 #include <map> 28 #include <com/sun/star/io/IOException.hpp> 29 #include <com/sun/star/xml/sax/SAXException.hpp> 30 #include <rtl/ref.hxx> 31 #include "oox/helper/binaryinputstream.hxx" 32 #include "oox/core/fragmenthandler.hxx" 33 34 namespace oox { 35 namespace core { 36 37 namespace prv { class Locator; } 38 namespace prv { class ContextStack; } 39 40 // ============================================================================ 41 42 struct RecordInputSource 43 { 44 BinaryInputStreamRef mxInStream; 45 ::rtl::OUString maPublicId; 46 ::rtl::OUString maSystemId; 47 }; 48 49 // ============================================================================ 50 51 class RecordParser 52 { 53 public: 54 explicit RecordParser(); 55 virtual ~RecordParser(); 56 57 void setFragmentHandler( const ::rtl::Reference< FragmentHandler >& rxHandler ); 58 59 void parseStream( const RecordInputSource& rInputSource ) 60 throw( ::com::sun::star::xml::sax::SAXException, 61 ::com::sun::star::io::IOException, 62 ::com::sun::star::uno::RuntimeException ); 63 getInputSource() const64 inline const RecordInputSource& getInputSource() const { return maSource; } 65 66 private: 67 /** Returns a RecordInfo struct that contains the passed record identifier 68 as context start identifier. */ 69 const RecordInfo* getStartRecordInfo( sal_Int32 nRecId ) const; 70 /** Returns a RecordInfo struct that contains the passed record identifier 71 as context end identifier. */ 72 const RecordInfo* getEndRecordInfo( sal_Int32 nRecId ) const; 73 74 private: 75 typedef ::std::map< sal_Int32, RecordInfo > RecordInfoMap; 76 77 RecordInputSource maSource; 78 ::rtl::Reference< FragmentHandler > mxHandler; 79 ::rtl::Reference< prv::Locator > mxLocator; 80 ::std::auto_ptr< prv::ContextStack > mxStack; 81 RecordInfoMap maStartMap; 82 RecordInfoMap maEndMap; 83 }; 84 85 // ============================================================================ 86 87 } // namespace core 88 } // namespace oox 89 90 #endif 91