tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sfx2 / source / doc / signaturestate.cxx
blobd511fa31afede75744c5c5187277f4b8b1deea7a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sfx2/signaturestate.hxx>
12 #include <com/sun/star/security/CertificateValidity.hpp>
13 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
15 using namespace css;
17 namespace DocumentSignatures
19 SignatureState
20 getSignatureState(const uno::Sequence<security::DocumentSignatureInformation>& aSigInfo)
22 bool bCertValid = true;
23 SignatureState nResult = SignatureState::NOSIGNATURES;
24 bool bCompleteSignature = true;
25 if (!aSigInfo.hasElements())
26 return nResult;
28 nResult = SignatureState::OK;
29 for (const auto& rInfo : aSigInfo)
31 if (bCertValid)
33 sal_Int32 nCertStat = rInfo.CertificateStatus;
34 bCertValid = nCertStat == security::CertificateValidity::VALID;
37 if (!rInfo.SignatureIsValid)
39 nResult = SignatureState::BROKEN;
40 break;
42 bCompleteSignature &= !rInfo.PartialDocumentSignature;
45 if (nResult == SignatureState::OK && !bCertValid && !bCompleteSignature)
46 nResult = SignatureState::NOTVALIDATED_PARTIAL_OK;
47 else if (nResult == SignatureState::OK && !bCertValid)
48 nResult = SignatureState::NOTVALIDATED;
49 else if (nResult == SignatureState::OK && bCertValid && !bCompleteSignature)
50 nResult = SignatureState::PARTIAL_OK;
52 // this code must not check whether the document is modified
53 // it should only check the provided info
55 return nResult;
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */