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