Skip to content

Commit

Permalink
Delete the "Any-to-Any" template specializations for LIBO_INTERNAL_ONLY
Browse files Browse the repository at this point in the history
i.e., css::uno::Any function template specializations

  Any::has<Any>() const
  Any::get(Any const &) const
  operator >>=(Any const &, Any &)
  operator <<=(Any &, Any const &)

that don't make much sense (the first is always true, the rest can be replaced
with operator =, which additionally supports move semantics).  For 3rd-party
compatibility, do this only for LIBO_INTERNAL_ONLY, however.

However, some generic template code did benefit from operator >>= working also
for Any, so make up for that with a new (LIBO_INTERNAL_ONLY, given that
operator >>= still covers if fine for !LIBO_INTERNAL_ONLY) fromAny,
complementing the existing toAny.

Change-Id: I8b1b5f803f0b909808159916366d53c948206a88
Reviewed-on: https://gerrit.libreoffice.org/30022
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
  • Loading branch information
stbergmann committed Nov 21, 2016
1 parent 05d175a commit bd614b9
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 93 deletions.
10 changes: 6 additions & 4 deletions codemaker/source/cppumaker/cpputype.cxx
Expand Up @@ -3621,10 +3621,12 @@ void ServiceType::dumpHppFile(
u2b(j.name), "param",
codemaker::cpp::IdentifierTranslationMode::NonGlobal));
sal_Int32 rank;
if (m_typeMgr->getSort(
b2u(codemaker::UnoType::decompose(
u2b(j.type), &rank)))
== codemaker::UnoType::Sort::Char)
if (resolveOuterTypedefs(j.type) == "any") {
o << "= " << param;
} else if (m_typeMgr->getSort(
b2u(codemaker::UnoType::decompose(
u2b(j.type), &rank)))
== codemaker::UnoType::Sort::Char)
{
o << "= ::css::uno::Any(&" << param
<< ", ::cppu::UnoType< ";
Expand Down
2 changes: 1 addition & 1 deletion comphelper/qa/unit/variadictemplates.cxx
Expand Up @@ -43,7 +43,7 @@ inline void extract(
OUString( "No such argument available!"),
xErrorContext, static_cast<sal_Int16>(nArg) );
}
if (! (seq[nArg] >>= v)) {
if (! fromAny(seq[nArg], &v)) {
OUStringBuffer buf;
buf.append( "Cannot extract ANY { " );
buf.append( seq[nArg].getValueType().getTypeName() );
Expand Down
26 changes: 26 additions & 0 deletions cppu/CppunitTest_cppu_any-external.mk
@@ -0,0 +1,26 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#

$(eval $(call gb_CppunitTest_CppunitTest,cppu_any-external))

$(eval $(call gb_CppunitTest_add_exception_objects,cppu_any-external, \
cppu/qa/any-external \
))

$(eval $(call gb_CppunitTest_set_external_code,cppu_any-external))

$(eval $(call gb_CppunitTest_use_libraries,cppu_any-external, \
cppu \
sal \
$(gb_UWINAPI) \
))

$(eval $(call gb_CppunitTest_use_udk_api,cppu_any-external))

# vim: set noet sw=4 ts=4:
1 change: 1 addition & 0 deletions cppu/Module_cppu.mk
Expand Up @@ -21,6 +21,7 @@ $(eval $(call gb_Module_add_targets,cppu,\
))

$(eval $(call gb_Module_add_check_targets,cppu,\
CppunitTest_cppu_any-external \
CppunitTest_cppu_qa_any \
CppunitTest_cppu_qa_recursion \
CppunitTest_cppu_qa_reference \
Expand Down
63 changes: 63 additions & 0 deletions cppu/qa/any-external.cxx
@@ -0,0 +1,63 @@
/* -*- 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 <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>

#include <com/sun/star/uno/Any.hxx>
#include <sal/types.h>

namespace {

class Test: public CppUnit::TestFixture {
private:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testGet);
CPPUNIT_TEST(testHas);
CPPUNIT_TEST(testExtract);
CPPUNIT_TEST(testInsert);
CPPUNIT_TEST_SUITE_END();

void testGet() {
css::uno::Any a(false);
CPPUNIT_ASSERT_EQUAL(a, a.get<css::uno::Any>());
CPPUNIT_ASSERT_EQUAL(false, a.get<bool>());
}

void testHas() {
css::uno::Any a(false);
CPPUNIT_ASSERT_EQUAL(true, a.has<css::uno::Any>());
CPPUNIT_ASSERT_EQUAL(true, a.has<bool>());
}

void testExtract() {
css::uno::Any a1(false);
css::uno::Any a2;
CPPUNIT_ASSERT(a1 >>= a2);
CPPUNIT_ASSERT_EQUAL(a1, a2);
}

void testInsert() {
css::uno::Any a;
a <<= css::uno::Any(false);
CPPUNIT_ASSERT_EQUAL(css::uno::Any(false), a);
}
};

CPPUNIT_TEST_SUITE_REGISTRATION(Test);

}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
80 changes: 0 additions & 80 deletions cppu/qa/test_any.cxx
Expand Up @@ -286,10 +286,6 @@ void Test::testVoid() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -376,10 +372,6 @@ void Test::testBoolean() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -471,10 +463,6 @@ void Test::testByte() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -566,10 +554,6 @@ void Test::testShort() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -663,10 +647,6 @@ void Test::testUnsignedShort() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -754,10 +734,6 @@ void Test::testLong() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -845,10 +821,6 @@ void Test::testUnsignedLong() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -936,10 +908,6 @@ void Test::testHyper() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1027,10 +995,6 @@ void Test::testUnsignedHyper() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1118,10 +1082,6 @@ void Test::testFloat() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1209,10 +1169,6 @@ void Test::testDouble() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1305,10 +1261,6 @@ void Test::testChar() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1396,10 +1348,6 @@ void Test::testString() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1486,10 +1434,6 @@ void Test::testType() {
CPPUNIT_ASSERT_MESSAGE(
"css::uno::Type", (a >>= b) && b == cppu::UnoType<sal_Int32>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1580,10 +1524,6 @@ void Test::testSequence() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1677,10 +1617,6 @@ void Test::testEnum() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1772,10 +1708,6 @@ void Test::testStruct() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1888,10 +1820,6 @@ void Test::testException() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -1998,10 +1926,6 @@ void Test::testInterface() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down Expand Up @@ -2106,10 +2030,6 @@ void Test::testNull() {
"css::uno::Type",
!(a >>= b) && b == cppu::UnoType<OUString>::get());
}
{
css::uno::Any b(rtl::OUString("2"));
CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a);
}
{
css::uno::Sequence< rtl::OUString > b(2);
CPPUNIT_ASSERT_MESSAGE(
Expand Down
3 changes: 1 addition & 2 deletions fpicker/source/win32/filepicker/VistaFilePicker.cxx
Expand Up @@ -304,8 +304,7 @@ css::uno::Any SAL_CALL VistaFilePicker::getValue(::sal_Int16 nControlId ,
rRequest->setArgument(PROP_CONTROL_ACTION, nControlAction);

m_aAsyncExecute.triggerRequestThreadAware(rRequest, AsyncRequests::BLOCKED);
const css::uno::Any aValue = rRequest->getArgumentOrDefault(PROP_CONTROL_VALUE, css::uno::Any());
return aValue;
return rRequest->getValue(PROP_CONTROL_VALUE);
}

void SAL_CALL VistaFilePicker::enableControl(::sal_Int16 nControlId,
Expand Down
2 changes: 1 addition & 1 deletion fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
Expand Up @@ -1055,7 +1055,7 @@ void VistaFilePickerImpl::impl_sta_SetControlValue(const RequestRef& rRequest)
{
::sal_Int16 nId = rRequest->getArgumentOrDefault(PROP_CONTROL_ID , INVALID_CONTROL_ID );
::sal_Int16 nAction = rRequest->getArgumentOrDefault(PROP_CONTROL_ACTION, INVALID_CONTROL_ACTION);
css::uno::Any aValue = rRequest->getArgumentOrDefault(PROP_CONTROL_VALUE , css::uno::Any() );
css::uno::Any aValue = rRequest->getValue(PROP_CONTROL_VALUE);

// don't check for right values here ...
// most parameters are optional !
Expand Down
4 changes: 4 additions & 0 deletions fpicker/source/win32/filepicker/asyncrequests.hxx
Expand Up @@ -94,6 +94,10 @@ class Request
return m_lArguments.getUnpackedValueOrDefault(sName, aDefault);
}

css::uno::Any getValue(OUString const & key) const
{
return m_lArguments.getValue(key);
}

void wait(::sal_Int32 nMilliSeconds = WAIT_INFINITE);

Expand Down

0 comments on commit bd614b9

Please sign in to comment.