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