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