summaryrefslogtreecommitdiffstats
path: root/shell/inc/spsupp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /shell/inc/spsupp
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--shell/inc/spsupp/COMOpenDocuments.hpp186
-rw-r--r--shell/inc/spsupp/COMRefCounted.hpp47
-rw-r--r--shell/inc/spsupp/registrar.hpp49
-rw-r--r--shell/inc/spsupp/spsuppClassFactory.hpp49
-rw-r--r--shell/inc/spsupp/spsuppServ.hpp20
-rw-r--r--shell/inc/spsupp/spsuppStrings.hrc23
6 files changed, 374 insertions, 0 deletions
diff --git a/shell/inc/spsupp/COMOpenDocuments.hpp b/shell/inc/spsupp/COMOpenDocuments.hpp
new file mode 100644
index 000000000..21b378d89
--- /dev/null
+++ b/shell/inc/spsupp/COMOpenDocuments.hpp
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP
+#define INCLUDED_SHELL_INC_SPSUPP_COMOPENDOCUMENTS_HPP
+
+#if defined __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+#include <spsupp_h.h>
+#if defined __clang__
+#pragma clang diagnostic pop
+#endif
+#include "COMRefCounted.hpp"
+#include <Objsafe.h>
+#include <assert.h>
+
+class COMOpenDocuments : public COMRefCounted<IOWSNewDocument3, IObjectSafety>
+{
+public:
+
+ class Error {
+ public:
+ Error(HRESULT syserr) : m_nErr(syserr) {}
+ HRESULT val() const { return m_nErr; }
+ private:
+ HRESULT m_nErr;
+ };
+
+ COMOpenDocuments();
+ virtual ~COMOpenDocuments() override;
+
+ // IUnknown methods
+
+ HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void **ppvObject) override;
+
+ // IDispatch methods
+
+ HRESULT STDMETHODCALLTYPE GetTypeInfoCount(
+ UINT *pctinfo) override;
+
+ HRESULT STDMETHODCALLTYPE GetTypeInfo(
+ UINT iTInfo,
+ LCID lcid,
+ ITypeInfo **ppTInfo) override;
+
+ HRESULT STDMETHODCALLTYPE GetIDsOfNames(
+ REFIID riid,
+ LPOLESTR *rgszNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *rgDispId) override;
+
+ HRESULT STDMETHODCALLTYPE Invoke(
+ DISPID dispIdMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO *pExcepInfo,
+ UINT *puArgErr) override;
+
+ // IOWSNewDocument methods https://msdn.microsoft.com/en-us/library/cc264316
+
+ HRESULT STDMETHODCALLTYPE CreateNewDocument(
+ BSTR bstrTemplateLocation,
+ BSTR bstrDefaultSaveLocation,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE EditDocument(
+ BSTR bstrDocumentLocation,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ // IOWSNewDocument2 methods
+
+ HRESULT STDMETHODCALLTYPE ViewDocument(
+ BSTR bstrDocumentLocation,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE ViewDocument2(
+ IDispatch *pdisp,
+ BSTR bstrDocumentLocation,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE EditDocument2(
+ IDispatch *pdisp,
+ BSTR bstrDocumentLocation,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE CreateNewDocument2(
+ IDispatch *pdisp,
+ BSTR bstrTemplateLocation,
+ BSTR bstrDefaultSaveLocation,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE PromptedOnLastOpen(
+ VARIANT_BOOL *pbResult) override;
+
+ // IOWSNewDocument3 methods
+
+ HRESULT STDMETHODCALLTYPE ViewDocument3(
+ IDispatch *pdisp,
+ BSTR bstrDocumentLocation,
+ int OpenType,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE CheckinDocument(
+ BSTR bstrDocumentLocation,
+ int CheckinType,
+ BSTR CheckinComment,
+ VARIANT_BOOL bKeepCheckout,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE DiscardLocalCheckout(
+ BSTR bstrDocumentLocationRaw,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE ViewInExcel(
+ BSTR SiteUrl,
+ BSTR FileName,
+ BSTR SessionId,
+ BSTR Cmd,
+ BSTR Sheet,
+ int Row,
+ int Column,
+ VARIANT varProgID) override;
+
+ HRESULT STDMETHODCALLTYPE CheckoutDocumentPrompt(
+ BSTR bstrDocumentLocationRaw,
+ VARIANT_BOOL fEditAfterCheckout,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE EditDocument3(
+ IDispatch *pdisp,
+ BSTR bstrDocumentLocation,
+ VARIANT_BOOL fUseLocalCopy,
+ VARIANT varProgID,
+ VARIANT_BOOL *pbResult) override;
+
+ HRESULT STDMETHODCALLTYPE NewBlogPost(
+ BSTR bstrProviderId,
+ BSTR bstrBlogUrl,
+ BSTR bstrBlogName) override;
+
+ // IObjectSafety methods
+
+ HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
+ REFIID riid,
+ DWORD *pdwSupportedOptions,
+ DWORD *pdwEnabledOptions) override;
+
+ HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions(
+ REFIID riid,
+ DWORD dwOptionSetMask,
+ DWORD dwEnabledOptions) override;
+
+ // Non-COM methods
+
+ static long GetObjectCount();
+
+private:
+ static long m_nObjCount;
+ static ITypeInfo* m_pTypeInfo;
+ static constexpr DWORD iSupportedOptionsMask = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
+ DWORD m_iEnabledOptions = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/spsupp/COMRefCounted.hpp b/shell/inc/spsupp/COMRefCounted.hpp
new file mode 100644
index 000000000..0c2460ba2
--- /dev/null
+++ b/shell/inc/spsupp/COMRefCounted.hpp
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
+#define INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
+
+#include <objbase.h>
+#include <assert.h>
+
+template <class... Interfaces>
+class COMRefCounted : public Interfaces...
+{
+public:
+ COMRefCounted() {}
+ virtual ~COMRefCounted() {}
+
+ // IUnknown methods
+
+ ULONG STDMETHODCALLTYPE AddRef() override
+ {
+ return static_cast<ULONG>(::InterlockedIncrement(&m_nRef));
+ }
+
+ ULONG STDMETHODCALLTYPE Release() override
+ {
+ assert(m_nRef > 0);
+ if (::InterlockedDecrement(&m_nRef) == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return static_cast<ULONG>(m_nRef);
+ }
+
+private:
+ long m_nRef = 1; // Created referenced
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/spsupp/registrar.hpp b/shell/inc/spsupp/registrar.hpp
new file mode 100644
index 000000000..920e076de
--- /dev/null
+++ b/shell/inc/spsupp/registrar.hpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
+#define INCLUDED_SHELL_INC_SPSUPP_REGISTRAR_H
+
+#include <initializer_list>
+
+#if !defined WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
+class Registrar {
+public:
+ explicit Registrar(REFIID riidCLSID);
+ // First version in list becomes default
+ HRESULT RegisterObject(REFIID riidTypeLib,
+ const wchar_t* sProgram,
+ const wchar_t* sComponent,
+ std::initializer_list<int> aVersions,
+ const wchar_t* Path);
+ HRESULT UnRegisterObject(const wchar_t* sProgram, const wchar_t* sComponent,
+ std::initializer_list<int> aVersions);
+ // First version in list becomes the default
+ HRESULT RegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+ std::initializer_list<int> aVersions);
+ HRESULT UnRegisterProgIDs(const wchar_t* sProgram, const wchar_t* sComponent,
+ std::initializer_list<int> aVersions);
+
+private:
+ HRESULT RegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion,
+ bool bSetDefault);
+ HRESULT UnRegisterProgID(const wchar_t* sProgram, const wchar_t* sComponent, int nVersion);
+
+ static const size_t nGUIDlen = 40;
+ wchar_t m_sCLSID[nGUIDlen];
+ HRESULT m_ConstructionResult;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/spsupp/spsuppClassFactory.hpp b/shell/inc/spsupp/spsuppClassFactory.hpp
new file mode 100644
index 000000000..9deccbd97
--- /dev/null
+++ b/shell/inc/spsupp/spsuppClassFactory.hpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP
+#define INCLUDED_SHELL_INC_SPSUPP_SPSUPPCLASSFACTORY_HPP
+
+#include "COMRefCounted.hpp"
+
+class ClassFactory : public COMRefCounted<IClassFactory>
+{
+public:
+ ClassFactory();
+ virtual ~ClassFactory() override;
+
+ // IUnknown methods
+
+ HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void **ppvObject) override;
+
+ // IClassFactory methods
+
+ HRESULT STDMETHODCALLTYPE CreateInstance(
+ IUnknown *pUnkOuter,
+ REFIID riid,
+ void **ppvObject) override;
+
+ HRESULT STDMETHODCALLTYPE LockServer(
+ BOOL fLock) override;
+
+ // Non-COM methods
+
+ static long GetObjectCount() { return m_nObjCount; }
+ static long GetLockCount() { return m_nLockCount; }
+
+private:
+ static long m_nObjCount;
+ static long m_nLockCount;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/spsupp/spsuppServ.hpp b/shell/inc/spsupp/spsuppServ.hpp
new file mode 100644
index 000000000..7e4d2fc54
--- /dev/null
+++ b/shell/inc/spsupp/spsuppServ.hpp
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP
+#define INCLUDED_SHELL_INC_SPSUPP_SPSUPPSERV_HPP
+
+#include <objbase.h>
+
+ITypeLib* GetTypeLib();
+const wchar_t* GetHelperExe();
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/spsupp/spsuppStrings.hrc b/shell/inc/spsupp/spsuppStrings.hrc
new file mode 100644
index 000000000..dc96fbb89
--- /dev/null
+++ b/shell/inc/spsupp/spsuppStrings.hrc
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC
+#define INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC
+
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+
+#define RID_STR_SP_VIEW_OR_EDIT_TITLE NC_("RID_STR_SP_VIEW_OR_EDIT_TITLE", "Open Document")
+#define RID_STR_SP_VIEW_OR_EDIT_MESSAGE NC_("RID_STR_SP_VIEW_OR_EDIT_MESSAGE", "You are opening document\n\n %DOCNAME\n\nDo you want to open it to view or to edit?")
+#define RID_STR_SP_VIEW_OR_EDIT_VIEW NC_("RID_STR_SP_VIEW_OR_EDIT_VIEW", "View")
+#define RID_STR_SP_VIEW_OR_EDIT_EDIT NC_("RID_STR_SP_VIEW_OR_EDIT_EDIT", "Edit")
+#define RID_STR_SP_VIEW_OR_EDIT_CANCEL NC_("RID_STR_SP_VIEW_OR_EDIT_CANCEL", "Cancel")
+
+#endif // INCLUDED_SHELL_INC_SPSUPP_STRINGS_HRC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */