From 9d7a7015857d617b91a0d323ca1ecfe7935fa7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99giel?= Date: Fri, 28 Aug 2015 18:24:51 +0200 Subject: [PATCH 1/3] WORKSHEET, TABLE, STYLE_NUMBER_FORMAT ZCL_EXCEL_WORKSHEET: - in method BIND_ALV optional parameter I_TABLE added so we can decide if we want to have formated table in Excel or not - in method BIND_TABLE optional parameter IV_DEFAULT_DESCR added to be able to control which description you want to use as a table header. ZCL_EXCEL_STYLE_NUMBER_FORMAT : - GBP and PLN currency formats added ZCL_EXCEL_TABLE: - few built in table styles added --- ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk | 14 +- ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk | 38 +-- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk | 245 +++++++++++-------- 3 files changed, 167 insertions(+), 130 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk index 3b485c2..db0ffa4 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk @@ -1,11 +1,11 @@ - - + - *"* local class implementation for public class *"* use this source file for the implementation part of @@ -16,6 +16,8 @@ *"* use this source file for any macro definitions you need *"* in the implementation part of the class + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk index 4a6bb67..9ff04f1 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk @@ -1,5 +1,5 @@ - + *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -20,25 +20,29 @@ - - - - - - - - + + + + + + + + + + + + - + - - - - - - - + + + + + + + method GET_BOTTOM_ROW_INTEGER. DATA: lv_table_lines TYPE i. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index f60a4db..5fb310a 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -1,15 +1,15 @@ - - - - - - - - - - - - + + + *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -199,6 +199,9 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION *"* use this source file for any macro definitions you need *"* in the implementation part of the class + + + @@ -222,6 +225,9 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION + + + @@ -232,7 +238,6 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION ABAP SLIS SOI - @@ -246,7 +251,7 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION - + @@ -256,19 +261,19 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION - + - - - - - - + + + + + + @@ -520,6 +525,7 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION + method BIND_ALV. data: lo_converter type ref to zcl_excel_converter. @@ -533,7 +539,7 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION it_table = it_table i_row_int = i_top i_column_int = i_left - i_table = abap_true + i_table = i_table i_style_table = table_style io_worksheet = me changing @@ -2636,7 +2642,8 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION - + + method BIND_TABLE. *--------------------------------------------------------------------* @@ -2652,8 +2659,8 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION *--------------------------------------------------------------------* CONSTANTS: - lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B', - lc_top_left_row TYPE zexcel_cell_row VALUE 3. + lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'A', + lc_top_left_row TYPE zexcel_cell_row VALUE 1. DATA: lv_row_int TYPE zexcel_cell_row, @@ -2773,18 +2780,43 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION " Check if a column with the same name exists, if exists add a counter " If no medium description is provided we try to use small or long * lv_value = <ls_field_catalog>-scrtext_m. - IF <ls_field_catalog>-scrtext_m IS NOT INITIAL. - lv_value = <ls_field_catalog>-scrtext_m. - <ls_field_catalog>-scrtext_l = lv_value. - ELSEIF <ls_field_catalog>-scrtext_s IS NOT INITIAL. - lv_value = <ls_field_catalog>-scrtext_s. - <ls_field_catalog>-scrtext_l = lv_value. - ELSEIF <ls_field_catalog>-scrtext_l IS NOT INITIAL. - lv_value = <ls_field_catalog>-scrtext_l. - ELSE. - lv_value = 'Column'. " default value as Excel does - <ls_field_catalog>-scrtext_l = lv_value. - ENDIF. + field-symbols: <scrtxt1> type any, + <scrtxt2> type any, + <scrtxt3> type any. + + case iv_default_descr. + when 'M'. + assign <ls_field_catalog>-scrtext_m to <scrtxt1>. + assign <ls_field_catalog>-scrtext_s to <scrtxt2>. + assign <ls_field_catalog>-scrtext_l to <scrtxt3>. + when 'S'. + assign <ls_field_catalog>-scrtext_s to <scrtxt1>. + assign <ls_field_catalog>-scrtext_m to <scrtxt2>. + assign <ls_field_catalog>-scrtext_l to <scrtxt3>. + when 'L'. + assign <ls_field_catalog>-scrtext_l to <scrtxt1>. + assign <ls_field_catalog>-scrtext_m to <scrtxt2>. + assign <ls_field_catalog>-scrtext_s to <scrtxt3>. + when others. + assign <ls_field_catalog>-scrtext_m to <scrtxt1>. + assign <ls_field_catalog>-scrtext_s to <scrtxt2>. + assign <ls_field_catalog>-scrtext_l to <scrtxt3>. + endcase. + + + if <scrtxt1> is not initial. + lv_value = <scrtxt1>. + <ls_field_catalog>-scrtext_l = lv_value. + elseif <scrtxt2> is not initial. + lv_value = <scrtxt2>. + <ls_field_catalog>-scrtext_l = lv_value. + elseif <scrtxt3> is not initial. + lv_value = <scrtxt3>. + <ls_field_catalog>-scrtext_l = lv_value. + else. + lv_value = 'Column'. " default value as Excel does + <ls_field_catalog>-scrtext_l = lv_value. + endif. WHILE 1 = 1. lv_value_lowercase = lv_value. TRANSLATE lv_value_lowercase TO LOWER CASE. @@ -2795,10 +2827,9 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION EXIT. ELSE. lv_syindex = sy-index. - DO lv_syindex TIMES. - CONCATENATE lv_value ' ' INTO lv_value RESPECTING BLANKS. - ENDDO. + CONCATENATE <ls_field_catalog>-scrtext_l lv_syindex INTO lv_value. ENDIF. + ENDWHILE. " First of all write column header IF <ls_field_catalog>-style_header IS NOT INITIAL. @@ -2819,7 +2850,7 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION " issue #290 Add formula support in table IF <ls_field_catalog>-formula EQ abap_true. IF <ls_field_catalog>-style IS NOT INITIAL. - IF <ls_field_catalog>-abap_type IS NOT INITIAL. + IF <ls_field_catalog>-abap_type IS NOT INITIAL. me->set_cell( ip_column = lv_column_alpha ip_row = lv_row_int ip_formula = <fs_fldval> @@ -3313,72 +3344,72 @@ ENDMETHOD. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD change_cell_style. " issue # 139 From f37e6e1b8872d5ba55bce6c17eb98c5f0ad9143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99giel?= Date: Thu, 24 Sep 2015 23:41:31 +0200 Subject: [PATCH 2/3] Themes hanling In the reader I've added loading of theme1.xml file. Color scheme and fonts are loaded to proper structure and can be updated, fmtscheme is at the moment copied from oryginal file as well as object defaults, extra colors and extension list. In case of new file default office theme is used. Changes can be tested with DEMO37 just create simple excel with theme settings and use program to rewrite file. --- ZA2X/CLAS/ZCL_EXCEL.slnk | 19 +- ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk | 58 ++- ZA2X/CLAS/ZCL_EXCEL_THEME.slnk | 200 ++++++++ ZA2X/CLAS/ZCL_EXCEL_THEME_COLOR_SCHEME.slnk | 427 ++++++++++++++++ ZA2X/CLAS/ZCL_EXCEL_THEME_ECLRSCHEMELST.slnk | 40 ++ ZA2X/CLAS/ZCL_EXCEL_THEME_ELEMENTS.slnk | 69 +++ ZA2X/CLAS/ZCL_EXCEL_THEME_EXTLST.slnk | 40 ++ ZA2X/CLAS/ZCL_EXCEL_THEME_FMT_SCHEME.slnk | 186 +++++++ ZA2X/CLAS/ZCL_EXCEL_THEME_FONT_SCHEME.slnk | 479 ++++++++++++++++++ ZA2X/CLAS/ZCL_EXCEL_THEME_OBJECTDEFAULTS.slnk | 38 ++ ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 138 ++--- 11 files changed, 1568 insertions(+), 126 deletions(-) create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_COLOR_SCHEME.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_ECLRSCHEMELST.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_ELEMENTS.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_EXTLST.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_FMT_SCHEME.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_FONT_SCHEME.slnk create mode 100644 ZA2X/CLAS/ZCL_EXCEL_THEME_OBJECTDEFAULTS.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL.slnk b/ZA2X/CLAS/ZCL_EXCEL.slnk index db60250..04df9ae 100644 --- a/ZA2X/CLAS/ZCL_EXCEL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL.slnk @@ -1,8 +1,8 @@ - - - + + + *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -125,6 +125,7 @@ ENDCLASS. "zcl_Tc_Excel + @@ -517,6 +518,12 @@ ENDMETHOD. endmethod. + + + method GET_THEME. + eo_theme = theme. +endmethod. + method GET_WORKSHEETS_ITERATOR. @@ -628,6 +635,12 @@ ENDMETHOD. me->default_style = ip_style. endmethod. + + + method SET_THEME. + theme = io_theme. +endmethod. + diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk index ddaea23..2fb7065 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -1,6 +1,6 @@ - - - - - - - - - - - - - - - - - - *"* local class implementation for public class @@ -1766,6 +1766,18 @@ ENDMETHOD. ENDMETHOD. + + + + + method load_theme. + data theme type ref to zcl_excel_theme. + data: lo_theme_xml type ref to if_ixml_document. + create object theme. + lo_theme_xml = me->get_ixml_from_zip_archive( iv_path ). + theme->read_theme( io_theme_xml = lo_theme_xml ). + ip_excel->set_theme( io_theme = theme ). +endmethod. @@ -1810,6 +1822,7 @@ ENDMETHOD. lcv_worksheet TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', lcv_styles TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', lcv_vba_project TYPE string VALUE 'http://schemas.microsoft.com/office/2006/relationships/vbaProject', "#EC NEEDED for future incorporation of XLSM-reader + lcv_theme TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', *--------------------------------------------------------------------* * #232: Read worksheetstate hidden/veryHidden - begin data declarations *--------------------------------------------------------------------* @@ -1969,7 +1982,14 @@ ENDMETHOD. ip_excel = io_excel ). me->load_dxf_styles( iv_path = lv_full_filename io_excel = io_excel ). - + when lcv_theme. + CONCATENATE lv_path ls_relationship-target + INTO lv_full_filename. + me->load_theme( + exporting + iv_path = lv_full_filename + ip_excel = io_excel " Excel creator + ). WHEN OTHERS. ENDCASE. diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk new file mode 100644 index 0000000..7979d28 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk @@ -0,0 +1,200 @@ + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + method constructor. + create object elements. + create object objectdefaults. + create object extclrschemelst. + create object extlst. + endmethod. "class_constructor + + + + method read_theme. + data: lo_node_theme type ref to if_ixml_element. + data: lo_theme_children type ref to if_ixml_node_list. + data: lo_theme_iterator type ref to if_ixml_node_iterator. + data: lo_theme_element type ref to if_ixml_element. + check io_theme_xml is not initial. + + lo_node_theme = io_theme_xml->get_root_element( )." find_from_name( name = c_theme ). + if lo_node_theme is bound. + name = lo_node_theme->get_attribute( name = c_theme_name ). + xmls_a = lo_node_theme->get_attribute( name = c_theme_xmlns ). + lo_theme_children = lo_node_theme->get_children( ). + lo_theme_iterator = lo_theme_children->create_iterator( ). + lo_theme_element ?= lo_theme_iterator->get_next( ). + while lo_theme_element is bound. + case lo_theme_element->get_name( ). + when c_theme_elements. + elements->load( io_elements = lo_theme_element ). + when c_theme_object_def. + objectdefaults->load( io_object_def = lo_theme_element ). + when c_theme_extra_color. + extclrschemelst->load( io_extra_color = lo_theme_element ). + when c_theme_extlst. + extlst->load( io_extlst = lo_theme_element ). + endcase. + lo_theme_element ?= lo_theme_iterator->get_next( ). + endwhile. + endif. + endmethod. "read_theme + + + + + + + method set_color. + elements->color_scheme->set_color( + exporting + iv_type = iv_type + iv_srgb = iv_srgb + iv_syscolorname = iv_syscolorname + iv_syscolorlast = iv_syscolorlast + ). + endmethod. "set_color + + + + method set_color_scheme_name. + elements->color_scheme->set_name( iv_name = iv_name ). + endmethod. "set_color_scheme_name + + + + + + + + method set_cs_font. + elements->font_scheme->modify_cs_font( + exporting + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "set_cs_font + + + + + + + + method set_ea_font. + elements->font_scheme->modify_ea_font( + exporting + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "set_ea_font + + + + + + method set_font. + elements->font_scheme->modify_font( + exporting + iv_type = iv_type + iv_script = iv_script + iv_typeface = iv_typeface + ). + endmethod. "set_font + + + + method set_font_scheme_name. + elements->font_scheme->set_name( iv_name = iv_name ). + endmethod. "set_font_scheme_name + + + + + + + + method set_latin_font. + elements->font_scheme->modify_latin_font( + exporting + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "set_latin_font + + + + method write_theme. + data: lo_ixml type ref to if_ixml, + lo_element_root type ref to if_ixml_element, + lo_encoding type ref to if_ixml_encoding. + data: lo_streamfactory TYPE REF TO if_ixml_stream_factory. + data: lo_ostream TYPE REF TO if_ixml_ostream. + data: lo_renderer TYPE REF TO if_ixml_renderer. + data: lo_document type ref to if_ixml_document. + lo_ixml = cl_ixml=>create( ). + + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + lo_document->set_namespace_prefix( prefix = 'a' ). + + lo_element_root = lo_document->create_simple_element_ns( prefix = c_theme_prefix + name = c_theme + parent = lo_document + ). + lo_element_root->set_attribute_ns( name = c_theme_xmlns + value = c_theme_xmlns_val ). + lo_element_root->set_attribute_ns( name = c_theme_name + value = name ). + + elements->build_xml( io_document = lo_document ). + objectdefaults->build_xml( io_document = lo_document ). + extclrschemelst->build_xml( io_document = lo_document ). + extlst->build_xml( io_document = lo_document ). + + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = rv_xstring ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + + endmethod. "write_theme + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_COLOR_SCHEME.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_COLOR_SCHEME.slnk new file mode 100644 index 0000000..bda9a95 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_COLOR_SCHEME.slnk @@ -0,0 +1,427 @@ + + + + + + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method build_xml. + data: lo_scheme_element type ref to if_ixml_element. + data: lo_color type ref to if_ixml_element. + data: lo_syscolor type ref to if_ixml_element. + data: lo_srgb type ref to if_ixml_element. + data: lo_elements type ref to if_ixml_element. + + check io_document is bound. + lo_elements ?= io_document->find_from_name_ns( name = zcl_excel_theme=>c_theme_elements ). + if lo_elements is bound. + lo_scheme_element ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = zcl_excel_theme_elements=>c_color_scheme + parent = lo_elements ). + lo_scheme_element->set_attribute( name = c_name value = name ). + + "! Adding colors to scheme + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = c_dark1 + parent = lo_scheme_element ). + if lo_color is bound. + if dark1-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = dark1-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = dark1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = dark1-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_light1 + parent = lo_scheme_element ). + if lo_color is bound. + if light1-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = light1-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = light1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = light1-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_dark2 + parent = lo_scheme_element ). + if lo_color is bound. + if dark2-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = dark2-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = dark2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = dark2-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_light2 + parent = lo_scheme_element ). + if lo_color is bound. + if light2-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = light2-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = light2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = light2-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent1 + parent = lo_scheme_element ). + if lo_color is bound. + if accent1-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent1-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent1-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent2 + parent = lo_scheme_element ). + if lo_color is bound. + if accent2-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent2-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent2-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent3 + parent = lo_scheme_element ). + if lo_color is bound. + if accent3-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent3-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent3-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent3-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent4 + parent = lo_scheme_element ). + if lo_color is bound. + if accent4-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent4-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent4-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent4-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent5 + parent = lo_scheme_element ). + if lo_color is bound. + if accent5-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent5-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent5-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent5-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_accent6 + parent = lo_scheme_element ). + if lo_color is bound. + if accent6-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent6-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent6-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent6-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_hlink + parent = lo_scheme_element ). + if lo_color is bound. + if hlink-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = hlink-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = hlink-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = hlink-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + lo_color ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_folhlink + parent = lo_scheme_element ). + if lo_color is bound. + if folhlink-srgb is not initial. + lo_srgb ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = folhlink-srgb ). + else. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = folhlink-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = folhlink-syscolor-lastclr ). + endif. + clear: lo_color, lo_srgb, lo_syscolor. + endif. + + + endif. + endmethod. "build_xml + + + method constructor. + set_defaults( ). + endmethod. "constructor + + + + + method get_color. + data: lo_color_children type ref to if_ixml_node_list. + data: lo_color_iterator type ref to if_ixml_node_iterator. + data: lo_color_element type ref to if_ixml_element. + check io_object is not initial. + + lo_color_children = io_object->get_children( ). + lo_color_iterator = lo_color_children->create_iterator( ). + lo_color_element ?= lo_color_iterator->get_next( ). + if lo_color_element is bound. + case lo_color_element->get_name( ). + when c_srgbcolor. + rv_color-srgb = lo_color_element->get_attribute( name = c_val ). + when c_syscolor. + rv_color-syscolor-val = lo_color_element->get_attribute( name = c_val ). + rv_color-syscolor-lastclr = lo_color_element->get_attribute( name = c_lastclr ). + endcase. + endif. + endmethod. "get_color + + + + method load. + data: lo_scheme_children type ref to if_ixml_node_list. + data: lo_scheme_iterator type ref to if_ixml_node_iterator. + data: lo_scheme_element type ref to if_ixml_element. + check io_color_scheme is not initial. + + name = io_color_scheme->get_attribute( name = c_name ). + lo_scheme_children = io_color_scheme->get_children( ). + lo_scheme_iterator = lo_scheme_children->create_iterator( ). + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + while lo_scheme_element is bound. + case lo_scheme_element->get_name( ). + when c_dark1. + dark1 = me->get_color( lo_scheme_element ). + when c_dark2. + dark2 = me->get_color( lo_scheme_element ). + when c_light1. + light1 = me->get_color( lo_scheme_element ). + when c_light2. + light2 = me->get_color( lo_scheme_element ). + when c_accent1. + accent1 = me->get_color( lo_scheme_element ). + when c_accent2. + accent2 = me->get_color( lo_scheme_element ). + when c_accent3. + accent3 = me->get_color( lo_scheme_element ). + when c_accent4. + accent4 = me->get_color( lo_scheme_element ). + when c_accent5. + accent5 = me->get_color( lo_scheme_element ). + when c_accent6. + accent6 = me->get_color( lo_scheme_element ). + when c_hlink. + hlink = me->get_color( lo_scheme_element ). + when c_folhlink. + folhlink = me->get_color( lo_scheme_element ). + endcase. + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + endwhile. + endmethod. "load + + + + + + + method set_color. + field-symbols: <color> type t_color. + check iv_type is not initial. + check iv_srgb is not initial or iv_syscolorname is not initial. + case iv_type. + when c_dark1. + assign dark1 to <color>. + when c_dark2. + assign dark2 to <color>. + when c_light1. + assign light1 to <color>. + when c_light2. + assign light2 to <color>. + when c_accent1. + assign accent1 to <color>. + when c_accent2. + assign accent2 to <color>. + when c_accent3. + assign accent3 to <color>. + when c_accent4. + assign accent4 to <color>. + when c_accent5. + assign accent5 to <color>. + when c_accent6. + assign accent6 to <color>. + when c_hlink. + assign hlink to <color>. + when c_folhlink. + assign folhlink to <color>. + endcase. + check <color> is assigned. + clear <color>. + if iv_srgb is not initial. + <color>-srgb = iv_srgb. + else. + <color>-syscolor-val = iv_syscolorname. + if iv_syscolorlast is not initial. + <color>-syscolor-lastclr = iv_syscolorlast. + else. + <color>-syscolor-lastclr = '000000'. + endif. + endif. + endmethod. "set_color + + + method set_defaults. + name = 'Office'. + dark1-syscolor-val = 'windowText'. + dark1-syscolor-lastclr = '000000'. + light1-syscolor-val = 'window'. + light1-syscolor-lastclr = 'FFFFFF'. + dark2-srgb = '44546A'. + light2-srgb = 'E7E6E6'. + accent1-srgb = '5B9BD5'. + accent2-srgb = 'ED7D31'. + accent3-srgb = 'A5A5A5'. + accent4-srgb = 'FFC000'. + accent5-srgb = '4472C4'. + accent6-srgb = '70AD47'. + hlink-srgb = '0563C1'. + folhlink-srgb = '954F72'. + endmethod. "set_defaults + + + + method set_name. + if strlen( iv_name ) > 50. + name = iv_name(50). + else. + name = iv_name. + endif. + endmethod. "set_name + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_ECLRSCHEMELST.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_ECLRSCHEMELST.slnk new file mode 100644 index 0000000..f186534 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_ECLRSCHEMELST.slnk @@ -0,0 +1,40 @@ + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + method build_xml. + data: lo_theme_element type ref to if_ixml_element. + data: lo_theme type ref to if_ixml_element. + data: lo_theme_objdef type ref to if_ixml_element. + check io_document is bound. + lo_theme ?= io_document->get_root_element( ). + check lo_theme is bound. + if extracolor is initial. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = zcl_excel_theme=>c_theme_extra_color + parent = lo_theme ). + + else. + lo_theme->append_child( new_child = extracolor ). + endif. + + endmethod. "build_xml + + + + method load. + "! so far copy only existing values + extracolor ?= io_extra_color. + endmethod. "load + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_ELEMENTS.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_ELEMENTS.slnk new file mode 100644 index 0000000..14e5aa6 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_ELEMENTS.slnk @@ -0,0 +1,69 @@ + + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + + + + + + + method build_xml. + data: lo_theme_element type ref to if_ixml_element. + data: lo_theme type ref to if_ixml_element. + check io_document is bound. + lo_theme ?= io_document->get_root_element( ).. + if lo_theme is bound. + lo_theme_element ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = c_theme_elements + parent = lo_theme ). + + color_scheme->build_xml( io_document = io_document ). + font_scheme->build_xml( io_document = io_document ). + fmt_scheme->build_xml( io_document = io_document ). + endif. + endmethod. + + + method constructor. + create object color_scheme. + create object font_scheme. + create object fmt_scheme. + endmethod. "constructor + + + + method load. + data: lo_elements_children type ref to if_ixml_node_list. + data: lo_elements_iterator type ref to if_ixml_node_iterator. + data: lo_elements_element type ref to if_ixml_element. + check io_elements is not initial. + + lo_elements_children = io_elements->get_children( ). + lo_elements_iterator = lo_elements_children->create_iterator( ). + lo_elements_element ?= lo_elements_iterator->get_next( ). + while lo_elements_element is bound. + case lo_elements_element->get_name( ). + when c_color_scheme. + color_scheme->load( io_color_scheme = lo_elements_element ). + when c_font_scheme. + font_scheme->load( io_font_scheme = lo_elements_element ). + when c_fmt_scheme. + fmt_scheme->load( io_fmt_scheme = lo_elements_element ). + endcase. + lo_elements_element ?= lo_elements_iterator->get_next( ). + endwhile. + endmethod. "load + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_EXTLST.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_EXTLST.slnk new file mode 100644 index 0000000..0181bdb --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_EXTLST.slnk @@ -0,0 +1,40 @@ + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + method build_xml. + data: lo_theme_element type ref to if_ixml_element. + data: lo_theme type ref to if_ixml_element. + data: lo_theme_objdef type ref to if_ixml_element. + check io_document is bound. + + lo_theme ?= io_document->get_root_element( ). + check lo_theme is bound. + if extlst is initial. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = zcl_excel_theme=>c_theme_extlst + parent = lo_theme ). + + else. + lo_theme->append_child( new_child = extlst ). + endif. + endmethod. "build_xml + + + + method load. + "! so far copy only existing values + extlst ?= io_extlst. + endmethod. "load + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_FMT_SCHEME.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_FMT_SCHEME.slnk new file mode 100644 index 0000000..1d38194 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_FMT_SCHEME.slnk @@ -0,0 +1,186 @@ + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + method build_xml. + data: lo_xml type ref to cl_xml_document. + data: lo_node type ref to if_ixml_node. + data: default_fmt_scheme type string. + data: lo_scheme_element type ref to if_ixml_element. + data: lo_elements type ref to if_ixml_element. + check io_document is bound. + lo_elements ?= io_document->find_from_name_ns( name = zcl_excel_theme=>c_theme_elements ). + if lo_elements is bound. + + if fmt_scheme is initial. + create object lo_xml. + lo_xml->parse_string( get_default_fmt( ) ). + lo_node = lo_xml->get_first_node( ). + lo_elements->append_child( new_child = lo_node ). + else. + lo_elements->append_child( new_child = fmt_scheme ). + endif. + endif. + endmethod. "build_xml + + + + method get_default_fmt. + concatenate '<a:fmtScheme name="Office">' + ' <a:fillStyleLst>' + ' <a:solidFill>' + ' <a:schemeClr val="phClr"/>' + ' </a:solidFill>' + ' <a:gradFill rotWithShape="1">' + ' <a:gsLst>' + ' <a:gs pos="0">' + ' <a:schemeClr val="phClr">' + ' <a:lumMod val="110000"/>' + ' <a:satMod val="105000"/>' + ' <a:tint val="67000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="50000">' + ' <a:schemeClr val="phClr">' + ' <a:lumMod val="105000"/>' + ' <a:satMod val="103000"/>' + ' <a:tint val="73000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="100000">' + ' <a:schemeClr val="phClr">' + ' <a:lumMod val="105000"/>' + ' <a:satMod val="109000"/>' + ' <a:tint val="81000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' </a:gsLst>' + ' <a:lin ang="5400000" scaled="0"/>' + ' </a:gradFill>' + ' <a:gradFill rotWithShape="1">' + ' <a:gsLst>' + ' <a:gs pos="0">' + ' <a:schemeClr val="phClr">' + ' <a:satMod val="103000"/>' + ' <a:lumMod val="102000"/>' + ' <a:tint val="94000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="50000">' + ' <a:schemeClr val="phClr">' + ' <a:satMod val="110000"/>' + ' <a:lumMod val="100000"/>' + ' <a:shade val="100000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="100000">' + ' <a:schemeClr val="phClr">' + ' <a:lumMod val="99000"/>' + ' <a:satMod val="120000"/>' + ' <a:shade val="78000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' </a:gsLst>' + ' <a:lin ang="5400000" scaled="0"/>' + ' </a:gradFill>' + ' </a:fillStyleLst>' + ' <a:lnStyleLst>' + ' <a:ln w="6350" cap="flat" cmpd="sng" algn="ctr">' + ' <a:solidFill>' + ' <a:schemeClr val="phClr"/>' + ' </a:solidFill>' + ' <a:prstDash val="solid"/>' + ' <a:miter lim="800000"/>' + ' </a:ln>' + ' <a:ln w="12700" cap="flat" cmpd="sng" algn="ctr">' + ' <a:solidFill>' + ' <a:schemeClr val="phClr"/>' + ' </a:solidFill>' + ' <a:prstDash val="solid"/>' + ' <a:miter lim="800000"/>' + ' </a:ln>' + ' <a:ln w="19050" cap="flat" cmpd="sng" algn="ctr">' + ' <a:solidFill>' + ' <a:schemeClr val="phClr"/>' + ' </a:solidFill>' + ' <a:prstDash val="solid"/>' + ' <a:miter lim="800000"/>' + ' </a:ln>' + ' </a:lnStyleLst>' + ' <a:effectStyleLst>' + ' <a:effectStyle>' + ' <a:effectLst/>' + ' </a:effectStyle>' + ' <a:effectStyle>' + ' <a:effectLst/>' + ' </a:effectStyle>' + ' <a:effectStyle>' + ' <a:effectLst>' + ' <a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0">' + ' <a:srgbClr val="000000">' + ' <a:alpha val="63000"/>' + ' </a:srgbClr>' + ' </a:outerShdw>' + ' </a:effectLst>' + ' </a:effectStyle>' + ' </a:effectStyleLst>' + ' <a:bgFillStyleLst>' + ' <a:solidFill>' + ' <a:schemeClr val="phClr"/>' + ' </a:solidFill>' + ' <a:solidFill>' + ' <a:schemeClr val="phClr">' + ' <a:tint val="95000"/>' + ' <a:satMod val="170000"/>' + ' </a:schemeClr>' + ' </a:solidFill>' + ' <a:gradFill rotWithShape="1">' + ' <a:gsLst>' + ' <a:gs pos="0">' + ' <a:schemeClr val="phClr">' + ' <a:tint val="93000"/>' + ' <a:satMod val="150000"/>' + ' <a:shade val="98000"/>' + ' <a:lumMod val="102000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="50000">' + ' <a:schemeClr val="phClr">' + ' <a:tint val="98000"/>' + ' <a:satMod val="130000"/>' + ' <a:shade val="90000"/>' + ' <a:lumMod val="103000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' <a:gs pos="100000">' + ' <a:schemeClr val="phClr">' + ' <a:shade val="63000"/>' + ' <a:satMod val="120000"/>' + ' </a:schemeClr>' + ' </a:gs>' + ' </a:gsLst>' + ' <a:lin ang="5400000" scaled="0"/>' + ' </a:gradFill>' + ' </a:bgFillStyleLst>' + ' </a:fmtScheme>' + into rv_string . + endmethod. "get_default_fmt + + + + method load. + "! so far copy only existing values + fmt_scheme ?= io_fmt_scheme. + endmethod. "load + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_FONT_SCHEME.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_FONT_SCHEME.slnk new file mode 100644 index 0000000..f87d3fa --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_FONT_SCHEME.slnk @@ -0,0 +1,479 @@ + + + + + + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + + + + + + + + + + + + + + method build_xml. + data: lo_scheme_element type ref to if_ixml_element. + data: lo_font type ref to if_ixml_element. + data: lo_latin type ref to if_ixml_element. + data: lo_ea type ref to if_ixml_element. + data: lo_cs type ref to if_ixml_element. + data: lo_major type ref to if_ixml_element. + data: lo_minor type ref to if_ixml_element. + data: lo_elements type ref to if_ixml_element. + field-symbols: <font> type t_font. + check io_document is bound. + lo_elements ?= io_document->find_from_name_ns( name = zcl_excel_theme=>c_theme_elements ). + if lo_elements is bound. + lo_scheme_element ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = zcl_excel_theme_elements=>c_font_scheme + parent = lo_elements ). + lo_scheme_element->set_attribute( name = c_name value = font_scheme-name ). + + lo_major ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_major + parent = lo_scheme_element ). + if lo_major is bound. + lo_latin ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_latin + parent = lo_major ). + lo_latin->set_attribute( name = c_typeface value = font_scheme-major-latin-typeface ). + if font_scheme-major-latin-panose is not initial. + lo_latin->set_attribute( name = c_panose value = font_scheme-major-latin-panose ). + endif. + if font_scheme-major-latin-pitchfamily is not initial. + lo_latin->set_attribute( name = c_pitchfamily value = font_scheme-major-latin-pitchfamily ). + endif. + if font_scheme-major-latin-charset is not initial. + lo_latin->set_attribute( name = c_charset value = font_scheme-major-latin-charset ). + endif. + + lo_ea ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_ea + parent = lo_major ). + lo_ea->set_attribute( name = c_typeface value = font_scheme-major-ea-typeface ). + if font_scheme-major-ea-panose is not initial. + lo_ea->set_attribute( name = c_panose value = font_scheme-major-ea-panose ). + endif. + if font_scheme-major-ea-pitchfamily is not initial. + lo_ea->set_attribute( name = c_pitchfamily value = font_scheme-major-ea-pitchfamily ). + endif. + if font_scheme-major-ea-charset is not initial. + lo_ea->set_attribute( name = c_charset value = font_scheme-major-ea-charset ). + endif. + + lo_cs ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_cs + parent = lo_major ). + lo_cs->set_attribute( name = c_typeface value = font_scheme-major-cs-typeface ). + if font_scheme-major-cs-panose is not initial. + lo_cs->set_attribute( name = c_panose value = font_scheme-major-cs-panose ). + endif. + if font_scheme-major-cs-pitchfamily is not initial. + lo_cs->set_attribute( name = c_pitchfamily value = font_scheme-major-cs-pitchfamily ). + endif. + if font_scheme-major-cs-charset is not initial. + lo_cs->set_attribute( name = c_charset value = font_scheme-major-cs-charset ). + endif. + + loop at font_scheme-major-fonts assigning <font>. + if <font>-script is not initial and <font>-typeface is not initial. + clear lo_font. + lo_font ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_font + parent = lo_major ). + lo_font->set_attribute( name = c_script value = <font>-script ). + lo_font->set_attribute( name = c_typeface value = <font>-typeface ). + endif. + endloop. + clear: lo_latin, lo_ea, lo_cs, lo_font. + endif. + + lo_minor ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_minor + parent = lo_scheme_element ). + if lo_minor is bound. + lo_latin ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_latin + parent = lo_minor ). + lo_latin->set_attribute( name = c_typeface value = font_scheme-minor-latin-typeface ). + if font_scheme-minor-latin-panose is not initial. + lo_latin->set_attribute( name = c_panose value = font_scheme-minor-latin-panose ). + endif. + if font_scheme-minor-latin-pitchfamily is not initial. + lo_latin->set_attribute( name = c_pitchfamily value = font_scheme-minor-latin-pitchfamily ). + endif. + if font_scheme-minor-latin-charset is not initial. + lo_latin->set_attribute( name = c_charset value = font_scheme-minor-latin-charset ). + endif. + + lo_ea ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_ea + parent = lo_minor ). + lo_ea->set_attribute( name = c_typeface value = font_scheme-minor-ea-typeface ). + if font_scheme-minor-ea-panose is not initial. + lo_ea->set_attribute( name = c_panose value = font_scheme-minor-ea-panose ). + endif. + if font_scheme-minor-ea-pitchfamily is not initial. + lo_ea->set_attribute( name = c_pitchfamily value = font_scheme-minor-ea-pitchfamily ). + endif. + if font_scheme-minor-ea-charset is not initial. + lo_ea->set_attribute( name = c_charset value = font_scheme-minor-ea-charset ). + endif. + + lo_cs ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_cs + parent = lo_minor ). + lo_cs->set_attribute( name = c_typeface value = font_scheme-minor-cs-typeface ). + if font_scheme-minor-cs-panose is not initial. + lo_cs->set_attribute( name = c_panose value = font_scheme-minor-cs-panose ). + endif. + if font_scheme-minor-cs-pitchfamily is not initial. + lo_cs->set_attribute( name = c_pitchfamily value = font_scheme-minor-cs-pitchfamily ). + endif. + if font_scheme-minor-cs-charset is not initial. + lo_cs->set_attribute( name = c_charset value = font_scheme-minor-cs-charset ). + endif. + + loop at font_scheme-minor-fonts assigning <font>. + if <font>-script is not initial and <font>-typeface is not initial. + clear lo_font. + lo_font ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix name = c_font + parent = lo_minor ). + lo_font->set_attribute( name = c_script value = <font>-script ). + lo_font->set_attribute( name = c_typeface value = <font>-typeface ). + endif. + endloop. + clear: lo_latin, lo_ea, lo_cs, lo_font. + endif. + + + endif. + endmethod. "build_xml + + + method constructor. + set_defaults( ). + endmethod. "constructor + + + + method load. + data: lo_scheme_children type ref to if_ixml_node_list. + data: lo_scheme_iterator type ref to if_ixml_node_iterator. + data: lo_scheme_element type ref to if_ixml_element. + data: lo_major_children type ref to if_ixml_node_list. + data: lo_major_iterator type ref to if_ixml_node_iterator. + data: lo_major_element type ref to if_ixml_element. + data: lo_minor_children type ref to if_ixml_node_list. + data: lo_minor_iterator type ref to if_ixml_node_iterator. + data: lo_minor_element type ref to if_ixml_element. + data: ls_font type t_font. + check io_font_scheme is not initial. + clear font_scheme. + font_scheme-name = io_font_scheme->get_attribute( name = c_name ). + lo_scheme_children = io_font_scheme->get_children( ). + lo_scheme_iterator = lo_scheme_children->create_iterator( ). + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + while lo_scheme_element is bound. + case lo_scheme_element->get_name( ). + when c_major. + lo_major_children = lo_scheme_element->get_children( ). + lo_major_iterator = lo_major_children->create_iterator( ). + lo_major_element ?= lo_major_iterator->get_next( ). + while lo_major_element is bound. + case lo_major_element->get_name( ). + when c_latin. + font_scheme-major-latin-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-latin-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-latin-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-latin-charset = lo_major_element->get_attribute( name = c_charset ). + when c_ea. + font_scheme-major-ea-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-ea-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-ea-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-ea-charset = lo_major_element->get_attribute( name = c_charset ). + when c_cs. + font_scheme-major-cs-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-cs-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-cs-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-cs-charset = lo_major_element->get_attribute( name = c_charset ). + when c_font. + clear ls_font. + ls_font-script = lo_major_element->get_attribute( name = c_script ). + ls_font-typeface = lo_major_element->get_attribute( name = c_typeface ). + try. + insert ls_font into table font_scheme-major-fonts. + catch cx_root. "not the best but just to avoid duplicate lines dump + + endtry. + endcase. + lo_major_element ?= lo_major_iterator->get_next( ). + endwhile. + when c_minor. + lo_minor_children = lo_scheme_element->get_children( ). + lo_minor_iterator = lo_minor_children->create_iterator( ). + lo_minor_element ?= lo_minor_iterator->get_next( ). + while lo_minor_element is bound. + case lo_minor_element->get_name( ). + when c_latin. + font_scheme-minor-latin-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-latin-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-latin-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-latin-charset = lo_minor_element->get_attribute( name = c_charset ). + when c_ea. + font_scheme-minor-ea-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-ea-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-ea-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-ea-charset = lo_minor_element->get_attribute( name = c_charset ). + when c_cs. + font_scheme-minor-cs-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-cs-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-cs-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-cs-charset = lo_minor_element->get_attribute( name = c_charset ). + when c_font. + clear ls_font. + ls_font-script = lo_minor_element->get_attribute( name = c_script ). + ls_font-typeface = lo_minor_element->get_attribute( name = c_typeface ). + try. + insert ls_font into table font_scheme-minor-fonts. + catch cx_root. "not the best but just to avoid duplicate lines dump + + endtry. + endcase. + lo_minor_element ?= lo_minor_iterator->get_next( ). + endwhile. + endcase. + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + endwhile. + endmethod. "load + + + + + + + + method modify_cs_font. + modify_lec_fonts( + exporting + iv_type = iv_type + iv_font_type = c_cs + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "modify_latin_font + + + + + + + + method modify_ea_font. + modify_lec_fonts( + exporting + iv_type = iv_type + iv_font_type = c_ea + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "modify_latin_font + + + + + + method modify_font. + data: ls_font type t_font. + field-symbols: <font> type t_font. + ls_font-script = iv_script. + ls_font-typeface = iv_typeface. + try. + case iv_type. + when c_major. + read table font_scheme-major-fonts with key script = iv_script assigning <font>. + if sy-subrc eq 0. + <font> = ls_font. + else. + insert ls_font into table font_scheme-major-fonts. + endif. + when c_minor. + read table font_scheme-minor-fonts with key script = iv_script assigning <font>. + if sy-subrc eq 0. + <font> = ls_font. + else. + insert ls_font into table font_scheme-minor-fonts. + endif. + endcase. + catch cx_root. "not the best but just to avoid duplicate lines dump + endtry. + endmethod. "add_font + + + + + + + + method modify_latin_font. + modify_lec_fonts( + exporting + iv_type = iv_type + iv_font_type = c_latin + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + endmethod. "modify_latin_font + + + + + + + + + method modify_lec_fonts. + field-symbols: <type> type t_fonts, + <font> type t_fonttype. + case iv_type. + when c_minor. + assign font_scheme-minor to <type>. + when c_major. + assign font_scheme-major to <type>. + when others. + return. + endcase. + check <type> is assigned. + case iv_font_type. + when c_latin. + assign <type>-latin to <font>. + when c_ea. + assign <type>-ea to <font>. + when c_cs. + assign <type>-cs to <font>. + when others. + return. + endcase. + check <font> is assigned. + <font>-typeface = iv_typeface. + <font>-panose = iv_panose. + <font>-pitchfamily = iv_pitchfamily. + <font>-charset = iv_charset. + endmethod. "modify_lec_fonts + + + method set_defaults. + clear font_scheme. + font_scheme-name = 'Office'. + font_scheme-major-latin-typeface = 'Calibri Light'. + font_scheme-major-latin-panose = '020F0302020204030204'. + modify_font( iv_type = c_major iv_script = 'Jpan' iv_typeface = 'MS Pゴシック' ). + modify_font( iv_type = c_major iv_script = 'Hang' iv_typeface = '맑은 고딕' ). + modify_font( iv_type = c_major iv_script = 'Hans' iv_typeface = '宋体' ). + modify_font( iv_type = c_major iv_script = 'Hant' iv_typeface = '新細明體' ). + modify_font( iv_type = c_major iv_script = 'Arab' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Hebr' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Thai' iv_typeface = 'Tahoma' ). + modify_font( iv_type = c_major iv_script = 'Ethi' iv_typeface = 'Nyala' ). + modify_font( iv_type = c_major iv_script = 'Beng' iv_typeface = 'Vrinda' ). + modify_font( iv_type = c_major iv_script = 'Gujr' iv_typeface = 'Shruti' ). + modify_font( iv_type = c_major iv_script = 'Khmr' iv_typeface = 'MoolBoran' ). + modify_font( iv_type = c_major iv_script = 'Knda' iv_typeface = 'Tunga' ). + modify_font( iv_type = c_major iv_script = 'Guru' iv_typeface = 'Raavi' ). + modify_font( iv_type = c_major iv_script = 'Cans' iv_typeface = 'Euphemia' ). + modify_font( iv_type = c_major iv_script = 'Cher' iv_typeface = 'Plantagenet Cherokee' ). + modify_font( iv_type = c_major iv_script = 'Yiii' iv_typeface = 'Microsoft Yi Baiti' ). + modify_font( iv_type = c_major iv_script = 'Tibt' iv_typeface = 'Microsoft Himalaya' ). + modify_font( iv_type = c_major iv_script = 'Thaa' iv_typeface = 'MV Boli' ). + modify_font( iv_type = c_major iv_script = 'Deva' iv_typeface = 'Mangal' ). + modify_font( iv_type = c_major iv_script = 'Telu' iv_typeface = 'Gautami' ). + modify_font( iv_type = c_major iv_script = 'Taml' iv_typeface = 'Latha' ). + modify_font( iv_type = c_major iv_script = 'Syrc' iv_typeface = 'Estrangelo Edessa' ). + modify_font( iv_type = c_major iv_script = 'Orya' iv_typeface = 'Kalinga' ). + modify_font( iv_type = c_major iv_script = 'Mlym' iv_typeface = 'Kartika' ). + modify_font( iv_type = c_major iv_script = 'Laoo' iv_typeface = 'DokChampa' ). + modify_font( iv_type = c_major iv_script = 'Sinh' iv_typeface = 'Iskoola Pota' ). + modify_font( iv_type = c_major iv_script = 'Mong' iv_typeface = 'Mongolian Baiti' ). + modify_font( iv_type = c_major iv_script = 'Viet' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Uigh' iv_typeface = 'Microsoft Uighur' ). + modify_font( iv_type = c_major iv_script = 'Geor' iv_typeface = 'Sylfaen' ). + + font_scheme-minor-latin-typeface = 'Calibri'. + font_scheme-minor-latin-panose = '020F0502020204030204'. + modify_font( iv_type = c_minor iv_script = 'Jpan' iv_typeface = 'MS Pゴシック' ). + modify_font( iv_type = c_minor iv_script = 'Hang' iv_typeface = '맑은 고딕' ). + modify_font( iv_type = c_minor iv_script = 'Hans' iv_typeface = '宋体' ). + modify_font( iv_type = c_minor iv_script = 'Hant' iv_typeface = '新細明體' ). + modify_font( iv_type = c_minor iv_script = 'Arab' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Hebr' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Thai' iv_typeface = 'Tahoma' ). + modify_font( iv_type = c_minor iv_script = 'Ethi' iv_typeface = 'Nyala' ). + modify_font( iv_type = c_minor iv_script = 'Beng' iv_typeface = 'Vrinda' ). + modify_font( iv_type = c_minor iv_script = 'Gujr' iv_typeface = 'Shruti' ). + modify_font( iv_type = c_minor iv_script = 'Khmr' iv_typeface = 'DaunPenh' ). + modify_font( iv_type = c_minor iv_script = 'Knda' iv_typeface = 'Tunga' ). + modify_font( iv_type = c_minor iv_script = 'Guru' iv_typeface = 'Raavi' ). + modify_font( iv_type = c_minor iv_script = 'Cans' iv_typeface = 'Euphemia' ). + modify_font( iv_type = c_minor iv_script = 'Cher' iv_typeface = 'Plantagenet Cherokee' ). + modify_font( iv_type = c_minor iv_script = 'Yiii' iv_typeface = 'Microsoft Yi Baiti' ). + modify_font( iv_type = c_minor iv_script = 'Tibt' iv_typeface = 'Microsoft Himalaya' ). + modify_font( iv_type = c_minor iv_script = 'Thaa' iv_typeface = 'MV Boli' ). + modify_font( iv_type = c_minor iv_script = 'Deva' iv_typeface = 'Mangal' ). + modify_font( iv_type = c_minor iv_script = 'Telu' iv_typeface = 'Gautami' ). + modify_font( iv_type = c_minor iv_script = 'Taml' iv_typeface = 'Latha' ). + modify_font( iv_type = c_minor iv_script = 'Syrc' iv_typeface = 'Estrangelo Edessa' ). + modify_font( iv_type = c_minor iv_script = 'Orya' iv_typeface = 'Kalinga' ). + modify_font( iv_type = c_minor iv_script = 'Mlym' iv_typeface = 'Kartika' ). + modify_font( iv_type = c_minor iv_script = 'Laoo' iv_typeface = 'DokChampa' ). + modify_font( iv_type = c_minor iv_script = 'Sinh' iv_typeface = 'Iskoola Pota' ). + modify_font( iv_type = c_minor iv_script = 'Mong' iv_typeface = 'Mongolian Baiti' ). + modify_font( iv_type = c_minor iv_script = 'Viet' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Uigh' iv_typeface = 'Microsoft Uighur' ). + modify_font( iv_type = c_minor iv_script = 'Geor' iv_typeface = 'Sylfaen' ). + + endmethod. "set_defaults + + + + method set_name. + font_scheme-name = iv_name. + endmethod. "set_name + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME_OBJECTDEFAULTS.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME_OBJECTDEFAULTS.slnk new file mode 100644 index 0000000..b3f2a9f --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME_OBJECTDEFAULTS.slnk @@ -0,0 +1,38 @@ + + + *"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + *"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + *"* use this source file for your ABAP unit test classes + + + + method build_xml. + data: lo_theme_element type ref to if_ixml_element. + data: lo_theme type ref to if_ixml_element. + data: lo_theme_objdef type ref to if_ixml_element. + check io_document is bound. + lo_theme ?= io_document->get_root_element( ). + check lo_theme is bound. + if objectdefaults is initial. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = zcl_excel_theme=>c_theme_prefix + name = zcl_excel_theme=>c_theme_object_def + parent = lo_theme ). + else. + lo_theme->append_child( new_child = objectdefaults ). + endif. + endmethod. "build_xml + + + + method load. + "! so far copy only existing values + objectdefaults ?= io_object_def. + endmethod. "load + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 1eb3077..da3697c 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1,5 +1,5 @@ - + *"* local class implementation for public class *"* use this source file for the implementation part of @@ -2585,10 +2585,29 @@ ENDMETHOD. lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 1. + lv_syindex = lv_size. + shift lv_syindex RIGHT DELETING TRAILING space. + shift lv_syindex left DELETING leading space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + replace all occurrences of '#' in lv_xml_node_ridx_id with lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( new_child = lo_element ). + + " Relationship node lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship parent = lo_document ). - lv_size = lv_size + 2. + lv_size = lv_size + 1. lv_syindex = lv_size. SHIFT lv_syindex RIGHT DELETING TRAILING space. SHIFT lv_syindex LEFT DELETING LEADING space. @@ -2603,22 +2622,6 @@ ENDMETHOD. lo_element_root->append_child( new_child = lo_element ). - " Relationship node - lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship - parent = lo_document ). - lv_size = lv_size - 1. - lv_syindex = lv_size. - SHIFT lv_syindex RIGHT DELETING TRAILING space. - SHIFT lv_syindex LEFT DELETING LEADING space. - lv_xml_node_ridx_id = lc_xml_node_ridx_id. - REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. - lo_element->set_attribute_ns( name = lc_xml_attr_id - value = lv_xml_node_ridx_id ). - lo_element->set_attribute_ns( name = lc_xml_attr_type - value = lc_xml_node_rid_theme_tp ). - lo_element->set_attribute_ns( name = lc_xml_attr_target - value = lc_xml_node_rid_theme_tg ). - lo_element_root->append_child( new_child = lo_element ). lv_size = excel->get_worksheets_size( ). @@ -6624,92 +6627,19 @@ ENDMETHOD. - method CREATE_XL_THEME. + method create_xl_theme. + data: lo_theme type ref to zcl_excel_theme. + excel->get_theme( + importing + eo_theme = lo_theme + ). + if lo_theme is initial. + create object lo_theme. + endif. + ep_content = lo_theme->write_theme( ). -* @TODO * - - DATA: lv_xl_theme TYPE string, - lv_xl_theme_01 TYPE string, - lv_xl_theme_02 TYPE string, - lv_xl_theme_03 TYPE string, - lv_xl_theme_04 TYPE string, - lv_xl_theme_05 TYPE string, - lv_xl_theme_06 TYPE string, - lv_xl_theme_07 TYPE string, - lv_xl_theme_08 TYPE string, - lv_xl_theme_09 TYPE string, - lv_xl_theme_10 TYPE string, - lv_xl_theme_11 TYPE string, - lv_xl_theme_12 TYPE string, - lv_xl_theme_13 TYPE string, - lv_xl_theme_14 TYPE string, - lv_xl_theme_15 TYPE string, - lv_xl_theme_16 TYPE string, - lv_xl_theme_17 TYPE string, - lv_xl_theme_18 TYPE string, - lv_xl_theme_19 TYPE string, - lv_xl_theme_20 TYPE string, - lv_xl_theme_21 TYPE string, - lv_xl_theme_22 TYPE string, - lv_xl_theme_23 TYPE string, - lv_xl_theme_24 TYPE string, - lv_xl_theme_25 TYPE string, - lv_xl_theme_26 TYPE string, - lv_xl_theme_27 TYPE string, - lv_xl_theme_28 TYPE string, - lv_xl_theme_29 TYPE string, - lv_xl_theme_30 TYPE string, - lv_xl_theme_31 TYPE string, - lv_xl_theme_32 TYPE string. - - lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. - lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. - lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. - lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. - lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. - lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. - lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. - lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. - lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. - lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. - lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. - lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. - lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. - lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. - lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. - lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. - lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. - lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. - lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. - lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. - lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. - lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. - lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. - lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. - lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. - lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. - lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. - lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. - lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. - lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. - lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. - lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. - - - CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 - lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 - lv_xl_theme_31 lv_xl_theme_32 - INTO lv_xl_theme SEPARATED BY space. - - CALL FUNCTION 'SCMS_STRING_TO_XSTRING' - EXPORTING - text = lv_xl_theme - IMPORTING - buffer = ep_content. - - - endmethod. +endmethod. @@ -6830,8 +6760,8 @@ ENDMETHOD. " fileVersion node lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr parent = lo_document ). - lo_element->set_attribute_ns( name = lc_xml_attr_themeversion - value = '124226' ). +* lo_element->set_attribute_ns( name = lc_xml_attr_themeversion +* value = '124226' ). lo_element_root->append_child( new_child = lo_element ). " workbookProtection node From f62ee2a03756a59397becad183b7418535d8745b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99giel?= Date: Fri, 25 Sep 2015 19:30:53 +0200 Subject: [PATCH 3/3] Demo of modification of theme added ZDEMO_EXCEL42 --- ZA2X/CLAS/ZCL_EXCEL_THEME.slnk | 8 ++- ZA2X/PROG/ZDEMO_EXCEL42.slnk | 110 +++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 ZA2X/PROG/ZDEMO_EXCEL42.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk b/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk index 7979d28..403c476 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_THEME.slnk @@ -70,7 +70,7 @@ - + method set_color. elements->color_scheme->set_color( exporting @@ -157,6 +157,12 @@ ). endmethod. "set_latin_font + + + method set_theme_name. + name = iv_name. + endmethod. + method write_theme. diff --git a/ZA2X/PROG/ZDEMO_EXCEL42.slnk b/ZA2X/PROG/ZDEMO_EXCEL42.slnk new file mode 100644 index 0000000..c85c5fe --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL42.slnk @@ -0,0 +1,110 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL42 +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT ZDEMO_EXCEL42. +type-POOLS: vrm. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_theme TYPE REF TO zcl_excel_theme, + lo_style type ref to zcl_excel_style, + lv_style_guid type ZEXCEL_CELL_STYLE. +DATA: gc_save_file_name TYPE string VALUE '42 Theme Manipulation demo.&'. +include zdemo_excel_outputopt_incl. + +initialization. + + +START-OF-SELECTION. + + + " Creates active sheet + CREATE OBJECT lo_excel. + + " Create a bold / italic style with usage of major font + lo_style = lo_excel->add_new_style( ). + lo_style->font->bold = abap_true. + lo_style->font->italic = abap_true. + lo_style->font->scheme = zcl_excel_style_font=>c_scheme_major. + lo_style->font->color-rgb = zcl_excel_style_color=>c_red. + lv_style_guid = lo_style->get_guid( ). + + " Get active sheet + lo_worksheet = lo_excel->get_active_worksheet( ). + lo_worksheet->set_title( ip_title = 'Styles' ). + lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). + lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_guid ). + + "create theme + create object lo_theme. + lo_theme->set_theme_name( iv_name = 'Theme Demo 42 A2X' ). + lo_theme->set_color_scheme_name( iv_name = 'Demo 42 A2X' ). + + "set theme colors + lo_theme->set_color( + exporting + iv_type = zcl_excel_theme_color_scheme=>c_dark1 + iv_srgb = '5F9EA0' +* iv_syscolorname = +* iv_syscolorlast = + ). + lo_theme->set_color( + exporting + iv_type = zcl_excel_theme_color_scheme=>c_dark2 + iv_srgb = 'FFA500' +* iv_syscolorname = +* iv_syscolorlast = + ). + lo_theme->set_color( + exporting + iv_type = zcl_excel_theme_color_scheme=>c_light1 + iv_srgb = '778899' +* iv_syscolorname = +* iv_syscolorlast = + ). + + lo_theme->set_color( + exporting + iv_type = zcl_excel_theme_color_scheme=>c_light1 + iv_srgb = '9932CC' +* iv_syscolorname = +* iv_syscolorlast = + ). + lo_theme->set_font_scheme_name( iv_name = 'Demo 42 A2X' ). + + + "set theme latin fonts - major and minor + lo_theme->set_latin_font( + exporting + iv_type = zcl_excel_theme_font_scheme=>c_major + iv_typeface = 'Britannic Bold' +* iv_panose = +* iv_pitchfamily = +* iv_charset = + ). + lo_theme->set_latin_font( + exporting + iv_type = zcl_excel_theme_font_scheme=>c_minor + iv_typeface = 'Broadway' +* iv_panose = +* iv_pitchfamily = +* iv_charset = + ). + "push theme to file + lo_excel->set_theme( io_theme = lo_theme ). + + "output + lcl_output=>output( cl_excel = lo_excel ). +