1*f8e2c85aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e2c85aSAndrew Rist  * distributed with this work for additional information
6*f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e2c85aSAndrew Rist  *
11*f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e2c85aSAndrew Rist  *
13*f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15*f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18*f8e2c85aSAndrew Rist  * under the License.
19*f8e2c85aSAndrew Rist  *
20*f8e2c85aSAndrew Rist  *************************************************************/
21*f8e2c85aSAndrew Rist 
22*f8e2c85aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_shell.hxx"
26cdf0e10cSrcweir #include "internal/basereader.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef XML_PARSER_HXX_INCLUDED
29cdf0e10cSrcweir #include "internal/xml_parser.hxx"
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "assert.h"
33cdf0e10cSrcweir #include <memory>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /**  constructor of CBaseReader.
36cdf0e10cSrcweir */
CBaseReader(const std::string & DocumentName)37cdf0e10cSrcweir CBaseReader::CBaseReader(const std::string& DocumentName):
38cdf0e10cSrcweir m_ZipFile( DocumentName )
39cdf0e10cSrcweir {
40cdf0e10cSrcweir }
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //------------------------------
43cdf0e10cSrcweir //
44cdf0e10cSrcweir //------------------------------
45cdf0e10cSrcweir 
CBaseReader(void * sw,zlib_filefunc_def * fa)46cdf0e10cSrcweir CBaseReader::CBaseReader(void * sw, zlib_filefunc_def* fa):
47cdf0e10cSrcweir m_ZipFile( sw , fa )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //------------------------------
52cdf0e10cSrcweir //
53cdf0e10cSrcweir //------------------------------
54cdf0e10cSrcweir 
~CBaseReader()55cdf0e10cSrcweir CBaseReader::~CBaseReader()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //------------------------------
60cdf0e10cSrcweir //
61cdf0e10cSrcweir //------------------------------
62cdf0e10cSrcweir 
start_document()63cdf0e10cSrcweir void CBaseReader::start_document()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //------------------------------
68cdf0e10cSrcweir //
69cdf0e10cSrcweir //------------------------------
70cdf0e10cSrcweir 
end_document()71cdf0e10cSrcweir void CBaseReader::end_document()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir /** Read interested tag content into respective structure then start parsing process.
76cdf0e10cSrcweir     @param ContentName
77cdf0e10cSrcweir     the xml file name in the zipped document which we interest.
78cdf0e10cSrcweir */
Initialize(const std::string & ContentName)79cdf0e10cSrcweir void CBaseReader::Initialize( const std::string& ContentName)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	try
82cdf0e10cSrcweir 	{
83cdf0e10cSrcweir 		if (m_ZipContent.empty())
84cdf0e10cSrcweir 			m_ZipFile.GetUncompressedContent( ContentName, m_ZipContent );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 		xml_parser parser;
87cdf0e10cSrcweir 		parser.set_document_handler(this);  // pass current reader as reader to the sax parser
88cdf0e10cSrcweir 		parser.parse(&m_ZipContent[0], m_ZipContent.size());
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 	catch(std::exception&
91cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 0
92cdf0e10cSrcweir         ex
93cdf0e10cSrcweir     #endif
94cdf0e10cSrcweir         )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		ENSURE( false, ex.what() );
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 	catch(...)
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		ENSURE(false, "Unknown error");
101cdf0e10cSrcweir 	}
102cdf0e10cSrcweir }
103