As documented in sap help,it can fulfill my help but unfortunately it is deprecated. Regardless of this warning I have a try and found it does not work indeed.
Then I am speculating that if the document uploaded is read only, it is for sure that the toolbar will be disabled. So the issue turns to that how could I mark the document to be read only on the fly during uploading.
Since word 2007 the format of MS office follows the so called “Open office” protocol whose specification could be found here.
If you change the file type extension from .docx to .zip and open it with WinRAR, you will find the document is actually a bundle of several single files ( called document part in SAP internal ). The editability is controlled within the file settings.xml.
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:sl="http://schemas.openxmlformats.org/schemaLibrary/2006/main" mc:Ignorable="w14" version="1.0">
readOnly
1
DATA: lr_element TYPE REF TO if_wd_context_element,
lv_file_data TYPE xstring,
lv_ret TYPE i,
lx_temp TYPE xstring,
lv_msg TYPE string,
lt_parms TYPE /ipro/tt_key_value_pair,
ls_parm LIKE LINE OF lt_parms.
lr_element = me->wd_context->get_element( ).
CHECK lr_element IS NOT INITIAL.
lr_element->get_attribute( EXPORTING name = 'BINARY' IMPORTING value = lv_file_data ).
DATA(lo_docx) = cl_docx_document=>load_document( lv_file_data ).
DATA(lo_main_part) = lo_docx->get_maindocumentpart( ).
DATA(lo_docx_settings) = lo_main_part->get_documentsettingspart( ).
DATA(lx_settings) = lo_docx_settings->get_data( ).
/ipro/cl_docx_utilities=>transform( EXPORTING iv_input_xstring = lx_settings
iv_transform_name = '/IPRO/DOCXCC_PROTECT'
it_parameters = lt_parms
IMPORTING ev_result = lx_temp
ev_ret = lv_ret
ev_message = lv_msg ).
lo_docx_settings->feed_data( lx_temp ).
DATA(lx_docx_package) = lo_docx->get_package_data( ).
lr_element->set_attribute( EXPORTING name = 'BINARY' value = lx_docx_package ).