[Libreoffice-commits] core.git: desktop/inc desktop/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Jan 23 05:21:17 UTC 2020


 desktop/inc/dp_misc.h                       |   12 +++-----
 desktop/source/deployment/misc/dp_misc.cxx  |   40 ++++------------------------
 desktop/source/pkgchk/unopkg/unopkg_app.cxx |    2 -
 3 files changed, 12 insertions(+), 42 deletions(-)

New commits:
commit 6960d0809e72e1edc758317723452735c918d4d9
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Jan 22 23:29:40 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Jan 23 06:20:41 2020 +0100

    Use crt functions for IO in unopkg on Windows
    
    Since https://gerrit.libreoffice.org/c/core/+/87210, the workaround
    using WinAPI is not needed anymore, so this unifies Windows behavior
    with other platforms.
    
    Change-Id: I0fa46b6b98a03a7e4d2fd1347b05c15b8f142607
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87221
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/desktop/inc/dp_misc.h b/desktop/inc/dp_misc.h
index 1ed5b3e5e1ce..3f4b07bc8790 100644
--- a/desktop/inc/dp_misc.h
+++ b/desktop/inc/dp_misc.h
@@ -108,10 +108,8 @@ oslProcess raiseProcess( OUString const & appURL,
 
 
 /** writes the argument string to the console.
-    On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using
-    osl_getThreadTextEncoding() as target encoding. On Windows it uses WriteFile
-    with the standard out stream. unopkg.com reads the data and prints them out using
-    WriteConsoleW.
+    It converts the UTF16 string to an ANSI string using osl_getThreadTextEncoding()
+    as target encoding.
 */
 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
 void writeConsole(OUString const & sText);
@@ -124,9 +122,9 @@ void writeConsoleError(OUString const & sText);
 
 
 /** reads from the console.
-    On Linux/Unix/etc. it uses fgets to read char values and converts them to OUString
-    using osl_getThreadTextEncoding as target encoding. The returned string has a maximum
-    size of 1024 and does NOT include leading and trailing white space(applied OUString::trim())
+    It uses fgets to read char values and converts them to OUString using
+    osl_getThreadTextEncoding as target encoding. The returned string has a maximum size of
+    1024 and does NOT include leading and trailing white space(applied OUString::trim())
 */
 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
 OUString readConsole();
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index baa5e716f4bd..bf1c1ced465b 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -48,8 +48,8 @@
 #include <salhelper/linkhelper.hxx>
 
 #ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include <prewin.h>
+#include <postwin.h>
 #endif
 
 using namespace ::com::sun::star;
@@ -57,6 +57,7 @@ using namespace ::com::sun::star::uno;
 
 #if defined(_WIN32)
 #define SOFFICE1 "soffice.exe"
+#define SOFFICE_COM "soffice.com"
 #define SBASE "sbase.exe"
 #define SCALC "scalc.exe"
 #define SDRAW "sdraw.exe"
@@ -357,12 +358,12 @@ bool office_is_running()
         if (
 #if defined UNIX
             sFile == SOFFICE2
-#elif defined WNT
+#elif defined _WIN32
             //osl_getExecutableFile should deliver "soffice.bin" on windows
             //even if swriter.exe, scalc.exe etc. was started. This is a bug
             //in osl_getExecutableFile
-            sFile == SOFFICE1 || sFile == SOFFICE2 || sFile == SBASE || sFile == SCALC
-            || sFile == SDRAW || sFile == SIMPRESS || sFile == SWRITER
+            sFile == SOFFICE1 || sFile == SOFFICE2 || sFile == SOFFICE_COM || sFile == SBASE ||
+            sFile == SCALC || sFile == SDRAW || sFile == SIMPRESS || sFile == SWRITER
 #else
 #error "Unsupported platform"
 #endif
@@ -464,53 +465,25 @@ Reference<XInterface> resolveUnoURL(
     return nullptr; // warning C4715
 }
 
-#ifdef _WIN32
-static void writeConsoleWithStream(OUString const & sText, HANDLE stream)
-{
-    DWORD nWrittenChars = 0;
-    WriteFile(stream, sText.getStr(),
-        sText.getLength() * 2, &nWrittenChars, nullptr);
-}
-#else
 static void writeConsoleWithStream(OUString const & sText, FILE * stream)
 {
     OString s = OUStringToOString(sText, osl_getThreadTextEncoding());
     fprintf(stream, "%s", s.getStr());
     fflush(stream);
 }
-#endif
 
 void writeConsole(OUString const & sText)
 {
-#ifdef _WIN32
-    writeConsoleWithStream(sText, GetStdHandle(STD_OUTPUT_HANDLE));
-#else
     writeConsoleWithStream(sText, stdout);
-#endif
 }
 
 void writeConsoleError(OUString const & sText)
 {
-#ifdef _WIN32
-    writeConsoleWithStream(sText, GetStdHandle(STD_ERROR_HANDLE));
-#else
     writeConsoleWithStream(sText, stderr);
-#endif
 }
 
 OUString readConsole()
 {
-#ifdef _WIN32
-    sal_Unicode aBuffer[1024];
-    DWORD   dwRead = 0;
-    //unopkg.com feeds unopkg.exe with wchar_t|s
-    if (ReadFile( GetStdHandle(STD_INPUT_HANDLE), &aBuffer, sizeof(aBuffer), &dwRead, nullptr ) )
-    {
-        OSL_ASSERT((dwRead % 2) == 0);
-        OUString value( aBuffer, dwRead / 2);
-        return value.trim();
-    }
-#else
     char buf[1024];
     memset(buf, 0, 1024);
     // read one char less so that the last char in buf is always zero
@@ -519,7 +492,6 @@ OUString readConsole()
         OUString value = OStringToOUString(OString(buf), osl_getThreadTextEncoding());
         return value.trim();
     }
-#endif
     throw css::uno::RuntimeException("reading from stdin failed");
 }
 
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index 443ccdbe842b..1f2429000152 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -90,7 +90,7 @@ const char s_usingText [] =
 "\n"
 "sub-commands:\n"
 " add                     add extension\n"
-" validate                checks the prerequisites of an installed extension and"
+" validate                checks the prerequisites of an installed extension and\n"
 "                         registers it if possible\n"
 " remove                  remove extensions by identifier\n"
 " reinstall               expert feature: reinstall all deployed extensions\n"


More information about the Libreoffice-commits mailing list