xref: /aoo41x/main/sw/source/ui/docvw/edtwin.cxx (revision b8d1dc32)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <tools/list.hxx>
29 #include <swtypes.hxx>
30 #include <hintids.hxx>
31 #include <com/sun/star/accessibility/XAccessible.hpp>
32 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/i18n/XBreakIterator.hpp>
34 #include <com/sun/star/i18n/ScriptType.hpp>
35 #include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
36 
37 #include <com/sun/star/i18n/UnicodeScript.hpp>
38 
39 #include <vcl/help.hxx>
40 #include <vcl/graph.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <vcl/cmdevt.h>
43 #include <sot/storage.hxx>
44 #include <svl/macitem.hxx>
45 #include <unotools/securityoptions.hxx>
46 #include <basic/sbxvar.hxx>
47 #include <svl/ctloptions.hxx>
48 #include <basic/sbx.hxx>
49 #include <svl/eitem.hxx>
50 #include <svl/stritem.hxx>
51 #include <sfx2/ipclient.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <svl/ptitem.hxx>
57 #include <editeng/sizeitem.hxx>
58 #include <editeng/langitem.hxx>
59 #include <svx/htmlmode.hxx>
60 #include <svx/svdview.hxx>
61 #include <svx/svdhdl.hxx>
62 #include <svx/svdoutl.hxx>
63 #include <editeng/editeng.hxx>
64 #include <editeng/svxacorr.hxx>
65 #include <editeng/scripttypeitem.hxx>
66 #include <editeng/flditem.hxx>
67 #include <editeng/colritem.hxx>
68 #include <editeng/brshitem.hxx>
69 #include <editeng/wghtitem.hxx>
70 #include <editeng/udlnitem.hxx>
71 #include <editeng/postitem.hxx>
72 #include <editeng/protitem.hxx>
73 #include <unotools/charclass.hxx>
74 
75 #include <editeng/acorrcfg.hxx>
76 #include <SwSmartTagMgr.hxx>
77 #include <edtwin.hxx>
78 #include <view.hxx>
79 #include <wrtsh.hxx>
80 #include <IDocumentSettingAccess.hxx>
81 #include <fldbas.hxx>
82 #include <swmodule.hxx>
83 #include <docsh.hxx>
84 #include <viewopt.hxx>
85 #include <drawbase.hxx>
86 #include <dselect.hxx>
87 #include <textsh.hxx>
88 #include <shdwcrsr.hxx>
89 #include <fmtanchr.hxx>
90 #include <fmtornt.hxx>
91 #include <fmtfsize.hxx>
92 #include <fmtclds.hxx>
93 #include <frmfmt.hxx>
94 #include <modcfg.hxx>
95 #include <fmtcol.hxx>
96 #include <wview.hxx>
97 #include <listsh.hxx>
98 #include <gloslst.hxx>
99 #include <inputwin.hxx>
100 #include <gloshdl.hxx>
101 #include <swundo.hxx>
102 #include <drwtxtsh.hxx>
103 #include <fchrfmt.hxx>
104 #include <fmturl.hxx>
105 #include <romenu.hxx>
106 #include <initui.hxx>
107 #include <frmatr.hxx>
108 #include <extinput.hxx>
109 #include <acmplwrd.hxx>
110 #include <swcalwrp.hxx>
111 #include <swdtflvr.hxx>
112 #include <wdocsh.hxx>
113 #include <crsskip.hxx>
114 #include <breakit.hxx>
115 #include <checkit.hxx>
116 
117 #include <helpid.h>
118 #include <cmdid.h>
119 #ifndef _DOCVW_HRC
120 #include <docvw.hrc>
121 #endif
122 #include <uitool.hxx>
123 // OD 18.09.2003 #i18732#
124 #include <fmtfollowtextflow.hxx>
125 #include <toolkit/helper/vclunohelper.hxx>
126 #include <charfmt.hxx>
127 #include <numrule.hxx>
128 #include <pagedesc.hxx>
129 #include <svtools/ruler.hxx> // #i23726#
130 #include "formatclipboard.hxx"
131 #include <vos/mutex.hxx>
132 #include <vcl/svapp.hxx>
133 
134 #include <IMark.hxx>
135 #include <doc.hxx>
136 #include <xmloff/odffields.hxx>
137 
138 #include <PostItMgr.hxx>
139 
140 //JP 11.10.2001: enable test code for bug fix 91313
141 #if defined(DBG_UTIL) && (OSL_DEBUG_LEVEL > 1)
142 //#define TEST_FOR_BUG91313
143 #endif
144 
145 using namespace sw::mark;
146 using namespace ::com::sun::star;
147 
148 /*--------------------------------------------------------------------
149     Beschreibung:   Globals
150  --------------------------------------------------------------------*/
151 
152 static bool bInputLanguageSwitched = false;
153 extern sal_Bool bNoInterrupt;       // in mainwn.cxx
154 
155 //Normalerweise wird im MouseButtonUp eine Selektion aufgehoben wenn die
156 //Selektion nicht gerade aufgezogen wird. Leider wird im MouseButtonDown
157 //bei doppel-/dreifach-Klick Selektiert, diese Selektion wird in dem Handler
158 //komplett abgeschlossen und kann deshalb im Up nicht mehr unterschieden
159 //werden. Um dies Aufzuloese wird bHoldSelection im Down gesetzt und im
160 //Up ausgewertet.
161 static sal_Bool bHoldSelection      = sal_False;
162 
163 sal_Bool bFrmDrag                   = sal_False;
164 sal_Bool bValidCrsrPos              = sal_False;
165 sal_Bool bModePushed                = sal_False;
166 sal_Bool bDDTimerStarted            = sal_False;
167 sal_Bool bFlushCharBuffer           = sal_False;
168 sal_Bool SwEditWin::bReplaceQuote   = sal_False;
169 sal_Bool bDDINetAttr                = sal_False;
170 SdrHdlKind eSdrMoveHdl          = HDL_USER;
171 
172 QuickHelpData* SwEditWin::pQuickHlpData = 0;
173 
174 long    SwEditWin::nDDStartPosY = 0;
175 long    SwEditWin::nDDStartPosX = 0;
176 Color   SwEditWin::aTextBackColor(COL_YELLOW);
177 Color   SwEditWin::aTextColor(COL_RED);
178 sal_Bool    SwEditWin::bTransparentBackColor = sal_False; // Hintergrund nicht transparent
179 
180 
181 extern sal_Bool     bExecuteDrag;
182 
183 SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
184 
185 DBG_NAME(edithdl)
186 
187 class SwAnchorMarker
188 {
189     SdrHdl* pHdl;
190     Point aHdlPos;
191     Point aLastPos;
192     // --> OD 2010-09-16 #i114522#
193     bool bTopRightHandle;
194     // <--
195 public:
196     SwAnchorMarker( SdrHdl* pH )
197         : pHdl( pH )
198         , aHdlPos( pH->GetPos() )
199         , aLastPos( pH->GetPos() )
200         // --> OD 2010-09-16 #i114522#
201         , bTopRightHandle( pH->GetKind() == HDL_ANCHOR_TR )
202         // <--
203     {}
204     const Point& GetLastPos() const { return aLastPos; }
205     void SetLastPos( const Point& rNew ) { aLastPos = rNew; }
206     void SetPos( const Point& rNew ) { pHdl->SetPos( rNew ); }
207     const Point& GetPos() { return pHdl->GetPos(); }
208     const Point& GetHdlPos() { return aHdlPos; }
209     void ChgHdl( SdrHdl* pNew )
210     {
211         pHdl = pNew;
212         // --> OD 2010-09-16 #i114522#
213         if ( pHdl )
214         {
215             bTopRightHandle = (pHdl->GetKind() == HDL_ANCHOR_TR);
216         }
217         // <--
218     }
219     // --> OD 2010-09-16 #i114522#
220     const Point GetPosForHitTest( const OutputDevice& rOut )
221     {
222         Point aHitTestPos( GetPos() );
223         aHitTestPos = rOut.LogicToPixel( aHitTestPos );
224         if ( bTopRightHandle )
225         {
226             aHitTestPos += Point( -1, 1 );
227         }
228         else
229         {
230             aHitTestPos += Point( 1, 1 );
231         }
232         aHitTestPos = rOut.PixelToLogic( aHitTestPos );
233 
234         return aHitTestPos;
235     }
236     // <--
237 };
238 
239 struct QuickHelpData
240 {
241     SvStringsISortDtor aArr;
242     sal_uInt16* pAttrs;
243     CommandExtTextInputData* pCETID;
244     sal_uLong nTipId;
245     sal_uInt16 nLen, nCurArrPos;
246     sal_Bool bClear : 1, bChkInsBlank : 1, bIsTip : 1, bIsAutoText : 1;
247 
248     QuickHelpData() : pAttrs( 0 ), pCETID( 0 )  { ClearCntnt(); }
249 
250     void Move( QuickHelpData& rCpy );
251     void ClearCntnt();
252     void Start( SwWrtShell& rSh, sal_uInt16 nWrdLen );
253     void Stop( SwWrtShell& rSh );
254 
255     sal_Bool HasCntnt() const       { return aArr.Count() && 0 != nLen; }
256 
257     void Inc( sal_Bool bEndLess )
258         {
259             if( ++nCurArrPos >= aArr.Count() )
260                 nCurArrPos = (bEndLess && !bIsAutoText )? 0 : nCurArrPos-1;
261         }
262     void Dec( sal_Bool bEndLess )
263         {
264             if( 0 == nCurArrPos-- )
265                 nCurArrPos = (bEndLess && !bIsAutoText ) ? aArr.Count()-1 : 0;
266         }
267     void FillStrArr( SwWrtShell& rSh, const String& rWord );
268 };
269 
270 
271 /*--------------------------------------------------------------------
272     Beschreibung:   Minimale Bewegung Zittern vermeiden
273  --------------------------------------------------------------------*/
274 
275 #define HIT_PIX  2 /* Hit-Toleranz in Pixel */
276 #define MIN_MOVE 4
277 
278 inline sal_Bool IsMinMove(const Point &rStartPos, const Point &rLPt)
279 {
280     return Abs(rStartPos.X() - rLPt.X()) > MIN_MOVE ||
281            Abs(rStartPos.Y() - rLPt.Y()) > MIN_MOVE;
282 }
283 
284 /*--------------------------------------------------------------------
285     JP 30.07.98: fuer MouseButtonDown - feststellen, ob ein DrawObject
286                 und KEIN SwgFrame getroffen wurde! Shift/Ctrl sollen
287                 nur bei DrawObjecte zum Selektieren fuehren, bei SwgFlys
288                 ggfs zum ausloesen von Hyperlinks (DownLoad/NewWindow!)
289  --------------------------------------------------------------------*/
290 inline sal_Bool IsDrawObjSelectable( const SwWrtShell& rSh, const Point& rPt )
291 {
292     sal_Bool bRet = sal_True;
293     SdrObject* pObj;
294     switch( rSh.GetObjCntType( rPt, pObj ))
295     {
296     case OBJCNT_NONE:
297     case OBJCNT_FLY:
298     case OBJCNT_GRF:
299     case OBJCNT_OLE:
300         bRet = sal_False;
301         break;
302     default:; //prevent warning
303     }
304     return bRet;
305 }
306 
307 /*--------------------------------------------------------------------
308     Beschreibung:   Pointer umschalten
309  --------------------------------------------------------------------*/
310 
311 
312 void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier )
313 {
314     SwWrtShell &rSh = rView.GetWrtShell();
315     if( pApplyTempl )
316     {
317         PointerStyle eStyle = POINTER_FILL;
318         if( rSh.IsOverReadOnlyPos( rLPt ))
319         {
320             if( pUserMarker )
321             {
322                 delete pUserMarker;
323                 pUserMarker = 0L;
324             }
325 //          rSh.SwCrsrShell::UnSetVisCrsr( rLPt );
326             eStyle = POINTER_NOTALLOWED;
327         }
328         else
329         {
330             SwRect aRect;
331             SwRect* pRect = &aRect;
332             const SwFrmFmt* pFmt = 0;
333 
334             bool bFrameIsValidTarget = false;
335             if( pApplyTempl->pFormatClipboard )
336                 bFrameIsValidTarget = pApplyTempl->pFormatClipboard->HasContentForThisType( nsSelectionType::SEL_FRM );
337             else if( !pApplyTempl->nColor )
338                 bFrameIsValidTarget = ( pApplyTempl->eType == SFX_STYLE_FAMILY_FRAME );
339 
340             if( bFrameIsValidTarget &&
341                         0 !=(pFmt = rSh.GetFmtFromObj( rLPt, &pRect )) &&
342                         PTR_CAST(SwFlyFrmFmt, pFmt))
343             {
344                 //Highlight fuer Rahmen anwerfen
345                 Rectangle aTmp( pRect->SVRect() );
346 
347                 if ( !pUserMarker )
348                 {
349                     pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
350                 }
351             }
352             else if(pUserMarker)
353             {
354                 delete pUserMarker;
355                 pUserMarker = 0L;
356             }
357 
358             rSh.SwCrsrShell::SetVisCrsr( rLPt );
359         }
360         SetPointer( eStyle );
361         return;
362     }
363 
364     if( !rSh.VisArea().Width() )
365         return;
366 
367     SET_CURR_SHELL(&rSh);
368 
369     if ( IsChainMode() )
370     {
371         SwRect aRect;
372         int nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt );
373         PointerStyle eStyle = nChainable
374                 ? POINTER_CHAIN_NOTALLOWED : POINTER_CHAIN;
375         if ( !nChainable )
376         {
377             Rectangle aTmp( aRect.SVRect() );
378 
379             if ( !pUserMarker )
380             {
381                 pUserMarker = new SdrDropMarkerOverlay( *rSh.GetDrawView(), aTmp );
382             }
383         }
384         else
385         {
386             delete pUserMarker;
387             pUserMarker = 0L;
388         }
389 
390         rView.GetViewFrame()->ShowStatusText(
391                                         SW_RESSTR(STR_CHAIN_OK+nChainable));
392         SetPointer( eStyle );
393         return;
394     }
395 
396     // Removed ExecHyperlink option.
397     //sal_Bool bExecHyperlinks = rSh.GetViewOptions()->IsExecHyperlinks() ^
398     //                     (nModifier == KEY_MOD2 ? sal_True : sal_False);
399     sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
400     if ( !bExecHyperlinks )
401     {
402         SvtSecurityOptions aSecOpts;
403         const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
404         if ( (  bSecureOption && nModifier == KEY_MOD1 ) ||
405              ( !bSecureOption && nModifier != KEY_MOD1 ) )
406             bExecHyperlinks = sal_True;
407     }
408 
409     const sal_Bool bExecSmarttags  = nModifier == KEY_MOD1;
410 
411     SdrView *pSdrView = rSh.GetDrawView();
412     sal_Bool bPrefSdrPointer = sal_False;
413     sal_Bool bHitHandle = sal_False;
414     sal_Bool bCntAtPos = sal_False;
415     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
416                           rSh.IsCrsrReadonly();
417     aActHitType = SDRHIT_NONE;
418     PointerStyle eStyle = POINTER_TEXT;
419     if ( !pSdrView )
420         bCntAtPos = sal_True;
421     else if ( sal_True == (bHitHandle = pSdrView->PickHandle( rLPt ) != 0) )
422     {
423         aActHitType = SDRHIT_OBJECT;
424         bPrefSdrPointer = sal_True;
425     }
426     else
427     {
428         const sal_Bool bNotInSelObj = !rSh.IsInsideSelectedObj( rLPt );
429         if ( rView.GetDrawFuncPtr() && !bInsDraw && bNotInSelObj )
430         {
431             aActHitType = SDRHIT_OBJECT;
432             if (IsObjectSelect())
433                 eStyle = POINTER_ARROW;
434             else
435                 bPrefSdrPointer = sal_True;
436         }
437         else
438         {
439             SdrObject* pObj; SdrPageView* pPV;
440             pSdrView->SetHitTolerancePixel( HIT_PIX );
441             if ( bNotInSelObj && bExecHyperlinks &&
442                  pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO ))
443             {
444                 SdrObjMacroHitRec aTmp;
445                 aTmp.aPos = rLPt;
446                 aTmp.pPageView = pPV;
447                 SetPointer( pObj->GetMacroPointer( aTmp ) );
448                 return;
449             }
450             else
451             {
452                 // dvo: IsObjSelectable() eventually calls SdrView::PickObj, so
453                 // apparently this is used to determine whether this is a
454                 // drawling layer object or not.
455                 if ( rSh.IsObjSelectable( rLPt ) )
456                 {
457                     if (pSdrView->IsTextEdit())
458                     {
459                         aActHitType = SDRHIT_NONE;
460                         bPrefSdrPointer = sal_True;
461                     }
462                     else
463                     {
464                         SdrViewEvent aVEvt;
465                         SdrHitKind eHit = pSdrView->PickAnything(rLPt, aVEvt);
466 
467                         if (eHit == SDRHIT_URLFIELD && bExecHyperlinks)
468                         {
469                             aActHitType = SDRHIT_OBJECT;
470                             bPrefSdrPointer = sal_True;
471                         }
472                         else
473                         {
474                             // if we're over a selected object, we show an
475                             // ARROW by default. We only show a MOVE if 1) the
476                             // object is selected, and 2) it may be moved
477                             // (i.e., position is not protected).
478                             bool bMovable =
479                                 (!bNotInSelObj) &&
480                                 (rSh.IsObjSelected() || rSh.IsFrmSelected()) &&
481                                 (!rSh.IsSelObjProtected(FLYPROTECT_POS));
482 
483                             eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW;
484                             aActHitType = SDRHIT_OBJECT;
485                         }
486                     }
487                 }
488                 else
489                 {
490                     if ( rSh.IsFrmSelected() && !bNotInSelObj )
491                     {
492                         // dvo: this branch appears to be dead and should be
493                         // removed in a future version. Reason: The condition
494                         // !bNotInSelObj means that this branch will only be
495                         // executed in the cursor points inside a selected
496                         // object. However, if this is the case, the previous
497                         // if( rSh.IsObjSelectable(rLPt) ) must always be true:
498                         // rLPt is inside a selected object, then obviously
499                         // rLPt is over a selectable object.
500                         if (rSh.IsSelObjProtected(FLYPROTECT_SIZE))
501                             eStyle = POINTER_NOTALLOWED;
502                         else
503                             eStyle = POINTER_MOVE;
504                         aActHitType = SDRHIT_OBJECT;
505                     }
506                     else
507                     {
508                         if ( rView.GetDrawFuncPtr() )
509                             bPrefSdrPointer = sal_True;
510                         else
511                             bCntAtPos = sal_True;
512                     }
513                 }
514             }
515         }
516     }
517     if ( bPrefSdrPointer )
518     {
519         if (bIsDocReadOnly || (rSh.IsObjSelected() && rSh.IsSelObjProtected(FLYPROTECT_CONTENT)))
520             SetPointer( POINTER_NOTALLOWED );
521         else
522         {
523             if (rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->IsInsertForm() && !bHitHandle)
524                 SetPointer( POINTER_DRAW_RECT );
525             else
526                 SetPointer( pSdrView->GetPreferedPointer( rLPt, rSh.GetOut() ) );
527         }
528     }
529     else
530     {
531         if( !rSh.IsPageAtPos( rLPt ) || pAnchorMarker )
532             eStyle = POINTER_ARROW;
533         else
534         {
535             if( bCntAtPos )
536             {
537                 SwContentAtPos aSwContentAtPos(
538                     SwContentAtPos::SW_CLICKFIELD|
539                     SwContentAtPos::SW_INETATTR|
540                     SwContentAtPos::SW_FTN |
541                     SwContentAtPos::SW_SMARTTAG );
542                 if( rSh.GetContentAtPos( rLPt, aSwContentAtPos) )
543                 {
544                     const bool bClickToFollow = SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos ||
545                                                 SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos;
546 
547                      if( !bClickToFollow ||
548                          (SwContentAtPos::SW_INETATTR == aSwContentAtPos.eCntntAtPos && bExecHyperlinks) ||
549                          (SwContentAtPos::SW_SMARTTAG == aSwContentAtPos.eCntntAtPos && bExecSmarttags) )
550                         eStyle = POINTER_REFHAND;
551                 }
552             }
553         }
554 
555         // which kind of text pointer have we to show - horz / vert - ?
556         if( POINTER_TEXT == eStyle && rSh.IsInVerticalText( &rLPt ))
557             eStyle = POINTER_TEXT_VERTICAL;
558 
559         SetPointer( eStyle );
560     }
561 }
562 
563 /*--------------------------------------------------------------------
564     Beschreibung: Timer fuer Selektion vergroessern
565  --------------------------------------------------------------------*/
566 
567 
568 IMPL_LINK( SwEditWin, TimerHandler, Timer *, EMPTYARG )
569 {
570     DBG_PROFSTART(edithdl);
571 
572     SwWrtShell &rSh = rView.GetWrtShell();
573     Point aModPt( aMovePos );
574     const SwRect aOldVis( rSh.VisArea() );
575     sal_Bool bDone = sal_False;
576 
577     if ( !rSh.VisArea().IsInside( aModPt ) )
578     {
579         if ( bInsDraw )
580         {
581             const int nMaxScroll = 40;
582             rView.Scroll( Rectangle(aModPt,Size(1,1)), nMaxScroll, nMaxScroll);
583             bDone = sal_True;
584         }
585         else if ( bFrmDrag )
586         {
587             (rSh.*rSh.fnDrag)(&aModPt,sal_False);
588             bDone = sal_True;
589         }
590         if ( !bDone )
591             aModPt = rSh.GetCntntPos( aModPt,aModPt.Y() > rSh.VisArea().Bottom() );
592     }
593     if ( !bDone && !(bFrmDrag || bInsDraw) )
594     {
595         if ( pRowColumnSelectionStart )
596         {
597             Point aPos( aModPt );
598             rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag );
599         }
600         else
601             (rSh.*rSh.fnSetCrsr)( &aModPt, sal_False );
602 
603         //fix(24138): Es kann sein, dass der "Sprung" ueber eine Tabelle so
604         //nicht geschafft wird. Deshalb wir hier eben per Up/Down ueber die
605         //Tabelle gesprungen.
606         const SwRect& rVisArea = rSh.VisArea();
607         if( aOldVis == rVisArea && !rSh.IsStartOfDoc() && !rSh.IsEndOfDoc() )
608         {
609             //JP 11.10.2001 Bug 72294 - take the center point of VisArea to
610             //              decide in which direction the user want.
611             if( aModPt.Y() < ( rVisArea.Top() + rVisArea.Height() / 2 ) )
612                 rSh.Up( sal_True, 1 );
613             else
614                 rSh.Down( sal_True, 1 );
615         }
616     }
617 
618     aMovePos += rSh.VisArea().Pos() - aOldVis.Pos();
619     JustifyAreaTimer();
620     DBG_PROFSTOP(edithdl);
621     return 0;
622 }
623 
624 /*--------------------------------------------------------------------
625     Beschreibung:
626  --------------------------------------------------------------------*/
627 
628 
629 void SwEditWin::JustifyAreaTimer()
630 {
631     const Rectangle &rVisArea = GetView().GetVisArea();
632 #ifdef UNX
633     const long coMinLen = 100;
634 #else
635     const long coMinLen = 50;
636 #endif
637     long nTimeout = 800,
638          nDiff = Max(
639          Max( aMovePos.Y() - rVisArea.Bottom(), rVisArea.Top() - aMovePos.Y() ),
640          Max( aMovePos.X() - rVisArea.Right(),  rVisArea.Left() - aMovePos.X()));
641 #ifdef TEST_FOR_BUG91313
642     aTimer.SetTimeout( Max( coMinLen, nTimeout - nDiff) );
643 #else
644     aTimer.SetTimeout( Max( coMinLen, nTimeout - nDiff*2L) );
645 #endif
646 }
647 
648 void SwEditWin::LeaveArea(const Point &rPos)
649 {
650     aMovePos = rPos;
651     JustifyAreaTimer();
652     if( !aTimer.IsActive() )
653         aTimer.Start();
654     if( pShadCrsr )
655         delete pShadCrsr, pShadCrsr = 0;
656 }
657 
658 inline void SwEditWin::EnterArea()
659 {
660     aTimer.Stop();
661 }
662 
663 /*------------------------------------------------------------------------
664  Beschreibung:  Modus fuer Rahmen einfuegen
665 ------------------------------------------------------------------------*/
666 
667 
668 void SwEditWin::InsFrm(sal_uInt16 nCols)
669 {
670     StdDrawMode( OBJ_NONE, sal_False );
671     bInsFrm = sal_True;
672     nInsFrmColCount = nCols;
673 }
674 
675 
676 
677 void SwEditWin::StdDrawMode( SdrObjKind eSdrObjectKind, sal_Bool bObjSelect )
678 {
679     SetSdrDrawMode( eSdrObjectKind );
680 
681 /*  if (GetDrawFuncPtr())
682         GetDrawFuncPtr()->Deactivate();*/
683 
684     if (bObjSelect)
685         rView.SetDrawFuncPtr(new DrawSelection( &rView.GetWrtShell(), this, &rView ));
686     else
687         rView.SetDrawFuncPtr(new SwDrawBase( &rView.GetWrtShell(), this, &rView ));
688 
689     rView.SetSelDrawSlot();
690     SetSdrDrawMode( eSdrObjectKind );
691     if (bObjSelect)
692         rView.GetDrawFuncPtr()->Activate( SID_OBJECT_SELECT );
693     else
694         rView.GetDrawFuncPtr()->Activate( sal::static_int_cast< sal_uInt16 >(eSdrObjectKind) );     // don't know if this is useful at all; but it keeps functionality as it was...
695     bInsFrm = sal_False;
696     nInsFrmColCount = 1;
697 }
698 
699 
700 
701 void SwEditWin::StopInsFrm()
702 {
703     if (rView.GetDrawFuncPtr())
704     {
705         rView.GetDrawFuncPtr()->Deactivate();
706         rView.SetDrawFuncPtr(NULL);
707     }
708     rView.LeaveDrawCreate();    // Konstruktionsmode verlassen
709     bInsFrm = sal_False;
710     nInsFrmColCount = 1;
711 }
712 
713 /*--------------------------------------------------------------------
714  --------------------------------------------------------------------*/
715 
716 
717 sal_Bool SwEditWin::IsInputSequenceCheckingRequired( const String &rText, const SwPaM& rCrsr ) const
718 {
719     const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
720     if ( !rCTLOptions.IsCTLFontEnabled() ||
721          !rCTLOptions.IsCTLSequenceChecking() )
722          return sal_False;
723 
724     const xub_StrLen nFirstPos = rCrsr.Start()->nContent.GetIndex();
725     if ( 0 == nFirstPos ) /* first char needs not to be checked */
726         return sal_False;
727 
728     SwBreakIt *pBreakIter = SwBreakIt::Get();
729     uno::Reference < i18n::XBreakIterator > xBI = pBreakIter->GetBreakIter();
730     long nCTLScriptPos = -1;
731 
732     if (xBI.is())
733     {
734         if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
735             nCTLScriptPos = 0;
736         else
737             nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
738     }
739 
740     return (0 <= nCTLScriptPos && nCTLScriptPos <= rText.Len());
741 }
742 
743 
744 /*--------------------------------------------------------------------
745      Beschreibung:  Der Character Buffer wird in das Dokument eingefuegt
746  --------------------------------------------------------------------*/
747 
748 
749 void SwEditWin::FlushInBuffer()
750 {
751     if ( aInBuffer.Len() )
752     {
753         SwWrtShell& rSh = rView.GetWrtShell();
754 
755         // generate new sequence input checker if not already done
756         if ( !pCheckIt )
757             pCheckIt = new SwCheckIt;
758 
759         uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = pCheckIt->xCheck;
760         if ( xISC.is() && IsInputSequenceCheckingRequired( aInBuffer, *rSh.GetCrsr() ) )
761         {
762             //
763             // apply (Thai) input sequence checking/correction
764             //
765 
766             rSh.Push(); // push current cursor to stack
767 
768             // get text from the beginning (i.e left side) of current selection
769             // to the start of the paragraph
770             rSh.NormalizePam();     // make point be the first (left) one
771             if (!rSh.GetCrsr()->HasMark())
772                 rSh.GetCrsr()->SetMark();
773             rSh.GetCrsr()->GetMark()->nContent = 0;
774             String aLeftText( rSh.GetCrsr()->GetTxt() );
775 
776             SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions();
777 
778             xub_StrLen nExpandSelection = 0;
779             if (aLeftText.Len() > 0)
780             {
781                 sal_Unicode cChar = '\0';
782 
783                 xub_StrLen nTmpPos = aLeftText.Len();
784                 sal_Int16 nCheckMode = rCTLOptions.IsCTLSequenceCheckingRestricted() ?
785                         i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
786 
787                 rtl::OUString aOldText( aLeftText );
788                 rtl::OUString aNewText( aOldText );
789                 if (rCTLOptions.IsCTLSequenceCheckingTypeAndReplace())
790                 {
791                     for (xub_StrLen k = 0;  k < aInBuffer.Len();  ++k)
792                     {
793                         cChar = aInBuffer.GetChar(k);
794                         const xub_StrLen nPrevPos = static_cast<xub_StrLen>(xISC->correctInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ));
795 
796                         // valid sequence or sequence could be corrected:
797                         if (nPrevPos != aNewText.getLength())
798                             nTmpPos = nPrevPos + 1;
799                     }
800 
801                     // find position of first character that has changed
802                     sal_Int32 nOldLen = aOldText.getLength();
803                     sal_Int32 nNewLen = aNewText.getLength();
804                     const sal_Unicode *pOldTxt = aOldText.getStr();
805                     const sal_Unicode *pNewTxt = aNewText.getStr();
806                     sal_Int32 nChgPos = 0;
807                     while ( nChgPos < nOldLen && nChgPos < nNewLen &&
808                             pOldTxt[nChgPos] == pNewTxt[nChgPos] )
809                         ++nChgPos;
810 
811                     xub_StrLen nChgLen = static_cast< xub_StrLen >(nNewLen - nChgPos);
812                     String aChgText( aNewText.copy( static_cast< xub_StrLen >(nChgPos), nChgLen ) );
813 
814                     if (aChgText.Len())
815                     {
816                         aInBuffer = aChgText;
817                         nExpandSelection = aLeftText.Len() - static_cast< xub_StrLen >(nChgPos);
818                     }
819                     else
820                         aInBuffer.Erase();
821                 }
822                 else
823                 {
824                     for (xub_StrLen k = 0;  k < aInBuffer.Len();  ++k)
825                     {
826                         cChar = aInBuffer.GetChar(k);
827                         if (xISC->checkInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ))
828                         {
829                             // character can be inserted:
830                             aNewText += rtl::OUString( (sal_Unicode) cChar );
831                             ++nTmpPos;
832                         }
833                     }
834                     aInBuffer = aNewText.copy( aOldText.getLength() );  // copy new text to be inserted to buffer
835                 }
836             }
837 
838             // at this point now we will insert the buffer text 'normally' some lines below...
839 
840             rSh.Pop( sal_False );  // pop old cursor from stack
841 
842             if (!aInBuffer.Len())
843                 return;
844 
845             // if text prior to the original selection needs to be changed
846             // as well, we now expand the selection accordingly.
847             SwPaM &rCrsr = *rSh.GetCrsr();
848             xub_StrLen nCrsrStartPos = rCrsr.Start()->nContent.GetIndex();
849             DBG_ASSERT( nCrsrStartPos >= nExpandSelection, "cannot expand selection as specified!!" );
850             if (nExpandSelection && nCrsrStartPos >= nExpandSelection)
851             {
852                 if (!rCrsr.HasMark())
853                     rCrsr.SetMark();
854                 rCrsr.Start()->nContent -= nExpandSelection;
855             }
856         }
857 
858         uno::Reference< frame::XDispatchRecorder > xRecorder =
859                 rView.GetViewFrame()->GetBindings().GetRecorder();
860         if ( xRecorder.is() )
861         {
862             //Shell ermitteln
863             SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
864             // Request generieren und recorden
865             if (pSfxShell)
866             {
867                 SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
868                 aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, aInBuffer ) );
869                 aReq.Done();
870             }
871         }
872         //#21019# apply CTL and CJK language to the text input
873         sal_Bool bLang = true;
874         if(eBufferLanguage != LANGUAGE_DONTKNOW)
875         {
876             sal_uInt16 nWhich = 0;
877             switch( GetI18NScriptTypeOfLanguage( eBufferLanguage ))
878             {
879                 case  i18n::ScriptType::ASIAN:     nWhich = RES_CHRATR_CJK_LANGUAGE; break;
880                 case  i18n::ScriptType::COMPLEX:   nWhich = RES_CHRATR_CTL_LANGUAGE; break;
881                 case  i18n::ScriptType::LATIN:     nWhich = RES_CHRATR_LANGUAGE; break;
882                 default: bLang = sal_False;
883             }
884             if(bLang)
885             {
886                 SfxItemSet aLangSet(rView.GetPool(), nWhich, nWhich);
887                 rSh.GetCurAttr(aLangSet);
888                 if(SFX_ITEM_DEFAULT <= aLangSet.GetItemState(nWhich, sal_True))
889                 {
890                     LanguageType eLang = static_cast<const SvxLanguageItem&>(aLangSet.Get(nWhich)).GetLanguage();
891                     if ( eLang == eBufferLanguage )
892                         // current language attribute equal to language reported from system
893                         bLang = sal_False;
894                     else if ( !bInputLanguageSwitched && RES_CHRATR_LANGUAGE == nWhich /* && (eLang&LANGUAGE_MASK_PRIMARY) == LANGUAGE_ENGLISH */ )
895                     {
896                         // special case: switching between two "LATIN" languages
897                         // In case the current keyboard setting might be suitable for both languages we can't safely assume that the user
898                         // wants to use the language reported from the system, except if we knew that it was explicitly switched (thus the check for "bInputLangeSwitched").
899                         // The language reported by the system could be just the system default language that the user is not even aware of,
900                         // because no language selection tool is installed at all. In this case the OOo language should get preference as
901                         // it might have been selected by the user explicitly.
902                         // Usually this case happens if the OOo language is different to the system language but the system keyboard is still suitable
903                         // for the OOo language (e.g. writing English texts with a German keyboard).
904                         // For non-latin keyboards overwriting the attribute is still valid. We do this for kyrillic and greek ATM.
905                         // In future versions of OOo this should be replaced by a configuration switch that allows to give the preference to
906                         // the OOo setting or the system setting explicitly and/or a better handling of the script type.
907                         sal_Int16 nScript = GetAppCharClass().getScript( aInBuffer, 0 );
908                         i18n::UnicodeScript eType = (i18n::UnicodeScript) nScript;
909 
910                         bool bSystemIsNonLatin = false, bOOoLangIsNonLatin = false;
911                         switch ( eType )
912                         {
913                             case i18n::UnicodeScript_kGreek:
914                             case i18n::UnicodeScript_kCyrillic:
915                                 // in case other UnicodeScripts require special keyboards they can be added here
916                                 bSystemIsNonLatin = true;
917                                 break;
918                             default:
919                                 break;
920                         }
921 
922                         switch ( eLang )
923                         {
924                             case LANGUAGE_AZERI_CYRILLIC:
925                             case LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
926                             case LANGUAGE_BULGARIAN:
927                             case LANGUAGE_GREEK:
928                             case LANGUAGE_RUSSIAN:
929                             case LANGUAGE_RUSSIAN_MOLDOVA:
930                             case LANGUAGE_SERBIAN_CYRILLIC:
931                             case LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA:
932                             case LANGUAGE_UZBEK_CYRILLIC:
933                             case LANGUAGE_UKRAINIAN:
934                             case LANGUAGE_BELARUSIAN:
935                                 bOOoLangIsNonLatin = true;
936                                 break;
937                             default:
938                                 break;
939                         }
940 
941                         bLang = (bSystemIsNonLatin != bOOoLangIsNonLatin);
942                     }
943                 }
944                 if(bLang)
945                 {
946                     SvxLanguageItem aLangItem( eBufferLanguage, nWhich );
947                     rSh.SetAttr( aLangItem );
948                 }
949             }
950         }
951 
952         rSh.Insert( aInBuffer );
953         eBufferLanguage = LANGUAGE_DONTKNOW;
954         aInBuffer.Erase();
955         bFlushCharBuffer = sal_False;
956     }
957 }
958 
959 #define MOVE_LEFT_SMALL     0
960 #define MOVE_UP_SMALL       1
961 #define MOVE_RIGHT_BIG      2
962 #define MOVE_DOWN_BIG       3
963 #define MOVE_LEFT_BIG       4
964 #define MOVE_UP_BIG         5
965 #define MOVE_RIGHT_SMALL    6
966 #define MOVE_DOWN_SMALL     7
967 
968 void SwEditWin::ChangeFly( sal_uInt8 nDir, sal_Bool bWeb )
969 {
970     SwWrtShell &rSh = rView.GetWrtShell();
971     SwRect aTmp = rSh.GetFlyRect();
972     if( aTmp.HasArea() &&
973         // --> FME 2005-01-13 #i40348#
974         // IsSelObjProtected() seems to be the correct condition, not
975         // !HasReadonlySel(), otherwise frame is not moveable if content is
976         // protected.
977         !rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE ) )
978         // <--
979     {
980         // OD 18.09.2003 #i18732# - add item <RES_FOLLOW_TEXT_FLOW>
981         SfxItemSet aSet(rSh.GetAttrPool(),
982                         RES_FRM_SIZE, RES_FRM_SIZE,
983                         RES_VERT_ORIENT, RES_ANCHOR,
984                         RES_COL, RES_COL,
985                         RES_PROTECT, RES_PROTECT,
986                         RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW, 0);
987         rSh.GetFlyFrmAttr( aSet );
988         RndStdIds eAnchorId = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
989         Size aSnap;
990         if(MOVE_LEFT_SMALL == nDir ||
991             MOVE_UP_SMALL == nDir ||
992             MOVE_RIGHT_SMALL == nDir ||
993             MOVE_DOWN_SMALL == nDir )
994             aSnap = PixelToLogic(Size(1,1));
995         else
996         {
997             aSnap = rSh.GetViewOptions()->GetSnapSize();
998             short nDiv = rSh.GetViewOptions()->GetDivisionX();
999             if ( nDiv > 0 )
1000                 aSnap.Width() = Max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
1001             nDiv = rSh.GetViewOptions()->GetDivisionY();
1002             if ( nDiv > 0 )
1003                 aSnap.Height() = Max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
1004         }
1005 
1006         SwRect aBoundRect;
1007         Point aRefPoint;
1008         // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
1009         //      aligned to page for fly frame anchored to paragraph or to character.
1010         {
1011             SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
1012             const bool bFollowTextFlow =
1013                     static_cast<const SwFmtFollowTextFlow&>(aSet.Get(RES_FOLLOW_TEXT_FLOW)).GetValue();
1014             // OD 12.11.2003 #i22341# - additional provide content position
1015             const SwPosition* pToCharCntntPos = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetCntntAnchor();
1016             rSh.CalcBoundRect( aBoundRect, eAnchorId,
1017                                text::RelOrientation::FRAME, aVert.GetRelationOrient(),
1018                                pToCharCntntPos, bFollowTextFlow,
1019                                false, &aRefPoint );
1020         }
1021         long nLeft = Min( aTmp.Left() - aBoundRect.Left(), aSnap.Width() );
1022         long nRight = Min( aBoundRect.Right() - aTmp.Right(), aSnap.Width() );
1023         long nUp = Min( aTmp.Top() - aBoundRect.Top(), aSnap.Height() );
1024         long nDown = Min( aBoundRect.Bottom() - aTmp.Bottom(), aSnap.Height() );
1025 
1026         switch ( nDir )
1027         {
1028             case MOVE_LEFT_BIG:
1029             case MOVE_LEFT_SMALL: aTmp.Left( aTmp.Left() - nLeft ); break;
1030             case MOVE_UP_BIG:
1031             case MOVE_UP_SMALL: aTmp.Top( aTmp.Top() - nUp ); break;
1032             case MOVE_RIGHT_SMALL: if( aTmp.Width() < aSnap.Width() + MINFLY ) break;
1033                     nRight = aSnap.Width(); // kein break
1034             case MOVE_RIGHT_BIG: aTmp.Left( aTmp.Left() + nRight ); break;
1035             case MOVE_DOWN_SMALL: if( aTmp.Height() < aSnap.Height() + MINFLY ) break;
1036                     nDown = aSnap.Height(); // kein break
1037             case MOVE_DOWN_BIG: aTmp.Top( aTmp.Top() + nDown ); break;
1038             default: ASSERT( sal_True, "ChangeFly: Unknown direction." );
1039         }
1040         sal_Bool bSet = sal_False;
1041         if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 ))
1042         {
1043             long aDiff = aTmp.Top() - aRefPoint.Y();
1044             if( aDiff > 0 )
1045                 aDiff = 0;
1046             else if ( aDiff < -aTmp.Height() )
1047                 aDiff = -aTmp.Height();
1048             SwFmtVertOrient aVert( (SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT) );
1049             sal_Int16 eNew;
1050             if( bWeb )
1051             {
1052                 eNew = aVert.GetVertOrient();
1053                 sal_Bool bDown = 0 != ( nDir & 0x02 );
1054                 switch( eNew )
1055                 {
1056                     case text::VertOrientation::CHAR_TOP:
1057                         if( bDown ) eNew = text::VertOrientation::CENTER;
1058                     break;
1059                     case text::VertOrientation::CENTER:
1060                         eNew = bDown ? text::VertOrientation::TOP : text::VertOrientation::CHAR_TOP;
1061                     break;
1062                     case text::VertOrientation::TOP:
1063                         if( !bDown ) eNew = text::VertOrientation::CENTER;
1064                     break;
1065                     case text::VertOrientation::LINE_TOP:
1066                         if( bDown ) eNew = text::VertOrientation::LINE_CENTER;
1067                     break;
1068                     case text::VertOrientation::LINE_CENTER:
1069                         eNew = bDown ? text::VertOrientation::LINE_BOTTOM : text::VertOrientation::LINE_TOP;
1070                     break;
1071                     case text::VertOrientation::LINE_BOTTOM:
1072                         if( !bDown ) eNew = text::VertOrientation::LINE_CENTER;
1073                     break;
1074                     default:; //prevent warning
1075                 }
1076             }
1077             else
1078             {
1079                 aVert.SetPos( aDiff );
1080                 eNew = text::VertOrientation::NONE;
1081             }
1082             aVert.SetVertOrient( eNew );
1083             aSet.Put( aVert );
1084             bSet = sal_True;
1085         }
1086         if (bWeb && (FLY_AT_PARA == eAnchorId)
1087             && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ))
1088         {
1089             SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) );
1090             sal_Int16 eNew;
1091             eNew = aHori.GetHoriOrient();
1092             switch( eNew )
1093             {
1094                 case text::HoriOrientation::RIGHT:
1095                     if( nDir==MOVE_LEFT_SMALL )
1096                         eNew = text::HoriOrientation::LEFT;
1097                 break;
1098                 case text::HoriOrientation::LEFT:
1099                     if( nDir==MOVE_RIGHT_BIG )
1100                         eNew = text::HoriOrientation::RIGHT;
1101                 break;
1102                 default:; //prevent warning
1103             }
1104             if( eNew != aHori.GetHoriOrient() )
1105             {
1106                 aHori.SetHoriOrient( eNew );
1107                 aSet.Put( aHori );
1108                 bSet = sal_True;
1109             }
1110         }
1111         rSh.StartAllAction();
1112         if( bSet )
1113             rSh.SetFlyFrmAttr( aSet );
1114         sal_Bool bSetPos = (FLY_AS_CHAR != eAnchorId);
1115         if(bSetPos && bWeb)
1116         {
1117             if (FLY_AT_PAGE != eAnchorId)
1118             {
1119                 bSetPos = sal_False;
1120             }
1121             else
1122             {
1123                 bSetPos = (::GetHtmlMode(rView.GetDocShell()) & HTMLMODE_SOME_ABS_POS) ?
1124                     sal_True : sal_False;
1125             }
1126         }
1127         if( bSetPos )
1128             rSh.SetFlyPos( aTmp.Pos() );
1129         rSh.EndAllAction();
1130     }
1131 }
1132 /* -----------------------------23.05.2002 11:35------------------------------
1133 
1134  ---------------------------------------------------------------------------*/
1135 void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
1136 {
1137     // --> OD 2005-01-31 #i40845# - start undo action in order to get only one
1138     // undo action for this change.
1139     SwWrtShell &rSh = rView.GetWrtShell();
1140     rSh.StartUndo();
1141     // <--
1142 
1143     long nX = 0;
1144     long nY = 0;
1145     sal_Bool bOnePixel = sal_False;
1146     sal_uInt16 nAnchorDir = SW_MOVE_UP;
1147     switch(nDir)
1148     {
1149         case MOVE_LEFT_SMALL:
1150             bOnePixel = sal_True;
1151             //no break;
1152         case MOVE_LEFT_BIG:
1153             nX = -1;
1154             nAnchorDir = SW_MOVE_LEFT;
1155         break;
1156         case MOVE_UP_SMALL:
1157             bOnePixel = sal_True;
1158             //no break;
1159         case MOVE_UP_BIG:
1160             nY = -1;
1161         break;
1162         case MOVE_RIGHT_SMALL:
1163             bOnePixel = sal_True;
1164             //no break;
1165         case MOVE_RIGHT_BIG:
1166             nX = +1;
1167             nAnchorDir = SW_MOVE_RIGHT;
1168         break;
1169         case MOVE_DOWN_SMALL:
1170             bOnePixel = sal_True;
1171             //no break;
1172         case MOVE_DOWN_BIG:
1173             nY = +1;
1174             nAnchorDir = SW_MOVE_DOWN;
1175         break;
1176     }
1177 
1178     if(0 != nX || 0 != nY)
1179     {
1180         sal_uInt8 nProtect = rSh.IsSelObjProtected( FLYPROTECT_POS|FLYPROTECT_SIZE );
1181         Size aSnap( rSh.GetViewOptions()->GetSnapSize() );
1182         short nDiv = rSh.GetViewOptions()->GetDivisionX();
1183         if ( nDiv > 0 )
1184             aSnap.Width() = Max( (sal_uLong)1, (sal_uLong)aSnap.Width() / nDiv );
1185         nDiv = rSh.GetViewOptions()->GetDivisionY();
1186         if ( nDiv > 0 )
1187             aSnap.Height() = Max( (sal_uLong)1, (sal_uLong)aSnap.Height() / nDiv );
1188 
1189         if(bOnePixel)
1190             aSnap = PixelToLogic(Size(1,1));
1191 
1192         nX *= aSnap.Width();
1193         nY *= aSnap.Height();
1194 
1195         SdrView *pSdrView = rSh.GetDrawView();
1196         const SdrHdlList& rHdlList = pSdrView->GetHdlList();
1197         SdrHdl* pHdl = rHdlList.GetFocusHdl();
1198         rSh.StartAllAction();
1199         if(0L == pHdl)
1200         {
1201             // now move the selected draw objects
1202             // if the object's position is not protected
1203             if(0 == (nProtect&FLYPROTECT_POS))
1204             {
1205                 // --> FME 2005-04-26 #i47138#
1206                 // Check if object is anchored as character and move direction
1207                 sal_Bool bDummy1, bDummy2;
1208                 const bool bVertAnchor = rSh.IsFrmVertical( sal_True, bDummy1, bDummy2 );
1209                 const bool bHoriMove = !bVertAnchor == !( nDir % 2 );
1210                 const bool bMoveAllowed =
1211                     !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR);
1212                 if ( bMoveAllowed )
1213                 {
1214                 // <--
1215                     pSdrView->MoveAllMarked(Size(nX, nY));
1216                     rSh.SetModified();
1217                 }
1218             }
1219         }
1220         else
1221         {
1222             // move handle with index nHandleIndex
1223             if(pHdl && (nX || nY))
1224             {
1225                 if( HDL_ANCHOR == pHdl->GetKind() ||
1226                     HDL_ANCHOR_TR == pHdl->GetKind() )
1227                 {
1228                     // anchor move cannot be allowed when position is protected
1229                     if(0 == (nProtect&FLYPROTECT_POS))
1230                         rSh.MoveAnchor( nAnchorDir );
1231                 }
1232                 //now resize if size is protected
1233                 else if(0 == (nProtect&FLYPROTECT_SIZE))
1234                 {
1235                     // now move the Handle (nX, nY)
1236                     Point aStartPoint(pHdl->GetPos());
1237                     Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
1238                     const SdrDragStat& rDragStat = pSdrView->GetDragStat();
1239 
1240                     // start dragging
1241                     pSdrView->BegDragObj(aStartPoint, 0, pHdl, 0);
1242 
1243                     if(pSdrView->IsDragObj())
1244                     {
1245                         sal_Bool bWasNoSnap = static_cast< sal_Bool >(rDragStat.IsNoSnap());
1246                         sal_Bool bWasSnapEnabled = pSdrView->IsSnapEnabled();
1247 
1248                         // switch snapping off
1249                         if(!bWasNoSnap)
1250                             ((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
1251                         if(bWasSnapEnabled)
1252                             pSdrView->SetSnapEnabled(sal_False);
1253 
1254                         pSdrView->MovAction(aEndPoint);
1255                         pSdrView->EndDragObj();
1256                         rSh.SetModified();
1257 
1258                         // restore snap
1259                         if(!bWasNoSnap)
1260                             ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
1261                         if(bWasSnapEnabled)
1262                             pSdrView->SetSnapEnabled(bWasSnapEnabled);
1263                     }
1264                 }
1265             }
1266         }
1267         rSh.EndAllAction();
1268     }
1269 
1270     // --> OD 2005-01-31 #i40845# - end undo action
1271     rSh.EndUndo();
1272     // <--
1273 }
1274 
1275 /*--------------------------------------------------------------------
1276     Beschreibung:   KeyEvents
1277  --------------------------------------------------------------------*/
1278 
1279 
1280 
1281 void SwEditWin::KeyInput(const KeyEvent &rKEvt)
1282 {
1283     if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
1284         pApplyTempl && pApplyTempl->pFormatClipboard )
1285     {
1286         pApplyTempl->pFormatClipboard->Erase();
1287         SetApplyTemplate(SwApplyTemplate());
1288         rView.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
1289     }
1290 
1291     SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell();
1292     if ( bLockInput || (pObjSh && pObjSh->GetProgress()) )
1293         // Wenn die Rechenleiste aktiv ist oder
1294         // auf dem Document ein Progress laeuft wird keine
1295         // Bestellungen angenommen.
1296         return;
1297 
1298     if( pShadCrsr )
1299         delete pShadCrsr, pShadCrsr = 0;
1300     aKeyInputFlushTimer.Stop();
1301 
1302     SwWrtShell &rSh = rView.GetWrtShell();
1303     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
1304                           rSh.IsCrsrReadonly();
1305 
1306     //if the language changes the buffer must be flushed
1307     LanguageType eNewLanguage = GetInputLanguage();
1308     if(!bIsDocReadOnly && eBufferLanguage != eNewLanguage && aInBuffer.Len())
1309     {
1310         FlushInBuffer();
1311     }
1312     eBufferLanguage = eNewLanguage;
1313 
1314     QuickHelpData aTmpQHD;
1315     if( pQuickHlpData->bClear )
1316     {
1317         aTmpQHD.Move( *pQuickHlpData );
1318         pQuickHlpData->Stop( rSh );
1319     }
1320 
1321     // OS:auch die DrawView braucht noch ein readonly-Flag
1322     if ( !bIsDocReadOnly && rSh.GetDrawView() && rSh.GetDrawView()->KeyInput( rKEvt, this ) )
1323     {
1324         rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll( sal_False );
1325         rSh.SetModified();
1326         return; // Event von der SdrView ausgewertet
1327     }
1328 
1329     if ( rView.GetDrawFuncPtr() && bInsFrm )
1330     {
1331         StopInsFrm();
1332         rSh.Edit();
1333     }
1334 
1335     sal_Bool bFlushBuffer = sal_False;
1336     sal_Bool bNormalChar = sal_False;
1337     sal_Bool bChkInsBlank = pQuickHlpData->bChkInsBlank;
1338     pQuickHlpData->bChkInsBlank = sal_False;
1339 
1340     KeyEvent aKeyEvent( rKEvt );
1341     // look for vertical mappings
1342     if( !bIsDocReadOnly && !rSh.IsSelFrmMode() && !rSh.IsObjSelected() )
1343     {
1344         //JP 21.2.2002: must changed from switch to if, because the Linux
1345         // compiler has problem with the code. Has to remove if the new general
1346         // handler exist.
1347         sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
1348 
1349         if( KEY_UP == nKey || KEY_DOWN == nKey ||
1350             KEY_LEFT == nKey || KEY_RIGHT == nKey )
1351         {
1352             // In general, we want to map the direction keys if we are inside
1353             // some vertical formatted text.
1354             // 1. Exception: For a table cursor in a horizontal table, the
1355             //               directions should never be mapped.
1356             // 2. Exception: For a table cursor in a vertical table, the
1357             //               directions should always be mapped.
1358             const bool bVertText = rSh.IsInVerticalText();
1359             const bool bTblCrsr = rSh.GetTableCrsr();
1360             const bool bVertTable = rSh.IsTableVertical();
1361             if( ( bVertText && ( !bTblCrsr || bVertTable ) ) ||
1362                 ( bTblCrsr && bVertTable ) )
1363             {
1364                 // Attempt to integrate cursor travelling for mongolian layout does not work.
1365                 // Thus, back to previous mapping of cursor keys to direction keys.
1366                 if( KEY_UP == nKey ) nKey = KEY_LEFT;
1367                 else if( KEY_DOWN == nKey ) nKey = KEY_RIGHT;
1368                 else if( KEY_LEFT == nKey ) nKey = KEY_DOWN;
1369                 else if( KEY_RIGHT == nKey ) nKey = KEY_UP;
1370             }
1371 
1372             if ( rSh.IsInRightToLeftText() )
1373             {
1374                 if( KEY_LEFT == nKey ) nKey = KEY_RIGHT;
1375                 else if( KEY_RIGHT == nKey ) nKey = KEY_LEFT;
1376             }
1377 
1378             aKeyEvent = KeyEvent( rKEvt.GetCharCode(),
1379                                   KeyCode( nKey, rKEvt.GetKeyCode().GetModifier() ),
1380                                   rKEvt.GetRepeat() );
1381         }
1382     }
1383 
1384     const KeyCode& rKeyCode = aKeyEvent.GetKeyCode();
1385     sal_Unicode aCh = aKeyEvent.GetCharCode();
1386 
1387     // enable switching to notes ankor with Ctrl - Alt - Page Up/Down
1388     // pressing this inside a note will switch to next/previous note
1389     if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((rKeyCode.GetCode() == KEY_PAGEUP) || (rKeyCode.GetCode() == KEY_PAGEDOWN)))
1390     {
1391         bool bNext = rKeyCode.GetCode()==KEY_PAGEDOWN ? true : false;
1392         SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
1393         rSh.MoveFldType( pFldType, bNext );
1394         return;
1395     }
1396 
1397     const SwFrmFmt* pFlyFmt = rSh.GetFlyFrmFmt();
1398     if( pFlyFmt )
1399     {
1400         sal_uInt16 nEvent;
1401 
1402         if( 32 <= aCh &&
1403             0 == (( KEY_MOD1 | KEY_MOD2 ) & rKeyCode.GetModifier() ))
1404             nEvent = SW_EVENT_FRM_KEYINPUT_ALPHA;
1405         else
1406             nEvent = SW_EVENT_FRM_KEYINPUT_NOALPHA;
1407 
1408         const SvxMacro* pMacro = pFlyFmt->GetMacro().GetMacroTable().Get( nEvent );
1409         if( pMacro )
1410         {
1411             String sRet;
1412             SbxArrayRef xArgs = new SbxArray;
1413             SbxVariableRef xVar = new SbxVariable;
1414             xVar->PutString( pFlyFmt->GetName() );
1415             xArgs->Put( &xVar, 1 );
1416 
1417             xVar = new SbxVariable;
1418             if( SW_EVENT_FRM_KEYINPUT_ALPHA == nEvent )
1419                 xVar->PutChar( aCh );
1420             else
1421                 xVar->PutUShort( rKeyCode.GetModifier() | rKeyCode.GetCode() );
1422             xArgs->Put( &xVar, 2 );
1423 
1424             rSh.ExecMacro( *pMacro, &sRet, &xArgs );
1425             if( sRet.Len() && 0 != sRet.ToInt32() )
1426                 return ;
1427         }
1428     }
1429     int nLclSelectionType;
1430     //A is converted to 1
1431     if( rKeyCode.GetFullCode() == (KEY_A | KEY_MOD1 |KEY_SHIFT)
1432         && rSh.HasDrawView() &&
1433         (0 != (nLclSelectionType = rSh.GetSelectionType()) &&
1434         ((nLclSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_GRF)) ||
1435         ((nLclSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) &&
1436                 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1))))
1437     {
1438         SdrHdlList& rHdlList = (SdrHdlList&)rSh.GetDrawView()->GetHdlList();
1439         SdrHdl* pAnchor = rHdlList.GetHdl(HDL_ANCHOR);
1440         if ( ! pAnchor )
1441             pAnchor = rHdlList.GetHdl(HDL_ANCHOR_TR);
1442         if(pAnchor)
1443             rHdlList.SetFocusHdl(pAnchor);
1444         return;
1445     }
1446 
1447     SvxAutoCorrCfg* pACfg = 0;
1448     SvxAutoCorrect* pACorr = 0;
1449 
1450     uno::Reference< frame::XDispatchRecorder > xRecorder =
1451             rView.GetViewFrame()->GetBindings().GetRecorder();
1452     if ( !xRecorder.is() )
1453     {
1454         pACfg = SvxAutoCorrCfg::Get();
1455         pACorr = pACfg->GetAutoCorrect();
1456     }
1457 
1458     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1459 
1460     TblChgWidthHeightType eTblChgMode = nsTblChgWidthHeightType::WH_COL_LEFT;    // initialization just for warning-free code
1461     sal_uInt16 nTblChgSize = 0;
1462     sal_Bool bStopKeyInputTimer = sal_True;
1463     String sFmlEntry;
1464 
1465     enum SW_KeyState { KS_Start,
1466                        KS_CheckKey, KS_InsChar, KS_InsTab,
1467                        KS_NoNum, KS_NumOff, KS_NumOrNoNum, KS_NumDown, KS_NumUp,
1468                        // -> #i23725#
1469                        KS_NumIndentInc, KS_NumIndentDec,
1470                        // <- #i23725#
1471 
1472                        KS_OutlineLvOff,
1473                        KS_NextCell, KS_PrevCell, KS_OutlineUp, KS_OutlineDown,
1474                        KS_GlossaryExpand, KS_NextPrevGlossary,
1475                        KS_AutoFmtByInput,
1476                        KS_NextObject, KS_PrevObject,
1477                        KS_KeyToView,
1478                        KS_LaunchOLEObject, KS_GoIntoFly, KS_GoIntoDrawing,
1479                        KS_EnterDrawHandleMode,
1480                        KS_CheckDocReadOnlyKeys,
1481                        KS_CheckAutoCorrect, KS_EditFormula,
1482                        KS_ColLeftBig, KS_ColRightBig,
1483                        KS_ColLeftSmall, KS_ColRightSmall,
1484                        KS_ColTopBig, KS_ColBottomBig,
1485                        KS_ColTopSmall, KS_ColBottomSmall,
1486                        KS_CellLeftBig, KS_CellRightBig,
1487                        KS_CellLeftSmall, KS_CellRightSmall,
1488                        KS_CellTopBig, KS_CellBottomBig,
1489                        KS_CellTopSmall, KS_CellBottomSmall,
1490 
1491                        KS_InsDel_ColLeftBig, KS_InsDel_ColRightBig,
1492                        KS_InsDel_ColLeftSmall, KS_InsDel_ColRightSmall,
1493                        KS_InsDel_ColTopBig, KS_InsDel_ColBottomBig,
1494                        KS_InsDel_ColTopSmall, KS_InsDel_ColBottomSmall,
1495                        KS_InsDel_CellLeftBig, KS_InsDel_CellRightBig,
1496                        KS_InsDel_CellLeftSmall, KS_InsDel_CellRightSmall,
1497                        KS_InsDel_CellTopBig, KS_InsDel_CellBottomBig,
1498                        KS_InsDel_CellTopSmall, KS_InsDel_CellBottomSmall,
1499                        KS_TblColCellInsDel,
1500 
1501                        KS_Fly_Change, KS_Draw_Change,
1502                        KS_SpecialInsert,
1503                        KS_EnterCharCell,
1504                        KS_GotoNextFieldMark,
1505                        KS_GotoPrevFieldMark,
1506                        KS_Ende };
1507 
1508 
1509 
1510     SW_KeyState eKeyState = bIsDocReadOnly ? KS_CheckDocReadOnlyKeys
1511                                            : KS_CheckKey,
1512                 eNextKeyState = KS_Ende;
1513     sal_uInt8 nDir = 0;
1514 
1515     // -> #i23725#
1516     if (nKS_NUMDOWN_Count > 0)
1517         nKS_NUMDOWN_Count--;
1518 
1519     if (nKS_NUMINDENTINC_Count > 0)
1520         nKS_NUMINDENTINC_Count--;
1521     // <- #i23725#
1522 
1523     while( KS_Ende != eKeyState )
1524     {
1525         SW_KeyState eFlyState = KS_KeyToView;
1526 
1527         switch( eKeyState )
1528         {
1529         case KS_CheckKey:
1530             eKeyState = KS_KeyToView;       // default weiter zur View
1531 
1532 #ifdef DBG_UTIL
1533 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1534             // JP 19.01.99: zum Umschalten des Cursor Verhaltens in ReadOnly
1535             //              Bereichen
1536             if( 0x7210 == rKeyCode.GetFullCode() )
1537                 rSh.SetReadOnlyAvailable( !rSh.IsReadOnlyAvailable() );
1538             else
1539 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1540 #endif
1541 
1542             if( !rKeyCode.IsMod2() && '=' == aCh &&
1543                 !rSh.IsTableMode() && rSh.GetTableFmt() &&
1544                 rSh.IsSttPara() /*&& rSh.IsEndPara()*/ &&
1545                 !rSh.HasReadonlySel() )
1546             {
1547                 // in der Tabelle am Anfang der Zelle ein '=' ->
1548                 //  EditZeile aufrufen (F2-Funktionalitaet)
1549                 rSh.Push();
1550                 if( !rSh.MoveSection( fnSectionCurr, fnSectionStart) &&
1551                     !rSh.IsTableBoxTextFormat() )
1552                 {
1553                     // steht also am Anfang der Box
1554                     eKeyState = KS_EditFormula;
1555                     if( rSh.HasMark() )
1556                         rSh.SwapPam();
1557                     else
1558                         rSh.SttSelect();
1559                     rSh.MoveSection( fnSectionCurr, fnSectionEnd );
1560                     rSh.Pop( sal_True );
1561                     rSh.EndSelect();
1562                     sFmlEntry = '=';
1563                 }
1564                 else
1565                     rSh.Pop( sal_False );
1566             }
1567             else
1568             {
1569                 if( pACorr && aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
1570                     !rSh.HasReadonlySel() && !aTmpQHD.bIsAutoText &&
1571                     pACorr->GetSwFlags().nAutoCmpltExpandKey ==
1572                     (rKeyCode.GetModifier() | rKeyCode.GetCode()) )
1573                 {
1574                     eKeyState = KS_GlossaryExpand;
1575                     break;
1576                 }
1577 
1578                 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
1579                 {
1580                 case KEY_RIGHT | KEY_MOD2:
1581                     eKeyState = KS_ColRightBig;
1582                     eFlyState = KS_Fly_Change;
1583                     nDir = MOVE_RIGHT_SMALL;
1584                     goto KEYINPUT_CHECKTABLE;
1585 
1586                 case KEY_LEFT | KEY_MOD2:
1587                     eKeyState = KS_ColRightSmall;
1588                     eFlyState = KS_Fly_Change;
1589                     nDir = MOVE_LEFT_SMALL;
1590                     goto KEYINPUT_CHECKTABLE;
1591                 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT:
1592                     eKeyState = KS_ColLeftSmall;
1593                     goto KEYINPUT_CHECKTABLE;
1594                 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT:
1595                     eKeyState = KS_ColLeftBig;
1596                     goto KEYINPUT_CHECKTABLE;
1597 
1598                 case KEY_RIGHT | KEY_MOD2 | KEY_MOD1:
1599                     eKeyState = KS_CellRightBig;
1600                     goto KEYINPUT_CHECKTABLE;
1601                 case KEY_LEFT | KEY_MOD2 | KEY_MOD1:
1602                     eKeyState = KS_CellRightSmall;
1603                     goto KEYINPUT_CHECKTABLE;
1604                 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
1605                     eKeyState = KS_CellLeftSmall;
1606                     goto KEYINPUT_CHECKTABLE;
1607                 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
1608                     eKeyState = KS_CellLeftBig;
1609                     goto KEYINPUT_CHECKTABLE;
1610 
1611                 case KEY_UP | KEY_MOD2:
1612                     eKeyState = KS_ColBottomSmall;
1613                     eFlyState = KS_Fly_Change;
1614                     nDir = MOVE_UP_SMALL;
1615                     goto KEYINPUT_CHECKTABLE;
1616                 case KEY_DOWN | KEY_MOD2:
1617                     eKeyState = KS_ColBottomBig;
1618                     eFlyState = KS_Fly_Change;
1619                     nDir = MOVE_DOWN_SMALL;
1620                     goto KEYINPUT_CHECKTABLE;
1621 //              case KEY_UP | KEY_MOD2 | KEY_SHIFT:
1622 //                  eKeyState = KS_ColTopBig;
1623 //                  goto KEYINPUT_CHECKTABLE;
1624 //              case KEY_DOWN | KEY_MOD2 | KEY_SHIFT:
1625 //                  eKeyState = KS_ColTopSmall;
1626 //                  goto KEYINPUT_CHECKTABLE;
1627 
1628                 case KEY_UP | KEY_MOD2 | KEY_MOD1:
1629                     eKeyState = KS_CellBottomSmall;
1630                     goto KEYINPUT_CHECKTABLE;
1631                 case KEY_DOWN | KEY_MOD2 | KEY_MOD1:
1632                     eKeyState = KS_CellBottomBig;
1633                     goto KEYINPUT_CHECKTABLE;
1634                 case KEY_UP | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
1635                     eKeyState = KS_CellTopBig;
1636                     goto KEYINPUT_CHECKTABLE;
1637                 case KEY_DOWN | KEY_MOD2 | KEY_SHIFT | KEY_MOD1:
1638                     eKeyState = KS_CellTopSmall;
1639                     goto KEYINPUT_CHECKTABLE;
1640 
1641 KEYINPUT_CHECKTABLE:
1642                     if( rSh.IsTableMode() || !rSh.GetTableFmt() )
1643                     {
1644                         if(KS_KeyToView != eFlyState)
1645                         {
1646                             if(!pFlyFmt && KS_KeyToView != eFlyState &&
1647                                 (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM))  &&
1648                                     rSh.GetDrawView()->AreObjectsMarked())
1649                                 eKeyState = KS_Draw_Change;
1650                         }
1651 
1652                         if( pFlyFmt )
1653                             eKeyState = eFlyState;
1654                         else if( KS_Draw_Change != eKeyState)
1655                             eKeyState = KS_EnterCharCell;
1656                     }
1657                     break;
1658 
1659 //-------
1660 // Insert/Delete
1661                 case KEY_LEFT:
1662                 case KEY_LEFT | KEY_MOD1:
1663                 {
1664                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
1665                     if(!bMod1)
1666                     {
1667                         eFlyState = KS_Fly_Change;
1668                         nDir = MOVE_LEFT_BIG;
1669                     }
1670                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
1671                             ( bMod1
1672                                 ? nsTblChgWidthHeightType::WH_CELL_LEFT
1673                                 : nsTblChgWidthHeightType::WH_COL_LEFT );
1674                     nTblChgSize = pModOpt->GetTblVInsert();
1675                 }
1676                     goto KEYINPUT_CHECKTABLE_INSDEL;
1677 //                case KEY_RIGHT:
1678                 case KEY_RIGHT | KEY_MOD1:
1679                 {
1680                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_CELL_RIGHT;
1681                     nTblChgSize = pModOpt->GetTblVInsert();
1682                 }
1683                     goto KEYINPUT_CHECKTABLE_INSDEL;
1684                 case KEY_UP:
1685                 case KEY_UP | KEY_MOD1:
1686                 {
1687                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
1688                     if(!bMod1)
1689                     {
1690                         eFlyState = KS_Fly_Change;
1691                         nDir = MOVE_UP_BIG;
1692                     }
1693                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
1694                             ( bMod1
1695                                 ? nsTblChgWidthHeightType::WH_CELL_TOP
1696                                 : nsTblChgWidthHeightType::WH_ROW_TOP );
1697                     nTblChgSize = pModOpt->GetTblHInsert();
1698                 }
1699                     goto KEYINPUT_CHECKTABLE_INSDEL;
1700                 case KEY_DOWN:
1701                 case KEY_DOWN | KEY_MOD1:
1702                 {
1703                     sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
1704                     if(!bMod1)
1705                     {
1706                         eFlyState = KS_Fly_Change;
1707                         nDir = MOVE_DOWN_BIG;
1708                     }
1709                     eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL |
1710                             ( bMod1
1711                                 ? nsTblChgWidthHeightType::WH_CELL_BOTTOM
1712                                 : nsTblChgWidthHeightType::WH_ROW_BOTTOM );
1713                     nTblChgSize = pModOpt->GetTblHInsert();
1714                 }
1715                     goto KEYINPUT_CHECKTABLE_INSDEL;
1716 
1717 KEYINPUT_CHECKTABLE_INSDEL:
1718                     if( rSh.IsTableMode() || !rSh.GetTableFmt() ||
1719                         !bTblInsDelMode ||
1720                         sal_False /* Tabelle geschuetzt */
1721                             )
1722                     {
1723                         const int nSelectionType = rSh.GetSelectionType();
1724 
1725                         eKeyState = KS_KeyToView;
1726                         if(KS_KeyToView != eFlyState)
1727                         {
1728                             if((nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM))  &&
1729                                     rSh.GetDrawView()->AreObjectsMarked())
1730                                 eKeyState = KS_Draw_Change;
1731                             else if(nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))
1732                                 eKeyState = KS_Fly_Change;
1733                         }
1734                     }
1735                     else
1736                     {
1737                         if( !bTblIsInsMode )
1738                             eTblChgMode = eTblChgMode | nsTblChgWidthHeightType::WH_FLAG_BIGGER;
1739                         eKeyState = KS_TblColCellInsDel;
1740                     }
1741                     break;
1742 
1743                 case KEY_DELETE:
1744                     if (rSh.IsInFrontOfLabel() &&
1745                         rSh.NumOrNoNum(sal_False))
1746                         eKeyState = KS_NumOrNoNum;
1747                     break;
1748 
1749                 case KEY_DELETE | KEY_MOD2:
1750                     if( !rSh.IsTableMode() && rSh.GetTableFmt() )
1751                     {
1752                         eKeyState = KS_Ende;
1753                         bTblInsDelMode = sal_True;
1754                         bTblIsInsMode = sal_False;
1755                         bTblIsColMode = sal_True;
1756                         aKeyInputTimer.Start();
1757                         bStopKeyInputTimer = sal_False;
1758                     }
1759                     break;
1760                 case KEY_INSERT | KEY_MOD2:
1761                     if( !rSh.IsTableMode() && rSh.GetTableFmt() )
1762                     {
1763                         eKeyState = KS_Ende;
1764                         bTblInsDelMode = sal_True;
1765                         bTblIsInsMode = sal_True;
1766                         bTblIsColMode = sal_True;
1767                         aKeyInputTimer.Start();
1768                         bStopKeyInputTimer = sal_False;
1769                     }
1770                     break;
1771 
1772                 case KEY_RETURN:                // Return
1773                     if( !rSh.HasReadonlySel() )
1774                     {
1775                         const int nSelectionType = rSh.GetSelectionType();
1776                         if(nSelectionType & nsSelectionType::SEL_OLE)
1777                             eKeyState = KS_LaunchOLEObject;
1778                         else if(nSelectionType & nsSelectionType::SEL_FRM)
1779                             eKeyState = KS_GoIntoFly;
1780                         else if((nSelectionType & nsSelectionType::SEL_DRW) &&
1781                                 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
1782                                 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
1783                             eKeyState = KS_GoIntoDrawing;
1784                         else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
1785                             aTmpQHD.bIsAutoText )
1786                             eKeyState = KS_GlossaryExpand;
1787 
1788                         //RETURN und leerer Absatz in Numerierung -> Num. beenden
1789                         else if( !aInBuffer.Len() &&
1790                                  rSh.GetCurNumRule() &&
1791                                  !rSh.GetCurNumRule()->IsOutlineRule() &&
1792                                  !rSh.HasSelection() &&
1793                                 rSh.IsSttPara() && rSh.IsEndPara() )
1794                             eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff;
1795 
1796                         //RETURN fuer neuen Absatz mit AutoFormatierung
1797                         else if( pACfg && pACfg->IsAutoFmtByInput() &&
1798                                 !(nSelectionType & (nsSelectionType::SEL_GRF |
1799                                     nsSelectionType::SEL_OLE | nsSelectionType::SEL_FRM |
1800                                     nsSelectionType::SEL_TBL_CELLS | nsSelectionType::SEL_DRW |
1801                                     nsSelectionType::SEL_DRW_TXT)) )
1802                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_AutoFmtByInput;
1803                         else
1804                             eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect;
1805                     }
1806                     break;
1807 
1808                 case KEY_RETURN | KEY_MOD2:     // ALT-Return
1809                     if( !rSh.HasReadonlySel() && !rSh.IsSttPara() && rSh.GetCurNumRule() )
1810                         eKeyState = KS_NoNum;
1811                     else if( rSh.CanSpecialInsert() )
1812                         eKeyState = KS_SpecialInsert;
1813                     break;
1814 
1815                 case KEY_BACKSPACE:
1816                 case KEY_BACKSPACE | KEY_SHIFT:
1817                     if( !rSh.HasReadonlySel() )
1818                     {
1819                         // #i23725#
1820                         sal_Bool bDone = sal_False;
1821                         // --> OD 2006-01-31 - try to add comment for code snip:
1822                         // Remove the paragraph indent, if the cursor is at the
1823                         // beginning of a paragraph, there is no selection
1824                         // and no numbering rule found at the current paragraph
1825                         // --> OD 2006-01-31 #b6341339#, #i58776#
1826                         // Also try to remove indent, if current paragraph
1827                         // has numbering rule, but isn't counted and only
1828                         // key <backspace> is hit.
1829                         const bool bOnlyBackspaceKey(
1830                                     KEY_BACKSPACE == rKeyCode.GetFullCode() );
1831                         if ( rSh.IsSttPara() &&
1832                              !rSh.HasSelection() && // i40834
1833                              ( NULL == rSh.GetCurNumRule() ||
1834                                ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) )
1835                         {
1836                             bDone = rSh.TryRemoveIndent();
1837                         }
1838                         // <--
1839 
1840                         // -> #i23725#
1841                         if (bDone)
1842                             eKeyState = KS_Ende;
1843                         else
1844                         {
1845                             if (rSh.IsSttPara() &&
1846                                 ! rSh.IsNoNum())
1847                             {
1848                                 if (nKS_NUMDOWN_Count > 0 &&
1849                                     0 < rSh.GetNumLevel())
1850                                 {
1851                                     eKeyState = KS_NumUp;
1852                                     nKS_NUMDOWN_Count = 2;
1853                                     bDone = sal_True;
1854                                 }
1855                                 else if (nKS_NUMINDENTINC_Count > 0)
1856                                 {
1857                                     eKeyState = KS_NumIndentDec;
1858                                     nKS_NUMINDENTINC_Count = 2;
1859                                     bDone = sal_True;
1860                                 }
1861                             }
1862                             // <- #i23725#
1863                             // --> OD 2006-01-31 #b6341339#, #i58776#
1864                             // --> OD 2006-04-21 #i63540#
1865                             // revise fix for issues b6341339 and i58776:
1866                             // If the cursor is in an empty paragraph, which has
1867                             // a numbering, but not the oultine numbering, and
1868                             // there is no selection, the numbering has to be
1869                             // deleted on key <Backspace>.
1870                             // Otherwise method <SwEditShell::NumOrNoNum(..)>
1871                             // should only change the <IsCounted()> state of
1872                             // the current paragraph depending of the key.
1873                             // On <backspace> it is set to <false>,
1874                             // on <shift-backspace> it is set to <true>.
1875                             // Thus, assure that method <SwEditShell::NumOrNum(..)>
1876                             // is only called for the intended purpose.
1877                             bool bCallNumOrNoNum( false );
1878                             {
1879                                 if ( !bDone )
1880                                 {
1881                                     if ( bOnlyBackspaceKey && !rSh.IsNoNum() )
1882                                     {
1883                                         bCallNumOrNoNum = true;
1884                                     }
1885                                     else if ( !bOnlyBackspaceKey && rSh.IsNoNum() )
1886                                     {
1887                                         bCallNumOrNoNum = true;
1888                                     }
1889                                     else if ( bOnlyBackspaceKey &&
1890                                               rSh.IsSttPara() && rSh.IsEndPara() &&
1891                                               !rSh.HasSelection() )
1892                                     {
1893                                         const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() );
1894                                         if ( pCurrNumRule &&
1895                                              pCurrNumRule != rSh.GetOutlineNumRule() )
1896                                         {
1897                                             bCallNumOrNoNum = true;
1898                                         }
1899                                     }
1900                                 }
1901                             }
1902                             if ( bCallNumOrNoNum &&
1903                                  rSh.NumOrNoNum( !bOnlyBackspaceKey, sal_True ) )
1904                             {
1905                                 eKeyState = KS_NumOrNoNum;
1906                             }
1907                             // <--
1908                         }
1909                     }
1910                     break;
1911 
1912                 case KEY_RIGHT:
1913                     {
1914                         eFlyState = KS_Fly_Change;
1915                         nDir = MOVE_RIGHT_BIG;
1916                         eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT;
1917                         nTblChgSize = pModOpt->GetTblVInsert();
1918                         goto KEYINPUT_CHECKTABLE_INSDEL;
1919                     }
1920                 case KEY_TAB:
1921                 {
1922 
1923 #ifdef SW_CRSR_TIMER
1924                     sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False );
1925 #endif
1926                     if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark() || rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
1927                     {
1928                         eKeyState=KS_GotoNextFieldMark;
1929                     }
1930                     else
1931                     if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
1932                         !rSh.HasReadonlySel() )
1933                     {
1934                         // --> OD 2007-10-02 #b660435#
1935 //                        if (rSh.IsFirstOfNumRule()) // #i23725#
1936                         if ( rSh.IsFirstOfNumRule() &&
1937                              numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
1938                         // <--
1939                             eKeyState = KS_NumIndentInc;
1940                         else
1941                             eKeyState = KS_NumDown;
1942                     }
1943                     else if ( rSh.GetTableFmt() )
1944                     {
1945                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
1946                             eKeyState = KS_NextCell;
1947                         else
1948                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_NextCell;
1949                     }
1950                     else if ( rSh.GetSelectionType() &
1951                                 (nsSelectionType::SEL_GRF |
1952                                     nsSelectionType::SEL_FRM |
1953                                     nsSelectionType::SEL_OLE |
1954                                     nsSelectionType::SEL_DRW |
1955                                     nsSelectionType::SEL_DRW_FORM))
1956 
1957                             eKeyState = KS_NextObject;
1958                     else
1959                     {
1960                         eKeyState = KS_InsTab;
1961                         if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
1962                         {
1963                             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
1964                             if( pColl &&
1965                                 //0 <= pColl->GetOutlineLevel() && #i24560#
1966                                 //MAXLEVEL - 1 > pColl->GetOutlineLevel() )//#outline level,zhaojianwei
1967                                 pColl->IsAssignedToListLevelOfOutlineStyle()
1968                                 && MAXLEVEL-1 > pColl->GetAssignedOutlineStyleLevel() )//<-end,zhaojianwei
1969                                 eKeyState = KS_OutlineDown;
1970                         }
1971                     }
1972 #ifdef SW_CRSR_TIMER
1973                     rSh.ChgCrsrTimerFlag( bOld );
1974 #endif
1975                 }
1976                 break;
1977                 case KEY_TAB | KEY_SHIFT:
1978                 {
1979 #ifdef SW_CRSR_TIMER
1980                     sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False );
1981                     sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False );
1982 #endif
1983                     if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark()|| rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT) {
1984                         eKeyState=KS_GotoPrevFieldMark;
1985                     }
1986                     else if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
1987                          !rSh.HasReadonlySel() )
1988                     {
1989                         // --> OD 2007-10-02 #b660435#
1990 //                        if (rSh.IsFirstOfNumRule()) // #i23725#
1991                         if ( rSh.IsFirstOfNumRule() &&
1992                              numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() )
1993                         // <--
1994                             eKeyState = KS_NumIndentDec;
1995                         else
1996                             eKeyState = KS_NumUp;
1997                     }
1998                     else if ( rSh.GetTableFmt() )
1999                     {
2000                         if( rSh.HasSelection() || rSh.HasReadonlySel() )
2001                             eKeyState = KS_PrevCell;
2002                         else
2003                             eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_PrevCell;
2004                     }
2005                     else if ( rSh.GetSelectionType() &
2006                                 (nsSelectionType::SEL_GRF |
2007                                     nsSelectionType::SEL_FRM |
2008                                     nsSelectionType::SEL_OLE |
2009                                     nsSelectionType::SEL_DRW |
2010                                     nsSelectionType::SEL_DRW_FORM))
2011 
2012                             eKeyState = KS_PrevObject;
2013                     else
2014                     {
2015                         eKeyState = KS_Ende;
2016                         if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() )
2017                         {
2018                             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
2019                             //if( pColl && 0 < pColl->GetOutlineLevel() &&  //#outline level,zhaojianwei
2020                             //  MAXLEVEL - 1 >= pColl->GetOutlineLevel() )
2021                             if( pColl &&
2022                                 pColl->IsAssignedToListLevelOfOutlineStyle() &&
2023                                 0 < pColl->GetAssignedOutlineStyleLevel())
2024                                 eKeyState = KS_OutlineUp;
2025                         }
2026                     }
2027 #ifdef SW_CRSR_TIMER
2028                     rSh.ChgCrsrTimerFlag( bOld );
2029 #endif
2030                 }
2031                 break;
2032                 case KEY_TAB | KEY_MOD1:
2033                 case KEY_TAB | KEY_MOD2:
2034                     if( !rSh.HasReadonlySel() )
2035                     {
2036                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() )
2037                         {
2038                             // zum naechsten Tip
2039                             aTmpQHD.Inc( pACorr && pACorr->GetSwFlags().
2040                                                    bAutoCmpltEndless );
2041                             eKeyState = KS_NextPrevGlossary;
2042                         }
2043                         else if( rSh.GetTableFmt() )
2044                             eKeyState = KS_InsTab;
2045                         else if((rSh.GetSelectionType() &
2046                                     (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
2047                                         nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF))  &&
2048                                 rSh.GetDrawView()->AreObjectsMarked())
2049                             eKeyState = KS_EnterDrawHandleMode;
2050                         else
2051                         {
2052                             eKeyState = KS_InsTab;
2053                         }
2054                     }
2055                     break;
2056 
2057                     case KEY_TAB | KEY_MOD1 | KEY_SHIFT:
2058                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
2059                             !rSh.HasReadonlySel() )
2060                         {
2061                             // zum vorherigen Tip
2062                             aTmpQHD.Dec( pACorr && pACorr->GetSwFlags().
2063                                                         bAutoCmpltEndless );
2064                             eKeyState = KS_NextPrevGlossary;
2065                         }
2066                         else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
2067                                         nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) &&
2068                                 rSh.GetDrawView()->AreObjectsMarked())
2069                             eKeyState = KS_EnterDrawHandleMode;
2070                     break;
2071                     case KEY_F2 :
2072                     if( !rSh.HasReadonlySel() )
2073                     {
2074                         const int nSelectionType = rSh.GetSelectionType();
2075                         if(nSelectionType & nsSelectionType::SEL_FRM)
2076                             eKeyState = KS_GoIntoFly;
2077                         else if((nSelectionType & nsSelectionType::SEL_DRW))
2078                             eKeyState = KS_GoIntoDrawing;
2079                     }
2080                     break;
2081                 }
2082             }
2083             break;
2084         case KS_CheckDocReadOnlyKeys:
2085             {
2086                 eKeyState = KS_KeyToView;
2087                 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() )
2088                 {
2089                     case KEY_TAB:
2090                     case KEY_TAB | KEY_SHIFT:
2091                         bNormalChar = sal_False;
2092                         eKeyState = KS_Ende;
2093                         if ( rSh.GetSelectionType() &
2094                                 (nsSelectionType::SEL_GRF |
2095                                     nsSelectionType::SEL_FRM |
2096                                     nsSelectionType::SEL_OLE |
2097                                     nsSelectionType::SEL_DRW |
2098                                     nsSelectionType::SEL_DRW_FORM))
2099 
2100                         {
2101                             eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ?
2102                                                 KS_PrevObject : KS_NextObject;
2103                         }
2104                         else
2105                             rSh.SelectNextPrevHyperlink(
2106                                             KEY_SHIFT != rKeyCode.GetModifier() );
2107                     break;
2108                     case KEY_RETURN:
2109                     {
2110                         const int nSelectionType = rSh.GetSelectionType();
2111                         if(nSelectionType & nsSelectionType::SEL_FRM)
2112                             eKeyState = KS_GoIntoFly;
2113                         else
2114                         {
2115                             SfxItemSet aSet(rSh.GetAttrPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
2116                             rSh.GetCurAttr(aSet);
2117                             if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False))
2118                             {
2119                                 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
2120                                 bNormalChar = sal_False;
2121                                 eKeyState = KS_Ende;
2122                                 rSh.ClickToINetAttr((const SwFmtINetFmt&)rItem, URLLOAD_NOFILTER);
2123                             }
2124                         }
2125                     }
2126                     break;
2127                 }
2128             }
2129             break;
2130 
2131         case KS_EnterCharCell:
2132             {
2133                 eKeyState = KS_KeyToView;
2134                 switch ( rKeyCode.GetModifier() | rKeyCode.GetCode() )
2135                 {
2136                     case KEY_RIGHT | KEY_MOD2:
2137                         rSh.Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
2138                         eKeyState = KS_Ende;
2139                         FlushInBuffer();
2140                         break;
2141                     case KEY_LEFT | KEY_MOD2:
2142                         rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False );
2143                         eKeyState = KS_Ende;
2144                         FlushInBuffer();
2145                         break;
2146                 }
2147             }
2148             break;
2149 
2150         case KS_KeyToView:
2151             {
2152                 eKeyState = KS_Ende;
2153                 bNormalChar =
2154                     !rKeyCode.IsMod2() &&
2155                     rKeyCode.GetModifier() != (KEY_MOD1) &&
2156                     rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) &&
2157                                 SW_ISPRINTABLE( aCh );
2158 
2159                 if (bNormalChar && rSh.IsInFrontOfLabel())
2160                 {
2161                     rSh.NumOrNoNum(sal_False);
2162                 }
2163 
2164                 if( aInBuffer.Len() && ( !bNormalChar || bIsDocReadOnly ))
2165                     FlushInBuffer();
2166 
2167                 if( rView.KeyInput( aKeyEvent ) )
2168                     bFlushBuffer = sal_True, bNormalChar = sal_False;
2169                 else
2170                 {
2171 // OS 22.09.95: Da der Sfx Acceleratoren nur aufruft, wenn sie beim letzten
2172 //              Statusupdate enabled wurden, muss copy ggf. von uns
2173 //              'gewaltsam' gerufen werden.
2174                     if( rKeyCode.GetFunction() == KEYFUNC_COPY )
2175                         GetView().GetViewFrame()->GetBindings().Execute(SID_COPY);
2176 
2177 
2178                     if( !bIsDocReadOnly && bNormalChar )
2179                     {
2180                         const int nSelectionType = rSh.GetSelectionType();
2181                         if((nSelectionType & nsSelectionType::SEL_DRW) &&
2182                             0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) &&
2183                             rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
2184                         {
2185                             SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
2186                             if(pObj)
2187                             {
2188                                 EnterDrawTextMode(pObj->GetLogicRect().Center());
2189                                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
2190                                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
2191                                 rSh.GetDrawView()->KeyInput( rKEvt, this );
2192                             }
2193                         }
2194                         else if(nSelectionType & nsSelectionType::SEL_FRM)
2195                         {
2196                             rSh.UnSelectFrm();
2197                             rSh.LeaveSelFrmMode();
2198                             rView.AttrChangedNotify(&rSh);
2199                             rSh.MoveSection( fnSectionCurr, fnSectionEnd );
2200                         }
2201                         eKeyState = KS_InsChar;
2202                     }
2203                     else
2204                     {
2205                         bNormalChar = sal_False;
2206                         Window::KeyInput( aKeyEvent );
2207                     }
2208                 }
2209             }
2210             break;
2211         case KS_LaunchOLEObject:
2212             rSh.LaunchOLEObj();
2213             eKeyState = KS_Ende;
2214         break;
2215         case KS_GoIntoFly :
2216             rSh.UnSelectFrm();
2217             rSh.LeaveSelFrmMode();
2218             rView.AttrChangedNotify(&rSh);
2219             rSh.MoveSection( fnSectionCurr, fnSectionEnd );
2220             eKeyState = KS_Ende;
2221         break;
2222         case KS_GoIntoDrawing :
2223         {
2224             SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
2225             if(pObj)
2226             {
2227                 EnterDrawTextMode(pObj->GetLogicRect().Center());
2228                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
2229                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
2230             }
2231             eKeyState = KS_Ende;
2232         }
2233         break;
2234         case KS_EnterDrawHandleMode:
2235         {
2236             const SdrHdlList& rHdlList = rSh.GetDrawView()->GetHdlList();
2237             sal_Bool bForward(!aKeyEvent.GetKeyCode().IsShift());
2238 
2239             ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
2240             eKeyState = KS_Ende;
2241         }
2242         break;
2243         case KS_InsTab:
2244             if( rView.ISA( SwWebView ))     //Kein Tabulator fuer Web!
2245             {
2246                 // Bug 56196 - dann sollte der weiter gereicht werden.
2247                 Window::KeyInput( aKeyEvent );
2248                 eKeyState = KS_Ende;
2249                 break;
2250             }
2251             aCh = '\t';
2252             // kein break!
2253         case KS_InsChar:
2254             if (rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
2255             {
2256                 ::sw::mark::ICheckboxFieldmark* pFieldmark =
2257                     dynamic_cast< ::sw::mark::ICheckboxFieldmark* >
2258                         (rSh.GetCurrentFieldmark());
2259                 OSL_ENSURE(pFieldmark,
2260                     "Where is my FieldMark??");
2261                 if(pFieldmark)
2262                 {
2263                     pFieldmark->SetChecked(!pFieldmark->IsChecked());
2264                     SwDocShell* pDocSh = rView.GetDocShell();
2265                     SwDoc *pDoc=pDocSh->GetDoc();
2266                     OSL_ENSURE(pFieldmark->IsExpanded(),
2267                         "where is the otherpos?");
2268                     if (pFieldmark->IsExpanded())
2269                     {
2270                         SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos());
2271                         if(0)
2272                         {
2273                             rSh.StartAllAction();  //$flr TODO: understand why this not works
2274                             pDoc->SetModified(aPaM);
2275                             rSh.EndAllAction();
2276                         }
2277                         else
2278                         {
2279                             rSh.CalcLayout(); // workaround
2280                         }
2281                     }
2282                 }
2283                 eKeyState = KS_Ende;
2284             }
2285             else if(!rSh.HasReadonlySel())
2286             {
2287                 sal_Bool bIsNormalChar = GetAppCharClass().isLetterNumeric(
2288                                                             String( aCh ), 0 );
2289                 if( bChkInsBlank && bIsNormalChar &&
2290                     (aInBuffer.Len() || !rSh.IsSttPara() || !rSh.IsEndPara() ))
2291                 {
2292                     // vor dem Zeichen noch ein Blank einfuegen. Dieses
2293                     // kommt zwischen den Expandierten Text und dem neuen
2294                     // "nicht Worttrenner".
2295                     aInBuffer.Expand( aInBuffer.Len() + 1, ' ' );
2296                 }
2297 
2298 
2299                 sal_Bool bIsAutoCorrectChar =  SvxAutoCorrect::IsAutoCorrectChar( aCh );
2300                 sal_Bool bRunNext = pACorr && pACorr->HasRunNext();
2301                 if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
2302                         pACfg->IsAutoFmtByInput() &&
2303                     (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) &&
2304                         ( '*' == aCh || '_' == aCh ) ) ||
2305                      ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
2306                      ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
2307                 {
2308                     FlushInBuffer();
2309                     rSh.AutoCorrect( *pACorr, aCh );
2310                     if( '\"' != aCh && '\'' != aCh )        // nur bei "*_" rufen!
2311                         rSh.UpdateAttr();
2312                 }
2313                 else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) &&
2314                         pACfg->IsAutoFmtByInput() &&
2315                     pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
2316                                             ChgOrdinalNumber | AddNonBrkSpace |
2317                                             ChgToEnEmDash | SetINetAttr |
2318                                             Autocorrect ) &&
2319                     '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh
2320                     )
2321                 {
2322                     FlushInBuffer();
2323                     rSh.AutoCorrect( *pACorr, aCh );
2324                 }
2325                 else
2326                 {
2327                     aInBuffer.Expand( aInBuffer.Len() + aKeyEvent.GetRepeat() + 1,aCh );
2328                     bFlushCharBuffer = Application::AnyInput( INPUT_KEYBOARD );
2329                     bFlushBuffer = !bFlushCharBuffer;
2330                     if( bFlushCharBuffer )
2331                         aKeyInputFlushTimer.Start();
2332                 }
2333                 eKeyState = KS_Ende;
2334             }
2335             else
2336             {
2337                 InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
2338     // ???          Window::KeyInput( aKeyEvent );
2339                 eKeyState = KS_Ende;
2340             }
2341         break;
2342 
2343         case KS_CheckAutoCorrect:
2344         {
2345             if( pACorr && pACfg->IsAutoFmtByInput() &&
2346 				pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
2347 										ChgOrdinalNumber |
2348 										ChgToEnEmDash | SetINetAttr |
2349 										Autocorrect ) &&
2350 				!rSh.HasReadonlySel() )
2351 		/*	{
2352                 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
2353                                         ChgFractionSymbol | ChgOrdinalNumber |
2354                                         ChgToEnEmDash | SetINetAttr |
2355                                         Autocorrect ) &&
2356                 !rSh.HasReadonlySel() ) */
2357             {
2358                 FlushInBuffer();
2359                 rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') );
2360             }
2361             eKeyState = eNextKeyState;
2362         }
2363         break;
2364 
2365         default:
2366         {
2367             sal_uInt16 nSlotId = 0;
2368             FlushInBuffer();
2369 //???           if( bFlushCharBuffer )
2370 //???               FlushInBuffer( &rSh );
2371             switch( eKeyState )
2372             {
2373             case KS_SpecialInsert:
2374                 rSh.DoSpecialInsert();
2375                 break;
2376 
2377             case KS_NoNum:
2378                 rSh.NoNum();
2379                 break;
2380 
2381             case KS_NumOff:
2382                 // Shellwechsel - also vorher aufzeichnen
2383                 rSh.DelNumRules();
2384                 eKeyState = eNextKeyState;
2385                 break;
2386             case KS_OutlineLvOff: // delete autofmt outlinelevel later
2387                 break;
2388 
2389             case KS_NumDown:
2390                 rSh.NumUpDown( sal_True );
2391                 nKS_NUMDOWN_Count = 2; // #i23725#
2392                 break;
2393             case KS_NumUp:
2394                 rSh.NumUpDown( sal_False );
2395                 break;
2396 
2397                 // -> #i23726#
2398             case KS_NumIndentInc:
2399                 // --> OD 2008-06-16 #i90078#
2400                 rSh.ChangeIndentOfAllListLevels(360);
2401                 // <--
2402                 nKS_NUMINDENTINC_Count = 2;
2403                 break;
2404 
2405             case KS_GotoNextFieldMark:
2406                 {
2407                     ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkAfter();
2408                     if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
2409                 }
2410                 break;
2411 
2412             case KS_GotoPrevFieldMark:
2413                 {
2414                     ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkBefore();
2415                     if(pFieldmark) rSh.GotoFieldmark(pFieldmark);
2416                 }
2417                 break;
2418 
2419             case KS_NumIndentDec:
2420                 // --> OD 2008-06-16 #i90078#
2421                 rSh.ChangeIndentOfAllListLevels(-360);
2422                 // <--
2423                 break;
2424                 // <- #i23726#
2425 
2426             case KS_OutlineDown:
2427                 rSh.OutlineUpDown( 1 );
2428                 break;
2429             case KS_OutlineUp:
2430                 rSh.OutlineUpDown( -1 );
2431                 break;
2432 
2433             case KS_NextCell:
2434                 //In Tabelle immer 'flushen'
2435                 rSh.GoNextCell();
2436                 nSlotId = FN_GOTO_NEXT_CELL;
2437                 break;
2438             case KS_PrevCell:
2439                 rSh.GoPrevCell();
2440                 nSlotId = FN_GOTO_PREV_CELL;
2441                 break;
2442             case KS_AutoFmtByInput:
2443                 rSh.SplitNode( sal_True );
2444                 break;
2445 
2446 //          case KS_NumOrNoNum:
2447 //              break;
2448             case KS_NextObject:
2449             case KS_PrevObject:
2450                 if(rSh.GotoObj( KS_NextObject == eKeyState, GOTOOBJ_GOTO_ANY))
2451                 {
2452                     if( rSh.IsFrmSelected() &&
2453                         rView.GetDrawFuncPtr() )
2454                     {
2455                         rView.GetDrawFuncPtr()->Deactivate();
2456                         rView.SetDrawFuncPtr(NULL);
2457                         rView.LeaveDrawCreate();
2458                         rView.AttrChangedNotify( &rSh );
2459                     }
2460                     rSh.HideCrsr();
2461                     rSh.EnterSelFrmMode();
2462                 }
2463             break;
2464             case KS_GlossaryExpand:
2465             {
2466                 // ersetze das Wort oder Kuerzel durch den den Textbaustein
2467                 rSh.StartUndo( UNDO_START );
2468 
2469                 String sFnd( *aTmpQHD.aArr[ aTmpQHD.nCurArrPos ] );
2470                 if( aTmpQHD.bIsAutoText )
2471                 {
2472                     SwGlossaryList* pList = ::GetGlossaryList();
2473                     String sShrtNm;
2474                     String sGroup;
2475                     if(pList->GetShortName( sFnd, sShrtNm, sGroup))
2476                     {
2477                         rSh.SttSelect();
2478                         rSh.ExtendSelection( sal_False, aTmpQHD.nLen );
2479                         SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
2480                         pGlosHdl->SetCurGroup(sGroup, sal_True);
2481                         pGlosHdl->InsertGlossary( sShrtNm);
2482                         pQuickHlpData->bChkInsBlank = sal_True;
2483                     }
2484                 }
2485                 else
2486                 {
2487                     rSh.Insert( sFnd.Erase( 0, aTmpQHD.nLen ));
2488                     pQuickHlpData->bChkInsBlank = !pACorr ||
2489                             pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
2490                 }
2491                 rSh.EndUndo( UNDO_END );
2492             }
2493             break;
2494 
2495             case KS_NextPrevGlossary:
2496                 pQuickHlpData->Move( aTmpQHD );
2497                 pQuickHlpData->Start( rSh, USHRT_MAX );
2498                 break;
2499 
2500             case KS_EditFormula:
2501             {
2502                 const sal_uInt16 nId = SwInputChild::GetChildWindowId();
2503 
2504                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
2505                 pVFrame->ToggleChildWindow( nId );
2506                 SwInputChild* pChildWin = (SwInputChild*)pVFrame->
2507                                                     GetChildWindow( nId );
2508                 if( pChildWin )
2509                     pChildWin->SetFormula( sFmlEntry );
2510             }
2511             break;
2512 
2513             case KS_ColLeftBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );   break;
2514             case KS_ColRightBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );  break;
2515             case KS_ColLeftSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHMove() );   break;
2516             case KS_ColRightSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHMove() );  break;
2517 //          case KS_ColTopBig:          rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() );    break;
2518             case KS_ColBottomBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break;
2519 //          case KS_ColTopSmall:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVMove() );    break;
2520             case KS_ColBottomSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVMove() ); break;
2521             case KS_CellLeftBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() );  break;
2522             case KS_CellRightBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break;
2523             case KS_CellLeftSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHMove() );  break;
2524             case KS_CellRightSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHMove() ); break;
2525             case KS_CellTopBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() );   break;
2526             case KS_CellBottomBig:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() );    break;
2527             case KS_CellTopSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVMove() );   break;
2528             case KS_CellBottomSmall:    rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVMove() );    break;
2529 
2530 //---------------
2531             case KS_InsDel_ColLeftBig:          rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break;
2532             case KS_InsDel_ColRightBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );    break;
2533             case KS_InsDel_ColLeftSmall:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHInsert() ); break;
2534             case KS_InsDel_ColRightSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHInsert() );    break;
2535             case KS_InsDel_ColTopBig:           rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );  break;
2536             case KS_InsDel_ColBottomBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );   break;
2537             case KS_InsDel_ColTopSmall:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVInsert() );  break;
2538             case KS_InsDel_ColBottomSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVInsert() );   break;
2539             case KS_InsDel_CellLeftBig:         rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );    break;
2540             case KS_InsDel_CellRightBig:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() );   break;
2541             case KS_InsDel_CellLeftSmall:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHInsert() );    break;
2542             case KS_InsDel_CellRightSmall:      rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHInsert() );   break;
2543             case KS_InsDel_CellTopBig:          rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break;
2544             case KS_InsDel_CellBottomBig:       rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() );  break;
2545             case KS_InsDel_CellTopSmall:        rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVInsert() ); break;
2546             case KS_InsDel_CellBottomSmall:     rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVInsert() );  break;
2547 //---------------
2548             case KS_TblColCellInsDel:
2549                 rSh.SetColRowWidthHeight( eTblChgMode, nTblChgSize );
2550                 break;
2551             case KS_Fly_Change:
2552             {
2553                 SdrView *pSdrView = rSh.GetDrawView();
2554                 const SdrHdlList& rHdlList = pSdrView->GetHdlList();
2555                 if(rHdlList.GetFocusHdl())
2556                     ChangeDrawing( nDir );
2557                 else
2558                     ChangeFly( nDir, rView.ISA( SwWebView ) );
2559             }
2560             break;
2561             case KS_Draw_Change :
2562                 ChangeDrawing( nDir );
2563                 break;
2564             default:; //prevent warning
2565             }
2566             if( nSlotId && rView.GetViewFrame()->GetBindings().GetRecorder().is() )
2567             {
2568                 SfxRequest aReq(rView.GetViewFrame(), nSlotId );
2569                 aReq.Done();
2570             }
2571             eKeyState = KS_Ende;
2572         }
2573         }
2574     }
2575 
2576     if( bStopKeyInputTimer )
2577     {
2578         aKeyInputTimer.Stop();
2579         bTblInsDelMode = sal_False;
2580     }
2581 
2582     // falls die gepufferten Zeichen eingefuegt werden sollen
2583     if( bFlushBuffer && aInBuffer.Len() )
2584     {
2585         //OS 16.02.96 11.04: bFlushCharBuffer wurde hier nicht zurueckgesetzt
2586         // warum nicht?
2587         sal_Bool bSave = bFlushCharBuffer;
2588         FlushInBuffer();
2589         bFlushCharBuffer = bSave;
2590 
2591         // evt. Tip-Hilfe anzeigen
2592         String sWord;
2593         if( bNormalChar && pACfg && pACorr &&
2594             ( pACfg->IsAutoTextTip() ||
2595               pACorr->GetSwFlags().bAutoCompleteWords ) &&
2596             rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
2597         {
2598             ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr);
2599         }
2600     }
2601 }
2602 
2603 /*--------------------------------------------------------------------
2604      Beschreibung:  MouseEvents
2605  --------------------------------------------------------------------*/
2606 
2607 
2608 void SwEditWin::RstMBDownFlags()
2609 {
2610     //Nicht auf allen Systemen kommt vor dem modalen
2611     //Dialog noch ein MouseButton Up (wie unter WINDOWS).
2612     //Daher hier die Stati zuruecksetzen und die Maus
2613     //fuer den Dialog freigeben.
2614     bMBPressed = bNoInterrupt = sal_False;
2615     EnterArea();
2616     ReleaseMouse();
2617 }
2618 
2619 
2620 
2621 void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
2622 {
2623     SwWrtShell &rSh = rView.GetWrtShell();
2624 
2625     // We have to check if a context menu is shown and we have an UI
2626     // active inplace client. In that case we have to ignore the mouse
2627     // button down event. Otherwise we would crash (context menu has been
2628     // opened by inplace client and we would deactivate the inplace client,
2629     // the contex menu is closed by VCL asynchronously which in the end
2630     // would work on deleted objects or the context menu has no parent anymore)
2631     // See #126086# and #128122#
2632     SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
2633     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
2634 
2635     if ( bIsOleActive && PopupMenu::IsInExecute() )
2636         return;
2637 
2638     MouseEvent rMEvt(_rMEvt);
2639 
2640     if (rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel()))
2641         return;
2642 
2643     rView.GetPostItMgr()->SetActiveSidebarWin(0);
2644 
2645     GrabFocus();
2646 
2647     //ignore key modifiers for format paintbrush
2648     {
2649         sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
2650                                 &&  pApplyTempl->pFormatClipboard->HasContent();
2651         if( bExecFormatPaintbrush )
2652             rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
2653                                     _rMEvt.GetMode(), _rMEvt.GetButtons() );
2654     }
2655 
2656     bWasShdwCrsr = 0 != pShadCrsr;
2657     if( bWasShdwCrsr )
2658         delete pShadCrsr, pShadCrsr = 0;
2659 
2660     const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
2661 
2662     if ( IsChainMode() )
2663     {
2664         SetChainMode( sal_False );
2665         SwRect aDummy;
2666         SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)rSh.GetFlyFrmFmt();
2667         if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) )
2668             rSh.Chain( *pFmt, aDocPos );
2669         UpdatePointer( aDocPos, rMEvt.GetModifier() );
2670         return;
2671     }
2672 
2673     //Nach GrabFocus sollte eine Shell gepusht sein. Das muss eigentlich
2674     //klappen aber in der Praxis ...
2675     lcl_SelectShellForDrop( rView );
2676 
2677     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
2678     sal_Bool bCallBase = sal_True;
2679 
2680     if( pQuickHlpData->bClear )
2681         pQuickHlpData->Stop( rSh );
2682     pQuickHlpData->bChkInsBlank = sal_False;
2683 
2684     if( rSh.FinishOLEObj() )
2685         return; //InPlace beenden und der Klick zaehlt nicht mehr
2686 
2687     SET_CURR_SHELL( &rSh );
2688 
2689     SdrView *pSdrView = rSh.GetDrawView();
2690     if ( pSdrView )
2691     {
2692         if (pSdrView->MouseButtonDown( rMEvt, this ) )
2693         {
2694             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
2695             return; // Event von der SdrView ausgewertet
2696         }
2697     }
2698 
2699 
2700     bIsInMove = sal_False;
2701     aStartPos = rMEvt.GetPosPixel();
2702     aRszMvHdlPt.X() = 0, aRszMvHdlPt.Y() = 0;
2703 
2704     sal_uInt8 nMouseTabCol = 0;
2705     const sal_Bool bTmp = !rSh.IsDrawCreate() && !pApplyTempl && !rSh.IsInSelect() &&
2706          rMEvt.GetClicks() == 1 && MOUSE_LEFT == rMEvt.GetButtons();
2707     if (  bTmp &&
2708          0 != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) &&
2709          !rSh.IsObjSelectable( aDocPos ) )
2710     {
2711         // --> FME 2004-07-30 #i32329# Enhanced table selection
2712         if ( SW_TABSEL_HORI <= nMouseTabCol && SW_TABCOLSEL_VERT >= nMouseTabCol )
2713         {
2714             rSh.EnterStdMode();
2715             rSh.SelectTableRowCol( aDocPos );
2716             if( SW_TABSEL_HORI  != nMouseTabCol && SW_TABSEL_HORI_RTL  != nMouseTabCol)
2717             {
2718                 pRowColumnSelectionStart = new Point( aDocPos );
2719                 bIsRowDrag = SW_TABROWSEL_HORI == nMouseTabCol||
2720                             SW_TABROWSEL_HORI_RTL == nMouseTabCol ||
2721                             SW_TABCOLSEL_VERT == nMouseTabCol;
2722                 bMBPressed = sal_True;
2723                 CaptureMouse();
2724             }
2725             return;
2726         }
2727         // <--
2728 
2729         if ( !rSh.IsTableMode() )
2730         {
2731             //Zuppeln von Tabellenspalten aus dem Dokument heraus.
2732             if(SW_TABCOL_VERT == nMouseTabCol || SW_TABCOL_HORI == nMouseTabCol)
2733                 rView.SetTabColFromDoc( sal_True );
2734             else
2735                 rView.SetTabRowFromDoc( sal_True );
2736 
2737             rView.SetTabColFromDocPos( aDocPos );
2738             rView.InvalidateRulerPos();
2739             SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
2740             rBind.Update();
2741             if ( RulerColumnDrag( rMEvt,
2742                     (SW_TABCOL_VERT == nMouseTabCol || SW_TABROW_HORI == nMouseTabCol)) )
2743             {
2744                 rView.SetTabColFromDoc( sal_False );
2745                 rView.SetTabRowFromDoc( sal_False );
2746                 rView.InvalidateRulerPos();
2747                 rBind.Update();
2748                 bCallBase = sal_False;
2749             }
2750             else
2751             {
2752                 return;
2753             }
2754         }
2755     }
2756     // #i23726#
2757     else if (bTmp &&
2758              rSh.IsNumLabel(aDocPos))
2759     {
2760         SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPos );
2761         rView.SetNumRuleNodeFromDoc( pNodeAtPos );
2762         rView.InvalidateRulerPos();
2763         SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
2764         rBind.Update();
2765 
2766         // --> OD 2005-02-21 #i42921#
2767         if ( RulerMarginDrag( rMEvt,
2768                         rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) )
2769         // <--
2770         {
2771             rView.SetNumRuleNodeFromDoc( NULL );
2772             rView.InvalidateRulerPos();
2773             rBind.Update();
2774             bCallBase = sal_False;
2775         }
2776         else
2777         {
2778             // --> FME 2005-11-03 #125036# Make sure the pointer is set to 0,
2779             // otherwise it may point to nowhere after deleting the corresponding
2780             // text node.
2781             rView.SetNumRuleNodeFromDoc( NULL );
2782             // <--
2783             return;
2784         }
2785     }
2786 
2787     //Man kann sich in einem Selektionszustand befinden, wenn zuletzt
2788     //mit dem Keyboard selektiert wurde, aber noch kein CURSOR_KEY
2789     //anschliessend bewegt worden ist. In diesem Fall muss die vorher-
2790     //gehende Selektion zuerst beendet werden.
2791     //MA 07. Oct. 95: Und zwar nicht nur bei Linker Maustaste sondern immer.
2792     //siehe auch Bug: 19263
2793     if ( rSh.IsInSelect() )
2794         rSh.EndSelect();
2795 
2796     //Abfrage auf LEFT, da sonst auch bei einem Click mit der rechten Taste
2797     //beispielsweise die Selektion aufgehoben wird.
2798     if ( MOUSE_LEFT == rMEvt.GetButtons() )
2799     {
2800         sal_Bool bOnlyText = sal_False;
2801         bMBPressed = bNoInterrupt = sal_True;
2802         nKS_NUMDOWN_Count = 0; // #i23725#
2803 
2804         CaptureMouse();
2805 
2806         //ggf. Cursorpositionen zuruecksetzen
2807         rSh.ResetCursorStack();
2808 
2809         switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
2810         {
2811             case MOUSE_LEFT:
2812             case MOUSE_LEFT + KEY_SHIFT:
2813             case MOUSE_LEFT + KEY_MOD2:
2814                 if( rSh.IsObjSelected() )
2815                 {
2816                     SdrHdl* pHdl;
2817                     if( !bIsDocReadOnly &&
2818                         !pAnchorMarker &&
2819                         0 != ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
2820                             ( pHdl->GetKind() == HDL_ANCHOR ||
2821                               pHdl->GetKind() == HDL_ANCHOR_TR ) )
2822                     {
2823                         pAnchorMarker = new SwAnchorMarker( pHdl );
2824                         UpdatePointer( aDocPos, rMEvt.GetModifier() );
2825                         return;
2826                     }
2827                 }
2828                 if ( EnterDrawMode( rMEvt, aDocPos ) )
2829                 {
2830                     bNoInterrupt = sal_False;
2831                     return;
2832                 }
2833                 else  if ( rView.GetDrawFuncPtr() && bInsFrm )
2834                 {
2835                     StopInsFrm();
2836                     rSh.Edit();
2837                 }
2838 
2839                 // Ohne SHIFT, da sonst Toggle bei Selektion nicht funktioniert
2840                 if (rMEvt.GetClicks() == 1)
2841                 {
2842                     if ( rSh.IsSelFrmMode())
2843                     {
2844                         SdrHdl* pHdl = rSh.GetDrawView()->PickHandle(aDocPos);
2845                         sal_Bool bHitHandle = pHdl && pHdl->GetKind() != HDL_ANCHOR &&
2846                                                   pHdl->GetKind() != HDL_ANCHOR_TR;
2847 
2848                         if ((rSh.IsInsideSelectedObj(aDocPos) || bHitHandle) &&
2849                             !(rMEvt.GetModifier() == KEY_SHIFT && !bHitHandle))
2850                         {
2851                             rSh.EnterSelFrmMode( &aDocPos );
2852                             if ( !pApplyTempl )
2853                             {
2854                                 //nur, wenn keine Position zum Sizen getroffen ist.
2855                                 if (!bHitHandle)
2856                                 {
2857                                     StartDDTimer();
2858                                     SwEditWin::nDDStartPosY = aDocPos.Y();
2859                                     SwEditWin::nDDStartPosX = aDocPos.X();
2860                                 }
2861                                 bFrmDrag = sal_True;
2862                             }
2863                             bNoInterrupt = sal_False;
2864                             return;
2865                         }
2866                     }
2867                 }
2868         }
2869 
2870         sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
2871         if ( !bExecHyperlinks )
2872         {
2873             SvtSecurityOptions aSecOpts;
2874             const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
2875             if ( (  bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
2876                  ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
2877                 bExecHyperlinks = sal_True;
2878         }
2879 
2880         // --> FME 2004-07-30 #i32329# Enhanced selection
2881         sal_uInt8 nNumberOfClicks = static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4);
2882         if ( 0 == nNumberOfClicks && 0 < rMEvt.GetClicks() )
2883             nNumberOfClicks = 4;
2884         // <--
2885 
2886         sal_Bool bExecDrawTextLink = sal_False;
2887 
2888         switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
2889         {
2890             case MOUSE_LEFT:
2891             case MOUSE_LEFT + KEY_MOD1:
2892             case MOUSE_LEFT + KEY_MOD2:
2893                 switch ( nNumberOfClicks )
2894                 {
2895                     case 1:
2896                     {
2897                         UpdatePointer( aDocPos, rMEvt.GetModifier() );
2898                         SwEditWin::nDDStartPosY = aDocPos.Y();
2899                         SwEditWin::nDDStartPosX = aDocPos.X();
2900 
2901                         // URL in DrawText-Objekt getroffen?
2902                         if (bExecHyperlinks && pSdrView)
2903                         {
2904                             SdrViewEvent aVEvt;
2905                             pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
2906 
2907                             if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
2908                                 bExecDrawTextLink = sal_True;
2909                         }
2910 
2911                         //Rahmen nur zu selektieren versuchen, wenn
2912                         //der Pointer bereits entsprechend geschaltet wurde
2913                         if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
2914                             !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
2915                             !bExecDrawTextLink)
2916                         {
2917                             // #107513#
2918                             // Test if there is a draw object at that position and if it should be selected.
2919                             sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
2920 
2921                             if(bShould)
2922                             {
2923                                 rView.NoRotate();
2924                                 rSh.HideCrsr();
2925 
2926                                 sal_Bool bUnLockView = !rSh.IsViewLocked();
2927                                 rSh.LockView( sal_True );
2928                                 sal_Bool bSelObj = rSh.SelectObj( aDocPos,
2929                                                rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
2930                                 if( bUnLockView )
2931                                     rSh.LockView( sal_False );
2932 
2933                                 if( bSelObj )
2934                                 {
2935                                     // falls im Macro der Rahmen deselektiert
2936                                     // wurde, muss nur noch der Cursor
2937                                     // wieder angezeigt werden.
2938                                     if( FRMTYPE_NONE == rSh.GetSelFrmType() )
2939                                         rSh.ShowCrsr();
2940                                     else
2941                                     {
2942                                         if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
2943                                         {
2944                                             rView.GetDrawFuncPtr()->Deactivate();
2945                                             rView.SetDrawFuncPtr(NULL);
2946                                             rView.LeaveDrawCreate();
2947                                             rView.AttrChangedNotify( &rSh );
2948                                         }
2949 
2950                                         rSh.EnterSelFrmMode( &aDocPos );
2951                                         bFrmDrag = sal_True;
2952                                         UpdatePointer( aDocPos, rMEvt.GetModifier() );
2953                                     }
2954                                     return;
2955                                 }
2956                                 else
2957                                     bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos ));
2958 
2959                                 if (!rView.GetDrawFuncPtr())
2960                                     rSh.ShowCrsr();
2961                             }
2962                             else
2963                                 bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
2964                         }
2965                         else if ( rSh.IsSelFrmMode() &&
2966                                   (aActHitType == SDRHIT_NONE ||
2967                                    !rSh.IsInsideSelectedObj( aDocPos )))
2968                         {
2969                             rView.NoRotate();
2970                             SdrHdl *pHdl;
2971                             if( !bIsDocReadOnly && !pAnchorMarker && 0 !=
2972                                 ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
2973                                     ( pHdl->GetKind() == HDL_ANCHOR ||
2974                                       pHdl->GetKind() == HDL_ANCHOR_TR ) )
2975                             {
2976                                 pAnchorMarker = new SwAnchorMarker( pHdl );
2977                                 UpdatePointer( aDocPos, rMEvt.GetModifier() );
2978                                 return;
2979                             }
2980                             else
2981                             {
2982                                 sal_Bool bUnLockView = !rSh.IsViewLocked();
2983                                 rSh.LockView( sal_True );
2984                                 sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
2985                                 if( rMEvt.IsMod1() )
2986                                     nFlag = nFlag | SW_ENTER_GROUP;
2987 
2988                                 if ( rSh.IsSelFrmMode() )
2989                                 {
2990                                     rSh.UnSelectFrm();
2991                                     rSh.LeaveSelFrmMode();
2992                                     rView.AttrChangedNotify(&rSh);
2993                                 }
2994 
2995                                 sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
2996                                 if( bUnLockView )
2997                                     rSh.LockView( sal_False );
2998 
2999                                 if( !bSelObj )
3000                                 {
3001                                     // Cursor hier umsetzen, damit er nicht zuerst
3002                                     // im Rahmen gezeichnet wird; ShowCrsr() geschieht
3003                                     // in LeaveSelFrmMode()
3004                                     bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False));
3005                                     rSh.LeaveSelFrmMode();
3006                                     rView.AttrChangedNotify( &rSh );
3007                                     bCallBase = sal_False;
3008                                 }
3009                                 else
3010                                 {
3011                                     rSh.HideCrsr();
3012                                     rSh.EnterSelFrmMode( &aDocPos );
3013                                     rSh.SelFlyGrabCrsr();
3014                                     rSh.MakeSelVisible();
3015                                     bFrmDrag = sal_True;
3016                                     if( rSh.IsFrmSelected() &&
3017                                         rView.GetDrawFuncPtr() )
3018                                     {
3019                                         rView.GetDrawFuncPtr()->Deactivate();
3020                                         rView.SetDrawFuncPtr(NULL);
3021                                         rView.LeaveDrawCreate();
3022                                         rView.AttrChangedNotify( &rSh );
3023                                     }
3024                                     UpdatePointer( aDocPos, rMEvt.GetModifier() );
3025                                     return;
3026                                 }
3027                             }
3028                         }
3029 
3030                         break;
3031                     }
3032                     case 2:
3033                     {
3034                         bFrmDrag = sal_False;
3035                         if ( !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
3036                              0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
3037 
3038 /* SJ: 01.03.2005: this is no good, on the one hand GetSelectionType is used as flag field (take a look into the GetSelectionType method)
3039    on the other hand the return value is used in a switch without proper masking (very nice), this must lead to trouble
3040 */
3041                         switch ( rSh.GetSelectionType() &~ ( nsSelectionType::SEL_FONTWORK | nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE ) )
3042                         {
3043                             case nsSelectionType::SEL_GRF:
3044                                 RstMBDownFlags();
3045                                 GetView().GetViewFrame()->GetBindings().Execute(
3046                                     FN_FORMAT_GRAFIC_DLG, 0, 0,
3047                                     SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
3048                                 return;
3049 
3050                                 // Doppelklick auf OLE-Objekt --> OLE-InPlace
3051                             case nsSelectionType::SEL_OLE:
3052                                 if (!rSh.IsSelObjProtected(FLYPROTECT_CONTENT))
3053                                 {
3054                                     RstMBDownFlags();
3055                                     rSh.LaunchOLEObj();
3056                                 }
3057                                 return;
3058 
3059                             case nsSelectionType::SEL_FRM:
3060                                 RstMBDownFlags();
3061                                 GetView().GetViewFrame()->GetBindings().Execute(
3062                                     FN_FORMAT_FRAME_DLG, 0, 0, SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT);
3063                                 return;
3064 
3065                             case nsSelectionType::SEL_DRW:
3066                                 RstMBDownFlags();
3067                                 EnterDrawTextMode(aDocPos);
3068                                 if ( rView.GetCurShell()->ISA(SwDrawTextShell) )
3069                                     ((SwDrawTextShell*)rView.GetCurShell())->Init();
3070                                 return;
3071                         }
3072 
3073                         //falls die Cursorposition korrigiert wurde oder
3074                         // ein Fly im ReadOnlyModus selektiert ist,
3075                         //keine Wortselektion.
3076                         if ( !bValidCrsrPos ||
3077                             (rSh.IsFrmSelected() && rSh.IsFrmSelected() ))
3078                             return;
3079 
3080                         SwField *pFld;
3081                         sal_Bool bFtn = sal_False;
3082 
3083                         if( !bIsDocReadOnly &&
3084                             ( 0 != ( pFld = rSh.GetCurFld() ) ||
3085                               0 != ( bFtn = rSh.GetCurFtn() )) )
3086                         {
3087                             RstMBDownFlags();
3088                             if( bFtn )
3089                                 GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE );
3090                             else
3091                             {
3092                                 sal_uInt16 nTypeId = pFld->GetTypeId();
3093                                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
3094                                 switch( nTypeId )
3095                                 {
3096                                 case TYP_POSTITFLD:
3097                                 case TYP_SCRIPTFLD:
3098                                 {
3099                                     //falls es ein Readonly-Bereich ist, dann muss der Status
3100                                     //enabled werden
3101                                     sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT;
3102                                     SfxBoolItem aItem(nSlot, sal_True);
3103                                     pVFrame->GetBindings().SetState(aItem);
3104                                     pVFrame->GetBindings().Execute(nSlot);
3105                                     break;
3106                                 }
3107                                 case TYP_AUTHORITY :
3108                                     pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG);
3109                                 break;
3110                                 default:
3111                                     pVFrame->GetBindings().Execute(FN_EDIT_FIELD);
3112                                 }
3113                             }
3114                             return;
3115                         }
3116                         //im Extended Mode hat Doppel- und
3117                         //Dreifachklick keine Auswirkungen.
3118                         if ( rSh.IsExtMode() || rSh.IsBlockMode() )
3119                             return;
3120 
3121                         //Wort selektieren, gfs. Additional Mode
3122                         if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
3123                         {
3124                             rSh.EnterAddMode();
3125                             rSh.SelWrd( &aDocPos );
3126                             rSh.LeaveAddMode();
3127                         }
3128                         else
3129                             rSh.SelWrd( &aDocPos );
3130                         bHoldSelection = sal_True;
3131                         return;
3132                     }
3133                     case 3:
3134                     case 4:
3135                     {
3136                         bFrmDrag = sal_False;
3137                         //im Extended Mode hat Doppel- und
3138                         //Dreifachklick keine Auswirkungen.
3139                         if ( rSh.IsExtMode() )
3140                             return;
3141 
3142                         //falls die Cursorposition korrigiert wurde oder
3143                         // ein Fly im ReadOnlyModus selektiert ist,
3144                         //keine Wortselektion.
3145                         if ( !bValidCrsrPos || rSh.IsFrmSelected() )
3146                             return;
3147 
3148                         //Zeile selektieren, gfs. Additional Mode
3149                         const bool bMod = KEY_MOD1 == rMEvt.GetModifier() &&
3150                                          !rSh.IsAddMode();
3151 
3152                         if ( bMod )
3153                             rSh.EnterAddMode();
3154 
3155                         // --> FME 2004-07-30 #i32329# Enhanced selection
3156                         if ( 3 == nNumberOfClicks )
3157                             rSh.SelSentence( &aDocPos );
3158                         else
3159                             rSh.SelPara( &aDocPos );
3160                         // <--
3161 
3162                         if ( bMod )
3163                             rSh.LeaveAddMode();
3164 
3165                         bHoldSelection = sal_True;
3166                         return;
3167                     }
3168 
3169                     default:
3170                         return;
3171                 }
3172                 /* no break */
3173             case MOUSE_LEFT + KEY_SHIFT:
3174             case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
3175             {
3176                 sal_Bool bLockView = bWasShdwCrsr;
3177 
3178                 switch ( rMEvt.GetModifier() )
3179                 {
3180                     case KEY_MOD1 + KEY_SHIFT:
3181                     {
3182                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
3183                         {
3184                             rView.NoRotate();
3185                             rSh.HideCrsr();
3186                             if ( rSh.IsSelFrmMode() )
3187                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP);
3188                             else
3189                             {   if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) )
3190                                 {
3191                                     rSh.EnterSelFrmMode( &aDocPos );
3192                                     SwEditWin::nDDStartPosY = aDocPos.Y();
3193                                     SwEditWin::nDDStartPosX = aDocPos.X();
3194                                     bFrmDrag = sal_True;
3195                                     return;
3196                                 }
3197                             }
3198                         }
3199                         else if( rSh.IsSelFrmMode() &&
3200                                  rSh.GetDrawView()->PickHandle( aDocPos ))
3201                         {
3202                             bFrmDrag = sal_True;
3203                             bNoInterrupt = sal_False;
3204                             return;
3205                         }
3206                     }
3207                     break;
3208                     case KEY_MOD1:
3209                     if ( !bExecDrawTextLink )
3210                     {
3211                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
3212                         {
3213                             rView.NoRotate();
3214                             rSh.HideCrsr();
3215                             if ( rSh.IsSelFrmMode() )
3216                                 rSh.SelectObj(aDocPos, SW_ENTER_GROUP);
3217                             else
3218                             {   if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) )
3219                                 {
3220                                     rSh.EnterSelFrmMode( &aDocPos );
3221                                     SwEditWin::nDDStartPosY = aDocPos.Y();
3222                                     SwEditWin::nDDStartPosX = aDocPos.X();
3223                                     bFrmDrag = sal_True;
3224                                     return;
3225                                 }
3226                             }
3227                         }
3228                         else if( rSh.IsSelFrmMode() &&
3229                                  rSh.GetDrawView()->PickHandle( aDocPos ))
3230                         {
3231                             bFrmDrag = sal_True;
3232                             bNoInterrupt = sal_False;
3233                             return;
3234                         }
3235                         else
3236                         {
3237                             if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
3238                             {
3239                                 rSh.PushMode();
3240                                 bModePushed = sal_True;
3241 
3242                                 sal_Bool bUnLockView = !rSh.IsViewLocked();
3243                                 rSh.LockView( sal_True );
3244                                 rSh.EnterAddMode();
3245                                 if( bUnLockView )
3246                                     rSh.LockView( sal_False );
3247                             }
3248                             bCallBase = sal_False;
3249                         }
3250                     }
3251                     break;
3252                     case KEY_MOD2:
3253                     {
3254                         if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
3255                         {
3256                             rSh.PushMode();
3257                             bModePushed = sal_True;
3258                             sal_Bool bUnLockView = !rSh.IsViewLocked();
3259                             rSh.LockView( sal_True );
3260                             rSh.EnterBlockMode();
3261                             if( bUnLockView )
3262                                 rSh.LockView( sal_False );
3263                         }
3264                         bCallBase = sal_False;
3265                     }
3266                     break;
3267                     case KEY_SHIFT:
3268                     {
3269                         if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) )
3270                         {
3271                             rView.NoRotate();
3272                             rSh.HideCrsr();
3273                             if ( rSh.IsSelFrmMode() )
3274                             {
3275                                 rSh.SelectObj(aDocPos, SW_ADD_SELECT);
3276 
3277                                 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
3278                                 if (rMarkList.GetMark(0) == NULL)
3279                                 {
3280                                     rSh.LeaveSelFrmMode();
3281                                     rView.AttrChangedNotify(&rSh);
3282                                     bFrmDrag = sal_False;
3283                                 }
3284                             }
3285                             else
3286                             {   if ( rSh.SelectObj( aDocPos ) )
3287                                 {
3288                                     rSh.EnterSelFrmMode( &aDocPos );
3289                                     SwEditWin::nDDStartPosY = aDocPos.Y();
3290                                     SwEditWin::nDDStartPosX = aDocPos.X();
3291                                     bFrmDrag = sal_True;
3292                                     return;
3293                                 }
3294                             }
3295                         }
3296                         else
3297                         {
3298                             if ( rSh.IsSelFrmMode() &&
3299                                  rSh.IsInsideSelectedObj( aDocPos ) )
3300                             {
3301                                 rSh.EnterSelFrmMode( &aDocPos );
3302                                 SwEditWin::nDDStartPosY = aDocPos.Y();
3303                                 SwEditWin::nDDStartPosX = aDocPos.X();
3304                                 bFrmDrag = sal_True;
3305                                 return;
3306                             }
3307                             if ( rSh.IsSelFrmMode() )
3308                             {
3309                                 rSh.UnSelectFrm();
3310                                 rSh.LeaveSelFrmMode();
3311                                 rView.AttrChangedNotify(&rSh);
3312                                 bFrmDrag = sal_False;
3313                             }
3314                             if ( !rSh.IsExtMode() )
3315                             {
3316                                 // keine Selection anfangen, wenn in ein URL-
3317                                 // Feld oder eine -Grafik geklickt wird
3318                                 sal_Bool bSttSelect = rSh.HasSelection() ||
3319                                                 Pointer(POINTER_REFHAND) != GetPointer();
3320 
3321                                 if( !bSttSelect )
3322                                 {
3323                                     bSttSelect = sal_True;
3324                                     if( bExecHyperlinks )
3325                                     {
3326                                         SwContentAtPos aCntntAtPos(
3327                                             SwContentAtPos::SW_FTN |
3328                                             SwContentAtPos::SW_INETATTR );
3329 
3330                                         if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) )
3331                                         {
3332                                             if( !rSh.IsViewLocked() &&
3333                                                 !rSh.IsReadOnlyAvailable() &&
3334                                                 aCntntAtPos.IsInProtectSect() )
3335                                                     bLockView = sal_True;
3336 
3337                                             bSttSelect = sal_False;
3338                                         }
3339                                         else if( rSh.IsURLGrfAtPos( aDocPos ))
3340                                             bSttSelect = sal_False;
3341                                     }
3342                                 }
3343 
3344                                 if( bSttSelect )
3345                                     rSh.SttSelect();
3346                             }
3347                         }
3348                         bCallBase = sal_False;
3349                         break;
3350                     }
3351                     default:
3352                         if( !rSh.IsViewLocked() )
3353                         {
3354                             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
3355                                                         SwContentAtPos::SW_INETATTR );
3356                             if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, sal_False ) &&
3357                                 !rSh.IsReadOnlyAvailable() &&
3358                                 aCntntAtPos.IsInProtectSect() )
3359                                 bLockView = sal_True;
3360                         }
3361                 }
3362 
3363                 if ( rSh.IsGCAttr() )
3364                 {
3365                     rSh.GCAttr();
3366                     rSh.ClearGCAttr();
3367                 }
3368 
3369                 sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
3370                 if( !bOverSelect )
3371                     bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
3372 
3373                 if ( !bOverSelect )
3374                 {
3375                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
3376                     bNoInterrupt = sal_False;
3377 
3378                     if( !rSh.IsViewLocked() && bLockView )
3379                         rSh.LockView( sal_True );
3380                     else
3381                         bLockView = sal_False;
3382 
3383                     int nTmpSetCrsr = 0;
3384 
3385                     {   // nur temp. Move-Kontext aufspannen, da sonst die
3386                         // Abfrage auf die Inhaltsform nicht funktioniert!!!
3387                         MV_KONTEXT( &rSh );
3388                         nTmpSetCrsr = (rSh.*rSh.fnSetCrsr)(&aDocPos,bOnlyText);
3389                         bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr);
3390                         bCallBase = sal_False;
3391                     }
3392 
3393                     //#i42732# - notify the edit window that from now on we do not use the input language
3394                     if ( !(CRSR_POSOLD & nTmpSetCrsr) )
3395                         SetUseInputLanguage( sal_False );
3396 
3397                     if( bLockView )
3398                         rSh.LockView( sal_False );
3399 
3400                     bNoInterrupt = bTmpNoInterrupt;
3401                 }
3402                 if ( !bOverURLGrf && !bOnlyText )
3403                 {
3404                     const int nSelType = rSh.GetSelectionType();
3405                     // --> OD 2009-12-30 #i89920#
3406                     // Check in general, if an object is selectable at given position.
3407                     // Thus, also text fly frames in background become selectable via Ctrl-Click.
3408                     if ( nSelType & nsSelectionType::SEL_OLE ||
3409                          nSelType & nsSelectionType::SEL_GRF ||
3410                          rSh.IsObjSelectable( aDocPos ) )
3411                     // <--
3412                     {
3413                         MV_KONTEXT( &rSh );
3414                         if( !rSh.IsFrmSelected() )
3415                             rSh.GotoNextFly();
3416                         rSh.EnterSelFrmMode();
3417                         bCallBase = sal_False;
3418                     }
3419                 }
3420                 // nicht mehr hier zuruecksetzen, damit -- falls durch MouseMove
3421                 // bei gedrueckter Ctrl-Taste eine Mehrfachselektion erfolgen soll,
3422                 // im Drag nicht die vorherige Selektion aufgehoben wird.
3423 //              if(bModePushed)
3424 //                  rSh.PopMode(sal_False);
3425                 break;
3426             }
3427         }
3428     }
3429     if (bCallBase)
3430         Window::MouseButtonDown(rMEvt);
3431 }
3432 
3433 /*--------------------------------------------------------------------
3434     Beschreibung:   MouseMove
3435  --------------------------------------------------------------------*/
3436 
3437 
3438 void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
3439 {
3440     MouseEvent rMEvt(_rMEvt);
3441 
3442     //ignore key modifiers for format paintbrush
3443     {
3444         sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard
3445                                 &&  pApplyTempl->pFormatClipboard->HasContent();
3446         if( bExecFormatPaintbrush )
3447             rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(),
3448                                     _rMEvt.GetMode(), _rMEvt.GetButtons() );
3449     }
3450 
3451     // solange eine Action laeuft sollte das MouseMove abgeklemmt sein
3452     // Ansonsten gibt es den Bug 40102
3453     SwWrtShell &rSh = rView.GetWrtShell();
3454     if( rSh.ActionPend() )
3455         return ;
3456 
3457     if( pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) )
3458         delete pShadCrsr, pShadCrsr = 0;
3459 
3460     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
3461 
3462     SET_CURR_SHELL( &rSh );
3463 
3464     //aPixPt == Point in Pixel, rel. zu ChildWin
3465     //aDocPt == Point in Twips, Dokumentkoordinaten
3466     const Point aPixPt( rMEvt.GetPosPixel() );
3467     const Point aDocPt( PixelToLogic( aPixPt ) );
3468 
3469     if ( IsChainMode() )
3470     {
3471         UpdatePointer( aDocPt, rMEvt.GetModifier() );
3472         if ( rMEvt.IsLeaveWindow() )
3473             rView.GetViewFrame()->HideStatusText();
3474         return;
3475     }
3476 
3477     SdrView *pSdrView = rSh.GetDrawView();
3478 
3479     const SwCallMouseEvent aLastCallEvent( aSaveCallEvent );
3480     aSaveCallEvent.Clear();
3481 
3482     if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) )
3483     {
3484         SetPointer( POINTER_TEXT );
3485         return; // Event von der SdrView ausgewertet
3486     }
3487 
3488     const Point aOldPt( rSh.VisArea().Pos() );
3489 #ifdef TEST_FOR_BUG91313
3490     // n Pixel as FUZZY border
3491     SwRect aVis( rSh.VisArea() );
3492     Size aFuzzySz( 2, 2 );
3493     aFuzzySz = PixelToLogic( aFuzzySz );
3494 
3495     aVis.Top(    aVis.Top()    + aFuzzySz.Height() );
3496     aVis.Bottom( aVis.Bottom() - aFuzzySz.Height() );
3497     aVis.Left(   aVis.Left()   + aFuzzySz.Width() );
3498     aVis.Right(  aVis.Right()  - aFuzzySz.Width() );
3499     const sal_Bool bInsWin = aVis.IsInside( aDocPt );
3500 #else
3501     const sal_Bool bInsWin = rSh.VisArea().IsInside( aDocPt );
3502 #endif
3503 
3504     if( pShadCrsr && !bInsWin )
3505         delete pShadCrsr, pShadCrsr = 0;
3506 
3507     if( bInsWin && pRowColumnSelectionStart )
3508     {
3509         EnterArea();
3510         Point aPos( aDocPt );
3511         if( rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag ))
3512             return;
3513     }
3514 
3515     // Position ist noetig fuer OS/2, da dort nach einem MB-Down
3516     // offensichtlich sofort ein MB-Move gerufen wird.
3517     if( bDDTimerStarted )
3518     {
3519         Point aDD( SwEditWin::nDDStartPosX, SwEditWin::nDDStartPosY );
3520         aDD = LogicToPixel( aDD );
3521         Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 );
3522         if ( !aRect.IsInside( aPixPt ) )    // MA 23. May. 95: Tatterschutz.
3523             StopDDTimer( &rSh, aDocPt );
3524     }
3525 
3526     if(rView.GetDrawFuncPtr())
3527     {
3528         if( bInsDraw  )
3529         {
3530             rView.GetDrawFuncPtr()->MouseMove( rMEvt );
3531             if ( !bInsWin )
3532             {
3533                 Point aTmp( aDocPt );
3534                 aTmp += rSh.VisArea().Pos() - aOldPt;
3535                 LeaveArea( aTmp );
3536             }
3537             else
3538                 EnterArea();
3539             return;
3540         }
3541         else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected())
3542         {
3543             SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings();
3544             Point aRelPos = rSh.GetRelativePagePosition(aDocPt);
3545             if(aRelPos.X() >= 0)
3546             {
3547                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
3548                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
3549                 const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos );
3550                 rBnd.SetState( aTmp1 );
3551             }
3552             else
3553             {
3554                 rBnd.Invalidate(SID_ATTR_POSITION);
3555             }
3556             rBnd.Invalidate(SID_ATTR_SIZE);
3557             const SfxStringItem aCell( SID_TABLE_CELL, aEmptyStr );
3558             rBnd.SetState( aCell );
3559         }
3560     }
3561 
3562     sal_uInt8 nMouseTabCol;
3563     if( !bIsDocReadOnly && bInsWin && !pApplyTempl && !rSh.IsInSelect() )
3564     {
3565         if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
3566              !rSh.IsObjSelectable( aDocPt ) )
3567         {
3568             sal_uInt16 nPointer = USHRT_MAX;
3569             bool bChkTblSel = false;
3570 
3571             switch ( nMouseTabCol )
3572             {
3573                 case SW_TABCOL_VERT :
3574                 case SW_TABROW_HORI :
3575                     nPointer = POINTER_VSIZEBAR;
3576                     bChkTblSel = true;
3577                     break;
3578                 case SW_TABROW_VERT :
3579                 case SW_TABCOL_HORI :
3580                     nPointer = POINTER_HSIZEBAR;
3581                     bChkTblSel = true;
3582                     break;
3583                 // --> FME 2004-07-30 #i20126# Enhanced table selection
3584                 case SW_TABSEL_HORI :
3585                     nPointer = POINTER_TAB_SELECT_SE;
3586                     break;
3587                 case SW_TABSEL_HORI_RTL :
3588                 case SW_TABSEL_VERT :
3589                     nPointer = POINTER_TAB_SELECT_SW;
3590                     break;
3591                 case SW_TABCOLSEL_HORI :
3592                 case SW_TABROWSEL_VERT :
3593                     nPointer = POINTER_TAB_SELECT_S;
3594                     break;
3595                 case SW_TABROWSEL_HORI :
3596                     nPointer = POINTER_TAB_SELECT_E;
3597                     break;
3598                 case SW_TABROWSEL_HORI_RTL :
3599                 case SW_TABCOLSEL_VERT :
3600                     nPointer = POINTER_TAB_SELECT_W;
3601                     break;
3602                 // <--
3603             }
3604 
3605             if ( USHRT_MAX != nPointer &&
3606                 // --> FME 2004-10-20 #i35543#
3607                 // Enhanced table selection is explicitely allowed in table mode
3608                 ( !bChkTblSel || !rSh.IsTableMode() ) )
3609                 // <--
3610             {
3611                 SetPointer( nPointer );
3612             }
3613 
3614             return;
3615         }
3616         // #i23726#
3617         else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
3618         {
3619             // --> OD 2005-02-21 #i42921# - consider vertical mode
3620             SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
3621             const sal_uInt16 nPointer =
3622                     rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
3623                     ? POINTER_VSIZEBAR
3624                     : POINTER_HSIZEBAR;
3625             SetPointer( nPointer );
3626             // <--
3627 
3628             return;
3629         }
3630     }
3631 
3632     sal_Bool bDelShadCrsr = sal_True;
3633 
3634     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
3635     {
3636         case MOUSE_LEFT:
3637             if( pAnchorMarker )
3638             {
3639                 // Now we need to refresh the SdrHdl pointer of pAnchorMarker.
3640                 // This looks a little bit tricky, but it solves the following
3641                 // problem: the pAnchorMarker contains a pointer to an SdrHdl,
3642                 // if the FindAnchorPos-call cause a scrolling of the visible
3643                 // area, it's possible that the SdrHdl will be destroyed and a
3644                 // new one will initialized at the original position(GetHdlPos).
3645                 // So the pAnchorMarker has to find the right SdrHdl, if it's
3646                 // the old one, it will find it with position aOld, if this one
3647                 // is destroyed, it will find a new one at position GetHdlPos().
3648                 // --> OD 2010-09-16 #i114522#
3649 //                const Point aOld = pAnchorMarker->GetPos();
3650                 const Point aOld = pAnchorMarker->GetPosForHitTest( *(rSh.GetOut()) );
3651                 // <--
3652                 Point aNew = rSh.FindAnchorPos( aDocPt );
3653                 SdrHdl* pHdl;
3654                 if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )||
3655                     0 !=(pHdl = pSdrView->PickHandle( pAnchorMarker->GetHdlPos()) ) ) &&
3656                         ( pHdl->GetKind() == HDL_ANCHOR ||
3657                           pHdl->GetKind() == HDL_ANCHOR_TR ) )
3658                 {
3659                     pAnchorMarker->ChgHdl( pHdl );
3660                     if( aNew.X() || aNew.Y() )
3661                     {
3662                         pAnchorMarker->SetPos( aNew );
3663                         pAnchorMarker->SetLastPos( aDocPt );
3664                         //OLMpSdrView->RefreshAllIAOManagers();
3665                     }
3666                 }
3667                 else
3668                 {
3669                     delete pAnchorMarker;
3670                     pAnchorMarker = NULL;
3671                 }
3672             }
3673             if ( bInsDraw )
3674             {
3675                 if ( !bMBPressed )
3676                     break;
3677                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
3678                 {
3679                     if ( !bInsWin )
3680                         LeaveArea( aDocPt );
3681                     else
3682                         EnterArea();
3683                     if ( rView.GetDrawFuncPtr() )
3684                     {
3685                         pSdrView->SetOrtho(sal_False);
3686                         rView.GetDrawFuncPtr()->MouseMove( rMEvt );
3687                     }
3688                     bIsInMove = sal_True;
3689                 }
3690                 return;
3691             }
3692         case MOUSE_LEFT + KEY_SHIFT:
3693         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
3694             if ( !bMBPressed )
3695                 break;
3696         case MOUSE_LEFT + KEY_MOD1:
3697             if ( bFrmDrag && rSh.IsSelFrmMode() )
3698             {
3699                 if( !bMBPressed )
3700                     break;
3701 
3702                 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) )
3703                 {
3704                     // Event-Verarbeitung fuers Resizen
3705                     if( pSdrView->AreObjectsMarked() )
3706                     {
3707                         const SwFrmFmt* pFlyFmt;
3708                         const SvxMacro* pMacro;
3709 
3710                         const Point aSttPt( PixelToLogic( aStartPos ) );
3711 
3712                         // geht es los?
3713                         if( HDL_USER == eSdrMoveHdl )
3714                         {
3715                             SdrHdl* pHdl = pSdrView->PickHandle( aSttPt );
3716                             eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE;
3717                         }
3718 
3719                         sal_uInt16 nEvent = HDL_MOVE == eSdrMoveHdl
3720                                             ? SW_EVENT_FRM_MOVE
3721                                             : SW_EVENT_FRM_RESIZE;
3722 
3723                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
3724                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
3725                             Get( nEvent )) &&
3726 // oder nur z.B. alle 20 Twip bescheid sagen?
3727 //                          ( 20 > Abs( aRszMvHdlPt.X() - aDocPt.X() ) ||
3728 //                            20 > Abs( aRszMvHdlPt.Y() - aDocPt.Y() ) )
3729                             aRszMvHdlPt != aDocPt )
3730                         {
3731                             aRszMvHdlPt = aDocPt;
3732                             sal_uInt16 nPos = 0;
3733                             String sRet;
3734                             SbxArrayRef xArgs = new SbxArray;
3735                             SbxVariableRef xVar = new SbxVariable;
3736                             xVar->PutString( pFlyFmt->GetName() );
3737                             xArgs->Put( &xVar, ++nPos );
3738 
3739                             if( SW_EVENT_FRM_RESIZE == nEvent )
3740                             {
3741                                 xVar = new SbxVariable;
3742                                 xVar->PutUShort( static_cast< sal_uInt16 >(eSdrMoveHdl) );
3743                                 xArgs->Put( &xVar, ++nPos );
3744                             }
3745 
3746                             xVar = new SbxVariable;
3747                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
3748                             xArgs->Put( &xVar, ++nPos );
3749                             xVar = new SbxVariable;
3750                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
3751                             xArgs->Put( &xVar, ++nPos );
3752 
3753                             ReleaseMouse();
3754 
3755                             rSh.ExecMacro( *pMacro, &sRet, &xArgs );
3756 
3757                             CaptureMouse();
3758 
3759                             if( sRet.Len() && 0 != sRet.ToInt32() )
3760                                 return ;
3761                         }
3762                     }
3763                     // Event-Verarbeitung fuers Resizen
3764 
3765                     if( bIsDocReadOnly )
3766                         break;
3767 
3768                     if ( rMEvt.IsShift() )
3769                     {
3770                         pSdrView->SetOrtho(sal_True);
3771                         pSdrView->SetAngleSnapEnabled(sal_True);
3772                     }
3773                     else
3774                     {
3775                         pSdrView->SetOrtho(sal_False);
3776                         pSdrView->SetAngleSnapEnabled(sal_False);
3777                     }
3778 
3779                     (rSh.*rSh.fnDrag)( &aDocPt, rMEvt.IsShift() );
3780                     bIsInMove = sal_True;
3781                 }
3782                 else if( bIsDocReadOnly )
3783                     break;
3784 
3785                 if ( !bInsWin )
3786                 {
3787                     Point aTmp( aDocPt );
3788                     aTmp += rSh.VisArea().Pos() - aOldPt;
3789                     LeaveArea( aTmp );
3790                 }
3791                 else if(bIsInMove)
3792                     EnterArea();
3793                 return;
3794             }
3795             if ( !rSh.IsSelFrmMode() && !bDDINetAttr &&
3796                 (IsMinMove( aStartPos,aPixPt ) || bIsInMove) &&
3797                 (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) )
3798             {
3799                 if ( pSdrView )
3800                 {
3801                     if ( rMEvt.IsShift() )
3802                         pSdrView->SetOrtho(sal_True);
3803                     else
3804                         pSdrView->SetOrtho(sal_False);
3805                 }
3806                 if ( !bInsWin )
3807                 {
3808                     Point aTmp( aDocPt );
3809                     aTmp += rSh.VisArea().Pos() - aOldPt;
3810                     LeaveArea( aTmp );
3811                 }
3812                 else
3813                 {
3814                     //JP 24.09.98: Fix fuer die Bugs 55592 / 55931
3815                     //JP 23.04.99: Fix fuer den Bugs 65289
3816                     //JP 06.07.99: Fix fuer den Bugs 67360
3817                     if( !rMEvt.IsSynthetic() &&
3818                             !(( MOUSE_LEFT + KEY_MOD1 ==
3819                             rMEvt.GetModifier() + rMEvt.GetButtons() ) &&
3820                             rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() ))
3821                     {
3822                         (rSh.*rSh.fnDrag)( &aDocPt,sal_False );
3823 
3824                         bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,sal_False));
3825                         EnterArea();
3826                     }
3827                 }
3828             }
3829             bDDINetAttr = sal_False;
3830             break;
3831         case 0:
3832         {
3833             if ( pApplyTempl )
3834                         {
3835                 UpdatePointer(aDocPt, 0); // evtl. muss hier ein Rahmen markiert werden
3836                                 break;
3837                         }
3838             //#i6193#, change ui if mouse is over SwPostItField
3839             // TODO: do the same thing for redlines SW_REDLINE
3840             SwRect aFldRect;
3841             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
3842             if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False, &aFldRect ) )
3843             {
3844                 const SwField* pFld = aCntntAtPos.aFnd.pFld;
3845                 if (pFld->Which()== RES_POSTITFLD)
3846                 {
3847                     rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false);
3848                 }
3849                 else
3850                     rView.GetPostItMgr()->SetShadowState(0,false);
3851             }
3852             else
3853                 rView.GetPostItMgr()->SetShadowState(0,false);
3854                 // no break;
3855         }
3856         case KEY_SHIFT:
3857         case KEY_MOD2:
3858         case KEY_MOD1:
3859             if ( !bInsDraw )
3860             {
3861                 sal_Bool bTstShdwCrsr = sal_True;
3862 
3863                 UpdatePointer( aDocPt, rMEvt.GetModifier() );
3864 
3865                 const SwFrmFmt* pFmt = 0;
3866                 const SwFmtINetFmt* pINet = 0;
3867                 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
3868                 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) )
3869                     pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr;
3870 
3871                 const void* pTmp = pINet;
3872 
3873                 if( pINet ||
3874                     0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt )))
3875                 {
3876                     bTstShdwCrsr = sal_False;
3877                     if( pTmp == pINet )
3878                         aSaveCallEvent.Set( pINet );
3879                     else
3880                     {
3881                         IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt );
3882                         if( pIMapObj )
3883                             aSaveCallEvent.Set( pFmt, pIMapObj );
3884                         else
3885                             aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt );
3886                     }
3887 
3888                     // sollte wir ueber einem InternetFeld mit einem
3889                     // gebundenen Macro stehen?
3890                     if( aSaveCallEvent != aLastCallEvent )
3891                     {
3892                         if( aLastCallEvent.HasEvent() )
3893                             rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
3894                                             aLastCallEvent, sal_True );
3895                         // 0 besagt, das das Object gar keine Tabelle hat
3896                         if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT,
3897                                         aSaveCallEvent ))
3898                             aSaveCallEvent.Clear();
3899                     }
3900                 }
3901                 else if( aLastCallEvent.HasEvent() )
3902                 {
3903                     // Cursor stand auf einem Object
3904                     rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT,
3905                                     aLastCallEvent, sal_True );
3906                 }
3907 
3908                 if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly &&
3909                     !bInsFrm &&
3910                     !rSh.GetViewOptions()->getBrowseMode() &&
3911                     rSh.GetViewOptions()->IsShadowCursor() &&
3912                     !(rMEvt.GetModifier() + rMEvt.GetButtons()) &&
3913                     !rSh.HasSelection() && !GetConnectMetaFile() )
3914                 {
3915                     SwRect aRect;
3916                     sal_Int16 eOrient;
3917                     SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
3918                     if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient ))
3919                     {
3920                         if( !pShadCrsr )
3921                             pShadCrsr = new SwShadowCursor( *this,
3922                                 SwViewOption::GetDirectCursorColor() );
3923                         if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient )
3924                             eOrient = text::HoriOrientation::LEFT;
3925                         pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< sal_uInt16 >(eOrient) );
3926                         bDelShadCrsr = sal_False;
3927                     }
3928                 }
3929             }
3930             break;
3931         case MOUSE_LEFT + KEY_MOD2:
3932             if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() )
3933             {
3934                 (rSh.*rSh.fnDrag)( &aDocPt,sal_False );
3935                 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,sal_False));
3936                 EnterArea();
3937             }
3938         break;
3939     }
3940 
3941     if( bDelShadCrsr && pShadCrsr )
3942         delete pShadCrsr, pShadCrsr = 0;
3943     bWasShdwCrsr = sal_False;
3944 }
3945 
3946 /*--------------------------------------------------------------------
3947     Beschreibung:   Button Up
3948  --------------------------------------------------------------------*/
3949 
3950 
3951 void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
3952 {
3953     sal_Bool bCallBase = sal_True;
3954 
3955     sal_Bool bCallShadowCrsr = bWasShdwCrsr;
3956     bWasShdwCrsr = sal_False;
3957     if( pShadCrsr )
3958         delete pShadCrsr, pShadCrsr = 0;
3959 
3960     if( pRowColumnSelectionStart )
3961         DELETEZ( pRowColumnSelectionStart );
3962 
3963     SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl;
3964     eSdrMoveHdl = HDL_USER;     // fuer die MoveEvents - wieder zuruecksetzen
3965 
3966     // sicherheitshalber zuruecksetzen Bug 27900
3967     rView.SetTabColFromDoc( sal_False );
3968     rView.SetNumRuleNodeFromDoc(NULL);
3969 
3970     SwWrtShell &rSh = rView.GetWrtShell();
3971     SET_CURR_SHELL( &rSh );
3972     SdrView *pSdrView = rSh.GetDrawView();
3973     if ( pSdrView )
3974     {
3975         pSdrView->SetOrtho(sal_False);
3976 
3977         if ( pSdrView->MouseButtonUp( rMEvt,this ) )
3978         {
3979             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
3980             return; // Event von der SdrView ausgewertet
3981         }
3982     }
3983     //MouseButtonUp nur bearbeiten, wenn auch das Down an dieses Fenster ging.
3984     if ( !bMBPressed )
3985     {
3986 // OS 25.02.97 Undo fuer die Giesskann ist bereits im CommandHdl
3987 //JP 29.09.95: so sollte es sein!!!     if(pApplyTempl->bUndo)
3988 //      if( pApplyTempl && MOUSE_RIGHT == rMEvt.GetModifier() + rMEvt.GetButtons() )
3989 //          rSh.Do( SwWrtShell::UNDO );
3990         return;
3991     }
3992 
3993     Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) );
3994 
3995     if ( bDDTimerStarted )
3996     {
3997         StopDDTimer( &rSh, aDocPt );
3998         bMBPressed = sal_False;
3999         if ( rSh.IsSelFrmMode() )
4000         {
4001             (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False );
4002             bFrmDrag = sal_False;
4003         }
4004         bNoInterrupt = sal_False;
4005         ReleaseMouse();
4006         return;
4007     }
4008 
4009     if( pAnchorMarker )
4010     {
4011         Point aPnt( pAnchorMarker->GetLastPos() );
4012         //OLMpSdrView->RefreshAllIAOManagers();
4013         DELETEZ( pAnchorMarker );
4014         if( aPnt.X() || aPnt.Y() )
4015             rSh.FindAnchorPos( aPnt, sal_True );
4016     }
4017     if ( bInsDraw && rView.GetDrawFuncPtr() )
4018     {
4019         if ( rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) )
4020         {
4021             if (rView.GetDrawFuncPtr()) // Koennte im MouseButtonUp zerstoert worden sein
4022             {
4023                 rView.GetDrawFuncPtr()->Deactivate();
4024 
4025                 if (!rView.IsDrawMode())
4026                 {
4027                     rView.SetDrawFuncPtr(NULL);
4028                     SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
4029                     rBind.Invalidate( SID_ATTR_SIZE );
4030                     rBind.Invalidate( SID_TABLE_CELL );
4031                 }
4032             }
4033 
4034             if ( rSh.IsObjSelected() )
4035             {
4036                 rSh.EnterSelFrmMode();
4037                 if (!rView.GetDrawFuncPtr())
4038                     StdDrawMode( OBJ_NONE, sal_True );
4039             }
4040             else if ( rSh.IsFrmSelected() )
4041             {
4042                 rSh.EnterSelFrmMode();
4043                 StopInsFrm();
4044             }
4045             else
4046             {
4047                 const Point aDocPos( PixelToLogic( aStartPos ) );
4048                 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False));
4049                 rSh.Edit();
4050             }
4051 
4052             rView.AttrChangedNotify( &rSh );
4053         }
4054         else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate())
4055             rView.GetDrawFuncPtr()->BreakCreate();   // Zeichnen abbrechen
4056 
4057         bNoInterrupt = sal_False;
4058         ReleaseMouse();
4059         return;
4060     }
4061     sal_Bool bPopMode = sal_False;
4062     switch ( rMEvt.GetModifier() + rMEvt.GetButtons() )
4063     {
4064         case MOUSE_LEFT:
4065             if ( bInsDraw && rSh.IsDrawCreate() )
4066             {
4067                 if ( rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == sal_True )
4068                 {
4069                     rView.GetDrawFuncPtr()->Deactivate();
4070                     rView.AttrChangedNotify( &rSh );
4071                     if ( rSh.IsObjSelected() )
4072                         rSh.EnterSelFrmMode();
4073                     if ( rView.GetDrawFuncPtr() && bInsFrm )
4074                         StopInsFrm();
4075                 }
4076                 bCallBase = sal_False;
4077                 break;
4078             }
4079         case MOUSE_LEFT + KEY_MOD1:
4080         case MOUSE_LEFT + KEY_MOD2:
4081         case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
4082             if ( bFrmDrag && rSh.IsSelFrmMode() )
4083             {
4084                 if ( rMEvt.IsMod1() ) //Kopieren und nicht moven.
4085                 {
4086                     //Drag abbrechen, statt dessen internes Copy verwenden
4087                     Rectangle aRect;
4088                     rSh.GetDrawView()->TakeActionRect( aRect );
4089                     if (!aRect.IsEmpty())
4090                     {
4091                         rSh.BreakDrag();
4092                         Point aEndPt, aSttPt;
4093                         if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT )
4094                         {
4095                             aEndPt = aRect.TopLeft();
4096                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft();
4097                         }
4098                         else
4099                         {
4100                             aEndPt = aRect.Center();
4101                             aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center();
4102                         }
4103                         if ( aSttPt != aEndPt )
4104                         {
4105                             rSh.StartUndo( UNDO_UI_DRAG_AND_COPY );
4106                             rSh.Copy(&rSh, aSttPt, aEndPt, sal_False);
4107                             rSh.EndUndo( UNDO_UI_DRAG_AND_COPY );
4108                         }
4109                     }
4110                     else
4111                         (rSh.*rSh.fnEndDrag)( &aDocPt,sal_False );
4112                 }
4113                 else
4114                 {
4115                     {
4116                         const SwFrmFmt* pFlyFmt;
4117                         const SvxMacro* pMacro;
4118 
4119                         sal_uInt16 nEvent = HDL_MOVE == eOldSdrMoveHdl
4120                                             ? SW_EVENT_FRM_MOVE
4121                                             : SW_EVENT_FRM_RESIZE;
4122 
4123                         if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) &&
4124                             0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable().
4125                             Get( nEvent )) )
4126                         {
4127                             const Point aSttPt( PixelToLogic( aStartPos ) );
4128                             aRszMvHdlPt = aDocPt;
4129                             sal_uInt16 nPos = 0;
4130                             SbxArrayRef xArgs = new SbxArray;
4131                             SbxVariableRef xVar = new SbxVariable;
4132                             xVar->PutString( pFlyFmt->GetName() );
4133                             xArgs->Put( &xVar, ++nPos );
4134 
4135                             if( SW_EVENT_FRM_RESIZE == nEvent )
4136                             {
4137                                 xVar = new SbxVariable;
4138                                 xVar->PutUShort( static_cast< sal_uInt16 >(eOldSdrMoveHdl) );
4139                                 xArgs->Put( &xVar, ++nPos );
4140                             }
4141 
4142                             xVar = new SbxVariable;
4143                             xVar->PutLong( aDocPt.X() - aSttPt.X() );
4144                             xArgs->Put( &xVar, ++nPos );
4145                             xVar = new SbxVariable;
4146                             xVar->PutLong( aDocPt.Y() - aSttPt.Y() );
4147                             xArgs->Put( &xVar, ++nPos );
4148 
4149                             xVar = new SbxVariable;
4150                             xVar->PutUShort( 1 );
4151                             xArgs->Put( &xVar, ++nPos );
4152 
4153                             ReleaseMouse();
4154 
4155                             rSh.ExecMacro( *pMacro, 0, &xArgs );
4156 
4157                             CaptureMouse();
4158                         }
4159                     }
4160                     (rSh.*rSh.fnEndDrag)( &aDocPt,sal_False );
4161                 }
4162                 bFrmDrag = sal_False;
4163                 bCallBase = sal_False;
4164                 break;
4165             }
4166             bPopMode = sal_True;
4167             // no break
4168         case MOUSE_LEFT + KEY_SHIFT:
4169             if (rSh.IsSelFrmMode())
4170             {
4171 
4172                 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False );
4173                 bFrmDrag = sal_False;
4174                 bCallBase = sal_False;
4175                 break;
4176             }
4177 
4178             if( bHoldSelection )
4179             {
4180                 //JP 27.04.99: Bug 65389 - das EndDrag sollte auf jedenfall
4181                 //              gerufen werden.
4182                 bHoldSelection = sal_False;
4183                 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False );
4184             }
4185             else
4186             {
4187                 if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) )
4188                 {
4189                     const sal_Bool bTmpNoInterrupt = bNoInterrupt;
4190                     bNoInterrupt = sal_False;
4191                     {   // nur temp. Move-Kontext aufspannen, da sonst die
4192                         // Abfrage auf die Inhaltsform nicht funktioniert!!!
4193                         MV_KONTEXT( &rSh );
4194                         const Point aDocPos( PixelToLogic( aStartPos ) );
4195                         bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False));
4196                     }
4197                     bNoInterrupt = bTmpNoInterrupt;
4198 
4199                 }
4200                 else
4201                 {
4202                     sal_Bool bInSel = rSh.IsInSelect();
4203                     (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False );
4204 
4205                     // Internetfield? --> Link-Callen (DocLaden!!)
4206 //JP 18.10.96: Bug 32437 -
4207 //                  if( !rSh.HasSelection() )
4208                     if( !bInSel )
4209                     {
4210                         sal_uInt16 nFilter = URLLOAD_NOFILTER;
4211                         if( KEY_MOD1 == rMEvt.GetModifier() )
4212                             nFilter |= URLLOAD_NEWVIEW;
4213 
4214                         sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly();
4215                         if ( !bExecHyperlinks )
4216                         {
4217                             SvtSecurityOptions aSecOpts;
4218                             const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
4219                             if ( (  bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) ||
4220                                  ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) )
4221                                 bExecHyperlinks = sal_True;
4222                         }
4223 
4224                         const sal_Bool bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1;
4225 
4226                         if(pApplyTempl)
4227                             bExecHyperlinks = sal_False;
4228 
4229                         SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD |
4230                                                     SwContentAtPos::SW_INETATTR |
4231                                                     SwContentAtPos::SW_SMARTTAG  | SwContentAtPos::SW_FORMCTRL);
4232 
4233                         if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) )
4234                         {
4235                             sal_Bool bViewLocked = rSh.IsViewLocked();
4236                             if( !bViewLocked && !rSh.IsReadOnlyAvailable() &&
4237                                 aCntntAtPos.IsInProtectSect() )
4238                                 rSh.LockView( sal_True );
4239 
4240                             ReleaseMouse();
4241 
4242                             if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos )
4243                             {
4244                                 rSh.ClickToField( *aCntntAtPos.aFnd.pFld );
4245                             }
4246                             else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos )
4247                             {
4248                                     // execute smarttag menu
4249                                     if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() )
4250                                         rView.ExecSmartTagPopup( aDocPt );
4251                             }
4252                             else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos )
4253                             {
4254                                 ASSERT( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???");
4255                                 if ( aCntntAtPos.aFnd.pFldmark != NULL)
4256                                 {
4257                                     IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark );
4258                                     //SwDocShell* pDocSh = rView.GetDocShell();
4259                                     //SwDoc *pDoc=pDocSh->GetDoc();
4260                                     if (fieldBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) )
4261                                     {
4262                                         ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM);
4263                                         pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked());
4264                                         pCheckboxFm->Invalidate();
4265                                         rSh.InvalidateWindows( rView.GetVisArea() );
4266                                     } else if (fieldBM->GetFieldname().equalsAscii( ODF_FORMDROPDOWN) ) {
4267                                         rView.ExecFieldPopup( aDocPt, fieldBM );
4268                                         fieldBM->Invalidate();
4269                                         rSh.InvalidateWindows( rView.GetVisArea() );
4270                                     } else {
4271                                         // unknown type..
4272                                     }
4273                                 }
4274                             }
4275                             else // if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos )
4276                             {
4277                                 if ( bExecHyperlinks )
4278                                     rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter );
4279                             }
4280 
4281                             rSh.LockView( bViewLocked );
4282                             bCallShadowCrsr = sal_False;
4283                         }
4284                         else
4285                         {
4286                             aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN );
4287                             if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) && bExecHyperlinks )
4288                             {
4289                                 SdrViewEvent aVEvt;
4290 
4291                                 if (pSdrView)
4292                                     pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
4293 
4294                                 if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL)
4295                                 {
4296                                     // URL-Feld getroffen
4297                                     const SvxURLField *pField = aVEvt.pURLField;
4298                                     if (pField)
4299                                     {
4300                                         String sURL(pField->GetURL());
4301                                         String sTarget(pField->GetTargetFrame());
4302                                         ::LoadURL( sURL, &rSh, nFilter, &sTarget);
4303                                     }
4304                                     bCallShadowCrsr = sal_False;
4305                                 }
4306                                 else
4307                                 {
4308                                     // Grafik getroffen
4309                                     ReleaseMouse();
4310                                     if( rSh.ClickToINetGrf( aDocPt, nFilter ))
4311                                         bCallShadowCrsr = sal_False;
4312                                 }
4313                             }
4314                         }
4315 
4316                         if( bCallShadowCrsr &&
4317                             rSh.GetViewOptions()->IsShadowCursor() &&
4318                             MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) &&
4319                             !rSh.HasSelection() &&
4320                             !GetConnectMetaFile() &&
4321                             rSh.VisArea().IsInside( aDocPt ))
4322                         {
4323                             SwUndoId nLastUndoId(UNDO_EMPTY);
4324                             if (rSh.GetLastUndoInfo(0, & nLastUndoId))
4325                             {
4326                                 if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId)
4327                                 {
4328                                     rSh.Undo();
4329                                 }
4330                             }
4331                             SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode();
4332                             rSh.SetShadowCrsrPos( aDocPt, eMode );
4333                         }
4334                     }
4335                 }
4336                 bCallBase = sal_False;
4337 
4338             }
4339 
4340             // gfs. im Down gepushten Mode wieder zuruecksetzen
4341             if ( bPopMode && bModePushed )
4342             {
4343                 rSh.PopMode();
4344                 bModePushed = sal_False;
4345                 bCallBase = sal_False;
4346             }
4347             break;
4348 
4349         default:
4350             ReleaseMouse();
4351             return;
4352     }
4353 
4354     if( pApplyTempl )
4355     {
4356         int eSelection = rSh.GetSelectionType();
4357         SwFormatClipboard* pFormatClipboard = pApplyTempl->pFormatClipboard;
4358         if( pFormatClipboard )//apply format paintbrush
4359         {
4360             //get some parameters
4361             SwWrtShell& rWrtShell = rView.GetWrtShell();
4362             SfxStyleSheetBasePool* pPool=0;
4363             bool bNoCharacterFormats = false;
4364             bool bNoParagraphFormats = false;
4365             {
4366                 SwDocShell* pDocSh = rView.GetDocShell();
4367                 if(pDocSh)
4368                     pPool = pDocSh->GetStyleSheetPool();
4369                 if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
4370                     bNoCharacterFormats = true;
4371                 else if( rMEvt.GetModifier() & KEY_MOD1 )
4372                     bNoParagraphFormats = true;
4373             }
4374             //execute paste
4375             pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats );
4376 
4377             //if the clipboard is empty after paste remove the ApplyTemplate
4378             if(!pFormatClipboard->HasContent())
4379                 SetApplyTemplate(SwApplyTemplate());
4380         }
4381         else if( pApplyTempl->nColor )
4382         {
4383             sal_uInt16 nId = 0;
4384             switch( pApplyTempl->nColor )
4385             {
4386                 case SID_ATTR_CHAR_COLOR_EXT:
4387                     nId = RES_CHRATR_COLOR;
4388                 break;
4389                 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
4390                     nId = RES_CHRATR_BACKGROUND;
4391                 break;
4392             }
4393             if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection)
4394             {
4395                 if( rSh.IsSelection() && !rSh.HasReadonlySel() )
4396                 {
4397                     if(nId == RES_CHRATR_BACKGROUND)
4398                     {
4399                         Color aColor( COL_TRANSPARENT  );
4400                         if( !SwEditWin::bTransparentBackColor )
4401                             aColor = SwEditWin::aTextBackColor;
4402                         rSh.SetAttr( SvxBrushItem( aColor, nId ) );
4403                     }
4404                     else
4405                         rSh.SetAttr( SvxColorItem(SwEditWin::aTextColor, nId) );
4406                     rSh.UnSetVisCrsr();
4407                     rSh.EnterStdMode();
4408                     rSh.SetVisCrsr(aDocPt);
4409 
4410                     pApplyTempl->bUndo = sal_True;
4411                     bCallBase = sal_False;
4412                     aTemplateTimer.Stop();
4413                 }
4414                 else if(rMEvt.GetClicks() == 1)
4415                 {
4416                     // keine Selektion -> also Giesskanne abschalten
4417                     aTemplateTimer.Start();
4418                 }
4419             }
4420         }
4421         else
4422         {
4423             String aStyleName;
4424             switch ( pApplyTempl->eType )
4425             {
4426                 case SFX_STYLE_FAMILY_PARA:
4427                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
4428                          & eSelection ) && !rSh.HasReadonlySel() )
4429                     {
4430                         rSh.SetTxtFmtColl( pApplyTempl->aColl.pTxtColl );
4431                         pApplyTempl->bUndo = sal_True;
4432                         bCallBase = sal_False;
4433                         if ( pApplyTempl->aColl.pTxtColl )
4434                             aStyleName = pApplyTempl->aColl.pTxtColl->GetName();
4435                     }
4436                     break;
4437                 case SFX_STYLE_FAMILY_CHAR:
4438                     if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL )
4439                          & eSelection ) && !rSh.HasReadonlySel() )
4440                     {
4441                         rSh.SetAttr( SwFmtCharFmt(pApplyTempl->aColl.pCharFmt) );
4442                         rSh.UnSetVisCrsr();
4443                         rSh.EnterStdMode();
4444                         rSh.SetVisCrsr(aDocPt);
4445                         pApplyTempl->bUndo = sal_True;
4446                         bCallBase = sal_False;
4447                         if ( pApplyTempl->aColl.pCharFmt )
4448                             aStyleName = pApplyTempl->aColl.pCharFmt->GetName();
4449                     }
4450                     break;
4451                 case SFX_STYLE_FAMILY_FRAME :
4452                 {
4453                     const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt );
4454                     if(PTR_CAST(SwFlyFrmFmt, pFmt))
4455                     {
4456                         rSh.SetFrmFmt( pApplyTempl->aColl.pFrmFmt, sal_False, &aDocPt );
4457                         pApplyTempl->bUndo = sal_True;
4458                         bCallBase = sal_False;
4459                         if( pApplyTempl->aColl.pFrmFmt )
4460                             aStyleName = pApplyTempl->aColl.pFrmFmt->GetName();
4461                     }
4462                     break;
4463                 }
4464                 case SFX_STYLE_FAMILY_PAGE:
4465                             // Kein Undo bei Seitenvorlagen
4466                     rSh.ChgCurPageDesc( *pApplyTempl->aColl.pPageDesc );
4467                     if ( pApplyTempl->aColl.pPageDesc )
4468                         aStyleName = pApplyTempl->aColl.pPageDesc->GetName();
4469                     bCallBase = sal_False;
4470                     break;
4471                 case SFX_STYLE_FAMILY_PSEUDO:
4472                     if( !rSh.HasReadonlySel() )
4473                     {
4474                         // --> OD 2008-03-17 #refactorlists#
4475                         rSh.SetCurNumRule( *pApplyTempl->aColl.pNumRule,
4476                                            false,
4477                                            pApplyTempl->aColl.pNumRule->GetDefaultListId() );
4478                         // <--
4479                         bCallBase = sal_False;
4480                         pApplyTempl->bUndo = sal_True;
4481                         if( pApplyTempl->aColl.pNumRule )
4482                             aStyleName = pApplyTempl->aColl.pNumRule->GetName();
4483                     }
4484                     break;
4485             }
4486 
4487             uno::Reference< frame::XDispatchRecorder > xRecorder =
4488                     rView.GetViewFrame()->GetBindings().GetRecorder();
4489             if ( aStyleName.Len() && xRecorder.is() )
4490             {
4491                 SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
4492                 if ( pSfxShell )
4493                 {
4494                     SfxRequest aReq( rView.GetViewFrame(), SID_STYLE_APPLY );
4495                     aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) );
4496                     aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (sal_uInt16) pApplyTempl->eType ) );
4497                     aReq.Done();
4498                 }
4499             }
4500         }
4501 
4502     }
4503     ReleaseMouse();
4504     // Hier kommen nur verarbeitete MouseEvents an; nur bei diesen duerfen
4505     // die Modi zurueckgesetzt werden.
4506     bMBPressed = sal_False;
4507 
4508     //sicherheitshalber aufrufen, da jetzt das Selektieren bestimmt zu Ende ist.
4509     //Andernfalls koennte der Timeout des Timers Kummer machen.
4510     EnterArea();
4511     bNoInterrupt = sal_False;
4512 
4513     if (bCallBase)
4514         Window::MouseButtonUp(rMEvt);
4515 }
4516 
4517 
4518 /*--------------------------------------------------------------------
4519     Beschreibung:   Vorlage anwenden
4520  --------------------------------------------------------------------*/
4521 
4522 
4523 void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl)
4524 {
4525     static sal_Bool bIdle = sal_False;
4526     DELETEZ(pApplyTempl);
4527     SwWrtShell &rSh = rView.GetWrtShell();
4528 
4529     if(rTempl.pFormatClipboard)
4530     {
4531         pApplyTempl = new SwApplyTemplate( rTempl );
4532               SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future
4533               rSh.NoEdit( sal_False );
4534               bIdle = rSh.GetViewOptions()->IsIdle();
4535               ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
4536     }
4537     else if(rTempl.nColor)
4538     {
4539         pApplyTempl = new SwApplyTemplate( rTempl );
4540         SetPointer( POINTER_FILL );
4541         rSh.NoEdit( sal_False );
4542         bIdle = rSh.GetViewOptions()->IsIdle();
4543         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
4544     }
4545     else if( rTempl.eType )
4546     {
4547         pApplyTempl = new SwApplyTemplate( rTempl );
4548         SetPointer( POINTER_FILL  );
4549         rSh.NoEdit( sal_False );
4550         bIdle = rSh.GetViewOptions()->IsIdle();
4551         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False );
4552     }
4553     else
4554     {
4555         SetPointer( POINTER_TEXT );
4556         rSh.UnSetVisCrsr();
4557 
4558         ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle );
4559         if ( !rSh.IsSelFrmMode() )
4560             rSh.Edit();
4561     }
4562 
4563     static sal_uInt16 __READONLY_DATA aInva[] =
4564     {
4565         SID_STYLE_WATERCAN,
4566         SID_ATTR_CHAR_COLOR_EXT,
4567         SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,
4568         0
4569     };
4570     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
4571 }
4572 
4573 /*--------------------------------------------------------------------
4574     Beschreibung:   ctor
4575  --------------------------------------------------------------------*/
4576 
4577 
4578 SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
4579     Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
4580     DropTargetHelper( this ),
4581     DragSourceHelper( this ),
4582 
4583     eBufferLanguage(LANGUAGE_DONTKNOW),
4584     pApplyTempl(0),
4585     pAnchorMarker( 0 ),
4586     pUserMarker( 0 ),
4587     pUserMarkerObj( 0 ),
4588     pShadCrsr( 0 ),
4589     pRowColumnSelectionStart( 0 ),
4590 
4591     rView( rMyView ),
4592 
4593     aActHitType(SDRHIT_NONE),
4594     m_nDropFormat( 0 ),
4595     m_nDropAction( 0 ),
4596     m_nDropDestination( 0 ),
4597 
4598     nInsFrmColCount( 1 ),
4599     eDrawMode(OBJ_NONE),
4600 
4601     bLockInput(sal_False),
4602     bObjectSelect( sal_False ),
4603     nKS_NUMDOWN_Count(0), // #i23725#
4604     nKS_NUMINDENTINC_Count(0) // #i23725#
4605 {
4606     SetHelpId(HID_EDIT_WIN);
4607     EnableChildTransparentMode();
4608     SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
4609 
4610     bLinkRemoved = bMBPressed = bInsDraw = bInsFrm =
4611     bIsInDrag = bOldIdle = bOldIdleSet = bChainMode = bWasShdwCrsr = sal_False;
4612     //#i42732# initially use the input language
4613     bUseInputLanguage = sal_True;
4614 
4615     SetMapMode(MapMode(MAP_TWIP));
4616 
4617     SetPointer( POINTER_TEXT );
4618     aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler));
4619 
4620     bTblInsDelMode = sal_False;
4621     aKeyInputTimer.SetTimeout( 3000 );
4622     aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler));
4623 
4624     aKeyInputFlushTimer.SetTimeout( 200 );
4625     aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler));
4626 
4627     // TemplatePointer fuer Farben soll nach Einfachclick
4628     // ohne Selektion zurueckgesetzt werden
4629     aTemplateTimer.SetTimeout(400);
4630     aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl));
4631 
4632     //JP 16.12.98: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
4633     //          den Font von der akt. einfuege Position setzen!
4634     if( !rMyView.GetDocShell()->IsReadOnly() )
4635     {
4636         Font aFont;
4637         SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
4638                                             INPUTCONTEXT_EXTTEXTINPUT ) );
4639     }
4640 }
4641 
4642 
4643 
4644 SwEditWin::~SwEditWin()
4645 {
4646     aKeyInputTimer.Stop();
4647     delete pShadCrsr;
4648     delete pRowColumnSelectionStart;
4649     if( pQuickHlpData->bClear && rView.GetWrtShellPtr() )
4650         pQuickHlpData->Stop( rView.GetWrtShell() );
4651     bExecuteDrag = sal_False;
4652     delete pApplyTempl;
4653     rView.SetDrawFuncPtr(NULL);
4654 
4655     if(pUserMarker)
4656     {
4657         delete pUserMarker;
4658     }
4659 
4660     delete pAnchorMarker;
4661 }
4662 
4663 
4664 /******************************************************************************
4665  *  Beschreibung: DrawTextEditMode einschalten
4666  ******************************************************************************/
4667 
4668 
4669 void SwEditWin::EnterDrawTextMode( const Point& aDocPos )
4670 {
4671     if ( rView.EnterDrawTextMode(aDocPos) == sal_True )
4672     {
4673         if (rView.GetDrawFuncPtr())
4674         {
4675             rView.GetDrawFuncPtr()->Deactivate();
4676             rView.SetDrawFuncPtr(NULL);
4677             rView.LeaveDrawCreate();
4678         }
4679         rView.NoRotate();
4680         rView.AttrChangedNotify( &rView.GetWrtShell() );
4681     }
4682 }
4683 
4684 /******************************************************************************
4685  *  Beschreibung: DrawMode einschalten
4686  ******************************************************************************/
4687 
4688 
4689 
4690 sal_Bool SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos)
4691 {
4692     SwWrtShell &rSh = rView.GetWrtShell();
4693     SdrView *pSdrView = rSh.GetDrawView();
4694 
4695 //  if ( GetDrawFuncPtr() && (aActHitType == SDRHIT_NONE || rSh.IsDrawCreate()) )
4696     if ( rView.GetDrawFuncPtr() )
4697     {
4698         if (rSh.IsDrawCreate())
4699             return sal_True;
4700 
4701         sal_Bool bRet = rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt );
4702         rView.AttrChangedNotify( &rSh );
4703         return bRet;
4704     }
4705 
4706     if ( pSdrView && pSdrView->IsTextEdit() )
4707     {
4708         sal_Bool bUnLockView = !rSh.IsViewLocked();
4709         rSh.LockView( sal_True );
4710 
4711         rSh.EndTextEdit(); // Danebengeklickt, Ende mit Edit
4712         rSh.SelectObj( aDocPos );
4713         if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() )
4714             rSh.LeaveSelFrmMode();
4715         else
4716         {
4717             SwEditWin::nDDStartPosY = aDocPos.Y();
4718             SwEditWin::nDDStartPosX = aDocPos.X();
4719             bFrmDrag = sal_True;
4720         }
4721         if( bUnLockView )
4722             rSh.LockView( sal_False );
4723         rView.AttrChangedNotify( &rSh );
4724         return sal_True;
4725     }
4726     return sal_False;
4727 }
4728 
4729 /******************************************************************************
4730  *  Beschreibung:
4731  ******************************************************************************/
4732 
4733 
4734 
4735 sal_Bool SwEditWin::IsDrawSelMode()
4736 {
4737 //  return (IsFrmAction() == sal_False && GetSdrDrawMode() == OBJ_NONE);
4738     return IsObjectSelect();
4739 }
4740 
4741 /******************************************************************************
4742  *  Beschreibung:
4743  ******************************************************************************/
4744 
4745 
4746 void SwEditWin::GetFocus()
4747 {
4748     if ( rView.GetPostItMgr()->HasActiveSidebarWin() )
4749     {
4750         rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin();
4751     }
4752 	else
4753 	{
4754 		rView.GotFocus();
4755 		Window::GetFocus();
4756 		rView.GetWrtShell().InvalidateAccessibleFocus();
4757 	}
4758 }
4759 
4760 /******************************************************************************
4761  *  Beschreibung:
4762  ******************************************************************************/
4763 
4764 
4765 
4766 void SwEditWin::LoseFocus()
4767 {
4768     rView.GetWrtShell().InvalidateAccessibleFocus();
4769     Window::LoseFocus();
4770     if( pQuickHlpData->bClear )
4771         pQuickHlpData->Stop( rView.GetWrtShell() );
4772     rView.LostFocus();
4773 }
4774 
4775 /******************************************************************************
4776  *  Beschreibung:
4777  ******************************************************************************/
4778 
4779 
4780 
4781 void SwEditWin::Command( const CommandEvent& rCEvt )
4782 {
4783     SwWrtShell &rSh = rView.GetWrtShell();
4784 
4785 	if ( !rView.GetViewFrame() )
4786 	{
4787 		//Wenn der ViewFrame in Kuerze stirbt kein Popup mehr!
4788 		Window::Command(rCEvt);
4789 		return;
4790 	}
4791 
4792     // The command event is send to the window after a possible context
4793     // menu from an inplace client has been closed. Now we have the chance
4794     // to deactivate the inplace client without any problem regarding parent
4795     // windows and code on the stack.
4796     // For more information, see #126086# and #128122#
4797     SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient();
4798     sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
4799     if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
4800     {
4801         rSh.FinishOLEObj();
4802         return;
4803     }
4804 
4805     sal_Bool bCallBase      = sal_True;
4806 
4807     switch ( rCEvt.GetCommand() )
4808     {
4809         case COMMAND_CONTEXTMENU:
4810         {
4811             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
4812             SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()->
4813                                                 GetChildWindow( nId );
4814 
4815             if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
4816                 return;
4817 
4818             if((!pChildWin || pChildWin->GetView() != &rView) &&
4819                 !rSh.IsDrawCreate() && !IsDrawAction())
4820             {
4821                 SET_CURR_SHELL( &rSh );
4822                 if (!pApplyTempl)
4823                 {
4824                     if (bNoInterrupt == sal_True)
4825                     {
4826                         ReleaseMouse();
4827                         bNoInterrupt = sal_False;
4828                         bMBPressed = sal_False;
4829                     }
4830                     Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) );
4831                     if ( !rCEvt.IsMouseEvent() )
4832                         aDocPos = rSh.GetCharRect().Center();
4833                     else
4834                     {
4835                         SelectMenuPosition(rSh, rCEvt.GetMousePosPixel());
4836                         rView.StopShellTimer();
4837 
4838                     }
4839                     const Point aPixPos = LogicToPixel( aDocPos );
4840 
4841                     if ( rView.GetDocShell()->IsReadOnly() )
4842                     {
4843                         SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, rView );
4844 
4845                         ui::ContextMenuExecuteEvent aEvent;
4846                         aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
4847                         aEvent.ExecutePosition.X = aPixPos.X();
4848                         aEvent.ExecutePosition.Y = aPixPos.Y();
4849                         Menu* pMenu = 0;
4850                         ::rtl::OUString sMenuName =
4851                             ::rtl::OUString::createFromAscii( "private:resource/ReadonlyContextMenu");
4852                         if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) )
4853                         {
4854                             if ( pMenu )
4855                             {
4856                                 sal_uInt16 nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos);
4857                                 if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *rView.GetViewFrame(), nExecId ))
4858                                     pROPopup->Execute(this, nExecId);
4859                             }
4860                             else
4861                                 pROPopup->Execute(this, aPixPos);
4862                         }
4863                         delete pROPopup;
4864                     }
4865                     else if ( !rView.ExecSpellPopup( aDocPos ) )
4866                         GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos);
4867                 }
4868                 else if (pApplyTempl->bUndo)
4869                     rSh.Do(SwWrtShell::UNDO);
4870                 bCallBase = sal_False;
4871             }
4872         }
4873         break;
4874 
4875         case COMMAND_WHEEL:
4876         case COMMAND_STARTAUTOSCROLL:
4877         case COMMAND_AUTOSCROLL:
4878             if( pShadCrsr )
4879                 delete pShadCrsr, pShadCrsr = 0;
4880             bCallBase = !rView.HandleWheelCommands( rCEvt );
4881             break;
4882 
4883         case COMMAND_VOICE:
4884             {
4885                 //ggf. an Outliner weiterleiten
4886                 if ( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
4887                 {
4888                     bCallBase = sal_False;
4889                     rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
4890                     break;
4891                 }
4892 
4893                 const CommandVoiceData *pCData = rCEvt.GetVoiceData();
4894                 if ( VOICECOMMANDTYPE_CONTROL == pCData->GetType() )
4895                     break;
4896 
4897 
4898                 sal_uInt16 nSlotId = 0;
4899                 SfxPoolItem *pItem = 0;
4900 
4901                 switch ( pCData->GetCommand() )
4902                 {
4903                     case DICTATIONCOMMAND_NEWPARAGRAPH: nSlotId = FN_INSERT_BREAK; break;
4904                     case DICTATIONCOMMAND_NEWLINE:      nSlotId = FN_INSERT_LINEBREAK; break;
4905                     case DICTATIONCOMMAND_LEFT:         nSlotId = FN_PREV_WORD; break;
4906                     case DICTATIONCOMMAND_RIGHT:        nSlotId = FN_NEXT_WORD; break;
4907                     case DICTATIONCOMMAND_UP:           nSlotId = FN_LINE_UP; break;
4908                     case DICTATIONCOMMAND_DOWN:         nSlotId = FN_LINE_DOWN; break;
4909                     case DICTATIONCOMMAND_UNDO:         nSlotId = SID_UNDO; break;
4910                     case DICTATIONCOMMAND_REPEAT:       nSlotId = SID_REPEAT; break;
4911                     case DICTATIONCOMMAND_DEL:          nSlotId = FN_DELETE_BACK_WORD; break;
4912 
4913                     case DICTATIONCOMMAND_BOLD_ON:      nSlotId = SID_ATTR_CHAR_WEIGHT;
4914                                                         pItem = new SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT );
4915                                                         break;
4916                     case DICTATIONCOMMAND_BOLD_OFF:     nSlotId = SID_ATTR_CHAR_WEIGHT;
4917                                                         pItem = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
4918                                                         break;
4919                     case DICTATIONCOMMAND_UNDERLINE_ON: nSlotId = SID_ATTR_CHAR_UNDERLINE;
4920                                                         pItem = new SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_WEIGHT );
4921                                                         break;
4922                     case DICTATIONCOMMAND_UNDERLINE_OFF:nSlotId = SID_ATTR_CHAR_UNDERLINE;
4923                                                         pItem = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE );
4924                                                         break;
4925                     case DICTATIONCOMMAND_ITALIC_ON:    nSlotId = SID_ATTR_CHAR_POSTURE;
4926                                                         pItem = new SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE );
4927                                                         break;
4928                     case DICTATIONCOMMAND_ITALIC_OFF:   nSlotId = SID_ATTR_CHAR_POSTURE;
4929                                                         pItem = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE );
4930                                                         break;
4931                     case DICTATIONCOMMAND_NUMBERING_ON:
4932                                     if ( !rSh.GetCurNumRule() )
4933                                         nSlotId = FN_NUM_NUMBERING_ON;
4934                                     break;
4935                     case DICTATIONCOMMAND_NUMBERING_OFF:
4936                                     if ( rSh.GetCurNumRule() )
4937                                        nSlotId = FN_NUM_NUMBERING_ON;
4938                                     break;
4939                     case DICTATIONCOMMAND_TAB:
4940                                     {
4941                                        rSh.Insert( '\t' );
4942                                     }
4943                                     break;
4944                     case DICTATIONCOMMAND_UNKNOWN:
4945                                     {
4946                                         rView.GetWrtShell().Insert( pCData->GetText() );
4947                                     }
4948                                     break;
4949 
4950 #ifdef DBG_UTIL
4951                     default:
4952                         ASSERT( !this, "unknown speech command." );
4953 #endif
4954                 }
4955                 if ( nSlotId )
4956                 {
4957                     bCallBase = sal_False;
4958                     if ( pItem )
4959                     {
4960                         const SfxPoolItem* aArgs[2];
4961                         aArgs[0] = pItem;
4962                         aArgs[1] = 0;
4963                         GetView().GetViewFrame()->GetBindings().Execute(
4964                                     nSlotId, aArgs, 0, SFX_CALLMODE_STANDARD );
4965                         delete pItem;
4966                     }
4967                     else
4968                         GetView().GetViewFrame()->GetBindings().Execute( nSlotId );
4969                 }
4970             }
4971             break;
4972 
4973     case COMMAND_STARTEXTTEXTINPUT:
4974     {
4975         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
4976                               rSh.IsCrsrReadonly();
4977         if(!bIsDocReadOnly)
4978         {
4979             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
4980             {
4981                 bCallBase = sal_False;
4982                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
4983             }
4984             else
4985             {
4986                 if( rSh.HasSelection() )
4987                     rSh.DelRight();
4988 
4989                 bCallBase = sal_False;
4990                 LanguageType eInputLanguage = GetInputLanguage();
4991                 rSh.CreateExtTextInput(eInputLanguage);
4992             }
4993         }
4994         break;
4995     }
4996     case COMMAND_ENDEXTTEXTINPUT:
4997     {
4998         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
4999                               rSh.IsCrsrReadonly();
5000         if(!bIsDocReadOnly)
5001         {
5002             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
5003             {
5004                 bCallBase = sal_False;
5005                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
5006             }
5007             else
5008             {
5009                 bCallBase = sal_False;
5010                 String sRecord = rSh.DeleteExtTextInput();
5011                 uno::Reference< frame::XDispatchRecorder > xRecorder =
5012                         rView.GetViewFrame()->GetBindings().GetRecorder();
5013 
5014                 if ( sRecord.Len() )
5015                 {
5016                     // #102812# convert quotes in IME text
5017                     // works on the last input character, this is escpecially in Korean text often done
5018                     // quotes that are inside of the string are not replaced!
5019                     const sal_Unicode aCh = sRecord.GetChar(sRecord.Len() - 1);
5020                     SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
5021                     SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
5022                     if(pACorr &&
5023                         (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))||
5024                         ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh))))
5025                     {
5026                         rSh.DelLeft();
5027                         rSh.AutoCorrect( *pACorr, aCh );
5028                     }
5029 
5030                     if ( xRecorder.is() )
5031                     {
5032                         //Shell ermitteln
5033                         SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) );
5034                         // Request generieren und recorden
5035                         if (pSfxShell)
5036                         {
5037                             SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING );
5038                             aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) );
5039                             aReq.Done();
5040                         }
5041                     }
5042                 }
5043             }
5044         }
5045     }
5046     break;
5047     case COMMAND_EXTTEXTINPUT:
5048     {
5049         sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
5050                               rSh.IsCrsrReadonly();
5051         if(!bIsDocReadOnly)
5052         {
5053             QuickHelpData aTmpQHD;
5054             if( pQuickHlpData->bClear )
5055             {
5056                 aTmpQHD.Move( *pQuickHlpData );
5057                 pQuickHlpData->Stop( rSh );
5058             }
5059             String sWord;
5060             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
5061             {
5062                 bCallBase = sal_False;
5063                 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
5064             }
5065             else
5066             {
5067                 const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
5068                 if( pData )
5069                 {
5070                     sWord = pData->GetText();
5071                     bCallBase = sal_False;
5072                     rSh.SetExtTextInputData( *pData );
5073                 }
5074             }
5075                 uno::Reference< frame::XDispatchRecorder > xRecorder =
5076                         rView.GetViewFrame()->GetBindings().GetRecorder();
5077                 if(!xRecorder.is())
5078                 {
5079                     SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
5080                     SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
5081                     if( pACfg && pACorr &&
5082                         ( pACfg->IsAutoTextTip() ||
5083                           pACorr->GetSwFlags().bAutoCompleteWords ) &&
5084                         rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
5085                     {
5086                         ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr, sal_True);
5087                     }
5088                 }
5089         }
5090     }
5091     break;
5092     case COMMAND_CURSORPOS:
5093         // will be handled by the base class
5094         break;
5095 
5096     case COMMAND_PASTESELECTION:
5097         if( !rView.GetDocShell()->IsReadOnly() )
5098         {
5099             TransferableDataHelper aDataHelper(
5100                         TransferableDataHelper::CreateFromSelection( this ));
5101             if( !aDataHelper.GetXTransferable().is() )
5102                 break;
5103 
5104             sal_uLong nDropFormat;
5105             sal_uInt16 nEventAction, nDropAction, nDropDestination;
5106             nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() );
5107             if( !nDropDestination )
5108                 break;
5109 
5110             nDropAction = SotExchange::GetExchangeAction(
5111                                 aDataHelper.GetDataFlavorExVector(),
5112                                 nDropDestination, EXCHG_IN_ACTION_COPY,
5113                                 EXCHG_IN_ACTION_COPY, nDropFormat,
5114                                 nEventAction );
5115             if( EXCHG_INOUT_ACTION_NONE != nDropAction )
5116             {
5117                 const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) );
5118                 SwTransferable::PasteData( aDataHelper, rSh, nDropAction,
5119                                     nDropFormat, nDropDestination, sal_False,
5120                                     sal_False, &aDocPt, EXCHG_IN_ACTION_COPY,
5121                                     sal_True );
5122             }
5123         }
5124         break;
5125         case COMMAND_MODKEYCHANGE :
5126         {
5127             const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData();
5128             if(pCommandData->IsMod1() && !pCommandData->IsMod2())
5129             {
5130                 sal_uInt16 nSlot = 0;
5131                 if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift())
5132                     nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT;
5133                 else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift())
5134                     nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT;
5135                 if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
5136                     GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
5137             }
5138         }
5139         break;
5140         case COMMAND_HANGUL_HANJA_CONVERSION :
5141             GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION);
5142         break;
5143         case COMMAND_INPUTLANGUAGECHANGE :
5144             //#i42732# update state of fontname if input language changes
5145             bInputLanguageSwitched = true;
5146             SetUseInputLanguage( sal_True );
5147         break;
5148         case COMMAND_SELECTIONCHANGE:
5149         {
5150             const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
5151             rSh.SttCrsrMove();
5152             rSh.GoStartSentence();
5153             rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetStart());
5154             rSh.SetMark();
5155             rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetEnd() - pData->GetStart());
5156             rSh.EndCrsrMove( sal_True );
5157         }
5158         break;
5159         case COMMAND_PREPARERECONVERSION:
5160         if( rSh.HasSelection() )
5161         {
5162             SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr();
5163 
5164             if( rSh.IsMultiSelection() )
5165             {
5166                 if( pCrsr && !pCrsr->HasMark() &&
5167                 pCrsr->GetPoint() == pCrsr->GetMark() )
5168                 {
5169                 rSh.GoPrevCrsr();
5170                 pCrsr = (SwPaM*)rSh.GetCrsr();
5171                 }
5172 
5173                 // Cancel all selections other than the last selected one.
5174                 while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() )
5175                 delete rSh.GetCrsr()->GetNext();
5176             }
5177 
5178             if( pCrsr )
5179             {
5180                 sal_uLong nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex();
5181                 xub_StrLen nPosIdx = pCrsr->GetPoint()->nContent.GetIndex();
5182                 sal_uLong nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex();
5183                 xub_StrLen nMarkIdx = pCrsr->GetMark()->nContent.GetIndex();
5184 
5185                 if( !rSh.GetCrsr()->HasMark() )
5186                 rSh.GetCrsr()->SetMark();
5187 
5188                 rSh.SttCrsrMove();
5189 
5190                 if( nPosNodeIdx < nMarkNodeIdx )
5191                 {
5192                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
5193                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
5194                 rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx;
5195                 rSh.GetCrsr()->GetMark()->nContent =
5196                     rSh.GetCrsr()->GetCntntNode( sal_True )->Len();
5197                 }
5198                 else if( nPosNodeIdx == nMarkNodeIdx )
5199                 {
5200                 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx;
5201                 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx;
5202                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
5203                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
5204                 }
5205                 else
5206                 {
5207                 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx;
5208                 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx;
5209                 rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx;
5210                 rSh.GetCrsr()->GetPoint()->nContent =
5211                     rSh.GetCrsr()->GetCntntNode( sal_False )->Len();
5212                 }
5213 
5214                 rSh.EndCrsrMove( sal_True );
5215             }
5216         }
5217         break;
5218 #ifdef DBG_UTIL
5219         default:
5220             ASSERT( !this, "unknown command." );
5221 #endif
5222     }
5223     if (bCallBase)
5224         Window::Command(rCEvt);
5225 }
5226 
5227 /* -----------------25.08.2003 10:12-----------------
5228     #i18686#: select the object/cursor at the mouse
5229     position of the context menu request
5230  --------------------------------------------------*/
5231 sal_Bool SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
5232 {
5233     sal_Bool bRet = sal_False;
5234     const Point aDocPos( PixelToLogic( rMousePos ) );
5235     // --> OD 2005-02-17 #i42258#
5236     const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) );
5237     // <--
5238     //create a synthetic mouse event out of the coordinates
5239     MouseEvent aMEvt(rMousePos);
5240     SdrView *pSdrView = rSh.GetDrawView();
5241     if ( pSdrView )
5242     {
5243         // --> OD 2005-02-17 #i42258# - no close of insert_draw and reset of
5244         // draw mode, if context menu position is inside a selected object.
5245         if ( !bIsInsideSelectedObj && rView.GetDrawFuncPtr() )
5246         // <--
5247         {
5248 
5249             rView.GetDrawFuncPtr()->Deactivate();
5250             rView.SetDrawFuncPtr(NULL);
5251             rView.LeaveDrawCreate();
5252             SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
5253             rBind.Invalidate( SID_ATTR_SIZE );
5254             rBind.Invalidate( SID_TABLE_CELL );
5255         }
5256 
5257         // if draw text is active and there's a text selection
5258         // at the mouse position then do nothing
5259         if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
5260         {
5261             OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
5262             ESelection aSelection = pOLV->GetSelection();
5263             if(!aSelection.IsZero())
5264             {
5265                 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
5266                 sal_Bool bVertical = pOutliner->IsVertical();
5267                 const EditEngine& rEditEng = pOutliner->GetEditEngine();
5268                 Point aEEPos(aDocPos);
5269                 const Rectangle& rOutputArea = pOLV->GetOutputArea();
5270                 // regard vertical mode
5271                 if(bVertical)
5272                 {
5273                     aEEPos -= rOutputArea.TopRight();
5274                     //invert the horizontal direction and exchange X and Y
5275                     long nTemp = -aEEPos.X();
5276                     aEEPos.X() = aEEPos.Y();
5277                     aEEPos.Y() = nTemp;
5278                 }
5279                 else
5280                     aEEPos -= rOutputArea.TopLeft();
5281 
5282                 EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos);
5283                 ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
5284                 // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
5285                 aSelection.Adjust();
5286                 if(!aCompare.IsLess(aSelection)  && !aCompare.IsGreater(aSelection))
5287                 {
5288                     return sal_False;
5289                 }
5290             }
5291 
5292         }
5293 
5294         if (pSdrView->MouseButtonDown( aMEvt, this ) )
5295         {
5296             pSdrView->MouseButtonUp( aMEvt, this );
5297             rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
5298             return sal_True;
5299         }
5300     }
5301     rSh.ResetCursorStack();
5302 
5303     if ( EnterDrawMode( aMEvt, aDocPos ) )
5304     {
5305         return sal_True;
5306     }
5307     if ( rView.GetDrawFuncPtr() && bInsFrm )
5308     {
5309         StopInsFrm();
5310         rSh.Edit();
5311     }
5312 
5313     UpdatePointer( aDocPos, 0 );
5314 
5315     if( !rSh.IsSelFrmMode() &&
5316         !GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
5317     {
5318         // #107513#
5319         // Test if there is a draw object at that position and if it should be selected.
5320         sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
5321 
5322         if(bShould)
5323         {
5324             rView.NoRotate();
5325             rSh.HideCrsr();
5326 
5327             sal_Bool bUnLockView = !rSh.IsViewLocked();
5328             rSh.LockView( sal_True );
5329             sal_Bool bSelObj = rSh.SelectObj( aDocPos, 0);
5330             if( bUnLockView )
5331                 rSh.LockView( sal_False );
5332 
5333             if( bSelObj )
5334             {
5335                 bRet = sal_True;
5336                 // falls im Macro der Rahmen deselektiert
5337                 // wurde, muss nur noch der Cursor
5338                 // wieder angezeigt werden.
5339                 if( FRMTYPE_NONE == rSh.GetSelFrmType() )
5340                     rSh.ShowCrsr();
5341                 else
5342                 {
5343                     if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
5344                     {
5345                         rView.GetDrawFuncPtr()->Deactivate();
5346                         rView.SetDrawFuncPtr(NULL);
5347                         rView.LeaveDrawCreate();
5348                         rView.AttrChangedNotify( &rSh );
5349                     }
5350 
5351                     rSh.EnterSelFrmMode( &aDocPos );
5352                     bFrmDrag = sal_True;
5353                     UpdatePointer( aDocPos, 0 );
5354                     return bRet;
5355                 }
5356             }
5357 
5358             if (!rView.GetDrawFuncPtr())
5359                 rSh.ShowCrsr();
5360         }
5361     }
5362     else if ( rSh.IsSelFrmMode() &&
5363               (aActHitType == SDRHIT_NONE ||
5364                !bIsInsideSelectedObj))
5365     {
5366         rView.NoRotate();
5367         sal_Bool bUnLockView = !rSh.IsViewLocked();
5368         rSh.LockView( sal_True );
5369         sal_uInt8 nFlag = 0;
5370 
5371         if ( rSh.IsSelFrmMode() )
5372         {
5373             rSh.UnSelectFrm();
5374             rSh.LeaveSelFrmMode();
5375             rView.AttrChangedNotify(&rSh);
5376             bRet = sal_True;
5377         }
5378 
5379         sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
5380         if( bUnLockView )
5381             rSh.LockView( sal_False );
5382 
5383         if( !bSelObj )
5384         {
5385             // Cursor hier umsetzen, damit er nicht zuerst
5386             // im Rahmen gezeichnet wird; ShowCrsr() geschieht
5387             // in LeaveSelFrmMode()
5388             bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False));
5389             rSh.LeaveSelFrmMode();
5390             rView.LeaveDrawCreate();
5391             rView.AttrChangedNotify( &rSh );
5392             bRet = sal_True;
5393         }
5394         else
5395         {
5396             rSh.HideCrsr();
5397             rSh.EnterSelFrmMode( &aDocPos );
5398             rSh.SelFlyGrabCrsr();
5399             rSh.MakeSelVisible();
5400             bFrmDrag = sal_True;
5401             if( rSh.IsFrmSelected() &&
5402                 rView.GetDrawFuncPtr() )
5403             {
5404                 rView.GetDrawFuncPtr()->Deactivate();
5405                 rView.SetDrawFuncPtr(NULL);
5406                 rView.LeaveDrawCreate();
5407                 rView.AttrChangedNotify( &rSh );
5408             }
5409             UpdatePointer( aDocPos, 0 );
5410             bRet = sal_True;
5411         }
5412     }
5413     else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj )
5414     {
5415         // ## object at the mouse cursor is already selected - do nothing
5416         return sal_False;
5417     }
5418 
5419     if ( rSh.IsGCAttr() )
5420     {
5421         rSh.GCAttr();
5422         rSh.ClearGCAttr();
5423     }
5424 
5425     sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False;
5426     if( !bOverSelect )
5427         bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos );
5428 
5429     if ( !bOverSelect )
5430     {
5431         {   // nur temp. Move-Kontext aufspannen, da sonst die
5432             // Abfrage auf die Inhaltsform nicht funktioniert!!!
5433             MV_KONTEXT( &rSh );
5434             (rSh.*rSh.fnSetCrsr)(&aDocPos, sal_False);
5435             bRet = sal_True;
5436         }
5437     }
5438     if( !bOverURLGrf )
5439     {
5440         const int nSelType = rSh.GetSelectionType();
5441         if( nSelType == nsSelectionType::SEL_OLE ||
5442             nSelType == nsSelectionType::SEL_GRF )
5443         {
5444             MV_KONTEXT( &rSh );
5445             if( !rSh.IsFrmSelected() )
5446                 rSh.GotoNextFly();
5447             rSh.EnterSelFrmMode();
5448             bRet = sal_True;
5449         }
5450     }
5451     return bRet;
5452 }
5453 
5454 SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType )
5455 {
5456     //Shell ermitteln
5457     SfxShell* pShell;
5458     SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher();
5459     for(sal_uInt16  i = 0; sal_True; ++i )
5460     {
5461         pShell = pDispatcher->GetShell( i );
5462         if( !pShell || pShell->IsA( nType ) )
5463             break;
5464     }
5465     return pShell;
5466 }
5467 
5468 
5469 
5470 void SwEditWin::ClearTip()
5471 {
5472 }
5473 
5474 IMPL_LINK( SwEditWin, KeyInputFlushHandler, Timer *, EMPTYARG )
5475 {
5476     FlushInBuffer();
5477     return 0;
5478 }
5479 
5480 
5481 IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG )
5482 {
5483     bTblInsDelMode = sal_False;
5484     return 0;
5485 }
5486 
5487 void SwEditWin::_InitStaticData()
5488 {
5489     pQuickHlpData = new QuickHelpData();
5490 }
5491 
5492 void SwEditWin::_FinitStaticData()
5493 {
5494     delete pQuickHlpData;
5495 }
5496 /* -----------------23.01.2003 12:15-----------------
5497  * #i3370# remove quick help to prevent saving
5498  * of autocorrection suggestions
5499  * --------------------------------------------------*/
5500 void SwEditWin::StopQuickHelp()
5501 {
5502     if( HasFocus() && pQuickHlpData && pQuickHlpData->bClear  )
5503         pQuickHlpData->Stop( rView.GetWrtShell() );
5504 }
5505 
5506 /*-----------------23.02.97 18:39-------------------
5507 
5508 --------------------------------------------------*/
5509 
5510 
5511 IMPL_LINK(SwEditWin, TemplateTimerHdl, Timer*, EMPTYARG)
5512 {
5513     SetApplyTemplate(SwApplyTemplate());
5514     return 0;
5515 }
5516 
5517 
5518 void SwEditWin::SetChainMode( sal_Bool bOn )
5519 {
5520     if ( !bChainMode )
5521         StopInsFrm();
5522 
5523     if ( pUserMarker )
5524     {
5525         delete pUserMarker;
5526         pUserMarker = 0L;
5527     }
5528 
5529     bChainMode = bOn;
5530     if ( !bChainMode )
5531         rView.GetViewFrame()->HideStatusText();
5532 
5533     static sal_uInt16 __READONLY_DATA aInva[] =
5534     {
5535         FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0
5536     };
5537     rView.GetViewFrame()->GetBindings().Invalidate(aInva);
5538 }
5539 
5540 uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible()
5541 {
5542     vos::OGuard aGuard(Application::GetSolarMutex());   // this should have
5543                                                         // happend already!!!
5544     SwWrtShell *pSh = rView.GetWrtShellPtr();
5545     ASSERT( pSh, "no writer shell, no accessible object" );
5546     uno::Reference<
5547         ::com::sun::star::accessibility::XAccessible > xAcc;
5548     if( pSh )
5549         xAcc = pSh->CreateAccessible();
5550 
5551     return xAcc;
5552 }
5553 
5554 //-------------------------------------------------------------
5555 
5556 void QuickHelpData::Move( QuickHelpData& rCpy )
5557 {
5558     // Pointer verschieben
5559     aArr.Insert( &rCpy.aArr );
5560     rCpy.aArr.Remove( (sal_uInt16)0, rCpy.aArr.Count() );
5561 //  nTipId = rCpy.nTipId;
5562     bClear = rCpy.bClear;
5563     nLen = rCpy.nLen;
5564     nCurArrPos = rCpy.nCurArrPos;
5565     bChkInsBlank = rCpy.bChkInsBlank;
5566     bIsTip = rCpy.bIsTip;
5567     bIsAutoText = rCpy.bIsAutoText;
5568 
5569     if( pCETID ) delete pCETID;
5570     pCETID = rCpy.pCETID;
5571     rCpy.pCETID = 0;
5572 
5573     if( pAttrs )
5574         delete[] pAttrs;
5575     pAttrs = rCpy.pAttrs;
5576     rCpy.pAttrs = 0;
5577 }
5578 
5579 void QuickHelpData::ClearCntnt()
5580 {
5581     nLen = nCurArrPos = 0;
5582     bClear = bChkInsBlank = sal_False;
5583     nTipId = 0;
5584     aArr.DeleteAndDestroy( 0 , aArr.Count() );
5585     bIsTip = sal_True;
5586     bIsAutoText = sal_True;
5587     delete pCETID, pCETID = 0;
5588     delete[] pAttrs, pAttrs = 0;
5589 }
5590 
5591 
5592 void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
5593 {
5594     if( pCETID ) delete pCETID, pCETID = 0;
5595     if( pAttrs ) delete[] pAttrs, pAttrs = 0;
5596 
5597     if( USHRT_MAX != nWrdLen )
5598     {
5599         nLen = nWrdLen;
5600         nCurArrPos = 0;
5601     }
5602     bClear = sal_True;
5603 
5604     Window& rWin = rSh.GetView().GetEditWin();
5605     if( bIsTip )
5606     {
5607         Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
5608                     rSh.GetCharRect().Pos() )));
5609         aPt.Y() -= 3;
5610         nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
5611                         *aArr[ nCurArrPos ],
5612                         QUICKHELP_LEFT | QUICKHELP_BOTTOM );
5613     }
5614     else
5615     {
5616         String sStr( *aArr[ nCurArrPos ] );
5617         sStr.Erase( 0, nLen );
5618         sal_uInt16 nL = sStr.Len();
5619         pAttrs = new sal_uInt16[ nL ];
5620         for( sal_uInt16 n = nL; n;  )
5621             *(pAttrs + --n ) = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
5622                                 EXTTEXTINPUT_ATTR_HIGHLIGHT;
5623         pCETID = new CommandExtTextInputData( sStr, pAttrs, nL,
5624                                                 0, 0, 0, sal_False );
5625         rSh.CreateExtTextInput(rWin.GetInputLanguage());
5626         rSh.SetExtTextInputData( *pCETID );
5627     }
5628 }
5629 
5630 void QuickHelpData::Stop( SwWrtShell& rSh )
5631 {
5632     if( !bIsTip )
5633         rSh.DeleteExtTextInput( 0, sal_False );
5634     else if( nTipId )
5635         Help::HideTip( nTipId );
5636     ClearCntnt();
5637 }
5638 
5639 
5640 
5641 void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord )
5642 {
5643     salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper();
5644     (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() );
5645 
5646     {
5647         uno::Sequence< i18n::CalendarItem > aNames(
5648                                             (*pCalendar)->getMonths() );
5649         for( int n = 0; n < 2; ++n )
5650         {
5651             for( long nPos = 0, nEnd = aNames.getLength(); nPos < nEnd; ++nPos )
5652             {
5653                 String sStr( aNames[ nPos ].FullName );
5654                 if( rWord.Len() + 1 < sStr.Len() &&
5655 
5656 //!!! UNICODE: fehlendes interface
5657 //                  pIntl->CompareEqual( rWord, sStr.Copy( 0, rWord.Len() ),
5658 //                              INTN_COMPARE_IGNORECASE ) )
5659                     COMPARE_EQUAL == rWord.CompareIgnoreCaseToAscii(
5660                                         sStr, rWord.Len() ))
5661                 {
5662                     String* pNew = new String( sStr );
5663                     if( !aArr.Insert( pNew ) )
5664                         delete pNew;
5665                 }
5666             }
5667             if( !n )                    // get data for the second loop
5668                 aNames = (*pCalendar)->getDays();
5669         }
5670     }
5671 
5672     // and than add all words from the AutoCompleteWord-List
5673     const SwAutoCompleteWord& rACLst = rSh.GetAutoCompleteWords();
5674     sal_uInt16 nStt, nEnd;
5675     if( rACLst.GetRange( rWord, nStt, nEnd ) )
5676     {
5677         while( nStt < nEnd )
5678         {
5679             const String& rS = rACLst[ nStt ];
5680             //JP 16.06.99: Bug 66927 - only if the count of chars
5681             //              from the suggest greater as the
5682             //              actual word
5683             if( rS.Len() > rWord.Len() )
5684             {
5685                 String* pNew = new String( rS );
5686                 ByteString bStr( ::rtl::OUStringToOString( rWord, RTL_TEXTENCODING_UTF8) );
5687                 if( bStr.IsLowerAscii() )
5688                     pNew->ToLowerAscii();
5689                 else if( bStr.IsUpperAscii() )
5690                     pNew->ToUpperAscii();
5691                 if( !aArr.Insert( pNew ) )
5692                     delete pNew;
5693             }
5694             ++nStt;
5695         }
5696     }
5697 }
5698 /* -----------------06.11.2002 12:01-----------------
5699  *
5700  * --------------------------------------------------*/
5701 void SwEditWin::ShowAutoTextCorrectQuickHelp(
5702         const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr,
5703         sal_Bool bFromIME )
5704 {
5705     SwWrtShell& rSh = rView.GetWrtShell();
5706     pQuickHlpData->ClearCntnt();
5707     if( pACfg->IsAutoTextTip() )
5708     {
5709         SwGlossaryList* pList = ::GetGlossaryList();
5710         pList->HasLongName( rWord, &pQuickHlpData->aArr );
5711     }
5712 
5713     if( pQuickHlpData->aArr.Count() )
5714     {
5715         pQuickHlpData->bIsTip = sal_True;
5716         pQuickHlpData->bIsAutoText = sal_True;
5717     }
5718     else if( pACorr->GetSwFlags().bAutoCompleteWords )
5719     {
5720         pQuickHlpData->bIsAutoText = sal_False;
5721         pQuickHlpData->bIsTip = bFromIME ||
5722                     !pACorr ||
5723                     pACorr->GetSwFlags().bAutoCmpltShowAsTip;
5724 
5725         pQuickHlpData->FillStrArr( rSh, rWord );
5726     }
5727 
5728     if( pQuickHlpData->aArr.Count() )
5729         pQuickHlpData->Start( rSh, rWord.Len() );
5730 }
5731 
5732 /* -----------------29.03.2006 11:01-----------------
5733  *
5734  * --------------------------------------------------*/
5735 
5736 void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
5737 {
5738     if ( bNew || bUseInputLanguage )
5739     {
5740         SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
5741         rBind.Invalidate( SID_ATTR_CHAR_FONT );
5742         rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
5743     }
5744     bUseInputLanguage = bNew;
5745 }
5746 
5747 /*-- 13.11.2008 10:18:17---------------------------------------------------
5748 
5749   -----------------------------------------------------------------------*/
5750 XubString SwEditWin::GetSurroundingText() const
5751 {
5752     String sReturn;
5753     SwWrtShell& rSh = rView.GetWrtShell();
5754     if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() )
5755         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
5756     else if( !rSh.HasSelection() )
5757     {
5758         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
5759         xub_StrLen nPos = pPos->nContent.GetIndex();
5760 
5761         // get the sentence around the cursor
5762         rSh.HideCrsr();
5763         rSh.GoStartSentence();
5764         rSh.SetMark();
5765         rSh.GoEndSentence();
5766         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
5767 
5768         pPos->nContent = nPos;
5769         rSh.ClearMark();
5770         rSh.HideCrsr();
5771     }
5772 
5773     return sReturn;
5774 }
5775 /*-- 13.11.2008 10:18:17---------------------------------------------------
5776 
5777   -----------------------------------------------------------------------*/
5778 Selection SwEditWin::GetSurroundingTextSelection() const
5779 {
5780     SwWrtShell& rSh = rView.GetWrtShell();
5781     if( rSh.HasSelection() )
5782     {
5783         String sReturn;
5784         rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR  );
5785         return Selection( 0, sReturn.Len() );
5786     }
5787     else
5788     {
5789         // Return the position of the visible cursor in the sentence
5790         // around the visible cursor.
5791         SwPosition *pPos = rSh.GetCrsr()->GetPoint();
5792         xub_StrLen nPos = pPos->nContent.GetIndex();
5793 
5794         rSh.HideCrsr();
5795         rSh.GoStartSentence();
5796         xub_StrLen nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex();
5797 
5798         pPos->nContent = nPos;
5799         rSh.ClearMark();
5800         rSh.ShowCrsr();
5801 
5802         return Selection( nPos - nStartPos, nPos - nStartPos );
5803     }
5804 }
5805