sw a11y: clang-format SidebarWinAccessible code
[LibreOffice.git] / xmlsecurity / inc / documentsignaturehelper.hxx
blobe13bdc81911d8eeb6d6156f080d11c11220c95f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <com/sun/star/uno/Reference.h>
23 #include <rtl/ustring.hxx>
24 #include <svl/sigstruct.hxx>
26 #include <vector>
28 namespace com::sun::star {
29 namespace io { class XStream; }
30 namespace embed { class XStorage; }
33 namespace com::sun::star::xml::sax { class XDocumentHandler; }
35 enum class DocumentSignatureMode
37 Content,
38 Macros,
41 enum class DocumentSignatureAlgorithm
43 OOo2,
44 OOo3_0,
45 OOo3_2
48 struct SignatureStreamHelper
50 css::uno::Reference < css::embed::XStorage > xSignatureStorage;
51 css::uno::Reference < css::io::XStream > xSignatureStream;
52 /// If this is embed::StorageFormats::OFOPXML, then it's expected that xSignatureStream is an empty reference.
53 sal_Int32 nStorageFormat;
55 SignatureStreamHelper()
56 : nStorageFormat(0)
61 namespace DocumentSignatureHelper
63 SignatureStreamHelper OpenSignatureStream(
64 const css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode,
65 DocumentSignatureMode eDocSigMode );
67 std::vector< OUString > CreateElementList(
68 const css::uno::Reference < css::embed::XStorage >& rxStore,
69 DocumentSignatureMode eMode,
70 const DocumentSignatureAlgorithm mode);
72 bool isODFPre_1_2(std::u16string_view sODFVersion);
73 bool isOOo3_2_Signature(const SignatureInformation & sigInfo);
75 DocumentSignatureAlgorithm getDocumentAlgorithm(
76 std::u16string_view sODFVersion, const SignatureInformation & sigInfo);
78 bool CanSignWithGPG(const css::uno::Reference < css::embed::XStorage >& rxStore,
79 std::u16string_view sOdfVersion);
81 bool checkIfAllFilesAreSigned( const ::std::vector< OUString > & sElementList,
82 const SignatureInformation & sigInfo, const DocumentSignatureAlgorithm alg);
84 bool equalsReferenceUriManifestPath(
85 std::u16string_view rUri, std::u16string_view rPath);
87 OUString GetDocumentContentSignatureDefaultStreamName();
88 OUString GetScriptingContentSignatureDefaultStreamName();
89 OUString GetPackageSignatureDefaultStreamName();
91 /// In case the storage is OOXML, prepend a leading '/' and append content type to the element URIs.
92 void AppendContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, std::vector<OUString>& rElements);
94 void writeDigestMethod(
95 const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler);
96 void writeSignedProperties(
97 const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler,
98 const SignatureInformation& signatureInfo,
99 const OUString& sDate,
100 const bool bWriteSignatureLineData);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */