コード例 #1
0
void xlsx_workbook_context::start_element(xmlns_id_t ns, xml_token_t name, const xml_attrs_t& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    switch (name)
    {
        case XML_workbook:
        {
            xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
            print_attrs(get_tokens(), attrs);
        }
        break;
        case XML_sheets:
            xml_element_expected(parent, NS_ooxml_xlsx, XML_workbook);
        break;
        case XML_sheet:
        {
            xml_element_expected(parent, NS_ooxml_xlsx, XML_sheets);
            workbook_sheet_attr_parser func(&get_session_context());
            func = for_each(attrs.begin(), attrs.end(), func);
            m_sheets.push_back(new xlsx_rel_sheet_info(func.get_sheet()));
            const xlsx_rel_sheet_info& info = m_sheets.back();
            m_sheet_info.insert(
                opc_rel_extras_t::value_type(func.get_rid(), &info));
        }
        break;
        default:
            warn_unhandled();
    }
}
コード例 #2
0
void text_para_context::start_element(xmlns_id_t ns, xml_token_t name, const xml_attrs_t& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    if (ns == NS_odf_text)
    {
        switch (name)
        {
            case XML_p:
                // paragraph
                xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
            break;
            case XML_span:
            {
                // text span.
                xml_element_expected(parent, NS_odf_text, XML_p);
                flush_segment();
                pstring style_name =
                    for_each(attrs.begin(), attrs.end(), single_attr_getter(m_pool, NS_odf_text, XML_style_name)).get_value();
                m_span_stack.push_back(style_name);

            }
            break;
            case XML_s:
                // control character.  ignored for now.
            break;
            default:
                warn_unhandled();
        }
    }
    else
        warn_unhandled();
}
コード例 #3
0
ファイル: xlsx_revision_context.cpp プロジェクト: jvsg/orcus
void xlsx_revheaders_context::start_element(xmlns_id_t ns, xml_token_t name, const vector<xml_token_attr_t>& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    if (ns == NS_ooxml_xlsx)
    {
        switch (name)
        {
            case XML_headers:
            {
                xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
                headers_attr_parser func;
                func = for_each(attrs.begin(), attrs.end(), func);
                cout << "* last guid: " << func.get_last_guid() << endl;
                cout << "* highest revision ID: " << func.get_highest_revid() << endl;
                cout << "* version: " << func.get_version() << endl;
                cout << "* disk revisions: " << func.is_disk_revisions() << endl;
            }
            break;
            case XML_header:
            {
                xml_element_expected(parent, NS_ooxml_xlsx, XML_headers);
                header_attr_parser func(get_session_context().m_string_pool);
                func = for_each(attrs.begin(), attrs.end(), func);
                cout << "* revision header (guid:" << func.get_guid() << ")" << endl;
                cout << "  - timestamp: " << func.get_date_time().to_string() << endl;
                cout << "  - user name: " << func.get_username() << endl;

                if (func.get_min_revid() != -1 && func.get_max_revid() != -1)
                    cout << "  - revision range: " << func.get_min_revid() << "-" << func.get_max_revid() << endl;

                long next_sheet = func.get_next_sheet_id();
                if (next_sheet != -1)
                    cout << "  - next available sheet: " << (next_sheet - 1) << endl;

                cout << "  - revision log rid: " << func.get_rid() << endl;
                // TODO : Intern the rid here when passing it to the revision log stream.
            }
            break;
            case XML_sheetIdMap:
            {
                xml_element_expected(parent, NS_ooxml_xlsx, XML_header);
                m_cur_sheet_ids.clear();
                long n = single_long_attr_getter::get(attrs, NS_ooxml_xlsx, XML_count);
                if (n > 0)
                    m_cur_sheet_ids.reserve(n);
            }
            break;
            case XML_sheetId:
            {
                xml_element_expected(parent, NS_ooxml_xlsx, XML_sheetIdMap);
                long val = single_long_attr_getter::get(attrs, NS_ooxml_xlsx, XML_val);
                if (val > 0)
                    m_cur_sheet_ids.push_back(val-1); // convert from 1-based to 0-based.
            }
            break;
            default:
                warn_unhandled();
        }
    }
}
コード例 #4
0
ファイル: opc_context.cpp プロジェクト: CarterWeron/liborcus
void opc_relations_context::start_element(xmlns_id_t ns, xml_token_t name, const vector<xml_token_attr_t> &attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    switch (name)
    {
        case XML_Relationships:
        {
            xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
            print_attrs(get_tokens(), attrs);
        }
        break;
        case XML_Relationship:
        {
            rel_attr_parser func(&get_session_context(), &m_schema_cache);
            xml_element_expected(parent, NS_opc_rel, XML_Relationships);
            func = for_each(attrs.begin(), attrs.end(), func);
            const opc_rel_t& rel = func.get_rel();
            if (rel.type)
                m_rels.push_back(rel);
        }
        break;
        default:
            warn_unhandled();
    }
}
コード例 #5
0
ファイル: xls_xml_context.cpp プロジェクト: jvsg/orcus
void xls_xml_context::start_element(xmlns_id_t ns, xml_token_t name, const xml_attrs_t& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    if (ns == NS_xls_xml_ss)
    {
        switch (name)
        {
            case XML_Workbook:
                // Do nothing.
            break;
            case XML_Worksheet:
            {
                xml_element_expected(parent, NS_xls_xml_ss, XML_Workbook);
                pstring sheet_name = for_each(attrs.begin(), attrs.end(), sheet_attr_parser()).get_name();
                mp_cur_sheet = mp_factory->append_sheet(sheet_name.get(), sheet_name.size());
                m_cur_row = 0;
                m_cur_col = 0;
            }
            break;
            case XML_Table:
                xml_element_expected(parent, NS_xls_xml_ss, XML_Worksheet);
            break;
            case XML_Row:
            {
                xml_element_expected(parent, NS_xls_xml_ss, XML_Table);
                m_cur_col = 0;
                long row_index = for_each(attrs.begin(), attrs.end(), row_attr_parser()).get_row_index();
                if (row_index > 0)
                {
                    // 1-based row index. Convert it to a 0-based one.
                    m_cur_row = row_index - 1;
                }
            }
            break;
            case XML_Cell:
            {
                xml_element_expected(parent, NS_xls_xml_ss, XML_Row);
                long col_index = for_each(attrs.begin(), attrs.end(), cell_attr_parser()).get_col_index();
                if (col_index > 0)
                {
                    // 1-based column index. Convert it to a 0-based one.
                    m_cur_col = col_index - 1;
                }
            }
            break;
            case XML_Data:
                xml_element_expected(parent, NS_xls_xml_ss, XML_Cell);
                m_cur_cell_type = for_each(attrs.begin(), attrs.end(), data_attr_parser()).get_cell_type();
                m_cur_cell_string.clear();
            break;
            default:
                warn_unhandled();
        }
    }
    else
        warn_unhandled();
}
コード例 #6
0
ファイル: opc_context.cpp プロジェクト: CarterWeron/liborcus
void opc_content_types_context::start_element(xmlns_id_t ns, xml_token_t name, const::std::vector<xml_token_attr_t> &attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);
    switch (name)
    {
        case XML_Types:
        {
            xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);

            print_attrs(get_tokens(), attrs);
        }
        break;
        case XML_Override:
        {
            xml_element_expected(parent, NS_opc_ct, XML_Types);
            part_ext_attr_parser func(&m_ct_cache, XML_PartName);
            func = for_each(attrs.begin(), attrs.end(), func);

            // We need to use allocated strings for part names here because
            // the part names need to survive after the [Content_Types].xml
            // stream is destroyed.
            pstring part_name = get_session_context().m_string_pool.intern(func.get_name()).first;
            m_parts.push_back(
                xml_part_t(part_name, func.get_content_type()));
        }
        break;
        case XML_Default:
        {
            xml_element_expected(parent, NS_opc_ct, XML_Types);
            part_ext_attr_parser func(&m_ct_cache, XML_Extension);
            func = for_each(attrs.begin(), attrs.end(), func);

            // Like the part names, we need to use allocated strings for
            // extension names.
            pstring ext_name = get_session_context().m_string_pool.intern(func.get_name()).first;
            m_ext_defaults.push_back(
                xml_part_t(ext_name, func.get_content_type()));
        }
        break;
        default:
            warn_unhandled();
    }
}
コード例 #7
0
ファイル: xlsx_revision_context.cpp プロジェクト: jvsg/orcus
void xlsx_revlog_context::start_element(xmlns_id_t ns, xml_token_t name, const vector<xml_token_attr_t>& attrs)
{
    xml_token_pair_t parent = push_stack(ns, name);

    if (ns == NS_ooxml_xlsx)
    {
        switch (name)
        {
            case XML_revisions:
                xml_element_expected(parent, XMLNS_UNKNOWN_ID, XML_UNKNOWN_TOKEN);
            break;
            case XML_raf:
                // revision auto format
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rcc:
            {
                // revision cell change
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
                rcc_attr_parser func;
                func = for_each(attrs.begin(), attrs.end(), func);
                cout << "* revision id: " << func.get_revision_id() << "  type: cell change" << endl;
                cout << "  - sheet index: " << func.get_sheet_id() << endl;
                m_cur_cell_type = xlsx_ct_unknown;
            }
            break;
            case XML_rcft:
                // revision merge conflict
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rcmt:
                // revision cell comment
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rcv:
                // revision custom view
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rdn:
                // revision defined name
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rfmt:
                // revision format
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_ris:
                // revision insert sheet
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rm:
                // revision cell move
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rqt:
                // revision query table
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_rrc:
            {
                // revision row column insert delete
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
                rrc_attr_parser func;
                func = for_each(attrs.begin(), attrs.end(), func);
                cout << "* revision id: " << func.get_revision_id() << "  type: row column insert delete" << endl;
                cout << "  - sheet index: " << func.get_sheet_id() << endl;
                cout << "  - action type: " << to_string(func.get_action_type()) << endl;
                cout << "  - range: " << func.get_ref() << endl;
                cout << "  - end of list: " << (func.is_end_of_list() ? "true":"false") << endl;
            }
            break;
            case XML_rsnm:
                // revision sheet name
                xml_element_expected(parent, NS_ooxml_xlsx, XML_revisions);
            break;
            case XML_oc:
                // old cell data
                xml_element_expected(parent, NS_ooxml_xlsx, XML_rcc);
            break;
            case XML_nc:
            {
                // new cell data
                xml_element_expected(parent, NS_ooxml_xlsx, XML_rcc);
                cell_data_attr_parser func;
                func = for_each(attrs.begin(), attrs.end(), func);
                m_cur_cell_type = func.get_cell_type();

                m_cur_formula = false;
                m_cur_value = 0.0;
                m_cur_string.clear();

                cout << "  - new cell position: " << func.get_ref() << endl;
                cout << "  - new cell type: " << to_string(m_cur_cell_type) << endl;
            }
            break;
            case XML_f:
            {
                xml_elem_stack_t elems;
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_oc));
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_nc));
                xml_element_expected(parent, elems);
            }
            break;
            case XML_v:
            {
                xml_elem_stack_t elems;
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_oc));
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_nc));
                xml_element_expected(parent, elems);
            }
            break;
            case XML_is:
            {
                xml_elem_stack_t elems;
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_oc));
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_nc));
                xml_element_expected(parent, elems);
            }
            break;
            case XML_t:
            {
                xml_elem_stack_t elems;
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_is));
                elems.push_back(xml_token_pair_t(NS_ooxml_xlsx, XML_r));
                xml_element_expected(parent, elems);
            }
            break;
            default:
                warn_unhandled();
        }
    }
}