From 841c2c37e5186b2de0b075a03528f11d8b06c6a7 Mon Sep 17 00:00:00 2001
From: Mikhail Voytenko <mav@openoffice.org>
Date: Mon, 23 Aug 2010 19:20:31 +0200
Subject: mib19: #163018# allow to intercept the messages to the system child
 windows

---
 vcl/win/source/window/salobj.cxx | 50 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

(limited to 'vcl/win/source/window')

diff --git a/vcl/win/source/window/salobj.cxx b/vcl/win/source/window/salobj.cxx
index 2f657968284f..6d00242ef313 100644
--- a/vcl/win/source/window/salobj.cxx
+++ b/vcl/win/source/window/salobj.cxx
@@ -39,6 +39,7 @@
 #include <salframe.h>
 #include <salobj.h>
 #include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
 
 // =======================================================================
 
@@ -101,6 +102,46 @@ WinSalFrame* ImplFindSalObjectFrame( HWND hWnd )
     return pFrame;
 }
 
+// -----------------------------------------------------------------------
+
+sal_Bool ImplInterceptChildWindowKeyDown( MSG& rMsg )
+{
+    sal_Bool bResult = sal_False;
+    if ( rMsg.message == WM_KEYDOWN )
+    {
+        wchar_t pClassName[10];
+        sal_Int32 nLen = GetClassNameW( rMsg.hwnd, pClassName, 10 );
+        if ( !( nLen == 9 && wcsncmp( pClassName, SAL_OBJECT_CLASSNAMEW, nLen ) == 0 ) )
+        {
+            // look for the first SalObject in the parent hierarchy
+            HWND hWin = rMsg.hwnd;
+            HWND hLastOLEWindow = hWin;
+            WinSalObject* pSalObj = NULL;
+            do
+            {
+                hLastOLEWindow = hWin;
+                hWin = ::GetParent( hWin );
+                if ( hWin )
+                {
+                    nLen = GetClassNameW( hWin, pClassName, 10 );
+                    if ( nLen == 9 && wcsncmp( pClassName, SAL_OBJECT_CLASSNAMEW, nLen ) == 0 )
+                        pSalObj = GetSalObjWindowPtr( hWin );
+                }
+            } while( hWin && !pSalObj );
+
+            if ( pSalObj && pSalObj->mbInterceptChildWindowKeyDown && pSalObj->maSysData.hWnd )
+            {
+                bResult = ( 1 == ImplSendMessage( pSalObj->maSysData.hWnd, rMsg.message, rMsg.wParam, rMsg.lParam ) );
+            }
+        }
+    }
+
+    return bResult;
+}
+
+// -----------------------------------------------------------------------
+
+
 // -----------------------------------------------------------------------
 
 LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
@@ -623,6 +664,7 @@ WinSalObject::WinSalObject()
     mhLastFocusWnd  = 0;
     maSysData.nSize = sizeof( SystemEnvData );
     mpStdClipRgnData    = NULL;
+    mbInterceptChildWindowKeyDown = sal_False;
 
     // Insert object in objectlist
     mpNextObject = pSalData->mpFirstObject;
@@ -836,3 +878,11 @@ const SystemEnvData* WinSalObject::GetSystemData() const
 {
     return &maSysData;
 }
+
+// -----------------------------------------------------------------------
+
+void WinSalObject::InterceptChildWindowKeyDown( sal_Bool bIntercept )
+{
+    mbInterceptChildWindowKeyDown = bIntercept;
+}
+
-- 
cgit