Commits

Anonymous committed 2b1dbee

CWS-TOOLING: integrate CWS ooo31gsl4_DEV300
2009-03-11 16:07:53 +0100 gh r269340 : missed compile on bigendian system (OSL_BIGENDIAN defined)
2009-03-11 10:22:27 +0100 pl r269300 : #i100057# one more case
2009-03-10 15:10:01 +0100 pl r269274 : #i100057# filter formatting marks in vcl i18n helper
2009-03-10 13:31:01 +0100 gh r269269 : #i100044#remove BiDi markers before sending to VCLTestTool
2009-03-10 10:16:05 +0100 hdu r269248 : #i100057# fix casefolding::getNextChar() end-of-string behaviour
2009-03-10 09:51:36 +0100 hdu r269245 : #i100044# add TransliterationModules_IGNORE_FORMATTING option
2009-03-09 14:30:00 +0100 pl r269176 : #i99360# workaround XIfEvent never returning

  • Participants
  • Parent commits 5c30191

Comments (0)

Files changed (10)

automation/source/server/cmdbasestream.cxx

 
 void CmdBaseStream::Write( const comm_UniChar* aString, comm_USHORT nLenInChars )
 {
-	*pCommStream << comm_USHORT(BinString);
-	*pCommStream << nLenInChars;
+    *pCommStream << comm_USHORT(BinString);
+
+    comm_USHORT n;
+
+    // remove BiDi and zero-width-markers    0x200B - 0x200F 
+    // remove BiDi and paragraph-markers     0x2028 - 0x202E
+
+    comm_UniChar* aNoBiDiString;
+    aNoBiDiString = new comm_UniChar [nLenInChars];
+    comm_USHORT nNewLenInChars = 0;
+    for ( n = 0 ; n < nLenInChars ; n++ )
+    {
+        comm_UniChar c = aString[ n ];
+        if (  ((c >= 0x200B) && (c <= 0x200F))
+            ||((c >= 0x2028) && (c <= 0x202E)) )
+        {   //Ignore character
+        }
+        else
+        {
+            aNoBiDiString[ nNewLenInChars ] = c;
+            nNewLenInChars++;
+        }
+    }
+
+	*pCommStream << nNewLenInChars;
+
 #ifdef OSL_BIGENDIAN
     // we have to change the byteorder
     comm_UniChar* aNewString;
-    aNewString = new comm_UniChar [nLenInChars];
-    comm_USHORT n;
-    for ( n = 0 ; n < nLenInChars ; n++ )
-        aNewString[ n ] = aString[ n ] >> 8 | aString[ n ] << 8;
-	pCommStream->Write( aNewString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) );
+    aNewString = new comm_UniChar [nNewLenInChars];
+    for ( n = 0 ; n < nNewLenInChars ; n++ )
+        aNewString[ n ] = aNoBiDiString[ n ] >> 8 | aNoBiDiString[ n ] << 8;
+	pCommStream->Write( aNewString, ((comm_ULONG)nNewLenInChars) * sizeof( comm_UniChar ) );
     delete [] aNewString;
 #else
-    pCommStream->Write( aString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) );
+    pCommStream->Write( aNoBiDiString, ((comm_ULONG)nNewLenInChars) * sizeof( comm_UniChar ) );
 #endif
+
+    delete [] aNoBiDiString;
 }
 
 void CmdBaseStream::Write( comm_BOOL bBool )

i18nutil/source/utility/casefolding.cxx

 
 sal_Unicode casefolding::getNextChar(const sal_Unicode *str, sal_Int32& idx, sal_Int32 len, MappingElement& e, Locale& aLocale, sal_uInt8 nMappingType, TransliterationModules moduleLoaded) throw (RuntimeException)
 {
+        if( idx >= len )
+            return 0;
+
         sal_Unicode c;
+
         if (moduleLoaded & TransliterationModules_IGNORE_CASE) {
-            if (e.current >= e.element.nmap && idx < len ) {
+            if( e.current >= e.element.nmap ) {
                 e.element = getValue(str, idx++, len, aLocale, nMappingType);
                 e.current = 0;
             }
         } else {
             c = *(str + idx++);
         }
+
         if (moduleLoaded & TransliterationModules_IGNORE_KANA) {
             if (0x3040 <= c && c <= 0x3094 || 0x309d <= c && c <= 0x309f)
                 c += 0x60;
                     is_ja_voice_sound_mark(c, half2fullTable[*(str + idx)]))
                 idx++;
         }
+
         return c;
 }
 
 } } } }
+

vcl/inc/vcl/i18nhelp.hxx

 
     String      GetDate( const Date& rDate ) const;
     String      GetNum( long nNumber, USHORT nDecimals, BOOL bUseThousandSep = TRUE, BOOL bTrailingZeros = TRUE ) const;
+    
+    static String filterFormattingChars( const String& );
 };
 
 }	// namespace vcl

vcl/source/app/i18nhelp.cxx

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_vcl.hxx"
 
+#include "vcl/i18nhelp.hxx"
 
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/i18n/TransliterationModules.hpp"
+#include "unotools/localedatawrapper.hxx"
+#include "unotools/transliterationwrapper.hxx"
+#include "i18npool/mslangid.hxx"
 
-#include <vcl/i18nhelp.hxx>
-
-/*
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-
-#include <comphelper/processfactory.hxx>
-*/
-
-// #include <cppuhelper/servicefactory.hxx>
-
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/i18n/TransliterationModules.hpp>
-#include <unotools/localedatawrapper.hxx>
-#include <unotools/transliterationwrapper.hxx>
-#include <i18npool/mslangid.hxx>
+#include "rtl/ustrbuf.hxx"
 
 using namespace ::com::sun::star;
 
     return maLocale; 
 }
 
+inline bool is_formatting_mark( sal_Unicode c )
+{
+	if( (c >= 0x200B) && (c <= 0x200F) )	// BiDi and zero-width-markers
+		return true;
+	if( (c >= 0x2028) && (c <= 0x202E) )	// BiDi and paragraph-markers
+		return true;
+	return false;
+}
+
+/* #i100057# filter formatting marks out of strings before passing them to
+   the transliteration. The real solution would have been an additional TransliterationModule
+   to ignore these marks during transliteration; however changin the code in i18npool that actually
+   implements this could produce unwanted side effects.
+   
+   Of course this copying around is not really good, but looking at i18npool, one more time
+   will not hurt.
+*/
+String vcl::I18nHelper::filterFormattingChars( const String& rStr )
+{
+    sal_Int32 nUnicodes = rStr.Len();
+    rtl::OUStringBuffer aBuf( nUnicodes );
+    const sal_Unicode* pStr = rStr.GetBuffer();
+    while( nUnicodes-- )
+    {
+        if( ! is_formatting_mark( *pStr ) )
+            aBuf.append( *pStr );
+        pStr++;
+    }
+    return aBuf.makeStringAndClear();
+}
+
 sal_Int32 vcl::I18nHelper::CompareString( const String& rStr1, const String& rStr2 ) const
 {
 	::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex );
         ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL;
     }
 
-    return ImplGetTransliterationWrapper().compareString( rStr1, rStr2 );
+    
+    String aStr1( filterFormattingChars(rStr1) );
+    String aStr2( filterFormattingChars(rStr2) );
+    return ImplGetTransliterationWrapper().compareString( aStr1, aStr2 );
 }
 
 sal_Bool vcl::I18nHelper::MatchString( const String& rStr1, const String& rStr2 ) const
         ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL;
     }
 
-    return ImplGetTransliterationWrapper().isMatch( rStr1, rStr2 );
+    String aStr1( filterFormattingChars(rStr1) );
+    String aStr2( filterFormattingChars(rStr2) );
+    return ImplGetTransliterationWrapper().isMatch( aStr1, aStr2 );
 }
 
 sal_Bool vcl::I18nHelper::MatchMnemonic( const String& rString, sal_Unicode cMnemonicChar ) const

vcl/source/control/ilstbox.cxx

     for ( USHORT n = bSearchMRUArea ? 0 : GetMRUCount(); n < nEntries; n++ )
 	{
 		ImplEntryType* pImplEntry = GetEntry( n );
-        if ( pImplEntry->maStr == rString )
+        String aComp( vcl::I18nHelper::filterFormattingChars( pImplEntry->maStr ) );
+        if ( aComp == rString )
             return n;
     }
     return LISTBOX_ENTRY_NOTFOUND;

vcl/unx/gtk/window/gtkframe.cxx

     {
         guint32 nUserTime = 0;
         if( (nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_TOOLWINDOW)) == 0 )
-            nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
+        {
+            /* #i99360# ugly workaround an X11 library bug */
+            nUserTime= getDisplay()->GetLastUserEventTime( true );
+            // nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
+        }
         lcl_set_user_time(GTK_WIDGET(m_pWindow)->window, nUserTime);
     }
 
 
             guint32 nUserTime = 0;
             if( ! bNoActivate && (m_nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_TOOLWINDOW)) == 0 )
-                nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
+                /* #i99360# ugly workaround an X11 library bug */
+                nUserTime= getDisplay()->GetLastUserEventTime( true );
+                //nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
 
             //For these floating windows we don't want the main window to lose focus, and metacity has...
             // metacity-2.24.0/src/core/window.c
                )
               )
             {
-                nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
+                /* #i99360# ugly workaround an X11 library bug */
+                nUserTime= getDisplay()->GetLastUserEventTime( true );
+                //nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
             }
 
             lcl_set_user_time( GTK_WIDGET(m_pWindow)->window, nUserTime );
             if( ! (nFlags & SAL_FRAME_TOTOP_GRABFOCUS_ONLY) )
                 gtk_window_present( GTK_WINDOW(m_pWindow) );
             else
-                gdk_window_focus( m_pWindow->window, gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window) );
+            {
+                // gdk_window_focus( m_pWindow->window, gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window) );
+                /* #i99360# ugly workaround an X11 library bug */
+                guint32 nUserTime= getDisplay()->GetLastUserEventTime( true );
+                gdk_window_focus( m_pWindow->window, nUserTime );
+            }
             /*  need to do an XSetInputFocus here because
              *  gdk_window_focus will ask a EWMH compliant WM to put the focus
              *  to our window - which it of course won't since our input hint

vcl/unx/inc/saldisp.hxx

 extern "C" {
     struct SnDisplay;
     struct SnLauncheeContext;
+    typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer);
 }
 
 class VCL_DLLPUBLIC SalDisplay
     bool			GetExactResolution() const { return mbExactResolution; }
 	ULONG			GetProperties() const { return nProperties_; }
 	ULONG			GetMaxRequestSize() const { return nMaxRequestSize_; }
-    XLIB_Time       GetLastUserEventTime() const;
+    XLIB_Time       GetLastUserEventTime( bool bAlwaysReget = false ) const;
+    
+    bool            XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate, long i_nTimeout = 1000 ) const;
 
 	BOOL			MouseCaptured( const SalFrame *pFrameData ) const
     { return m_pCapture == pFrameData; }

vcl/unx/inc/salgdi.h

      *  it is imperative to eat up graphics exposes even in case you don't need
      *  them because the next one using XCopyArea can depend on them
      */
-    static void YieldGraphicsExpose( Display* pDisplay, SalFrame* pFrame, Drawable aDrawable );
+    void YieldGraphicsExpose();
 
     // do XCopyArea or XGet/PutImage depending on screen numbers
     // signature is like XCopyArea with screen numbers added

vcl/unx/source/app/saldisp.cxx

 #include <dtint.hxx>
 
 #include <osl/socket.h>
+#include <poll.h>
 
 using namespace rtl;
 using namespace vcl_sal;
         m_pWMAdaptor( NULL ),
         m_pDtIntegrator( NULL ),
         m_bUseRandRWrapper( true ),
-        m_nLastUserEventTime( 0 )
+        m_nLastUserEventTime( CurrentTime )
 {
 #if OSL_DEBUG_LEVEL > 1
     fprintf( stderr, "SalDisplay::SalDisplay()\n" );
     }
 }
 
-XLIB_Time SalDisplay::GetLastUserEventTime() const
+XLIB_Time SalDisplay::GetLastUserEventTime( bool i_bAlwaysReget ) const
 {
-    if( m_nLastUserEventTime == 0 )
+    if( m_nLastUserEventTime == CurrentTime || i_bAlwaysReget )
     {
         // get current server time
         unsigned char c = 0;
         Atom nAtom = getWMAdaptor()->getAtom( WMAdaptor::SAL_GETTIMEEVENT );
         XChangeProperty( GetDisplay(), GetDrawable( GetDefaultScreenNumber() ),
                          nAtom, nAtom, 8, PropModeReplace, &c, 1 );
-        XIfEvent( GetDisplay(), &aEvent, timestamp_predicate, (XPointer)this );
+        XFlush( GetDisplay() );
+
+        if( ! XIfEventWithTimeout( &aEvent, (XPointer)this, timestamp_predicate ) )
+        {
+            // this should not happen at all; still sometimes it happens
+            aEvent.xproperty.time = CurrentTime;
+        }
+
         m_nLastUserEventTime = aEvent.xproperty.time;
     }
     return m_nLastUserEventTime;
 }
 
+bool SalDisplay::XIfEventWithTimeout( XEvent* o_pEvent, XPointer i_pPredicateData,
+                                      X_if_predicate i_pPredicate, long i_nTimeout ) const
+{
+    /* #i99360# ugly workaround an X11 library bug
+       this replaces the following call:
+       XIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData );
+    */
+    bool bRet = true;
+
+    if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) )
+    {
+        // wait for some event to arrive
+        struct pollfd aFD;
+        aFD.fd = ConnectionNumber(GetDisplay());
+        aFD.events = POLLIN;
+        aFD.revents = 0;
+        poll( &aFD, 1, i_nTimeout );
+        if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) )
+        {
+            poll( &aFD, 1, i_nTimeout ); // try once more for a packet of events from the Xserver
+            if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) )
+            {
+                bRet = false;
+            }
+        }
+    }
+    return bRet;
+}
+
 // -=-= SalVisual -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 SalVisual::SalVisual()

vcl/unx/source/gdi/salgdi2.cxx

 }
 
 
-void X11SalGraphics::YieldGraphicsExpose( Display* pDisplay, SalFrame* pFrame, Drawable aWindow )
+void X11SalGraphics::YieldGraphicsExpose()
 {
     // get frame if necessary
+    SalFrame* pFrame    = m_pFrame;
+    Display* pDisplay   = GetXDisplay();
+    XLIB_Window aWindow = GetDrawable();
     if( ! pFrame )
     {
         const std::list< SalFrame* >& rFrames = GetX11SalData()->GetDisplay()->getFrames();
 
     do
     {
-        if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) )
-        {
-            // wait for some event to arrive
-            struct pollfd aFD;
-            aFD.fd = ConnectionNumber(pDisplay);
-            aFD.events = POLLIN;
-            aFD.revents = 0;
-            poll( &aFD, 1, 1000 );
-            if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) )
-            {
-                poll( &aFD, 1, 1000 ); // try once more for a packet of events from the Xserver
-                if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) )
-                {
-                    // this should not happen at all; still sometimes it happens
-                    break;
-                }
-            }
-        }
+        if( ! GetDisplay()->XIfEventWithTimeout( &aEvent, (XPointer)aWindow, GraphicsExposePredicate ) )
+            // this should not happen at all; still sometimes it happens
+            break;
+
         if( aEvent.type == NoExpose )
             break;
 
 
         if( bNeedGraphicsExposures )
         {
-            YieldGraphicsExpose( GetXDisplay(), m_pFrame, GetDrawable() );
+            YieldGraphicsExpose();
 
             if( pCopyGC )
                 XSetGraphicsExposures( GetXDisplay(),