PowerPoint.SensitivityLabel class
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
プレゼンテーションの秘密度ラベルを表します。
- Extends
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
メソッド
| get |
ユーザーのプレゼンテーションに存在する現在のラベル情報を取得します。 現在のプレゼンテーションに秘密度ラベルがない場合は、 |
| toJSON() | API オブジェクトが |
| try |
ユーザーのプレゼンテーションで指定された秘密度ラベルに更新しようとします。 ABAC 対応ラベルの場合は、目的の属性選択を |
プロパティの詳細
context
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
メソッドの詳細
getCurrentOrNullObject()
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
ユーザーのプレゼンテーションに存在する現在のラベル情報を取得します。 現在のプレゼンテーションに秘密度ラベルがない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getCurrentOrNullObject(): PowerPoint.SensitivityLabelDetails;
戻り値
現在の SensitivityLabelDetails オブジェクト。
注釈
API セット: PowerPointApi ベータ版 (プレビューのみ)
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/manage-sensitivity-labels.yaml
await PowerPoint.run(async (context) => {
// Get the sensitivity label currently applied to the presentation.
const presentation: PowerPoint.Presentation = context.presentation;
const presentationLabel: PowerPoint.SensitivityLabel = presentation.sensitivityLabel;
const currentLabel: PowerPoint.SensitivityLabelDetails = presentationLabel.getCurrentOrNullObject();
// Load the properties of the label currently applied to the presentation.
currentLabel.load(
"color,id,isAbacAttributesRequired,isAbacEnabled,isEnabled,name,order,protectionType,siteId,tooltip"
);
await context.sync();
if (currentLabel.isNullObject) {
console.log("The presentation doesn't have a sensitivity label.");
return;
}
// Get ABAC values when enabled for the label.
let abacAttributeValues: PowerPoint.SensitivityLabelAbacAttributeValue[] = [];
if (currentLabel.isAbacEnabled) {
currentLabel.load("abacAttributeValues");
await context.sync();
abacAttributeValues = currentLabel.abacAttributeValues;
}
// Display the loaded properties of the current label.
const attributeValues = abacAttributeValues.length
? abacAttributeValues
.map(
(attributeValue: PowerPoint.SensitivityLabelAbacAttributeValue) =>
`${attributeValue.displayName} (ID: ${attributeValue.id}, order: ${attributeValue.displayOrder}, active: ${attributeValue.isActive ? "Yes" : "No"})`
)
.join(", ")
: "None";
let protectionDescription: string;
switch (currentLabel.protectionType) {
case PowerPoint.SensitivityLabelProtectionType.adminDefined:
protectionDescription = "Defined by an administrator";
break;
case PowerPoint.SensitivityLabelProtectionType.userDefined:
protectionDescription = "Defined by the user";
break;
case PowerPoint.SensitivityLabelProtectionType.noProtection:
protectionDescription = "No protection";
break;
default:
protectionDescription = `Unknown (${currentLabel.protectionType})`;
break;
}
console.log(
`Current presentation sensitivity label:\n\n${currentLabel.name}\n` +
` ID: ${currentLabel.id}\n` +
` Site ID: ${currentLabel.siteId}\n` +
` Tooltip: ${currentLabel.tooltip}\n` +
` Color: ${currentLabel.color}\n` +
` Enabled: ${currentLabel.isEnabled ? "Yes" : "No"}\n` +
` Display order: ${currentLabel.order}\n` +
` ABAC enabled: ${currentLabel.isAbacEnabled ? "Yes" : "No"}\n` +
` ABAC attributes required: ${currentLabel.isAbacAttributesRequired ? "Yes" : "No"}\n` +
` ABAC attribute values: ${attributeValues}\n` +
` Protection type: ${protectionDescription}`
);
});
toJSON()
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.SensitivityLabel オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SensitivityLabelData と型指定) を返します。
toJSON(): {
[key: string]: string;
};
戻り値
{ [key: string]: string; }
tryToUpdate(labelId, options)
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
ユーザーのプレゼンテーションで指定された秘密度ラベルに更新しようとします。 ABAC 対応ラベルの場合は、目的の属性選択を options.abacAttributes 経由で渡します。
tryToUpdate(labelId: string, options?: PowerPoint.SensitivityLabelTryUpdateOptions): OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult>;
パラメーター
- labelId
-
string
適用するラベルの ID。
省略可能。 ABAC 対応ラベルの ABAC 属性の選択など、更新に影響する追加の入力。
戻り値
SensitivityLabelUpdateResult オブジェクト。
注釈
API セット: PowerPointApi ベータ版 (プレビューのみ)
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/preview-apis/manage-sensitivity-labels.yaml
await PowerPoint.run(async (context) => {
// Apply the selected sensitivity label to the presentation.
const labelId = (document.getElementById("label-id") as HTMLSelectElement).value;
if (!labelId) {
console.warn("Get the available labels, and then select a label to apply.");
return;
}
const presentation: PowerPoint.Presentation = context.presentation;
const presentationLabel: PowerPoint.SensitivityLabel = presentation.sensitivityLabel;
const updateResult: OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult> =
presentationLabel.tryToUpdate(labelId);
await context.sync();
if (updateResult.value.status === PowerPoint.SensitivityLabelUpdateStatus.success) {
console.log("Applied the sensitivity label to the presentation.");
} else {
console.error(`The sensitivity label wasn't applied. Status: ${updateResult.value.status}`);
}
});