Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / unotest / macros_test.hxx
blobcf667125e8f0c27a10af4c75d24c0fce6419320d
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/.
8 */
10 #ifndef INCLUDED_UNOTEST_MACROS_TEST_HXX
11 #define INCLUDED_UNOTEST_MACROS_TEST_HXX
13 #include <sal/config.h>
15 #include <memory>
16 #include <functional>
17 #include <config_gpgme.h>
18 #include <rtl/ustring.hxx>
19 #include <unotest/detail/unotestdllapi.hxx>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/frame/XDesktop2.hpp>
23 #include <com/sun/star/uno/Any.h>
24 #include <utility>
26 struct TestMacroInfo
28 OUString sFileBaseName;
29 OUString sMacroUrl;
32 class BasicDLL;
33 class SvStream;
35 namespace test
37 class Directories;
39 namespace utl
41 class TempFileNamed;
44 namespace com::sun::star::security
46 class XCertificate;
48 namespace com::sun::star::xml::crypto
50 class XSecurityEnvironment;
53 namespace unotest
55 class OOO_DLLPUBLIC_UNOTEST MacrosTest
57 public:
58 class Resetter
60 private:
61 std::function<void()> m_Func;
63 public:
64 Resetter(std::function<void()> aFunc)
65 : m_Func(std::move(aFunc))
68 ~Resetter()
70 try
72 m_Func();
74 catch (...) // has to be reliable
76 fprintf(stderr, "resetter failed with exception\n");
77 abort();
82 MacrosTest();
83 ~MacrosTest();
85 css::uno::Reference<css::lang::XComponent>
86 loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString(),
87 const css::uno::Sequence<css::beans::PropertyValue>& rExtra_args
88 = css::uno::Sequence<css::beans::PropertyValue>());
90 static css::uno::Any
91 dispatchCommand(const css::uno::Reference<css::lang::XComponent>& xComponent,
92 const OUString& rCommand,
93 const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
95 /// Opens rStreamName from rTempFile, assuming it's a ZIP storage.
96 static std::unique_ptr<SvStream> parseExportStream(const OUString& url,
97 const OUString& rStreamName);
99 // note: there is no tearDownX509
100 void setUpX509(const test::Directories& rDirectories, const OUString& rTestName);
101 void setUpGpg(const test::Directories& rDirectories, const OUString& rTestName);
102 void tearDownGpg();
104 static bool IsValid(const css::uno::Reference<css::security::XCertificate>& cert,
105 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env);
106 static css::uno::Reference<css::security::XCertificate> GetValidCertificate(
107 const css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>& certs,
108 const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& env,
109 const css::uno::Sequence<css::beans::PropertyValue>& rFilterData = {});
111 protected:
112 css::uno::Reference<css::frame::XDesktop2> mxDesktop;
114 private:
115 std::unique_ptr<BasicDLL> mpDll;
116 #if HAVE_GPGCONF_SOCKETDIR
117 OString m_gpgconfCommandPrefix;
118 #endif
122 #endif
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */