summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-08-21 10:33:44 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-08-21 10:34:04 +0200
commitfe6c124da752c784c8c9578923a0033a77d3c5b3 (patch)
treeabecf6baf859612cd7255d13588ded9d204da690 /comphelper
parent5ff8f80a27b08ed6b3c12e354080c6ea1b90b6ee (diff)
Remove demonstrated-useless comphelper::compare
Change-Id: Ifd1b38afb963255b76f0d821eb46e4c6a972128a
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/CppunitTest_comphelper_test.mk3
-rw-r--r--comphelper/qa/test_any.cxx94
-rw-r--r--comphelper/source/misc/types.cxx284
3 files changed, 0 insertions, 381 deletions
diff --git a/comphelper/CppunitTest_comphelper_test.mk b/comphelper/CppunitTest_comphelper_test.mk
index b87ab7b11a34..89e071044ed7 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 9262f672d2eb..000000000000
--- 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 025000dcb911..9ae263cd549d 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 ) ) &&