资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

怎么将SAPDocumentBuilder的word控件设置成只读模式-创新互联

这篇文章将为大家详细讲解有关怎么将SAP Document Builder的word控件设置成只读模式,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

站在用户的角度思考问题,与客户深入沟通,找到汪清网站设计与汪清网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名注册、网页空间、企业邮箱。业务覆盖汪清地区。

最近我正在从事一个客户项目,客户的一个要求是他们不希望word文档在word控件中可编辑。

这意味着工具栏中的所有按钮和菜单都应该被禁用。

怎么将SAP Document Builder的word控件设置成只读模式

image

The first idea comes to my mind is the flag “enableReadWrite“.

怎么将SAP Document Builder的word控件设置成只读模式

image

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.

怎么将SAP Document Builder的word控件设置成只读模式

然后我推测,如果上传的文档是只读的,那么工具栏肯定会被禁用。因此,问题变成了如何在上传过程中将文档标记为只读。

自word 2007以来,MS office的格式遵循所谓的“Open office”协议,其规范可在此处找到。

如果将文件类型扩展名从更改为。docx到。使用WinRAR压缩并打开它,您会发现该文档实际上是由多个单个文件组成的包(在SAP internal中称为文档部分)。可编辑性由文件设置控制。xml。

怎么将SAP Document Builder的word控件设置成只读模式

如果你不知道确切的语法,就用谷歌搜索。我在谷歌的解释中使用了:

现在任务非常简单,只需在文档源代码中添加必要的xml标记即可。您不需要手动解析文档源代码,因为SAP已经完成了这项工作。您可以重用标准类CL_DOCX_文档。

由于我需要在“设置”节点中插入文档保护节点,因此为此编写了一个简单的转换。魔术在第18行和第21行之间。


  
  
  
    
      
    
  
  
    
      
        
      
      
        readOnly
        1
      
      
    
  

and find a proper place to call the transformation:

 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 ).

after that the tag will be there in settings.xml:

怎么将SAP Document Builder的word控件设置成只读模式

image

The word control before upload document looks like below, buttons and menus available:

怎么将SAP Document Builder的word控件设置成只读模式

image

After upload, menu and button are disabled. If you try to edit the document, there will be notifications in the right pane to give you a hint that is not possible.

怎么将SAP Document Builder的word控件设置成只读模式

当然,此解决方案不适用于较低版本的MS word,如word2003。幸运的是,我的客户有足够的钱,他们已经在使用Office 2013,所以我不必为此担心。

关于怎么将SAP Document Builder的word控件设置成只读模式就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


分享标题:怎么将SAPDocumentBuilder的word控件设置成只读模式-创新互联
URL链接:http://cdkjz.cn/article/gpjpe.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220