用于将DOORS对象信息导出到Microsoft Word的DXL脚本-随机删除信息

问题描述

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

有一些函数可以执行数据导出,它们的调用取决于DOORS对象:

  • put_heading_in_word(string s)-将标题编号和标题文本设置为较大的字体
  • put_plain_text_in_word(字符串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,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,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,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接口的访问过多,并且一切都被丢弃,所以我创建了使用Buffer变量的函数,在其中我将各个字符串放入缓冲区中并停止使用“ put_new_line_in_word”函数,而只是在缓冲区中放置“ \ n”。现在我只是丢失了更大的数据块,而且似乎并没有减少丢失数据的频率。

有什么想法吗?

解决方法

据我所知,这是DOORS和Windows 10的一个未解决的问题。导出到Word文档的常用方法是使用Windows剪贴板。 Windows 10中的内存管理似乎已更改,这会引发OLE错误/ OLE问题。这就是为什么该问题无法始终再现的原因。

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...