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