LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/orcus/src/liborcus - gnumeric_handler.cpp (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 32 3.1 %
Date: 2012-12-17 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*************************************************************************
       2             :  *
       3             :  * Copyright (c) 2010-2012 Kohei Yoshida
       4             :  *
       5             :  * Permission is hereby granted, free of charge, to any person
       6             :  * obtaining a copy of this software and associated documentation
       7             :  * files (the "Software"), to deal in the Software without
       8             :  * restriction, including without limitation the rights to use,
       9             :  * copy, modify, merge, publish, distribute, sublicense, and/or sell
      10             :  * copies of the Software, and to permit persons to whom the
      11             :  * Software is furnished to do so, subject to the following
      12             :  * conditions:
      13             :  *
      14             :  * The above copyright notice and this permission notice shall be
      15             :  * included in all copies or substantial portions of the Software.
      16             :  *
      17             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      18             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      19             :  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      20             :  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      21             :  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      22             :  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      23             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      24             :  * OTHER DEALINGS IN THE SOFTWARE.
      25             :  *
      26             :  ************************************************************************/
      27             : 
      28             : #include "orcus/gnumeric/gnumeric_handler.hpp"
      29             : #include "orcus/gnumeric/gnumeric_context.hpp"
      30             : #include "orcus/exception.hpp"
      31             : 
      32             : #include <iostream>
      33             : 
      34             : using namespace std;
      35             : 
      36             : namespace orcus {
      37             : 
      38           0 : gnumeric_content_xml_handler::gnumeric_content_xml_handler(const tokens& tokens, spreadsheet::iface::import_factory* factory) :
      39           0 :     mp_factory(factory)
      40             : {
      41           0 :     m_context_stack.push_back(new gnumeric_content_xml_context(tokens, factory));
      42           0 : }
      43             : 
      44           0 : gnumeric_content_xml_handler::~gnumeric_content_xml_handler()
      45             : {
      46           0 : }
      47             : 
      48           0 : void gnumeric_content_xml_handler::start_document()
      49             : {
      50           0 : }
      51             : 
      52           0 : void gnumeric_content_xml_handler::end_document()
      53             : {
      54           0 : }
      55             : 
      56           0 : void gnumeric_content_xml_handler::start_element(const sax_token_parser_element& elem)
      57             : {
      58           0 :     xml_context_base& cur = get_current_context();
      59           0 :     if (!cur.can_handle_element(elem.ns, elem.name))
      60           0 :         m_context_stack.push_back(cur.create_child_context(elem.ns, elem.name));
      61             : 
      62           0 :     get_current_context().start_element(elem.ns, elem.name, elem.attrs);
      63           0 : }
      64             : 
      65           0 : void gnumeric_content_xml_handler::end_element(const sax_token_parser_element& elem)
      66             : {
      67           0 :     bool ended = get_current_context().end_element(elem.ns, elem.name);
      68             : 
      69           0 :     if (ended)
      70             :     {
      71           0 :         if (m_context_stack.size() > 1)
      72             :         {
      73             :             // Call end_child_context of the parent context to provide a way for
      74             :             // the two adjacent contexts to communicate with each other.
      75             :             context_stack_type::reverse_iterator itr_cur = m_context_stack.rbegin();
      76             :             context_stack_type::reverse_iterator itr_par = itr_cur + 1;
      77           0 :             itr_par->end_child_context(elem.ns, elem.name, &(*itr_cur));
      78             :         }
      79           0 :         m_context_stack.pop_back();
      80             :     }
      81           0 : }
      82             : 
      83           0 : void gnumeric_content_xml_handler::characters(const pstring& str)
      84             : {
      85           0 :     if (m_context_stack.empty())
      86           0 :         return;
      87             : 
      88           0 :     get_current_context().characters(str);
      89             : }
      90             : 
      91           0 : xml_context_base& gnumeric_content_xml_handler::get_current_context()
      92             : {
      93           0 :     if (m_context_stack.empty())
      94           0 :         throw general_error("context stack is empty");
      95             : 
      96           0 :     return m_context_stack.back();
      97             : }
      98             : 
      99          24 : }

Generated by: LCOV version 1.10