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