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