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