PowerPoint.SensitivityLabel class
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
Representa o rótulo de confidencialidade na apresentação.
- Extends
Propriedades
| context | O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office. |
Métodos
| get |
Obtém as informações de rótulo atuais que existem na apresentação para o usuário. Se não houver nenhum rótulo de confidencialidade na apresentação atual, um objeto com uma |
| toJSON() | Substitui o método JavaScript |
| try |
Tenta atualizar para o rótulo de confidencialidade fornecido na apresentação para o usuário. Para rótulos habilitados para ABAC, passe as seleções de atributo desejadas por meio |
Detalhes da propriedade
context
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.
context: RequestContext;
Valor da propriedade
Detalhes do método
getCurrentOrNullObject()
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
Obtém as informações de rótulo atuais que existem na apresentação para o usuário. Se não houver nenhum rótulo de confidencialidade na apresentação atual, um objeto com uma isNullObject propriedade definida como true será retornado. Para obter mais informações, consulte métodos e propriedades *OrNullObject.
getCurrentOrNullObject(): PowerPoint.SensitivityLabelDetails;
Retornos
O objeto atual SensitivityLabelDetails .
Comentários
Conjunto de APIs: PowerPointApi BETA (SOMENTE VISUALIZAÇÃO)
Exemplos
// 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()
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original PowerPoint.SensitivityLabel é um objeto de API, o toJSON método retorna um objeto JavaScript simples (digitado como PowerPoint.Interfaces.SensitivityLabelData) que contém cópias superficiais de todas as propriedades filho carregadas do objeto original.
toJSON(): {
[key: string]: string;
};
Retornos
{ [key: string]: string; }
tryToUpdate(labelId, options)
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
Tenta atualizar para o rótulo de confidencialidade fornecido na apresentação para o usuário. Para rótulos habilitados para ABAC, passe as seleções de atributo desejadas por meio options.abacAttributesde .
tryToUpdate(labelId: string, options?: PowerPoint.SensitivityLabelTryUpdateOptions): OfficeExtension.ClientResult<PowerPoint.SensitivityLabelUpdateResult>;
Parâmetros
- labelId
-
string
A ID do rótulo a ser aplicado.
Opcional. Entradas adicionais que influenciam a atualização, como seleções de atributos do ABAC para rótulos habilitados para ABAC.
Retornos
O SensitivityLabelUpdateResult objeto.
Comentários
Conjunto de APIs: PowerPointApi BETA (SOMENTE VISUALIZAÇÃO)
Exemplos
// 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}`);
}
});