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