summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-06-16 10:33:53 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-06-16 08:59:33 +0200
commit47efcbdcb4c56e3f29e9c7755eede365eb2a2ac3 (patch)
treeb55a829e6b504e047433648150f660568f3a75c2
parent52a2c19fc403affea4e609add8fd3aebe1bbb220 (diff)
Simplify a bit
Change-Id: Ibb0165d0ce1ec1159a7d5446f746c4cdfcd0d748 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168916 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
-rw-r--r--embedserv/source/embed/ed_ipersiststr.cxx16
-rw-r--r--embedserv/source/embed/guid.cxx66
-rw-r--r--embedserv/source/embed/guid.hxx6
-rw-r--r--embedserv/source/embed/servprov.cxx47
-rw-r--r--embedserv/source/inc/embservconst.h24
-rw-r--r--embedserv/source/inc/servprov.hxx5
-rw-r--r--embedserv/source/inprocserv/dllentry.cxx30
7 files changed, 92 insertions, 102 deletions
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index 698bbe13f586..c82a46d5f845 100644
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -198,7 +198,7 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp
uno::Sequence< beans::PropertyValue > aArgs( xStream.is() ? 3 : 2 );
auto pArgs = aArgs.getArray();
pArgs[0].Name = "FilterName";
- pArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid );
+ pArgs[0].Value <<= getFilterNameFromGUID_Impl( m_guid );
if ( xStream.is() )
{
@@ -237,7 +237,7 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForStoring_Imp
uno::Sequence< beans::PropertyValue > aArgs( xStream.is() ? 2 : 1 );
auto pArgs = aArgs.getArray();
pArgs[0].Name = "FilterName";
- pArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid );
+ pArgs[0].Value <<= getFilterNameFromGUID_Impl( m_guid );
if ( xStream.is() )
{
@@ -394,7 +394,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
if ( m_xFactory.is() && pStg )
{
uno::Reference< frame::XModel > aDocument(
- m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( &m_guid )) ),
+ m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( m_guid )) ),
uno::UNO_QUERY );
if ( aDocument.is() )
{
@@ -416,7 +416,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
if ( hr == S_OK )
{
- wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ???
+ wchar_t const * aCurType = getStorageTypeFromGUID_Impl( m_guid ); // ???
CLIPFORMAT cf = static_cast<CLIPFORMAT>(RegisterClipboardFormatW( L"Embedded Object" ));
hr = WriteFmtUserTypeStg( pStg,
cf, // ???
@@ -529,7 +529,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
if ( xTempIn.is() )
{
uno::Reference< frame::XModel > aDocument(
- m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( &m_guid )) ),
+ m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( m_guid )) ),
uno::UNO_QUERY );
if ( aDocument.is() )
{
@@ -736,7 +736,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileNam
if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL;
- std::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
+ std::u16string_view aCurType = getServiceNameFromGUID_Impl( m_guid ); // ???
CLIPFORMAT cf = static_cast<CLIPFORMAT>(RegisterClipboardFormatW( L"Embedded Object" ));
hr = WriteFmtUserTypeStg( m_pMasterStorage,
cf, // ???
@@ -762,7 +762,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileNam
uno::Reference< frame::XModel > aDocument(
- m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( &m_guid )) ),
+ m_xFactory->createInstance( OUString(getServiceNameFromGUID_Impl( m_guid )) ),
uno::UNO_QUERY );
if ( aDocument.is() )
{
@@ -787,7 +787,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileNam
if ( hr == S_OK )
{
- aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
+ aCurType = getServiceNameFromGUID_Impl( m_guid ); // ???
cf = static_cast<CLIPFORMAT>(RegisterClipboardFormatW( L"Embedded Object" ));
hr = WriteFmtUserTypeStg( m_pMasterStorage,
cf, // ???
diff --git a/embedserv/source/embed/guid.cxx b/embedserv/source/embed/guid.cxx
index 5b284a8a9dff..5dee480982b7 100644
--- a/embedserv/source/embed/guid.cxx
+++ b/embedserv/source/embed/guid.cxx
@@ -23,106 +23,106 @@
#include "guid.hxx"
-wchar_t const * getStorageTypeFromGUID_Impl( GUID const * guid )
+wchar_t const * getStorageTypeFromGUID_Impl( GUID const & guid )
{
- if ( *guid == OID_WriterTextServer )
+ if ( guid == OID_WriterTextServer )
return L"soffice.StarWriterDocument.6";
- if ( *guid == OID_WriterOASISTextServer )
+ if ( guid == OID_WriterOASISTextServer )
return L"LibreOffice.WriterDocument.1";
- if ( *guid == OID_CalcServer )
+ if ( guid == OID_CalcServer )
return L"soffice.StarCalcDocument.6";
- if ( *guid == OID_CalcOASISServer )
+ if ( guid == OID_CalcOASISServer )
return L"LibreOffice.CalcDocument.1";
- if ( *guid == OID_DrawingServer )
+ if ( guid == OID_DrawingServer )
return L"soffice.StarDrawDocument.6";
- if ( *guid == OID_DrawingOASISServer )
+ if ( guid == OID_DrawingOASISServer )
return L"LibreOffice.DrawDocument.1";
- if ( *guid == OID_PresentationServer )
+ if ( guid == OID_PresentationServer )
return L"soffice.StarImpressDocument.6";
- if ( *guid == OID_PresentationOASISServer )
+ if ( guid == OID_PresentationOASISServer )
return L"LibreOffice.ImpressDocument.1";
- if ( *guid == OID_MathServer )
+ if ( guid == OID_MathServer )
return L"soffice.StarMathDocument.6";
- if ( *guid == OID_MathOASISServer )
+ if ( guid == OID_MathOASISServer )
return L"LibreOffice.MathDocument.1";
return L"";
}
-std::u16string_view getServiceNameFromGUID_Impl( GUID const * guid )
+std::u16string_view getServiceNameFromGUID_Impl( GUID const & guid )
{
- if ( *guid == OID_WriterTextServer )
+ if ( guid == OID_WriterTextServer )
return u"com.sun.star.comp.Writer.TextDocument";
- if ( *guid == OID_WriterOASISTextServer )
+ if ( guid == OID_WriterOASISTextServer )
return u"com.sun.star.comp.Writer.TextDocument";
- if ( *guid == OID_CalcServer )
+ if ( guid == OID_CalcServer )
return u"com.sun.star.comp.Calc.SpreadsheetDocument";
- if ( *guid == OID_CalcOASISServer )
+ if ( guid == OID_CalcOASISServer )
return u"com.sun.star.comp.Calc.SpreadsheetDocument";
- if ( *guid == OID_DrawingServer )
+ if ( guid == OID_DrawingServer )
return u"com.sun.star.comp.Draw.DrawingDocument";
- if ( *guid == OID_DrawingOASISServer )
+ if ( guid == OID_DrawingOASISServer )
return u"com.sun.star.comp.Draw.DrawingDocument";
- if ( *guid == OID_PresentationServer )
+ if ( guid == OID_PresentationServer )
return u"com.sun.star.comp.Draw.PresentationDocument";
- if ( *guid == OID_PresentationOASISServer )
+ if ( guid == OID_PresentationOASISServer )
return u"com.sun.star.comp.Draw.PresentationDocument";
- if ( *guid == OID_MathServer )
+ if ( guid == OID_MathServer )
return u"com.sun.star.comp.Math.FormulaDocument";
- if ( *guid == OID_MathOASISServer )
+ if ( guid == OID_MathOASISServer )
return u"com.sun.star.comp.Math.FormulaDocument";
return u"";
}
-OUString getFilterNameFromGUID_Impl( GUID const * guid )
+OUString getFilterNameFromGUID_Impl( GUID const & guid )
{
- if ( *guid == OID_WriterTextServer )
+ if ( guid == OID_WriterTextServer )
return "StarOffice XML (Writer)";
- if ( *guid == OID_WriterOASISTextServer )
+ if ( guid == OID_WriterOASISTextServer )
return "writer8";
- if ( *guid == OID_CalcServer )
+ if ( guid == OID_CalcServer )
return "StarOffice XML (Calc)";
- if ( *guid == OID_CalcOASISServer )
+ if ( guid == OID_CalcOASISServer )
return "calc8";
- if ( *guid == OID_DrawingServer )
+ if ( guid == OID_DrawingServer )
return "StarOffice XML (Draw)";
- if ( *guid == OID_DrawingOASISServer )
+ if ( guid == OID_DrawingOASISServer )
return "draw8";
- if ( *guid == OID_PresentationServer )
+ if ( guid == OID_PresentationServer )
return "StarOffice XML (Impress)";
- if ( *guid == OID_PresentationOASISServer )
+ if ( guid == OID_PresentationOASISServer )
return "impress8";
- if ( *guid == OID_MathServer )
+ if ( guid == OID_MathServer )
return "StarOffice XML (Math)";
- if ( *guid == OID_MathOASISServer )
+ if ( guid == OID_MathOASISServer )
return "math8";
return OUString();
diff --git a/embedserv/source/embed/guid.hxx b/embedserv/source/embed/guid.hxx
index 9e1d8006ebda..82ef79321786 100644
--- a/embedserv/source/embed/guid.hxx
+++ b/embedserv/source/embed/guid.hxx
@@ -26,10 +26,10 @@
#include <common.h>
-OUString getFilterNameFromGUID_Impl(GUID const*);
+OUString getFilterNameFromGUID_Impl(GUID const&);
-std::u16string_view getServiceNameFromGUID_Impl(GUID const*);
+std::u16string_view getServiceNameFromGUID_Impl(GUID const&);
-wchar_t const* getStorageTypeFromGUID_Impl(GUID const* guid);
+wchar_t const* getStorageTypeFromGUID_Impl(GUID const& guid);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx
index 44eab63dd8b7..1365a48c9397 100644
--- a/embedserv/source/embed/servprov.cxx
+++ b/embedserv/source/embed/servprov.cxx
@@ -28,19 +28,17 @@
#include <osl/thread.h>
#include <sal/log.hxx>
-using namespace com::sun::star;
-
-const GUID* const guidList[ SUPPORTED_FACTORIES_NUM ] = {
- &OID_WriterTextServer,
- &OID_WriterOASISTextServer,
- &OID_CalcServer,
- &OID_CalcOASISServer,
- &OID_DrawingServer,
- &OID_DrawingOASISServer,
- &OID_PresentationServer,
- &OID_PresentationOASISServer,
- &OID_MathServer,
- &OID_MathOASISServer
+static constexpr GUID guidList[] = {
+ OID_WriterTextServer,
+ OID_WriterOASISTextServer,
+ OID_CalcServer,
+ OID_CalcOASISServer,
+ OID_DrawingServer,
+ OID_DrawingOASISServer,
+ OID_PresentationServer,
+ OID_PresentationOASISServer,
+ OID_MathServer,
+ OID_MathOASISServer
};
static void o2u_attachCurrentThread()
@@ -61,23 +59,18 @@ static void o2u_attachCurrentThread()
// EmbedServer_Impl
-EmbedServer_Impl::EmbedServer_Impl( const uno::Reference<lang::XMultiServiceFactory>& xFactory):
+EmbedServer_Impl::EmbedServer_Impl( const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory):
m_xFactory( xFactory)
{
- for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
- {
- m_pOLEFactories[nInd] = new EmbedProviderFactory_Impl( m_xFactory, guidList[nInd] );
- m_pOLEFactories[nInd]->registerClass();
- }
+ m_pOLEFactories.reserve(std::size(guidList));
+ std::transform(std::begin(guidList), std::end(guidList), std::back_inserter(m_pOLEFactories),
+ [this](auto& guid) { return new EmbedProviderFactory_Impl(m_xFactory, guid); });
}
EmbedServer_Impl::~EmbedServer_Impl()
{
- for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
- {
- if ( m_pOLEFactories[nInd] )
- m_pOLEFactories[nInd]->deregisterClass();
- }
+ for (auto& factory : m_pOLEFactories)
+ factory->deregisterClass();
}
OUString EmbedServer_Impl::getImplementationName()
@@ -98,9 +91,9 @@ css::uno::Sequence<OUString> EmbedServer_Impl::getSupportedServiceNames()
// EmbedProviderFactory_Impl
-EmbedProviderFactory_Impl::EmbedProviderFactory_Impl(const uno::Reference<lang::XMultiServiceFactory>& xFactory, const GUID* pGuid)
+EmbedProviderFactory_Impl::EmbedProviderFactory_Impl(const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory, const GUID& guid)
: m_refCount( 0 )
- , m_guid( *pGuid )
+ , m_guid( guid )
, m_xFactory( xFactory )
{
}
@@ -186,7 +179,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
embedserv_EmbedServer(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
{
- auto msf = uno::Reference<lang::XMultiServiceFactory>(context->getServiceManager(), css::uno::UNO_QUERY_THROW);
+ auto msf = css::uno::Reference<css::lang::XMultiServiceFactory>(context->getServiceManager(), css::uno::UNO_QUERY_THROW);
return cppu::acquire(new EmbedServer_Impl(msf));
}
diff --git a/embedserv/source/inc/embservconst.h b/embedserv/source/inc/embservconst.h
index 0b48df3d2c2d..8f110dd4cfa5 100644
--- a/embedserv/source/inc/embservconst.h
+++ b/embedserv/source/inc/embservconst.h
@@ -24,24 +24,20 @@
#include <comphelper/classids.hxx>
-#define SUPPORTED_FACTORIES_NUM 10
+inline constexpr GUID OID_WriterTextServer = { SO3_SW_OLE_EMBED_CLASSID_60 };
+inline constexpr GUID OID_WriterOASISTextServer = { SO3_SW_OLE_EMBED_CLASSID_8 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_WriterTextServer = { SO3_SW_OLE_EMBED_CLASSID_60 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_WriterOASISTextServer = { SO3_SW_OLE_EMBED_CLASSID_8 };
+inline constexpr GUID OID_CalcServer = { SO3_SC_OLE_EMBED_CLASSID_60 };
+inline constexpr GUID OID_CalcOASISServer = { SO3_SC_OLE_EMBED_CLASSID_8 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_CalcServer = { SO3_SC_OLE_EMBED_CLASSID_60 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_CalcOASISServer = { SO3_SC_OLE_EMBED_CLASSID_8 };
+inline constexpr GUID OID_DrawingServer = { SO3_SDRAW_OLE_EMBED_CLASSID_60 };
+inline constexpr GUID OID_DrawingOASISServer = { SO3_SDRAW_OLE_EMBED_CLASSID_8 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_DrawingServer = { SO3_SDRAW_OLE_EMBED_CLASSID_60 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_DrawingOASISServer = { SO3_SDRAW_OLE_EMBED_CLASSID_8 };
+inline constexpr GUID OID_PresentationServer = { SO3_SIMPRESS_OLE_EMBED_CLASSID_60 };
+inline constexpr GUID OID_PresentationOASISServer = { SO3_SIMPRESS_OLE_EMBED_CLASSID_8 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_PresentationServer
- = { SO3_SIMPRESS_OLE_EMBED_CLASSID_60 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_PresentationOASISServer
- = { SO3_SIMPRESS_OLE_EMBED_CLASSID_8 };
-
-extern "C" const GUID DECLSPEC_SELECTANY OID_MathServer = { SO3_SM_OLE_EMBED_CLASSID_60 };
-extern "C" const GUID DECLSPEC_SELECTANY OID_MathOASISServer = { SO3_SM_OLE_EMBED_CLASSID_8 };
+inline constexpr GUID OID_MathServer = { SO3_SM_OLE_EMBED_CLASSID_60 };
+inline constexpr GUID OID_MathOASISServer = { SO3_SM_OLE_EMBED_CLASSID_8 };
#endif
diff --git a/embedserv/source/inc/servprov.hxx b/embedserv/source/inc/servprov.hxx
index f2b30fb6ccaa..3542b35a991c 100644
--- a/embedserv/source/inc/servprov.hxx
+++ b/embedserv/source/inc/servprov.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
+#include <vector>
class EmbedProviderFactory_Impl;
@@ -44,7 +45,7 @@ public:
protected:
- CComPtr< EmbedProviderFactory_Impl > m_pOLEFactories[ SUPPORTED_FACTORIES_NUM ];
+ std::vector<CComPtr<EmbedProviderFactory_Impl>> m_pOLEFactories;
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
};
@@ -52,7 +53,7 @@ class EmbedProviderFactory_Impl : public IClassFactory
{
public:
- EmbedProviderFactory_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, const GUID* pGuid);
+ EmbedProviderFactory_Impl(const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory, const GUID& guid);
virtual ~EmbedProviderFactory_Impl();
bool registerClass();
diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx
index 4b430336d7e5..73699aeb4959 100644
--- a/embedserv/source/inprocserv/dllentry.cxx
+++ b/embedserv/source/inprocserv/dllentry.cxx
@@ -27,17 +27,17 @@
#include <olectl.h> // declarations of DllRegisterServer/DllUnregisterServer
-static const GUID* guidList[ SUPPORTED_FACTORIES_NUM ] = {
- &OID_WriterTextServer,
- &OID_WriterOASISTextServer,
- &OID_CalcServer,
- &OID_CalcOASISServer,
- &OID_DrawingServer,
- &OID_DrawingOASISServer,
- &OID_PresentationServer,
- &OID_PresentationOASISServer,
- &OID_MathServer,
- &OID_MathOASISServer
+static constexpr GUID guidList[] = {
+ OID_WriterTextServer,
+ OID_WriterOASISTextServer,
+ OID_CalcServer,
+ OID_CalcOASISServer,
+ OID_DrawingServer,
+ OID_DrawingOASISServer,
+ OID_PresentationServer,
+ OID_PresentationOASISServer,
+ OID_MathServer,
+ OID_MathOASISServer
};
static HINSTANCE g_hInstance = nullptr;
@@ -52,7 +52,7 @@ namespace {
if ( pLibrary && nLen )
{
hRes = S_OK;
- for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
+ for (auto& guid : guidList)
{
constexpr std::wstring_view prefix(L"Software\\Classes\\CLSID\\");
constexpr std::wstring_view suffix(L"\\InprocHandler32");
@@ -62,7 +62,7 @@ namespace {
wchar_t pSubKey[bufsize];
wchar_t *pos = pSubKey, *end = pSubKey + std::size(pSubKey);
pos += prefix.copy(pos, prefix.size());
- int nGuidLen = StringFromGUID2(*guidList[nInd], pos, end - pos);
+ int nGuidLen = StringFromGUID2(guid, pos, end - pos);
bool bLocalSuccess = false;
if (nGuidLen == guidStringSize)
@@ -136,8 +136,8 @@ extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lp
STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID* ppv )
{
- for( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
- if ( *guidList[nInd] == rclsid )
+ for (auto& guid : guidList)
+ if ( guid == rclsid )
{
if ( !IsEqualIID( riid, IID_IUnknown ) && !IsEqualIID( riid, IID_IClassFactory ) )
return E_NOINTERFACE;