`context.document.body.insertOoxml`破坏文档,使单词崩溃 [英] `context.document.body.insertOoxml` breaks documents, crashes word

查看:121
本文介绍了`context.document.body.insertOoxml`破坏文档,使单词崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这不是问题,但是我是Rick Kirkham从

I know this is not a question, but I was sent here by Rick Kirkham from here, and apparently asking on SO is the way to file bugs for Microsoft products :-p

当我将insertOoxml与'replace'参数一起使用时,Word将在末尾插入额外的内容.例如,在脚本实验室,带有一个新的空word文档:

When I use insertOoxml with the 'replace' parameter, Word will insert extra content at the end. For example, when using the following code in Script Lab, with a new, empty word document:

$("#run").click(run);

function run() {
    Word.run(function (context) {
        var ooxml = context.document.body.getOoxml();
        return context.sync().then(function () {
            console.log(ooxml.value.length);
            context.document.body.insertOoxml(ooxml.value, Word.InsertLocation.replace);
            return context.sync();
        });
    });
}

每次触发此代码时,word文档都会在正文末尾获得一个附加的段落.当文档以内容控件结尾时,它变得更加疯狂:获取一个新文档,插入一个新的RTF内容控件.触发run将复制内容控件并将其插入自身(因此您有两个内容控件,其中一个包含另一个).多次单击run将创建许多嵌套的内容控件,并将Word拖慢进行爬网.插入纯文本内容控件并触发两次运行"将使单词崩溃(似乎是空指针取消引用).

Every time you trigger this code, the word document will acquire an additional paragraph at the end of the body. It gets crazier when the document ends in a content control: take a new document, insert a new rich text content control. Triggering run will duplicate the content control and insert it inside itself (so you have two content controls, where one is contained by the other). Clicking run a couple of times will create a lot of nested content controls and slow down Word to a crawl. Inserting a plain text content control and triggering 'run' twice will crash word (appears to be a null pointer dereference).

这不是与Script Lab相关的问题,但是使用Script Lab是最简单的复制方法.

This is not a problem related to Script Lab, but using Script Lab is the easiest way to reproduce it.

Word版本:1703,内部版本7967.2139,2016 MSO(16.0.7927.1020)32位.

Word version: 1703, build 7967.2139, 2016 MSO (16.0.7927.1020) 32-bit.

预期的行为:Word不会崩溃并且不会引入额外的内容.

Expected behavior: Word does not crash and does not introduce extra content.

好的,让我们提出一个问题:如何在不破坏文档的情况下使用完整文档insertOoxml(ooxml, 'replace')?

Okay so let's make this a question: how do I use a full-document insertOoxml(ooxml, 'replace') without breaking my documents?

推荐答案

我使用较新的版本验证了Word不会崩溃,但确实添加了一个额外的空段落.该错误已于昨天解决,该修复程序将在下个月提供.谢谢!

I verified with the newer build that Word does not crash, but an extra empty paragraph is indeed added. This bug was resolved yesterday and the fix will be available in the next month. Thanks!

这篇关于`context.document.body.insertOoxml`破坏文档,使单词崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆