[Libreoffice-commits] core.git: 2 commits - comphelper/source dbaccess/source forms/source include/comphelper reportdesign/source svx/source toolkit/source
Stephan Bergmann
sbergman at redhat.com
Fri Aug 21 01:34:28 PDT 2015
comphelper/source/misc/types.cxx | 284 ---------------------
dbaccess/source/core/dataaccess/datasource.cxx | 2
dbaccess/source/ui/dlg/DbAdminImpl.cxx | 2
forms/source/component/Currency.cxx | 2
forms/source/component/Date.cxx | 2
forms/source/component/Numeric.cxx | 2
forms/source/component/Time.cxx | 2
include/comphelper/types.hxx | 7
reportdesign/source/ui/report/ReportController.cxx | 3
svx/source/fmcomp/gridctrl.cxx | 2
svx/source/form/fmobj.cxx | 12
toolkit/source/helper/property.cxx | 3
12 files changed, 15 insertions(+), 308 deletions(-)
New commits:
commit fe6c124da752c784c8c9578923a0033a77d3c5b3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Aug 21 10:33:44 2015 +0200
Remove demonstrated-useless comphelper::compare
Change-Id: Ifd1b38afb963255b76f0d821eb46e4c6a972128a
diff --git a/comphelper/CppunitTest_comphelper_test.mk b/comphelper/CppunitTest_comphelper_test.mk
index b87ab7b..89e0710 100644
--- a/comphelper/CppunitTest_comphelper_test.mk
+++ b/comphelper/CppunitTest_comphelper_test.mk
@@ -11,7 +11,6 @@ $(eval $(call gb_CppunitTest_CppunitTest,comphelper_test))
$(eval $(call gb_CppunitTest_add_exception_objects,comphelper_test, \
comphelper/qa/string/test_string \
- comphelper/qa/test_any \
))
$(eval $(call gb_CppunitTest_use_api,comphelper_test, \
@@ -27,6 +26,4 @@ $(eval $(call gb_CppunitTest_use_libraries,comphelper_test, \
$(gb_UWINAPI) \
))
-$(eval $(call gb_CppunitTest_use_ure,comphelper_test))
-
# vim: set noet sw=4 ts=4:
diff --git a/comphelper/qa/test_any.cxx b/comphelper/qa/test_any.cxx
deleted file mode 100644
index 9262f67..0000000
--- a/comphelper/qa/test_any.cxx
+++ /dev/null
@@ -1,94 +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/.
- */
-
-#include <sal/config.h>
-
-#include <com/sun/star/awt/FontDescriptor.hpp>
-#include <com/sun/star/awt/FontSlant.hpp>
-#include <com/sun/star/uno/Any.hxx>
-#include <com/sun/star/util/Date.hpp>
-#include <com/sun/star/util/DateTime.hpp>
-#include <comphelper/types.hxx>
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-#include <sal/types.h>
-
-// Demonstrate that comphelper::compare works exactly the same as
-// css::uno::Any::operator ==:
-
-namespace {
-
-class Test: public CppUnit::TestFixture {
-public:
- void test();
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test);
- CPPUNIT_TEST_SUITE_END();
-};
-
-void Test::test() {
- css::uno::Any a1, a2;
-
- a1 = css::uno::makeAny<sal_uInt32>(5);
- a2 = css::uno::makeAny<sal_Int16>(5);
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<sal_uInt32>(5);
- a2 = css::uno::makeAny<sal_Int16>(6);
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::awt::FontDescriptor>({
- "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
- false, true, 11});
- a2 = css::uno::makeAny<css::awt::FontDescriptor>({
- "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
- false, true, 11});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::awt::FontDescriptor>({
- "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
- false, true, 11});
- a2 = css::uno::makeAny<css::awt::FontDescriptor>({
- "a", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
- false, true, 11});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
- a2 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
- a2 = css::uno::makeAny<css::util::Date>({1, 3, 2003});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
- a2 = css::uno::makeAny<css::util::DateTime>({
- 0, 0, 0, 0, 1, 2, 2003, false});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
- a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
- a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 3});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-
- a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
- a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1});
- CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx
index 025000d..9ae263c 100644
--- a/comphelper/source/misc/types.cxx
+++ b/comphelper/source/misc/types.cxx
@@ -41,36 +41,6 @@ using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
-
-bool operator ==(const DateTime& _rLeft, const DateTime& _rRight)
-{
- return ( _rLeft.NanoSeconds == _rRight.NanoSeconds) &&
- ( _rLeft.Seconds == _rRight.Seconds) &&
- ( _rLeft.Minutes == _rRight.Minutes) &&
- ( _rLeft.Hours == _rRight.Hours) &&
- ( _rLeft.Day == _rRight.Day) &&
- ( _rLeft.Month == _rRight.Month) &&
- ( _rLeft.Year == _rRight.Year) ;
-}
-
-
-bool operator ==(const Date& _rLeft, const Date& _rRight)
-{
- return ( _rLeft.Day == _rRight.Day) &&
- ( _rLeft.Month == _rRight.Month) &&
- ( _rLeft.Year == _rRight.Year) ;
-}
-
-
-bool operator ==(const Time& _rLeft, const Time& _rRight)
-{
- return ( _rLeft.NanoSeconds == _rRight.NanoSeconds) &&
- ( _rLeft.Seconds == _rRight.Seconds) &&
- ( _rLeft.Minutes == _rRight.Minutes) &&
- ( _rLeft.Hours == _rRight.Hours) ;
-}
-
-
sal_Int64 getINT64(const Any& _rAny)
{
sal_Int64 nReturn = 0;
@@ -162,260 +132,6 @@ bool isAssignableFrom(const Type& _rAssignable, const Type& _rFrom)
return typelib_typedescription_isAssignableFrom(pAssignable, pFrom);
}
-
-template<class TYPE>
-bool tryCompare(const void* _pData, const Any& _rValue, bool& _bIdentical, TYPE& _rOut)
-{
- bool bSuccess = _rValue >>= _rOut;
- _bIdentical = bSuccess && (_rOut == *static_cast<const TYPE*>(_pData));
- return bSuccess;
-}
-
-
-bool tryCompare(const void* _pData, const Any& _rValue, bool& _bIdentical, sal_Unicode& _rOut)
-{
- bool bSuccess = ( _rValue.getValueTypeClass() == TypeClass_CHAR );
- if ( bSuccess )
- _rOut = *static_cast< const sal_Unicode* >( _rValue.getValue() );
- _bIdentical = bSuccess && ( _rOut == *static_cast< const sal_Unicode* >( _pData ) );
- return bSuccess;
-}
-
-
-bool compare_impl(const Type& _rType, const void* pData, const Any& _rValue)
-{
- bool bRes = true;
-
- if (_rType.getTypeClass() == TypeClass_ANY)
- {
- // beides AnyWerte
- if (_rValue.getValueType().getTypeClass() == TypeClass_ANY)
- bRes = compare_impl(
- static_cast<const Any*>(pData)->getValueType(),
- static_cast<const Any*>(pData)->getValue(),
- *static_cast<const Any*>(_rValue.getValue()));
- else
- bRes = compare_impl(
- static_cast<const Any*>(pData)->getValueType(),
- static_cast<const Any*>(pData)->getValue(),
- _rValue);
- }
- else if ( (_rType.getTypeClass() == TypeClass_VOID)
- || (_rValue.getValueType().getTypeClass() == TypeClass_VOID)
- )
- {
- bRes = _rType.getTypeClass() == _rValue.getValueType().getTypeClass();
- }
- else
- {
- bool bConversionSuccess = false;
- switch (_rType.getTypeClass())
- {
- case TypeClass_VOID:
- bConversionSuccess = true;
- bRes = _rValue.getValueType().getTypeClass() == TypeClass_VOID;
- break;
- case TypeClass_BOOLEAN:
- {
- bool aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_CHAR:
- {
- sal_Unicode aDummy(0);
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_STRING:
- {
- OUString aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_FLOAT:
- {
- float aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_DOUBLE:
- {
- double aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_BYTE:
- {
- sal_Int8 aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_SHORT:
- {
- sal_Int16 aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_ENUM:
- {
- sal_Int32 nAsInt32 = 0;
- bConversionSuccess = ::cppu::enum2int(nAsInt32, _rValue);
- bRes = bConversionSuccess && (nAsInt32== *static_cast<const sal_Int32*>(pData));
- break;
- }
- case TypeClass_LONG:
- {
- sal_Int32 aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_UNSIGNED_SHORT:
- {
- sal_uInt16 aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_UNSIGNED_LONG:
- {
- sal_uInt32 aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_INTERFACE:
- {
- css::uno::Reference<css::uno::XInterface> aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- case TypeClass_STRUCT:
- if (_rType == cppu::UnoType<FontDescriptor>::get())
- {
- FontDescriptor aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- bRes = *static_cast<FontDescriptor const *>(pData) == aTemp;
- }
- else
- bRes = false;
- break;
- }
- if (_rType == cppu::UnoType<Date>::get())
- {
- Date aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- if (_rType == cppu::UnoType<Time>::get())
- {
- Time aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- if (_rType == cppu::UnoType<DateTime>::get())
- {
- DateTime aDummy;
- bConversionSuccess = tryCompare(pData, _rValue, bRes, aDummy);
- break;
- }
- break;
- case TypeClass_SEQUENCE:
- if (_rType == cppu::UnoType<Sequence<sal_Int8>>::get())
- {
- Sequence<sal_Int8> aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence<sal_Int8>& rLeftSeq = *static_cast<const Sequence<sal_Int8>*>(pData);
- const Sequence<sal_Int8>& rRightSeq = aTemp;
- bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
- memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()) == 0;
- }
- }
- else if (_rType == cppu::UnoType<Sequence<sal_Int16>>::get())
- {
- Sequence<sal_Int16> aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence<sal_Int16>& rLeftSeq = *static_cast<const Sequence<sal_Int16>*>(pData);
- const Sequence<sal_Int16>& rRightSeq = aTemp;
- bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
- memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_Int16)) == 0;
- }
- }
- else if (_rType == cppu::UnoType<cppu::UnoSequenceType<cppu::UnoUnsignedShortType>>::get())
- {
- Sequence<sal_uInt16> aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence<sal_uInt16>& rLeftSeq = *static_cast<const Sequence<sal_uInt16>*>(pData);
- const Sequence<sal_uInt16>& rRightSeq = aTemp;
- bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
- memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_uInt16)) == 0;
- }
- }
- else if (_rType == cppu::UnoType<Sequence<sal_Int32>>::get())
- {
- Sequence<sal_Int32> aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence<sal_Int32>& rLeftSeq = *static_cast<const Sequence<sal_Int32>*>(pData);
- const Sequence<sal_Int32>& rRightSeq = aTemp;
- bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
- memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_Int32)) == 0;
- }
- }
- else if (_rType == cppu::UnoType<Sequence<sal_uInt32>>::get())
- {
- Sequence<sal_uInt32> aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence<sal_uInt32>& rLeftSeq = *static_cast<const Sequence<sal_uInt32>*>(pData);
- const Sequence<sal_uInt32>& rRightSeq = aTemp;
- bRes = rLeftSeq.getLength() == rRightSeq.getLength() &&
- memcmp(rLeftSeq.getConstArray(), rRightSeq.getConstArray(), rLeftSeq.getLength()*sizeof(sal_uInt32)) == 0;
- }
- }
- else if (_rType == cppu::UnoType<Sequence<OUString>>::get())
- {
- Sequence< OUString > aTemp;
- bConversionSuccess = _rValue >>= aTemp;
- if (bConversionSuccess)
- {
- const Sequence< OUString >& rLeftSeq = *static_cast<const Sequence< OUString>*>(pData);
- const Sequence< OUString >& rRightSeq = aTemp;
- sal_Int32 nSeqLen = rLeftSeq.getLength();
- bRes = ( nSeqLen == rRightSeq.getLength() );
- for ( sal_Int32 n = 0; bRes && ( n < nSeqLen ); n++ )
- {
- const OUString& rS1 = rLeftSeq.getConstArray()[n];
- const OUString& rS2 = rRightSeq.getConstArray()[n];
- bRes = ( rS1 == rS2 );
- }
- }
- }
- break;
- default:
- bRes = false;
- }
-
- bRes = bRes && bConversionSuccess;
- }
- return bRes;
-}
-
-
-bool compare(const Any& rLeft, const Any& rRight)
-{
- return compare_impl(rLeft.getValueType(), rLeft.getValue(), rRight);
-}
-
-
bool operator ==(const FontDescriptor& _rLeft, const FontDescriptor& _rRight)
{
return ( _rLeft.Name.equals( _rRight.Name ) ) &&
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 4f09edf..daf414e 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -813,7 +813,7 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any &
bModified = checkValue->Name != pInfoIter->Name;
if ( !bModified )
{
- bModified = !::comphelper::compare(checkValue->Value,pInfoIter->Value);
+ bModified = checkValue->Value != pInfoIter->Value;
}
}
}
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index f32ae28..6f248f4 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -748,7 +748,7 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS
PropertyValueSet::iterator aOverwrittenSetting = aRelevantSettings.find(aSearchFor);
if (aRelevantSettings.end() != aOverwrittenSetting)
{ // the setting was present in the original sequence, and it is to be overwritten -> replace it
- if ( !::comphelper::compare(pInfo->Value,aOverwrittenSetting->Value) )
+ if ( pInfo->Value != aOverwrittenSetting->Value )
*pInfo = *aOverwrittenSetting;
aRelevantSettings.erase(aOverwrittenSetting);
}
diff --git a/forms/source/component/Currency.cxx b/forms/source/component/Currency.cxx
index 28844bc..469cb6c 100644
--- a/forms/source/component/Currency.cxx
+++ b/forms/source/component/Currency.cxx
@@ -187,7 +187,7 @@ OUString SAL_CALL OCurrencyModel::getServiceName() throw ( ::com::sun::star::uno
bool OCurrencyModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( !compare( aControlValue, m_aSaveValue ) )
+ if ( aControlValue != m_aSaveValue )
{
if ( aControlValue.getValueType().getTypeClass() == TypeClass_VOID )
m_xColumnUpdate->updateNull();
diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx
index b28531e..a74e556 100644
--- a/forms/source/component/Date.cxx
+++ b/forms/source/component/Date.cxx
@@ -223,7 +223,7 @@ void ODateModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
bool ODateModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( !compare( aControlValue, m_aSaveValue ) )
+ if ( aControlValue != m_aSaveValue )
{
if ( !aControlValue.hasValue() )
m_xColumnUpdate->updateNull();
diff --git a/forms/source/component/Numeric.cxx b/forms/source/component/Numeric.cxx
index e7fb495..23e6e2e 100644
--- a/forms/source/component/Numeric.cxx
+++ b/forms/source/component/Numeric.cxx
@@ -138,7 +138,7 @@ OUString SAL_CALL ONumericModel::getServiceName() throw ( ::com::sun::star::uno:
bool ONumericModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( !compare( aControlValue, m_aSaveValue ) )
+ if ( aControlValue != m_aSaveValue )
{
if ( !aControlValue.hasValue() )
m_xColumnUpdate->updateNull();
diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx
index c2d4b66..c866729 100644
--- a/forms/source/component/Time.cxx
+++ b/forms/source/component/Time.cxx
@@ -215,7 +215,7 @@ void OTimeModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( !compare( aControlValue, m_aSaveValue ) )
+ if ( aControlValue != m_aSaveValue )
{
if ( !aControlValue.hasValue() )
m_xColumnUpdate->updateNull();
diff --git a/include/comphelper/types.hxx b/include/comphelper/types.hxx
index 0e506f3..2dab540 100644
--- a/include/comphelper/types.hxx
+++ b/include/comphelper/types.hxx
@@ -36,13 +36,6 @@ namespace com { namespace sun { namespace star { namespace awt {
namespace comphelper
{
- /** compare the two given Anys
- The comparison is deep, means if one of the Any's contains an Any which contains an Any ..., this is resolved <br/>
- Other types recognized currently : FontDescriptor, ::com::sun::star::util::Date/Tim/DateTime, css::uno::Sequence<sal_Int8>
- */
- COMPHELPER_DLLPUBLIC bool compare(const css::uno::Any& rLeft, const css::uno::Any& rRight);
-
-
/** compare two FontDescriptor's
*/
COMPHELPER_DLLPUBLIC bool operator ==(const css::awt::FontDescriptor& _rLeft, const css::awt::FontDescriptor& _rRight);
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 0e304d5..3013854 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -35,7 +35,6 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/property.hxx>
#include <comphelper/sequenceashashmap.hxx>
-#include <comphelper/types.hxx>
#include <connectivity/dbtools.hxx>
#include <com/sun/star/view/PaperFormat.hpp>
@@ -4137,7 +4136,7 @@ void OReportController::impl_fillState_nothrow(const OUString& _sProperty,dbaui:
{
aTemp = aTemp2;
}
- else if ( !comphelper::compare(aTemp,aTemp2) )
+ else if ( aTemp != aTemp2 )
break;
}
catch(const beans::UnknownPropertyException&)
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 1fc19e5..5f98698 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -246,7 +246,7 @@ static const sal_uInt16 ControlMap[] =
bool CompareBookmark(const Any& aLeft, const Any& aRight)
{
- return ::comphelper::compare(aLeft, aRight);
+ return aLeft == aRight;
}
class FmXGridSourcePropListener : public ::comphelper::OPropertyChangeListener
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 759d753..4246ca4 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -497,9 +497,9 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
{ // it is a form
try
{
- if ( ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
- && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
- && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
+ if ( xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND) == aSrcCursorSource
+ && xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE) == aSrcCursorSourceType
+ && xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE) == aSrcDataSource
)
{
bEqualDSS = true;
@@ -528,9 +528,9 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
{ // it is a form
try
{
- if ( ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
- && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
- && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
+ if ( xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND) == aSrcCursorSource
+ && xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE) == aSrcCursorSourceType
+ && xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE) == aSrcDataSource
)
{
bEqualDSS = true;
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index b71916d..2bc88c9 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -45,7 +45,6 @@
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/resource/XStringResourceResolver.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
-#include <comphelper/types.hxx>
#include <functional>
#include <algorithm>
@@ -390,7 +389,7 @@ bool DoesDependOnOthers( sal_uInt16 nPropertyId )
bool CompareProperties( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 )
{
- return ::comphelper::compare( r1, r2 );
+ return r1 == r2;
}
commit 5ff8f80a27b08ed6b3c12e354080c6ea1b90b6ee
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Aug 19 15:25:30 2015 +0200
Demonstrate comphelper::compare is useless
Change-Id: I03de2d02f4814bf3425f7278ec91ed1e3b4ce1a0
diff --git a/comphelper/CppunitTest_comphelper_test.mk b/comphelper/CppunitTest_comphelper_test.mk
index 89e0710..b87ab7b 100644
--- a/comphelper/CppunitTest_comphelper_test.mk
+++ b/comphelper/CppunitTest_comphelper_test.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,comphelper_test))
$(eval $(call gb_CppunitTest_add_exception_objects,comphelper_test, \
comphelper/qa/string/test_string \
+ comphelper/qa/test_any \
))
$(eval $(call gb_CppunitTest_use_api,comphelper_test, \
@@ -26,4 +27,6 @@ $(eval $(call gb_CppunitTest_use_libraries,comphelper_test, \
$(gb_UWINAPI) \
))
+$(eval $(call gb_CppunitTest_use_ure,comphelper_test))
+
# vim: set noet sw=4 ts=4:
diff --git a/comphelper/qa/test_any.cxx b/comphelper/qa/test_any.cxx
new file mode 100644
index 0000000..9262f67
--- /dev/null
+++ b/comphelper/qa/test_any.cxx
@@ -0,0 +1,94 @@
+/* -*- 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/.
+ */
+
+#include <sal/config.h>
+
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <comphelper/types.hxx>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <sal/types.h>
+
+// Demonstrate that comphelper::compare works exactly the same as
+// css::uno::Any::operator ==:
+
+namespace {
+
+class Test: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void Test::test() {
+ css::uno::Any a1, a2;
+
+ a1 = css::uno::makeAny<sal_uInt32>(5);
+ a2 = css::uno::makeAny<sal_Int16>(5);
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<sal_uInt32>(5);
+ a2 = css::uno::makeAny<sal_Int16>(6);
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::awt::FontDescriptor>({
+ "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
+ false, true, 11});
+ a2 = css::uno::makeAny<css::awt::FontDescriptor>({
+ "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
+ false, true, 11});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::awt::FontDescriptor>({
+ "A", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
+ false, true, 11});
+ a2 = css::uno::makeAny<css::awt::FontDescriptor>({
+ "a", 0, 1, "B", 3, 4, 5, 6.0, 7.0, css::awt::FontSlant_NONE, 8, 9, 10.0,
+ false, true, 11});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
+ a2 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
+ a2 = css::uno::makeAny<css::util::Date>({1, 3, 2003});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::util::Date>({1, 2, 2003});
+ a2 = css::uno::makeAny<css::util::DateTime>({
+ 0, 0, 0, 0, 1, 2, 2003, false});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
+ a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
+ a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 3});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+
+ a1 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1, 2});
+ a2 = css::uno::makeAny<css::uno::Sequence<sal_Int8>>({0, 1});
+ CPPUNIT_ASSERT_EQUAL(a1 == a2, comphelper::compare(a1, a2));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list