From 57dc5ef6ddf2d6e4c153d2d984dbcf983b5c4a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schm=C3=B6cker?= Date: Tue, 2 Oct 2012 23:18:19 +0000 Subject: [PATCH] Ready to test bugfixes for issues #180 and #212 git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@336 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk | 206 ++++++++++++++++----------- 1 file changed, 121 insertions(+), 85 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk index 3a38168..436bde3 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -1,12 +1,13 @@ - - - + + + - - - - - - - - - - - - - - - + class ZCL_EXCEL_READER_2007 definition public create public . @@ -164,6 +165,7 @@ protected section. methods GET_IXML_FROM_ZIP_ARCHIVE importing !I_FILENAME type STRING + !IS_NORMALIZING type BOOLEAN default 'X' returning value(R_IXML) type ref to IF_IXML_DOCUMENT raising @@ -245,15 +247,15 @@ protected section. *"* in the implementation part of the class IXML - - - - + + + + - METHOD zif_excel_reader~can_read_file. + method ZIF_EXCEL_READER~CAN_READ_FILE. * For now always Unknown r_readable = abap_undefined. -ENDMETHOD. +endmethod. method ZIF_EXCEL_READER~LOAD. @@ -357,9 +359,9 @@ endmethod. r_excel = me->zif_excel_reader~load( excel_data ). endmethod. - - - + + + method FILL_STRUCT_FROM_ATTRIBUTES. DATA: name TYPE string, attributes TYPE REF TO if_ixml_named_node_map, @@ -384,10 +386,10 @@ endmethod. ENDWHILE. endmethod. - - - - + + + + method GET_FROM_ZIP_ARCHIVE. IF me->zip IS NOT BOUND. @@ -424,10 +426,11 @@ endmethod. endmethod. - - - - + + + + + method GET_IXML_FROM_ZIP_ARCHIVE. TYPE-POOLS: ixml. @@ -446,16 +449,17 @@ endmethod. parser = ixml->create_parser( stream_factory = streamfactory istream = istream document = r_ixml ). - parser->set_normalizing( ). +* parser->set_normalizing( ). + parser->set_normalizing( is_normalizing ). parser->set_validating( mode = if_ixml_parser=>co_no_validation ). parser->parse( ). endmethod. - - - - + + + + method LOAD_DRAWING_ANCHOR. TYPES: BEGIN OF t_c_nv_pr, @@ -599,37 +603,69 @@ endmethod. endmethod. - - - - method LOAD_SHARED_STRINGS. - DATA: value TYPE string, - shared_strings_xml TYPE REF TO if_ixml_document, - tag_name TYPE string, - node TYPE REF TO if_ixml_element, - node2 TYPE REF TO if_ixml_element. + + + + METHOD load_shared_strings. + DATA: value TYPE string, + value2 TYPE string, + shared_strings_xml TYPE REF TO if_ixml_document, + tag_name TYPE string, + node TYPE REF TO if_ixml_element, + node2 TYPE REF TO if_ixml_element, + node3 TYPE REF TO if_ixml_element. - shared_strings_xml = me->get_ixml_from_zip_archive( ip_path ). +*** Basic structure of Shared strings +*** Some lines insignificant for us to read +*** <si>(Stringinfo)</si> +*** So far I have seen 2 versions how (Stringinfo) can be displayed +*** a) "simple" strings: <t>string</t> +*** b) rich text string: (<r>richtextstring</r>)+ " String split up into parts that are of equal formatting +*** richtextstring: can be +*** b1) <t xml:space="preserve">string</t> +*** or b2) <rPr>someformattinginfo</rPr><t xml:space="preserve">string</t> + + + + shared_strings_xml = me->get_ixml_from_zip_archive( i_filename = ip_path + is_normalizing = space ). " NO!!! normalizing - otherwise leading blanks will be omitted and that is not really desired for the stringtable node ?= shared_strings_xml->find_from_name( 'si' ). WHILE node IS BOUND. node2 ?= node->get_first_child( ). tag_name = node2->get_name( ). - IF tag_name = 't'. + IF tag_name = 't'. " a - "simple" string value = node2->get_value( ). APPEND value TO shared_strings. - ELSEIF tag_name = 'r'. - " TODO pharse Ritch text + ELSEIF tag_name = 'r'. " b - rich text string + " TODO parse rich text +* Still no support for rich text strings - but at least we should try to extract the stringinfo from this passage +* and !!! APPEND it to shared strings - otherwise the stringtable might get jumbled + CLEAR value. + WHILE node2 IS BOUND. " Walk through b) + node3 ?= node2->get_first_child( ). + WHILE node3 IS BOUND. + tag_name = node3->get_name( ). + IF tag_name = 't'. " this is sufficient to get hold of b1 and b2 + value2 = node3->get_value( ). + CONCATENATE value value2 INTO value RESPECTING BLANKS. " Build resulting string from all partial (formatted) strings + ENDIF. + node3 ?= node3->get_next( ). + ENDWHILE. + node2 ?= node2->get_next( ). + ENDWHILE. + APPEND value TO shared_strings. + ENDIF. node ?= node->get_next( ). ENDWHILE. -endmethod. +ENDMETHOD. - - - - + + + + method LOAD_STYLES. TYPES: BEGIN OF t_xf, applyalignment TYPE string, @@ -798,9 +834,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_BORDERS. DATA: node TYPE REF TO if_ixml_element, node2 TYPE REF TO if_ixml_element, @@ -870,9 +906,9 @@ endmethod. ENDWHILE. endmethod. - - - + + + method LOAD_STYLE_FILLS. DATA: value TYPE string, node TYPE REF TO if_ixml_element, @@ -939,9 +975,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_FONTS. DATA: value TYPE string, node TYPE REF TO if_ixml_element, @@ -1017,9 +1053,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_NUM_FORMATS. DATA: node TYPE REF TO if_ixml_element, num_format TYPE t_num_format. @@ -1076,10 +1112,10 @@ endmethod. endmethod. - - - - + + + + method LOAD_WORKBOOK. CONSTANTS: lc_shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', @@ -1203,10 +1239,10 @@ endmethod. endmethod. - - - - + + + + method LOAD_WORKSHEET. TYPES: BEGIN OF t_cell, r TYPE string, @@ -1576,10 +1612,10 @@ endmethod. endmethod. - - - - + + + + method LOAD_WORKSHEET_DRAWING. TYPES: BEGIN OF t_c_nv_pr, @@ -1687,9 +1723,9 @@ endmethod. endmethod. - - - + + + method RESOLVE_PATH. DATA: lt_segments TYPE TABLE OF string,