Office js Word.DocumentProperties.security是什么意思?

Office js Word.DocumentProperties.security是什么意思?,office-js,office-addins,Office Js,Office Addins,我正在为Word开发Office插件,因此我正在使用OfficeJs 我有这段代码,如果Word文档处于只读模式,它应该执行一些东西 Word.run(function (context) { var prop = context.document.properties; prop.load("*"); return context.sync().then(function () { if (prop.security && prop.secur

我正在为Word开发Office插件,因此我正在使用OfficeJs

我有这段代码,如果Word文档处于只读模式,它应该执行一些东西

Word.run(function (context) {
   var prop = context.document.properties;
   prop.load("*");

   return context.sync().then(function () {
       if (prop.security && prop.security !== 0) {
           // do some stuff
       }
   });
});
我不理解
prop.security
的含义。我试图将Word文档模式更改为只读,但
prop.security
的值不会立即更改,即使在重新加载加载项后也是如此。有时
prop.security
的值为
0
,其他时间为
8

只说:
获取文档的安全性
,但没有解释这些值的含义


有人能帮我解释一下Word.DocumentProperties.security是如何工作的吗?

更新3

微软的一位开发人员找到了官方文档。它是OpenOfficeXML标准的一部分,特别是DocSecurity元素:(下载zip文件并在PDF中搜索“DocSecurity”。)这里有一些关于Microsoft如何实现它的进一步信息:。本文档确认以下更新2中的列表是正确的。(因此,忽略“(可能)”s。)此外,它表明列出的16个值是唯一可能的值

更新2

根据OP下面的评论,这里是更新后的值列表。我无法验证标记为“(可能)”的那些,但根据模式,我非常有信心它们是正确的。这不一定是完整的。可能存在高于15的值

0 = File on disk is read/write
1 = Protect Document: File is encrypted and requires a password to open
2 = Protect Document: Always Open as Read-Only
3 = Protect Document: Both #1 above and #2
4 = File on disk is read only
5 = Both #1 above and #4 above
6 = Both #2 and #4
7 = (Probably) All of #1, #2, and #4
8 = Protect Document: Restrict Edit to read-only
9 = Both #1 and #8
10 = Both #2 and #8
11 = All of #1, #2, and #8
12 = (Probably) Both #4 and #8
13 = (Probably) All of #1, #4, and #8
14 = (Probably) All of #2, #4, and #8
15 = (Probably) All of #1, #2, #4, and #8
更新: 它不是powers-of-2,一些值与“文件”菜单中的“保护文档”选项相连接。以下是我能够发现的价值观:

0 = File on disk is read/write
1 = Protect Document: File is encrypted and requires a password to open
3 = Protect Document: Both #1 above and #6 below
4 = File on disk is read only
5 = Both #1 above and #4 above
6 = Protect Document: Always Open as Read-Only
8 = ?
请注意,某些“保护文档”选项禁用脚本实验室,因此我无法测试它们是否具有
wdPropertySecurity
值。我认为,但尚未测试,它们会阻止任何外接程序,因此,如果存在这些值,外接程序将永远不会返回这些值

原始答案: 我从Word团队的一位开发人员那里得到了一些信息。
内置文档属性(wdPropertySecurity)
值将文档的属性作为磁盘上的文件引用。将视图模式设置为只读时,不会更改对磁盘上文件的访问权限,因此wdPropertySecurity值不应更改。如果是
0
,则应保持
0
。开发人员发现了
0
4
的含义。因为您已经看到了
8
,看起来这些是2的幂,所以可能还有一个
2
。开发人员报告如下:

0 = read/write
2 = ?
4 = read only
8 = ?

如果我发现更多的话,我会补充这一点。同时,您能否提供获得
8
的确切步骤?

谢谢Rick的回答。当我将编辑限制为只读时,我得了8分。我还发现,当文件总是以只读方式打开时,安全性的值是2。当文件为加密+限制编辑时,安全性为9。当文件始终为sopenreadonly+RestrictEdit时,安全性为10。当文件为Encryption+AlwaysPenReadOnly+RestrictEdit时,安全性为11。我的Word文档存储在Azure存储模拟器中。@EstevaoLuis。谢谢,我会在文档中包括你的发现。