Kaydet (Commit) f9632ab0 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

use init lists for property sequences

Change-Id: I8b3b2b839c37b584e1a4036e49af7ff2737ea7f6
üst caebcd5d
......@@ -68,6 +68,7 @@
#include <comphelper/interaction.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/property.hxx>
#include <comphelper/propertysequence.hxx>
#include <connectivity/conncleanup.hxx>
#include <connectivity/dbconversion.hxx>
#include <connectivity/dbexception.hxx>
......@@ -410,11 +411,10 @@ SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const R
xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
if (!sUser.isEmpty())
{ // use user and pwd together with the url
Sequence< PropertyValue> aInfo(2);
aInfo.getArray()[0].Name = "user";
aInfo.getArray()[0].Value <<= sUser;
aInfo.getArray()[1].Name = "password";
aInfo.getArray()[1].Value <<= sPwd;
auto aInfo(::comphelper::InitPropertySequence({
{ "user", makeAny(sUser) },
{ "password", makeAny(sPwd) }
}));
xPureConnection = xDriverManager->getConnectionWithInfo( sURL, aInfo );
}
else
......
/* -*- 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_PROPERTYSEQUENCE_HXX
#define INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
#include <utility>
#include <initializer_list>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
namespace comphelper
{
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > InitPropertySequence(
::std::initializer_list< ::std::pair< OUString, ::com::sun::star::uno::Any > > vInit)
{
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> vResult{static_cast<sal_Int32>(vInit.size())};
size_t nCount{0};
for(auto aEntry : vInit)
{
vResult[nCount].Name = std::move(aEntry.first);
vResult[nCount].Value = std::move(aEntry.second);
++nCount;
}
return std::move(vResult);
}
} // namespace comphelper
#endif // INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment