【问题标题】:DXL Script to Export DOORS Object Information to Microsoft Word - Randomly Dropping Information将 DOORS 对象信息导出到 Microsoft Word 的 DXL 脚本 - 随机删除信息
【发布时间】:2020-10-13 15:33:53
【问题描述】:

我有一个 DXL 脚本,它应该遍历所选模块中的每个对象,并将基于对象数据的各种对象信息导出到 Microsoft Word 文件。它通常可以工作,但我遇到了一个问题,模块中的随机点数据没有粘贴到 Word 文档中。

有几个函数可以执行数据的导出,根据 DOORS 对象调用它们:

  • put_heading_in_word( string s ) - 将标题编号和标题文本以更大的字体显示
  • put_plain_text_in_word( string s ) - 将纯文本放入 Word 文档中
  • put_new_line_in_word() - 在 Word 中放置一个回车
  • put_object_text_in_word(Object ob) - 将传入的 DOORS 对象中的文本复制到 Word

以下是函数:


/****************************************************************************************
* put_new_line_in_word
*****************************************************************************************/
void put_new_line_in_word()
{
    clear oleAutoArgs
    put(oleAutoArgs, 1) // 0=wdCollapseEnd, 1=wdCollapseStart
    oleMethod(objSel, "Collapse", oleAutoArgs)
    setRichClip(richText "\n" )
    oleMethod(objSel, "Paste")
}//put_new_line_in_word


/****************************************************************************************
* put_plain_text_in_word
*****************************************************************************************/
void put_plain_text_in_word(string s)
{
    clear oleAutoArgs
    put(oleAutoArgs, 1) // 0=wdCollapseEnd, 1=wdCollapseStart
    oleMethod(objSel, "Collapse", oleAutoArgs)
    copyToClipboard( s )
    oleGet(objSel, "Font", oleFont)
    olePut(oleFont, "Size", 11)
    oleMethod(objSel, "Paste")

}//put_plain_text_in_word

/****************************************************************************************
* put_heading_in_word
*****************************************************************************************/
void put_heading_in_word( string s )
{
    clear oleAutoArgs
    put(oleAutoArgs, 1) // 0=wdCollapseEnd, 1=wdCollapseStart
    oleMethod(objSel, "Collapse", oleAutoArgs)
    copyToClipboard( s )
    oleGet(objSel, "Font", oleFont)
    olePut(oleFont, "Size", 18)
    oleMethod(objSel, "Paste")
}//put_heading_in_word


/****************************************************************************************
* put_object_text_in_word
*****************************************************************************************/
void put_object_text_in_word(Object ob)
{
    clear oleAutoArgs
    put(oleAutoArgs, 1) // 0=wdCollapseEnd, 1=wdCollapseStart
    oleMethod(objSel, "Collapse", oleAutoArgs)
//  setRichClip(richText richText(ob."Object Text"))
    setRichClip(richText(ob."Object Text"))
    oleMethod(objSel, "Paste")

}//put_object_text_in_word

以下是如何使用它们的示例:

/****************************************************************************************
* Export_object
*   This is called for each object
*****************************************************************************************/
void Export_object (Module m, Object obj)
{

// allows the the use of attribute exists
current = m


    if ( isValidObject(obj))
    {
        temp_str = obj."Object Heading"
        if(!null temp_str)
        {
            put_plian_text_in_word("ID: ")
            put_plian_text_in_word(identifier(obj))
            put_new_line_in_word
            
            temp_str = number(obj)
            put_heading_in_word(temp_str)
            put_heading_in_word("  ")
            temp_str = obj."Object Heading"
            put_heading_in_word(temp_str)
            put_new_line_in_word
        
        
        }
        else
        {
        
        
            put_plian_text_in_word("ID: ")
            put_plian_text_in_word(identifier(obj))
            put_new_line_in_word
            
            temp_str = obj."Requirement"
            put_plian_text_in_word("Requirement: " temp_str)
            put_new_line_in_word
            
            temp_str = obj."Derived"
            put_plian_text_in_word("Derived: " temp_str)
            put_new_line_in_word
            
            temp_str = obj."DO-178 Level"
            put_plian_text_in_word("DO-178 Level: " temp_str)
            put_new_line_in_word
            
            temp_str = obj."Safety"
            put_plian_text_in_word("Safety: " temp_str)
            put_new_line_in_word        
            
            put_plian_text_in_word("Object Text: ")
            put_new_line_in_word
            put_object_text_in_word(obj)
            if(oleCopy(obj))
            {
                oleMethod(objSel, "Paste")
                put_new_line_in_word
            }
            
            temp_str = obj."Justify"
            put_plian_text_in_word("Justify: " temp_str)
            put_new_line_in_word    
        }

    }
}

我最初的想法是对 OLE 接口的访问过多并且事情被丢弃了,所以我创建了使用缓冲区变量的函数,我将各个字符串放入缓冲区并停止使用“put_new_line_in_word”函数,只是将 '\n' 放在缓冲区中。现在我只是丢失了更大的数据块,而且似乎并没有降低丢失数据的频率。

有什么想法吗?

【问题讨论】:

  • 在 put_heading_in_word() 和 put_plain_text_in_word() 的基于缓冲区的版本中,我放置了“print()”语句以查看函数是否实际执行,并验证缓冲区具有正确的内容在函数被调用之后。

标签: ibm-doors


【解决方案1】:

据我所知,这是 DOORS 和 Windows 10 未解决的问题。导出到 Word 文档的常用方法是使用 Windows 剪贴板。 Windows 10 中的内存管理似乎发生了变化,这引发了 OLE-Errors / OLE 问题。这也是为什么这个问题不能一直重现的原因。

我没有实际的解决方案。作为一种解决方法,如果您有可能使用 Windows 7,我建议您使用它,直到 IBM 或 Microsoft 修复此问题,(在 IBM DOORS 发行说明中,我还没有看到有关此问题的修复,直到当前版本 9.7.2.1)。

【讨论】:

  • 谢谢弗雷德。我确实有一台装有 DOORS 的 Windows 7 服务器,但它没有 Microsoft Office。我正在尝试安装它,但在 IT 帮助台的巨大泥沼中找不到合适的工作流程......
  • 我能够访问运行 Windows Server 2008 R2 Standard 的 VM,并且脚本按预期运行。我能够在不删除任何数据的情况下生成 Word 文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-23
  • 1970-01-01
相关资源
最近更新 更多