Aspose::Words::Properties::BuiltInDocumentProperties::get_Security method
Содержание
[
Скрывать
]BuiltInDocumentProperties::get_Security method
Указывает уровень безопасности документа в виде числового значения.
Aspose::Words::Properties::DocumentSecurity Aspose::Words::Properties::BuiltInDocumentProperties::get_Security()
Примечания
Используйте это свойство только в информационных целях, поскольку Microsoft Word не всегда устанавливает его. Это свойство доступно только в документах DOC и OOXML.
Для защиты или снятия защиты документа используйте методы Protect() и Unprotect.
Aspose.Words обновляет это свойство до корректного значения перед сохранением документа.
Примеры
Показывает, как использовать свойства документа для отображения уровня безопасности документа.
auto doc = System::MakeObject<Aspose::Words::Document>();
ASSERT_EQ(Aspose::Words::Properties::DocumentSecurity::None, doc->get_BuiltInDocumentProperties()->get_Security());
// Если мы настроим документ как только для чтения, он будет отображать этот статус с помощью встроенного свойства "Security".
doc->get_WriteProtection()->set_ReadOnlyRecommended(true);
doc->Save(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyRecommended.docx");
ASSERT_EQ(Aspose::Words::Properties::DocumentSecurity::ReadOnlyRecommended, System::MakeObject<Aspose::Words::Document>(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyRecommended.docx")->get_BuiltInDocumentProperties()->get_Security());
// Защитите документ от записи, а затем проверьте его уровень безопасности.
doc = System::MakeObject<Aspose::Words::Document>();
ASSERT_FALSE(doc->get_WriteProtection()->get_IsWriteProtected());
doc->get_WriteProtection()->SetPassword(u"MyPassword");
ASSERT_TRUE(doc->get_WriteProtection()->ValidatePassword(u"MyPassword"));
ASSERT_TRUE(doc->get_WriteProtection()->get_IsWriteProtected());
doc->Save(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyEnforced.docx");
ASSERT_EQ(Aspose::Words::Properties::DocumentSecurity::ReadOnlyEnforced, System::MakeObject<Aspose::Words::Document>(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyEnforced.docx")->get_BuiltInDocumentProperties()->get_Security());
// "Security" — описательное свойство. Мы можем изменить его значение вручную.
doc = System::MakeObject<Aspose::Words::Document>();
doc->Protect(Aspose::Words::ProtectionType::AllowOnlyComments, u"MyPassword");
doc->get_BuiltInDocumentProperties()->set_Security(Aspose::Words::Properties::DocumentSecurity::ReadOnlyExceptAnnotations);
doc->Save(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyExceptAnnotations.docx");
ASSERT_EQ(Aspose::Words::Properties::DocumentSecurity::ReadOnlyExceptAnnotations, System::MakeObject<Aspose::Words::Document>(get_ArtifactsDir() + u"DocumentProperties.Security.ReadOnlyExceptAnnotations.docx")->get_BuiltInDocumentProperties()->get_Security());
См. также
- Enum DocumentSecurity
- Class BuiltInDocumentProperties
- Namespace Aspose::Words::Properties
- Library Aspose.Words for C++