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