From 23858bdf0398f89cc81369071c6981696caf4040 Mon Sep 17 00:00:00 2001 From: Hannes Rempel Date: Wed, 29 Oct 2014 13:30:48 +0100 Subject: [PATCH] backwards compatibility --- ZA2X/CLAS/ZCL_EXCEL_READER_HUGE_FILE.slnk | 55 +++++++++++++++-------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_HUGE_FILE.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_HUGE_FILE.slnk index dd1dab6..bfe1205 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_HUGE_FILE.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_HUGE_FILE.slnk @@ -184,8 +184,8 @@ class lcl_test implementation. append `` to out->shared_strings. append `t` to out->shared_strings. lo_reader = get_reader( - `<c r="A1" t="s"><v>0</v></c>` && - `<c r="A2" t="inlineStr"><is><t></t></is></c>` && + `<c r="A1" t="s"><v>0</v></c>` & + `<c r="A2" t="inlineStr"><is><t></t></is></c>` & `<c r="A3" t="s"><v>1</v></c>` ). @@ -239,12 +239,16 @@ class lcl_test implementation. * method test_read_shared_strings. - data: lo_reader type ref to if_sxml_reader, + data: lo_c2x type ref to cl_abap_conv_out_ce, + lv_xstring type xstring, + lo_reader type ref to if_sxml_reader, lt_act type stringtab, lt_exp type stringtab. - lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( - `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>` - ) ). + + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( exporting data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>` + importing buffer = lv_xstring ). + lo_reader = cl_sxml_string_reader=>create( lv_xstring ). append : `` to lt_exp, `Alpha` to lt_exp, @@ -259,13 +263,16 @@ class lcl_test implementation. * method test_skip_to_inexistent. - data: lo_reader type ref to if_sxml_reader, + data: lo_c2x type ref to cl_abap_conv_out_ce, + lv_xstring type xstring, + lo_reader type ref to if_sxml_reader, lo_ex type ref to lcx_not_found, lv_text type string. - lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( - `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>` - ) ). + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( exporting data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>` + importing buffer = lv_xstring ). + lo_reader = cl_sxml_string_reader=>create( lv_xstring ). try. out->skip_to( iv_element_name = `nonExistingElement` io_reader = lo_reader ). fail(`Skipping to non-existing element must raise lcx_not_found exception`). @@ -276,9 +283,14 @@ class lcl_test implementation. * method get_reader. - data: lv_full type string. + data: lv_full type string, + lo_c2x type ref to cl_abap_conv_out_ce, + lv_xstring type xstring. concatenate `<root><sheetData><row>` iv_xml `</row></sheetData></root>` into lv_full. - eo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( lv_full ) ). + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( exporting data = lv_full + importing buffer = lv_xstring ). + eo_reader = cl_sxml_string_reader=>create( lv_xstring ). endmethod. "get_reader * method assert_value_equals. @@ -411,13 +423,15 @@ endmethod. method GET_SHARED_STRING. - data: lv_tabix type i. + data: lv_tabix type i, + lv_error type string. lv_tabix = iv_index + 1. read table shared_strings into ev_value index lv_tabix. if sy-subrc ne 0. + concatenate 'Entry ' iv_index ' not found in Shared String Table' into lv_error. raise exception type lcx_not_found exporting - error = |Entry { iv_index } not found in Shared String Table|. + error = lv_error. endif. endmethod. @@ -428,15 +442,17 @@ endmethod. method GET_STYLE. data: lv_tabix type i, - lo_style type ref to zcl_excel_style. + lo_style type ref to zcl_excel_style, + lv_error type string. if gs_buffer_style-index ne iv_index. lv_tabix = iv_index + 1. read table styles into lo_style index lv_tabix. if sy-subrc ne 0. + concatenate 'Entry ' iv_index ' not found in Style Table' into lv_error. raise exception type lcx_not_found exporting - error = |Entry { iv_index } not found in Style Table|. + error = lv_error. else. gs_buffer_style-index = iv_index. gs_buffer_style-guid = lo_style->get_guid( ). @@ -565,18 +581,21 @@ endmethod. method SKIP_TO. + data: lv_error type string. + * Skip forward to given element while io_reader->name ne iv_element_name or io_reader->node_type ne c_element_open. io_reader->next_node( ). if io_reader->node_type = c_end_of_stream. + concatenate 'XML error: Didn''t find element <' iv_element_name '>' into lv_error. raise exception type lcx_not_found exporting - error = |XML error: Didn't find element <{ iv_element_name }>|. + error = lv_error. endif. endwhile. endmethod. - + \ No newline at end of file