diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-22 23:29:40 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-23 06:20:41 +0100 |
commit | 6960d0809e72e1edc758317723452735c918d4d9 (patch) | |
tree | 2b94f01598a4cda6f88c95c57201a11f84afd2f1 /desktop | |
parent | 9a1610f8290f723e801864f9037d4467efd02d1a (diff) |
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@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/dp_misc.h | 12 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_misc.cxx | 40 | ||||
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_app.cxx | 2 |
3 files changed, 12 insertions, 42 deletions
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" |