[Libreoffice-commits] core.git: 2 commits - dtrans/Library_ftransl.mk dtrans/source dtrans/util sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 22 18:34:18 UTC 2020
dtrans/Library_ftransl.mk | 1
dtrans/source/win32/ftransl/ftransl.cxx | 26 ++++----
dtrans/source/win32/ftransl/ftranslentry.cxx | 79 ---------------------------
dtrans/util/ftransl.component | 5 +
sc/source/core/tool/scmatrix.cxx | 6 +-
5 files changed, 20 insertions(+), 97 deletions(-)
New commits:
commit 376cd186eee775c71912c5427278bf4943a88b08
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 22 15:21:22 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 22 20:33:42 2020 +0200
fix unused ScMatrixRef
from the surrounding code, these look like they should be returned
since these look like bad code checks, add asserts.
Change-Id: Idb1a2eb80b3357654e91bf2ad52b547421552003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99226
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index fdba2f1b7989..7f1d915ec6c7 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2183,8 +2183,9 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
// We assume the result matrix has the same dimension as this matrix.
const std::vector<double>& rResVal = aFunc.getValues();
+ assert (nSize == rResVal.size());
if (nSize != rResVal.size())
- ScMatrixRef();
+ return ScMatrixRef();
return ScMatrixRef(new ScMatrix(aSize.column, aSize.row, rResVal));
}
@@ -2195,8 +2196,9 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
// We assume the result matrix has the same dimension as this matrix.
const std::vector<double>& rResVal = aFunc.getValues();
+ assert (nSize == rResVal.size());
if (nSize != rResVal.size())
- ScMatrixRef();
+ return ScMatrixRef();
return ScMatrixRef(new ScMatrix(aSize.column, aSize.row, rResVal));
}
commit 8aa16f7ae0202a46bd7ef2d1896663b68441fa10
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Tue Jul 21 14:57:09 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 22 20:33:33 2020 +0200
dtrans/ftransl: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I7068fd727d57258a21001d24d2f6b14fa51f9870
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99159
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/dtrans/Library_ftransl.mk b/dtrans/Library_ftransl.mk
index 5a16ee83c419..f418af318d3f 100644
--- a/dtrans/Library_ftransl.mk
+++ b/dtrans/Library_ftransl.mk
@@ -42,7 +42,6 @@ $(eval $(call gb_Library_use_static_libraries,ftransl,\
$(eval $(call gb_Library_add_exception_objects,ftransl,\
dtrans/source/win32/ftransl/ftransl \
- dtrans/source/win32/ftransl/ftranslentry \
))
$(eval $(call gb_Library_set_include,ftransl,\
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index bd189b890f99..f2c5d6487e48 100644
--- a/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/dtrans/source/win32/ftransl/ftransl.cxx
@@ -26,16 +26,13 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
#include "../misc/ImplHelper.hxx"
#include <shlobj.h>
-#define IMPL_NAME "com.sun.star.datatransfer.DataFormatTranslator"
-
#define CPPUTYPE_SEQSALINT8 cppu::UnoType<Sequence< sal_Int8 >>::get()
#define CPPUTYPE_DEFAULT CPPUTYPE_SEQSALINT8
-#define CPPUTYPE_OUSTR cppu::UnoType<OUString>::get()
-#define CPPUTYPE_SALINT32 cppu::UnoType<sal_Int32>::get()
const OUString Windows_FormatName ("windows_formatname");
const css::uno::Type CppuType_ByteSequence = cppu::UnoType<css::uno::Sequence<sal_Int8>>::get();
@@ -51,11 +48,6 @@ using namespace com::sun::star::container;
namespace
{
- Sequence< OUString > DataFormatTranslator_getSupportedServiceNames( )
- {
- Sequence< OUString > aRet { "com.sun.star.datatransfer.DataFormatTranslator" };
- return aRet;
- }
struct FormatEntry
{
@@ -507,14 +499,14 @@ DataFlavor SAL_CALL CDataFormatTranslatorUNO::getDataFlavorFromSystemDataType( c
DataFlavor aFlavor = mkDataFlv( OUString(), OUString(), CPPUTYPE_SEQSALINT8 );
- if ( aSysDataType.getValueType( ) == CPPUTYPE_SALINT32 )
+ if ( aSysDataType.getValueType( ) == cppu::UnoType<sal_Int32>::get() )
{
sal_Int32 clipformat = CF_INVALID;
aSysDataType >>= clipformat;
if ( CF_INVALID != clipformat )
findDataFlavorForStandardFormatId( clipformat, aFlavor );
}
- else if ( aSysDataType.getValueType( ) == CPPUTYPE_OUSTR )
+ else if ( aSysDataType.getValueType( ) == cppu::UnoType<OUString>::get() )
{
OUString nativeFormatName;
aSysDataType >>= nativeFormatName;
@@ -531,7 +523,7 @@ DataFlavor SAL_CALL CDataFormatTranslatorUNO::getDataFlavorFromSystemDataType( c
OUString SAL_CALL CDataFormatTranslatorUNO::getImplementationName( )
{
- return IMPL_NAME;
+ return "com.sun.star.datatransfer.DataFormatTranslator";
}
sal_Bool SAL_CALL CDataFormatTranslatorUNO::supportsService( const OUString& ServiceName )
@@ -541,7 +533,15 @@ sal_Bool SAL_CALL CDataFormatTranslatorUNO::supportsService( const OUString& Ser
Sequence< OUString > SAL_CALL CDataFormatTranslatorUNO::getSupportedServiceNames( )
{
- return DataFormatTranslator_getSupportedServiceNames( );
+ return { "com.sun.star.datatransfer.DataFormatTranslator" };
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+dtrans_CDataFormatTranslatorUNO_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+ static rtl::Reference<CDataFormatTranslatorUNO> g_Instance(new CDataFormatTranslatorUNO(context));
+ g_Instance->acquire();
+ return static_cast<cppu::OWeakObject*>(g_Instance.get());
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/win32/ftransl/ftranslentry.cxx b/dtrans/source/win32/ftransl/ftranslentry.cxx
deleted file mode 100644
index 2959e589fa29..000000000000
--- a/dtrans/source/win32/ftransl/ftranslentry.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppuhelper/factory.hxx>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/container/XSet.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include <com/sun/star/datatransfer/XDataFormatTranslator.hpp>
-#include "ftransl.hxx"
-
-#define SERVICE_NAME "com.sun.star.datatransfer.DataFormatTranslator"
-
-#define IMPL_NAME "com.sun.star.datatransfer.DataFormatTranslator"
-
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::registry;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::datatransfer;
-
-namespace
-{
-
- // functions to create a new Clipboard instance; is needed by factory helper implementation
- // @param rServiceManager - service manager, useful if the component needs other uno services
- // so we should give it to every UNO-Implementation component
-
- Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
- {
- return Reference< XInterface >( static_cast< XDataFormatTranslator* >( new CDataFormatTranslatorUNO( comphelper::getComponentContext(rServiceManager) ) ) );
- }
-}
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void* ftransl_component_getFactory( const char* pImplName, void* pSrvManager, void* /*pRegistryKey*/ )
-{
- void* pRet = nullptr;
-
- if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, IMPL_NAME ) ) )
- {
- Sequence< OUString > aSNS { SERVICE_NAME };
-
- Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
- static_cast< XMultiServiceFactory* > ( pSrvManager ),
- OUString::createFromAscii( pImplName ),
- createInstance,
- aSNS ) );
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
- }
-
- return pRet;
-}
-
-} // extern "C"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/util/ftransl.component b/dtrans/util/ftransl.component
index b1fe4b006460..e97a897f7437 100644
--- a/dtrans/util/ftransl.component
+++ b/dtrans/util/ftransl.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="ftransl" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.datatransfer.DataFormatTranslator">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.datatransfer.DataFormatTranslator"
+ constructor="dtrans_CDataFormatTranslatorUNO_get_implementation">
<service name="com.sun.star.datatransfer.DataFormatTranslator"/>
</implementation>
</component>
More information about the Libreoffice-commits
mailing list