xref: /trunk/main/sw/source/ui/wrtsh/select.cxx (revision 2b5187381cc9da7a87bafe24be64619d7f077545)
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 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <limits.h>
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <sfx2/bindings.hxx>
28cdf0e10cSrcweir #include <svl/eitem.hxx>
29cdf0e10cSrcweir #include <svl/macitem.hxx>
30cdf0e10cSrcweir #include <unotools/charclass.hxx>
31cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
32cdf0e10cSrcweir #include <cmdid.h>
33cdf0e10cSrcweir #include <view.hxx>
34cdf0e10cSrcweir #include <basesh.hxx>
35cdf0e10cSrcweir #include <wrtsh.hxx>
36cdf0e10cSrcweir #include <frmatr.hxx>
37cdf0e10cSrcweir #include <initui.hxx>
38cdf0e10cSrcweir #include <mdiexp.hxx>
39cdf0e10cSrcweir #include <fmtcol.hxx>
40cdf0e10cSrcweir #include <frmfmt.hxx>
41cdf0e10cSrcweir #include <swundo.hxx>                   // fuer Undo-Ids
42cdf0e10cSrcweir #include <swevent.hxx>
43cdf0e10cSrcweir #include <swdtflvr.hxx>
44cdf0e10cSrcweir #include <crsskip.hxx>
45cdf0e10cSrcweir 
46ca62e2c2SSteve Yin #ifndef _DOC_HXX
47ca62e2c2SSteve Yin #include <doc.hxx>
48ca62e2c2SSteve Yin #endif
49cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
50cdf0e10cSrcweir #include <pam.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace util {
54cdf0e10cSrcweir     struct SearchOptions;
55cdf0e10cSrcweir } } } }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir using namespace ::com::sun::star::util;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir static long nStartDragX = 0, nStartDragY = 0;
60cdf0e10cSrcweir static sal_Bool  bStartDrag = sal_False;
61cdf0e10cSrcweir 
Invalidate()62cdf0e10cSrcweir void SwWrtShell::Invalidate()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir     // to avoid making the slot volatile, invalidate it every time if something could have been changed
65cdf0e10cSrcweir     // this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
66cdf0e10cSrcweir     GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE );
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
SelNearestWrd()69cdf0e10cSrcweir sal_Bool SwWrtShell::SelNearestWrd()
70cdf0e10cSrcweir {
71*2b518738Smseidel     MV_CONTEXT(this);
72cdf0e10cSrcweir     if( !IsInWrd() && !IsEndWrd() && !IsSttWrd() )
73cdf0e10cSrcweir         PrvWrd();
74cdf0e10cSrcweir     if( IsEndWrd() )
75cdf0e10cSrcweir         Left(CRSR_SKIP_CELLS, sal_False, 1, sal_False );
76cdf0e10cSrcweir     return SelWrd();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
SelWrd(const Point * pPt,sal_Bool)81cdf0e10cSrcweir sal_Bool SwWrtShell::SelWrd(const Point *pPt, sal_Bool )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     sal_Bool bRet;
84cdf0e10cSrcweir     {
85*2b518738Smseidel         MV_CONTEXT(this);
86cdf0e10cSrcweir         SttSelect();
87cdf0e10cSrcweir         bRet = SwCrsrShell::SelectWord( pPt );
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir     EndSelect();
90cdf0e10cSrcweir     if( bRet )
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         bSelWrd = sal_True;
93cdf0e10cSrcweir         if(pPt)
94cdf0e10cSrcweir             aStart = *pPt;
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir     return bRet;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
SelSentence(const Point * pPt,sal_Bool)99cdf0e10cSrcweir void SwWrtShell::SelSentence(const Point *pPt, sal_Bool )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     {
102*2b518738Smseidel         MV_CONTEXT(this);
103cdf0e10cSrcweir         ClearMark();
104cdf0e10cSrcweir         SwCrsrShell::GoStartSentence();
105cdf0e10cSrcweir         SttSelect();
106cdf0e10cSrcweir         SwCrsrShell::GoEndSentence();
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir     EndSelect();
109cdf0e10cSrcweir     if(pPt)
110cdf0e10cSrcweir         aStart = *pPt;
111cdf0e10cSrcweir     bSelLn = sal_True;
112cdf0e10cSrcweir     bSelWrd = sal_False;    // SelWord abschalten, sonst geht kein SelLine weiter
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
SelPara(const Point * pPt,sal_Bool)115cdf0e10cSrcweir void SwWrtShell::SelPara(const Point *pPt, sal_Bool )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     {
118*2b518738Smseidel         MV_CONTEXT(this);
119cdf0e10cSrcweir         ClearMark();
120cdf0e10cSrcweir         SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
121cdf0e10cSrcweir         SttSelect();
122cdf0e10cSrcweir         SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir     EndSelect();
125cdf0e10cSrcweir     if(pPt)
126cdf0e10cSrcweir         aStart = *pPt;
127cdf0e10cSrcweir     bSelLn = sal_False;
128cdf0e10cSrcweir     bSelWrd = sal_False;    // SelWord abschalten, sonst geht kein SelLine weiter
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
SelAll()132cdf0e10cSrcweir long SwWrtShell::SelAll()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     const sal_Bool bLockedView = IsViewLocked();
135cdf0e10cSrcweir     LockView( sal_True );
136cdf0e10cSrcweir     {
137cdf0e10cSrcweir         if(bBlockMode)
138cdf0e10cSrcweir             LeaveBlockMode();
139*2b518738Smseidel         MV_CONTEXT(this);
140cdf0e10cSrcweir         sal_Bool bMoveTable = sal_False;
141cdf0e10cSrcweir         SwPosition *pStartPos = 0;
142cdf0e10cSrcweir         SwPosition *pEndPos = 0;
143cdf0e10cSrcweir         SwShellCrsr* pTmpCrsr = 0;
144cdf0e10cSrcweir         if( !HasWholeTabSelection() )
145cdf0e10cSrcweir         {
146cdf0e10cSrcweir             if ( IsSelection() && IsCrsrPtAtEnd() )
147cdf0e10cSrcweir                 SwapPam();
148cdf0e10cSrcweir             pTmpCrsr = getShellCrsr( false );
149cdf0e10cSrcweir             if( pTmpCrsr )
150cdf0e10cSrcweir             {
151cdf0e10cSrcweir                 pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
152cdf0e10cSrcweir                 pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
153cdf0e10cSrcweir             }
154cdf0e10cSrcweir             Push();
155cdf0e10cSrcweir             sal_Bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
156cdf0e10cSrcweir             SwapPam();
157cdf0e10cSrcweir             bIsFullSel &= !MoveSection( fnSectionCurr, fnSectionEnd);
158cdf0e10cSrcweir             Pop(sal_False);
159cdf0e10cSrcweir             GoStart(sal_True, &bMoveTable, sal_False, !bIsFullSel);
160cdf0e10cSrcweir         }
161cdf0e10cSrcweir         else
162cdf0e10cSrcweir         {
163cdf0e10cSrcweir             EnterStdMode();
164cdf0e10cSrcweir             SttEndDoc(sal_True);
165cdf0e10cSrcweir         }
166cdf0e10cSrcweir         SttSelect();
167cdf0e10cSrcweir         GoEnd(sal_True, &bMoveTable);
168ca62e2c2SSteve Yin 
169ca62e2c2SSteve Yin         SwDoc *pDoc = GetDoc();
170ca62e2c2SSteve Yin         if ( pDoc )
171ca62e2c2SSteve Yin         {
172ca62e2c2SSteve Yin             pDoc->SetPrepareSelAll();
173ca62e2c2SSteve Yin         }
174cdf0e10cSrcweir         if( pStartPos )
175cdf0e10cSrcweir         {
176cdf0e10cSrcweir             pTmpCrsr = getShellCrsr( false );
177cdf0e10cSrcweir             if( pTmpCrsr )
178cdf0e10cSrcweir             {
179cdf0e10cSrcweir                 // Some special handling for sections (e.g. TOC) at the beginning of the document body
180cdf0e10cSrcweir                 // to avoid the selection of the first section
181cdf0e10cSrcweir                 // if the last selection was behind the first section or
182cdf0e10cSrcweir                 // if the last selection was already the first section
183cdf0e10cSrcweir                 // In this both cases we select to the end of document
184cdf0e10cSrcweir                 if( *pTmpCrsr->GetPoint() < *pEndPos ||
185cdf0e10cSrcweir                     ( *pStartPos == *pTmpCrsr->GetMark() &&
186cdf0e10cSrcweir                       *pEndPos == *pTmpCrsr->GetPoint() ) )
187cdf0e10cSrcweir                     SwCrsrShell::SttEndDoc(sal_False);
188cdf0e10cSrcweir             }
189cdf0e10cSrcweir             delete pStartPos;
190cdf0e10cSrcweir             delete pEndPos;
191cdf0e10cSrcweir         }
192cdf0e10cSrcweir     }
193cdf0e10cSrcweir     EndSelect();
194cdf0e10cSrcweir     LockView( bLockedView );
195cdf0e10cSrcweir     return 1;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir /*------------------------------------------------------------------------
199cdf0e10cSrcweir  Beschreibung:  Textsuche
200cdf0e10cSrcweir ------------------------------------------------------------------------*/
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
SearchPattern(const SearchOptions & rSearchOpt,sal_Bool bSearchInNotes,SwDocPositions eStt,SwDocPositions eEnd,FindRanges eFlags,int bReplace)203cdf0e10cSrcweir sal_uLong SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, sal_Bool bSearchInNotes,
204cdf0e10cSrcweir                                 SwDocPositions eStt, SwDocPositions eEnd,
205cdf0e10cSrcweir                                 FindRanges eFlags, int bReplace )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir         // keine Erweiterung bestehender Selektionen
208cdf0e10cSrcweir     if(!(eFlags & FND_IN_SEL))
209cdf0e10cSrcweir         ClearMark();
210cdf0e10cSrcweir     sal_Bool bCancel = sal_False;
211cdf0e10cSrcweir     sal_uLong nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace );
212cdf0e10cSrcweir     if(bCancel)
213cdf0e10cSrcweir     {
214cdf0e10cSrcweir         Undo(1);
215cdf0e10cSrcweir         nRet = ULONG_MAX;
216cdf0e10cSrcweir     }
217cdf0e10cSrcweir     return nRet;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir /*------------------------------------------------------------------------
220cdf0e10cSrcweir  Beschreibung:  Suche nach Vorlagen
221cdf0e10cSrcweir ------------------------------------------------------------------------*/
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 
SearchTempl(const String & rTempl,SwDocPositions eStt,SwDocPositions eEnd,FindRanges eFlags,const String * pReplTempl)225cdf0e10cSrcweir sal_uLong SwWrtShell::SearchTempl( const String &rTempl,
226cdf0e10cSrcweir                                SwDocPositions eStt, SwDocPositions eEnd,
227cdf0e10cSrcweir                                FindRanges eFlags, const String* pReplTempl )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir         // keine Erweiterung bestehender Selektionen
230cdf0e10cSrcweir     if(!(eFlags & FND_IN_SEL))
231cdf0e10cSrcweir         ClearMark();
232cdf0e10cSrcweir     SwTxtFmtColl *pColl = GetParaStyle(rTempl, SwWrtShell::GETSTYLE_CREATESOME);
233cdf0e10cSrcweir     SwTxtFmtColl *pReplaceColl = 0;
234cdf0e10cSrcweir     if( pReplTempl )
235cdf0e10cSrcweir         pReplaceColl = GetParaStyle(*pReplTempl, SwWrtShell::GETSTYLE_CREATESOME );
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     sal_Bool bCancel = sal_False;
238cdf0e10cSrcweir     sal_uLong nRet = Find(pColl? *pColl: GetDfltTxtFmtColl(),
239cdf0e10cSrcweir                                eStt,eEnd, bCancel, eFlags, pReplaceColl);
240cdf0e10cSrcweir     if(bCancel)
241cdf0e10cSrcweir     {
242cdf0e10cSrcweir         Undo(1);
243cdf0e10cSrcweir         nRet = ULONG_MAX;
244cdf0e10cSrcweir     }
245cdf0e10cSrcweir     return nRet;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir // Suche nach Attributen ----------------------------------------------------
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 
SearchAttr(const SfxItemSet & rFindSet,sal_Bool bNoColls,SwDocPositions eStart,SwDocPositions eEnde,FindRanges eFlags,const SearchOptions * pSearchOpt,const SfxItemSet * pReplaceSet)252cdf0e10cSrcweir sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, sal_Bool bNoColls,
253cdf0e10cSrcweir                                 SwDocPositions eStart, SwDocPositions eEnde,
254cdf0e10cSrcweir                                 FindRanges eFlags, const SearchOptions* pSearchOpt,
255cdf0e10cSrcweir                                 const SfxItemSet* pReplaceSet )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir     // Keine Erweiterung bestehender Selektionen
258cdf0e10cSrcweir     if (!(eFlags & FND_IN_SEL))
259cdf0e10cSrcweir         ClearMark();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     // Suchen
262cdf0e10cSrcweir     sal_Bool bCancel = sal_False;
263cdf0e10cSrcweir     sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     if(bCancel)
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         Undo(1);
268cdf0e10cSrcweir         nRet = ULONG_MAX;
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir     return nRet;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir // ---------- Selektionsmodi ----------
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 
PushMode()277cdf0e10cSrcweir void SwWrtShell::PushMode()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir     pModeStack = new ModeStack( pModeStack, bIns, bExtMode, bAddMode, bBlockMode );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 
PopMode()284cdf0e10cSrcweir void SwWrtShell::PopMode()
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     if ( 0 == pModeStack )
287cdf0e10cSrcweir         return;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     if ( bExtMode && !pModeStack->bExt )
290cdf0e10cSrcweir         LeaveExtMode();
291cdf0e10cSrcweir     if ( bAddMode && !pModeStack->bAdd )
292cdf0e10cSrcweir         LeaveAddMode();
293cdf0e10cSrcweir     if ( bBlockMode && !pModeStack->bBlock )
294cdf0e10cSrcweir         LeaveBlockMode();
295cdf0e10cSrcweir     bIns = pModeStack->bIns;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     ModeStack *pTmp = pModeStack->pNext;
298cdf0e10cSrcweir     delete pModeStack;
299cdf0e10cSrcweir     pModeStack = pTmp;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir 
302cdf0e10cSrcweir /*
303*2b518738Smseidel  * Zwei Methoden für das Cursorsetzen; die erste mappt auf die
304cdf0e10cSrcweir  * gleichnamige Methoden an der CursorShell, die zweite hebt
305cdf0e10cSrcweir  * zuerst alle Selektionen auf.
306cdf0e10cSrcweir  */
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 
SetCrsr(const Point * pPt,sal_Bool bTextOnly)310cdf0e10cSrcweir long SwWrtShell::SetCrsr(const Point *pPt, sal_Bool bTextOnly)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir         /*
313*2b518738Smseidel         * eine ggfs. bestehende Selektion an der Position des
314cdf0e10cSrcweir         * Mausklicks aufheben
315cdf0e10cSrcweir         */
316cdf0e10cSrcweir     if(!IsInSelect() && ChgCurrPam(*pPt)) {
317cdf0e10cSrcweir         ClearMark();
318cdf0e10cSrcweir     }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
321cdf0e10cSrcweir }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 
SetCrsrKillSel(const Point * pPt,sal_Bool bTextOnly)324cdf0e10cSrcweir long SwWrtShell::SetCrsrKillSel(const Point *pPt, sal_Bool bTextOnly )
325cdf0e10cSrcweir {
326*2b518738Smseidel     ACT_CONTEXT(this);
327cdf0e10cSrcweir     ResetSelect(pPt,sal_False);
328cdf0e10cSrcweir     return SwCrsrShell::SetCrsr(*pPt, bTextOnly);
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 
UnSelectFrm()333cdf0e10cSrcweir void SwWrtShell::UnSelectFrm()
334cdf0e10cSrcweir {
335*2b518738Smseidel     // Rahmenselektion aufheben mit garantiert ungültiger Position
336cdf0e10cSrcweir     Point aPt(LONG_MIN, LONG_MIN);
337cdf0e10cSrcweir     SelectObj(aPt, 0);
338cdf0e10cSrcweir     SwTransferable::ClearSelection( *this );
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir /*
342cdf0e10cSrcweir  * Aufheben aller Selektionen
343cdf0e10cSrcweir  */
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 
ResetSelect(const Point *,sal_Bool)347cdf0e10cSrcweir long SwWrtShell::ResetSelect(const Point *,sal_Bool)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir     if(IsSelFrmMode())
350cdf0e10cSrcweir     {
351cdf0e10cSrcweir         UnSelectFrm();
352cdf0e10cSrcweir         LeaveSelFrmMode();
353cdf0e10cSrcweir     }
354cdf0e10cSrcweir     else
355cdf0e10cSrcweir     {
356*2b518738Smseidel         /*  ACT_CONTEXT() macht eine Action auf -
357cdf0e10cSrcweir             um im Basicablauf keine Probleme mit der
358cdf0e10cSrcweir             Shellumschaltung zu bekommen, darf
359cdf0e10cSrcweir             GetChgLnk().Call() erst nach
360cdf0e10cSrcweir             EndAction() gerufen werden.
361cdf0e10cSrcweir         */
362cdf0e10cSrcweir         {
363*2b518738Smseidel             ACT_CONTEXT(this);
364cdf0e10cSrcweir             bSelWrd = bSelLn = sal_False;
365cdf0e10cSrcweir             KillPams();
366cdf0e10cSrcweir             ClearMark();
367cdf0e10cSrcweir             fnKillSel = &SwWrtShell::Ignore;
368cdf0e10cSrcweir             fnSetCrsr = &SwWrtShell::SetCrsr;
369cdf0e10cSrcweir         }
370cdf0e10cSrcweir         /*
371*2b518738Smseidel             * nach dem Aufheben aller Selektionen könnte ein Update der
372cdf0e10cSrcweir             * Attr-Controls notwendig sein.
373cdf0e10cSrcweir         */
374cdf0e10cSrcweir         GetChgLnk().Call(this);
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir     Invalidate();
377cdf0e10cSrcweir     SwTransferable::ClearSelection( *this );
378cdf0e10cSrcweir     return 1;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir /*
384cdf0e10cSrcweir  * tue nichts
385cdf0e10cSrcweir  */
Ignore(const Point *,sal_Bool)386cdf0e10cSrcweir long SwWrtShell::Ignore(const Point *, sal_Bool ) {
387cdf0e10cSrcweir     return 1;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
390cdf0e10cSrcweir /*
391cdf0e10cSrcweir  * Start eines Selektionsvorganges.
392cdf0e10cSrcweir  */
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 
SttSelect()396cdf0e10cSrcweir void SwWrtShell::SttSelect()
397cdf0e10cSrcweir {
398cdf0e10cSrcweir     if(bInSelect)
399cdf0e10cSrcweir         return;
400cdf0e10cSrcweir     if(!HasMark())
401cdf0e10cSrcweir         SetMark();
402cdf0e10cSrcweir     if( bBlockMode )
403cdf0e10cSrcweir     {
404cdf0e10cSrcweir         SwShellCrsr* pTmp = getShellCrsr( true );
405cdf0e10cSrcweir         if( !pTmp->HasMark() )
406cdf0e10cSrcweir             pTmp->SetMark();
407cdf0e10cSrcweir     }
408cdf0e10cSrcweir     fnKillSel = &SwWrtShell::Ignore;
409cdf0e10cSrcweir     fnSetCrsr = &SwWrtShell::SetCrsr;
410cdf0e10cSrcweir     bInSelect = sal_True;
411cdf0e10cSrcweir     Invalidate();
412cdf0e10cSrcweir     SwTransferable::CreateSelection( *this );
413cdf0e10cSrcweir }
414cdf0e10cSrcweir /*
415cdf0e10cSrcweir  * Ende eines Selektionsvorganges.
416cdf0e10cSrcweir  */
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 
EndSelect()420cdf0e10cSrcweir void SwWrtShell::EndSelect()
421cdf0e10cSrcweir {
422cdf0e10cSrcweir     if(!bInSelect || bExtMode)
423cdf0e10cSrcweir         return;
424cdf0e10cSrcweir     bInSelect = sal_False;
425cdf0e10cSrcweir     (this->*fnLeaveSelect)(0,sal_False);
426cdf0e10cSrcweir     if(!bAddMode) {
427cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
428cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
429cdf0e10cSrcweir     }
430cdf0e10cSrcweir }
431cdf0e10cSrcweir /* Methode, um eine bestehende wortweise oder zeilenweise Selektion
432cdf0e10cSrcweir  * zu erweitern.
433cdf0e10cSrcweir  */
434cdf0e10cSrcweir 
operator <(const Point & rP1,const Point & rP2)435cdf0e10cSrcweir inline sal_Bool operator<(const Point &rP1,const Point &rP2)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir     return rP1.Y() < rP2.Y() || (rP1.Y() == rP2.Y() && rP1.X() < rP2.X());
438cdf0e10cSrcweir }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 
ExtSelWrd(const Point * pPt,sal_Bool)442cdf0e10cSrcweir long SwWrtShell::ExtSelWrd(const Point *pPt, sal_Bool )
443cdf0e10cSrcweir {
444*2b518738Smseidel     MV_CONTEXT(this);
445cdf0e10cSrcweir     if( IsTableMode() )
446cdf0e10cSrcweir         return 1;
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     // Bug 66823: actual crsr has in additional mode no selection?
449cdf0e10cSrcweir     // Then destroy the actual an go to prev, this will be expand
450cdf0e10cSrcweir     if( !HasMark() && GoPrevCrsr() )
451cdf0e10cSrcweir     {
452cfd52e18Smseidel         sal_Bool bHasMark = HasMark(); // that's wrong!
453cdf0e10cSrcweir         GoNextCrsr();
454cdf0e10cSrcweir         if( bHasMark )
455cdf0e10cSrcweir         {
456cdf0e10cSrcweir             DestroyCrsr();
457cdf0e10cSrcweir             GoPrevCrsr();
458cdf0e10cSrcweir         }
459cdf0e10cSrcweir     }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     // check the direction of the selection with the new point
462cdf0e10cSrcweir     sal_Bool bRet = sal_False, bMoveCrsr = sal_True, bToTop = sal_False;
463cdf0e10cSrcweir     SwCrsrShell::SelectWord( &aStart );     // select the startword
464cdf0e10cSrcweir     SwCrsrShell::Push();                    // save the cursor
465cdf0e10cSrcweir     SwCrsrShell::SetCrsr( *pPt );           // and check the direction
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     switch( SwCrsrShell::CompareCursor( StackMkCurrPt ))
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir     case -1:    bToTop = sal_False;     break;
470cdf0e10cSrcweir     case 1:     bToTop = sal_True;      break;
471cdf0e10cSrcweir     default:    bMoveCrsr = sal_False;  break;
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir     SwCrsrShell::Pop( sal_False );              // retore the saved cursor
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     if( bMoveCrsr )
477cdf0e10cSrcweir     {
478cdf0e10cSrcweir         // select to Top but cursor select to Bottom? or
479cdf0e10cSrcweir         // select to Bottom but cursor select to Top?       --> swap the cursor
480cdf0e10cSrcweir         if( bToTop )
481cdf0e10cSrcweir             SwapPam();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir         SwCrsrShell::Push();                // save cur cursor
484cdf0e10cSrcweir         if( SwCrsrShell::SelectWord( pPt )) // select the current word
485cdf0e10cSrcweir         {
486cdf0e10cSrcweir             if( bToTop )
487cdf0e10cSrcweir                 SwapPam();
488cdf0e10cSrcweir             Combine();
489cdf0e10cSrcweir             bRet = sal_True;
490cdf0e10cSrcweir         }
491cdf0e10cSrcweir         else
492cdf0e10cSrcweir         {
493cdf0e10cSrcweir             SwCrsrShell::Pop( sal_False );
494cdf0e10cSrcweir             if( bToTop )
495cdf0e10cSrcweir                 SwapPam();
496cdf0e10cSrcweir         }
497cdf0e10cSrcweir     }
498cdf0e10cSrcweir     else
499cdf0e10cSrcweir         bRet = sal_True;
500cdf0e10cSrcweir     return bRet;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 
ExtSelLn(const Point * pPt,sal_Bool)504cdf0e10cSrcweir long SwWrtShell::ExtSelLn(const Point *pPt, sal_Bool )
505cdf0e10cSrcweir {
506*2b518738Smseidel     MV_CONTEXT(this);
507cdf0e10cSrcweir     SwCrsrShell::SetCrsr(*pPt);
508cdf0e10cSrcweir     if( IsTableMode() )
509cdf0e10cSrcweir         return 1;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     // Bug 66823: actual crsr has in additional mode no selection?
512cdf0e10cSrcweir     // Then destroy the actual an go to prev, this will be expand
513cdf0e10cSrcweir     if( !HasMark() && GoPrevCrsr() )
514cdf0e10cSrcweir     {
515cfd52e18Smseidel         sal_Bool bHasMark = HasMark(); // that's wrong!
516cdf0e10cSrcweir         GoNextCrsr();
517cdf0e10cSrcweir         if( bHasMark )
518cdf0e10cSrcweir         {
519cdf0e10cSrcweir             DestroyCrsr();
520cdf0e10cSrcweir             GoPrevCrsr();
521cdf0e10cSrcweir         }
522cdf0e10cSrcweir     }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     // ggfs. den Mark der Selektion anpassen
525cdf0e10cSrcweir     sal_Bool bToTop = !IsCrsrPtAtEnd();
526cdf0e10cSrcweir     SwapPam();
527cdf0e10cSrcweir 
528cdf0e10cSrcweir     // der "Mark" muss am Zeilenende/-anfang stehen
529cdf0e10cSrcweir     if( bToTop ? !IsEndSentence() : !IsStartSentence() )
530cdf0e10cSrcweir     {
531cdf0e10cSrcweir         if( bToTop )
532cdf0e10cSrcweir         {
533cdf0e10cSrcweir             if( !IsEndPara() )
534cdf0e10cSrcweir                 SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
535cdf0e10cSrcweir             SwCrsrShell::GoEndSentence();
536cdf0e10cSrcweir         }
537cdf0e10cSrcweir         else
538cdf0e10cSrcweir             SwCrsrShell::GoStartSentence();
539cdf0e10cSrcweir     }
540cdf0e10cSrcweir     SwapPam();
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     return bToTop ? SwCrsrShell::GoStartSentence() : SwCrsrShell::GoEndSentence();
543cdf0e10cSrcweir }
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 
546cdf0e10cSrcweir /*
547*2b518738Smseidel  * zurück in den Standard Mode: kein Mode, keine Selektionen.
548cdf0e10cSrcweir  */
549cdf0e10cSrcweir 
EnterStdMode()550cdf0e10cSrcweir void SwWrtShell::EnterStdMode()
551cdf0e10cSrcweir {
552cdf0e10cSrcweir     if(bAddMode)
553cdf0e10cSrcweir         LeaveAddMode();
554cdf0e10cSrcweir     if(bBlockMode)
555cdf0e10cSrcweir         LeaveBlockMode();
556cdf0e10cSrcweir     bBlockMode = sal_False;
557cdf0e10cSrcweir     bExtMode = sal_False;
558cdf0e10cSrcweir     bInSelect = sal_False;
559cdf0e10cSrcweir     if(IsSelFrmMode())
560cdf0e10cSrcweir     {
561cdf0e10cSrcweir         UnSelectFrm();
562cdf0e10cSrcweir         LeaveSelFrmMode();
563cdf0e10cSrcweir     }
564cdf0e10cSrcweir     else
565cdf0e10cSrcweir     {
566*2b518738Smseidel         /*  ACT_CONTEXT() opens and action which has to be
567cdf0e10cSrcweir             closed prior to the call of
568cdf0e10cSrcweir             GetChgLnk().Call()
569cdf0e10cSrcweir         */
570cdf0e10cSrcweir         {
571*2b518738Smseidel             ACT_CONTEXT(this);
572cdf0e10cSrcweir             bSelWrd = bSelLn = sal_False;
573cdf0e10cSrcweir             if( !IsRetainSelection() )
574cdf0e10cSrcweir                 KillPams();
575cdf0e10cSrcweir             ClearMark();
576cdf0e10cSrcweir             fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
577cdf0e10cSrcweir             fnKillSel = &SwWrtShell::ResetSelect;
578cdf0e10cSrcweir         }
579cdf0e10cSrcweir     }
580cdf0e10cSrcweir     Invalidate();
581cdf0e10cSrcweir     SwTransferable::ClearSelection( *this );
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir /*
585cdf0e10cSrcweir  * Extended Mode
586cdf0e10cSrcweir  */
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 
EnterExtMode()590cdf0e10cSrcweir void SwWrtShell::EnterExtMode()
591cdf0e10cSrcweir {
592cdf0e10cSrcweir     if(bBlockMode)
593cdf0e10cSrcweir     {
594cdf0e10cSrcweir         LeaveBlockMode();
595cdf0e10cSrcweir         KillPams();
596cdf0e10cSrcweir         ClearMark();
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir     bExtMode = sal_True;
599cdf0e10cSrcweir     bAddMode = sal_False;
600cdf0e10cSrcweir     bBlockMode = sal_False;
601cdf0e10cSrcweir     SttSelect();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 
LeaveExtMode()606cdf0e10cSrcweir void SwWrtShell::LeaveExtMode()
607cdf0e10cSrcweir {
608cdf0e10cSrcweir     bExtMode = sal_False;
609cdf0e10cSrcweir     EndSelect();
610cdf0e10cSrcweir }
611cdf0e10cSrcweir /*
612cdf0e10cSrcweir  * Ende einer Selektion; falls die Selektion leer ist,
613cdf0e10cSrcweir  * ClearMark().
614cdf0e10cSrcweir  */
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 
SttLeaveSelect(const Point *,sal_Bool)618cdf0e10cSrcweir long SwWrtShell::SttLeaveSelect(const Point *, sal_Bool )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir     if(SwCrsrShell::HasSelection() && !IsSelTblCells() && bClearMark) {
621cdf0e10cSrcweir         return 0;
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir //  if( IsSelTblCells() ) aSelTblLink.Call(this);
624cdf0e10cSrcweir     ClearMark();
625cdf0e10cSrcweir     return 1;
626cdf0e10cSrcweir }
627cdf0e10cSrcweir /*
628cdf0e10cSrcweir  * Verlassen des Selektionsmodus in Additional Mode
629cdf0e10cSrcweir  */
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 
AddLeaveSelect(const Point *,sal_Bool)633cdf0e10cSrcweir long SwWrtShell::AddLeaveSelect(const Point *, sal_Bool )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir     if(IsTableMode()) LeaveAddMode();
636cdf0e10cSrcweir     else if(SwCrsrShell::HasSelection())
637cdf0e10cSrcweir         CreateCrsr();
638cdf0e10cSrcweir     return 1;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir /*
641cdf0e10cSrcweir  * Additional Mode
642cdf0e10cSrcweir  */
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 
EnterAddMode()646cdf0e10cSrcweir void SwWrtShell::EnterAddMode()
647cdf0e10cSrcweir {
648cdf0e10cSrcweir     if(IsTableMode()) return;
649cdf0e10cSrcweir     if(bBlockMode)
650cdf0e10cSrcweir         LeaveBlockMode();
651cdf0e10cSrcweir     fnLeaveSelect = &SwWrtShell::AddLeaveSelect;
652cdf0e10cSrcweir     fnKillSel = &SwWrtShell::Ignore;
653cdf0e10cSrcweir     fnSetCrsr = &SwWrtShell::SetCrsr;
654cdf0e10cSrcweir     bAddMode = sal_True;
655cdf0e10cSrcweir     bBlockMode = sal_False;
656cdf0e10cSrcweir     bExtMode = sal_False;
657cdf0e10cSrcweir     if(SwCrsrShell::HasSelection())
658cdf0e10cSrcweir         CreateCrsr();
659cdf0e10cSrcweir     Invalidate();
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 
LeaveAddMode()664cdf0e10cSrcweir void SwWrtShell::LeaveAddMode()
665cdf0e10cSrcweir {
666cdf0e10cSrcweir     fnLeaveSelect = &SwWrtShell::SttLeaveSelect;
667cdf0e10cSrcweir     fnKillSel = &SwWrtShell::ResetSelect;
668cdf0e10cSrcweir     fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
669cdf0e10cSrcweir     bAddMode = sal_False;
670cdf0e10cSrcweir     Invalidate();
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir /*
674cdf0e10cSrcweir  * Block Mode
675cdf0e10cSrcweir  */
676cdf0e10cSrcweir 
EnterBlockMode()677cdf0e10cSrcweir void SwWrtShell::EnterBlockMode()
678cdf0e10cSrcweir {
679cdf0e10cSrcweir     bBlockMode = sal_False;
680cdf0e10cSrcweir     EnterStdMode();
681cdf0e10cSrcweir     bBlockMode = sal_True;
682cdf0e10cSrcweir     CrsrToBlockCrsr();
683cdf0e10cSrcweir     Invalidate();
684cdf0e10cSrcweir }
685cdf0e10cSrcweir 
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 
LeaveBlockMode()688cdf0e10cSrcweir void SwWrtShell::LeaveBlockMode()
689cdf0e10cSrcweir {
690cdf0e10cSrcweir     bBlockMode = sal_False;
691cdf0e10cSrcweir     BlockCrsrToCrsr();
692cdf0e10cSrcweir     EndSelect();
693cdf0e10cSrcweir     Invalidate();
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir // Einfuegemodus
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 
SetInsMode(sal_Bool bOn)700cdf0e10cSrcweir void SwWrtShell::SetInsMode( sal_Bool bOn )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir     bIns = bOn;
703cdf0e10cSrcweir     SwCrsrShell::SetOverwriteCrsr( !bIns );
704cdf0e10cSrcweir     const SfxBoolItem aTmp( SID_ATTR_INSERT, bIns );
705cdf0e10cSrcweir     GetView().GetViewFrame()->GetBindings().SetState( aTmp );
706cdf0e10cSrcweir     StartAction();
707cdf0e10cSrcweir     EndAction();
708cdf0e10cSrcweir     Invalidate();
709cdf0e10cSrcweir }
710cdf0e10cSrcweir //Overwrite mode is incompatible with red-lining
SetRedlineModeAndCheckInsMode(sal_uInt16 eMode)711cdf0e10cSrcweir void SwWrtShell::SetRedlineModeAndCheckInsMode( sal_uInt16 eMode )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir    SetRedlineMode( eMode );
714cdf0e10cSrcweir    if (IsRedlineOn())
715cdf0e10cSrcweir        SetInsMode( true );
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir /*
719cdf0e10cSrcweir  * Rahmen bearbeiten
720cdf0e10cSrcweir  */
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 
BeginFrmDrag(const Point * pPt,sal_Bool)723cdf0e10cSrcweir long SwWrtShell::BeginFrmDrag(const Point *pPt, sal_Bool)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir     fnDrag = &SwFEShell::Drag;
726cdf0e10cSrcweir     if(bStartDrag)
727cdf0e10cSrcweir     {
728cdf0e10cSrcweir         Point aTmp( nStartDragX, nStartDragY );
729cdf0e10cSrcweir         SwFEShell::BeginDrag( &aTmp, sal_False );
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir     else
732cdf0e10cSrcweir         SwFEShell::BeginDrag( pPt, sal_False );
733cdf0e10cSrcweir     return 1;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 
EnterSelFrmMode(const Point * pPos)738cdf0e10cSrcweir void SwWrtShell::EnterSelFrmMode(const Point *pPos)
739cdf0e10cSrcweir {
740cdf0e10cSrcweir     if(pPos)
741cdf0e10cSrcweir     {
742cdf0e10cSrcweir         nStartDragX = pPos->X();
743cdf0e10cSrcweir         nStartDragY = pPos->Y();
744cdf0e10cSrcweir         bStartDrag = sal_True;
745cdf0e10cSrcweir     }
746cdf0e10cSrcweir     bNoEdit = bLayoutMode = sal_True;
747cdf0e10cSrcweir     HideCrsr();
748cdf0e10cSrcweir 
749cdf0e10cSrcweir         // gleicher Aufruf von BeginDrag an der SwFEShell
750cdf0e10cSrcweir     fnDrag          = &SwWrtShell::BeginFrmDrag;
751cdf0e10cSrcweir     fnEndDrag       = &SwWrtShell::UpdateLayoutFrm;
752cdf0e10cSrcweir     SwBaseShell::SetFrmMode( FLY_DRAG_START, this );
753cdf0e10cSrcweir     Invalidate();
754cdf0e10cSrcweir }
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 
LeaveSelFrmMode()758cdf0e10cSrcweir void SwWrtShell::LeaveSelFrmMode()
759cdf0e10cSrcweir {
760cdf0e10cSrcweir     fnDrag          = &SwWrtShell::BeginDrag;
761cdf0e10cSrcweir     fnEndDrag       = &SwWrtShell::EndDrag;
762cdf0e10cSrcweir     bLayoutMode = sal_False;
763cdf0e10cSrcweir     bStartDrag = sal_False;
764cdf0e10cSrcweir     Edit();
765cdf0e10cSrcweir     SwBaseShell::SetFrmMode( FLY_DRAG_END, this );
766cdf0e10cSrcweir     Invalidate();
767cdf0e10cSrcweir }
768cdf0e10cSrcweir /*------------------------------------------------------------------------
769cdf0e10cSrcweir  Beschreibung:  Rahmengebundenes Macro ausfuehren
770cdf0e10cSrcweir ------------------------------------------------------------------------*/
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 
773cdf0e10cSrcweir 
IMPL_LINK(SwWrtShell,ExecFlyMac,void *,pFlyFmt)774cdf0e10cSrcweir IMPL_LINK( SwWrtShell, ExecFlyMac, void *, pFlyFmt )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir     const SwFrmFmt *pFmt = pFlyFmt ? (SwFrmFmt*)pFlyFmt : GetFlyFrmFmt();
777cdf0e10cSrcweir     ASSERT(pFmt, kein FrameFormat.);
778cdf0e10cSrcweir     const SvxMacroItem &rFmtMac = pFmt->GetMacro();
779cdf0e10cSrcweir 
780cdf0e10cSrcweir     if(rFmtMac.HasMacro(SW_EVENT_OBJECT_SELECT))
781cdf0e10cSrcweir     {
782cdf0e10cSrcweir         const SvxMacro &rMac = rFmtMac.GetMacro(SW_EVENT_OBJECT_SELECT);
783cdf0e10cSrcweir         if( IsFrmSelected() )
784cdf0e10cSrcweir             bLayoutMode = sal_True;
785cdf0e10cSrcweir         CallChgLnk();
786cdf0e10cSrcweir         ExecMacro( rMac );
787cdf0e10cSrcweir     }
788cdf0e10cSrcweir     return 0;
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 
UpdateLayoutFrm(const Point * pPt,sal_Bool)793cdf0e10cSrcweir long SwWrtShell::UpdateLayoutFrm(const Point *pPt, sal_Bool )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir         // voerst Dummy
796cdf0e10cSrcweir     SwFEShell::EndDrag( pPt, sal_False );
797cdf0e10cSrcweir     fnDrag = &SwWrtShell::BeginFrmDrag;
798cdf0e10cSrcweir     return 1;
799cdf0e10cSrcweir }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir /*
802cdf0e10cSrcweir  * Handler fuer das Togglen der Modi. Liefern alten Mode zurueck.
803cdf0e10cSrcweir  */
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 
ToggleAddMode()807cdf0e10cSrcweir long SwWrtShell::ToggleAddMode()
808cdf0e10cSrcweir {
809cdf0e10cSrcweir     bAddMode ? LeaveAddMode(): EnterAddMode();
810cdf0e10cSrcweir     Invalidate();
811cdf0e10cSrcweir     return !bAddMode;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 
ToggleBlockMode()815cdf0e10cSrcweir long SwWrtShell::ToggleBlockMode()
816cdf0e10cSrcweir {
817cdf0e10cSrcweir     bBlockMode ? LeaveBlockMode(): EnterBlockMode();
818cdf0e10cSrcweir     Invalidate();
819cdf0e10cSrcweir     return !bBlockMode;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 
ToggleExtMode()823cdf0e10cSrcweir long SwWrtShell::ToggleExtMode()
824cdf0e10cSrcweir {
825cdf0e10cSrcweir     bExtMode ? LeaveExtMode() : EnterExtMode();
826cdf0e10cSrcweir     Invalidate();
827cdf0e10cSrcweir     return !bExtMode;
828cdf0e10cSrcweir }
829cdf0e10cSrcweir /*
830cdf0e10cSrcweir  * Draggen im Standard Modus (Selektieren von Inhalt)
831cdf0e10cSrcweir  */
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 
BeginDrag(const Point *,sal_Bool)835cdf0e10cSrcweir long SwWrtShell::BeginDrag(const Point * /*pPt*/, sal_Bool )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir     if(bSelWrd)
838cdf0e10cSrcweir     {
839cdf0e10cSrcweir         bInSelect = sal_True;
840cdf0e10cSrcweir         if( !IsCrsrPtAtEnd() )
841cdf0e10cSrcweir             SwapPam();
842cdf0e10cSrcweir 
843cdf0e10cSrcweir         fnDrag = &SwWrtShell::ExtSelWrd;
844cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::Ignore;
845cdf0e10cSrcweir     }
846cdf0e10cSrcweir     else if(bSelLn)
847cdf0e10cSrcweir     {
848cdf0e10cSrcweir         bInSelect = sal_True;
849cdf0e10cSrcweir         fnDrag = &SwWrtShell::ExtSelLn;
850cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::Ignore;
851cdf0e10cSrcweir     }
852cdf0e10cSrcweir     else
853cdf0e10cSrcweir     {
854cdf0e10cSrcweir         fnDrag = &SwWrtShell::Drag;
855cdf0e10cSrcweir         SttSelect();
856cdf0e10cSrcweir     }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     return 1;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 
Drag(const Point *,sal_Bool)863cdf0e10cSrcweir long SwWrtShell::Drag(const Point *, sal_Bool )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir     if( IsSelTblCells() )
866cdf0e10cSrcweir         aSelTblLink.Call(this);
867cdf0e10cSrcweir 
868cdf0e10cSrcweir     return 1;
869cdf0e10cSrcweir }
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 
EndDrag(const Point *,sal_Bool)873cdf0e10cSrcweir long SwWrtShell::EndDrag(const Point * /*pPt*/, sal_Bool )
874cdf0e10cSrcweir {
875cdf0e10cSrcweir     fnDrag = &SwWrtShell::BeginDrag;
876cdf0e10cSrcweir     if( IsExtSel() )
877cdf0e10cSrcweir         LeaveExtSel();
878cdf0e10cSrcweir 
879cdf0e10cSrcweir     if( IsSelTblCells() )
880cdf0e10cSrcweir         aSelTblLink.Call(this);
881cdf0e10cSrcweir     EndSelect();
882cdf0e10cSrcweir     return 1;
883cdf0e10cSrcweir }
884cdf0e10cSrcweir 
885cdf0e10cSrcweir // --> FME 2004-07-30 #i32329# Enhanced table selection
SelectTableRowCol(const Point & rPt,const Point * pEnd,bool bRowDrag)886cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTableRowCol( const Point& rPt, const Point* pEnd, bool bRowDrag )
887cdf0e10cSrcweir {
888*2b518738Smseidel     MV_CONTEXT(this);
889cdf0e10cSrcweir     SttSelect();
890cdf0e10cSrcweir     if(SelTblRowCol( rPt, pEnd, bRowDrag ))
891cdf0e10cSrcweir     {
892cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
893cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
894cdf0e10cSrcweir         return sal_True;
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir     return sal_False;
897cdf0e10cSrcweir }
898cdf0e10cSrcweir // <--
899cdf0e10cSrcweir 
900cdf0e10cSrcweir /*------------------------------------------------------------------------
901cdf0e10cSrcweir  Beschreibung:  Selektion einer Tabellenzeile / Spalte
902cdf0e10cSrcweir ------------------------------------------------------------------------*/
903cdf0e10cSrcweir 
SelectTableRow()904cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTableRow()
905cdf0e10cSrcweir {
906cdf0e10cSrcweir     if ( SelTblRow() )
907cdf0e10cSrcweir     {
908cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
909cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
910cdf0e10cSrcweir         return sal_True;
911cdf0e10cSrcweir     }
912cdf0e10cSrcweir     return sal_False;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 
SelectTableCol()917cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTableCol()
918cdf0e10cSrcweir {
919cdf0e10cSrcweir     if ( SelTblCol() )
920cdf0e10cSrcweir     {
921cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
922cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
923cdf0e10cSrcweir         return sal_True;
924cdf0e10cSrcweir     }
925cdf0e10cSrcweir     return sal_False;
926cdf0e10cSrcweir }
927cdf0e10cSrcweir 
SelectTableCell()928cdf0e10cSrcweir sal_Bool SwWrtShell::SelectTableCell()
929cdf0e10cSrcweir {
930cdf0e10cSrcweir     if ( SelTblBox() )
931cdf0e10cSrcweir     {
932cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
933cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
934cdf0e10cSrcweir         return sal_True;
935cdf0e10cSrcweir     }
936cdf0e10cSrcweir     return sal_False;
937cdf0e10cSrcweir }
938cdf0e10cSrcweir /*------------------------------------------------------------------------
939cdf0e10cSrcweir  Beschreibung:    Prueft, ob eine Wortselektion vorliegt.
940cdf0e10cSrcweir                   Gemaess den Regeln fuer intelligentes Cut / Paste
941cdf0e10cSrcweir                   werden umgebende Spaces rausgeschnitten.
942cdf0e10cSrcweir  Return:          Liefert Art der Wortselektion zurueck.
943cdf0e10cSrcweir ------------------------------------------------------------------------*/
944cdf0e10cSrcweir 
945cdf0e10cSrcweir 
946cdf0e10cSrcweir 
IntelligentCut(int nSelection,sal_Bool bCut)947cdf0e10cSrcweir int SwWrtShell::IntelligentCut(int nSelection, sal_Bool bCut)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir         // kein intelligentes Drag and Drop bei Mehrfachselektion
950cdf0e10cSrcweir         // es existieren mehrere Cursor, da ein zweiter bereits
951cdf0e10cSrcweir         // an die Zielposition gesetzt wurde
952cdf0e10cSrcweir     if( IsAddMode() || !(nSelection & nsSelectionType::SEL_TXT) )
953cdf0e10cSrcweir         return sal_False;
954cdf0e10cSrcweir 
955cdf0e10cSrcweir     String sTxt;
956cdf0e10cSrcweir     CharClass& rCC = GetAppCharClass();
957cdf0e10cSrcweir 
958cdf0e10cSrcweir         // wenn das erste und das letzte Zeichen kein Wortzeichen ist,
959cdf0e10cSrcweir         // ist kein Wort selektiert.
960cdf0e10cSrcweir     sal_Unicode cPrev = GetChar(sal_False);
961cdf0e10cSrcweir     sal_Unicode cNext = GetChar(sal_True, -1);
962cdf0e10cSrcweir     if( !cPrev || !cNext ||
963cdf0e10cSrcweir         !rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) ||
964cdf0e10cSrcweir         !rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
965cdf0e10cSrcweir         return NO_WORD;
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     cPrev = GetChar(sal_False, -1);
968cdf0e10cSrcweir     cNext = GetChar(sal_True);
969cdf0e10cSrcweir 
970cdf0e10cSrcweir     int cWord = NO_WORD;
971cdf0e10cSrcweir         // ist ein Wort selektiert?
972cdf0e10cSrcweir     if(!cWord && cPrev && cNext &&
973cdf0e10cSrcweir         CH_TXTATR_BREAKWORD != cPrev && CH_TXTATR_INWORD != cPrev &&
974cdf0e10cSrcweir         CH_TXTATR_BREAKWORD != cNext && CH_TXTATR_INWORD != cNext &&
975cdf0e10cSrcweir         !rCC.isLetterNumeric( ( sTxt = cPrev), 0 ) &&
976cdf0e10cSrcweir         !rCC.isLetterNumeric( ( sTxt = cNext), 0 ) )
977cdf0e10cSrcweir        cWord = WORD_NO_SPACE;
978cdf0e10cSrcweir 
979cdf0e10cSrcweir     if(cWord == WORD_NO_SPACE && ' ' == cPrev )
980cdf0e10cSrcweir     {
981cdf0e10cSrcweir         cWord = WORD_SPACE_BEFORE;
982cdf0e10cSrcweir             // Space davor loeschen
983cdf0e10cSrcweir         if(bCut)
984cdf0e10cSrcweir         {
985cdf0e10cSrcweir             Push();
986cdf0e10cSrcweir             if(IsCrsrPtAtEnd())
987cdf0e10cSrcweir                 SwapPam();
988cdf0e10cSrcweir             ClearMark();
989cdf0e10cSrcweir             SetMark();
990cdf0e10cSrcweir             SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
991cdf0e10cSrcweir             SwFEShell::Delete();
992cdf0e10cSrcweir             Pop( sal_False );
993cdf0e10cSrcweir         }
994cdf0e10cSrcweir     }
995cdf0e10cSrcweir     else if(cWord == WORD_NO_SPACE && cNext == ' ')
996cdf0e10cSrcweir     {
997cdf0e10cSrcweir         cWord = WORD_SPACE_AFTER;
998cdf0e10cSrcweir             // Space dahinter loeschen
999cdf0e10cSrcweir         if(bCut) {
1000cdf0e10cSrcweir             Push();
1001cdf0e10cSrcweir             if(!IsCrsrPtAtEnd()) SwapPam();
1002cdf0e10cSrcweir             ClearMark();
1003cdf0e10cSrcweir             SetMark();
1004cdf0e10cSrcweir             SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
1005cdf0e10cSrcweir             SwFEShell::Delete();
1006cdf0e10cSrcweir             Pop( sal_False );
1007cdf0e10cSrcweir         }
1008cdf0e10cSrcweir     }
1009cdf0e10cSrcweir     return cWord;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir     // jump to the next / previous hyperlink - inside text and also
1015cdf0e10cSrcweir     // on graphics
SelectNextPrevHyperlink(sal_Bool bNext)1016cdf0e10cSrcweir sal_Bool SwWrtShell::SelectNextPrevHyperlink( sal_Bool bNext )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     StartAction();
1019cdf0e10cSrcweir     sal_Bool bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
1020cdf0e10cSrcweir     if( !bRet )
1021cdf0e10cSrcweir     {
1022cdf0e10cSrcweir         // will we have this feature?
1023cdf0e10cSrcweir         EnterStdMode();
1024cdf0e10cSrcweir         if( bNext )
1025cdf0e10cSrcweir             SttEndDoc(sal_True);
1026cdf0e10cSrcweir         else
1027cdf0e10cSrcweir             SttEndDoc(sal_False);
1028cdf0e10cSrcweir         bRet = SwCrsrShell::SelectNxtPrvHyperlink( bNext );
1029cdf0e10cSrcweir     }
1030cdf0e10cSrcweir     EndAction();
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir     sal_Bool bCreateXSelection = sal_False;
1033cdf0e10cSrcweir     const sal_Bool bFrmSelected = IsFrmSelected() || IsObjSelected();
1034cdf0e10cSrcweir     if( IsSelection() )
1035cdf0e10cSrcweir     {
1036cdf0e10cSrcweir         if ( bFrmSelected )
1037cdf0e10cSrcweir             UnSelectFrm();
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir         // Funktionspointer fuer das Aufheben der Selektion setzen
1040cdf0e10cSrcweir         // bei Cursor setzen
1041cdf0e10cSrcweir         fnKillSel = &SwWrtShell::ResetSelect;
1042cdf0e10cSrcweir         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
1043cdf0e10cSrcweir         bCreateXSelection = sal_True;
1044cdf0e10cSrcweir     }
1045cdf0e10cSrcweir     else if( bFrmSelected )
1046cdf0e10cSrcweir     {
1047cdf0e10cSrcweir         EnterSelFrmMode();
1048cdf0e10cSrcweir         bCreateXSelection = sal_True;
1049cdf0e10cSrcweir     }
1050cdf0e10cSrcweir     else if( (CNT_GRF | CNT_OLE ) & GetCntType() )
1051cdf0e10cSrcweir     {
1052cdf0e10cSrcweir         SelectObj( GetCharRect().Pos() );
1053cdf0e10cSrcweir         EnterSelFrmMode();
1054cdf0e10cSrcweir         bCreateXSelection = sal_True;
1055cdf0e10cSrcweir     }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir     if( bCreateXSelection )
1058cdf0e10cSrcweir         SwTransferable::CreateSelection( *this );
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir     return bRet;
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
1063*2b518738Smseidel /* für den Erhalt der Selektion wird nach SetMark() der Cursor
1064*2b518738Smseidel  * nach links bewegt, damit er durch das Einfügen von Text nicht
1065cdf0e10cSrcweir  * verschoben wird. Da auf der CORE-Seite am aktuellen Cursor
1066cdf0e10cSrcweir  * eine bestehende Selektion aufgehoben wird, wird der Cursor auf
1067cdf0e10cSrcweir  * den Stack gepushed. Nach dem Verschieben werden sie wieder
1068cdf0e10cSrcweir  * zusammengefasst. */
1069*2b518738Smseidel 
1070*2b518738Smseidel /* vim: set noet sw=4 ts=4: */
1071