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