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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_shell.hxx" 26 #include "internal/basereader.hxx" 27 28 #ifndef XML_PARSER_HXX_INCLUDED 29 #include "internal/xml_parser.hxx" 30 #endif 31 32 #include "assert.h" 33 #include <memory> 34 35 /** constructor of CBaseReader. 36 */ 37 CBaseReader::CBaseReader(const std::string& DocumentName): 38 m_ZipFile( DocumentName ) 39 { 40 } 41 42 //------------------------------ 43 // 44 //------------------------------ 45 46 CBaseReader::CBaseReader(void * sw, zlib_filefunc_def* fa): 47 m_ZipFile( sw , fa ) 48 { 49 } 50 51 //------------------------------ 52 // 53 //------------------------------ 54 55 CBaseReader::~CBaseReader() 56 { 57 } 58 59 //------------------------------ 60 // 61 //------------------------------ 62 63 void CBaseReader::start_document() 64 { 65 } 66 67 //------------------------------ 68 // 69 //------------------------------ 70 71 void CBaseReader::end_document() 72 { 73 } 74 75 /** Read interested tag content into respective structure then start parsing process. 76 @param ContentName 77 the xml file name in the zipped document which we interest. 78 */ 79 void CBaseReader::Initialize( const std::string& ContentName) 80 { 81 try 82 { 83 if (m_ZipContent.empty()) 84 m_ZipFile.GetUncompressedContent( ContentName, m_ZipContent ); 85 86 xml_parser parser; 87 parser.set_document_handler(this); // pass current reader as reader to the sax parser 88 parser.parse(&m_ZipContent[0], m_ZipContent.size()); 89 } 90 catch(std::exception& 91 #if OSL_DEBUG_LEVEL > 0 92 ex 93 #endif 94 ) 95 { 96 ENSURE( false, ex.what() ); 97 } 98 catch(...) 99 { 100 ENSURE(false, "Unknown error"); 101 } 102 } 103