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