[Libreoffice-commits] core.git: odk/examples

Hossein (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 11 22:09:38 UTC 2021


 odk/examples/cpp/DocumentLoader/DocumentLoader.cxx |   26 ++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit 0fc020fb73c86a20608e8dff12af607e60327379
Author:     Hossein <hossein at libreoffice.org>
AuthorDate: Tue Jun 29 20:24:59 2021 +0200
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Mon Jul 12 00:09:05 2021 +0200

    Cleaning up DocumentLoader C++ SDK example
    
    * Removing calls to C functions
    * Simplifying string usage
    
    Change-Id: Ia8ca329d7ad586d98e309809e430006eaac9eaaa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118131
    Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
    Tested-by: Thorsten Behrens <thorsten.behrens at allotropia.de>

diff --git a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
index 7e1f89cf3875..057a9e8152b0 100644
--- a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
+++ b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
@@ -34,9 +34,7 @@
  *************************************************************************/
 
 // Simple client application using the UnoUrlResolver service.
-#include <stdio.h>
-#include <wchar.h>
-
+#include <iostream>
 #include <sal/main.h>
 #include <cppuhelper/bootstrap.hxx>
 
@@ -51,8 +49,7 @@
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/registry/XSimpleRegistry.hpp>
 
-#include <string.h>
-
+using namespace std;
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::beans;
@@ -60,9 +57,7 @@ using namespace com::sun::star::bridge;
 using namespace com::sun::star::frame;
 using namespace com::sun::star::registry;
 
-using ::rtl::OUString;
-using ::rtl::OUStringToOString;
-
+using namespace rtl;
 
 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 {
@@ -72,8 +67,14 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 
     if (nCount < 1)
     {
-        printf("using: DocumentLoader -env:URE_MORE_TYPES=<office_types_rdb_url> <file_url> [<uno_connection_url>]\n\n"
-               "example: DocumentLoader -env:URE_MORE_TYPES=\"file:///.../program/offapi.rdb\" \"file:///e:/temp/test.odt\" \"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n");
+        cout << "using: DocumentLoader -env:URE_MORE_TYPES=<office_types_rdb_url> <file_url> "
+                "[<uno_connection_url>]"
+             << endl
+             << endl
+             << "example: DocumentLoader -env:URE_MORE_TYPES=\"file:///.../program/offapi.rdb\" "
+                "\"file:///e:/temp/test.odt\" "
+                "\"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\""
+             << endl;
         exit(1);
     }
      if (nCount == 2)
@@ -108,9 +109,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
     }
     catch ( Exception& e )
     {
-        printf("Error: cannot establish a connection using '%s':\n       %s\n",
-               OUStringToOString(sConnectionString, RTL_TEXTENCODING_ASCII_US).getStr(),
-               OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
+        cout << "Error: cannot establish a connection using "
+             << sConnectionString << endl << e.Message << endl;
         exit(1);
     }
 


More information about the Libreoffice-commits mailing list