mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-04 20:28:22 +08:00
Modif done but tests not done (#851)
Co-authored-by: sandraros <sandra.rossi@gmail.com> Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
c24196bcd0
commit
de39aa842a
|
@ -158,6 +158,11 @@ CLASS zcl_excel_reader_2007 DEFINITION
|
|||
!ip_xml TYPE REF TO if_ixml_document
|
||||
RETURNING
|
||||
VALUE(ep_fills) TYPE t_fills .
|
||||
METHODS load_style_font
|
||||
IMPORTING
|
||||
!io_xml_element TYPE REF TO if_ixml_element
|
||||
RETURNING
|
||||
VALUE(ro_font) TYPE REF TO zcl_excel_style_font .
|
||||
METHODS load_style_fonts
|
||||
IMPORTING
|
||||
!ip_xml TYPE REF TO if_ixml_document
|
||||
|
@ -1481,36 +1486,14 @@ CLASS zcl_excel_reader_2007 IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD load_style_fonts.
|
||||
METHOD load_style_font.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #230 - Pimp my Code
|
||||
* - Stefan Schmoecker, (done) 2012-11-25
|
||||
* - ...
|
||||
* changes: renaming variables and types to naming conventions
|
||||
* aligning code
|
||||
* removing unused variables
|
||||
* adding comments to explain what we are trying to achieve
|
||||
*--------------------------------------------------------------------*
|
||||
DATA: lo_node_font TYPE REF TO if_ixml_element,
|
||||
lo_node2 TYPE REF TO if_ixml_element,
|
||||
lo_font TYPE REF TO zcl_excel_style_font,
|
||||
ls_color TYPE t_color.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* We need a table of used fonts to build up our styles
|
||||
|
||||
* Following is an example how this part of a file could be set up
|
||||
* <font>
|
||||
* <sz val="11"/>
|
||||
* <color theme="1"/>
|
||||
* <name val="Calibri"/>
|
||||
* <family val="2"/>
|
||||
* <scheme val="minor"/>
|
||||
* </font>
|
||||
*--------------------------------------------------------------------*
|
||||
lo_node_font ?= ip_xml->find_from_name( 'font' ).
|
||||
WHILE lo_node_font IS BOUND.
|
||||
lo_node_font = io_xml_element.
|
||||
|
||||
CREATE OBJECT lo_font.
|
||||
*--------------------------------------------------------------------*
|
||||
|
@ -1597,6 +1580,41 @@ CLASS zcl_excel_reader_2007 IMPLEMENTATION.
|
|||
lo_font->color-tint = ls_color-tint.
|
||||
ENDIF.
|
||||
|
||||
ro_font = lo_font.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD load_style_fonts.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #230 - Pimp my Code
|
||||
* - Stefan Schmoecker, (done) 2012-11-25
|
||||
* - ...
|
||||
* changes: renaming variables and types to naming conventions
|
||||
* aligning code
|
||||
* removing unused variables
|
||||
* adding comments to explain what we are trying to achieve
|
||||
*--------------------------------------------------------------------*
|
||||
DATA: lo_node_font TYPE REF TO if_ixml_element,
|
||||
lo_font TYPE REF TO zcl_excel_style_font.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* We need a table of used fonts to build up our styles
|
||||
|
||||
* Following is an example how this part of a file could be set up
|
||||
* <font>
|
||||
* <sz val="11"/>
|
||||
* <color theme="1"/>
|
||||
* <name val="Calibri"/>
|
||||
* <family val="2"/>
|
||||
* <scheme val="minor"/>
|
||||
* </font>
|
||||
*--------------------------------------------------------------------*
|
||||
lo_node_font ?= ip_xml->find_from_name( 'font' ).
|
||||
WHILE lo_node_font IS BOUND.
|
||||
|
||||
lo_font = load_style_font( lo_node_font ).
|
||||
INSERT lo_font INTO TABLE ep_fonts.
|
||||
|
||||
lo_node_font ?= lo_node_font->get_next( ).
|
||||
|
|
|
@ -139,6 +139,11 @@ CLASS zcl_excel_writer_2007 DEFINITION
|
|||
!io_parent TYPE REF TO if_ixml_element
|
||||
!iv_color_elem_name TYPE string DEFAULT 'color'
|
||||
!is_color TYPE zexcel_s_style_color .
|
||||
METHODS create_xl_styles_font_node
|
||||
IMPORTING
|
||||
!io_document TYPE REF TO if_ixml_document
|
||||
!io_parent TYPE REF TO if_ixml_element
|
||||
!is_font TYPE zexcel_s_style_font .
|
||||
METHODS create_xl_table
|
||||
IMPORTING
|
||||
!io_table TYPE REF TO zcl_excel_table
|
||||
|
@ -6085,15 +6090,7 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
|
|||
" font
|
||||
lc_xml_node_fonts TYPE string VALUE 'fonts',
|
||||
lc_xml_node_font TYPE string VALUE 'font',
|
||||
lc_xml_node_b TYPE string VALUE 'b', "bold
|
||||
lc_xml_node_i TYPE string VALUE 'i', "italic
|
||||
lc_xml_node_u TYPE string VALUE 'u', "underline
|
||||
lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough
|
||||
lc_xml_node_sz TYPE string VALUE 'sz',
|
||||
lc_xml_node_color TYPE string VALUE 'color',
|
||||
lc_xml_node_name TYPE string VALUE 'name',
|
||||
lc_xml_node_family TYPE string VALUE 'family',
|
||||
lc_xml_node_scheme TYPE string VALUE 'scheme',
|
||||
" fill
|
||||
lc_xml_node_fills TYPE string VALUE 'fills',
|
||||
lc_xml_node_fill TYPE string VALUE 'fill',
|
||||
|
@ -6425,69 +6422,9 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
|
|||
LOOP AT lt_fonts INTO ls_font.
|
||||
lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font
|
||||
parent = lo_document ).
|
||||
IF ls_font-bold EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-italic EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-underline EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-underline_mode.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-strikethrough EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
"size
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-size.
|
||||
SHIFT lv_value RIGHT DELETING TRAILING space.
|
||||
SHIFT lv_value LEFT DELETING LEADING space.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"color
|
||||
create_xl_styles_color_node(
|
||||
io_document = lo_document
|
||||
io_parent = lo_element_font
|
||||
is_color = ls_font-color ).
|
||||
|
||||
"name
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-name.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"family
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-family.
|
||||
SHIFT lv_value RIGHT DELETING TRAILING space.
|
||||
SHIFT lv_value LEFT DELETING LEADING space.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"scheme
|
||||
IF ls_font-scheme IS NOT INITIAL.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-scheme.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
create_xl_styles_font_node( io_document = lo_document
|
||||
io_parent = lo_element_font
|
||||
is_font = ls_font ).
|
||||
lo_element_fonts->append_child( new_child = lo_element_font ).
|
||||
ENDLOOP.
|
||||
|
||||
|
@ -7092,6 +7029,95 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD create_xl_styles_font_node.
|
||||
|
||||
CONSTANTS: lc_xml_node_b TYPE string VALUE 'b', "bold
|
||||
lc_xml_node_i TYPE string VALUE 'i', "italic
|
||||
lc_xml_node_u TYPE string VALUE 'u', "underline
|
||||
lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough
|
||||
lc_xml_node_sz TYPE string VALUE 'sz',
|
||||
lc_xml_node_name TYPE string VALUE 'name',
|
||||
lc_xml_node_family TYPE string VALUE 'family',
|
||||
lc_xml_node_scheme TYPE string VALUE 'scheme',
|
||||
lc_xml_attr_val TYPE string VALUE 'val'.
|
||||
|
||||
DATA: lo_document TYPE REF TO if_ixml_document,
|
||||
lo_element_font TYPE REF TO if_ixml_element,
|
||||
ls_font TYPE zexcel_s_style_font,
|
||||
lo_sub_element TYPE REF TO if_ixml_element,
|
||||
lv_value TYPE string.
|
||||
|
||||
lo_document = io_document.
|
||||
lo_element_font = io_parent.
|
||||
ls_font = is_font.
|
||||
|
||||
IF ls_font-bold EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-italic EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-underline EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-underline_mode.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
IF ls_font-strikethrough EQ abap_true.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike
|
||||
parent = lo_document ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
"size
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-size.
|
||||
SHIFT lv_value RIGHT DELETING TRAILING space.
|
||||
SHIFT lv_value LEFT DELETING LEADING space.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"color
|
||||
create_xl_styles_color_node(
|
||||
io_document = lo_document
|
||||
io_parent = lo_element_font
|
||||
is_color = ls_font-color ).
|
||||
|
||||
"name
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-name.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"family
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-family.
|
||||
SHIFT lv_value RIGHT DELETING TRAILING space.
|
||||
SHIFT lv_value LEFT DELETING LEADING space.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
"scheme
|
||||
IF ls_font-scheme IS NOT INITIAL.
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme
|
||||
parent = lo_document ).
|
||||
lv_value = ls_font-scheme.
|
||||
lo_sub_element->set_attribute_ns( name = lc_xml_attr_val
|
||||
value = lv_value ).
|
||||
lo_element_font->append_child( new_child = lo_sub_element ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD create_xl_table.
|
||||
|
||||
DATA: lc_xml_node_table TYPE string VALUE 'table',
|
||||
|
|
Loading…
Reference in New Issue
Block a user