2 get methods instead of 1 + minor changes

This commit is contained in:
sandraros 2024-05-04 09:08:09 +00:00
parent dd2f957007
commit 8a4add3486
2 changed files with 57 additions and 69 deletions

View File

@ -9,15 +9,21 @@ CLASS zcl_excel_comment DEFINITION
CONSTANTS default_bottom_row TYPE i VALUE 15. "#EC NOTEXT CONSTANTS default_bottom_row TYPE i VALUE 15. "#EC NOTEXT
METHODS constructor . METHODS constructor .
METHODS get_name METHODS get_bottom_row
RETURNING RETURNING
VALUE(r_name) TYPE string . VALUE(rp_result) TYPE i .
METHODS get_index METHODS get_index
RETURNING RETURNING
VALUE(rp_index) TYPE string . VALUE(rp_index) TYPE string .
METHODS get_name
RETURNING
VALUE(r_name) TYPE string .
METHODS get_ref METHODS get_ref
RETURNING RETURNING
VALUE(rp_ref) TYPE string . VALUE(rp_ref) TYPE string .
METHODS get_right_column
RETURNING
VALUE(rp_result) TYPE i .
METHODS get_text METHODS get_text
RETURNING RETURNING
VALUE(rp_text) TYPE string . VALUE(rp_text) TYPE string .
@ -27,19 +33,15 @@ CLASS zcl_excel_comment DEFINITION
!ip_ref TYPE string OPTIONAL !ip_ref TYPE string OPTIONAL
!ip_right_column TYPE i OPTIONAL !ip_right_column TYPE i OPTIONAL
!ip_bottom_row TYPE i OPTIONAL . !ip_bottom_row TYPE i OPTIONAL .
METHODS get_position
EXPORTING
!ep_right_column TYPE i
!ep_bottom_row TYPE i .
PROTECTED SECTION. PROTECTED SECTION.
PRIVATE SECTION. PRIVATE SECTION.
DATA bottom_row TYPE i .
DATA index TYPE string . DATA index TYPE string .
DATA ref TYPE string . DATA ref TYPE string .
DATA text TYPE string .
DATA right_column TYPE i . DATA right_column TYPE i .
DATA bottom_row TYPE i . DATA text TYPE string .
ENDCLASS. ENDCLASS.
@ -52,6 +54,11 @@ CLASS zcl_excel_comment IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
METHOD get_bottom_row.
rp_result = bottom_row.
ENDMETHOD.
METHOD get_index. METHOD get_index.
rp_index = me->index. rp_index = me->index.
ENDMETHOD. ENDMETHOD.
@ -67,6 +74,11 @@ CLASS zcl_excel_comment IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
METHOD get_right_column.
rp_result = right_column.
ENDMETHOD.
METHOD get_text. METHOD get_text.
rp_text = me->text. rp_text = me->text.
ENDMETHOD. ENDMETHOD.
@ -79,30 +91,17 @@ CLASS zcl_excel_comment IMPLEMENTATION.
me->ref = ip_ref. me->ref = ip_ref.
ENDIF. ENDIF.
IF ip_right_column IS SUPPLIED. IF ip_right_column IS NOT INITIAL.
me->right_column = ip_right_column. me->right_column = ip_right_column.
ELSE.
me->right_column = default_right_column.
ENDIF. ENDIF.
IF ip_bottom_row IS SUPPLIED. IF ip_bottom_row IS NOT INITIAL.
me->bottom_row = ip_bottom_row. me->bottom_row = ip_bottom_row.
ELSE.
me->bottom_row = default_bottom_row.
ENDIF. ENDIF.
ENDMETHOD. ENDMETHOD.
METHOD get_position.
IF right_column IS NOT INITIAL.
ep_right_column = right_column.
ELSE.
ep_right_column = default_right_column. "Default right_column
ENDIF.
IF bottom_row IS NOT INITIAL.
ep_bottom_row = bottom_row.
ELSE.
ep_bottom_row = default_bottom_row. "Default bottom_row
ENDIF.
ENDMETHOD.
ENDCLASS. ENDCLASS.

View File

@ -3139,6 +3139,7 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
lc_xml_attr_val_none TYPE string VALUE 'none', lc_xml_attr_val_none TYPE string VALUE 'none',
lc_xml_attr_val_msodir TYPE string VALUE 'mso-direction-alt:auto', lc_xml_attr_val_msodir TYPE string VALUE 'mso-direction-alt:auto',
lc_xml_attr_val_note TYPE string VALUE 'Note'. lc_xml_attr_val_note TYPE string VALUE 'Note'.
CONSTANTS lc_anchor_init TYPE string VALUE '2, 15, 11, 10, &right_column&, 31, &bottom_row&, 9'.
DATA: lo_document TYPE REF TO if_ixml_document, DATA: lo_document TYPE REF TO if_ixml_document,
@ -3175,6 +3176,11 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
lv_int_value TYPE i, lv_int_value TYPE i,
lv_int_value_string TYPE string. lv_int_value_string TYPE string.
DATA: lv_rel_id TYPE i. DATA: lv_rel_id TYPE i.
DATA lv_anchor TYPE string.
DATA lv_bottom_row TYPE i.
DATA lv_right_column TYPE i.
DATA lv_bottom_row_str TYPE string.
DATA lv_right_column_str TYPE string.
********************************************************************** **********************************************************************
@ -3298,42 +3304,25 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
lo_element_anchor = lo_document->create_simple_element( name = lc_xml_node_anchor lo_element_anchor = lo_document->create_simple_element( name = lc_xml_node_anchor
parent = lo_document ). parent = lo_document ).
" Anchor represents 4 pairs of numbers:
" ( left column, left offset ), ( top row, top offset ),
" ( right column, right offset ), ( bottom row, botton offset )
" Offsets are a number of pixels.
" Reference: Anchor Class at
" https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.vml.spreadsheet.anchor?view=openxml-3.0.1
lv_right_column = lo_comment->get_right_column( ).
lv_bottom_row = lo_comment->get_bottom_row( ).
*--------------------------------------------------------------------* lv_right_column_str = lv_right_column.
* Ricardo R. - 2024.05.02 CONDENSE lv_right_column_str.
* https://github.com/abap2xlsx/abap2xlsx/pull/1219
*--------------------------------------------------------------------*
* Anchor represents 4 pairs of numbers:
* ( left column, left offset ), ( top row, top offset ),
* ( right column, right offset ), ( bottom row, botton offset )
*--------------------------------------------------------------------*
DATA:
lv_anchor TYPE string,
lv_bottom_row TYPE i,
lv_right_col TYPE i,
lv_bottom_row_str TYPE string,
lv_right_col_str TYPE string.
CONSTANTS:
lc_anchor_init TYPE string VALUE '2, 15, 11, 10, &right_col&, 31, &bottom_row&, 9'.
CALL METHOD lo_comment->get_position
IMPORTING
ep_right_column = lv_right_col
ep_bottom_row = lv_bottom_row.
lv_right_col_str = lv_right_col.
lv_bottom_row_str = lv_bottom_row. lv_bottom_row_str = lv_bottom_row.
CONDENSE lv_bottom_row_str.
lv_anchor = lc_anchor_init. lv_anchor = lc_anchor_init.
REPLACE '&right_col&' WITH lv_right_col_str INTO lv_anchor. REPLACE '&right_column&' WITH lv_right_column_str INTO lv_anchor.
REPLACE '&bottom_row&' WITH lv_bottom_row_str INTO lv_anchor. REPLACE '&bottom_row&' WITH lv_bottom_row_str INTO lv_anchor.
lo_element_anchor->set_value( lv_anchor ). lo_element_anchor->set_value( lv_anchor ).
** lo_element_anchor->set_value( '2, 15, 11, 10, 4, 31, 15, 9' ). "Original line
*--------------------------------------------------------------------*
lo_element_clientdata->append_child( new_child = lo_element_anchor ). lo_element_clientdata->append_child( new_child = lo_element_anchor ).
lo_element_autofill = lo_document->create_simple_element( name = lc_xml_node_autofill lo_element_autofill = lo_document->create_simple_element( name = lc_xml_node_autofill
parent = lo_document ). parent = lo_document ).