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