[ooo-build-commit] Branch 'ooo/master' - 2 commits - desktop/win32 fpicker/source

Jan Holesovsky kendy at kemper.freedesktop.org
Tue Jul 7 17:59:25 PDT 2009


 desktop/win32/source/guistdio/guistdio.inc    |   75 +++++++++++++++++++++-----
 fpicker/source/aqua/AquaFilePickerDelegate.mm |    4 +
 2 files changed, 66 insertions(+), 13 deletions(-)

New commits:
commit 6493a402a5d2c5b86dc8b398cf02ddb42cab21fb
Author: Vladimir Glazounov <vg at openoffice.org>
Date:   Tue Jul 7 09:33:06 2009 +0000

    CWS-TOOLING: integrate CWS c27v001_DEV300
    2009-05-29 09:24:04 +0200 jl  r272433 : #102097# not using stl anymore
    2009-05-27 13:47:46 +0200 jl  r272340 : #i102097# make unopkg.com accept pipe input in console

diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc
index 6ee59c8..024b456 100644
--- a/desktop/win32/source/guistdio/guistdio.inc
+++ b/desktop/win32/source/guistdio/guistdio.inc
@@ -47,10 +47,6 @@
 
 #include <stdio.h>
 
-//---------------------------------------------------------------------------
-// Thread that reads from child process standard output pipe
-//---------------------------------------------------------------------------
-
 #ifdef UNOPKG
 
 DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
@@ -169,21 +165,76 @@ DWORD WINAPI ErrorThread( LPVOID pParam )
 // Thread that writes to child process standard input pipe
 //---------------------------------------------------------------------------
 #ifdef UNOPKG
+
 DWORD WINAPI InputThread( LPVOID pParam )
 {
-	const DWORD dwBufferSize = 256;
-	wchar_t	aBuffer[dwBufferSize];
 	DWORD	dwRead = 0;
 	HANDLE	hWritePipe = (HANDLE)pParam;
-		
-	while (ReadConsoleW( GetStdHandle( STD_INPUT_HANDLE ), &aBuffer, dwBufferSize, &dwRead, NULL ) )
+
+    //We need to read in the complete input until we encounter a new line before
+    //converting to Unicode. This is necessary because the input string can use
+    //characters of one, two, and more bytes. If the last character is not
+    //complete, then it will not be converted properly.
+
+    //Find out how a new line (0xd 0xa) looks like with the used code page.
+    //Characters may have one or multiple bytes and different byte ordering
+    //can be used (little and big endian);
+    int cNewLine = WideCharToMultiByte(
+        GetConsoleCP(), 0, L"\r\n", 2, NULL, 0, NULL, NULL);
+    char * mbBuff = new char[cNewLine];
+    WideCharToMultiByte(
+        GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, NULL, NULL);
+    
+    const size_t dwBufferSize = 256;
+    char* readBuf = (char*) malloc(dwBufferSize);
+    int readAll = 0;
+    size_t curBufSize = dwBufferSize;
+    
+    while ( ReadFile( GetStdHandle( STD_INPUT_HANDLE ),
+                      readBuf + readAll,
+                      curBufSize - readAll, &dwRead, NULL ) )
 	{
-		BOOL	fSuccess;
+        readAll += dwRead;
+        int lastBufSize = curBufSize;
+        //Grow the buffer if necessary
+        if (readAll > curBufSize * 0.7)
+        {
+            curBufSize *= 2;
+            readBuf = (char *) realloc(readBuf, curBufSize);
+        }
+        
+        //If the buffer was filled completely then 
+        //there could be more input coming. But if we read from the console
+        //and the console input fits exactly in the buffer, then the next
+        //ReadFile would block until the users presses return, etc.
+        //Therefor we check if last character is a new line.
+        //To test this, set dwBufferSize to 4 and enter "no". This should produce
+        //4 bytes with most code pages.
+        if ( readAll == lastBufSize
+             && memcmp(readBuf + lastBufSize - cNewLine, mbBuff, cNewLine) != 0)
+        {
+            //The buffer was completely filled and the last byte(s) are no
+            //new line, so there is more to come.
+            continue;
+        }
+        //Obtain the size of the buffer for the converted string.
+        int sizeWBuf = MultiByteToWideChar(
+            GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, NULL, 0);
+
+        wchar_t * wideBuf = new wchar_t[sizeWBuf];
+
+        //Do the conversion.
+        MultiByteToWideChar(
+            GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, wideBuf, sizeWBuf);
+        
+        BOOL	fSuccess;
 		DWORD	dwWritten;
-
-		fSuccess = WriteFile( hWritePipe, aBuffer, dwRead * 2, &dwWritten, NULL );
+        fSuccess = WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, NULL );
+        delete[] wideBuf;
+        readAll = 0;
 	}
-
+    delete[] mbBuff;
+    free(readBuf);
 	return 0;
 }
 #else
commit dea7992bc45efd9fa492b12b801033e8ca27bb15
Author: Vladimir Glazounov <vg at openoffice.org>
Date:   Tue Jul 7 07:40:36 2009 +0000

    CWS-TOOLING: integrate CWS ooo311gsl04_DEV300
    2009-06-25 18:59:25 +0200 pl  r273391 : add forgotten patch flags for cws: ooo311gsl01,ooo311gsl02,ooo311gsl03,ooo311gsl04,svp02,c28v001
    2009-06-25 18:05:10 +0200 pl  r273388 : CWS-TOOLING: rebase CWS ooo311gsl04 to branches/OOO310 at 272865 (milestone: OOO310:m13)
    2009-06-15 16:57:19 +0200 pl  r273001 : #i98804# check for nil
    2009-06-11 07:14:52 +0200 hdu  r272842 : #i102603# make rotated+shuffled text export work again

diff --git a/fpicker/source/aqua/AquaFilePickerDelegate.mm b/fpicker/source/aqua/AquaFilePickerDelegate.mm
index 2bece2d..7a55749 100644
--- a/fpicker/source/aqua/AquaFilePickerDelegate.mm
+++ b/fpicker/source/aqua/AquaFilePickerDelegate.mm
@@ -59,8 +59,10 @@
 
 - (MacOSBOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
 {
-    if (filterHelper == NULL)
+    if( filterHelper == NULL )
         return true;
+    if( filename == nil )
+        return false;
     return filterHelper->filenameMatchesFilter(filename);
 }
 


More information about the ooo-build-commit mailing list