[Libreoffice-commits] core.git: 4 commits - connectivity/source desktop/source include/comphelper

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Feb 23 09:02:45 PST 2015


 connectivity/source/commontools/dbtools.cxx                   |   10 +-
 desktop/source/deployment/registry/component/dp_component.cxx |   34 ++++----
 include/comphelper/propertysequence.hxx                       |   40 ++++++++++
 3 files changed, 64 insertions(+), 20 deletions(-)

New commits:
commit f9632ab04288909c9ff4de56171c31acb7f2c573
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Feb 23 02:38:18 2015 +0100

    use init lists for property sequences
    
    Change-Id: I8b3b2b839c37b584e1a4036e49af7ff2737ea7f6

diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index b385eb7..f5d564c 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -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
diff --git a/include/comphelper/propertysequence.hxx b/include/comphelper/propertysequence.hxx
new file mode 100644
index 0000000..ce28e4f
--- /dev/null
+++ b/include/comphelper/propertysequence.hxx
@@ -0,0 +1,40 @@
+/* -*- 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: */
commit caebcd5d12f8d2798f32f72fd0bcfdc12f9f2c4f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Fri Feb 20 01:55:12 2015 +0100

    related lp#1419836: provide decent error message
    
    Change-Id: I95387ae6b2ca8f49af87945954e4c418322860be

diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index b3ee90f..d859d04 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -1101,8 +1101,17 @@ Reference<XComponentContext> raise_uno_process(
     ::std::vector<OUString> bootvars = getCmdBootstrapVariables();
     args.insert(args.end(), bootvars.begin(), bootvars.end());
 
-    oslProcess hProcess = raiseProcess(
-        url, comphelper::containerToSequence(args) );
+    oslProcess hProcess;
+    try {
+        hProcess = raiseProcess(
+            url, comphelper::containerToSequence(args) );
+    }
+    catch (...) {
+        OUString sMsg = "error starting process: " + url;
+        for(auto arg : args)
+            sMsg += " " + arg;
+        throw uno::RuntimeException(sMsg);
+    }
     try {
         return Reference<XComponentContext>(
             resolveUnoURL( connectStr, xContext, abortChannel.get() ),
commit d30b8f9357e9eb505ebff133b24a3d1ce0bdd58f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Fri Feb 20 01:42:29 2015 +0100

    use initializer list
    
    Change-Id: Ie15b08a3bc08760d602f6b71ff30234aa4a03dca

diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 5502e43..b3ee90f 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -1087,15 +1087,15 @@ Reference<XComponentContext> raise_uno_process(
     // javavm service uses unorc next to executable to retrieve deployed
     // jar typelibs
 
-    ::std::vector<OUString> args;
+    ::std::vector<OUString> args{
 #if OSL_DEBUG_LEVEL == 0
-    args.push_back( "--quiet" );
+        "--quiet",
 #endif
-    args.push_back( "--singleaccept" );
-    args.push_back( "-u" );
-    args.push_back( connectStr );
-    // don't inherit from unorc:
-    args.push_back( "-env:INIFILENAME=" );
+        "--singleaccept",
+        "-u",
+        connectStr,
+        // don't inherit from unorc:
+        "-env:INIFILENAME=" };
 
     //now add the bootstrap variables which were supplied on the command line
     ::std::vector<OUString> bootvars = getCmdBootstrapVariables();
commit f8c745d1c060312c03fa020e52acd1337b6e81d9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Fri Feb 20 01:32:54 2015 +0100

    fdo#57950: skip verbose OUStringBuffer
    
    Change-Id: I151da82d4a7b3d2f00108bfcea444915d6b8e1da

diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 5a3cce3..5502e43 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -1081,12 +1081,7 @@ Reference<XComponentContext> raise_uno_process(
 
     OUString url( util::theMacroExpander::get(xContext)->expandMacros( "$URE_BIN_DIR/uno" ) );
 
-    OUStringBuffer buf;
-    buf.appendAscii( "uno:pipe,name=" );
-    OUString pipeId( generateRandomPipeId() );
-    buf.append( pipeId );
-    buf.appendAscii( ";urp;uno.ComponentContext" );
-    const OUString connectStr( buf.makeStringAndClear() );
+    const OUString connectStr = "uno:pipe,name=" + generateRandomPipeId() + ";urp;uno.ComponentContext";
 
     // raise core UNO process to register/run a component,
     // javavm service uses unorc next to executable to retrieve deployed


More information about the Libreoffice-commits mailing list