1*323de322SAndrew Rist/**************************************************************
2cdf0e10cSrcweir *
3*323de322SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*323de322SAndrew Rist * or more contributor license agreements.  See the NOTICE file
5*323de322SAndrew Rist * distributed with this work for additional information
6*323de322SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
7*323de322SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*323de322SAndrew Rist * "License"); you may not use this file except in compliance
9*323de322SAndrew Rist * with the License.  You may obtain a copy of the License at
10*323de322SAndrew Rist *
11*323de322SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
12*323de322SAndrew Rist *
13*323de322SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*323de322SAndrew Rist * software distributed under the License is distributed on an
15*323de322SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*323de322SAndrew Rist * KIND, either express or implied.  See the License for the
17*323de322SAndrew Rist * specific language governing permissions and limitations
18*323de322SAndrew Rist * under the License.
19*323de322SAndrew Rist *
20*323de322SAndrew Rist *************************************************************/
21*323de322SAndrew Rist
22*323de322SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir// MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir#include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir#include <sal/alloca.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir#include "vcl/window.hxx"
30cdf0e10cSrcweir#include "vcl/svapp.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir#include "aqua/salinst.h"
33cdf0e10cSrcweir#include "aqua/salgdi.h"
34cdf0e10cSrcweir#include "aqua/salframe.h"
35cdf0e10cSrcweir#include "aqua/salframeview.h"
36cdf0e10cSrcweir#include "aqua/aqua11yfactory.h"
37cdf0e10cSrcweir
38cdf0e10cSrcweir#define WHEEL_EVENT_FACTOR 1.5
39cdf0e10cSrcweir
40cdf0e10cSrcweirstatic sal_uInt16 ImplGetModifierMask( unsigned int nMask )
41cdf0e10cSrcweir{
42cdf0e10cSrcweir    sal_uInt16 nRet = 0;
43cdf0e10cSrcweir    if( (nMask & NSShiftKeyMask) != 0 )
44cdf0e10cSrcweir        nRet |= KEY_SHIFT;
45cdf0e10cSrcweir    if( (nMask & NSControlKeyMask) != 0 )
46cdf0e10cSrcweir        nRet |= KEY_MOD3;
47cdf0e10cSrcweir    if( (nMask & NSAlternateKeyMask) != 0 )
48cdf0e10cSrcweir        nRet |= KEY_MOD2;
49cdf0e10cSrcweir    if( (nMask & NSCommandKeyMask) != 0 )
50cdf0e10cSrcweir        nRet |= KEY_MOD1;
51cdf0e10cSrcweir    return nRet;
52cdf0e10cSrcweir}
53cdf0e10cSrcweir
54cdf0e10cSrcweirstatic sal_uInt16 ImplMapCharCode( sal_Unicode aCode )
55cdf0e10cSrcweir{
56cdf0e10cSrcweir    static sal_uInt16 aKeyCodeMap[ 128 ] =
57cdf0e10cSrcweir    {
58cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
59cdf0e10cSrcweir        KEY_BACKSPACE, KEY_TAB, KEY_RETURN, 0, 0, KEY_RETURN, 0, 0,
60cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
61cdf0e10cSrcweir        0, KEY_TAB, 0, KEY_ESCAPE, 0, 0, 0, 0,
62cdf0e10cSrcweir        KEY_SPACE, 0, 0, 0, 0, 0, 0, 0,
63cdf0e10cSrcweir        0, 0, KEY_MULTIPLY, KEY_ADD, KEY_COMMA, KEY_SUBTRACT, KEY_POINT, KEY_DIVIDE,
64cdf0e10cSrcweir        KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7,
65cdf0e10cSrcweir        KEY_8, KEY_9, 0, 0, KEY_LESS, KEY_EQUAL, KEY_GREATER, 0,
66cdf0e10cSrcweir        0, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
67cdf0e10cSrcweir        KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
68cdf0e10cSrcweir        KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W,
69cdf0e10cSrcweir        KEY_X, KEY_Y, KEY_Z, 0, 0, 0, 0, 0,
70cdf0e10cSrcweir        KEY_QUOTELEFT, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
71cdf0e10cSrcweir        KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
72cdf0e10cSrcweir        KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W,
73cdf0e10cSrcweir        KEY_X, KEY_Y, KEY_Z, 0, 0, 0, KEY_TILDE, KEY_BACKSPACE
74cdf0e10cSrcweir    };
75cdf0e10cSrcweir
76cdf0e10cSrcweir    // Note: the mapping 0x7f should by rights be KEY_DELETE
77cdf0e10cSrcweir    // however if you press "backspace" 0x7f is reported
78cdf0e10cSrcweir    // whereas for "delete" 0xf728 gets reported
79cdf0e10cSrcweir
80cdf0e10cSrcweir    // Note: the mapping of 0x19 to KEY_TAB is because for unknown reasons
81cdf0e10cSrcweir    // tab alone is reported as 0x09 (as expected) but shift-tab is
82cdf0e10cSrcweir    // reported as 0x19 (end of medium)
83cdf0e10cSrcweir
84cdf0e10cSrcweir    static sal_uInt16 aFunctionKeyCodeMap[ 128 ] =
85cdf0e10cSrcweir    {
86cdf0e10cSrcweir        KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_F1, KEY_F2, KEY_F3, KEY_F4,
87cdf0e10cSrcweir        KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
88cdf0e10cSrcweir        KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20,
89cdf0e10cSrcweir        KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_F25, KEY_F26, 0, 0,
90cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, KEY_INSERT,
91cdf0e10cSrcweir        KEY_DELETE, KEY_HOME, 0, KEY_END, KEY_PAGEUP, KEY_PAGEDOWN, 0, 0,
92cdf0e10cSrcweir        0, 0, 0, 0, 0, KEY_MENU, 0, 0,
93cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
94cdf0e10cSrcweir        0, 0, 0, KEY_UNDO, KEY_REPEAT, KEY_FIND, KEY_HELP, 0,
95cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
96cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
97cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
98cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
99cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
100cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0,
101cdf0e10cSrcweir        0, 0, 0, 0, 0, 0, 0, 0
102cdf0e10cSrcweir    };
103cdf0e10cSrcweir
104cdf0e10cSrcweir    sal_uInt16 nKeyCode = 0;
105cdf0e10cSrcweir    if( aCode < sizeof( aKeyCodeMap) / sizeof( aKeyCodeMap[0] ) )
106cdf0e10cSrcweir        nKeyCode = aKeyCodeMap[ aCode ];
107cdf0e10cSrcweir    else if( aCode >= 0xf700 && aCode < 0xf780 )
108cdf0e10cSrcweir        nKeyCode = aFunctionKeyCodeMap[ aCode - 0xf700 ];
109cdf0e10cSrcweir    return nKeyCode;
110cdf0e10cSrcweir}
111cdf0e10cSrcweir
112cdf0e10cSrcweir// store the frame the mouse last entered
113cdf0e10cSrcweirstatic AquaSalFrame* s_pMouseFrame = NULL;
114cdf0e10cSrcweir// store the last pressed button for enter/exit events
115cdf0e10cSrcweir// which lack that information
116cdf0e10cSrcweirstatic sal_uInt16 s_nLastButton = 0;
117cdf0e10cSrcweir
118cdf0e10cSrcweir// combinations of keys we need to handle ourselves
119cdf0e10cSrcweirstatic const struct ExceptionalKey
120cdf0e10cSrcweir{
121cdf0e10cSrcweir    const sal_uInt16        nKeyCode;
122cdf0e10cSrcweir    const unsigned int  nModifierMask;
123cdf0e10cSrcweir} aExceptionalKeys[] =
124cdf0e10cSrcweir{
125cdf0e10cSrcweir    { KEY_D, NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask },
126cdf0e10cSrcweir    { KEY_D, NSCommandKeyMask | NSShiftKeyMask | NSAlternateKeyMask }
127cdf0e10cSrcweir};
128cdf0e10cSrcweir
129cdf0e10cSrcweirstatic AquaSalFrame* getMouseContainerFrame()
130cdf0e10cSrcweir{
131cdf0e10cSrcweir    int nWindows = 0;
132cdf0e10cSrcweir    NSCountWindows( &nWindows );
133cdf0e10cSrcweir    int* pWindows = (int*)alloca( nWindows * sizeof(int) );
134cdf0e10cSrcweir    // note: NSWindowList is supposed to be in z-order front to back
135cdf0e10cSrcweir    NSWindowList( nWindows, pWindows );
136cdf0e10cSrcweir    AquaSalFrame* pDispatchFrame = NULL;
137cdf0e10cSrcweir    for(int i = 0; i < nWindows && ! pDispatchFrame; i++ )
138cdf0e10cSrcweir    {
139cdf0e10cSrcweir        NSWindow* pWin = [NSApp windowWithWindowNumber: pWindows[i]];
140cdf0e10cSrcweir        if( pWin && [pWin isMemberOfClass: [SalFrameWindow class]] && [(SalFrameWindow*)pWin containsMouse] )
141cdf0e10cSrcweir            pDispatchFrame = [(SalFrameWindow*)pWin getSalFrame];
142cdf0e10cSrcweir    }
143cdf0e10cSrcweir    return pDispatchFrame;
144cdf0e10cSrcweir}
145cdf0e10cSrcweir
146cdf0e10cSrcweir@implementation SalFrameWindow
147cdf0e10cSrcweir-(id)initWithSalFrame: (AquaSalFrame*)pFrame
148cdf0e10cSrcweir{
149cdf0e10cSrcweir	mDraggingDestinationHandler = nil;
150cdf0e10cSrcweir    mpFrame = pFrame;
151cdf0e10cSrcweir    NSRect aRect = { { pFrame->maGeometry.nX, pFrame->maGeometry.nY },
152cdf0e10cSrcweir                     { pFrame->maGeometry.nWidth, pFrame->maGeometry.nHeight } };
153cdf0e10cSrcweir    pFrame->VCLToCocoa( aRect );
154cdf0e10cSrcweir    NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ];
155cdf0e10cSrcweir    [pNSWindow useOptimizedDrawing: YES]; // OSX recommendation when there are no overlapping subviews within the receiver
156cdf0e10cSrcweir    return pNSWindow;
157cdf0e10cSrcweir}
158cdf0e10cSrcweir
159cdf0e10cSrcweir-(AquaSalFrame*)getSalFrame
160cdf0e10cSrcweir{
161cdf0e10cSrcweir    return mpFrame;
162cdf0e10cSrcweir}
163cdf0e10cSrcweir
164cdf0e10cSrcweir-(void)displayIfNeeded
165cdf0e10cSrcweir{
166cdf0e10cSrcweir    if( GetSalData() && GetSalData()->mpFirstInstance )
167cdf0e10cSrcweir    {
168cdf0e10cSrcweir        vos::IMutex* pMutex = GetSalData()->mpFirstInstance->GetYieldMutex();
169cdf0e10cSrcweir        if( pMutex )
170cdf0e10cSrcweir        {
171cdf0e10cSrcweir            pMutex->acquire();
172cdf0e10cSrcweir            [super displayIfNeeded];
173cdf0e10cSrcweir            pMutex->release();
174cdf0e10cSrcweir        }
175cdf0e10cSrcweir    }
176cdf0e10cSrcweir}
177cdf0e10cSrcweir
178cdf0e10cSrcweir-(BOOL)containsMouse
179cdf0e10cSrcweir{
180cdf0e10cSrcweir    // is this event actually inside that NSWindow ?
181cdf0e10cSrcweir    NSPoint aPt = [NSEvent mouseLocation];
182cdf0e10cSrcweir    NSRect aFrameRect = [self frame];
183cdf0e10cSrcweir    BOOL bInRect = NSPointInRect( aPt, aFrameRect );
184cdf0e10cSrcweir    return bInRect;
185cdf0e10cSrcweir}
186cdf0e10cSrcweir
187cdf0e10cSrcweir-(BOOL)canBecomeKeyWindow
188cdf0e10cSrcweir{
189cdf0e10cSrcweir    if( (mpFrame->mnStyle &
190cdf0e10cSrcweir            ( SAL_FRAME_STYLE_FLOAT                 |
191cdf0e10cSrcweir              SAL_FRAME_STYLE_TOOLTIP               |
192cdf0e10cSrcweir              SAL_FRAME_STYLE_INTRO
193cdf0e10cSrcweir            )) == 0 )
194cdf0e10cSrcweir        return YES;
195cdf0e10cSrcweir    if( (mpFrame->mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) != 0 )
196cdf0e10cSrcweir        return YES;
197cdf0e10cSrcweir    if( mpFrame->mbFullScreen )
198cdf0e10cSrcweir        return YES;
199cdf0e10cSrcweir    if( (mpFrame->mnStyle & SAL_FRAME_STYLE_FLOAT_FOCUSABLE) )
200cdf0e10cSrcweir        return YES;
201cdf0e10cSrcweir    return [super canBecomeKeyWindow];
202cdf0e10cSrcweir}
203cdf0e10cSrcweir
204cdf0e10cSrcweir-(void)windowDidBecomeKey: (NSNotification*)pNotification
205cdf0e10cSrcweir{
206cdf0e10cSrcweir    (void)pNotification;
207cdf0e10cSrcweir    YIELD_GUARD;
208cdf0e10cSrcweir
209cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
210cdf0e10cSrcweir    {
211cdf0e10cSrcweir        static const sal_uLong nGuessDocument = SAL_FRAME_STYLE_MOVEABLE|
212cdf0e10cSrcweir                                            SAL_FRAME_STYLE_SIZEABLE|
213cdf0e10cSrcweir                                            SAL_FRAME_STYLE_CLOSEABLE;
214cdf0e10cSrcweir
215cdf0e10cSrcweir        if( mpFrame->mpMenu )
216cdf0e10cSrcweir            mpFrame->mpMenu->setMainMenu();
217cdf0e10cSrcweir        else if( ! mpFrame->mpParent &&
218cdf0e10cSrcweir                 ( (mpFrame->mnStyle & nGuessDocument) == nGuessDocument || // set default menu for e.g. help
219cdf0e10cSrcweir                    mpFrame->mbFullScreen ) )                               // ser default menu for e.g. presentation
220cdf0e10cSrcweir        {
221cdf0e10cSrcweir            AquaSalMenu::setDefaultMenu();
222cdf0e10cSrcweir        }
223cdf0e10cSrcweir        #if 0
224cdf0e10cSrcweir        // FIXME: we should disable menus while in modal mode
225cdf0e10cSrcweir        // however from down here there is currently no reliable way to
226cdf0e10cSrcweir        // find out when to do this
227cdf0e10cSrcweir        if( (mpFrame->mpParent && mpFrame->mpParent->GetWindow()->IsInModalMode()) )
228cdf0e10cSrcweir            AquaSalMenu::enableMainMenu( false );
229cdf0e10cSrcweir        #endif
230cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_GETFOCUS, 0 );
231cdf0e10cSrcweir        mpFrame->SendPaintEvent(); // repaint controls as active
232cdf0e10cSrcweir    }
233cdf0e10cSrcweir}
234cdf0e10cSrcweir
235cdf0e10cSrcweir-(void)windowDidResignKey: (NSNotification*)pNotification
236cdf0e10cSrcweir{
237cdf0e10cSrcweir    (void)pNotification;
238cdf0e10cSrcweir    YIELD_GUARD;
239cdf0e10cSrcweir
240cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
241cdf0e10cSrcweir    {
242cdf0e10cSrcweir        mpFrame->CallCallback(SALEVENT_LOSEFOCUS, 0);
243cdf0e10cSrcweir        mpFrame->SendPaintEvent(); // repaint controls as inactive
244cdf0e10cSrcweir    }
245cdf0e10cSrcweir}
246cdf0e10cSrcweir
247cdf0e10cSrcweir-(void)windowDidChangeScreen: (NSNotification*)pNotification
248cdf0e10cSrcweir{
249cdf0e10cSrcweir    (void)pNotification;
250cdf0e10cSrcweir    YIELD_GUARD;
251cdf0e10cSrcweir
252cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
253cdf0e10cSrcweir        mpFrame->screenParametersChanged();
254cdf0e10cSrcweir}
255cdf0e10cSrcweir
256cdf0e10cSrcweir-(void)windowDidMove: (NSNotification*)pNotification
257cdf0e10cSrcweir{
258cdf0e10cSrcweir    (void)pNotification;
259cdf0e10cSrcweir    YIELD_GUARD;
260cdf0e10cSrcweir
261cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
262cdf0e10cSrcweir    {
263cdf0e10cSrcweir        mpFrame->UpdateFrameGeometry();
264cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_MOVE, 0 );
265cdf0e10cSrcweir    }
266cdf0e10cSrcweir}
267cdf0e10cSrcweir
268cdf0e10cSrcweir-(void)windowDidResize: (NSNotification*)pNotification
269cdf0e10cSrcweir{
270cdf0e10cSrcweir    (void)pNotification;
271cdf0e10cSrcweir    YIELD_GUARD;
272cdf0e10cSrcweir
273cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
274cdf0e10cSrcweir    {
275cdf0e10cSrcweir        mpFrame->UpdateFrameGeometry();
276cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
277cdf0e10cSrcweir        mpFrame->SendPaintEvent();
278cdf0e10cSrcweir    }
279cdf0e10cSrcweir}
280cdf0e10cSrcweir
281cdf0e10cSrcweir-(void)windowDidMiniaturize: (NSNotification*)pNotification
282cdf0e10cSrcweir{
283cdf0e10cSrcweir    (void)pNotification;
284cdf0e10cSrcweir    YIELD_GUARD;
285cdf0e10cSrcweir
286cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
287cdf0e10cSrcweir    {
288cdf0e10cSrcweir        mpFrame->mbShown = false;
289cdf0e10cSrcweir        mpFrame->UpdateFrameGeometry();
290cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
291cdf0e10cSrcweir    }
292cdf0e10cSrcweir}
293cdf0e10cSrcweir
294cdf0e10cSrcweir-(void)windowDidDeminiaturize: (NSNotification*)pNotification
295cdf0e10cSrcweir{
296cdf0e10cSrcweir    (void)pNotification;
297cdf0e10cSrcweir    YIELD_GUARD;
298cdf0e10cSrcweir
299cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
300cdf0e10cSrcweir    {
301cdf0e10cSrcweir        mpFrame->mbShown = true;
302cdf0e10cSrcweir        mpFrame->UpdateFrameGeometry();
303cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
304cdf0e10cSrcweir    }
305cdf0e10cSrcweir}
306cdf0e10cSrcweir
307cdf0e10cSrcweir-(BOOL)windowShouldClose: (NSNotification*)pNotification
308cdf0e10cSrcweir{
309cdf0e10cSrcweir    (void)pNotification;
310cdf0e10cSrcweir    YIELD_GUARD;
311cdf0e10cSrcweir
312cdf0e10cSrcweir    BOOL bRet = YES;
313cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
314cdf0e10cSrcweir    {
315cdf0e10cSrcweir        // #i84461# end possible input
316cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 );
317cdf0e10cSrcweir        if( AquaSalFrame::isAlive( mpFrame ) )
318cdf0e10cSrcweir        {
319cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_CLOSE, 0 );
320cdf0e10cSrcweir            bRet = NO; // application will close the window or not, AppKit shouldn't
321cdf0e10cSrcweir        }
322cdf0e10cSrcweir    }
323cdf0e10cSrcweir
324cdf0e10cSrcweir    return bRet;
325cdf0e10cSrcweir}
326cdf0e10cSrcweir
327cdf0e10cSrcweir-(void)dockMenuItemTriggered: (id)sender
328cdf0e10cSrcweir{
329cdf0e10cSrcweir    (void)sender;
330cdf0e10cSrcweir    YIELD_GUARD;
331cdf0e10cSrcweir
332cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
333cdf0e10cSrcweir        mpFrame->ToTop( SAL_FRAME_TOTOP_RESTOREWHENMIN | SAL_FRAME_TOTOP_GRABFOCUS );
334cdf0e10cSrcweir}
335cdf0e10cSrcweir
336cdf0e10cSrcweir-(::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessibleContext >)accessibleContext
337cdf0e10cSrcweir{
338cdf0e10cSrcweir    return mpFrame -> GetWindow() -> GetAccessible() -> getAccessibleContext();
339cdf0e10cSrcweir}
340cdf0e10cSrcweir
341cdf0e10cSrcweir-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
342cdf0e10cSrcweir{
343cdf0e10cSrcweir  return [mDraggingDestinationHandler draggingEntered: sender];
344cdf0e10cSrcweir}
345cdf0e10cSrcweir
346cdf0e10cSrcweir-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
347cdf0e10cSrcweir{
348cdf0e10cSrcweir  return [mDraggingDestinationHandler draggingUpdated: sender];
349cdf0e10cSrcweir}
350cdf0e10cSrcweir
351cdf0e10cSrcweir-(void)draggingExited:(id <NSDraggingInfo>)sender
352cdf0e10cSrcweir{
353cdf0e10cSrcweir  [mDraggingDestinationHandler draggingExited: sender];
354cdf0e10cSrcweir}
355cdf0e10cSrcweir
356cdf0e10cSrcweir-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
357cdf0e10cSrcweir{
358cdf0e10cSrcweir  return [mDraggingDestinationHandler prepareForDragOperation: sender];
359cdf0e10cSrcweir}
360cdf0e10cSrcweir
361cdf0e10cSrcweir-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
362cdf0e10cSrcweir{
363cdf0e10cSrcweir  return [mDraggingDestinationHandler performDragOperation: sender];
364cdf0e10cSrcweir}
365cdf0e10cSrcweir
366cdf0e10cSrcweir-(void)concludeDragOperation:(id <NSDraggingInfo>)sender
367cdf0e10cSrcweir{
368cdf0e10cSrcweir  [mDraggingDestinationHandler concludeDragOperation: sender];
369cdf0e10cSrcweir}
370cdf0e10cSrcweir
371cdf0e10cSrcweir-(void)registerDraggingDestinationHandler:(id)theHandler
372cdf0e10cSrcweir{
373cdf0e10cSrcweir  mDraggingDestinationHandler = theHandler;
374cdf0e10cSrcweir}
375cdf0e10cSrcweir
376cdf0e10cSrcweir-(void)unregisterDraggingDestinationHandler:(id)theHandler
377cdf0e10cSrcweir{
378cdf0e10cSrcweir    (void)theHandler;
379cdf0e10cSrcweir    mDraggingDestinationHandler = nil;
380cdf0e10cSrcweir}
381cdf0e10cSrcweir
382cdf0e10cSrcweir@end
383cdf0e10cSrcweir
384cdf0e10cSrcweir@implementation SalFrameView
385cdf0e10cSrcweir+(void)unsetMouseFrame: (AquaSalFrame*)pFrame
386cdf0e10cSrcweir{
387cdf0e10cSrcweir    if( pFrame == s_pMouseFrame )
388cdf0e10cSrcweir        s_pMouseFrame = NULL;
389cdf0e10cSrcweir}
390cdf0e10cSrcweir
391cdf0e10cSrcweir-(id)initWithSalFrame: (AquaSalFrame*)pFrame
392cdf0e10cSrcweir{
393cdf0e10cSrcweir    if ((self = [super initWithFrame: [NSWindow contentRectForFrameRect: [pFrame->getWindow() frame] styleMask: pFrame->mnStyleMask]]) != nil)
394cdf0e10cSrcweir    {
395cdf0e10cSrcweir        mDraggingDestinationHandler = nil;
396cdf0e10cSrcweir        mpFrame = pFrame;
397cdf0e10cSrcweir        mMarkedRange = NSMakeRange(NSNotFound, 0);
398cdf0e10cSrcweir        mSelectedRange = NSMakeRange(NSNotFound, 0);
399cdf0e10cSrcweir        mpReferenceWrapper = nil;
400cdf0e10cSrcweir		mpMouseEventListener = nil;
401cdf0e10cSrcweir        mpLastSuperEvent = nil;
402cdf0e10cSrcweir    }
403cdf0e10cSrcweir
404cdf0e10cSrcweir    mfLastMagnifyTime = 0.0;
405cdf0e10cSrcweir    return self;
406cdf0e10cSrcweir}
407cdf0e10cSrcweir
408cdf0e10cSrcweir-(AquaSalFrame*)getSalFrame
409cdf0e10cSrcweir{
410cdf0e10cSrcweir    return mpFrame;
411cdf0e10cSrcweir}
412cdf0e10cSrcweir
413cdf0e10cSrcweir-(void)resetCursorRects
414cdf0e10cSrcweir{
415cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
416cdf0e10cSrcweir    {
417cdf0e10cSrcweir        // FIXME: does this leak the returned NSCursor of getCurrentCursor ?
418cdf0e10cSrcweir        NSRect aRect = { { 0, 0 }, { mpFrame->maGeometry.nWidth, mpFrame->maGeometry.nHeight } };
419cdf0e10cSrcweir        [self addCursorRect: aRect cursor: mpFrame->getCurrentCursor()];
420cdf0e10cSrcweir    }
421cdf0e10cSrcweir}
422cdf0e10cSrcweir
423cdf0e10cSrcweir-(BOOL)acceptsFirstResponder
424cdf0e10cSrcweir{
425cdf0e10cSrcweir    return YES;
426cdf0e10cSrcweir}
427cdf0e10cSrcweir
428cdf0e10cSrcweir-(BOOL)acceptsFirstMouse: (NSEvent*)pEvent
429cdf0e10cSrcweir{
430cdf0e10cSrcweir    (void)pEvent;
431cdf0e10cSrcweir    return YES;
432cdf0e10cSrcweir}
433cdf0e10cSrcweir
434cdf0e10cSrcweir-(BOOL)isOpaque
435cdf0e10cSrcweir{
436cdf0e10cSrcweir    return mpFrame ? (mpFrame->getClipPath() != 0 ? NO : YES) : YES;
437cdf0e10cSrcweir}
438cdf0e10cSrcweir
439cdf0e10cSrcweir// helper class similar to a vos::OGuard for the SalYieldMutex
440cdf0e10cSrcweir// the difference is that it only does tryToAcquire instead of aquire
441cdf0e10cSrcweir// so dreaded deadlocks like #i93512# are prevented
442cdf0e10cSrcweirclass TryGuard
443cdf0e10cSrcweir{
444cdf0e10cSrcweirpublic:
445cdf0e10cSrcweir			TryGuard()  { mbGuarded = ImplSalYieldMutexTryToAcquire(); }
446cdf0e10cSrcweir			~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); }
447cdf0e10cSrcweir	bool	IsGuarded() { return mbGuarded; }
448cdf0e10cSrcweirprivate:
449cdf0e10cSrcweir	bool	mbGuarded;
450cdf0e10cSrcweir};
451cdf0e10cSrcweir
452cdf0e10cSrcweir-(void)drawRect: (NSRect)aRect
453cdf0e10cSrcweir{
454cdf0e10cSrcweir	// HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex
455cdf0e10cSrcweir	TryGuard aTryGuard;
456cdf0e10cSrcweir	if( !aTryGuard.IsGuarded() )
457cdf0e10cSrcweir	{
458cdf0e10cSrcweir		// NOTE: the mpFrame access below is not guarded yet!
459cdf0e10cSrcweir		// TODO: mpFrame et al need to be guarded by an independent mutex
460cdf0e10cSrcweir		AquaSalGraphics* pGraphics = (mpFrame && AquaSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : NULL;
461cdf0e10cSrcweir		if( pGraphics )
462cdf0e10cSrcweir		{
463cdf0e10cSrcweir			// we did not get the mutex so we cannot draw now => request to redraw later
464cdf0e10cSrcweir			// convert the NSRect to a CGRect for Refreshrect()
465cdf0e10cSrcweir			const CGRect aCGRect = {{aRect.origin.x,aRect.origin.y},{aRect.size.width,aRect.size.height}};
466cdf0e10cSrcweir			pGraphics->RefreshRect( aCGRect );
467cdf0e10cSrcweir		}
468cdf0e10cSrcweir		return;
469cdf0e10cSrcweir	}
470cdf0e10cSrcweir
471cdf0e10cSrcweir    if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
472cdf0e10cSrcweir    {
473cdf0e10cSrcweir        if( mpFrame->mpGraphics )
474cdf0e10cSrcweir        {
475cdf0e10cSrcweir            mpFrame->mpGraphics->UpdateWindow( aRect );
476cdf0e10cSrcweir            if( mpFrame->getClipPath() )
477cdf0e10cSrcweir                [mpFrame->getWindow() invalidateShadow];
478cdf0e10cSrcweir        }
479cdf0e10cSrcweir    }
480cdf0e10cSrcweir}
481cdf0e10cSrcweir
482cdf0e10cSrcweir-(void)sendMouseEventToFrame: (NSEvent*)pEvent button:(sal_uInt16)nButton eventtype:(sal_uInt16)nEvent
483cdf0e10cSrcweir{
484cdf0e10cSrcweir    YIELD_GUARD;
485cdf0e10cSrcweir
486cdf0e10cSrcweir    AquaSalFrame* pDispatchFrame = AquaSalFrame::GetCaptureFrame();
487cdf0e10cSrcweir    bool bIsCaptured = false;
488cdf0e10cSrcweir    if( pDispatchFrame )
489cdf0e10cSrcweir    {
490cdf0e10cSrcweir        bIsCaptured = true;
491cdf0e10cSrcweir        if( nEvent == SALEVENT_MOUSELEAVE ) // no leave events if mouse is captured
492cdf0e10cSrcweir            nEvent = SALEVENT_MOUSEMOVE;
493cdf0e10cSrcweir    }
494cdf0e10cSrcweir    else if( s_pMouseFrame )
495cdf0e10cSrcweir        pDispatchFrame = s_pMouseFrame;
496cdf0e10cSrcweir    else
497cdf0e10cSrcweir        pDispatchFrame = mpFrame;
498cdf0e10cSrcweir
499cdf0e10cSrcweir    /* #i81645# Cocoa reports mouse events while a button is pressed
500cdf0e10cSrcweir       to the window in which it was first pressed. This is reasonable and fine and
501cdf0e10cSrcweir       gets one around most cases where on other platforms one uses CaptureMouse or XGrabPointer,
502cdf0e10cSrcweir       however vcl expects mouse events to occur in the window the mouse is over, unless the
503cdf0e10cSrcweir       mouse is explicitly captured. So we need to find the window the mouse is actually
504cdf0e10cSrcweir       over for conformance with other platforms.
505cdf0e10cSrcweir    */
506cdf0e10cSrcweir    if( ! bIsCaptured && nButton && pDispatchFrame && AquaSalFrame::isAlive( pDispatchFrame ) )
507cdf0e10cSrcweir    {
508cdf0e10cSrcweir        // is this event actually inside that NSWindow ?
509cdf0e10cSrcweir        NSPoint aPt = [NSEvent mouseLocation];
510cdf0e10cSrcweir        NSRect aFrameRect = [pDispatchFrame->getWindow() frame];
511cdf0e10cSrcweir
512cdf0e10cSrcweir	if ( ! NSPointInRect( aPt, aFrameRect ) )
513cdf0e10cSrcweir        {
514cdf0e10cSrcweir            // no, it is not
515cdf0e10cSrcweir            // now we need to find the one it may be in
516cdf0e10cSrcweir            /* #i93756# we ant to get enumerate the application windows in z-order
517cdf0e10cSrcweir               to check if any contains the mouse. This could be elegantly done with this
518cdf0e10cSrcweir               code:
519cdf0e10cSrcweir
520cdf0e10cSrcweir               // use NSApp to check windows in ZOrder whether they contain the mouse pointer
521cdf0e10cSrcweir               NSWindow* pWindow = [NSApp makeWindowsPerform: @selector(containsMouse) inOrder: YES];
522cdf0e10cSrcweir               if( pWindow && [pWindow isMemberOfClass: [SalFrameWindow class]] )
523cdf0e10cSrcweir                   pDispatchFrame = [(SalFrameWindow*)pWindow getSalFrame];
524cdf0e10cSrcweir
525cdf0e10cSrcweir               However if a non SalFrameWindow is on screen (like e.g. the file dialog)
526cdf0e10cSrcweir               it can be hit with the containsMouse selector, which it doesn't support.
527cdf0e10cSrcweir               Sadly NSApplication:makeWindowsPerform does not check (for performance reasons
528cdf0e10cSrcweir               I assume) whether a window supports a selector before sending it.
529cdf0e10cSrcweir            */
530cdf0e10cSrcweir            AquaSalFrame* pMouseFrame = getMouseContainerFrame();
531cdf0e10cSrcweir            if( pMouseFrame )
532cdf0e10cSrcweir                pDispatchFrame = pMouseFrame;
533cdf0e10cSrcweir        }
534cdf0e10cSrcweir    }
535cdf0e10cSrcweir
536cdf0e10cSrcweir    if( pDispatchFrame && AquaSalFrame::isAlive( pDispatchFrame ) )
537cdf0e10cSrcweir    {
538cdf0e10cSrcweir        pDispatchFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 );
539cdf0e10cSrcweir        pDispatchFrame->mnLastModifierFlags = [pEvent modifierFlags];
540cdf0e10cSrcweir
541cdf0e10cSrcweir        NSPoint aPt = [NSEvent mouseLocation];
542cdf0e10cSrcweir        pDispatchFrame->CocoaToVCL( aPt );
543cdf0e10cSrcweir
544cdf0e10cSrcweir        sal_uInt16 nModMask = ImplGetModifierMask( [pEvent modifierFlags] );
545cdf0e10cSrcweir        // #i82284# emulate ctrl left
546cdf0e10cSrcweir        if( nModMask == KEY_MOD3 && nButton == MOUSE_LEFT )
547cdf0e10cSrcweir        {
548cdf0e10cSrcweir            nModMask    = 0;
549cdf0e10cSrcweir            nButton     = MOUSE_RIGHT;
550cdf0e10cSrcweir        }
551cdf0e10cSrcweir
552cdf0e10cSrcweir        SalMouseEvent aEvent;
553cdf0e10cSrcweir        aEvent.mnTime   = pDispatchFrame->mnLastEventTime;
554cdf0e10cSrcweir        aEvent.mnX      = static_cast<long>(aPt.x) - pDispatchFrame->maGeometry.nX;
555cdf0e10cSrcweir        aEvent.mnY      = static_cast<long>(aPt.y) - pDispatchFrame->maGeometry.nY;
556cdf0e10cSrcweir        aEvent.mnButton = nButton;
557cdf0e10cSrcweir        aEvent.mnCode   =  aEvent.mnButton | nModMask;
558cdf0e10cSrcweir
559cdf0e10cSrcweir        // --- RTL --- (mirror mouse pos)
560cdf0e10cSrcweir        if( Application::GetSettings().GetLayoutRTL() )
561cdf0e10cSrcweir            aEvent.mnX = pDispatchFrame->maGeometry.nWidth-1-aEvent.mnX;
562cdf0e10cSrcweir
563cdf0e10cSrcweir        pDispatchFrame->CallCallback( nEvent, &aEvent );
564cdf0e10cSrcweir    }
565cdf0e10cSrcweir}
566cdf0e10cSrcweir
567cdf0e10cSrcweir-(void)mouseDown: (NSEvent*)pEvent
568cdf0e10cSrcweir{
569cdf0e10cSrcweir    if ( mpMouseEventListener != nil &&
570cdf0e10cSrcweir	    [mpMouseEventListener respondsToSelector: @selector(mouseDown:)])
571cdf0e10cSrcweir	{
572cdf0e10cSrcweir	    [mpMouseEventListener mouseDown: [pEvent copyWithZone: NULL]];
573cdf0e10cSrcweir	}
574cdf0e10cSrcweir
575cdf0e10cSrcweir    s_nLastButton = MOUSE_LEFT;
576cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEBUTTONDOWN];
577cdf0e10cSrcweir}
578cdf0e10cSrcweir
579cdf0e10cSrcweir-(void)mouseDragged: (NSEvent*)pEvent
580cdf0e10cSrcweir{
581cdf0e10cSrcweir    if ( mpMouseEventListener != nil &&
582cdf0e10cSrcweir	     [mpMouseEventListener respondsToSelector: @selector(mouseDragged:)])
583cdf0e10cSrcweir	{
584cdf0e10cSrcweir	    [mpMouseEventListener mouseDragged: [pEvent copyWithZone: NULL]];
585cdf0e10cSrcweir	}
586cdf0e10cSrcweir    s_nLastButton = MOUSE_LEFT;
587cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEMOVE];
588cdf0e10cSrcweir}
589cdf0e10cSrcweir
590cdf0e10cSrcweir-(void)mouseUp: (NSEvent*)pEvent
591cdf0e10cSrcweir{
592cdf0e10cSrcweir    s_nLastButton = 0;
593cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_LEFT eventtype:SALEVENT_MOUSEBUTTONUP];
594cdf0e10cSrcweir}
595cdf0e10cSrcweir
596cdf0e10cSrcweir-(void)mouseMoved: (NSEvent*)pEvent
597cdf0e10cSrcweir{
598cdf0e10cSrcweir    s_nLastButton = 0;
599cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:0 eventtype:SALEVENT_MOUSEMOVE];
600cdf0e10cSrcweir}
601cdf0e10cSrcweir
602cdf0e10cSrcweir-(void)mouseEntered: (NSEvent*)pEvent
603cdf0e10cSrcweir{
604cdf0e10cSrcweir    s_pMouseFrame = mpFrame;
605cdf0e10cSrcweir
606cdf0e10cSrcweir    // #i107215# the only mouse events we get when inactive are enter/exit
607cdf0e10cSrcweir    // actually we would like to have all of them, but better none than some
608cdf0e10cSrcweir    if( [NSApp isActive] )
609cdf0e10cSrcweir        [self sendMouseEventToFrame:pEvent button:s_nLastButton eventtype:SALEVENT_MOUSEMOVE];
610cdf0e10cSrcweir}
611cdf0e10cSrcweir
612cdf0e10cSrcweir-(void)mouseExited: (NSEvent*)pEvent
613cdf0e10cSrcweir{
614cdf0e10cSrcweir    if( s_pMouseFrame == mpFrame )
615cdf0e10cSrcweir        s_pMouseFrame = NULL;
616cdf0e10cSrcweir
617cdf0e10cSrcweir    // #i107215# the only mouse events we get when inactive are enter/exit
618cdf0e10cSrcweir    // actually we would like to have all of them, but better none than some
619cdf0e10cSrcweir    if( [NSApp isActive] )
620cdf0e10cSrcweir        [self sendMouseEventToFrame:pEvent button:s_nLastButton eventtype:SALEVENT_MOUSELEAVE];
621cdf0e10cSrcweir}
622cdf0e10cSrcweir
623cdf0e10cSrcweir-(void)rightMouseDown: (NSEvent*)pEvent
624cdf0e10cSrcweir{
625cdf0e10cSrcweir    s_nLastButton = MOUSE_RIGHT;
626cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEBUTTONDOWN];
627cdf0e10cSrcweir}
628cdf0e10cSrcweir
629cdf0e10cSrcweir-(void)rightMouseDragged: (NSEvent*)pEvent
630cdf0e10cSrcweir{
631cdf0e10cSrcweir    s_nLastButton = MOUSE_RIGHT;
632cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEMOVE];
633cdf0e10cSrcweir}
634cdf0e10cSrcweir
635cdf0e10cSrcweir-(void)rightMouseUp: (NSEvent*)pEvent
636cdf0e10cSrcweir{
637cdf0e10cSrcweir    s_nLastButton = 0;
638cdf0e10cSrcweir    [self sendMouseEventToFrame:pEvent button:MOUSE_RIGHT eventtype:SALEVENT_MOUSEBUTTONUP];
639cdf0e10cSrcweir}
640cdf0e10cSrcweir
641cdf0e10cSrcweir-(void)otherMouseDown: (NSEvent*)pEvent
642cdf0e10cSrcweir{
643cdf0e10cSrcweir    if( [pEvent buttonNumber] == 2 )
644cdf0e10cSrcweir    {
645cdf0e10cSrcweir        s_nLastButton = MOUSE_MIDDLE;
646cdf0e10cSrcweir        [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEBUTTONDOWN];
647cdf0e10cSrcweir    }
648cdf0e10cSrcweir    else
649cdf0e10cSrcweir        s_nLastButton = 0;
650cdf0e10cSrcweir}
651cdf0e10cSrcweir
652cdf0e10cSrcweir-(void)otherMouseDragged: (NSEvent*)pEvent
653cdf0e10cSrcweir{
654cdf0e10cSrcweir    if( [pEvent buttonNumber] == 2 )
655cdf0e10cSrcweir    {
656cdf0e10cSrcweir        s_nLastButton = MOUSE_MIDDLE;
657cdf0e10cSrcweir        [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEMOVE];
658cdf0e10cSrcweir    }
659cdf0e10cSrcweir    else
660cdf0e10cSrcweir        s_nLastButton = 0;
661cdf0e10cSrcweir}
662cdf0e10cSrcweir
663cdf0e10cSrcweir-(void)otherMouseUp: (NSEvent*)pEvent
664cdf0e10cSrcweir{
665cdf0e10cSrcweir    s_nLastButton = 0;
666cdf0e10cSrcweir    if( [pEvent buttonNumber] == 2 )
667cdf0e10cSrcweir        [self sendMouseEventToFrame:pEvent button:MOUSE_MIDDLE eventtype:SALEVENT_MOUSEBUTTONUP];
668cdf0e10cSrcweir}
669cdf0e10cSrcweir
670cdf0e10cSrcweir- (void)magnifyWithEvent: (NSEvent*)pEvent
671cdf0e10cSrcweir{
672cdf0e10cSrcweir    YIELD_GUARD;
673cdf0e10cSrcweir
674cdf0e10cSrcweir    // TODO: ??  -(float)magnification;
675cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
676cdf0e10cSrcweir	{
677cdf0e10cSrcweir		const NSTimeInterval fMagnifyTime = [pEvent timestamp];
678cdf0e10cSrcweir        mpFrame->mnLastEventTime = static_cast<sal_uLong>( fMagnifyTime * 1000.0 );
679cdf0e10cSrcweir        mpFrame->mnLastModifierFlags = [pEvent modifierFlags];
680cdf0e10cSrcweir
681cdf0e10cSrcweir        // check if this is a new series of magnify events
682cdf0e10cSrcweir        static const NSTimeInterval fMaxDiffTime = 0.3;
683cdf0e10cSrcweir        const bool bNewSeries = (fMagnifyTime - mfLastMagnifyTime > fMaxDiffTime);
684cdf0e10cSrcweir
685cdf0e10cSrcweir        if( bNewSeries )
686cdf0e10cSrcweir            mfMagnifyDeltaSum = 0.0;
687cdf0e10cSrcweir        mfMagnifyDeltaSum += [pEvent deltaZ];
688cdf0e10cSrcweir
689cdf0e10cSrcweir		mfLastMagnifyTime = [pEvent timestamp];
690cdf0e10cSrcweir		// TODO: change to 0.1 when COMMAND_WHEEL_ZOOM handlers allow finer zooming control
691cdf0e10cSrcweir		static const float fMagnifyFactor = 0.25;
692cdf0e10cSrcweir        static const float fMinMagnifyStep = 15.0 / fMagnifyFactor;
693cdf0e10cSrcweir        if( fabs(mfMagnifyDeltaSum) <= fMinMagnifyStep )
694cdf0e10cSrcweir            return;
695cdf0e10cSrcweir
696cdf0e10cSrcweir        // adapt NSEvent-sensitivity to application expectations
697cdf0e10cSrcweir        // TODO: rather make COMMAND_WHEEL_ZOOM handlers smarter
698cdf0e10cSrcweir        const float fDeltaZ = mfMagnifyDeltaSum * fMagnifyFactor;
699cdf0e10cSrcweir        int nDeltaZ = FRound( fDeltaZ );
700cdf0e10cSrcweir        if( !nDeltaZ )
701cdf0e10cSrcweir        {
702cdf0e10cSrcweir            // handle new series immediately
703cdf0e10cSrcweir            if( !bNewSeries )
704cdf0e10cSrcweir                return;
705cdf0e10cSrcweir            nDeltaZ = (fDeltaZ >= 0.0) ? +1 : -1;
706cdf0e10cSrcweir        }
707cdf0e10cSrcweir        // eventually give credit for delta sum
708cdf0e10cSrcweir        mfMagnifyDeltaSum -= nDeltaZ / fMagnifyFactor;
709cdf0e10cSrcweir
710cdf0e10cSrcweir        NSPoint aPt = [NSEvent mouseLocation];
711cdf0e10cSrcweir        mpFrame->CocoaToVCL( aPt );
712cdf0e10cSrcweir
713cdf0e10cSrcweir        SalWheelMouseEvent aEvent;
714cdf0e10cSrcweir        aEvent.mnTime           = mpFrame->mnLastEventTime;
715cdf0e10cSrcweir        aEvent.mnX              = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX;
716cdf0e10cSrcweir        aEvent.mnY              = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY;
717cdf0e10cSrcweir        aEvent.mnCode           = ImplGetModifierMask( mpFrame->mnLastModifierFlags );
718cdf0e10cSrcweir        aEvent.mnCode           |= KEY_MOD1; // we want zooming, no scrolling
719cdf0e10cSrcweir        aEvent.mbDeltaIsPixel   = TRUE;
720cdf0e10cSrcweir
721cdf0e10cSrcweir        // --- RTL --- (mirror mouse pos)
722cdf0e10cSrcweir        if( Application::GetSettings().GetLayoutRTL() )
723cdf0e10cSrcweir            aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX;
724cdf0e10cSrcweir
725cdf0e10cSrcweir        aEvent.mnDelta = nDeltaZ;
726cdf0e10cSrcweir        aEvent.mnNotchDelta = (nDeltaZ >= 0) ? +1 : -1;
727cdf0e10cSrcweir        if( aEvent.mnDelta == 0 )
728cdf0e10cSrcweir            aEvent.mnDelta = aEvent.mnNotchDelta;
729cdf0e10cSrcweir        aEvent.mbHorz = FALSE;
730cdf0e10cSrcweir        aEvent.mnScrollLines = nDeltaZ;
731cdf0e10cSrcweir        if( aEvent.mnScrollLines == 0 )
732cdf0e10cSrcweir            aEvent.mnScrollLines = 1;
733cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent );
734cdf0e10cSrcweir    }
735cdf0e10cSrcweir}
736cdf0e10cSrcweir
737cdf0e10cSrcweir- (void)rotateWithEvent: (NSEvent*)pEvent
738cdf0e10cSrcweir{
739cdf0e10cSrcweir    //Rotation : -(float)rotation;
740cdf0e10cSrcweir    // TODO: create new CommandType so rotation is available to the applications
741cdf0e10cSrcweir    (void)pEvent;
742cdf0e10cSrcweir}
743cdf0e10cSrcweir
744cdf0e10cSrcweir- (void)swipeWithEvent: (NSEvent*)pEvent
745cdf0e10cSrcweir{
746cdf0e10cSrcweir    YIELD_GUARD;
747cdf0e10cSrcweir
748cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
749cdf0e10cSrcweir    {
750cdf0e10cSrcweir        mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 );
751cdf0e10cSrcweir        mpFrame->mnLastModifierFlags = [pEvent modifierFlags];
752cdf0e10cSrcweir
753cdf0e10cSrcweir        // merge pending scroll wheel events
754cdf0e10cSrcweir        float dX = 0.0;
755cdf0e10cSrcweir        float dY = 0.0;
756cdf0e10cSrcweir        for(;;)
757cdf0e10cSrcweir        {
758cdf0e10cSrcweir            dX += [pEvent deltaX];
759cdf0e10cSrcweir            dY += [pEvent deltaY];
760cdf0e10cSrcweir            NSEvent* pNextEvent = [NSApp nextEventMatchingMask: NSScrollWheelMask
761cdf0e10cSrcweir            untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES ];
762cdf0e10cSrcweir            if( !pNextEvent )
763cdf0e10cSrcweir                break;
764cdf0e10cSrcweir            pEvent = pNextEvent;
765cdf0e10cSrcweir        }
766cdf0e10cSrcweir
767cdf0e10cSrcweir        NSPoint aPt = [NSEvent mouseLocation];
768cdf0e10cSrcweir        mpFrame->CocoaToVCL( aPt );
769cdf0e10cSrcweir
770cdf0e10cSrcweir        SalWheelMouseEvent aEvent;
771cdf0e10cSrcweir        aEvent.mnTime           = mpFrame->mnLastEventTime;
772cdf0e10cSrcweir        aEvent.mnX              = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX;
773cdf0e10cSrcweir        aEvent.mnY              = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY;
774cdf0e10cSrcweir        aEvent.mnCode           = ImplGetModifierMask( mpFrame->mnLastModifierFlags );
775cdf0e10cSrcweir        aEvent.mbDeltaIsPixel   = TRUE;
776cdf0e10cSrcweir
777cdf0e10cSrcweir        // --- RTL --- (mirror mouse pos)
778cdf0e10cSrcweir        if( Application::GetSettings().GetLayoutRTL() )
779cdf0e10cSrcweir            aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX;
780cdf0e10cSrcweir
781cdf0e10cSrcweir        if( dX != 0.0 )
782cdf0e10cSrcweir        {
783cdf0e10cSrcweir            aEvent.mnDelta = static_cast<long>(floor(dX));
784cdf0e10cSrcweir            aEvent.mnNotchDelta = dX < 0 ? -1 : 1;
785cdf0e10cSrcweir            if( aEvent.mnDelta == 0 )
786cdf0e10cSrcweir                aEvent.mnDelta = aEvent.mnNotchDelta;
787cdf0e10cSrcweir            aEvent.mbHorz = TRUE;
788cdf0e10cSrcweir            aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL;
789cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent );
790cdf0e10cSrcweir        }
791cdf0e10cSrcweir        if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ))
792cdf0e10cSrcweir        {
793cdf0e10cSrcweir            aEvent.mnDelta = static_cast<long>(floor(dY));
794cdf0e10cSrcweir            aEvent.mnNotchDelta = dY < 0 ? -1 : 1;
795cdf0e10cSrcweir            if( aEvent.mnDelta == 0 )
796cdf0e10cSrcweir                aEvent.mnDelta = aEvent.mnNotchDelta;
797cdf0e10cSrcweir            aEvent.mbHorz = FALSE;
798cdf0e10cSrcweir            aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL;
799cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent );
800cdf0e10cSrcweir        }
801cdf0e10cSrcweir    }
802cdf0e10cSrcweir}
803cdf0e10cSrcweir
804cdf0e10cSrcweir-(void)scrollWheel: (NSEvent*)pEvent
805cdf0e10cSrcweir{
806cdf0e10cSrcweir    YIELD_GUARD;
807cdf0e10cSrcweir
808cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
809cdf0e10cSrcweir    {
810cdf0e10cSrcweir        mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 );
811cdf0e10cSrcweir        mpFrame->mnLastModifierFlags = [pEvent modifierFlags];
812cdf0e10cSrcweir
813cdf0e10cSrcweir        // merge pending scroll wheel events
814cdf0e10cSrcweir        float dX = 0.0;
815cdf0e10cSrcweir        float dY = 0.0;
816cdf0e10cSrcweir        for(;;)
817cdf0e10cSrcweir        {
818cdf0e10cSrcweir            dX += [pEvent deltaX];
819cdf0e10cSrcweir    	    dY += [pEvent deltaY];
820cdf0e10cSrcweir            NSEvent* pNextEvent = [NSApp nextEventMatchingMask: NSScrollWheelMask
821cdf0e10cSrcweir                untilDate: nil inMode: NSDefaultRunLoopMode dequeue: YES ];
822cdf0e10cSrcweir            if( !pNextEvent )
823cdf0e10cSrcweir                break;
824cdf0e10cSrcweir            pEvent = pNextEvent;
825cdf0e10cSrcweir        }
826cdf0e10cSrcweir
827cdf0e10cSrcweir        NSPoint aPt = [NSEvent mouseLocation];
828cdf0e10cSrcweir        mpFrame->CocoaToVCL( aPt );
829cdf0e10cSrcweir
830cdf0e10cSrcweir        SalWheelMouseEvent aEvent;
831cdf0e10cSrcweir        aEvent.mnTime         = mpFrame->mnLastEventTime;
832cdf0e10cSrcweir        aEvent.mnX            = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX;
833cdf0e10cSrcweir        aEvent.mnY            = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY;
834cdf0e10cSrcweir        aEvent.mnCode         = ImplGetModifierMask( mpFrame->mnLastModifierFlags );
835cdf0e10cSrcweir        aEvent.mbDeltaIsPixel = TRUE;
836cdf0e10cSrcweir
837cdf0e10cSrcweir        // --- RTL --- (mirror mouse pos)
838cdf0e10cSrcweir        if( Application::GetSettings().GetLayoutRTL() )
839cdf0e10cSrcweir            aEvent.mnX = mpFrame->maGeometry.nWidth-1-aEvent.mnX;
840cdf0e10cSrcweir
841cdf0e10cSrcweir        if( dX != 0.0 )
842cdf0e10cSrcweir        {
843cdf0e10cSrcweir            aEvent.mnDelta = static_cast<long>(floor(dX));
844cdf0e10cSrcweir            aEvent.mnNotchDelta = dX < 0 ? -1 : 1;
845cdf0e10cSrcweir            if( aEvent.mnDelta == 0 )
846cdf0e10cSrcweir                aEvent.mnDelta = aEvent.mnNotchDelta;
847cdf0e10cSrcweir            aEvent.mbHorz = TRUE;
848cdf0e10cSrcweir            aEvent.mnScrollLines = dY > 0 ? dX/WHEEL_EVENT_FACTOR : -dX/WHEEL_EVENT_FACTOR;
849cdf0e10cSrcweir            if( aEvent.mnScrollLines == 0 )
850cdf0e10cSrcweir                aEvent.mnScrollLines = 1;
851cdf0e10cSrcweir
852cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent );
853cdf0e10cSrcweir        }
854cdf0e10cSrcweir        if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ) )
855cdf0e10cSrcweir        {
856cdf0e10cSrcweir            aEvent.mnDelta = static_cast<long>(floor(dY));
857cdf0e10cSrcweir            aEvent.mnNotchDelta = dY < 0 ? -1 : 1;
858cdf0e10cSrcweir            if( aEvent.mnDelta == 0 )
859cdf0e10cSrcweir                aEvent.mnDelta = aEvent.mnNotchDelta;
860cdf0e10cSrcweir            aEvent.mbHorz = FALSE;
861cdf0e10cSrcweir            aEvent.mnScrollLines = dY > 0 ? dY/WHEEL_EVENT_FACTOR : -dY/WHEEL_EVENT_FACTOR;
862cdf0e10cSrcweir            if( aEvent.mnScrollLines < 1 )
863cdf0e10cSrcweir                aEvent.mnScrollLines = 1;
864cdf0e10cSrcweir
865cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent );
866cdf0e10cSrcweir        }
867cdf0e10cSrcweir    }
868cdf0e10cSrcweir}
869cdf0e10cSrcweir
870cdf0e10cSrcweir
871cdf0e10cSrcweir-(void)keyDown: (NSEvent*)pEvent
872cdf0e10cSrcweir{
873cdf0e10cSrcweir    YIELD_GUARD;
874cdf0e10cSrcweir
875cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
876cdf0e10cSrcweir    {
877cdf0e10cSrcweir        mpLastEvent = pEvent;
878cdf0e10cSrcweir        mbInKeyInput = true;
879cdf0e10cSrcweir        mbNeedSpecialKeyHandle = false;
880cdf0e10cSrcweir        mbKeyHandled = false;
881cdf0e10cSrcweir
882cdf0e10cSrcweir        mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 );
883cdf0e10cSrcweir        mpFrame->mnLastModifierFlags = [pEvent modifierFlags];
884cdf0e10cSrcweir
885cdf0e10cSrcweir        if( ! [self handleKeyDownException: pEvent] )
886cdf0e10cSrcweir        {
887cdf0e10cSrcweir            NSArray* pArray = [NSArray arrayWithObject: pEvent];
888cdf0e10cSrcweir            [self interpretKeyEvents: pArray];
889cdf0e10cSrcweir        }
890cdf0e10cSrcweir
891cdf0e10cSrcweir        mbInKeyInput = false;
892cdf0e10cSrcweir    }
893cdf0e10cSrcweir}
894cdf0e10cSrcweir
895cdf0e10cSrcweir-(BOOL)handleKeyDownException:(NSEvent*)pEvent
896cdf0e10cSrcweir{
897cdf0e10cSrcweir    // check for a very special set of modified characters
898cdf0e10cSrcweir    NSString* pUnmodifiedString = [pEvent charactersIgnoringModifiers];
899cdf0e10cSrcweir
900cdf0e10cSrcweir    if( pUnmodifiedString && [pUnmodifiedString length] == 1 )
901cdf0e10cSrcweir    {
902cdf0e10cSrcweir        /* #i103102# key events with command and alternate don't make it through
903cdf0e10cSrcweir           interpretKeyEvents (why ?). Try to dispatch them here first,
904cdf0e10cSrcweir           if not successful continue normally
905cdf0e10cSrcweir        */
906cdf0e10cSrcweir        if( (mpFrame->mnLastModifierFlags & (NSAlternateKeyMask | NSCommandKeyMask))
907cdf0e10cSrcweir                    == (NSAlternateKeyMask | NSCommandKeyMask) )
908cdf0e10cSrcweir        {
909cdf0e10cSrcweir            if( [self sendSingleCharacter: mpLastEvent] )
910cdf0e10cSrcweir                return YES;
911cdf0e10cSrcweir        }
912cdf0e10cSrcweir        unichar keyChar = [pUnmodifiedString characterAtIndex: 0];
913cdf0e10cSrcweir        sal_uInt16 nKeyCode = ImplMapCharCode( keyChar );
914cdf0e10cSrcweir
915cdf0e10cSrcweir        // Caution: should the table grow to more than 5 or 6 entries,
916cdf0e10cSrcweir        // we must consider moving it to a kind of hash map
917cdf0e10cSrcweir        const unsigned int nExceptions = sizeof( aExceptionalKeys ) / sizeof( aExceptionalKeys[0] );
918cdf0e10cSrcweir        for( unsigned int i = 0; i < nExceptions; i++ )
919cdf0e10cSrcweir        {
920cdf0e10cSrcweir            if( nKeyCode == aExceptionalKeys[i].nKeyCode &&
921cdf0e10cSrcweir                (mpFrame->mnLastModifierFlags & aExceptionalKeys[i].nModifierMask)
922cdf0e10cSrcweir                == aExceptionalKeys[i].nModifierMask )
923cdf0e10cSrcweir            {
924cdf0e10cSrcweir                [self sendKeyInputAndReleaseToFrame: nKeyCode character: 0];
925cdf0e10cSrcweir
926cdf0e10cSrcweir                return YES;
927cdf0e10cSrcweir            }
928cdf0e10cSrcweir        }
929cdf0e10cSrcweir    }
930cdf0e10cSrcweir    return NO;
931cdf0e10cSrcweir}
932cdf0e10cSrcweir
933cdf0e10cSrcweir-(void)flagsChanged: (NSEvent*)pEvent
934cdf0e10cSrcweir{
935cdf0e10cSrcweir    YIELD_GUARD;
936cdf0e10cSrcweir
937cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
938cdf0e10cSrcweir    {
939cdf0e10cSrcweir        mpFrame->mnLastEventTime = static_cast<sal_uLong>( [pEvent timestamp] * 1000.0 );
940cdf0e10cSrcweir        mpFrame->mnLastModifierFlags = [pEvent modifierFlags];
941cdf0e10cSrcweir    }
942cdf0e10cSrcweir}
943cdf0e10cSrcweir
944cdf0e10cSrcweir-(void)insertText:(id)aString
945cdf0e10cSrcweir{
946cdf0e10cSrcweir    YIELD_GUARD;
947cdf0e10cSrcweir
948cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
949cdf0e10cSrcweir    {
950cdf0e10cSrcweir        NSString* pInsert = nil;
951cdf0e10cSrcweir        if( [aString isMemberOfClass: [NSAttributedString class]] )
952cdf0e10cSrcweir            pInsert = [aString string];
953cdf0e10cSrcweir        else
954cdf0e10cSrcweir            pInsert = aString;
955cdf0e10cSrcweir
956cdf0e10cSrcweir        int nLen = 0;
957cdf0e10cSrcweir        if( pInsert && ( nLen = [pInsert length] ) > 0 )
958cdf0e10cSrcweir        {
959cdf0e10cSrcweir            OUString aInsertString( GetOUString( pInsert ) );
960cdf0e10cSrcweir             // aCharCode initializer is safe since aInsertString will at least contain '\0'
961cdf0e10cSrcweir            sal_Unicode aCharCode = *aInsertString.getStr();
962cdf0e10cSrcweir
963cdf0e10cSrcweir            if( nLen == 1 &&
964cdf0e10cSrcweir                aCharCode < 0x80 &&
965cdf0e10cSrcweir                aCharCode > 0x1f &&
966cdf0e10cSrcweir				! [self hasMarkedText ]
967cdf0e10cSrcweir                )
968cdf0e10cSrcweir            {
969cdf0e10cSrcweir                sal_uInt16 nKeyCode = ImplMapCharCode( aCharCode );
970cdf0e10cSrcweir                unsigned int nLastModifiers = mpFrame->mnLastModifierFlags;
971cdf0e10cSrcweir
972cdf0e10cSrcweir                // #i99567#
973cdf0e10cSrcweir                // find out the unmodified key code
974cdf0e10cSrcweir
975cdf0e10cSrcweir                // sanity check
976cdf0e10cSrcweir                if( mpLastEvent && ( [mpLastEvent type] == NSKeyDown || [mpLastEvent type] == NSKeyUp ) )
977cdf0e10cSrcweir                {
978cdf0e10cSrcweir                    // get unmodified string
979cdf0e10cSrcweir                    NSString* pUnmodifiedString = [mpLastEvent charactersIgnoringModifiers];
980cdf0e10cSrcweir                    if( pUnmodifiedString && [pUnmodifiedString length] == 1 )
981cdf0e10cSrcweir                    {
982cdf0e10cSrcweir                        // map the unmodified key code
983cdf0e10cSrcweir                        unichar keyChar = [pUnmodifiedString characterAtIndex: 0];
984cdf0e10cSrcweir                        nKeyCode = ImplMapCharCode( keyChar );
985cdf0e10cSrcweir                    }
986cdf0e10cSrcweir                    nLastModifiers = [mpLastEvent modifierFlags];
987cdf0e10cSrcweir
988cdf0e10cSrcweir                }
989cdf0e10cSrcweir                // #i99567#
990cdf0e10cSrcweir                // applications and vcl's edit fields ignore key events with ALT
991cdf0e10cSrcweir                // however we're at a place where we know text should be inserted
992cdf0e10cSrcweir                // so it seems we need to strip the Alt modifier here
993cdf0e10cSrcweir                if( (nLastModifiers & (NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask))
994cdf0e10cSrcweir                    == NSAlternateKeyMask )
995cdf0e10cSrcweir                {
996cdf0e10cSrcweir                    nLastModifiers = 0;
997cdf0e10cSrcweir                }
998cdf0e10cSrcweir                [self sendKeyInputAndReleaseToFrame: nKeyCode character: aCharCode modifiers: nLastModifiers];
999cdf0e10cSrcweir            }
1000cdf0e10cSrcweir            else
1001cdf0e10cSrcweir            {
1002cdf0e10cSrcweir                SalExtTextInputEvent aEvent;
1003cdf0e10cSrcweir                aEvent.mnTime           = mpFrame->mnLastEventTime;
1004cdf0e10cSrcweir                aEvent.maText           = aInsertString;
1005cdf0e10cSrcweir                aEvent.mpTextAttr       = NULL;
1006cdf0e10cSrcweir                aEvent.mnCursorPos      = aInsertString.getLength();
1007cdf0e10cSrcweir                aEvent.mnDeltaStart     = 0;
1008cdf0e10cSrcweir                aEvent.mnCursorFlags    = 0;
1009cdf0e10cSrcweir                aEvent.mbOnlyCursor     = FALSE;
1010cdf0e10cSrcweir                mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, &aEvent );
1011cdf0e10cSrcweir                if( AquaSalFrame::isAlive( mpFrame ) )
1012cdf0e10cSrcweir                    mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 );
1013cdf0e10cSrcweir            }
1014cdf0e10cSrcweir        }
1015cdf0e10cSrcweir        else
1016cdf0e10cSrcweir        {
1017cdf0e10cSrcweir            SalExtTextInputEvent aEvent;
1018cdf0e10cSrcweir            aEvent.mnTime           = mpFrame->mnLastEventTime;
1019cdf0e10cSrcweir            aEvent.maText           = String();
1020cdf0e10cSrcweir            aEvent.mpTextAttr       = NULL;
1021cdf0e10cSrcweir            aEvent.mnCursorPos      = 0;
1022cdf0e10cSrcweir            aEvent.mnDeltaStart     = 0;
1023cdf0e10cSrcweir            aEvent.mnCursorFlags    = 0;
1024cdf0e10cSrcweir            aEvent.mbOnlyCursor     = FALSE;
1025cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, &aEvent );
1026cdf0e10cSrcweir            if( AquaSalFrame::isAlive( mpFrame ) )
1027cdf0e10cSrcweir                mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 );
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir        }
1030cdf0e10cSrcweir        mbKeyHandled = true;
1031cdf0e10cSrcweir        [self unmarkText];
1032cdf0e10cSrcweir    }
1033cdf0e10cSrcweir}
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir-(void)insertTab: (id)aSender
1036cdf0e10cSrcweir{
1037cdf0e10cSrcweir    (void)aSender;
1038cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_TAB character: '\t' modifiers: 0];
1039cdf0e10cSrcweir}
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir-(void)insertBacktab: (id)aSender
1042cdf0e10cSrcweir{
1043cdf0e10cSrcweir    (void)aSender;
1044cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: (KEY_TAB | KEY_SHIFT) character: '\t' modifiers: 0];
1045cdf0e10cSrcweir}
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir-(void)moveLeft: (id)aSender
1048cdf0e10cSrcweir{
1049cdf0e10cSrcweir    (void)aSender;
1050cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_LEFT character: 0 modifiers: 0];
1051cdf0e10cSrcweir}
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir-(void)moveLeftAndModifySelection: (id)aSender
1054cdf0e10cSrcweir{
1055cdf0e10cSrcweir    (void)aSender;
1056cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_LEFT character: 0 modifiers: NSShiftKeyMask];
1057cdf0e10cSrcweir}
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir-(void)moveBackwardAndModifySelection: (id)aSender
1060cdf0e10cSrcweir{
1061cdf0e10cSrcweir    (void)aSender;
1062cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_BACKWARD character: 0  modifiers: 0];
1063cdf0e10cSrcweir}
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir-(void)moveRight: (id)aSender
1066cdf0e10cSrcweir{
1067cdf0e10cSrcweir    (void)aSender;
1068cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_RIGHT character: 0 modifiers: 0];
1069cdf0e10cSrcweir}
1070cdf0e10cSrcweir
1071cdf0e10cSrcweir-(void)moveRightAndModifySelection: (id)aSender
1072cdf0e10cSrcweir{
1073cdf0e10cSrcweir    (void)aSender;
1074cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_RIGHT character: 0 modifiers: NSShiftKeyMask];
1075cdf0e10cSrcweir}
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir-(void)moveForwardAndModifySelection: (id)aSender
1078cdf0e10cSrcweir{
1079cdf0e10cSrcweir    (void)aSender;
1080cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_FORWARD character: 0  modifiers: 0];
1081cdf0e10cSrcweir}
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir-(void)moveWordLeft: (id)aSender
1084cdf0e10cSrcweir{
1085cdf0e10cSrcweir    (void)aSender;
1086cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_BACKWARD character: 0  modifiers: 0];
1087cdf0e10cSrcweir}
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir-(void)moveWordBackward: (id)aSender
1090cdf0e10cSrcweir{
1091cdf0e10cSrcweir    (void)aSender;
1092cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_BACKWARD character: 0  modifiers: 0];
1093cdf0e10cSrcweir}
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir-(void)moveWordBackwardAndModifySelection: (id)aSender
1096cdf0e10cSrcweir{
1097cdf0e10cSrcweir    (void)aSender;
1098cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_BACKWARD character: 0  modifiers: 0];
1099cdf0e10cSrcweir}
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir-(void)moveWordLeftAndModifySelection: (id)aSender
1102cdf0e10cSrcweir{
1103cdf0e10cSrcweir    (void)aSender;
1104cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_BACKWARD character: 0  modifiers: 0];
1105cdf0e10cSrcweir}
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir-(void)moveWordRight: (id)aSender
1108cdf0e10cSrcweir{
1109cdf0e10cSrcweir    (void)aSender;
1110cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_FORWARD character: 0  modifiers: 0];
1111cdf0e10cSrcweir}
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir-(void)moveWordForward: (id)aSender
1114cdf0e10cSrcweir{
1115cdf0e10cSrcweir    (void)aSender;
1116cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_WORD_FORWARD character: 0  modifiers: 0];
1117cdf0e10cSrcweir}
1118cdf0e10cSrcweir
1119cdf0e10cSrcweir-(void)moveWordForwardAndModifySelection: (id)aSender
1120cdf0e10cSrcweir{
1121cdf0e10cSrcweir    (void)aSender;
1122cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_FORWARD character: 0  modifiers: 0];
1123cdf0e10cSrcweir}
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir-(void)moveWordRightAndModifySelection: (id)aSender
1126cdf0e10cSrcweir{
1127cdf0e10cSrcweir    (void)aSender;
1128cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD_FORWARD character: 0  modifiers: 0];
1129cdf0e10cSrcweir}
1130cdf0e10cSrcweir
1131cdf0e10cSrcweir-(void)moveToEndOfLine: (id)aSender
1132cdf0e10cSrcweir{
1133cdf0e10cSrcweir    (void)aSender;
1134cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_LINE character: 0  modifiers: 0];
1135cdf0e10cSrcweir}
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir-(void)moveToRightEndOfLine: (id)aSender
1138cdf0e10cSrcweir{
1139cdf0e10cSrcweir    (void)aSender;
1140cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_LINE character: 0  modifiers: 0];
1141cdf0e10cSrcweir}
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir-(void)moveToEndOfLineAndModifySelection: (id)aSender
1144cdf0e10cSrcweir{
1145cdf0e10cSrcweir    (void)aSender;
1146cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_LINE character: 0  modifiers: 0];
1147cdf0e10cSrcweir}
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir-(void)moveToRightEndOfLineAndModifySelection: (id)aSender
1150cdf0e10cSrcweir{
1151cdf0e10cSrcweir    (void)aSender;
1152cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_LINE character: 0  modifiers: 0];
1153cdf0e10cSrcweir}
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir-(void)moveToBeginningOfLine: (id)aSender
1156cdf0e10cSrcweir{
1157cdf0e10cSrcweir    (void)aSender;
1158cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE character: 0  modifiers: 0];
1159cdf0e10cSrcweir}
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir-(void)moveToLeftEndOfLine: (id)aSender
1162cdf0e10cSrcweir{
1163cdf0e10cSrcweir    (void)aSender;
1164cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE character: 0  modifiers: 0];
1165cdf0e10cSrcweir}
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir-(void)moveToBeginningOfLineAndModifySelection: (id)aSender
1168cdf0e10cSrcweir{
1169cdf0e10cSrcweir    (void)aSender;
1170cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE character: 0  modifiers: 0];
1171cdf0e10cSrcweir}
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir-(void)moveToLeftEndOfLineAndModifySelection: (id)aSender
1174cdf0e10cSrcweir{
1175cdf0e10cSrcweir    (void)aSender;
1176cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE character: 0  modifiers: 0];
1177cdf0e10cSrcweir}
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir-(void)moveToEndOfParagraph: (id)aSender
1180cdf0e10cSrcweir{
1181cdf0e10cSrcweir    (void)aSender;
1182cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH character: 0  modifiers: 0];
1183cdf0e10cSrcweir}
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir-(void)moveToEndOfParagraphAndModifySelection: (id)aSender
1186cdf0e10cSrcweir{
1187cdf0e10cSrcweir    (void)aSender;
1188cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH character: 0  modifiers: 0];
1189cdf0e10cSrcweir}
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir-(void)moveParagraphForward: (id)aSender
1192cdf0e10cSrcweir{
1193cdf0e10cSrcweir    (void)aSender;
1194cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH character: 0  modifiers: 0];
1195cdf0e10cSrcweir}
1196cdf0e10cSrcweir
1197cdf0e10cSrcweir-(void)moveParagraphForwardAndModifySelection: (id)aSender
1198cdf0e10cSrcweir{
1199cdf0e10cSrcweir    (void)aSender;
1200cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH character: 0  modifiers: 0];
1201cdf0e10cSrcweir}
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir-(void)moveToBeginningOfParagraph: (id)aSender
1204cdf0e10cSrcweir{
1205cdf0e10cSrcweir    (void)aSender;
1206cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH character: 0  modifiers: 0];
1207cdf0e10cSrcweir}
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir-(void)moveParagraphBackward: (id)aSender
1210cdf0e10cSrcweir{
1211cdf0e10cSrcweir    (void)aSender;
1212cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH character: 0  modifiers: 0];
1213cdf0e10cSrcweir}
1214cdf0e10cSrcweir
1215cdf0e10cSrcweir-(void)moveToBeginningOfParagraphAndModifySelection: (id)aSender
1216cdf0e10cSrcweir{
1217cdf0e10cSrcweir    (void)aSender;
1218cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH character: 0  modifiers: 0];
1219cdf0e10cSrcweir}
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir-(void)moveParagraphBackwardAndModifySelection: (id)aSender
1222cdf0e10cSrcweir{
1223cdf0e10cSrcweir    (void)aSender;
1224cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH character: 0  modifiers: 0];
1225cdf0e10cSrcweir}
1226cdf0e10cSrcweir
1227cdf0e10cSrcweir-(void)moveToEndOfDocument: (id)aSender
1228cdf0e10cSrcweir{
1229cdf0e10cSrcweir    (void)aSender;
1230cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT character: 0  modifiers: 0];
1231cdf0e10cSrcweir}
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir-(void)scrollToEndOfDocument: (id)aSender
1234cdf0e10cSrcweir{
1235cdf0e10cSrcweir    (void)aSender;
1236cdf0e10cSrcweir    // this is not exactly what we should do, but it makes "End" and "Shift-End" behave consistent
1237cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT character: 0  modifiers: 0];
1238cdf0e10cSrcweir}
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir-(void)moveToEndOfDocumentAndModifySelection: (id)aSender
1241cdf0e10cSrcweir{
1242cdf0e10cSrcweir    (void)aSender;
1243cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT character: 0  modifiers: 0];
1244cdf0e10cSrcweir}
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir-(void)moveToBeginningOfDocument: (id)aSender
1247cdf0e10cSrcweir{
1248cdf0e10cSrcweir    (void)aSender;
1249cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT character: 0  modifiers: 0];
1250cdf0e10cSrcweir}
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir-(void)scrollToBeginningOfDocument: (id)aSender
1253cdf0e10cSrcweir{
1254cdf0e10cSrcweir    (void)aSender;
1255cdf0e10cSrcweir    // this is not exactly what we should do, but it makes "Home" and "Shift-Home" behave consistent
1256cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT character: 0  modifiers: 0];
1257cdf0e10cSrcweir}
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir-(void)moveToBeginningOfDocumentAndModifySelection: (id)aSender
1260cdf0e10cSrcweir{
1261cdf0e10cSrcweir    (void)aSender;
1262cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT character: 0  modifiers: 0];
1263cdf0e10cSrcweir}
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir-(void)moveUp: (id)aSender
1266cdf0e10cSrcweir{
1267cdf0e10cSrcweir    (void)aSender;
1268cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_UP character: 0 modifiers: 0];
1269cdf0e10cSrcweir}
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir-(void)moveDown: (id)aSender
1272cdf0e10cSrcweir{
1273cdf0e10cSrcweir    (void)aSender;
1274cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_DOWN character: 0 modifiers: 0];
1275cdf0e10cSrcweir}
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir-(void)insertNewline: (id)aSender
1278cdf0e10cSrcweir{
1279cdf0e10cSrcweir    (void)aSender;
1280cdf0e10cSrcweir    // #i91267# make enter and shift-enter work by evaluating the modifiers
1281cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_RETURN character: '\n' modifiers: mpFrame->mnLastModifierFlags];
1282cdf0e10cSrcweir}
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir-(void)deleteBackward: (id)aSender
1285cdf0e10cSrcweir{
1286cdf0e10cSrcweir    (void)aSender;
1287cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_BACKSPACE character: '\b' modifiers: 0];
1288cdf0e10cSrcweir}
1289cdf0e10cSrcweir
1290cdf0e10cSrcweir-(void)deleteForward: (id)aSender
1291cdf0e10cSrcweir{
1292cdf0e10cSrcweir    (void)aSender;
1293cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_DELETE character: 0x7f modifiers: 0];
1294cdf0e10cSrcweir}
1295cdf0e10cSrcweir
1296cdf0e10cSrcweir-(void)deleteBackwardByDecomposingPreviousCharacter: (id)aSender
1297cdf0e10cSrcweir{
1298cdf0e10cSrcweir    (void)aSender;
1299cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_BACKSPACE character: '\b' modifiers: 0];
1300cdf0e10cSrcweir}
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir-(void)deleteWordBackward: (id)aSender
1303cdf0e10cSrcweir{
1304cdf0e10cSrcweir    (void)aSender;
1305cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_WORD_BACKWARD character: 0  modifiers: 0];
1306cdf0e10cSrcweir}
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir-(void)deleteWordForward: (id)aSender
1309cdf0e10cSrcweir{
1310cdf0e10cSrcweir    (void)aSender;
1311cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_WORD_FORWARD character: 0  modifiers: 0];
1312cdf0e10cSrcweir}
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir-(void)deleteToBeginningOfLine: (id)aSender
1315cdf0e10cSrcweir{
1316cdf0e10cSrcweir    (void)aSender;
1317cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE character: 0  modifiers: 0];
1318cdf0e10cSrcweir}
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir-(void)deleteToEndOfLine: (id)aSender
1321cdf0e10cSrcweir{
1322cdf0e10cSrcweir    (void)aSender;
1323cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_END_OF_LINE character: 0  modifiers: 0];
1324cdf0e10cSrcweir}
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir-(void)deleteToBeginningOfParagraph: (id)aSender
1327cdf0e10cSrcweir{
1328cdf0e10cSrcweir    (void)aSender;
1329cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH character: 0  modifiers: 0];
1330cdf0e10cSrcweir}
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir-(void)deleteToEndOfParagraph: (id)aSender
1333cdf0e10cSrcweir{
1334cdf0e10cSrcweir    (void)aSender;
1335cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH character: 0  modifiers: 0];
1336cdf0e10cSrcweir}
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir-(void)insertLineBreak: (id)aSender
1339cdf0e10cSrcweir{
1340cdf0e10cSrcweir    (void)aSender;
1341cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::INSERT_LINEBREAK character: 0  modifiers: 0];
1342cdf0e10cSrcweir}
1343cdf0e10cSrcweir
1344cdf0e10cSrcweir-(void)insertParagraphSeparator: (id)aSender
1345cdf0e10cSrcweir{
1346cdf0e10cSrcweir    (void)aSender;
1347cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::INSERT_PARAGRAPH character: 0  modifiers: 0];
1348cdf0e10cSrcweir}
1349cdf0e10cSrcweir
1350cdf0e10cSrcweir-(void)selectWord: (id)aSender
1351cdf0e10cSrcweir{
1352cdf0e10cSrcweir    (void)aSender;
1353cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_WORD character: 0  modifiers: 0];
1354cdf0e10cSrcweir}
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir-(void)selectLine: (id)aSender
1357cdf0e10cSrcweir{
1358cdf0e10cSrcweir    (void)aSender;
1359cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_LINE character: 0  modifiers: 0];
1360cdf0e10cSrcweir}
1361cdf0e10cSrcweir
1362cdf0e10cSrcweir-(void)selectParagraph: (id)aSender
1363cdf0e10cSrcweir{
1364cdf0e10cSrcweir    (void)aSender;
1365cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_PARAGRAPH character: 0  modifiers: 0];
1366cdf0e10cSrcweir}
1367cdf0e10cSrcweir
1368cdf0e10cSrcweir-(void)selectAll: (id)aSender
1369cdf0e10cSrcweir{
1370cdf0e10cSrcweir    (void)aSender;
1371cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: com::sun::star::awt::Key::SELECT_ALL character: 0  modifiers: 0];
1372cdf0e10cSrcweir}
1373cdf0e10cSrcweir
1374cdf0e10cSrcweir-(void)cancelOperation: (id)aSender
1375cdf0e10cSrcweir{
1376cdf0e10cSrcweir    (void)aSender;
1377cdf0e10cSrcweir    [self sendKeyInputAndReleaseToFrame: KEY_ESCAPE character: 0x1b modifiers: 0];
1378cdf0e10cSrcweir}
1379cdf0e10cSrcweir
1380cdf0e10cSrcweir-(void)noop: (id)aSender
1381cdf0e10cSrcweir{
1382cdf0e10cSrcweir    (void)aSender;
1383cdf0e10cSrcweir    if( ! mbKeyHandled )
1384cdf0e10cSrcweir    {
1385cdf0e10cSrcweir        if( ! [self sendSingleCharacter:mpLastEvent] )
1386cdf0e10cSrcweir        {
1387cdf0e10cSrcweir            /* prevent recursion */
1388cdf0e10cSrcweir            if( mpLastEvent != mpLastSuperEvent && [NSApp respondsToSelector: @selector(sendSuperEvent:)] )
1389cdf0e10cSrcweir            {
1390cdf0e10cSrcweir                id pLastSuperEvent = mpLastSuperEvent;
1391cdf0e10cSrcweir                mpLastSuperEvent = mpLastEvent;
1392cdf0e10cSrcweir                [NSApp performSelector:@selector(sendSuperEvent:) withObject: mpLastEvent];
1393cdf0e10cSrcweir                mpLastSuperEvent = pLastSuperEvent;
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir                std::map< NSEvent*, bool >::iterator it = GetSalData()->maKeyEventAnswer.find( mpLastEvent );
1396cdf0e10cSrcweir                if( it != GetSalData()->maKeyEventAnswer.end() )
1397cdf0e10cSrcweir                    it->second = true;
1398cdf0e10cSrcweir            }
1399cdf0e10cSrcweir        }
1400cdf0e10cSrcweir    }
1401cdf0e10cSrcweir}
1402cdf0e10cSrcweir
1403cdf0e10cSrcweir-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar
1404cdf0e10cSrcweir{
1405cdf0e10cSrcweir    return [self sendKeyInputAndReleaseToFrame: nKeyCode character: aChar modifiers: mpFrame->mnLastModifierFlags];
1406cdf0e10cSrcweir}
1407cdf0e10cSrcweir
1408cdf0e10cSrcweir-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod
1409cdf0e10cSrcweir{
1410cdf0e10cSrcweir    return [self sendKeyToFrameDirect: nKeyCode character: aChar modifiers: nMod] ||
1411cdf0e10cSrcweir           [self sendSingleCharacter: mpLastEvent];
1412cdf0e10cSrcweir}
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir-(BOOL)sendKeyToFrameDirect: (sal_uInt16)nKeyCode  character: (sal_Unicode)aChar modifiers: (unsigned int)nMod
1415cdf0e10cSrcweir{
1416cdf0e10cSrcweir    YIELD_GUARD;
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir    long nRet = 0;
1419cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
1420cdf0e10cSrcweir    {
1421cdf0e10cSrcweir        SalKeyEvent aEvent;
1422cdf0e10cSrcweir        aEvent.mnTime           = mpFrame->mnLastEventTime;
1423cdf0e10cSrcweir        aEvent.mnCode           = nKeyCode | ImplGetModifierMask( nMod );
1424cdf0e10cSrcweir        aEvent.mnCharCode       = aChar;
1425cdf0e10cSrcweir        aEvent.mnRepeat         = FALSE;
1426cdf0e10cSrcweir        nRet = mpFrame->CallCallback( SALEVENT_KEYINPUT, &aEvent );
1427cdf0e10cSrcweir        std::map< NSEvent*, bool >::iterator it = GetSalData()->maKeyEventAnswer.find( mpLastEvent );
1428cdf0e10cSrcweir        if( it != GetSalData()->maKeyEventAnswer.end() )
1429cdf0e10cSrcweir            it->second = nRet ? true : false;
1430cdf0e10cSrcweir        if( AquaSalFrame::isAlive( mpFrame ) )
1431cdf0e10cSrcweir            mpFrame->CallCallback( SALEVENT_KEYUP, &aEvent );
1432cdf0e10cSrcweir    }
1433cdf0e10cSrcweir    return nRet ? YES : NO;
1434cdf0e10cSrcweir}
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir
1437cdf0e10cSrcweir-(BOOL)sendSingleCharacter: (NSEvent *)pEvent
1438cdf0e10cSrcweir{
1439cdf0e10cSrcweir    NSString* pUnmodifiedString = [pEvent charactersIgnoringModifiers];
1440cdf0e10cSrcweir
1441cdf0e10cSrcweir    if( pUnmodifiedString && [pUnmodifiedString length] == 1 )
1442cdf0e10cSrcweir    {
1443cdf0e10cSrcweir        unichar keyChar = [pUnmodifiedString characterAtIndex: 0];
1444cdf0e10cSrcweir        sal_uInt16 nKeyCode = ImplMapCharCode( keyChar );
1445cdf0e10cSrcweir        if( nKeyCode != 0 )
1446cdf0e10cSrcweir        {
1447cdf0e10cSrcweir            // don't send unicodes in the private use area
1448cdf0e10cSrcweir            if( keyChar >= 0xf700 && keyChar < 0xf780 )
1449cdf0e10cSrcweir                keyChar = 0;
1450cdf0e10cSrcweir            BOOL bRet = [self sendKeyToFrameDirect: nKeyCode character: keyChar modifiers: mpFrame->mnLastModifierFlags];
1451cdf0e10cSrcweir            mbInKeyInput = false;
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir            return bRet;
1454cdf0e10cSrcweir        }
1455cdf0e10cSrcweir    }
1456cdf0e10cSrcweir    return NO;
1457cdf0e10cSrcweir}
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir// NSTextInput protocol
1461cdf0e10cSrcweir- (NSArray *)validAttributesForMarkedText
1462cdf0e10cSrcweir{
1463cdf0e10cSrcweir    return [NSArray arrayWithObjects:NSUnderlineStyleAttributeName, nil];
1464cdf0e10cSrcweir}
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir- (BOOL)hasMarkedText
1467cdf0e10cSrcweir{
1468cdf0e10cSrcweir    BOOL bHasMarkedText;
1469cdf0e10cSrcweir
1470cdf0e10cSrcweir    bHasMarkedText = ( mMarkedRange.location != NSNotFound ) &&
1471cdf0e10cSrcweir                     ( mMarkedRange.length != 0 );
1472cdf0e10cSrcweir    // hack to check keys like "Control-j"
1473cdf0e10cSrcweir    if( mbInKeyInput )
1474cdf0e10cSrcweir    {
1475cdf0e10cSrcweir        mbNeedSpecialKeyHandle = true;
1476cdf0e10cSrcweir    }
1477cdf0e10cSrcweir
1478cdf0e10cSrcweir    // FIXME:
1479cdf0e10cSrcweir    // #i106901#
1480cdf0e10cSrcweir    // if we come here outside of mbInKeyInput, this is likely to be because
1481cdf0e10cSrcweir    // of the keyboard viewer. For unknown reasons having no marked range
1482cdf0e10cSrcweir    // in this case causes a crash. So we say we have a marked range anyway
1483cdf0e10cSrcweir    // This is a hack, since it is not understood what a) causes that crash
1484cdf0e10cSrcweir    // and b) why we should have a marked range at this point.
1485cdf0e10cSrcweir    if( ! mbInKeyInput )
1486cdf0e10cSrcweir        bHasMarkedText = YES;
1487cdf0e10cSrcweir
1488cdf0e10cSrcweir    return bHasMarkedText;
1489cdf0e10cSrcweir}
1490cdf0e10cSrcweir
1491cdf0e10cSrcweir- (NSRange)markedRange
1492cdf0e10cSrcweir{
1493cdf0e10cSrcweir    // FIXME:
1494cdf0e10cSrcweir    // #i106901#
1495cdf0e10cSrcweir    // if we come here outside of mbInKeyInput, this is likely to be because
1496cdf0e10cSrcweir    // of the keyboard viewer. For unknown reasons having no marked range
1497cdf0e10cSrcweir    // in this case causes a crash. So we say we have a marked range anyway
1498cdf0e10cSrcweir    // This is a hack, since it is not understood what a) causes that crash
1499cdf0e10cSrcweir    // and b) why we should have a marked range at this point.
1500cdf0e10cSrcweir    if( ! mbInKeyInput )
1501cdf0e10cSrcweir        return NSMakeRange( 0, 0 );
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir    return [self hasMarkedText] ? mMarkedRange : NSMakeRange( NSNotFound, 0 );
1504cdf0e10cSrcweir}
1505cdf0e10cSrcweir
1506cdf0e10cSrcweir- (NSRange)selectedRange
1507cdf0e10cSrcweir{
1508cdf0e10cSrcweir    return mSelectedRange;
1509cdf0e10cSrcweir}
1510cdf0e10cSrcweir
1511cdf0e10cSrcweir- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange
1512cdf0e10cSrcweir{
1513cdf0e10cSrcweir    if( ![aString isKindOfClass:[NSAttributedString class]] )
1514cdf0e10cSrcweir        aString = [[[NSAttributedString alloc] initWithString:aString] autorelease];
1515cdf0e10cSrcweir    NSRange rangeToReplace = [self hasMarkedText] ? [self markedRange] : [self selectedRange];
1516cdf0e10cSrcweir    if( rangeToReplace.location == NSNotFound )
1517cdf0e10cSrcweir    {
1518cdf0e10cSrcweir        mMarkedRange = NSMakeRange( selRange.location, [aString length] );
1519cdf0e10cSrcweir        mSelectedRange = NSMakeRange( selRange.location, selRange.length );
1520cdf0e10cSrcweir    }
1521cdf0e10cSrcweir    else
1522cdf0e10cSrcweir    {
1523cdf0e10cSrcweir        mMarkedRange = NSMakeRange( rangeToReplace.location, [aString length] );
1524cdf0e10cSrcweir        mSelectedRange = NSMakeRange( rangeToReplace.location + selRange.location, selRange.length );
1525cdf0e10cSrcweir    }
1526cdf0e10cSrcweir
1527cdf0e10cSrcweir    int len = [aString length];
1528cdf0e10cSrcweir    SalExtTextInputEvent aInputEvent;
1529cdf0e10cSrcweir    aInputEvent.mnTime = mpFrame->mnLastEventTime;
1530cdf0e10cSrcweir    aInputEvent.mnDeltaStart = 0;
1531cdf0e10cSrcweir    aInputEvent.mbOnlyCursor = FALSE;
1532cdf0e10cSrcweir    if( len > 0 ) {
1533cdf0e10cSrcweir        NSString *pString = [aString string];
1534cdf0e10cSrcweir        OUString aInsertString( GetOUString( pString ) );
1535cdf0e10cSrcweir        std::vector<sal_uInt16> aInputFlags = std::vector<sal_uInt16>( std::max( 1, len ), 0 );
1536cdf0e10cSrcweir        for ( int i = 0; i < len; i++ )
1537cdf0e10cSrcweir        {
1538cdf0e10cSrcweir            unsigned int nUnderlineValue;
1539cdf0e10cSrcweir            NSRange effectiveRange;
1540cdf0e10cSrcweir
1541cdf0e10cSrcweir            effectiveRange = NSMakeRange(i, 1);
1542cdf0e10cSrcweir            nUnderlineValue = [[aString attribute:NSUnderlineStyleAttributeName atIndex:i effectiveRange:&effectiveRange] unsignedIntValue];
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir            switch (nUnderlineValue & 0xff) {
1545cdf0e10cSrcweir            case NSUnderlineStyleSingle:
1546cdf0e10cSrcweir                aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_UNDERLINE;
1547cdf0e10cSrcweir                break;
1548cdf0e10cSrcweir            case NSUnderlineStyleThick:
1549cdf0e10cSrcweir                aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_UNDERLINE | SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT;
1550cdf0e10cSrcweir                break;
1551cdf0e10cSrcweir            case NSUnderlineStyleDouble:
1552cdf0e10cSrcweir                aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_BOLDUNDERLINE;
1553cdf0e10cSrcweir                break;
1554cdf0e10cSrcweir            default:
1555cdf0e10cSrcweir                aInputFlags[i] = SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT;
1556cdf0e10cSrcweir                break;
1557cdf0e10cSrcweir            }
1558cdf0e10cSrcweir        }
1559cdf0e10cSrcweir
1560cdf0e10cSrcweir        aInputEvent.maText = aInsertString;
1561cdf0e10cSrcweir        aInputEvent.mnCursorPos = selRange.location;
1562cdf0e10cSrcweir        aInputEvent.mpTextAttr = &aInputFlags[0];
1563cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void *)&aInputEvent );
1564cdf0e10cSrcweir    } else {
1565cdf0e10cSrcweir        aInputEvent.maText = String();
1566cdf0e10cSrcweir        aInputEvent.mnCursorPos = 0;
1567cdf0e10cSrcweir        aInputEvent.mnCursorFlags = 0;
1568cdf0e10cSrcweir        aInputEvent.mpTextAttr = 0;
1569cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void *)&aInputEvent );
1570cdf0e10cSrcweir        mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 );
1571cdf0e10cSrcweir    }
1572cdf0e10cSrcweir    mbKeyHandled= true;
1573cdf0e10cSrcweir}
1574cdf0e10cSrcweir
1575cdf0e10cSrcweir- (void)unmarkText
1576cdf0e10cSrcweir{
1577cdf0e10cSrcweir    mSelectedRange = mMarkedRange = NSMakeRange(NSNotFound, 0);
1578cdf0e10cSrcweir}
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange
1581cdf0e10cSrcweir{
1582cdf0e10cSrcweir    (void)theRange;
1583cdf0e10cSrcweir    // FIXME
1584cdf0e10cSrcweir    return nil;
1585cdf0e10cSrcweir}
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir- (unsigned int)characterIndexForPoint:(NSPoint)thePoint
1588cdf0e10cSrcweir{
1589cdf0e10cSrcweir    (void)thePoint;
1590cdf0e10cSrcweir    // FIXME
1591cdf0e10cSrcweir    return 0;
1592cdf0e10cSrcweir}
1593cdf0e10cSrcweir
1594cdf0e10cSrcweir#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
1595cdf0e10cSrcweir/* build target 10.5 or greater */
1596cdf0e10cSrcweir- (NSInteger)conversationIdentifier
1597cdf0e10cSrcweir#else
1598cdf0e10cSrcweir/* build target 10.4 */
1599cdf0e10cSrcweir- (long)conversationIdentifier
1600cdf0e10cSrcweir#endif
1601cdf0e10cSrcweir{
1602cdf0e10cSrcweir    return (long)self;
1603cdf0e10cSrcweir}
1604cdf0e10cSrcweir
1605cdf0e10cSrcweir- (void)doCommandBySelector:(SEL)aSelector
1606cdf0e10cSrcweir{
1607cdf0e10cSrcweir    if( AquaSalFrame::isAlive( mpFrame ) )
1608cdf0e10cSrcweir    {
1609cdf0e10cSrcweir        #if OSL_DEBUG_LEVEL > 1
1610cdf0e10cSrcweir        // fprintf( stderr, "SalFrameView: doCommandBySelector %s\n", (char*)aSelector );
1611cdf0e10cSrcweir        #endif
1612cdf0e10cSrcweir        if( (mpFrame->mnICOptions & SAL_INPUTCONTEXT_TEXT) != 0 &&
1613cdf0e10cSrcweir            aSelector != NULL && [self respondsToSelector: aSelector] )
1614cdf0e10cSrcweir        {
1615cdf0e10cSrcweir            [self performSelector: aSelector];
1616cdf0e10cSrcweir        }
1617cdf0e10cSrcweir        else
1618cdf0e10cSrcweir        {
1619cdf0e10cSrcweir            [self sendSingleCharacter:mpLastEvent];
1620cdf0e10cSrcweir        }
1621cdf0e10cSrcweir    }
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir    mbKeyHandled = true;
1624cdf0e10cSrcweir}
1625cdf0e10cSrcweir
1626cdf0e10cSrcweir-(void)clearLastEvent
1627cdf0e10cSrcweir{
1628cdf0e10cSrcweir    mpLastEvent = nil;
1629cdf0e10cSrcweir}
1630cdf0e10cSrcweir
1631cdf0e10cSrcweir- (NSRect)firstRectForCharacterRange:(NSRange)theRange
1632cdf0e10cSrcweir{
1633cdf0e10cSrcweir    (void)theRange;
1634cdf0e10cSrcweir    SalExtTextInputPosEvent aPosEvent;
1635cdf0e10cSrcweir    mpFrame->CallCallback( SALEVENT_EXTTEXTINPUTPOS, (void *)&aPosEvent );
1636cdf0e10cSrcweir
1637cdf0e10cSrcweir    NSRect rect;
1638cdf0e10cSrcweir
1639cdf0e10cSrcweir    rect.origin.x = aPosEvent.mnX + mpFrame->maGeometry.nX;
1640cdf0e10cSrcweir    rect.origin.y =   aPosEvent.mnY + mpFrame->maGeometry.nY + 4; // add some space for underlines
1641cdf0e10cSrcweir    rect.size.width = aPosEvent.mnWidth;
1642cdf0e10cSrcweir    rect.size.height = aPosEvent.mnHeight;
1643cdf0e10cSrcweir
1644cdf0e10cSrcweir    mpFrame->VCLToCocoa( rect );
1645cdf0e10cSrcweir    return rect;
1646cdf0e10cSrcweir}
1647cdf0e10cSrcweir
1648cdf0e10cSrcweir-(id)parentAttribute {
1649cdf0e10cSrcweir    return (NSView *) mpFrame -> mpWindow;
1650cdf0e10cSrcweir}
1651cdf0e10cSrcweir
1652cdf0e10cSrcweir-(::com::sun::star::accessibility::XAccessibleContext *)accessibleContext
1653cdf0e10cSrcweir{
1654cdf0e10cSrcweir    if ( mpReferenceWrapper == nil ) {
1655cdf0e10cSrcweir        // some frames never become visible ..
1656cdf0e10cSrcweir        Window *pWindow = mpFrame -> GetWindow();
1657cdf0e10cSrcweir        if ( ! pWindow )
1658cdf0e10cSrcweir            return nil;
1659cdf0e10cSrcweir
1660cdf0e10cSrcweir        mpReferenceWrapper = new ReferenceWrapper;
1661cdf0e10cSrcweir        mpReferenceWrapper -> rAccessibleContext =  pWindow -> /*GetAccessibleChildWindow( 0 ) ->*/ GetAccessible() -> getAccessibleContext();
1662cdf0e10cSrcweir        [ AquaA11yFactory insertIntoWrapperRepository: self forAccessibleContext: mpReferenceWrapper -> rAccessibleContext ];
1663cdf0e10cSrcweir    }
1664cdf0e10cSrcweir    return [ super accessibleContext ];
1665cdf0e10cSrcweir}
1666cdf0e10cSrcweir
1667cdf0e10cSrcweir-(NSView *)viewElementForParent
1668cdf0e10cSrcweir{
1669cdf0e10cSrcweir    return (NSView *) mpFrame -> mpWindow;
1670cdf0e10cSrcweir}
1671cdf0e10cSrcweir
1672cdf0e10cSrcweir-(void)registerMouseEventListener: (id)theListener
1673cdf0e10cSrcweir{
1674cdf0e10cSrcweir  mpMouseEventListener = theListener;
1675cdf0e10cSrcweir}
1676cdf0e10cSrcweir
1677cdf0e10cSrcweir-(void)unregisterMouseEventListener: (id)theListener
1678cdf0e10cSrcweir{
1679cdf0e10cSrcweir    (void)theListener;
1680cdf0e10cSrcweir    mpMouseEventListener = nil;
1681cdf0e10cSrcweir}
1682cdf0e10cSrcweir
1683cdf0e10cSrcweir-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
1684cdf0e10cSrcweir{
1685cdf0e10cSrcweir  return [mDraggingDestinationHandler draggingEntered: sender];
1686cdf0e10cSrcweir}
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
1689cdf0e10cSrcweir{
1690cdf0e10cSrcweir  return [mDraggingDestinationHandler draggingUpdated: sender];
1691cdf0e10cSrcweir}
1692cdf0e10cSrcweir
1693cdf0e10cSrcweir-(void)draggingExited:(id <NSDraggingInfo>)sender
1694cdf0e10cSrcweir{
1695cdf0e10cSrcweir  [mDraggingDestinationHandler draggingExited: sender];
1696cdf0e10cSrcweir}
1697cdf0e10cSrcweir
1698cdf0e10cSrcweir-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
1699cdf0e10cSrcweir{
1700cdf0e10cSrcweir  return [mDraggingDestinationHandler prepareForDragOperation: sender];
1701cdf0e10cSrcweir}
1702cdf0e10cSrcweir
1703cdf0e10cSrcweir-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
1704cdf0e10cSrcweir{
1705cdf0e10cSrcweir  return [mDraggingDestinationHandler performDragOperation: sender];
1706cdf0e10cSrcweir}
1707cdf0e10cSrcweir
1708cdf0e10cSrcweir-(void)concludeDragOperation:(id <NSDraggingInfo>)sender
1709cdf0e10cSrcweir{
1710cdf0e10cSrcweir  [mDraggingDestinationHandler concludeDragOperation: sender];
1711cdf0e10cSrcweir}
1712cdf0e10cSrcweir
1713cdf0e10cSrcweir-(void)registerDraggingDestinationHandler:(id)theHandler
1714cdf0e10cSrcweir{
1715cdf0e10cSrcweir  mDraggingDestinationHandler = theHandler;
1716cdf0e10cSrcweir}
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir-(void)unregisterDraggingDestinationHandler:(id)theHandler
1719cdf0e10cSrcweir{
1720cdf0e10cSrcweir    (void)theHandler;
1721cdf0e10cSrcweir    mDraggingDestinationHandler = nil;
1722cdf0e10cSrcweir}
1723cdf0e10cSrcweir
1724cdf0e10cSrcweir@end
1725cdf0e10cSrcweir
1726