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 eKeyState = KS_ColRightBig; 1630 eFlyState = KS_Fly_Change; 1631 nDir = MOVE_RIGHT_SMALL; 1632 goto KEYINPUT_CHECKTABLE; 1633 1634 case KEY_LEFT | KEY_MOD2: 1635 eKeyState = KS_ColRightSmall; 1636 eFlyState = KS_Fly_Change; 1637 nDir = MOVE_LEFT_SMALL; 1638 goto KEYINPUT_CHECKTABLE; 1639 1640 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT: 1641 eKeyState = KS_ColLeftSmall; 1642 goto KEYINPUT_CHECKTABLE; 1643 1644 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT: 1645 eKeyState = KS_ColLeftBig; 1646 goto KEYINPUT_CHECKTABLE; 1647 1648 case KEY_RIGHT | KEY_MOD2 | KEY_MOD1: 1649 eKeyState = KS_CellRightBig; 1650 goto KEYINPUT_CHECKTABLE; 1651 1652 case KEY_LEFT | KEY_MOD2 | KEY_MOD1: 1653 eKeyState = KS_CellRightSmall; 1654 goto KEYINPUT_CHECKTABLE; 1655 1656 case KEY_RIGHT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1: 1657 eKeyState = KS_CellLeftSmall; 1658 goto KEYINPUT_CHECKTABLE; 1659 1660 case KEY_LEFT | KEY_MOD2 | KEY_SHIFT | KEY_MOD1: 1661 eKeyState = KS_CellLeftBig; 1662 goto KEYINPUT_CHECKTABLE; 1663 1664 case KEY_UP | KEY_MOD2: 1665 eKeyState = KS_ColBottomSmall; 1666 eFlyState = KS_Fly_Change; 1667 nDir = MOVE_UP_SMALL; 1668 goto KEYINPUT_CHECKTABLE; 1669 1670 case KEY_DOWN | KEY_MOD2: 1671 eKeyState = KS_ColBottomBig; 1672 eFlyState = KS_Fly_Change; 1673 nDir = MOVE_DOWN_SMALL; 1674 goto KEYINPUT_CHECKTABLE; 1675 1676 // case KEY_UP | KEY_MOD2 | KEY_SHIFT: 1677 // eKeyState = KS_ColTopBig; 1678 // goto KEYINPUT_CHECKTABLE; 1679 // case KEY_DOWN | KEY_MOD2 | KEY_SHIFT: 1680 // eKeyState = KS_ColTopSmall; 1681 // goto KEYINPUT_CHECKTABLE; 1682 1683 case KEY_UP | KEY_MOD2 | KEY_MOD1: 1684 eKeyState = KS_CellBottomSmall; 1685 goto KEYINPUT_CHECKTABLE; 1686 1687 case KEY_DOWN | KEY_MOD2 | KEY_MOD1: 1688 eKeyState = KS_CellBottomBig; 1689 goto KEYINPUT_CHECKTABLE; 1690 1691 case KEY_UP | KEY_MOD2 | KEY_SHIFT | KEY_MOD1: 1692 eKeyState = KS_CellTopBig; 1693 goto KEYINPUT_CHECKTABLE; 1694 1695 case KEY_DOWN | KEY_MOD2 | KEY_SHIFT | KEY_MOD1: 1696 eKeyState = KS_CellTopSmall; 1697 goto KEYINPUT_CHECKTABLE; 1698 1699 KEYINPUT_CHECKTABLE: 1700 if( rSh.IsTableMode() || !rSh.GetTableFmt() ) 1701 { 1702 if(KS_KeyToView != eFlyState) 1703 { 1704 if(!pFlyFmt && KS_KeyToView != eFlyState && 1705 (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) && 1706 rSh.GetDrawView()->AreObjectsMarked()) 1707 eKeyState = KS_Draw_Change; 1708 } 1709 1710 if( pFlyFmt ) 1711 eKeyState = eFlyState; 1712 else if( KS_Draw_Change != eKeyState) 1713 eKeyState = KS_EnterCharCell; 1714 } 1715 break; 1716 1717 // huge object move 1718 case KEY_RIGHT | KEY_SHIFT: 1719 case KEY_LEFT | KEY_SHIFT: 1720 case KEY_UP | KEY_SHIFT: 1721 case KEY_DOWN | KEY_SHIFT: 1722 { 1723 if ( pFlyFmt 1724 || ( (rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) 1725 && rSh.GetDrawView()->AreObjectsMarked() ) ) 1726 { 1727 eKeyState = pFlyFmt ? KS_Fly_Change : KS_Draw_Change; 1728 switch ( rKeyCode.GetCode() ) 1729 { 1730 case KEY_RIGHT: nDir = MOVE_RIGHT_HUGE; break; 1731 case KEY_LEFT: nDir = MOVE_LEFT_HUGE; break; 1732 case KEY_UP: nDir = MOVE_UP_HUGE; break; 1733 case KEY_DOWN: nDir = MOVE_DOWN_HUGE; break; 1734 } 1735 } 1736 break; 1737 } 1738 1739 //------- 1740 // Insert/Delete 1741 case KEY_LEFT: 1742 case KEY_LEFT | KEY_MOD1: 1743 { 1744 sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1); 1745 if(!bMod1) 1746 { 1747 eFlyState = KS_Fly_Change; 1748 nDir = MOVE_LEFT_BIG; 1749 } 1750 eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | 1751 ( bMod1 1752 ? nsTblChgWidthHeightType::WH_CELL_LEFT 1753 : nsTblChgWidthHeightType::WH_COL_LEFT ); 1754 nTblChgSize = pModOpt->GetTblVInsert(); 1755 } 1756 goto KEYINPUT_CHECKTABLE_INSDEL; 1757 // case KEY_RIGHT: 1758 case KEY_RIGHT | KEY_MOD1: 1759 { 1760 eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_CELL_RIGHT; 1761 nTblChgSize = pModOpt->GetTblVInsert(); 1762 } 1763 goto KEYINPUT_CHECKTABLE_INSDEL; 1764 case KEY_UP: 1765 case KEY_UP | KEY_MOD1: 1766 { 1767 sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1); 1768 if(!bMod1) 1769 { 1770 eFlyState = KS_Fly_Change; 1771 nDir = MOVE_UP_BIG; 1772 } 1773 eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | 1774 ( bMod1 1775 ? nsTblChgWidthHeightType::WH_CELL_TOP 1776 : nsTblChgWidthHeightType::WH_ROW_TOP ); 1777 nTblChgSize = pModOpt->GetTblHInsert(); 1778 } 1779 goto KEYINPUT_CHECKTABLE_INSDEL; 1780 case KEY_DOWN: 1781 case KEY_DOWN | KEY_MOD1: 1782 { 1783 sal_Bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1); 1784 if(!bMod1) 1785 { 1786 eFlyState = KS_Fly_Change; 1787 nDir = MOVE_DOWN_BIG; 1788 } 1789 eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | 1790 ( bMod1 1791 ? nsTblChgWidthHeightType::WH_CELL_BOTTOM 1792 : nsTblChgWidthHeightType::WH_ROW_BOTTOM ); 1793 nTblChgSize = pModOpt->GetTblHInsert(); 1794 } 1795 goto KEYINPUT_CHECKTABLE_INSDEL; 1796 1797 KEYINPUT_CHECKTABLE_INSDEL: 1798 if( rSh.IsTableMode() || !rSh.GetTableFmt() || 1799 !bTblInsDelMode || 1800 sal_False /* Tabelle geschuetzt */ 1801 ) 1802 { 1803 const int nSelectionType = rSh.GetSelectionType(); 1804 1805 eKeyState = KS_KeyToView; 1806 if(KS_KeyToView != eFlyState) 1807 { 1808 if((nSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) && 1809 rSh.GetDrawView()->AreObjectsMarked()) 1810 eKeyState = KS_Draw_Change; 1811 else if(nSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) 1812 eKeyState = KS_Fly_Change; 1813 } 1814 } 1815 else 1816 { 1817 if( !bTblIsInsMode ) 1818 eTblChgMode = eTblChgMode | nsTblChgWidthHeightType::WH_FLAG_BIGGER; 1819 eKeyState = KS_TblColCellInsDel; 1820 } 1821 break; 1822 1823 case KEY_DELETE: 1824 if (rSh.IsInFrontOfLabel() && 1825 rSh.NumOrNoNum(sal_False)) 1826 eKeyState = KS_NumOrNoNum; 1827 break; 1828 1829 case KEY_DELETE | KEY_MOD2: 1830 if( !rSh.IsTableMode() && rSh.GetTableFmt() ) 1831 { 1832 eKeyState = KS_Ende; 1833 bTblInsDelMode = sal_True; 1834 bTblIsInsMode = sal_False; 1835 bTblIsColMode = sal_True; 1836 aKeyInputTimer.Start(); 1837 bStopKeyInputTimer = sal_False; 1838 } 1839 break; 1840 case KEY_INSERT | KEY_MOD2: 1841 if( !rSh.IsTableMode() && rSh.GetTableFmt() ) 1842 { 1843 eKeyState = KS_Ende; 1844 bTblInsDelMode = sal_True; 1845 bTblIsInsMode = sal_True; 1846 bTblIsColMode = sal_True; 1847 aKeyInputTimer.Start(); 1848 bStopKeyInputTimer = sal_False; 1849 } 1850 break; 1851 1852 case KEY_RETURN: // Return 1853 if( !rSh.HasReadonlySel() ) 1854 { 1855 const int nSelectionType = rSh.GetSelectionType(); 1856 if(nSelectionType & nsSelectionType::SEL_OLE) 1857 eKeyState = KS_LaunchOLEObject; 1858 else if(nSelectionType & nsSelectionType::SEL_FRM) 1859 eKeyState = KS_GoIntoFly; 1860 else if((nSelectionType & nsSelectionType::SEL_DRW) && 1861 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) && 1862 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1) 1863 eKeyState = KS_GoIntoDrawing; 1864 else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() && 1865 aTmpQHD.bIsAutoText ) 1866 eKeyState = KS_GlossaryExpand; 1867 1868 //RETURN und leerer Absatz in Numerierung -> Num. beenden 1869 else if( !aInBuffer.Len() && 1870 rSh.GetCurNumRule() && 1871 !rSh.GetCurNumRule()->IsOutlineRule() && 1872 !rSh.HasSelection() && 1873 rSh.IsSttPara() && rSh.IsEndPara() ) 1874 eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff; 1875 1876 //RETURN fuer neuen Absatz mit AutoFormatierung 1877 else if( pACfg && pACfg->IsAutoFmtByInput() && 1878 !(nSelectionType & (nsSelectionType::SEL_GRF | 1879 nsSelectionType::SEL_OLE | nsSelectionType::SEL_FRM | 1880 nsSelectionType::SEL_TBL_CELLS | nsSelectionType::SEL_DRW | 1881 nsSelectionType::SEL_DRW_TXT)) ) 1882 eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_AutoFmtByInput; 1883 else 1884 eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect; 1885 } 1886 break; 1887 1888 case KEY_RETURN | KEY_MOD2: // ALT-Return 1889 if( !rSh.HasReadonlySel() && !rSh.IsSttPara() && rSh.GetCurNumRule() ) 1890 eKeyState = KS_NoNum; 1891 else if( rSh.CanSpecialInsert() ) 1892 eKeyState = KS_SpecialInsert; 1893 break; 1894 1895 case KEY_BACKSPACE: 1896 case KEY_BACKSPACE | KEY_SHIFT: 1897 if( !rSh.HasReadonlySel() ) 1898 { 1899 // #i23725# 1900 sal_Bool bDone = sal_False; 1901 // --> OD 2006-01-31 - try to add comment for code snip: 1902 // Remove the paragraph indent, if the cursor is at the 1903 // beginning of a paragraph, there is no selection 1904 // and no numbering rule found at the current paragraph 1905 // --> OD 2006-01-31 #b6341339#, #i58776# 1906 // Also try to remove indent, if current paragraph 1907 // has numbering rule, but isn't counted and only 1908 // key <backspace> is hit. 1909 const bool bOnlyBackspaceKey( 1910 KEY_BACKSPACE == rKeyCode.GetFullCode() ); 1911 if ( rSh.IsSttPara() && 1912 !rSh.HasSelection() && // i40834 1913 ( NULL == rSh.GetCurNumRule() || 1914 ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) ) 1915 { 1916 bDone = rSh.TryRemoveIndent(); 1917 } 1918 // <-- 1919 1920 // -> #i23725# 1921 if (bDone) 1922 eKeyState = KS_Ende; 1923 else 1924 { 1925 if (rSh.IsSttPara() && 1926 ! rSh.IsNoNum()) 1927 { 1928 if (nKS_NUMDOWN_Count > 0 && 1929 0 < rSh.GetNumLevel()) 1930 { 1931 eKeyState = KS_NumUp; 1932 nKS_NUMDOWN_Count = 2; 1933 bDone = sal_True; 1934 } 1935 else if (nKS_NUMINDENTINC_Count > 0) 1936 { 1937 eKeyState = KS_NumIndentDec; 1938 nKS_NUMINDENTINC_Count = 2; 1939 bDone = sal_True; 1940 } 1941 } 1942 // <- #i23725# 1943 // --> OD 2006-01-31 #b6341339#, #i58776# 1944 // --> OD 2006-04-21 #i63540# 1945 // revise fix for issues b6341339 and i58776: 1946 // If the cursor is in an empty paragraph, which has 1947 // a numbering, but not the oultine numbering, and 1948 // there is no selection, the numbering has to be 1949 // deleted on key <Backspace>. 1950 // Otherwise method <SwEditShell::NumOrNoNum(..)> 1951 // should only change the <IsCounted()> state of 1952 // the current paragraph depending of the key. 1953 // On <backspace> it is set to <false>, 1954 // on <shift-backspace> it is set to <true>. 1955 // Thus, assure that method <SwEditShell::NumOrNum(..)> 1956 // is only called for the intended purpose. 1957 bool bCallNumOrNoNum( false ); 1958 { 1959 if ( !bDone ) 1960 { 1961 if ( bOnlyBackspaceKey && !rSh.IsNoNum() ) 1962 { 1963 bCallNumOrNoNum = true; 1964 } 1965 else if ( !bOnlyBackspaceKey && rSh.IsNoNum() ) 1966 { 1967 bCallNumOrNoNum = true; 1968 } 1969 else if ( bOnlyBackspaceKey && 1970 rSh.IsSttPara() && rSh.IsEndPara() && 1971 !rSh.HasSelection() ) 1972 { 1973 const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() ); 1974 if ( pCurrNumRule && 1975 pCurrNumRule != rSh.GetOutlineNumRule() ) 1976 { 1977 bCallNumOrNoNum = true; 1978 } 1979 } 1980 } 1981 } 1982 if ( bCallNumOrNoNum && 1983 rSh.NumOrNoNum( !bOnlyBackspaceKey, sal_True ) ) 1984 { 1985 eKeyState = KS_NumOrNoNum; 1986 } 1987 // <-- 1988 } 1989 } 1990 break; 1991 1992 case KEY_RIGHT: 1993 { 1994 eFlyState = KS_Fly_Change; 1995 nDir = MOVE_RIGHT_BIG; 1996 eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT; 1997 nTblChgSize = pModOpt->GetTblVInsert(); 1998 goto KEYINPUT_CHECKTABLE_INSDEL; 1999 } 2000 case KEY_TAB: 2001 { 2002 2003 #ifdef SW_CRSR_TIMER 2004 sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False ); 2005 #endif 2006 if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark() || rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT) 2007 { 2008 eKeyState=KS_GotoNextFieldMark; 2009 } 2010 else 2011 if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && 2012 !rSh.HasReadonlySel() ) 2013 { 2014 // --> OD 2007-10-02 #b660435# 2015 // if (rSh.IsFirstOfNumRule()) // #i23725# 2016 if ( rSh.IsFirstOfNumRule() && 2017 numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) 2018 // <-- 2019 eKeyState = KS_NumIndentInc; 2020 else 2021 eKeyState = KS_NumDown; 2022 } 2023 else if ( rSh.GetTableFmt() ) 2024 { 2025 if( rSh.HasSelection() || rSh.HasReadonlySel() ) 2026 eKeyState = KS_NextCell; 2027 else 2028 eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_NextCell; 2029 } 2030 else if ( rSh.GetSelectionType() & 2031 (nsSelectionType::SEL_GRF | 2032 nsSelectionType::SEL_FRM | 2033 nsSelectionType::SEL_OLE | 2034 nsSelectionType::SEL_DRW | 2035 nsSelectionType::SEL_DRW_FORM)) 2036 2037 eKeyState = KS_NextObject; 2038 else 2039 { 2040 eKeyState = KS_InsTab; 2041 if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() ) 2042 { 2043 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl(); 2044 if( pColl && 2045 //0 <= pColl->GetOutlineLevel() && #i24560# 2046 //MAXLEVEL - 1 > pColl->GetOutlineLevel() )//#outline level,zhaojianwei 2047 pColl->IsAssignedToListLevelOfOutlineStyle() 2048 && MAXLEVEL-1 > pColl->GetAssignedOutlineStyleLevel() )//<-end,zhaojianwei 2049 eKeyState = KS_OutlineDown; 2050 } 2051 } 2052 #ifdef SW_CRSR_TIMER 2053 rSh.ChgCrsrTimerFlag( bOld ); 2054 #endif 2055 } 2056 break; 2057 case KEY_TAB | KEY_SHIFT: 2058 { 2059 #ifdef SW_CRSR_TIMER 2060 sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False ); 2061 sal_Bool bOld = rSh.ChgCrsrTimerFlag( sal_False ); 2062 #endif 2063 if (rSh.IsFormProtected() || rSh.GetCurrentFieldmark()|| rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT) { 2064 eKeyState=KS_GotoPrevFieldMark; 2065 } 2066 else if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && 2067 !rSh.HasReadonlySel() ) 2068 { 2069 // --> OD 2007-10-02 #b660435# 2070 // if (rSh.IsFirstOfNumRule()) // #i23725# 2071 if ( rSh.IsFirstOfNumRule() && 2072 numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) 2073 // <-- 2074 eKeyState = KS_NumIndentDec; 2075 else 2076 eKeyState = KS_NumUp; 2077 } 2078 else if ( rSh.GetTableFmt() ) 2079 { 2080 if( rSh.HasSelection() || rSh.HasReadonlySel() ) 2081 eKeyState = KS_PrevCell; 2082 else 2083 eKeyState = KS_CheckAutoCorrect, eNextKeyState = KS_PrevCell; 2084 } 2085 else if ( rSh.GetSelectionType() & 2086 (nsSelectionType::SEL_GRF | 2087 nsSelectionType::SEL_FRM | 2088 nsSelectionType::SEL_OLE | 2089 nsSelectionType::SEL_DRW | 2090 nsSelectionType::SEL_DRW_FORM)) 2091 2092 eKeyState = KS_PrevObject; 2093 else 2094 { 2095 eKeyState = KS_Ende; 2096 if( rSh.IsSttOfPara() && !rSh.HasReadonlySel() ) 2097 { 2098 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl(); 2099 //if( pColl && 0 < pColl->GetOutlineLevel() && //#outline level,zhaojianwei 2100 // MAXLEVEL - 1 >= pColl->GetOutlineLevel() ) 2101 if( pColl && 2102 pColl->IsAssignedToListLevelOfOutlineStyle() && 2103 0 < pColl->GetAssignedOutlineStyleLevel()) 2104 eKeyState = KS_OutlineUp; 2105 } 2106 } 2107 #ifdef SW_CRSR_TIMER 2108 rSh.ChgCrsrTimerFlag( bOld ); 2109 #endif 2110 } 2111 break; 2112 case KEY_TAB | KEY_MOD1: 2113 case KEY_TAB | KEY_MOD2: 2114 if( !rSh.HasReadonlySel() ) 2115 { 2116 if( aTmpQHD.HasCntnt() && !rSh.HasSelection() ) 2117 { 2118 // zum naechsten Tip 2119 aTmpQHD.Inc( pACorr && pACorr->GetSwFlags(). 2120 bAutoCmpltEndless ); 2121 eKeyState = KS_NextPrevGlossary; 2122 } 2123 else if( rSh.GetTableFmt() ) 2124 eKeyState = KS_InsTab; 2125 else if((rSh.GetSelectionType() & 2126 (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM| 2127 nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) && 2128 rSh.GetDrawView()->AreObjectsMarked()) 2129 eKeyState = KS_EnterDrawHandleMode; 2130 else 2131 { 2132 eKeyState = KS_InsTab; 2133 } 2134 } 2135 break; 2136 2137 case KEY_TAB | KEY_MOD1 | KEY_SHIFT: 2138 if( aTmpQHD.HasCntnt() && !rSh.HasSelection() && 2139 !rSh.HasReadonlySel() ) 2140 { 2141 // zum vorherigen Tip 2142 aTmpQHD.Dec( pACorr && pACorr->GetSwFlags(). 2143 bAutoCmpltEndless ); 2144 eKeyState = KS_NextPrevGlossary; 2145 } 2146 else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM| 2147 nsSelectionType::SEL_FRM|nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF)) && 2148 rSh.GetDrawView()->AreObjectsMarked()) 2149 eKeyState = KS_EnterDrawHandleMode; 2150 break; 2151 case KEY_F2 : 2152 if( !rSh.HasReadonlySel() ) 2153 { 2154 const int nSelectionType = rSh.GetSelectionType(); 2155 if(nSelectionType & nsSelectionType::SEL_FRM) 2156 eKeyState = KS_GoIntoFly; 2157 else if((nSelectionType & nsSelectionType::SEL_DRW)) 2158 eKeyState = KS_GoIntoDrawing; 2159 } 2160 break; 2161 } 2162 } 2163 break; 2164 case KS_CheckDocReadOnlyKeys: 2165 { 2166 eKeyState = KS_KeyToView; 2167 switch( rKeyCode.GetModifier() | rKeyCode.GetCode() ) 2168 { 2169 case KEY_TAB: 2170 case KEY_TAB | KEY_SHIFT: 2171 bNormalChar = sal_False; 2172 eKeyState = KS_Ende; 2173 if ( rSh.GetSelectionType() & 2174 (nsSelectionType::SEL_GRF | 2175 nsSelectionType::SEL_FRM | 2176 nsSelectionType::SEL_OLE | 2177 nsSelectionType::SEL_DRW | 2178 nsSelectionType::SEL_DRW_FORM)) 2179 2180 { 2181 eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ? 2182 KS_PrevObject : KS_NextObject; 2183 } 2184 else 2185 rSh.SelectNextPrevHyperlink( 2186 KEY_SHIFT != rKeyCode.GetModifier() ); 2187 break; 2188 case KEY_RETURN: 2189 { 2190 const int nSelectionType = rSh.GetSelectionType(); 2191 if(nSelectionType & nsSelectionType::SEL_FRM) 2192 eKeyState = KS_GoIntoFly; 2193 else 2194 { 2195 SfxItemSet aSet(rSh.GetAttrPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); 2196 rSh.GetCurAttr(aSet); 2197 if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False)) 2198 { 2199 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True); 2200 bNormalChar = sal_False; 2201 eKeyState = KS_Ende; 2202 rSh.ClickToINetAttr((const SwFmtINetFmt&)rItem, URLLOAD_NOFILTER); 2203 } 2204 } 2205 } 2206 break; 2207 } 2208 } 2209 break; 2210 2211 case KS_EnterCharCell: 2212 { 2213 eKeyState = KS_KeyToView; 2214 switch ( rKeyCode.GetModifier() | rKeyCode.GetCode() ) 2215 { 2216 case KEY_RIGHT | KEY_MOD2: 2217 rSh.Right( CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 2218 eKeyState = KS_Ende; 2219 FlushInBuffer(); 2220 break; 2221 case KEY_LEFT | KEY_MOD2: 2222 rSh.Left( CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 2223 eKeyState = KS_Ende; 2224 FlushInBuffer(); 2225 break; 2226 } 2227 } 2228 break; 2229 2230 case KS_KeyToView: 2231 { 2232 eKeyState = KS_Ende; 2233 bNormalChar = 2234 !rKeyCode.IsMod2() && 2235 rKeyCode.GetModifier() != (KEY_MOD1) && 2236 rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) && 2237 SW_ISPRINTABLE( aCh ); 2238 2239 if (bNormalChar && rSh.IsInFrontOfLabel()) 2240 { 2241 rSh.NumOrNoNum(sal_False); 2242 } 2243 2244 if( aInBuffer.Len() && ( !bNormalChar || bIsDocReadOnly )) 2245 FlushInBuffer(); 2246 2247 if( rView.KeyInput( aKeyEvent ) ) 2248 bFlushBuffer = sal_True, bNormalChar = sal_False; 2249 else 2250 { 2251 // OS 22.09.95: Da der Sfx Acceleratoren nur aufruft, wenn sie beim letzten 2252 // Statusupdate enabled wurden, muss copy ggf. von uns 2253 // 'gewaltsam' gerufen werden. 2254 if( rKeyCode.GetFunction() == KEYFUNC_COPY ) 2255 GetView().GetViewFrame()->GetBindings().Execute(SID_COPY); 2256 2257 2258 if( !bIsDocReadOnly && bNormalChar ) 2259 { 2260 const int nSelectionType = rSh.GetSelectionType(); 2261 if((nSelectionType & nsSelectionType::SEL_DRW) && 2262 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) && 2263 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1) 2264 { 2265 SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); 2266 if(pObj) 2267 { 2268 EnterDrawTextMode(pObj->GetLogicRect().Center()); 2269 if ( rView.GetCurShell()->ISA(SwDrawTextShell) ) 2270 ((SwDrawTextShell*)rView.GetCurShell())->Init(); 2271 rSh.GetDrawView()->KeyInput( rKEvt, this ); 2272 } 2273 } 2274 else if(nSelectionType & nsSelectionType::SEL_FRM) 2275 { 2276 rSh.UnSelectFrm(); 2277 rSh.LeaveSelFrmMode(); 2278 rView.AttrChangedNotify(&rSh); 2279 rSh.MoveSection( fnSectionCurr, fnSectionEnd ); 2280 } 2281 eKeyState = KS_InsChar; 2282 } 2283 else 2284 { 2285 bNormalChar = sal_False; 2286 Window::KeyInput( aKeyEvent ); 2287 } 2288 } 2289 } 2290 break; 2291 case KS_LaunchOLEObject: 2292 rSh.LaunchOLEObj(); 2293 eKeyState = KS_Ende; 2294 break; 2295 case KS_GoIntoFly : 2296 rSh.UnSelectFrm(); 2297 rSh.LeaveSelFrmMode(); 2298 rView.AttrChangedNotify(&rSh); 2299 rSh.MoveSection( fnSectionCurr, fnSectionEnd ); 2300 eKeyState = KS_Ende; 2301 break; 2302 case KS_GoIntoDrawing : 2303 { 2304 SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); 2305 if(pObj) 2306 { 2307 EnterDrawTextMode(pObj->GetLogicRect().Center()); 2308 if ( rView.GetCurShell()->ISA(SwDrawTextShell) ) 2309 ((SwDrawTextShell*)rView.GetCurShell())->Init(); 2310 } 2311 eKeyState = KS_Ende; 2312 } 2313 break; 2314 case KS_EnterDrawHandleMode: 2315 { 2316 const SdrHdlList& rHdlList = rSh.GetDrawView()->GetHdlList(); 2317 sal_Bool bForward(!aKeyEvent.GetKeyCode().IsShift()); 2318 2319 ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward); 2320 eKeyState = KS_Ende; 2321 } 2322 break; 2323 case KS_InsTab: 2324 if( rView.ISA( SwWebView )) //Kein Tabulator fuer Web! 2325 { 2326 // Bug 56196 - dann sollte der weiter gereicht werden. 2327 Window::KeyInput( aKeyEvent ); 2328 eKeyState = KS_Ende; 2329 break; 2330 } 2331 aCh = '\t'; 2332 // kein break! 2333 case KS_InsChar: 2334 if (rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT) 2335 { 2336 ::sw::mark::ICheckboxFieldmark* pFieldmark = 2337 dynamic_cast< ::sw::mark::ICheckboxFieldmark* > 2338 (rSh.GetCurrentFieldmark()); 2339 OSL_ENSURE(pFieldmark, 2340 "Where is my FieldMark??"); 2341 if(pFieldmark) 2342 { 2343 pFieldmark->SetChecked(!pFieldmark->IsChecked()); 2344 SwDocShell* pDocSh = rView.GetDocShell(); 2345 SwDoc *pDoc=pDocSh->GetDoc(); 2346 OSL_ENSURE(pFieldmark->IsExpanded(), 2347 "where is the otherpos?"); 2348 if (pFieldmark->IsExpanded()) 2349 { 2350 SwPaM aPaM(pFieldmark->GetMarkPos(), pFieldmark->GetOtherMarkPos()); 2351 if(0) 2352 { 2353 rSh.StartAllAction(); //$flr TODO: understand why this not works 2354 pDoc->SetModified(aPaM); 2355 rSh.EndAllAction(); 2356 } 2357 else 2358 { 2359 rSh.CalcLayout(); // workaround 2360 } 2361 } 2362 } 2363 eKeyState = KS_Ende; 2364 } 2365 else if(!rSh.HasReadonlySel()) 2366 { 2367 sal_Bool bIsNormalChar = GetAppCharClass().isLetterNumeric( 2368 String( aCh ), 0 ); 2369 if( bChkInsBlank && bIsNormalChar && 2370 (aInBuffer.Len() || !rSh.IsSttPara() || !rSh.IsEndPara() )) 2371 { 2372 // vor dem Zeichen noch ein Blank einfuegen. Dieses 2373 // kommt zwischen den Expandierten Text und dem neuen 2374 // "nicht Worttrenner". 2375 aInBuffer.Expand( aInBuffer.Len() + 1, ' ' ); 2376 } 2377 2378 2379 sal_Bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh ); 2380 sal_Bool bRunNext = pACorr && pACorr->HasRunNext(); 2381 if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) && 2382 pACfg->IsAutoFmtByInput() && 2383 (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) && 2384 ( '*' == aCh || '_' == aCh ) ) || 2385 ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))|| 2386 ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh)))) 2387 { 2388 FlushInBuffer(); 2389 rSh.AutoCorrect( *pACorr, aCh ); 2390 if( '\"' != aCh && '\'' != aCh ) // nur bei "*_" rufen! 2391 rSh.UpdateAttr(); 2392 } 2393 else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || bRunNext ) && 2394 pACfg->IsAutoFmtByInput() && 2395 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | 2396 ChgOrdinalNumber | AddNonBrkSpace | 2397 ChgToEnEmDash | SetINetAttr | 2398 Autocorrect ) && 2399 '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh 2400 ) 2401 { 2402 FlushInBuffer(); 2403 rSh.AutoCorrect( *pACorr, aCh ); 2404 } 2405 else 2406 { 2407 aInBuffer.Expand( aInBuffer.Len() + aKeyEvent.GetRepeat() + 1,aCh ); 2408 bFlushCharBuffer = Application::AnyInput( INPUT_KEYBOARD ); 2409 bFlushBuffer = !bFlushCharBuffer; 2410 if( bFlushCharBuffer ) 2411 aKeyInputFlushTimer.Start(); 2412 } 2413 eKeyState = KS_Ende; 2414 } 2415 else 2416 { 2417 InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute(); 2418 // ??? Window::KeyInput( aKeyEvent ); 2419 eKeyState = KS_Ende; 2420 } 2421 break; 2422 2423 case KS_CheckAutoCorrect: 2424 { 2425 if( pACorr && pACfg->IsAutoFmtByInput() && 2426 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | 2427 ChgOrdinalNumber | 2428 ChgToEnEmDash | SetINetAttr | 2429 Autocorrect ) && 2430 !rSh.HasReadonlySel() ) 2431 /* { 2432 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | 2433 ChgFractionSymbol | ChgOrdinalNumber | 2434 ChgToEnEmDash | SetINetAttr | 2435 Autocorrect ) && 2436 !rSh.HasReadonlySel() ) */ 2437 { 2438 FlushInBuffer(); 2439 rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') ); 2440 } 2441 eKeyState = eNextKeyState; 2442 } 2443 break; 2444 2445 default: 2446 { 2447 sal_uInt16 nSlotId = 0; 2448 FlushInBuffer(); 2449 //??? if( bFlushCharBuffer ) 2450 //??? FlushInBuffer( &rSh ); 2451 switch( eKeyState ) 2452 { 2453 case KS_SpecialInsert: 2454 rSh.DoSpecialInsert(); 2455 break; 2456 2457 case KS_NoNum: 2458 rSh.NoNum(); 2459 break; 2460 2461 case KS_NumOff: 2462 // Shellwechsel - also vorher aufzeichnen 2463 rSh.DelNumRules(); 2464 eKeyState = eNextKeyState; 2465 break; 2466 case KS_OutlineLvOff: // delete autofmt outlinelevel later 2467 break; 2468 2469 case KS_NumDown: 2470 rSh.NumUpDown( sal_True ); 2471 nKS_NUMDOWN_Count = 2; // #i23725# 2472 break; 2473 case KS_NumUp: 2474 rSh.NumUpDown( sal_False ); 2475 break; 2476 2477 // -> #i23726# 2478 case KS_NumIndentInc: 2479 // --> OD 2008-06-16 #i90078# 2480 rSh.ChangeIndentOfAllListLevels(360); 2481 // <-- 2482 nKS_NUMINDENTINC_Count = 2; 2483 break; 2484 2485 case KS_GotoNextFieldMark: 2486 { 2487 ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkAfter(); 2488 if(pFieldmark) rSh.GotoFieldmark(pFieldmark); 2489 } 2490 break; 2491 2492 case KS_GotoPrevFieldMark: 2493 { 2494 ::sw::mark::IFieldmark const * const pFieldmark = rSh.GetFieldmarkBefore(); 2495 if(pFieldmark) rSh.GotoFieldmark(pFieldmark); 2496 } 2497 break; 2498 2499 case KS_NumIndentDec: 2500 // --> OD 2008-06-16 #i90078# 2501 rSh.ChangeIndentOfAllListLevels(-360); 2502 // <-- 2503 break; 2504 // <- #i23726# 2505 2506 case KS_OutlineDown: 2507 rSh.OutlineUpDown( 1 ); 2508 break; 2509 case KS_OutlineUp: 2510 rSh.OutlineUpDown( -1 ); 2511 break; 2512 2513 case KS_NextCell: 2514 //In Tabelle immer 'flushen' 2515 rSh.GoNextCell(); 2516 nSlotId = FN_GOTO_NEXT_CELL; 2517 break; 2518 case KS_PrevCell: 2519 rSh.GoPrevCell(); 2520 nSlotId = FN_GOTO_PREV_CELL; 2521 break; 2522 case KS_AutoFmtByInput: 2523 rSh.SplitNode( sal_True ); 2524 break; 2525 2526 // case KS_NumOrNoNum: 2527 // break; 2528 case KS_NextObject: 2529 case KS_PrevObject: 2530 if(rSh.GotoObj( KS_NextObject == eKeyState, GOTOOBJ_GOTO_ANY)) 2531 { 2532 if( rSh.IsFrmSelected() && 2533 rView.GetDrawFuncPtr() ) 2534 { 2535 rView.GetDrawFuncPtr()->Deactivate(); 2536 rView.SetDrawFuncPtr(NULL); 2537 rView.LeaveDrawCreate(); 2538 rView.AttrChangedNotify( &rSh ); 2539 } 2540 rSh.HideCrsr(); 2541 rSh.EnterSelFrmMode(); 2542 } 2543 break; 2544 case KS_GlossaryExpand: 2545 { 2546 // ersetze das Wort oder Kuerzel durch den den Textbaustein 2547 rSh.StartUndo( UNDO_START ); 2548 2549 String sFnd( *aTmpQHD.aArr[ aTmpQHD.nCurArrPos ] ); 2550 if( aTmpQHD.bIsAutoText ) 2551 { 2552 SwGlossaryList* pList = ::GetGlossaryList(); 2553 String sShrtNm; 2554 String sGroup; 2555 if(pList->GetShortName( sFnd, sShrtNm, sGroup)) 2556 { 2557 rSh.SttSelect(); 2558 rSh.ExtendSelection( sal_False, aTmpQHD.nLen ); 2559 SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl(); 2560 pGlosHdl->SetCurGroup(sGroup, sal_True); 2561 pGlosHdl->InsertGlossary( sShrtNm); 2562 pQuickHlpData->bChkInsBlank = sal_True; 2563 } 2564 } 2565 else 2566 { 2567 rSh.Insert( sFnd.Erase( 0, aTmpQHD.nLen )); 2568 pQuickHlpData->bChkInsBlank = !pACorr || 2569 pACorr->GetSwFlags().bAutoCmpltAppendBlanc; 2570 } 2571 rSh.EndUndo( UNDO_END ); 2572 } 2573 break; 2574 2575 case KS_NextPrevGlossary: 2576 pQuickHlpData->Move( aTmpQHD ); 2577 pQuickHlpData->Start( rSh, USHRT_MAX ); 2578 break; 2579 2580 case KS_EditFormula: 2581 { 2582 const sal_uInt16 nId = SwInputChild::GetChildWindowId(); 2583 2584 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 2585 pVFrame->ToggleChildWindow( nId ); 2586 SwInputChild* pChildWin = (SwInputChild*)pVFrame-> 2587 GetChildWindow( nId ); 2588 if( pChildWin ) 2589 pChildWin->SetFormula( sFmlEntry ); 2590 } 2591 break; 2592 2593 case KS_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break; 2594 case KS_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break; 2595 case KS_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHMove() ); break; 2596 case KS_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHMove() ); break; 2597 // case KS_ColTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break; 2598 case KS_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break; 2599 // case KS_ColTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVMove() ); break; 2600 case KS_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVMove() ); break; 2601 case KS_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break; 2602 case KS_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHMove() ); break; 2603 case KS_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHMove() ); break; 2604 case KS_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHMove() ); break; 2605 case KS_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break; 2606 case KS_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVMove() ); break; 2607 case KS_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVMove() ); break; 2608 case KS_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVMove() ); break; 2609 2610 //--------------- 2611 case KS_InsDel_ColLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break; 2612 case KS_InsDel_ColRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break; 2613 case KS_InsDel_ColLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_LEFT, pModOpt->GetTblHInsert() ); break; 2614 case KS_InsDel_ColRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_COL_RIGHT, pModOpt->GetTblHInsert() ); break; 2615 case KS_InsDel_ColTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break; 2616 case KS_InsDel_ColBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break; 2617 case KS_InsDel_ColTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_TOP, pModOpt->GetTblVInsert() ); break; 2618 case KS_InsDel_ColBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_ROW_BOTTOM, pModOpt->GetTblVInsert() ); break; 2619 case KS_InsDel_CellLeftBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break; 2620 case KS_InsDel_CellRightBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblHInsert() ); break; 2621 case KS_InsDel_CellLeftSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_LEFT, pModOpt->GetTblHInsert() ); break; 2622 case KS_InsDel_CellRightSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_RIGHT, pModOpt->GetTblHInsert() ); break; 2623 case KS_InsDel_CellTopBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break; 2624 case KS_InsDel_CellBottomBig: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM|nsTblChgWidthHeightType::WH_FLAG_BIGGER, pModOpt->GetTblVInsert() ); break; 2625 case KS_InsDel_CellTopSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_TOP, pModOpt->GetTblVInsert() ); break; 2626 case KS_InsDel_CellBottomSmall: rSh.SetColRowWidthHeight( nsTblChgWidthHeightType::WH_FLAG_INSDEL|nsTblChgWidthHeightType::WH_CELL_BOTTOM, pModOpt->GetTblVInsert() ); break; 2627 //--------------- 2628 case KS_TblColCellInsDel: 2629 rSh.SetColRowWidthHeight( eTblChgMode, nTblChgSize ); 2630 break; 2631 case KS_Fly_Change: 2632 { 2633 SdrView *pSdrView = rSh.GetDrawView(); 2634 const SdrHdlList& rHdlList = pSdrView->GetHdlList(); 2635 if(rHdlList.GetFocusHdl()) 2636 ChangeDrawing( nDir ); 2637 else 2638 ChangeFly( nDir, rView.ISA( SwWebView ) ); 2639 } 2640 break; 2641 case KS_Draw_Change : 2642 ChangeDrawing( nDir ); 2643 break; 2644 default:; //prevent warning 2645 } 2646 if( nSlotId && rView.GetViewFrame()->GetBindings().GetRecorder().is() ) 2647 { 2648 SfxRequest aReq(rView.GetViewFrame(), nSlotId ); 2649 aReq.Done(); 2650 } 2651 eKeyState = KS_Ende; 2652 } 2653 } 2654 } 2655 2656 if( bStopKeyInputTimer ) 2657 { 2658 aKeyInputTimer.Stop(); 2659 bTblInsDelMode = sal_False; 2660 } 2661 2662 // falls die gepufferten Zeichen eingefuegt werden sollen 2663 if( bFlushBuffer && aInBuffer.Len() ) 2664 { 2665 //OS 16.02.96 11.04: bFlushCharBuffer wurde hier nicht zurueckgesetzt 2666 // warum nicht? 2667 sal_Bool bSave = bFlushCharBuffer; 2668 FlushInBuffer(); 2669 bFlushCharBuffer = bSave; 2670 2671 // evt. Tip-Hilfe anzeigen 2672 String sWord; 2673 if( bNormalChar && pACfg && pACorr && 2674 ( pACfg->IsAutoTextTip() || 2675 pACorr->GetSwFlags().bAutoCompleteWords ) && 2676 rSh.GetPrevAutoCorrWord( *pACorr, sWord ) ) 2677 { 2678 ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr); 2679 } 2680 } 2681 } 2682 2683 /*-------------------------------------------------------------------- 2684 Beschreibung: MouseEvents 2685 --------------------------------------------------------------------*/ 2686 2687 2688 void SwEditWin::RstMBDownFlags() 2689 { 2690 //Nicht auf allen Systemen kommt vor dem modalen 2691 //Dialog noch ein MouseButton Up (wie unter WINDOWS). 2692 //Daher hier die Stati zuruecksetzen und die Maus 2693 //fuer den Dialog freigeben. 2694 bMBPressed = bNoInterrupt = sal_False; 2695 EnterArea(); 2696 ReleaseMouse(); 2697 } 2698 2699 2700 2701 void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) 2702 { 2703 SwWrtShell &rSh = rView.GetWrtShell(); 2704 2705 // We have to check if a context menu is shown and we have an UI 2706 // active inplace client. In that case we have to ignore the mouse 2707 // button down event. Otherwise we would crash (context menu has been 2708 // opened by inplace client and we would deactivate the inplace client, 2709 // the contex menu is closed by VCL asynchronously which in the end 2710 // would work on deleted objects or the context menu has no parent anymore) 2711 // See #126086# and #128122# 2712 SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient(); 2713 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() ); 2714 2715 if ( bIsOleActive && PopupMenu::IsInExecute() ) 2716 return; 2717 2718 MouseEvent rMEvt(_rMEvt); 2719 2720 if (rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel())) 2721 return; 2722 2723 rView.GetPostItMgr()->SetActiveSidebarWin(0); 2724 2725 GrabFocus(); 2726 2727 //ignore key modifiers for format paintbrush 2728 { 2729 sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard 2730 && pApplyTempl->pFormatClipboard->HasContent(); 2731 if( bExecFormatPaintbrush ) 2732 rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(), 2733 _rMEvt.GetMode(), _rMEvt.GetButtons() ); 2734 } 2735 2736 bWasShdwCrsr = 0 != pShadCrsr; 2737 if( bWasShdwCrsr ) 2738 delete pShadCrsr, pShadCrsr = 0; 2739 2740 const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) ); 2741 2742 if ( IsChainMode() ) 2743 { 2744 SetChainMode( sal_False ); 2745 SwRect aDummy; 2746 SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)rSh.GetFlyFrmFmt(); 2747 if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) ) 2748 rSh.Chain( *pFmt, aDocPos ); 2749 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 2750 return; 2751 } 2752 2753 //Nach GrabFocus sollte eine Shell gepusht sein. Das muss eigentlich 2754 //klappen aber in der Praxis ... 2755 lcl_SelectShellForDrop( rView ); 2756 2757 sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly(); 2758 sal_Bool bCallBase = sal_True; 2759 2760 if( pQuickHlpData->bClear ) 2761 pQuickHlpData->Stop( rSh ); 2762 pQuickHlpData->bChkInsBlank = sal_False; 2763 2764 if( rSh.FinishOLEObj() ) 2765 return; //InPlace beenden und der Klick zaehlt nicht mehr 2766 2767 SET_CURR_SHELL( &rSh ); 2768 2769 SdrView *pSdrView = rSh.GetDrawView(); 2770 if ( pSdrView ) 2771 { 2772 if (pSdrView->MouseButtonDown( rMEvt, this ) ) 2773 { 2774 rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 2775 return; // Event von der SdrView ausgewertet 2776 } 2777 } 2778 2779 2780 bIsInMove = sal_False; 2781 aStartPos = rMEvt.GetPosPixel(); 2782 aRszMvHdlPt.X() = 0, aRszMvHdlPt.Y() = 0; 2783 2784 sal_uInt8 nMouseTabCol = 0; 2785 const sal_Bool bTmp = !rSh.IsDrawCreate() && !pApplyTempl && !rSh.IsInSelect() && 2786 rMEvt.GetClicks() == 1 && MOUSE_LEFT == rMEvt.GetButtons(); 2787 if ( bTmp && 2788 0 != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) && 2789 !rSh.IsObjSelectable( aDocPos ) ) 2790 { 2791 // --> FME 2004-07-30 #i32329# Enhanced table selection 2792 if ( SW_TABSEL_HORI <= nMouseTabCol && SW_TABCOLSEL_VERT >= nMouseTabCol ) 2793 { 2794 rSh.EnterStdMode(); 2795 rSh.SelectTableRowCol( aDocPos ); 2796 if( SW_TABSEL_HORI != nMouseTabCol && SW_TABSEL_HORI_RTL != nMouseTabCol) 2797 { 2798 pRowColumnSelectionStart = new Point( aDocPos ); 2799 bIsRowDrag = SW_TABROWSEL_HORI == nMouseTabCol|| 2800 SW_TABROWSEL_HORI_RTL == nMouseTabCol || 2801 SW_TABCOLSEL_VERT == nMouseTabCol; 2802 bMBPressed = sal_True; 2803 CaptureMouse(); 2804 } 2805 return; 2806 } 2807 // <-- 2808 2809 if ( !rSh.IsTableMode() ) 2810 { 2811 //Zuppeln von Tabellenspalten aus dem Dokument heraus. 2812 if(SW_TABCOL_VERT == nMouseTabCol || SW_TABCOL_HORI == nMouseTabCol) 2813 rView.SetTabColFromDoc( sal_True ); 2814 else 2815 rView.SetTabRowFromDoc( sal_True ); 2816 2817 rView.SetTabColFromDocPos( aDocPos ); 2818 rView.InvalidateRulerPos(); 2819 SfxBindings& rBind = rView.GetViewFrame()->GetBindings(); 2820 rBind.Update(); 2821 if ( RulerColumnDrag( rMEvt, 2822 (SW_TABCOL_VERT == nMouseTabCol || SW_TABROW_HORI == nMouseTabCol)) ) 2823 { 2824 rView.SetTabColFromDoc( sal_False ); 2825 rView.SetTabRowFromDoc( sal_False ); 2826 rView.InvalidateRulerPos(); 2827 rBind.Update(); 2828 bCallBase = sal_False; 2829 } 2830 else 2831 { 2832 return; 2833 } 2834 } 2835 } 2836 // #i23726# 2837 else if (bTmp && 2838 rSh.IsNumLabel(aDocPos)) 2839 { 2840 SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPos ); 2841 rView.SetNumRuleNodeFromDoc( pNodeAtPos ); 2842 rView.InvalidateRulerPos(); 2843 SfxBindings& rBind = rView.GetViewFrame()->GetBindings(); 2844 rBind.Update(); 2845 2846 // --> OD 2005-02-21 #i42921# 2847 if ( RulerMarginDrag( rMEvt, 2848 rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPos ) ) ) 2849 // <-- 2850 { 2851 rView.SetNumRuleNodeFromDoc( NULL ); 2852 rView.InvalidateRulerPos(); 2853 rBind.Update(); 2854 bCallBase = sal_False; 2855 } 2856 else 2857 { 2858 // --> FME 2005-11-03 #125036# Make sure the pointer is set to 0, 2859 // otherwise it may point to nowhere after deleting the corresponding 2860 // text node. 2861 rView.SetNumRuleNodeFromDoc( NULL ); 2862 // <-- 2863 return; 2864 } 2865 } 2866 2867 //Man kann sich in einem Selektionszustand befinden, wenn zuletzt 2868 //mit dem Keyboard selektiert wurde, aber noch kein CURSOR_KEY 2869 //anschliessend bewegt worden ist. In diesem Fall muss die vorher- 2870 //gehende Selektion zuerst beendet werden. 2871 //MA 07. Oct. 95: Und zwar nicht nur bei Linker Maustaste sondern immer. 2872 //siehe auch Bug: 19263 2873 if ( rSh.IsInSelect() ) 2874 rSh.EndSelect(); 2875 2876 //Abfrage auf LEFT, da sonst auch bei einem Click mit der rechten Taste 2877 //beispielsweise die Selektion aufgehoben wird. 2878 if ( MOUSE_LEFT == rMEvt.GetButtons() ) 2879 { 2880 sal_Bool bOnlyText = sal_False; 2881 bMBPressed = bNoInterrupt = sal_True; 2882 nKS_NUMDOWN_Count = 0; // #i23725# 2883 2884 CaptureMouse(); 2885 2886 //ggf. Cursorpositionen zuruecksetzen 2887 rSh.ResetCursorStack(); 2888 2889 switch ( rMEvt.GetModifier() + rMEvt.GetButtons() ) 2890 { 2891 case MOUSE_LEFT: 2892 case MOUSE_LEFT + KEY_SHIFT: 2893 case MOUSE_LEFT + KEY_MOD2: 2894 if( rSh.IsObjSelected() ) 2895 { 2896 SdrHdl* pHdl; 2897 if( !bIsDocReadOnly && 2898 !pAnchorMarker && 2899 0 != ( pHdl = pSdrView->PickHandle(aDocPos) ) && 2900 ( pHdl->GetKind() == HDL_ANCHOR || 2901 pHdl->GetKind() == HDL_ANCHOR_TR ) ) 2902 { 2903 // #121463# Set selected during drag 2904 pHdl->SetSelected(true); 2905 pAnchorMarker = new SwAnchorMarker( pHdl ); 2906 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 2907 return; 2908 } 2909 } 2910 if ( EnterDrawMode( rMEvt, aDocPos ) ) 2911 { 2912 bNoInterrupt = sal_False; 2913 return; 2914 } 2915 else if ( rView.GetDrawFuncPtr() && bInsFrm ) 2916 { 2917 StopInsFrm(); 2918 rSh.Edit(); 2919 } 2920 2921 // Ohne SHIFT, da sonst Toggle bei Selektion nicht funktioniert 2922 if (rMEvt.GetClicks() == 1) 2923 { 2924 if ( rSh.IsSelFrmMode()) 2925 { 2926 SdrHdl* pHdl = rSh.GetDrawView()->PickHandle(aDocPos); 2927 sal_Bool bHitHandle = pHdl && pHdl->GetKind() != HDL_ANCHOR && 2928 pHdl->GetKind() != HDL_ANCHOR_TR; 2929 2930 if ((rSh.IsInsideSelectedObj(aDocPos) || bHitHandle) && 2931 !(rMEvt.GetModifier() == KEY_SHIFT && !bHitHandle)) 2932 { 2933 rSh.EnterSelFrmMode( &aDocPos ); 2934 if ( !pApplyTempl ) 2935 { 2936 //nur, wenn keine Position zum Sizen getroffen ist. 2937 if (!bHitHandle) 2938 { 2939 StartDDTimer(); 2940 SwEditWin::nDDStartPosY = aDocPos.Y(); 2941 SwEditWin::nDDStartPosX = aDocPos.X(); 2942 } 2943 bFrmDrag = sal_True; 2944 } 2945 bNoInterrupt = sal_False; 2946 return; 2947 } 2948 } 2949 } 2950 } 2951 2952 sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly(); 2953 if ( !bExecHyperlinks ) 2954 { 2955 SvtSecurityOptions aSecOpts; 2956 const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK ); 2957 if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) || 2958 ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) ) 2959 bExecHyperlinks = sal_True; 2960 } 2961 2962 // --> FME 2004-07-30 #i32329# Enhanced selection 2963 sal_uInt8 nNumberOfClicks = static_cast< sal_uInt8 >(rMEvt.GetClicks() % 4); 2964 if ( 0 == nNumberOfClicks && 0 < rMEvt.GetClicks() ) 2965 nNumberOfClicks = 4; 2966 // <-- 2967 2968 sal_Bool bExecDrawTextLink = sal_False; 2969 2970 switch ( rMEvt.GetModifier() + rMEvt.GetButtons() ) 2971 { 2972 case MOUSE_LEFT: 2973 case MOUSE_LEFT + KEY_MOD1: 2974 case MOUSE_LEFT + KEY_MOD2: 2975 switch ( nNumberOfClicks ) 2976 { 2977 case 1: 2978 { 2979 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 2980 SwEditWin::nDDStartPosY = aDocPos.Y(); 2981 SwEditWin::nDDStartPosX = aDocPos.X(); 2982 2983 // URL in DrawText-Objekt getroffen? 2984 if (bExecHyperlinks && pSdrView) 2985 { 2986 SdrViewEvent aVEvt; 2987 pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); 2988 2989 if (aVEvt.eEvent == SDREVENT_EXECUTEURL) 2990 bExecDrawTextLink = sal_True; 2991 } 2992 2993 //Rahmen nur zu selektieren versuchen, wenn 2994 //der Pointer bereits entsprechend geschaltet wurde 2995 if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() && 2996 !GetView().GetViewFrame()->GetDispatcher()->IsLocked() && 2997 !bExecDrawTextLink) 2998 { 2999 // #107513# 3000 // Test if there is a draw object at that position and if it should be selected. 3001 sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos); 3002 3003 if(bShould) 3004 { 3005 rView.NoRotate(); 3006 rSh.HideCrsr(); 3007 3008 sal_Bool bUnLockView = !rSh.IsViewLocked(); 3009 rSh.LockView( sal_True ); 3010 sal_Bool bSelObj = rSh.SelectObj( aDocPos, 3011 rMEvt.IsMod1() ? SW_ENTER_GROUP : 0); 3012 if( bUnLockView ) 3013 rSh.LockView( sal_False ); 3014 3015 if( bSelObj ) 3016 { 3017 // falls im Macro der Rahmen deselektiert 3018 // wurde, muss nur noch der Cursor 3019 // wieder angezeigt werden. 3020 if( FRMTYPE_NONE == rSh.GetSelFrmType() ) 3021 rSh.ShowCrsr(); 3022 else 3023 { 3024 if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr()) 3025 { 3026 rView.GetDrawFuncPtr()->Deactivate(); 3027 rView.SetDrawFuncPtr(NULL); 3028 rView.LeaveDrawCreate(); 3029 rView.AttrChangedNotify( &rSh ); 3030 } 3031 3032 rSh.EnterSelFrmMode( &aDocPos ); 3033 bFrmDrag = sal_True; 3034 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 3035 } 3036 return; 3037 } 3038 else 3039 bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos )); 3040 3041 if (!rView.GetDrawFuncPtr()) 3042 rSh.ShowCrsr(); 3043 } 3044 else 3045 bOnlyText = KEY_MOD1 != rMEvt.GetModifier(); 3046 } 3047 else if ( rSh.IsSelFrmMode() && 3048 (aActHitType == SDRHIT_NONE || 3049 !rSh.IsInsideSelectedObj( aDocPos ))) 3050 { 3051 rView.NoRotate(); 3052 SdrHdl *pHdl; 3053 if( !bIsDocReadOnly && !pAnchorMarker && 0 != 3054 ( pHdl = pSdrView->PickHandle(aDocPos) ) && 3055 ( pHdl->GetKind() == HDL_ANCHOR || 3056 pHdl->GetKind() == HDL_ANCHOR_TR ) ) 3057 { 3058 pAnchorMarker = new SwAnchorMarker( pHdl ); 3059 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 3060 return; 3061 } 3062 else 3063 { 3064 sal_Bool bUnLockView = !rSh.IsViewLocked(); 3065 rSh.LockView( sal_True ); 3066 sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0; 3067 if( rMEvt.IsMod1() ) 3068 nFlag = nFlag | SW_ENTER_GROUP; 3069 3070 if ( rSh.IsSelFrmMode() ) 3071 { 3072 rSh.UnSelectFrm(); 3073 rSh.LeaveSelFrmMode(); 3074 rView.AttrChangedNotify(&rSh); 3075 } 3076 3077 sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag ); 3078 if( bUnLockView ) 3079 rSh.LockView( sal_False ); 3080 3081 if( !bSelObj ) 3082 { 3083 // Cursor hier umsetzen, damit er nicht zuerst 3084 // im Rahmen gezeichnet wird; ShowCrsr() geschieht 3085 // in LeaveSelFrmMode() 3086 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False)); 3087 rSh.LeaveSelFrmMode(); 3088 rView.AttrChangedNotify( &rSh ); 3089 bCallBase = sal_False; 3090 } 3091 else 3092 { 3093 rSh.HideCrsr(); 3094 rSh.EnterSelFrmMode( &aDocPos ); 3095 rSh.SelFlyGrabCrsr(); 3096 rSh.MakeSelVisible(); 3097 bFrmDrag = sal_True; 3098 if( rSh.IsFrmSelected() && 3099 rView.GetDrawFuncPtr() ) 3100 { 3101 rView.GetDrawFuncPtr()->Deactivate(); 3102 rView.SetDrawFuncPtr(NULL); 3103 rView.LeaveDrawCreate(); 3104 rView.AttrChangedNotify( &rSh ); 3105 } 3106 UpdatePointer( aDocPos, rMEvt.GetModifier() ); 3107 return; 3108 } 3109 } 3110 } 3111 3112 break; 3113 } 3114 case 2: 3115 { 3116 bFrmDrag = sal_False; 3117 if ( !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) && 3118 0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) ) 3119 3120 /* 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) 3121 on the other hand the return value is used in a switch without proper masking (very nice), this must lead to trouble 3122 */ 3123 switch ( rSh.GetSelectionType() &~ ( nsSelectionType::SEL_FONTWORK | nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE ) ) 3124 { 3125 case nsSelectionType::SEL_GRF: 3126 RstMBDownFlags(); 3127 GetView().GetViewFrame()->GetBindings().Execute( 3128 FN_FORMAT_GRAFIC_DLG, 0, 0, 3129 SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT); 3130 return; 3131 3132 // Doppelklick auf OLE-Objekt --> OLE-InPlace 3133 case nsSelectionType::SEL_OLE: 3134 if (!rSh.IsSelObjProtected(FLYPROTECT_CONTENT)) 3135 { 3136 RstMBDownFlags(); 3137 rSh.LaunchOLEObj(); 3138 } 3139 return; 3140 3141 case nsSelectionType::SEL_FRM: 3142 RstMBDownFlags(); 3143 GetView().GetViewFrame()->GetBindings().Execute( 3144 FN_FORMAT_FRAME_DLG, 0, 0, SFX_CALLMODE_RECORD|SFX_CALLMODE_SLOT); 3145 return; 3146 3147 case nsSelectionType::SEL_DRW: 3148 RstMBDownFlags(); 3149 EnterDrawTextMode(aDocPos); 3150 if ( rView.GetCurShell()->ISA(SwDrawTextShell) ) 3151 ((SwDrawTextShell*)rView.GetCurShell())->Init(); 3152 return; 3153 } 3154 3155 //falls die Cursorposition korrigiert wurde oder 3156 // ein Fly im ReadOnlyModus selektiert ist, 3157 //keine Wortselektion. 3158 if ( !bValidCrsrPos || 3159 (rSh.IsFrmSelected() && rSh.IsFrmSelected() )) 3160 return; 3161 3162 SwField *pFld; 3163 sal_Bool bFtn = sal_False; 3164 3165 if( !bIsDocReadOnly && 3166 ( 0 != ( pFld = rSh.GetCurFld() ) || 3167 0 != ( bFtn = rSh.GetCurFtn() )) ) 3168 { 3169 RstMBDownFlags(); 3170 if( bFtn ) 3171 GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE ); 3172 else 3173 { 3174 sal_uInt16 nTypeId = pFld->GetTypeId(); 3175 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 3176 switch( nTypeId ) 3177 { 3178 case TYP_POSTITFLD: 3179 case TYP_SCRIPTFLD: 3180 { 3181 //falls es ein Readonly-Bereich ist, dann muss der Status 3182 //enabled werden 3183 sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT; 3184 SfxBoolItem aItem(nSlot, sal_True); 3185 pVFrame->GetBindings().SetState(aItem); 3186 pVFrame->GetBindings().Execute(nSlot); 3187 break; 3188 } 3189 case TYP_AUTHORITY : 3190 pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG); 3191 break; 3192 default: 3193 pVFrame->GetBindings().Execute(FN_EDIT_FIELD); 3194 } 3195 } 3196 return; 3197 } 3198 //im Extended Mode hat Doppel- und 3199 //Dreifachklick keine Auswirkungen. 3200 if ( rSh.IsExtMode() || rSh.IsBlockMode() ) 3201 return; 3202 3203 //Wort selektieren, gfs. Additional Mode 3204 if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() ) 3205 { 3206 rSh.EnterAddMode(); 3207 rSh.SelWrd( &aDocPos ); 3208 rSh.LeaveAddMode(); 3209 } 3210 else 3211 rSh.SelWrd( &aDocPos ); 3212 bHoldSelection = sal_True; 3213 return; 3214 } 3215 case 3: 3216 case 4: 3217 { 3218 bFrmDrag = sal_False; 3219 //im Extended Mode hat Doppel- und 3220 //Dreifachklick keine Auswirkungen. 3221 if ( rSh.IsExtMode() ) 3222 return; 3223 3224 //falls die Cursorposition korrigiert wurde oder 3225 // ein Fly im ReadOnlyModus selektiert ist, 3226 //keine Wortselektion. 3227 if ( !bValidCrsrPos || rSh.IsFrmSelected() ) 3228 return; 3229 3230 //Zeile selektieren, gfs. Additional Mode 3231 const bool bMod = KEY_MOD1 == rMEvt.GetModifier() && 3232 !rSh.IsAddMode(); 3233 3234 if ( bMod ) 3235 rSh.EnterAddMode(); 3236 3237 // --> FME 2004-07-30 #i32329# Enhanced selection 3238 if ( 3 == nNumberOfClicks ) 3239 rSh.SelSentence( &aDocPos ); 3240 else 3241 rSh.SelPara( &aDocPos ); 3242 // <-- 3243 3244 if ( bMod ) 3245 rSh.LeaveAddMode(); 3246 3247 bHoldSelection = sal_True; 3248 return; 3249 } 3250 3251 default: 3252 return; 3253 } 3254 /* no break */ 3255 case MOUSE_LEFT + KEY_SHIFT: 3256 case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1: 3257 { 3258 sal_Bool bLockView = bWasShdwCrsr; 3259 3260 switch ( rMEvt.GetModifier() ) 3261 { 3262 case KEY_MOD1 + KEY_SHIFT: 3263 { 3264 if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) ) 3265 { 3266 rView.NoRotate(); 3267 rSh.HideCrsr(); 3268 if ( rSh.IsSelFrmMode() ) 3269 rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP); 3270 else 3271 { if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) ) 3272 { 3273 rSh.EnterSelFrmMode( &aDocPos ); 3274 SwEditWin::nDDStartPosY = aDocPos.Y(); 3275 SwEditWin::nDDStartPosX = aDocPos.X(); 3276 bFrmDrag = sal_True; 3277 return; 3278 } 3279 } 3280 } 3281 else if( rSh.IsSelFrmMode() && 3282 rSh.GetDrawView()->PickHandle( aDocPos )) 3283 { 3284 bFrmDrag = sal_True; 3285 bNoInterrupt = sal_False; 3286 return; 3287 } 3288 } 3289 break; 3290 case KEY_MOD1: 3291 if ( !bExecDrawTextLink ) 3292 { 3293 if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) ) 3294 { 3295 rView.NoRotate(); 3296 rSh.HideCrsr(); 3297 if ( rSh.IsSelFrmMode() ) 3298 rSh.SelectObj(aDocPos, SW_ENTER_GROUP); 3299 else 3300 { if ( rSh.SelectObj( aDocPos, SW_ENTER_GROUP ) ) 3301 { 3302 rSh.EnterSelFrmMode( &aDocPos ); 3303 SwEditWin::nDDStartPosY = aDocPos.Y(); 3304 SwEditWin::nDDStartPosX = aDocPos.X(); 3305 bFrmDrag = sal_True; 3306 return; 3307 } 3308 } 3309 } 3310 else if( rSh.IsSelFrmMode() && 3311 rSh.GetDrawView()->PickHandle( aDocPos )) 3312 { 3313 bFrmDrag = sal_True; 3314 bNoInterrupt = sal_False; 3315 return; 3316 } 3317 else 3318 { 3319 if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() ) 3320 { 3321 rSh.PushMode(); 3322 bModePushed = sal_True; 3323 3324 sal_Bool bUnLockView = !rSh.IsViewLocked(); 3325 rSh.LockView( sal_True ); 3326 rSh.EnterAddMode(); 3327 if( bUnLockView ) 3328 rSh.LockView( sal_False ); 3329 } 3330 bCallBase = sal_False; 3331 } 3332 } 3333 break; 3334 case KEY_MOD2: 3335 { 3336 if ( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() ) 3337 { 3338 rSh.PushMode(); 3339 bModePushed = sal_True; 3340 sal_Bool bUnLockView = !rSh.IsViewLocked(); 3341 rSh.LockView( sal_True ); 3342 rSh.EnterBlockMode(); 3343 if( bUnLockView ) 3344 rSh.LockView( sal_False ); 3345 } 3346 bCallBase = sal_False; 3347 } 3348 break; 3349 case KEY_SHIFT: 3350 { 3351 if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) ) 3352 { 3353 rView.NoRotate(); 3354 rSh.HideCrsr(); 3355 if ( rSh.IsSelFrmMode() ) 3356 { 3357 rSh.SelectObj(aDocPos, SW_ADD_SELECT); 3358 3359 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); 3360 if (rMarkList.GetMark(0) == NULL) 3361 { 3362 rSh.LeaveSelFrmMode(); 3363 rView.AttrChangedNotify(&rSh); 3364 bFrmDrag = sal_False; 3365 } 3366 } 3367 else 3368 { if ( rSh.SelectObj( aDocPos ) ) 3369 { 3370 rSh.EnterSelFrmMode( &aDocPos ); 3371 SwEditWin::nDDStartPosY = aDocPos.Y(); 3372 SwEditWin::nDDStartPosX = aDocPos.X(); 3373 bFrmDrag = sal_True; 3374 return; 3375 } 3376 } 3377 } 3378 else 3379 { 3380 if ( rSh.IsSelFrmMode() && 3381 rSh.IsInsideSelectedObj( aDocPos ) ) 3382 { 3383 rSh.EnterSelFrmMode( &aDocPos ); 3384 SwEditWin::nDDStartPosY = aDocPos.Y(); 3385 SwEditWin::nDDStartPosX = aDocPos.X(); 3386 bFrmDrag = sal_True; 3387 return; 3388 } 3389 if ( rSh.IsSelFrmMode() ) 3390 { 3391 rSh.UnSelectFrm(); 3392 rSh.LeaveSelFrmMode(); 3393 rView.AttrChangedNotify(&rSh); 3394 bFrmDrag = sal_False; 3395 } 3396 if ( !rSh.IsExtMode() ) 3397 { 3398 // keine Selection anfangen, wenn in ein URL- 3399 // Feld oder eine -Grafik geklickt wird 3400 sal_Bool bSttSelect = rSh.HasSelection() || 3401 Pointer(POINTER_REFHAND) != GetPointer(); 3402 3403 if( !bSttSelect ) 3404 { 3405 bSttSelect = sal_True; 3406 if( bExecHyperlinks ) 3407 { 3408 SwContentAtPos aCntntAtPos( 3409 SwContentAtPos::SW_FTN | 3410 SwContentAtPos::SW_INETATTR ); 3411 3412 if( rSh.GetContentAtPos( aDocPos, aCntntAtPos ) ) 3413 { 3414 if( !rSh.IsViewLocked() && 3415 !rSh.IsReadOnlyAvailable() && 3416 aCntntAtPos.IsInProtectSect() ) 3417 bLockView = sal_True; 3418 3419 bSttSelect = sal_False; 3420 } 3421 else if( rSh.IsURLGrfAtPos( aDocPos )) 3422 bSttSelect = sal_False; 3423 } 3424 } 3425 3426 if( bSttSelect ) 3427 rSh.SttSelect(); 3428 } 3429 } 3430 bCallBase = sal_False; 3431 break; 3432 } 3433 default: 3434 if( !rSh.IsViewLocked() ) 3435 { 3436 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD | 3437 SwContentAtPos::SW_INETATTR ); 3438 if( rSh.GetContentAtPos( aDocPos, aCntntAtPos, sal_False ) && 3439 !rSh.IsReadOnlyAvailable() && 3440 aCntntAtPos.IsInProtectSect() ) 3441 bLockView = sal_True; 3442 } 3443 } 3444 3445 if ( rSh.IsGCAttr() ) 3446 { 3447 rSh.GCAttr(); 3448 rSh.ClearGCAttr(); 3449 } 3450 3451 sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False; 3452 if( !bOverSelect ) 3453 bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos ); 3454 3455 if ( !bOverSelect ) 3456 { 3457 const sal_Bool bTmpNoInterrupt = bNoInterrupt; 3458 bNoInterrupt = sal_False; 3459 3460 if( !rSh.IsViewLocked() && bLockView ) 3461 rSh.LockView( sal_True ); 3462 else 3463 bLockView = sal_False; 3464 3465 int nTmpSetCrsr = 0; 3466 3467 { // nur temp. Move-Kontext aufspannen, da sonst die 3468 // Abfrage auf die Inhaltsform nicht funktioniert!!! 3469 MV_KONTEXT( &rSh ); 3470 nTmpSetCrsr = (rSh.*rSh.fnSetCrsr)(&aDocPos,bOnlyText); 3471 bValidCrsrPos = !(CRSR_POSCHG & nTmpSetCrsr); 3472 bCallBase = sal_False; 3473 } 3474 3475 //#i42732# - notify the edit window that from now on we do not use the input language 3476 if ( !(CRSR_POSOLD & nTmpSetCrsr) ) 3477 SetUseInputLanguage( sal_False ); 3478 3479 if( bLockView ) 3480 rSh.LockView( sal_False ); 3481 3482 bNoInterrupt = bTmpNoInterrupt; 3483 } 3484 if ( !bOverURLGrf && !bOnlyText ) 3485 { 3486 const int nSelType = rSh.GetSelectionType(); 3487 // --> OD 2009-12-30 #i89920# 3488 // Check in general, if an object is selectable at given position. 3489 // Thus, also text fly frames in background become selectable via Ctrl-Click. 3490 if ( nSelType & nsSelectionType::SEL_OLE || 3491 nSelType & nsSelectionType::SEL_GRF || 3492 rSh.IsObjSelectable( aDocPos ) ) 3493 // <-- 3494 { 3495 MV_KONTEXT( &rSh ); 3496 if( !rSh.IsFrmSelected() ) 3497 rSh.GotoNextFly(); 3498 rSh.EnterSelFrmMode(); 3499 bCallBase = sal_False; 3500 } 3501 } 3502 // nicht mehr hier zuruecksetzen, damit -- falls durch MouseMove 3503 // bei gedrueckter Ctrl-Taste eine Mehrfachselektion erfolgen soll, 3504 // im Drag nicht die vorherige Selektion aufgehoben wird. 3505 // if(bModePushed) 3506 // rSh.PopMode(sal_False); 3507 break; 3508 } 3509 } 3510 } 3511 if (bCallBase) 3512 Window::MouseButtonDown(rMEvt); 3513 } 3514 3515 /*-------------------------------------------------------------------- 3516 Beschreibung: MouseMove 3517 --------------------------------------------------------------------*/ 3518 3519 3520 void SwEditWin::MouseMove(const MouseEvent& _rMEvt) 3521 { 3522 MouseEvent rMEvt(_rMEvt); 3523 3524 //ignore key modifiers for format paintbrush 3525 { 3526 sal_Bool bExecFormatPaintbrush = pApplyTempl && pApplyTempl->pFormatClipboard 3527 && pApplyTempl->pFormatClipboard->HasContent(); 3528 if( bExecFormatPaintbrush ) 3529 rMEvt = MouseEvent( _rMEvt.GetPosPixel(), _rMEvt.GetClicks(), 3530 _rMEvt.GetMode(), _rMEvt.GetButtons() ); 3531 } 3532 3533 // solange eine Action laeuft sollte das MouseMove abgeklemmt sein 3534 // Ansonsten gibt es den Bug 40102 3535 SwWrtShell &rSh = rView.GetWrtShell(); 3536 if( rSh.ActionPend() ) 3537 return ; 3538 3539 if( pShadCrsr && 0 != (rMEvt.GetModifier() + rMEvt.GetButtons() ) ) 3540 delete pShadCrsr, pShadCrsr = 0; 3541 3542 sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly(); 3543 3544 SET_CURR_SHELL( &rSh ); 3545 3546 //aPixPt == Point in Pixel, rel. zu ChildWin 3547 //aDocPt == Point in Twips, Dokumentkoordinaten 3548 const Point aPixPt( rMEvt.GetPosPixel() ); 3549 const Point aDocPt( PixelToLogic( aPixPt ) ); 3550 3551 if ( IsChainMode() ) 3552 { 3553 UpdatePointer( aDocPt, rMEvt.GetModifier() ); 3554 if ( rMEvt.IsLeaveWindow() ) 3555 rView.GetViewFrame()->HideStatusText(); 3556 return; 3557 } 3558 3559 SdrView *pSdrView = rSh.GetDrawView(); 3560 3561 const SwCallMouseEvent aLastCallEvent( aSaveCallEvent ); 3562 aSaveCallEvent.Clear(); 3563 3564 if ( !bIsDocReadOnly && pSdrView && pSdrView->MouseMove(rMEvt,this) ) 3565 { 3566 SetPointer( POINTER_TEXT ); 3567 return; // Event von der SdrView ausgewertet 3568 } 3569 3570 const Point aOldPt( rSh.VisArea().Pos() ); 3571 #ifdef TEST_FOR_BUG91313 3572 // n Pixel as FUZZY border 3573 SwRect aVis( rSh.VisArea() ); 3574 Size aFuzzySz( 2, 2 ); 3575 aFuzzySz = PixelToLogic( aFuzzySz ); 3576 3577 aVis.Top( aVis.Top() + aFuzzySz.Height() ); 3578 aVis.Bottom( aVis.Bottom() - aFuzzySz.Height() ); 3579 aVis.Left( aVis.Left() + aFuzzySz.Width() ); 3580 aVis.Right( aVis.Right() - aFuzzySz.Width() ); 3581 const sal_Bool bInsWin = aVis.IsInside( aDocPt ); 3582 #else 3583 const sal_Bool bInsWin = rSh.VisArea().IsInside( aDocPt ); 3584 #endif 3585 3586 if( pShadCrsr && !bInsWin ) 3587 delete pShadCrsr, pShadCrsr = 0; 3588 3589 if( bInsWin && pRowColumnSelectionStart ) 3590 { 3591 EnterArea(); 3592 Point aPos( aDocPt ); 3593 if( rSh.SelectTableRowCol( *pRowColumnSelectionStart, &aPos, bIsRowDrag )) 3594 return; 3595 } 3596 3597 // Position ist noetig fuer OS/2, da dort nach einem MB-Down 3598 // offensichtlich sofort ein MB-Move gerufen wird. 3599 if( bDDTimerStarted ) 3600 { 3601 Point aDD( SwEditWin::nDDStartPosX, SwEditWin::nDDStartPosY ); 3602 aDD = LogicToPixel( aDD ); 3603 Rectangle aRect( aDD.X()-3, aDD.Y()-3, aDD.X()+3, aDD.Y()+3 ); 3604 if ( !aRect.IsInside( aPixPt ) ) // MA 23. May. 95: Tatterschutz. 3605 StopDDTimer( &rSh, aDocPt ); 3606 } 3607 3608 if(rView.GetDrawFuncPtr()) 3609 { 3610 if( bInsDraw ) 3611 { 3612 rView.GetDrawFuncPtr()->MouseMove( rMEvt ); 3613 if ( !bInsWin ) 3614 { 3615 Point aTmp( aDocPt ); 3616 aTmp += rSh.VisArea().Pos() - aOldPt; 3617 LeaveArea( aTmp ); 3618 } 3619 else 3620 EnterArea(); 3621 return; 3622 } 3623 else if(!rSh.IsFrmSelected() && !rSh.IsObjSelected()) 3624 { 3625 SfxBindings &rBnd = rSh.GetView().GetViewFrame()->GetBindings(); 3626 Point aRelPos = rSh.GetRelativePagePosition(aDocPt); 3627 if(aRelPos.X() >= 0) 3628 { 3629 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView())); 3630 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); 3631 const SfxPointItem aTmp1( SID_ATTR_POSITION, aRelPos ); 3632 rBnd.SetState( aTmp1 ); 3633 } 3634 else 3635 { 3636 rBnd.Invalidate(SID_ATTR_POSITION); 3637 } 3638 rBnd.Invalidate(SID_ATTR_SIZE); 3639 const SfxStringItem aCell( SID_TABLE_CELL, aEmptyStr ); 3640 rBnd.SetState( aCell ); 3641 } 3642 } 3643 3644 sal_uInt8 nMouseTabCol; 3645 if( !bIsDocReadOnly && bInsWin && !pApplyTempl && !rSh.IsInSelect() ) 3646 { 3647 if ( SW_TABCOL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) && 3648 !rSh.IsObjSelectable( aDocPt ) ) 3649 { 3650 sal_uInt16 nPointer = USHRT_MAX; 3651 bool bChkTblSel = false; 3652 3653 switch ( nMouseTabCol ) 3654 { 3655 case SW_TABCOL_VERT : 3656 case SW_TABROW_HORI : 3657 nPointer = POINTER_VSIZEBAR; 3658 bChkTblSel = true; 3659 break; 3660 case SW_TABROW_VERT : 3661 case SW_TABCOL_HORI : 3662 nPointer = POINTER_HSIZEBAR; 3663 bChkTblSel = true; 3664 break; 3665 // --> FME 2004-07-30 #i20126# Enhanced table selection 3666 case SW_TABSEL_HORI : 3667 nPointer = POINTER_TAB_SELECT_SE; 3668 break; 3669 case SW_TABSEL_HORI_RTL : 3670 case SW_TABSEL_VERT : 3671 nPointer = POINTER_TAB_SELECT_SW; 3672 break; 3673 case SW_TABCOLSEL_HORI : 3674 case SW_TABROWSEL_VERT : 3675 nPointer = POINTER_TAB_SELECT_S; 3676 break; 3677 case SW_TABROWSEL_HORI : 3678 nPointer = POINTER_TAB_SELECT_E; 3679 break; 3680 case SW_TABROWSEL_HORI_RTL : 3681 case SW_TABCOLSEL_VERT : 3682 nPointer = POINTER_TAB_SELECT_W; 3683 break; 3684 // <-- 3685 } 3686 3687 if ( USHRT_MAX != nPointer && 3688 // --> FME 2004-10-20 #i35543# 3689 // Enhanced table selection is explicitely allowed in table mode 3690 ( !bChkTblSel || !rSh.IsTableMode() ) ) 3691 // <-- 3692 { 3693 SetPointer( nPointer ); 3694 } 3695 3696 return; 3697 } 3698 // #i23726# 3699 else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH)) 3700 { 3701 // --> OD 2005-02-21 #i42921# - consider vertical mode 3702 SwTxtNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt ); 3703 const sal_uInt16 nPointer = 3704 rSh.IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt ) 3705 ? POINTER_VSIZEBAR 3706 : POINTER_HSIZEBAR; 3707 SetPointer( nPointer ); 3708 // <-- 3709 3710 return; 3711 } 3712 } 3713 3714 sal_Bool bDelShadCrsr = sal_True; 3715 3716 switch ( rMEvt.GetModifier() + rMEvt.GetButtons() ) 3717 { 3718 case MOUSE_LEFT: 3719 if( pAnchorMarker ) 3720 { 3721 // Now we need to refresh the SdrHdl pointer of pAnchorMarker. 3722 // This looks a little bit tricky, but it solves the following 3723 // problem: the pAnchorMarker contains a pointer to an SdrHdl, 3724 // if the FindAnchorPos-call cause a scrolling of the visible 3725 // area, it's possible that the SdrHdl will be destroyed and a 3726 // new one will initialized at the original position(GetHdlPos). 3727 // So the pAnchorMarker has to find the right SdrHdl, if it's 3728 // the old one, it will find it with position aOld, if this one 3729 // is destroyed, it will find a new one at position GetHdlPos(). 3730 // --> OD 2010-09-16 #i114522# 3731 // const Point aOld = pAnchorMarker->GetPos(); 3732 const Point aOld = pAnchorMarker->GetPosForHitTest( *(rSh.GetOut()) ); 3733 // <-- 3734 Point aNew = rSh.FindAnchorPos( aDocPt ); 3735 SdrHdl* pHdl; 3736 if( (0!=( pHdl = pSdrView->PickHandle( aOld ) )|| 3737 0 !=(pHdl = pSdrView->PickHandle( pAnchorMarker->GetHdlPos()) ) ) && 3738 ( pHdl->GetKind() == HDL_ANCHOR || 3739 pHdl->GetKind() == HDL_ANCHOR_TR ) ) 3740 { 3741 pAnchorMarker->ChgHdl( pHdl ); 3742 if( aNew.X() || aNew.Y() ) 3743 { 3744 pAnchorMarker->SetPos( aNew ); 3745 pAnchorMarker->SetLastPos( aDocPt ); 3746 //OLMpSdrView->RefreshAllIAOManagers(); 3747 } 3748 } 3749 else 3750 { 3751 delete pAnchorMarker; 3752 pAnchorMarker = NULL; 3753 } 3754 } 3755 if ( bInsDraw ) 3756 { 3757 if ( !bMBPressed ) 3758 break; 3759 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) ) 3760 { 3761 if ( !bInsWin ) 3762 LeaveArea( aDocPt ); 3763 else 3764 EnterArea(); 3765 if ( rView.GetDrawFuncPtr() ) 3766 { 3767 pSdrView->SetOrtho(sal_False); 3768 rView.GetDrawFuncPtr()->MouseMove( rMEvt ); 3769 } 3770 bIsInMove = sal_True; 3771 } 3772 return; 3773 } 3774 case MOUSE_LEFT + KEY_SHIFT: 3775 case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1: 3776 if ( !bMBPressed ) 3777 break; 3778 case MOUSE_LEFT + KEY_MOD1: 3779 if ( bFrmDrag && rSh.IsSelFrmMode() ) 3780 { 3781 if( !bMBPressed ) 3782 break; 3783 3784 if ( bIsInMove || IsMinMove( aStartPos, aPixPt ) ) 3785 { 3786 // Event-Verarbeitung fuers Resizen 3787 if( pSdrView->AreObjectsMarked() ) 3788 { 3789 const SwFrmFmt* pFlyFmt; 3790 const SvxMacro* pMacro; 3791 3792 const Point aSttPt( PixelToLogic( aStartPos ) ); 3793 3794 // geht es los? 3795 if( HDL_USER == eSdrMoveHdl ) 3796 { 3797 SdrHdl* pHdl = pSdrView->PickHandle( aSttPt ); 3798 eSdrMoveHdl = pHdl ? pHdl->GetKind() : HDL_MOVE; 3799 } 3800 3801 sal_uInt16 nEvent = HDL_MOVE == eSdrMoveHdl 3802 ? SW_EVENT_FRM_MOVE 3803 : SW_EVENT_FRM_RESIZE; 3804 3805 if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) && 3806 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable(). 3807 Get( nEvent )) && 3808 // oder nur z.B. alle 20 Twip bescheid sagen? 3809 // ( 20 > Abs( aRszMvHdlPt.X() - aDocPt.X() ) || 3810 // 20 > Abs( aRszMvHdlPt.Y() - aDocPt.Y() ) ) 3811 aRszMvHdlPt != aDocPt ) 3812 { 3813 aRszMvHdlPt = aDocPt; 3814 sal_uInt16 nPos = 0; 3815 String sRet; 3816 SbxArrayRef xArgs = new SbxArray; 3817 SbxVariableRef xVar = new SbxVariable; 3818 xVar->PutString( pFlyFmt->GetName() ); 3819 xArgs->Put( &xVar, ++nPos ); 3820 3821 if( SW_EVENT_FRM_RESIZE == nEvent ) 3822 { 3823 xVar = new SbxVariable; 3824 xVar->PutUShort( static_cast< sal_uInt16 >(eSdrMoveHdl) ); 3825 xArgs->Put( &xVar, ++nPos ); 3826 } 3827 3828 xVar = new SbxVariable; 3829 xVar->PutLong( aDocPt.X() - aSttPt.X() ); 3830 xArgs->Put( &xVar, ++nPos ); 3831 xVar = new SbxVariable; 3832 xVar->PutLong( aDocPt.Y() - aSttPt.Y() ); 3833 xArgs->Put( &xVar, ++nPos ); 3834 3835 ReleaseMouse(); 3836 3837 rSh.ExecMacro( *pMacro, &sRet, &xArgs ); 3838 3839 CaptureMouse(); 3840 3841 if( sRet.Len() && 0 != sRet.ToInt32() ) 3842 return ; 3843 } 3844 } 3845 // Event-Verarbeitung fuers Resizen 3846 3847 if( bIsDocReadOnly ) 3848 break; 3849 3850 if ( rMEvt.IsShift() ) 3851 { 3852 pSdrView->SetOrtho(sal_True); 3853 pSdrView->SetAngleSnapEnabled(sal_True); 3854 } 3855 else 3856 { 3857 pSdrView->SetOrtho(sal_False); 3858 pSdrView->SetAngleSnapEnabled(sal_False); 3859 } 3860 3861 (rSh.*rSh.fnDrag)( &aDocPt, rMEvt.IsShift() ); 3862 bIsInMove = sal_True; 3863 } 3864 else if( bIsDocReadOnly ) 3865 break; 3866 3867 if ( !bInsWin ) 3868 { 3869 Point aTmp( aDocPt ); 3870 aTmp += rSh.VisArea().Pos() - aOldPt; 3871 LeaveArea( aTmp ); 3872 } 3873 else if(bIsInMove) 3874 EnterArea(); 3875 return; 3876 } 3877 if ( !rSh.IsSelFrmMode() && !bDDINetAttr && 3878 (IsMinMove( aStartPos,aPixPt ) || bIsInMove) && 3879 (rSh.IsInSelect() || !rSh.ChgCurrPam( aDocPt )) ) 3880 { 3881 if ( pSdrView ) 3882 { 3883 if ( rMEvt.IsShift() ) 3884 pSdrView->SetOrtho(sal_True); 3885 else 3886 pSdrView->SetOrtho(sal_False); 3887 } 3888 if ( !bInsWin ) 3889 { 3890 Point aTmp( aDocPt ); 3891 aTmp += rSh.VisArea().Pos() - aOldPt; 3892 LeaveArea( aTmp ); 3893 } 3894 else 3895 { 3896 //JP 24.09.98: Fix fuer die Bugs 55592 / 55931 3897 //JP 23.04.99: Fix fuer den Bugs 65289 3898 //JP 06.07.99: Fix fuer den Bugs 67360 3899 if( !rMEvt.IsSynthetic() && 3900 !(( MOUSE_LEFT + KEY_MOD1 == 3901 rMEvt.GetModifier() + rMEvt.GetButtons() ) && 3902 rSh.Is_FnDragEQBeginDrag() && !rSh.IsAddMode() )) 3903 { 3904 (rSh.*rSh.fnDrag)( &aDocPt,sal_False ); 3905 3906 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,sal_False)); 3907 EnterArea(); 3908 } 3909 } 3910 } 3911 bDDINetAttr = sal_False; 3912 break; 3913 case 0: 3914 { 3915 if ( pApplyTempl ) 3916 { 3917 UpdatePointer(aDocPt, 0); // evtl. muss hier ein Rahmen markiert werden 3918 break; 3919 } 3920 //#i6193#, change ui if mouse is over SwPostItField 3921 // TODO: do the same thing for redlines SW_REDLINE 3922 SwRect aFldRect; 3923 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD); 3924 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_False, &aFldRect ) ) 3925 { 3926 const SwField* pFld = aCntntAtPos.aFnd.pFld; 3927 if (pFld->Which()== RES_POSTITFLD) 3928 { 3929 rView.GetPostItMgr()->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld),false); 3930 } 3931 else 3932 rView.GetPostItMgr()->SetShadowState(0,false); 3933 } 3934 else 3935 rView.GetPostItMgr()->SetShadowState(0,false); 3936 // no break; 3937 } 3938 case KEY_SHIFT: 3939 case KEY_MOD2: 3940 case KEY_MOD1: 3941 if ( !bInsDraw ) 3942 { 3943 sal_Bool bTstShdwCrsr = sal_True; 3944 3945 UpdatePointer( aDocPt, rMEvt.GetModifier() ); 3946 3947 const SwFrmFmt* pFmt = 0; 3948 const SwFmtINetFmt* pINet = 0; 3949 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR ); 3950 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos ) ) 3951 pINet = (SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr; 3952 3953 const void* pTmp = pINet; 3954 3955 if( pINet || 3956 0 != ( pTmp = pFmt = rSh.GetFmtFromAnyObj( aDocPt ))) 3957 { 3958 bTstShdwCrsr = sal_False; 3959 if( pTmp == pINet ) 3960 aSaveCallEvent.Set( pINet ); 3961 else 3962 { 3963 IMapObject* pIMapObj = pFmt->GetIMapObject( aDocPt ); 3964 if( pIMapObj ) 3965 aSaveCallEvent.Set( pFmt, pIMapObj ); 3966 else 3967 aSaveCallEvent.Set( EVENT_OBJECT_URLITEM, pFmt ); 3968 } 3969 3970 // sollte wir ueber einem InternetFeld mit einem 3971 // gebundenen Macro stehen? 3972 if( aSaveCallEvent != aLastCallEvent ) 3973 { 3974 if( aLastCallEvent.HasEvent() ) 3975 rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT, 3976 aLastCallEvent, sal_True ); 3977 // 0 besagt, das das Object gar keine Tabelle hat 3978 if( !rSh.CallEvent( SFX_EVENT_MOUSEOVER_OBJECT, 3979 aSaveCallEvent )) 3980 aSaveCallEvent.Clear(); 3981 } 3982 } 3983 else if( aLastCallEvent.HasEvent() ) 3984 { 3985 // Cursor stand auf einem Object 3986 rSh.CallEvent( SFX_EVENT_MOUSEOUT_OBJECT, 3987 aLastCallEvent, sal_True ); 3988 } 3989 3990 if( bTstShdwCrsr && bInsWin && !bIsDocReadOnly && 3991 !bInsFrm && 3992 !rSh.GetViewOptions()->getBrowseMode() && 3993 rSh.GetViewOptions()->IsShadowCursor() && 3994 !(rMEvt.GetModifier() + rMEvt.GetButtons()) && 3995 !rSh.HasSelection() && !GetConnectMetaFile() ) 3996 { 3997 SwRect aRect; 3998 sal_Int16 eOrient; 3999 SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode(); 4000 if( rSh.GetShadowCrsrPos( aDocPt, eMode, aRect, eOrient )) 4001 { 4002 if( !pShadCrsr ) 4003 pShadCrsr = new SwShadowCursor( *this, 4004 SwViewOption::GetDirectCursorColor() ); 4005 if( text::HoriOrientation::RIGHT != eOrient && text::HoriOrientation::CENTER != eOrient ) 4006 eOrient = text::HoriOrientation::LEFT; 4007 pShadCrsr->SetPos( aRect.Pos(), aRect.Height(), static_cast< sal_uInt16 >(eOrient) ); 4008 bDelShadCrsr = sal_False; 4009 } 4010 } 4011 } 4012 break; 4013 case MOUSE_LEFT + KEY_MOD2: 4014 if( rSh.IsBlockMode() && !rMEvt.IsSynthetic() ) 4015 { 4016 (rSh.*rSh.fnDrag)( &aDocPt,sal_False ); 4017 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPt,sal_False)); 4018 EnterArea(); 4019 } 4020 break; 4021 } 4022 4023 if( bDelShadCrsr && pShadCrsr ) 4024 delete pShadCrsr, pShadCrsr = 0; 4025 bWasShdwCrsr = sal_False; 4026 } 4027 4028 /*-------------------------------------------------------------------- 4029 Beschreibung: Button Up 4030 --------------------------------------------------------------------*/ 4031 4032 4033 void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) 4034 { 4035 sal_Bool bCallBase = sal_True; 4036 4037 sal_Bool bCallShadowCrsr = bWasShdwCrsr; 4038 bWasShdwCrsr = sal_False; 4039 if( pShadCrsr ) 4040 delete pShadCrsr, pShadCrsr = 0; 4041 4042 if( pRowColumnSelectionStart ) 4043 DELETEZ( pRowColumnSelectionStart ); 4044 4045 SdrHdlKind eOldSdrMoveHdl = eSdrMoveHdl; 4046 eSdrMoveHdl = HDL_USER; // fuer die MoveEvents - wieder zuruecksetzen 4047 4048 // sicherheitshalber zuruecksetzen Bug 27900 4049 rView.SetTabColFromDoc( sal_False ); 4050 rView.SetNumRuleNodeFromDoc(NULL); 4051 4052 SwWrtShell &rSh = rView.GetWrtShell(); 4053 SET_CURR_SHELL( &rSh ); 4054 SdrView *pSdrView = rSh.GetDrawView(); 4055 if ( pSdrView ) 4056 { 4057 pSdrView->SetOrtho(sal_False); 4058 4059 if ( pSdrView->MouseButtonUp( rMEvt,this ) ) 4060 { 4061 rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 4062 return; // Event von der SdrView ausgewertet 4063 } 4064 } 4065 //MouseButtonUp nur bearbeiten, wenn auch das Down an dieses Fenster ging. 4066 if ( !bMBPressed ) 4067 { 4068 // OS 25.02.97 Undo fuer die Giesskann ist bereits im CommandHdl 4069 //JP 29.09.95: so sollte es sein!!! if(pApplyTempl->bUndo) 4070 // if( pApplyTempl && MOUSE_RIGHT == rMEvt.GetModifier() + rMEvt.GetButtons() ) 4071 // rSh.Do( SwWrtShell::UNDO ); 4072 return; 4073 } 4074 4075 Point aDocPt( PixelToLogic( rMEvt.GetPosPixel() ) ); 4076 4077 if ( bDDTimerStarted ) 4078 { 4079 StopDDTimer( &rSh, aDocPt ); 4080 bMBPressed = sal_False; 4081 if ( rSh.IsSelFrmMode() ) 4082 { 4083 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False ); 4084 bFrmDrag = sal_False; 4085 } 4086 bNoInterrupt = sal_False; 4087 ReleaseMouse(); 4088 return; 4089 } 4090 4091 if( pAnchorMarker ) 4092 { 4093 if(pAnchorMarker->GetHdl()) 4094 { 4095 // #121463# delete selected after drag 4096 pAnchorMarker->GetHdl()->SetSelected(false); 4097 } 4098 4099 Point aPnt( pAnchorMarker->GetLastPos() ); 4100 //OLMpSdrView->RefreshAllIAOManagers(); 4101 DELETEZ( pAnchorMarker ); 4102 if( aPnt.X() || aPnt.Y() ) 4103 rSh.FindAnchorPos( aPnt, sal_True ); 4104 } 4105 if ( bInsDraw && rView.GetDrawFuncPtr() ) 4106 { 4107 if ( rView.GetDrawFuncPtr()->MouseButtonUp( rMEvt ) ) 4108 { 4109 if (rView.GetDrawFuncPtr()) // Koennte im MouseButtonUp zerstoert worden sein 4110 { 4111 rView.GetDrawFuncPtr()->Deactivate(); 4112 4113 if (!rView.IsDrawMode()) 4114 { 4115 rView.SetDrawFuncPtr(NULL); 4116 SfxBindings& rBind = rView.GetViewFrame()->GetBindings(); 4117 rBind.Invalidate( SID_ATTR_SIZE ); 4118 rBind.Invalidate( SID_TABLE_CELL ); 4119 } 4120 } 4121 4122 if ( rSh.IsObjSelected() ) 4123 { 4124 rSh.EnterSelFrmMode(); 4125 if (!rView.GetDrawFuncPtr()) 4126 StdDrawMode( OBJ_NONE, sal_True ); 4127 } 4128 else if ( rSh.IsFrmSelected() ) 4129 { 4130 rSh.EnterSelFrmMode(); 4131 StopInsFrm(); 4132 } 4133 else 4134 { 4135 const Point aDocPos( PixelToLogic( aStartPos ) ); 4136 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False)); 4137 rSh.Edit(); 4138 } 4139 4140 rView.AttrChangedNotify( &rSh ); 4141 } 4142 else if (rMEvt.GetButtons() == MOUSE_RIGHT && rSh.IsDrawCreate()) 4143 rView.GetDrawFuncPtr()->BreakCreate(); // Zeichnen abbrechen 4144 4145 bNoInterrupt = sal_False; 4146 ReleaseMouse(); 4147 return; 4148 } 4149 sal_Bool bPopMode = sal_False; 4150 switch ( rMEvt.GetModifier() + rMEvt.GetButtons() ) 4151 { 4152 case MOUSE_LEFT: 4153 if ( bInsDraw && rSh.IsDrawCreate() ) 4154 { 4155 if ( rView.GetDrawFuncPtr() && rView.GetDrawFuncPtr()->MouseButtonUp(rMEvt) == sal_True ) 4156 { 4157 rView.GetDrawFuncPtr()->Deactivate(); 4158 rView.AttrChangedNotify( &rSh ); 4159 if ( rSh.IsObjSelected() ) 4160 rSh.EnterSelFrmMode(); 4161 if ( rView.GetDrawFuncPtr() && bInsFrm ) 4162 StopInsFrm(); 4163 } 4164 bCallBase = sal_False; 4165 break; 4166 } 4167 case MOUSE_LEFT + KEY_MOD1: 4168 case MOUSE_LEFT + KEY_MOD2: 4169 case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1: 4170 if ( bFrmDrag && rSh.IsSelFrmMode() ) 4171 { 4172 if ( rMEvt.IsMod1() ) //Kopieren und nicht moven. 4173 { 4174 //Drag abbrechen, statt dessen internes Copy verwenden 4175 Rectangle aRect; 4176 rSh.GetDrawView()->TakeActionRect( aRect ); 4177 if (!aRect.IsEmpty()) 4178 { 4179 rSh.BreakDrag(); 4180 Point aEndPt, aSttPt; 4181 if ( rSh.GetSelFrmType() & FRMTYPE_FLY_ATCNT ) 4182 { 4183 aEndPt = aRect.TopLeft(); 4184 aSttPt = rSh.GetDrawView()->GetAllMarkedRect().TopLeft(); 4185 } 4186 else 4187 { 4188 aEndPt = aRect.Center(); 4189 aSttPt = rSh.GetDrawView()->GetAllMarkedRect().Center(); 4190 } 4191 if ( aSttPt != aEndPt ) 4192 { 4193 rSh.StartUndo( UNDO_UI_DRAG_AND_COPY ); 4194 rSh.Copy(&rSh, aSttPt, aEndPt, sal_False); 4195 rSh.EndUndo( UNDO_UI_DRAG_AND_COPY ); 4196 } 4197 } 4198 else 4199 (rSh.*rSh.fnEndDrag)( &aDocPt,sal_False ); 4200 } 4201 else 4202 { 4203 { 4204 const SwFrmFmt* pFlyFmt; 4205 const SvxMacro* pMacro; 4206 4207 sal_uInt16 nEvent = HDL_MOVE == eOldSdrMoveHdl 4208 ? SW_EVENT_FRM_MOVE 4209 : SW_EVENT_FRM_RESIZE; 4210 4211 if( 0 != ( pFlyFmt = rSh.GetFlyFrmFmt() ) && 4212 0 != ( pMacro = pFlyFmt->GetMacro().GetMacroTable(). 4213 Get( nEvent )) ) 4214 { 4215 const Point aSttPt( PixelToLogic( aStartPos ) ); 4216 aRszMvHdlPt = aDocPt; 4217 sal_uInt16 nPos = 0; 4218 SbxArrayRef xArgs = new SbxArray; 4219 SbxVariableRef xVar = new SbxVariable; 4220 xVar->PutString( pFlyFmt->GetName() ); 4221 xArgs->Put( &xVar, ++nPos ); 4222 4223 if( SW_EVENT_FRM_RESIZE == nEvent ) 4224 { 4225 xVar = new SbxVariable; 4226 xVar->PutUShort( static_cast< sal_uInt16 >(eOldSdrMoveHdl) ); 4227 xArgs->Put( &xVar, ++nPos ); 4228 } 4229 4230 xVar = new SbxVariable; 4231 xVar->PutLong( aDocPt.X() - aSttPt.X() ); 4232 xArgs->Put( &xVar, ++nPos ); 4233 xVar = new SbxVariable; 4234 xVar->PutLong( aDocPt.Y() - aSttPt.Y() ); 4235 xArgs->Put( &xVar, ++nPos ); 4236 4237 xVar = new SbxVariable; 4238 xVar->PutUShort( 1 ); 4239 xArgs->Put( &xVar, ++nPos ); 4240 4241 ReleaseMouse(); 4242 4243 rSh.ExecMacro( *pMacro, 0, &xArgs ); 4244 4245 CaptureMouse(); 4246 } 4247 } 4248 (rSh.*rSh.fnEndDrag)( &aDocPt,sal_False ); 4249 } 4250 bFrmDrag = sal_False; 4251 bCallBase = sal_False; 4252 break; 4253 } 4254 bPopMode = sal_True; 4255 // no break 4256 case MOUSE_LEFT + KEY_SHIFT: 4257 if (rSh.IsSelFrmMode()) 4258 { 4259 4260 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False ); 4261 bFrmDrag = sal_False; 4262 bCallBase = sal_False; 4263 break; 4264 } 4265 4266 if( bHoldSelection ) 4267 { 4268 //JP 27.04.99: Bug 65389 - das EndDrag sollte auf jedenfall 4269 // gerufen werden. 4270 bHoldSelection = sal_False; 4271 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False ); 4272 } 4273 else 4274 { 4275 if ( !rSh.IsInSelect() && rSh.ChgCurrPam( aDocPt ) ) 4276 { 4277 const sal_Bool bTmpNoInterrupt = bNoInterrupt; 4278 bNoInterrupt = sal_False; 4279 { // nur temp. Move-Kontext aufspannen, da sonst die 4280 // Abfrage auf die Inhaltsform nicht funktioniert!!! 4281 MV_KONTEXT( &rSh ); 4282 const Point aDocPos( PixelToLogic( aStartPos ) ); 4283 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False)); 4284 } 4285 bNoInterrupt = bTmpNoInterrupt; 4286 4287 } 4288 else 4289 { 4290 sal_Bool bInSel = rSh.IsInSelect(); 4291 (rSh.*rSh.fnEndDrag)( &aDocPt, sal_False ); 4292 4293 // Internetfield? --> Link-Callen (DocLaden!!) 4294 //JP 18.10.96: Bug 32437 - 4295 // if( !rSh.HasSelection() ) 4296 if( !bInSel ) 4297 { 4298 sal_uInt16 nFilter = URLLOAD_NOFILTER; 4299 if( KEY_MOD1 == rMEvt.GetModifier() ) 4300 nFilter |= URLLOAD_NEWVIEW; 4301 4302 sal_Bool bExecHyperlinks = rView.GetDocShell()->IsReadOnly(); 4303 if ( !bExecHyperlinks ) 4304 { 4305 SvtSecurityOptions aSecOpts; 4306 const sal_Bool bSecureOption = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK ); 4307 if ( ( bSecureOption && rMEvt.GetModifier() == KEY_MOD1 ) || 4308 ( !bSecureOption && rMEvt.GetModifier() != KEY_MOD1 ) ) 4309 bExecHyperlinks = sal_True; 4310 } 4311 4312 const sal_Bool bExecSmarttags = rMEvt.GetModifier() == KEY_MOD1; 4313 4314 if(pApplyTempl) 4315 bExecHyperlinks = sal_False; 4316 4317 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_CLICKFIELD | 4318 SwContentAtPos::SW_INETATTR | 4319 SwContentAtPos::SW_SMARTTAG | SwContentAtPos::SW_FORMCTRL); 4320 4321 if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) ) 4322 { 4323 sal_Bool bViewLocked = rSh.IsViewLocked(); 4324 if( !bViewLocked && !rSh.IsReadOnlyAvailable() && 4325 aCntntAtPos.IsInProtectSect() ) 4326 rSh.LockView( sal_True ); 4327 4328 ReleaseMouse(); 4329 4330 if( SwContentAtPos::SW_FIELD == aCntntAtPos.eCntntAtPos ) 4331 { 4332 rSh.ClickToField( *aCntntAtPos.aFnd.pFld ); 4333 } 4334 else if ( SwContentAtPos::SW_SMARTTAG == aCntntAtPos.eCntntAtPos ) 4335 { 4336 // execute smarttag menu 4337 if ( bExecSmarttags && SwSmartTagMgr::Get().IsSmartTagsEnabled() ) 4338 rView.ExecSmartTagPopup( aDocPt ); 4339 } 4340 else if ( SwContentAtPos::SW_FORMCTRL == aCntntAtPos.eCntntAtPos ) 4341 { 4342 ASSERT( aCntntAtPos.aFnd.pFldmark != NULL, "where is my field ptr???"); 4343 if ( aCntntAtPos.aFnd.pFldmark != NULL) 4344 { 4345 IFieldmark *fieldBM = const_cast< IFieldmark* > ( aCntntAtPos.aFnd.pFldmark ); 4346 //SwDocShell* pDocSh = rView.GetDocShell(); 4347 //SwDoc *pDoc=pDocSh->GetDoc(); 4348 if (fieldBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) ) 4349 { 4350 ICheckboxFieldmark* pCheckboxFm = dynamic_cast<ICheckboxFieldmark*>(fieldBM); 4351 pCheckboxFm->SetChecked(!pCheckboxFm->IsChecked()); 4352 pCheckboxFm->Invalidate(); 4353 rSh.InvalidateWindows( rView.GetVisArea() ); 4354 } else if (fieldBM->GetFieldname().equalsAscii( ODF_FORMDROPDOWN) ) { 4355 rView.ExecFieldPopup( aDocPt, fieldBM ); 4356 fieldBM->Invalidate(); 4357 rSh.InvalidateWindows( rView.GetVisArea() ); 4358 } else { 4359 // unknown type.. 4360 } 4361 } 4362 } 4363 else // if ( SwContentAtPos::SW_INETATTR == aCntntAtPos.eCntntAtPos ) 4364 { 4365 if ( bExecHyperlinks ) 4366 rSh.ClickToINetAttr( *(SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr, nFilter ); 4367 } 4368 4369 rSh.LockView( bViewLocked ); 4370 bCallShadowCrsr = sal_False; 4371 } 4372 else 4373 { 4374 aCntntAtPos = SwContentAtPos( SwContentAtPos::SW_FTN ); 4375 if( !rSh.GetContentAtPos( aDocPt, aCntntAtPos, sal_True ) && bExecHyperlinks ) 4376 { 4377 SdrViewEvent aVEvt; 4378 4379 if (pSdrView) 4380 pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); 4381 4382 if (pSdrView && aVEvt.eEvent == SDREVENT_EXECUTEURL) 4383 { 4384 // URL-Feld getroffen 4385 const SvxURLField *pField = aVEvt.pURLField; 4386 if (pField) 4387 { 4388 String sURL(pField->GetURL()); 4389 String sTarget(pField->GetTargetFrame()); 4390 ::LoadURL( sURL, &rSh, nFilter, &sTarget); 4391 } 4392 bCallShadowCrsr = sal_False; 4393 } 4394 else 4395 { 4396 // Grafik getroffen 4397 ReleaseMouse(); 4398 if( rSh.ClickToINetGrf( aDocPt, nFilter )) 4399 bCallShadowCrsr = sal_False; 4400 } 4401 } 4402 } 4403 4404 if( bCallShadowCrsr && 4405 rSh.GetViewOptions()->IsShadowCursor() && 4406 MOUSE_LEFT == (rMEvt.GetModifier() + rMEvt.GetButtons()) && 4407 !rSh.HasSelection() && 4408 !GetConnectMetaFile() && 4409 rSh.VisArea().IsInside( aDocPt )) 4410 { 4411 SwUndoId nLastUndoId(UNDO_EMPTY); 4412 if (rSh.GetLastUndoInfo(0, & nLastUndoId)) 4413 { 4414 if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId) 4415 { 4416 rSh.Undo(); 4417 } 4418 } 4419 SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode(); 4420 rSh.SetShadowCrsrPos( aDocPt, eMode ); 4421 } 4422 } 4423 } 4424 bCallBase = sal_False; 4425 4426 } 4427 4428 // gfs. im Down gepushten Mode wieder zuruecksetzen 4429 if ( bPopMode && bModePushed ) 4430 { 4431 rSh.PopMode(); 4432 bModePushed = sal_False; 4433 bCallBase = sal_False; 4434 } 4435 break; 4436 4437 default: 4438 ReleaseMouse(); 4439 return; 4440 } 4441 4442 if( pApplyTempl ) 4443 { 4444 int eSelection = rSh.GetSelectionType(); 4445 SwFormatClipboard* pFormatClipboard = pApplyTempl->pFormatClipboard; 4446 if( pFormatClipboard )//apply format paintbrush 4447 { 4448 //get some parameters 4449 SwWrtShell& rWrtShell = rView.GetWrtShell(); 4450 SfxStyleSheetBasePool* pPool=0; 4451 bool bNoCharacterFormats = false; 4452 bool bNoParagraphFormats = false; 4453 { 4454 SwDocShell* pDocSh = rView.GetDocShell(); 4455 if(pDocSh) 4456 pPool = pDocSh->GetStyleSheetPool(); 4457 if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) ) 4458 bNoCharacterFormats = true; 4459 else if( rMEvt.GetModifier() & KEY_MOD1 ) 4460 bNoParagraphFormats = true; 4461 } 4462 //execute paste 4463 pFormatClipboard->Paste( rWrtShell, pPool, bNoCharacterFormats, bNoParagraphFormats ); 4464 4465 //if the clipboard is empty after paste remove the ApplyTemplate 4466 if(!pFormatClipboard->HasContent()) 4467 SetApplyTemplate(SwApplyTemplate()); 4468 } 4469 else if( pApplyTempl->nColor ) 4470 { 4471 sal_uInt16 nId = 0; 4472 switch( pApplyTempl->nColor ) 4473 { 4474 case SID_ATTR_CHAR_COLOR_EXT: 4475 nId = RES_CHRATR_COLOR; 4476 break; 4477 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: 4478 nId = RES_CHRATR_BACKGROUND; 4479 break; 4480 } 4481 if( nId && (nsSelectionType::SEL_TXT|nsSelectionType::SEL_TBL) & eSelection) 4482 { 4483 if( rSh.IsSelection() && !rSh.HasReadonlySel() ) 4484 { 4485 if(nId == RES_CHRATR_BACKGROUND) 4486 { 4487 Color aColor( COL_TRANSPARENT ); 4488 if( !SwEditWin::bTransparentBackColor ) 4489 aColor = SwEditWin::aTextBackColor; 4490 rSh.SetAttr( SvxBrushItem( aColor, nId ) ); 4491 } 4492 else 4493 rSh.SetAttr( SvxColorItem(SwEditWin::aTextColor, nId) ); 4494 rSh.UnSetVisCrsr(); 4495 rSh.EnterStdMode(); 4496 rSh.SetVisCrsr(aDocPt); 4497 4498 pApplyTempl->bUndo = sal_True; 4499 bCallBase = sal_False; 4500 aTemplateTimer.Stop(); 4501 } 4502 else if(rMEvt.GetClicks() == 1) 4503 { 4504 // keine Selektion -> also Giesskanne abschalten 4505 aTemplateTimer.Start(); 4506 } 4507 } 4508 } 4509 else 4510 { 4511 String aStyleName; 4512 switch ( pApplyTempl->eType ) 4513 { 4514 case SFX_STYLE_FAMILY_PARA: 4515 if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL ) 4516 & eSelection ) && !rSh.HasReadonlySel() ) 4517 { 4518 rSh.SetTxtFmtColl( pApplyTempl->aColl.pTxtColl ); 4519 pApplyTempl->bUndo = sal_True; 4520 bCallBase = sal_False; 4521 if ( pApplyTempl->aColl.pTxtColl ) 4522 aStyleName = pApplyTempl->aColl.pTxtColl->GetName(); 4523 } 4524 break; 4525 case SFX_STYLE_FAMILY_CHAR: 4526 if( (( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL ) 4527 & eSelection ) && !rSh.HasReadonlySel() ) 4528 { 4529 rSh.SetAttr( SwFmtCharFmt(pApplyTempl->aColl.pCharFmt) ); 4530 rSh.UnSetVisCrsr(); 4531 rSh.EnterStdMode(); 4532 rSh.SetVisCrsr(aDocPt); 4533 pApplyTempl->bUndo = sal_True; 4534 bCallBase = sal_False; 4535 if ( pApplyTempl->aColl.pCharFmt ) 4536 aStyleName = pApplyTempl->aColl.pCharFmt->GetName(); 4537 } 4538 break; 4539 case SFX_STYLE_FAMILY_FRAME : 4540 { 4541 const SwFrmFmt* pFmt = rSh.GetFmtFromObj( aDocPt ); 4542 if(PTR_CAST(SwFlyFrmFmt, pFmt)) 4543 { 4544 rSh.SetFrmFmt( pApplyTempl->aColl.pFrmFmt, sal_False, &aDocPt ); 4545 pApplyTempl->bUndo = sal_True; 4546 bCallBase = sal_False; 4547 if( pApplyTempl->aColl.pFrmFmt ) 4548 aStyleName = pApplyTempl->aColl.pFrmFmt->GetName(); 4549 } 4550 break; 4551 } 4552 case SFX_STYLE_FAMILY_PAGE: 4553 // Kein Undo bei Seitenvorlagen 4554 rSh.ChgCurPageDesc( *pApplyTempl->aColl.pPageDesc ); 4555 if ( pApplyTempl->aColl.pPageDesc ) 4556 aStyleName = pApplyTempl->aColl.pPageDesc->GetName(); 4557 bCallBase = sal_False; 4558 break; 4559 case SFX_STYLE_FAMILY_PSEUDO: 4560 if( !rSh.HasReadonlySel() ) 4561 { 4562 // --> OD 2008-03-17 #refactorlists# 4563 rSh.SetCurNumRule( *pApplyTempl->aColl.pNumRule, 4564 false, 4565 pApplyTempl->aColl.pNumRule->GetDefaultListId() ); 4566 // <-- 4567 bCallBase = sal_False; 4568 pApplyTempl->bUndo = sal_True; 4569 if( pApplyTempl->aColl.pNumRule ) 4570 aStyleName = pApplyTempl->aColl.pNumRule->GetName(); 4571 } 4572 break; 4573 } 4574 4575 uno::Reference< frame::XDispatchRecorder > xRecorder = 4576 rView.GetViewFrame()->GetBindings().GetRecorder(); 4577 if ( aStyleName.Len() && xRecorder.is() ) 4578 { 4579 SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) ); 4580 if ( pSfxShell ) 4581 { 4582 SfxRequest aReq( rView.GetViewFrame(), SID_STYLE_APPLY ); 4583 aReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aStyleName ) ); 4584 aReq.AppendItem( SfxUInt16Item( SID_STYLE_FAMILY, (sal_uInt16) pApplyTempl->eType ) ); 4585 aReq.Done(); 4586 } 4587 } 4588 } 4589 4590 } 4591 ReleaseMouse(); 4592 // Hier kommen nur verarbeitete MouseEvents an; nur bei diesen duerfen 4593 // die Modi zurueckgesetzt werden. 4594 bMBPressed = sal_False; 4595 4596 //sicherheitshalber aufrufen, da jetzt das Selektieren bestimmt zu Ende ist. 4597 //Andernfalls koennte der Timeout des Timers Kummer machen. 4598 EnterArea(); 4599 bNoInterrupt = sal_False; 4600 4601 if (bCallBase) 4602 Window::MouseButtonUp(rMEvt); 4603 } 4604 4605 4606 /*-------------------------------------------------------------------- 4607 Beschreibung: Vorlage anwenden 4608 --------------------------------------------------------------------*/ 4609 4610 4611 void SwEditWin::SetApplyTemplate(const SwApplyTemplate &rTempl) 4612 { 4613 static sal_Bool bIdle = sal_False; 4614 DELETEZ(pApplyTempl); 4615 SwWrtShell &rSh = rView.GetWrtShell(); 4616 4617 if(rTempl.pFormatClipboard) 4618 { 4619 pApplyTempl = new SwApplyTemplate( rTempl ); 4620 SetPointer( POINTER_FILL );//@todo #i20119# maybe better a new brush pointer here in future 4621 rSh.NoEdit( sal_False ); 4622 bIdle = rSh.GetViewOptions()->IsIdle(); 4623 ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False ); 4624 } 4625 else if(rTempl.nColor) 4626 { 4627 pApplyTempl = new SwApplyTemplate( rTempl ); 4628 SetPointer( POINTER_FILL ); 4629 rSh.NoEdit( sal_False ); 4630 bIdle = rSh.GetViewOptions()->IsIdle(); 4631 ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False ); 4632 } 4633 else if( rTempl.eType ) 4634 { 4635 pApplyTempl = new SwApplyTemplate( rTempl ); 4636 SetPointer( POINTER_FILL ); 4637 rSh.NoEdit( sal_False ); 4638 bIdle = rSh.GetViewOptions()->IsIdle(); 4639 ((SwViewOption *)rSh.GetViewOptions())->SetIdle( sal_False ); 4640 } 4641 else 4642 { 4643 SetPointer( POINTER_TEXT ); 4644 rSh.UnSetVisCrsr(); 4645 4646 ((SwViewOption *)rSh.GetViewOptions())->SetIdle( bIdle ); 4647 if ( !rSh.IsSelFrmMode() ) 4648 rSh.Edit(); 4649 } 4650 4651 static sal_uInt16 __READONLY_DATA aInva[] = 4652 { 4653 SID_STYLE_WATERCAN, 4654 SID_ATTR_CHAR_COLOR_EXT, 4655 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, 4656 0 4657 }; 4658 rView.GetViewFrame()->GetBindings().Invalidate(aInva); 4659 } 4660 4661 /*-------------------------------------------------------------------- 4662 Beschreibung: ctor 4663 --------------------------------------------------------------------*/ 4664 4665 4666 SwEditWin::SwEditWin(Window *pParent, SwView &rMyView): 4667 Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), 4668 DropTargetHelper( this ), 4669 DragSourceHelper( this ), 4670 4671 eBufferLanguage(LANGUAGE_DONTKNOW), 4672 pApplyTempl(0), 4673 pAnchorMarker( 0 ), 4674 pUserMarker( 0 ), 4675 pUserMarkerObj( 0 ), 4676 pShadCrsr( 0 ), 4677 pRowColumnSelectionStart( 0 ), 4678 4679 rView( rMyView ), 4680 4681 aActHitType(SDRHIT_NONE), 4682 m_nDropFormat( 0 ), 4683 m_nDropAction( 0 ), 4684 m_nDropDestination( 0 ), 4685 4686 nInsFrmColCount( 1 ), 4687 eDrawMode(OBJ_NONE), 4688 4689 bLockInput(sal_False), 4690 bObjectSelect( sal_False ), 4691 nKS_NUMDOWN_Count(0), // #i23725# 4692 nKS_NUMINDENTINC_Count(0) // #i23725# 4693 { 4694 SetHelpId(HID_EDIT_WIN); 4695 EnableChildTransparentMode(); 4696 SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS ); 4697 4698 bLinkRemoved = bMBPressed = bInsDraw = bInsFrm = 4699 bIsInDrag = bOldIdle = bOldIdleSet = bChainMode = bWasShdwCrsr = sal_False; 4700 //#i42732# initially use the input language 4701 bUseInputLanguage = sal_True; 4702 4703 SetMapMode(MapMode(MAP_TWIP)); 4704 4705 SetPointer( POINTER_TEXT ); 4706 aTimer.SetTimeoutHdl(LINK(this, SwEditWin, TimerHandler)); 4707 4708 bTblInsDelMode = sal_False; 4709 aKeyInputTimer.SetTimeout( 3000 ); 4710 aKeyInputTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputTimerHandler)); 4711 4712 aKeyInputFlushTimer.SetTimeout( 200 ); 4713 aKeyInputFlushTimer.SetTimeoutHdl(LINK(this, SwEditWin, KeyInputFlushHandler)); 4714 4715 // TemplatePointer fuer Farben soll nach Einfachclick 4716 // ohne Selektion zurueckgesetzt werden 4717 aTemplateTimer.SetTimeout(400); 4718 aTemplateTimer.SetTimeoutHdl(LINK(this, SwEditWin, TemplateTimerHdl)); 4719 4720 //JP 16.12.98: temporaere Loesung!!! Sollte bei jeder Cursorbewegung 4721 // den Font von der akt. einfuege Position setzen! 4722 if( !rMyView.GetDocShell()->IsReadOnly() ) 4723 { 4724 Font aFont; 4725 SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT | 4726 INPUTCONTEXT_EXTTEXTINPUT ) ); 4727 } 4728 } 4729 4730 4731 4732 SwEditWin::~SwEditWin() 4733 { 4734 aKeyInputTimer.Stop(); 4735 delete pShadCrsr; 4736 delete pRowColumnSelectionStart; 4737 if( pQuickHlpData->bClear && rView.GetWrtShellPtr() ) 4738 pQuickHlpData->Stop( rView.GetWrtShell() ); 4739 bExecuteDrag = sal_False; 4740 delete pApplyTempl; 4741 rView.SetDrawFuncPtr(NULL); 4742 4743 if(pUserMarker) 4744 { 4745 delete pUserMarker; 4746 } 4747 4748 delete pAnchorMarker; 4749 } 4750 4751 4752 /****************************************************************************** 4753 * Beschreibung: DrawTextEditMode einschalten 4754 ******************************************************************************/ 4755 4756 4757 void SwEditWin::EnterDrawTextMode( const Point& aDocPos ) 4758 { 4759 if ( rView.EnterDrawTextMode(aDocPos) == sal_True ) 4760 { 4761 if (rView.GetDrawFuncPtr()) 4762 { 4763 rView.GetDrawFuncPtr()->Deactivate(); 4764 rView.SetDrawFuncPtr(NULL); 4765 rView.LeaveDrawCreate(); 4766 } 4767 rView.NoRotate(); 4768 rView.AttrChangedNotify( &rView.GetWrtShell() ); 4769 } 4770 } 4771 4772 /****************************************************************************** 4773 * Beschreibung: DrawMode einschalten 4774 ******************************************************************************/ 4775 4776 4777 4778 sal_Bool SwEditWin::EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos) 4779 { 4780 SwWrtShell &rSh = rView.GetWrtShell(); 4781 SdrView *pSdrView = rSh.GetDrawView(); 4782 4783 // if ( GetDrawFuncPtr() && (aActHitType == SDRHIT_NONE || rSh.IsDrawCreate()) ) 4784 if ( rView.GetDrawFuncPtr() ) 4785 { 4786 if (rSh.IsDrawCreate()) 4787 return sal_True; 4788 4789 sal_Bool bRet = rView.GetDrawFuncPtr()->MouseButtonDown( rMEvt ); 4790 rView.AttrChangedNotify( &rSh ); 4791 return bRet; 4792 } 4793 4794 if ( pSdrView && pSdrView->IsTextEdit() ) 4795 { 4796 sal_Bool bUnLockView = !rSh.IsViewLocked(); 4797 rSh.LockView( sal_True ); 4798 4799 rSh.EndTextEdit(); // Danebengeklickt, Ende mit Edit 4800 rSh.SelectObj( aDocPos ); 4801 if ( !rSh.IsObjSelected() && !rSh.IsFrmSelected() ) 4802 rSh.LeaveSelFrmMode(); 4803 else 4804 { 4805 SwEditWin::nDDStartPosY = aDocPos.Y(); 4806 SwEditWin::nDDStartPosX = aDocPos.X(); 4807 bFrmDrag = sal_True; 4808 } 4809 if( bUnLockView ) 4810 rSh.LockView( sal_False ); 4811 rView.AttrChangedNotify( &rSh ); 4812 return sal_True; 4813 } 4814 return sal_False; 4815 } 4816 4817 /****************************************************************************** 4818 * Beschreibung: 4819 ******************************************************************************/ 4820 4821 4822 4823 sal_Bool SwEditWin::IsDrawSelMode() 4824 { 4825 // return (IsFrmAction() == sal_False && GetSdrDrawMode() == OBJ_NONE); 4826 return IsObjectSelect(); 4827 } 4828 4829 /****************************************************************************** 4830 * Beschreibung: 4831 ******************************************************************************/ 4832 4833 4834 void SwEditWin::GetFocus() 4835 { 4836 if ( rView.GetPostItMgr()->HasActiveSidebarWin() ) 4837 { 4838 rView.GetPostItMgr()->GrabFocusOnActiveSidebarWin(); 4839 } 4840 else 4841 { 4842 rView.GotFocus(); 4843 Window::GetFocus(); 4844 rView.GetWrtShell().InvalidateAccessibleFocus(); 4845 } 4846 } 4847 4848 /****************************************************************************** 4849 * Beschreibung: 4850 ******************************************************************************/ 4851 4852 4853 4854 void SwEditWin::LoseFocus() 4855 { 4856 rView.GetWrtShell().InvalidateAccessibleFocus(); 4857 Window::LoseFocus(); 4858 if( pQuickHlpData->bClear ) 4859 pQuickHlpData->Stop( rView.GetWrtShell() ); 4860 rView.LostFocus(); 4861 } 4862 4863 /****************************************************************************** 4864 * Beschreibung: 4865 ******************************************************************************/ 4866 4867 4868 4869 void SwEditWin::Command( const CommandEvent& rCEvt ) 4870 { 4871 SwWrtShell &rSh = rView.GetWrtShell(); 4872 4873 if ( !rView.GetViewFrame() ) 4874 { 4875 //Wenn der ViewFrame in Kuerze stirbt kein Popup mehr! 4876 Window::Command(rCEvt); 4877 return; 4878 } 4879 4880 // The command event is send to the window after a possible context 4881 // menu from an inplace client has been closed. Now we have the chance 4882 // to deactivate the inplace client without any problem regarding parent 4883 // windows and code on the stack. 4884 // For more information, see #126086# and #128122# 4885 SfxInPlaceClient* pIPClient = rSh.GetSfxViewShell()->GetIPClient(); 4886 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() ); 4887 if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )) 4888 { 4889 rSh.FinishOLEObj(); 4890 return; 4891 } 4892 4893 sal_Bool bCallBase = sal_True; 4894 4895 switch ( rCEvt.GetCommand() ) 4896 { 4897 case COMMAND_CONTEXTMENU: 4898 { 4899 const sal_uInt16 nId = SwInputChild::GetChildWindowId(); 4900 SwInputChild* pChildWin = (SwInputChild*)GetView().GetViewFrame()-> 4901 GetChildWindow( nId ); 4902 4903 if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel())) 4904 return; 4905 4906 if((!pChildWin || pChildWin->GetView() != &rView) && 4907 !rSh.IsDrawCreate() && !IsDrawAction()) 4908 { 4909 SET_CURR_SHELL( &rSh ); 4910 if (!pApplyTempl) 4911 { 4912 if (bNoInterrupt == sal_True) 4913 { 4914 ReleaseMouse(); 4915 bNoInterrupt = sal_False; 4916 bMBPressed = sal_False; 4917 } 4918 Point aDocPos( PixelToLogic( rCEvt.GetMousePosPixel() ) ); 4919 if ( !rCEvt.IsMouseEvent() ) 4920 aDocPos = rSh.GetCharRect().Center(); 4921 else 4922 { 4923 SelectMenuPosition(rSh, rCEvt.GetMousePosPixel()); 4924 rView.StopShellTimer(); 4925 4926 } 4927 const Point aPixPos = LogicToPixel( aDocPos ); 4928 4929 if ( rView.GetDocShell()->IsReadOnly() ) 4930 { 4931 SwReadOnlyPopup* pROPopup = new SwReadOnlyPopup( aDocPos, rView ); 4932 4933 ui::ContextMenuExecuteEvent aEvent; 4934 aEvent.SourceWindow = VCLUnoHelper::GetInterface( this ); 4935 aEvent.ExecutePosition.X = aPixPos.X(); 4936 aEvent.ExecutePosition.Y = aPixPos.Y(); 4937 Menu* pMenu = 0; 4938 ::rtl::OUString sMenuName = 4939 ::rtl::OUString::createFromAscii( "private:resource/ReadonlyContextMenu"); 4940 if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) ) 4941 { 4942 if ( pMenu ) 4943 { 4944 sal_uInt16 nExecId = ((PopupMenu*)pMenu)->Execute(this, aPixPos); 4945 if( !::ExecuteMenuCommand( *static_cast<PopupMenu*>(pMenu), *rView.GetViewFrame(), nExecId )) 4946 pROPopup->Execute(this, nExecId); 4947 } 4948 else 4949 pROPopup->Execute(this, aPixPos); 4950 } 4951 delete pROPopup; 4952 } 4953 else if ( !rView.ExecSpellPopup( aDocPos ) ) 4954 GetView().GetViewFrame()->GetDispatcher()->ExecutePopup( 0, this, &aPixPos); 4955 } 4956 else if (pApplyTempl->bUndo) 4957 rSh.Do(SwWrtShell::UNDO); 4958 bCallBase = sal_False; 4959 } 4960 } 4961 break; 4962 4963 case COMMAND_WHEEL: 4964 case COMMAND_STARTAUTOSCROLL: 4965 case COMMAND_AUTOSCROLL: 4966 if( pShadCrsr ) 4967 delete pShadCrsr, pShadCrsr = 0; 4968 bCallBase = !rView.HandleWheelCommands( rCEvt ); 4969 break; 4970 4971 case COMMAND_VOICE: 4972 { 4973 //ggf. an Outliner weiterleiten 4974 if ( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() ) 4975 { 4976 bCallBase = sal_False; 4977 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt ); 4978 break; 4979 } 4980 4981 const CommandVoiceData *pCData = rCEvt.GetVoiceData(); 4982 if ( VOICECOMMANDTYPE_CONTROL == pCData->GetType() ) 4983 break; 4984 4985 4986 sal_uInt16 nSlotId = 0; 4987 SfxPoolItem *pItem = 0; 4988 4989 switch ( pCData->GetCommand() ) 4990 { 4991 case DICTATIONCOMMAND_NEWPARAGRAPH: nSlotId = FN_INSERT_BREAK; break; 4992 case DICTATIONCOMMAND_NEWLINE: nSlotId = FN_INSERT_LINEBREAK; break; 4993 case DICTATIONCOMMAND_LEFT: nSlotId = FN_PREV_WORD; break; 4994 case DICTATIONCOMMAND_RIGHT: nSlotId = FN_NEXT_WORD; break; 4995 case DICTATIONCOMMAND_UP: nSlotId = FN_LINE_UP; break; 4996 case DICTATIONCOMMAND_DOWN: nSlotId = FN_LINE_DOWN; break; 4997 case DICTATIONCOMMAND_UNDO: nSlotId = SID_UNDO; break; 4998 case DICTATIONCOMMAND_REPEAT: nSlotId = SID_REPEAT; break; 4999 case DICTATIONCOMMAND_DEL: nSlotId = FN_DELETE_BACK_WORD; break; 5000 5001 case DICTATIONCOMMAND_BOLD_ON: nSlotId = SID_ATTR_CHAR_WEIGHT; 5002 pItem = new SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ); 5003 break; 5004 case DICTATIONCOMMAND_BOLD_OFF: nSlotId = SID_ATTR_CHAR_WEIGHT; 5005 pItem = new SvxWeightItem( WEIGHT_NORMAL, RES_CHRATR_WEIGHT ); 5006 break; 5007 case DICTATIONCOMMAND_UNDERLINE_ON: nSlotId = SID_ATTR_CHAR_UNDERLINE; 5008 pItem = new SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_WEIGHT ); 5009 break; 5010 case DICTATIONCOMMAND_UNDERLINE_OFF:nSlotId = SID_ATTR_CHAR_UNDERLINE; 5011 pItem = new SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE ); 5012 break; 5013 case DICTATIONCOMMAND_ITALIC_ON: nSlotId = SID_ATTR_CHAR_POSTURE; 5014 pItem = new SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ); 5015 break; 5016 case DICTATIONCOMMAND_ITALIC_OFF: nSlotId = SID_ATTR_CHAR_POSTURE; 5017 pItem = new SvxPostureItem( ITALIC_NONE, RES_CHRATR_POSTURE ); 5018 break; 5019 case DICTATIONCOMMAND_NUMBERING_ON: 5020 if ( !rSh.GetCurNumRule() ) 5021 nSlotId = FN_NUM_NUMBERING_ON; 5022 break; 5023 case DICTATIONCOMMAND_NUMBERING_OFF: 5024 if ( rSh.GetCurNumRule() ) 5025 nSlotId = FN_NUM_NUMBERING_ON; 5026 break; 5027 case DICTATIONCOMMAND_TAB: 5028 { 5029 rSh.Insert( '\t' ); 5030 } 5031 break; 5032 case DICTATIONCOMMAND_UNKNOWN: 5033 { 5034 rView.GetWrtShell().Insert( pCData->GetText() ); 5035 } 5036 break; 5037 5038 #ifdef DBG_UTIL 5039 default: 5040 ASSERT( !this, "unknown speech command." ); 5041 #endif 5042 } 5043 if ( nSlotId ) 5044 { 5045 bCallBase = sal_False; 5046 if ( pItem ) 5047 { 5048 const SfxPoolItem* aArgs[2]; 5049 aArgs[0] = pItem; 5050 aArgs[1] = 0; 5051 GetView().GetViewFrame()->GetBindings().Execute( 5052 nSlotId, aArgs, 0, SFX_CALLMODE_STANDARD ); 5053 delete pItem; 5054 } 5055 else 5056 GetView().GetViewFrame()->GetBindings().Execute( nSlotId ); 5057 } 5058 } 5059 break; 5060 5061 case COMMAND_STARTEXTTEXTINPUT: 5062 { 5063 sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() && 5064 rSh.IsCrsrReadonly(); 5065 if(!bIsDocReadOnly) 5066 { 5067 if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() ) 5068 { 5069 bCallBase = sal_False; 5070 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt ); 5071 } 5072 else 5073 { 5074 if( rSh.HasSelection() ) 5075 rSh.DelRight(); 5076 5077 bCallBase = sal_False; 5078 LanguageType eInputLanguage = GetInputLanguage(); 5079 rSh.CreateExtTextInput(eInputLanguage); 5080 } 5081 } 5082 break; 5083 } 5084 case COMMAND_ENDEXTTEXTINPUT: 5085 { 5086 sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() && 5087 rSh.IsCrsrReadonly(); 5088 if(!bIsDocReadOnly) 5089 { 5090 if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() ) 5091 { 5092 bCallBase = sal_False; 5093 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt ); 5094 } 5095 else 5096 { 5097 bCallBase = sal_False; 5098 String sRecord = rSh.DeleteExtTextInput(); 5099 uno::Reference< frame::XDispatchRecorder > xRecorder = 5100 rView.GetViewFrame()->GetBindings().GetRecorder(); 5101 5102 if ( sRecord.Len() ) 5103 { 5104 // #102812# convert quotes in IME text 5105 // works on the last input character, this is escpecially in Korean text often done 5106 // quotes that are inside of the string are not replaced! 5107 const sal_Unicode aCh = sRecord.GetChar(sRecord.Len() - 1); 5108 SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); 5109 SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect(); 5110 if(pACorr && 5111 (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))|| 5112 ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh)))) 5113 { 5114 rSh.DelLeft(); 5115 rSh.AutoCorrect( *pACorr, aCh ); 5116 } 5117 5118 if ( xRecorder.is() ) 5119 { 5120 //Shell ermitteln 5121 SfxShell *pSfxShell = lcl_GetShellFromDispatcher( rView, TYPE(SwTextShell) ); 5122 // Request generieren und recorden 5123 if (pSfxShell) 5124 { 5125 SfxRequest aReq( rView.GetViewFrame(), FN_INSERT_STRING ); 5126 aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sRecord ) ); 5127 aReq.Done(); 5128 } 5129 } 5130 } 5131 } 5132 } 5133 } 5134 break; 5135 case COMMAND_EXTTEXTINPUT: 5136 { 5137 sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() && 5138 rSh.IsCrsrReadonly(); 5139 if(!bIsDocReadOnly) 5140 { 5141 QuickHelpData aTmpQHD; 5142 if( pQuickHlpData->bClear ) 5143 { 5144 aTmpQHD.Move( *pQuickHlpData ); 5145 pQuickHlpData->Stop( rSh ); 5146 } 5147 String sWord; 5148 if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() ) 5149 { 5150 bCallBase = sal_False; 5151 rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt ); 5152 } 5153 else 5154 { 5155 const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData(); 5156 if( pData ) 5157 { 5158 sWord = pData->GetText(); 5159 bCallBase = sal_False; 5160 rSh.SetExtTextInputData( *pData ); 5161 } 5162 } 5163 uno::Reference< frame::XDispatchRecorder > xRecorder = 5164 rView.GetViewFrame()->GetBindings().GetRecorder(); 5165 if(!xRecorder.is()) 5166 { 5167 SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); 5168 SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect(); 5169 if( pACfg && pACorr && 5170 ( pACfg->IsAutoTextTip() || 5171 pACorr->GetSwFlags().bAutoCompleteWords ) && 5172 rSh.GetPrevAutoCorrWord( *pACorr, sWord ) ) 5173 { 5174 ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr, sal_True); 5175 } 5176 } 5177 } 5178 } 5179 break; 5180 case COMMAND_CURSORPOS: 5181 // will be handled by the base class 5182 break; 5183 5184 case COMMAND_PASTESELECTION: 5185 if( !rView.GetDocShell()->IsReadOnly() ) 5186 { 5187 TransferableDataHelper aDataHelper( 5188 TransferableDataHelper::CreateFromSelection( this )); 5189 if( !aDataHelper.GetXTransferable().is() ) 5190 break; 5191 5192 sal_uLong nDropFormat; 5193 sal_uInt16 nEventAction, nDropAction, nDropDestination; 5194 nDropDestination = GetDropDestination( rCEvt.GetMousePosPixel() ); 5195 if( !nDropDestination ) 5196 break; 5197 5198 nDropAction = SotExchange::GetExchangeAction( 5199 aDataHelper.GetDataFlavorExVector(), 5200 nDropDestination, EXCHG_IN_ACTION_COPY, 5201 EXCHG_IN_ACTION_COPY, nDropFormat, 5202 nEventAction ); 5203 if( EXCHG_INOUT_ACTION_NONE != nDropAction ) 5204 { 5205 const Point aDocPt( PixelToLogic( rCEvt.GetMousePosPixel() ) ); 5206 SwTransferable::PasteData( aDataHelper, rSh, nDropAction, 5207 nDropFormat, nDropDestination, sal_False, 5208 sal_False, &aDocPt, EXCHG_IN_ACTION_COPY, 5209 sal_True ); 5210 } 5211 } 5212 break; 5213 case COMMAND_MODKEYCHANGE : 5214 { 5215 const CommandModKeyData* pCommandData = (const CommandModKeyData*)rCEvt.GetData(); 5216 if(pCommandData->IsMod1() && !pCommandData->IsMod2()) 5217 { 5218 sal_uInt16 nSlot = 0; 5219 if(pCommandData->IsLeftShift() && !pCommandData->IsRightShift()) 5220 nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT; 5221 else if(!pCommandData->IsLeftShift() && pCommandData->IsRightShift()) 5222 nSlot = SID_ATTR_PARA_RIGHT_TO_LEFT; 5223 if(nSlot && SW_MOD()->GetCTLOptions().IsCTLFontEnabled()) 5224 GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot); 5225 } 5226 } 5227 break; 5228 case COMMAND_HANGUL_HANJA_CONVERSION : 5229 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HANGUL_HANJA_CONVERSION); 5230 break; 5231 case COMMAND_INPUTLANGUAGECHANGE : 5232 //#i42732# update state of fontname if input language changes 5233 bInputLanguageSwitched = true; 5234 SetUseInputLanguage( sal_True ); 5235 break; 5236 case COMMAND_SELECTIONCHANGE: 5237 { 5238 const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData(); 5239 rSh.SttCrsrMove(); 5240 rSh.GoStartSentence(); 5241 rSh.GetCrsr()->GetPoint()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetStart()); 5242 rSh.SetMark(); 5243 rSh.GetCrsr()->GetMark()->nContent += sal::static_int_cast<sal_uInt16, sal_uLong>(pData->GetEnd() - pData->GetStart()); 5244 rSh.EndCrsrMove( sal_True ); 5245 } 5246 break; 5247 case COMMAND_PREPARERECONVERSION: 5248 if( rSh.HasSelection() ) 5249 { 5250 SwPaM *pCrsr = (SwPaM*)rSh.GetCrsr(); 5251 5252 if( rSh.IsMultiSelection() ) 5253 { 5254 if( pCrsr && !pCrsr->HasMark() && 5255 pCrsr->GetPoint() == pCrsr->GetMark() ) 5256 { 5257 rSh.GoPrevCrsr(); 5258 pCrsr = (SwPaM*)rSh.GetCrsr(); 5259 } 5260 5261 // Cancel all selections other than the last selected one. 5262 while( rSh.GetCrsr()->GetNext() != rSh.GetCrsr() ) 5263 delete rSh.GetCrsr()->GetNext(); 5264 } 5265 5266 if( pCrsr ) 5267 { 5268 sal_uLong nPosNodeIdx = pCrsr->GetPoint()->nNode.GetIndex(); 5269 xub_StrLen nPosIdx = pCrsr->GetPoint()->nContent.GetIndex(); 5270 sal_uLong nMarkNodeIdx = pCrsr->GetMark()->nNode.GetIndex(); 5271 xub_StrLen nMarkIdx = pCrsr->GetMark()->nContent.GetIndex(); 5272 5273 if( !rSh.GetCrsr()->HasMark() ) 5274 rSh.GetCrsr()->SetMark(); 5275 5276 rSh.SttCrsrMove(); 5277 5278 if( nPosNodeIdx < nMarkNodeIdx ) 5279 { 5280 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx; 5281 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx; 5282 rSh.GetCrsr()->GetMark()->nNode = nPosNodeIdx; 5283 rSh.GetCrsr()->GetMark()->nContent = 5284 rSh.GetCrsr()->GetCntntNode( sal_True )->Len(); 5285 } 5286 else if( nPosNodeIdx == nMarkNodeIdx ) 5287 { 5288 rSh.GetCrsr()->GetPoint()->nNode = nPosNodeIdx; 5289 rSh.GetCrsr()->GetPoint()->nContent = nPosIdx; 5290 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx; 5291 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx; 5292 } 5293 else 5294 { 5295 rSh.GetCrsr()->GetMark()->nNode = nMarkNodeIdx; 5296 rSh.GetCrsr()->GetMark()->nContent = nMarkIdx; 5297 rSh.GetCrsr()->GetPoint()->nNode = nMarkNodeIdx; 5298 rSh.GetCrsr()->GetPoint()->nContent = 5299 rSh.GetCrsr()->GetCntntNode( sal_False )->Len(); 5300 } 5301 5302 rSh.EndCrsrMove( sal_True ); 5303 } 5304 } 5305 break; 5306 #ifdef DBG_UTIL 5307 default: 5308 ASSERT( !this, "unknown command." ); 5309 #endif 5310 } 5311 if (bCallBase) 5312 Window::Command(rCEvt); 5313 } 5314 5315 /* -----------------25.08.2003 10:12----------------- 5316 #i18686#: select the object/cursor at the mouse 5317 position of the context menu request 5318 --------------------------------------------------*/ 5319 sal_Bool SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos ) 5320 { 5321 sal_Bool bRet = sal_False; 5322 const Point aDocPos( PixelToLogic( rMousePos ) ); 5323 // --> OD 2005-02-17 #i42258# 5324 const bool bIsInsideSelectedObj( rSh.IsInsideSelectedObj( aDocPos ) ); 5325 // <-- 5326 //create a synthetic mouse event out of the coordinates 5327 MouseEvent aMEvt(rMousePos); 5328 SdrView *pSdrView = rSh.GetDrawView(); 5329 if ( pSdrView ) 5330 { 5331 // --> OD 2005-02-17 #i42258# - no close of insert_draw and reset of 5332 // draw mode, if context menu position is inside a selected object. 5333 if ( !bIsInsideSelectedObj && rView.GetDrawFuncPtr() ) 5334 // <-- 5335 { 5336 5337 rView.GetDrawFuncPtr()->Deactivate(); 5338 rView.SetDrawFuncPtr(NULL); 5339 rView.LeaveDrawCreate(); 5340 SfxBindings& rBind = rView.GetViewFrame()->GetBindings(); 5341 rBind.Invalidate( SID_ATTR_SIZE ); 5342 rBind.Invalidate( SID_TABLE_CELL ); 5343 } 5344 5345 // if draw text is active and there's a text selection 5346 // at the mouse position then do nothing 5347 if(rSh.GetSelectionType() & nsSelectionType::SEL_DRW_TXT) 5348 { 5349 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 5350 ESelection aSelection = pOLV->GetSelection(); 5351 if(!aSelection.IsZero()) 5352 { 5353 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner(); 5354 sal_Bool bVertical = pOutliner->IsVertical(); 5355 const EditEngine& rEditEng = pOutliner->GetEditEngine(); 5356 Point aEEPos(aDocPos); 5357 const Rectangle& rOutputArea = pOLV->GetOutputArea(); 5358 // regard vertical mode 5359 if(bVertical) 5360 { 5361 aEEPos -= rOutputArea.TopRight(); 5362 //invert the horizontal direction and exchange X and Y 5363 long nTemp = -aEEPos.X(); 5364 aEEPos.X() = aEEPos.Y(); 5365 aEEPos.Y() = nTemp; 5366 } 5367 else 5368 aEEPos -= rOutputArea.TopLeft(); 5369 5370 EPosition aDocPosition = rEditEng.FindDocPosition(aEEPos); 5371 ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex); 5372 // make it a forward selection - otherwise the IsLess/IsGreater do not work :-( 5373 aSelection.Adjust(); 5374 if(!aCompare.IsLess(aSelection) && !aCompare.IsGreater(aSelection)) 5375 { 5376 return sal_False; 5377 } 5378 } 5379 5380 } 5381 5382 if (pSdrView->MouseButtonDown( aMEvt, this ) ) 5383 { 5384 pSdrView->MouseButtonUp( aMEvt, this ); 5385 rSh.GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 5386 return sal_True; 5387 } 5388 } 5389 rSh.ResetCursorStack(); 5390 5391 if ( EnterDrawMode( aMEvt, aDocPos ) ) 5392 { 5393 return sal_True; 5394 } 5395 if ( rView.GetDrawFuncPtr() && bInsFrm ) 5396 { 5397 StopInsFrm(); 5398 rSh.Edit(); 5399 } 5400 5401 UpdatePointer( aDocPos, 0 ); 5402 5403 if( !rSh.IsSelFrmMode() && 5404 !GetView().GetViewFrame()->GetDispatcher()->IsLocked() ) 5405 { 5406 // #107513# 5407 // Test if there is a draw object at that position and if it should be selected. 5408 sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos); 5409 5410 if(bShould) 5411 { 5412 rView.NoRotate(); 5413 rSh.HideCrsr(); 5414 5415 sal_Bool bUnLockView = !rSh.IsViewLocked(); 5416 rSh.LockView( sal_True ); 5417 sal_Bool bSelObj = rSh.SelectObj( aDocPos, 0); 5418 if( bUnLockView ) 5419 rSh.LockView( sal_False ); 5420 5421 if( bSelObj ) 5422 { 5423 bRet = sal_True; 5424 // falls im Macro der Rahmen deselektiert 5425 // wurde, muss nur noch der Cursor 5426 // wieder angezeigt werden. 5427 if( FRMTYPE_NONE == rSh.GetSelFrmType() ) 5428 rSh.ShowCrsr(); 5429 else 5430 { 5431 if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr()) 5432 { 5433 rView.GetDrawFuncPtr()->Deactivate(); 5434 rView.SetDrawFuncPtr(NULL); 5435 rView.LeaveDrawCreate(); 5436 rView.AttrChangedNotify( &rSh ); 5437 } 5438 5439 rSh.EnterSelFrmMode( &aDocPos ); 5440 bFrmDrag = sal_True; 5441 UpdatePointer( aDocPos, 0 ); 5442 return bRet; 5443 } 5444 } 5445 5446 if (!rView.GetDrawFuncPtr()) 5447 rSh.ShowCrsr(); 5448 } 5449 } 5450 else if ( rSh.IsSelFrmMode() && 5451 (aActHitType == SDRHIT_NONE || 5452 !bIsInsideSelectedObj)) 5453 { 5454 rView.NoRotate(); 5455 sal_Bool bUnLockView = !rSh.IsViewLocked(); 5456 rSh.LockView( sal_True ); 5457 sal_uInt8 nFlag = 0; 5458 5459 if ( rSh.IsSelFrmMode() ) 5460 { 5461 rSh.UnSelectFrm(); 5462 rSh.LeaveSelFrmMode(); 5463 rView.AttrChangedNotify(&rSh); 5464 bRet = sal_True; 5465 } 5466 5467 sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag ); 5468 if( bUnLockView ) 5469 rSh.LockView( sal_False ); 5470 5471 if( !bSelObj ) 5472 { 5473 // Cursor hier umsetzen, damit er nicht zuerst 5474 // im Rahmen gezeichnet wird; ShowCrsr() geschieht 5475 // in LeaveSelFrmMode() 5476 bValidCrsrPos = !(CRSR_POSCHG & (rSh.*rSh.fnSetCrsr)(&aDocPos,sal_False)); 5477 rSh.LeaveSelFrmMode(); 5478 rView.LeaveDrawCreate(); 5479 rView.AttrChangedNotify( &rSh ); 5480 bRet = sal_True; 5481 } 5482 else 5483 { 5484 rSh.HideCrsr(); 5485 rSh.EnterSelFrmMode( &aDocPos ); 5486 rSh.SelFlyGrabCrsr(); 5487 rSh.MakeSelVisible(); 5488 bFrmDrag = sal_True; 5489 if( rSh.IsFrmSelected() && 5490 rView.GetDrawFuncPtr() ) 5491 { 5492 rView.GetDrawFuncPtr()->Deactivate(); 5493 rView.SetDrawFuncPtr(NULL); 5494 rView.LeaveDrawCreate(); 5495 rView.AttrChangedNotify( &rSh ); 5496 } 5497 UpdatePointer( aDocPos, 0 ); 5498 bRet = sal_True; 5499 } 5500 } 5501 else if ( rSh.IsSelFrmMode() && bIsInsideSelectedObj ) 5502 { 5503 // ## object at the mouse cursor is already selected - do nothing 5504 return sal_False; 5505 } 5506 5507 if ( rSh.IsGCAttr() ) 5508 { 5509 rSh.GCAttr(); 5510 rSh.ClearGCAttr(); 5511 } 5512 5513 sal_Bool bOverSelect = rSh.ChgCurrPam( aDocPos ), bOverURLGrf = sal_False; 5514 if( !bOverSelect ) 5515 bOverURLGrf = bOverSelect = 0 != rSh.IsURLGrfAtPos( aDocPos ); 5516 5517 if ( !bOverSelect ) 5518 { 5519 { // nur temp. Move-Kontext aufspannen, da sonst die 5520 // Abfrage auf die Inhaltsform nicht funktioniert!!! 5521 MV_KONTEXT( &rSh ); 5522 (rSh.*rSh.fnSetCrsr)(&aDocPos, sal_False); 5523 bRet = sal_True; 5524 } 5525 } 5526 if( !bOverURLGrf ) 5527 { 5528 const int nSelType = rSh.GetSelectionType(); 5529 if( nSelType == nsSelectionType::SEL_OLE || 5530 nSelType == nsSelectionType::SEL_GRF ) 5531 { 5532 MV_KONTEXT( &rSh ); 5533 if( !rSh.IsFrmSelected() ) 5534 rSh.GotoNextFly(); 5535 rSh.EnterSelFrmMode(); 5536 bRet = sal_True; 5537 } 5538 } 5539 return bRet; 5540 } 5541 5542 SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType ) 5543 { 5544 //Shell ermitteln 5545 SfxShell* pShell; 5546 SfxDispatcher* pDispatcher = rView.GetViewFrame()->GetDispatcher(); 5547 for(sal_uInt16 i = 0; sal_True; ++i ) 5548 { 5549 pShell = pDispatcher->GetShell( i ); 5550 if( !pShell || pShell->IsA( nType ) ) 5551 break; 5552 } 5553 return pShell; 5554 } 5555 5556 5557 5558 void SwEditWin::ClearTip() 5559 { 5560 } 5561 5562 IMPL_LINK( SwEditWin, KeyInputFlushHandler, Timer *, EMPTYARG ) 5563 { 5564 FlushInBuffer(); 5565 return 0; 5566 } 5567 5568 5569 IMPL_LINK( SwEditWin, KeyInputTimerHandler, Timer *, EMPTYARG ) 5570 { 5571 bTblInsDelMode = sal_False; 5572 return 0; 5573 } 5574 5575 void SwEditWin::_InitStaticData() 5576 { 5577 pQuickHlpData = new QuickHelpData(); 5578 } 5579 5580 void SwEditWin::_FinitStaticData() 5581 { 5582 delete pQuickHlpData; 5583 } 5584 /* -----------------23.01.2003 12:15----------------- 5585 * #i3370# remove quick help to prevent saving 5586 * of autocorrection suggestions 5587 * --------------------------------------------------*/ 5588 void SwEditWin::StopQuickHelp() 5589 { 5590 if( HasFocus() && pQuickHlpData && pQuickHlpData->bClear ) 5591 pQuickHlpData->Stop( rView.GetWrtShell() ); 5592 } 5593 5594 /*-----------------23.02.97 18:39------------------- 5595 5596 --------------------------------------------------*/ 5597 5598 5599 IMPL_LINK(SwEditWin, TemplateTimerHdl, Timer*, EMPTYARG) 5600 { 5601 SetApplyTemplate(SwApplyTemplate()); 5602 return 0; 5603 } 5604 5605 5606 void SwEditWin::SetChainMode( sal_Bool bOn ) 5607 { 5608 if ( !bChainMode ) 5609 StopInsFrm(); 5610 5611 if ( pUserMarker ) 5612 { 5613 delete pUserMarker; 5614 pUserMarker = 0L; 5615 } 5616 5617 bChainMode = bOn; 5618 if ( !bChainMode ) 5619 rView.GetViewFrame()->HideStatusText(); 5620 5621 static sal_uInt16 __READONLY_DATA aInva[] = 5622 { 5623 FN_FRAME_CHAIN, FN_FRAME_UNCHAIN, 0 5624 }; 5625 rView.GetViewFrame()->GetBindings().Invalidate(aInva); 5626 } 5627 5628 uno::Reference< ::com::sun::star::accessibility::XAccessible > SwEditWin::CreateAccessible() 5629 { 5630 vos::OGuard aGuard(Application::GetSolarMutex()); // this should have 5631 // happend already!!! 5632 SwWrtShell *pSh = rView.GetWrtShellPtr(); 5633 ASSERT( pSh, "no writer shell, no accessible object" ); 5634 uno::Reference< 5635 ::com::sun::star::accessibility::XAccessible > xAcc; 5636 if( pSh ) 5637 xAcc = pSh->CreateAccessible(); 5638 5639 return xAcc; 5640 } 5641 5642 //------------------------------------------------------------- 5643 5644 void QuickHelpData::Move( QuickHelpData& rCpy ) 5645 { 5646 // Pointer verschieben 5647 aArr.Insert( &rCpy.aArr ); 5648 rCpy.aArr.Remove( (sal_uInt16)0, rCpy.aArr.Count() ); 5649 // nTipId = rCpy.nTipId; 5650 bClear = rCpy.bClear; 5651 nLen = rCpy.nLen; 5652 nCurArrPos = rCpy.nCurArrPos; 5653 bChkInsBlank = rCpy.bChkInsBlank; 5654 bIsTip = rCpy.bIsTip; 5655 bIsAutoText = rCpy.bIsAutoText; 5656 5657 if( pCETID ) delete pCETID; 5658 pCETID = rCpy.pCETID; 5659 rCpy.pCETID = 0; 5660 5661 if( pAttrs ) 5662 delete[] pAttrs; 5663 pAttrs = rCpy.pAttrs; 5664 rCpy.pAttrs = 0; 5665 } 5666 5667 void QuickHelpData::ClearCntnt() 5668 { 5669 nLen = nCurArrPos = 0; 5670 bClear = bChkInsBlank = sal_False; 5671 nTipId = 0; 5672 aArr.DeleteAndDestroy( 0 , aArr.Count() ); 5673 bIsTip = sal_True; 5674 bIsAutoText = sal_True; 5675 delete pCETID, pCETID = 0; 5676 delete[] pAttrs, pAttrs = 0; 5677 } 5678 5679 5680 void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen ) 5681 { 5682 if( pCETID ) delete pCETID, pCETID = 0; 5683 if( pAttrs ) delete[] pAttrs, pAttrs = 0; 5684 5685 if( USHRT_MAX != nWrdLen ) 5686 { 5687 nLen = nWrdLen; 5688 nCurArrPos = 0; 5689 } 5690 bClear = sal_True; 5691 5692 Window& rWin = rSh.GetView().GetEditWin(); 5693 if( bIsTip ) 5694 { 5695 Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel( 5696 rSh.GetCharRect().Pos() ))); 5697 aPt.Y() -= 3; 5698 nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )), 5699 *aArr[ nCurArrPos ], 5700 QUICKHELP_LEFT | QUICKHELP_BOTTOM ); 5701 } 5702 else 5703 { 5704 String sStr( *aArr[ nCurArrPos ] ); 5705 sStr.Erase( 0, nLen ); 5706 sal_uInt16 nL = sStr.Len(); 5707 pAttrs = new sal_uInt16[ nL ]; 5708 for( sal_uInt16 n = nL; n; ) 5709 *(pAttrs + --n ) = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE | 5710 EXTTEXTINPUT_ATTR_HIGHLIGHT; 5711 pCETID = new CommandExtTextInputData( sStr, pAttrs, nL, 5712 0, 0, 0, sal_False ); 5713 rSh.CreateExtTextInput(rWin.GetInputLanguage()); 5714 rSh.SetExtTextInputData( *pCETID ); 5715 } 5716 } 5717 5718 void QuickHelpData::Stop( SwWrtShell& rSh ) 5719 { 5720 if( !bIsTip ) 5721 rSh.DeleteExtTextInput( 0, sal_False ); 5722 else if( nTipId ) 5723 Help::HideTip( nTipId ); 5724 ClearCntnt(); 5725 } 5726 5727 void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord ) 5728 { 5729 // #i22961# get the letter-case context 5730 const CharClass& rCharClass = GetAppCharClass(); 5731 const String aLWord = rCharClass.toLower( rWord, 0, rWord.Len() ); 5732 const bool bIsUpper = (rWord == rCharClass.toUpper( rWord, 0, rWord.Len() ) ); 5733 const bool bIsLower = (rWord == aLWord); 5734 5735 // add all matching month/day names from the calendar 5736 salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper(); 5737 (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() ); 5738 5739 { 5740 uno::Sequence< i18n::CalendarItem > aNames( 5741 (*pCalendar)->getMonths() ); 5742 for( int n = 0; n < 2; ++n ) 5743 { 5744 for( long nPos = 0, nEnd = aNames.getLength(); nPos < nEnd; ++nPos ) 5745 { 5746 const String& rS = aNames[ nPos ].FullName; 5747 if( rS.Len() <= rWord.Len() + 1 ) 5748 continue; 5749 const String aLName = rCharClass.toLower( rS, 0, rWord.Len() ); 5750 if( aLName != aLWord ) 5751 continue; 5752 // #i22961# provide case-sensitive autocompletion suggestions 5753 String* pNew = new String( (bIsUpper==bIsLower) ? rS : (bIsUpper ? rCharClass.toUpper(rS,0,rS.Len()) : rCharClass.toLower(rS,0,rS.Len())) ); 5754 if( !aArr.Insert( pNew ) ) 5755 delete pNew; 5756 } 5757 if( !n ) // get data for the second loop 5758 aNames = (*pCalendar)->getDays(); 5759 } 5760 } 5761 5762 // and then add all words from the AutoCompleteWord-List 5763 const SwAutoCompleteWord& rACLst = rSh.GetAutoCompleteWords(); 5764 sal_uInt16 nStt, nEnd; 5765 if( rACLst.GetRange( rWord, nStt, nEnd ) ) 5766 { 5767 for(; nStt < nEnd; ++nStt ) 5768 { 5769 const String& rS = rACLst[ nStt ]; 5770 if( rS.Len() <= rWord.Len() ) 5771 continue; 5772 // #i22961# provide case-sensitive autocompletion suggestions 5773 String* pNew = new String( (bIsUpper==bIsLower) ? rS : (bIsUpper ? rCharClass.toUpper(rS,0,rS.Len()) : rCharClass.toLower(rS,0,rS.Len())) ); 5774 if( !aArr.Insert( pNew ) ) 5775 delete pNew; 5776 } 5777 } 5778 } 5779 5780 void SwEditWin::ShowAutoTextCorrectQuickHelp( 5781 const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr, 5782 sal_Bool bFromIME ) 5783 { 5784 SwWrtShell& rSh = rView.GetWrtShell(); 5785 pQuickHlpData->ClearCntnt(); 5786 if( pACfg->IsAutoTextTip() ) 5787 { 5788 SwGlossaryList* pList = ::GetGlossaryList(); 5789 pList->HasLongName( rWord, &pQuickHlpData->aArr ); 5790 } 5791 5792 if( pQuickHlpData->aArr.Count() ) 5793 { 5794 pQuickHlpData->bIsTip = sal_True; 5795 pQuickHlpData->bIsAutoText = sal_True; 5796 } 5797 else if( pACorr->GetSwFlags().bAutoCompleteWords ) 5798 { 5799 pQuickHlpData->bIsAutoText = sal_False; 5800 pQuickHlpData->bIsTip = bFromIME || 5801 !pACorr || 5802 pACorr->GetSwFlags().bAutoCmpltShowAsTip; 5803 5804 pQuickHlpData->FillStrArr( rSh, rWord ); 5805 } 5806 5807 if( pQuickHlpData->aArr.Count() ) 5808 pQuickHlpData->Start( rSh, rWord.Len() ); 5809 } 5810 5811 /* -----------------29.03.2006 11:01----------------- 5812 * 5813 * --------------------------------------------------*/ 5814 5815 void SwEditWin::SetUseInputLanguage( sal_Bool bNew ) 5816 { 5817 if ( bNew || bUseInputLanguage ) 5818 { 5819 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings(); 5820 rBind.Invalidate( SID_ATTR_CHAR_FONT ); 5821 rBind.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 5822 } 5823 bUseInputLanguage = bNew; 5824 } 5825 5826 /*-- 13.11.2008 10:18:17--------------------------------------------------- 5827 5828 -----------------------------------------------------------------------*/ 5829 XubString SwEditWin::GetSurroundingText() const 5830 { 5831 String sReturn; 5832 SwWrtShell& rSh = rView.GetWrtShell(); 5833 if( rSh.HasSelection() && !rSh.IsMultiSelection() && rSh.IsSelOnePara() ) 5834 rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR ); 5835 else if( !rSh.HasSelection() ) 5836 { 5837 SwPosition *pPos = rSh.GetCrsr()->GetPoint(); 5838 xub_StrLen nPos = pPos->nContent.GetIndex(); 5839 5840 // get the sentence around the cursor 5841 rSh.HideCrsr(); 5842 rSh.GoStartSentence(); 5843 rSh.SetMark(); 5844 rSh.GoEndSentence(); 5845 rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR ); 5846 5847 pPos->nContent = nPos; 5848 rSh.ClearMark(); 5849 rSh.HideCrsr(); 5850 } 5851 5852 return sReturn; 5853 } 5854 /*-- 13.11.2008 10:18:17--------------------------------------------------- 5855 5856 -----------------------------------------------------------------------*/ 5857 Selection SwEditWin::GetSurroundingTextSelection() const 5858 { 5859 SwWrtShell& rSh = rView.GetWrtShell(); 5860 if( rSh.HasSelection() ) 5861 { 5862 String sReturn; 5863 rSh.GetSelectedText( sReturn, GETSELTXT_PARABRK_TO_ONLYCR ); 5864 return Selection( 0, sReturn.Len() ); 5865 } 5866 else 5867 { 5868 // Return the position of the visible cursor in the sentence 5869 // around the visible cursor. 5870 SwPosition *pPos = rSh.GetCrsr()->GetPoint(); 5871 xub_StrLen nPos = pPos->nContent.GetIndex(); 5872 5873 rSh.HideCrsr(); 5874 rSh.GoStartSentence(); 5875 xub_StrLen nStartPos = rSh.GetCrsr()->GetPoint()->nContent.GetIndex(); 5876 5877 pPos->nContent = nPos; 5878 rSh.ClearMark(); 5879 rSh.ShowCrsr(); 5880 5881 return Selection( nPos - nStartPos, nPos - nStartPos ); 5882 } 5883 } 5884