xref: /trunk/main/oox/inc/oox/core/recordparser.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
getInputSource() const61     inline const RecordInputSource& getInputSource() const { return maSource; }
62 
63 private:
64     /** Returns a RecordInfo struct that contains the passed record identifier
65         as context start identifier. */
66     const RecordInfo*   getStartRecordInfo( sal_Int32 nRecId ) const;
67     /** Returns a RecordInfo struct that contains the passed record identifier
68         as context end identifier. */
69     const RecordInfo*   getEndRecordInfo( sal_Int32 nRecId ) const;
70 
71 private:
72     typedef ::std::map< sal_Int32, RecordInfo > RecordInfoMap;
73 
74     RecordInputSource   maSource;
75     ::rtl::Reference< FragmentHandler > mxHandler;
76     ::rtl::Reference< prv::Locator > mxLocator;
77     ::std::auto_ptr< prv::ContextStack > mxStack;
78     RecordInfoMap       maStartMap;
79     RecordInfoMap       maEndMap;
80 };
81 
82 // ============================================================================
83 
84 } // namespace core
85 } // namespace oox
86 
87 #endif
88