office-gobmx/include/comphelper/propertyvalue.hxx
Stephan Bergmann 1fc79c3491 Avoid using O[U]StringConcat lvalues containing dangling refs to temporaries
...in code accidentally using auto like

> auto const aURL = uri->getUriReference() + "/"
>     + INetURLObject::encode(
>         m_sEmbeddedName, INetURLObject::PART_FPATH,
>         INetURLObject::EncodeMechanism::All);
>
> uno::Reference<uno::XInterface> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY);

in <https://gerrit.libreoffice.org/#/c/44569/1> "Properly construct
vnd.sun.star.pkg URL" did (causing hard to debug test failures there).

So make functions taking O[U]StringConcat take those by rvalue reference.
Unfortunately, that also needed adaption of various functions that just forward
their arguments.  And some code in sc/qa/unit/ucalc_formula.cxx used
CPPUNIT_ASSERT_EQUAL on OUStringConcat arguments in cases where that happened to
actually compile (because the structure of the two OUStringConcats was
identical), which needed adaption too (but which would arguably better use
CPPUNIT_ASSERT_EQUAL_MESSAGE, anyway).

Change-Id: I8994d932aaedb2a491c7c81c167e93379d4fb6e3
Reviewed-on: https://gerrit.libreoffice.org/44608
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-11 00:03:37 +01:00

41 lines
1.1 KiB
C++

/* -*- 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/.
*/
#ifndef INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
#define INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
#include <sal/config.h>
#include <utility>
#include <com/sun/star/beans/PropertyValue.hpp>
namespace comphelper
{
/**
* Creates a beans::PropertyValue easily, i.e. you can write:
*
* function(comphelper::makePropertyValue("Foo", nBar));
*
* instead of writing 3 extra lines to set the name and value of the beans::PropertyValue.
*/
template<typename T> css::beans::PropertyValue makePropertyValue(const OUString& rName, T&& rValue)
{
css::beans::PropertyValue aValue;
aValue.Name = rName;
aValue.Value = css::uno::toAny(std::forward<T>(rValue));
return aValue;
}
}
#endif // INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */