xref: /aoo41x/main/sw/source/ui/wrtsh/delete.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <wrtsh.hxx>
33*cdf0e10cSrcweir #include <crsskip.hxx>
34*cdf0e10cSrcweir #include <swcrsr.hxx>
35*cdf0e10cSrcweir #include <editeng/lrspitem.hxx> // #i23725#
36*cdf0e10cSrcweir // --> OD 2006-07-10 #134369#
37*cdf0e10cSrcweir #ifndef _VIEW_HXX
38*cdf0e10cSrcweir #include <view.hxx>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #ifndef _DRAWBASE_HXX
41*cdf0e10cSrcweir #include <drawbase.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir // <--
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir inline void SwWrtShell::OpenMark()
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 	StartAllAction();
48*cdf0e10cSrcweir 	ResetCursorStack();
49*cdf0e10cSrcweir 	KillPams();
50*cdf0e10cSrcweir 	SetMark();
51*cdf0e10cSrcweir }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir inline void SwWrtShell::CloseMark( sal_Bool bOkFlag )
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir 	if( bOkFlag )
56*cdf0e10cSrcweir 		UpdateAttr();
57*cdf0e10cSrcweir 	else
58*cdf0e10cSrcweir 		SwapPam();
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	ClearMark();
61*cdf0e10cSrcweir 	EndAllAction();
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir // #i23725#
65*cdf0e10cSrcweir sal_Bool SwWrtShell::TryRemoveIndent()
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     sal_Bool bResult = sal_False;
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     SfxItemSet aAttrSet(GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE);
70*cdf0e10cSrcweir     GetCurAttr(aAttrSet);
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     SvxLRSpaceItem aItem = (const SvxLRSpaceItem &)aAttrSet.Get(RES_LR_SPACE);
73*cdf0e10cSrcweir     short aOldFirstLineOfst = aItem.GetTxtFirstLineOfst();
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir     if (aOldFirstLineOfst > 0)
76*cdf0e10cSrcweir     {
77*cdf0e10cSrcweir         aItem.SetTxtFirstLineOfst(0);
78*cdf0e10cSrcweir         bResult = sal_True;
79*cdf0e10cSrcweir     }
80*cdf0e10cSrcweir     else if (aOldFirstLineOfst < 0)
81*cdf0e10cSrcweir     {
82*cdf0e10cSrcweir         aItem.SetTxtFirstLineOfst(0);
83*cdf0e10cSrcweir         aItem.SetLeft(aItem.GetLeft() + aOldFirstLineOfst);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir         bResult = sal_True;
86*cdf0e10cSrcweir     }
87*cdf0e10cSrcweir     else if (aItem.GetLeft() != 0)
88*cdf0e10cSrcweir     {
89*cdf0e10cSrcweir         aItem.SetLeft(0);
90*cdf0e10cSrcweir         bResult = sal_True;
91*cdf0e10cSrcweir     }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     if (bResult)
94*cdf0e10cSrcweir     {
95*cdf0e10cSrcweir         aAttrSet.Put(aItem);
96*cdf0e10cSrcweir         SetAttr(aAttrSet);
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     return bResult;
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir /*------------------------------------------------------------------------
103*cdf0e10cSrcweir  Beschreibung:	Zeile loeschen
104*cdf0e10cSrcweir ------------------------------------------------------------------------*/
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir long SwWrtShell::DelLine()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	ACT_KONTEXT(this);
111*cdf0e10cSrcweir 	ResetCursorStack();
112*cdf0e10cSrcweir 		// alten Cursor merken
113*cdf0e10cSrcweir 	Push();
114*cdf0e10cSrcweir 	ClearMark();
115*cdf0e10cSrcweir 	SwCrsrShell::LeftMargin();
116*cdf0e10cSrcweir 	SetMark();
117*cdf0e10cSrcweir 	SwCrsrShell::RightMargin();
118*cdf0e10cSrcweir //Warum soll hier noch ein Zeichen in der naechsten Zeile geloescht werden?
119*cdf0e10cSrcweir //	if(!IsEndOfPara())
120*cdf0e10cSrcweir //		SwCrsrShell::Right();
121*cdf0e10cSrcweir 	long nRet = Delete();
122*cdf0e10cSrcweir 	Pop(sal_False);
123*cdf0e10cSrcweir 	if( nRet )
124*cdf0e10cSrcweir 		UpdateAttr();
125*cdf0e10cSrcweir 	return nRet;
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir long SwWrtShell::DelToStartOfLine()
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	OpenMark();
133*cdf0e10cSrcweir 	SwCrsrShell::LeftMargin();
134*cdf0e10cSrcweir 	long nRet = Delete();
135*cdf0e10cSrcweir 	CloseMark( 0 != nRet );
136*cdf0e10cSrcweir 	return nRet;
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir long SwWrtShell::DelToEndOfLine()
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	OpenMark();
144*cdf0e10cSrcweir 	SwCrsrShell::RightMargin();
145*cdf0e10cSrcweir 	long nRet = Delete();
146*cdf0e10cSrcweir 	CloseMark( 0 != nRet );
147*cdf0e10cSrcweir 	return 1;
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir long SwWrtShell::DelLeft()
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	// wenns denn ein Fly ist, wech damit
153*cdf0e10cSrcweir 	int nSelType = GetSelectionType();
154*cdf0e10cSrcweir     const int nCmp = nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW;
155*cdf0e10cSrcweir 	if( nCmp & nSelType )
156*cdf0e10cSrcweir 	{
157*cdf0e10cSrcweir         /*  #108205# Remember object's position. */
158*cdf0e10cSrcweir         Point aTmpPt = GetObjRect().TopLeft();
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 		DelSelectedObj();
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         /*  #108205# Set cursor to remembered position. */
163*cdf0e10cSrcweir         SetCrsr(&aTmpPt);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 		LeaveSelFrmMode();
166*cdf0e10cSrcweir 		UnSelectFrm();
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 		nSelType = GetSelectionType();
169*cdf0e10cSrcweir 		if ( nCmp & nSelType )
170*cdf0e10cSrcweir 		{
171*cdf0e10cSrcweir 			EnterSelFrmMode();
172*cdf0e10cSrcweir 			GotoNextFly();
173*cdf0e10cSrcweir 		}
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 		return 1L;
176*cdf0e10cSrcweir 	}
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	// wenn eine Selektion existiert, diese loeschen.
179*cdf0e10cSrcweir 	if ( IsSelection() )
180*cdf0e10cSrcweir 	{
181*cdf0e10cSrcweir 		if( !IsBlockMode() || HasSelection() )
182*cdf0e10cSrcweir         {
183*cdf0e10cSrcweir              //OS: wieder einmal Basic: ACT_KONTEXT muss vor
184*cdf0e10cSrcweir             //EnterStdMode verlassen werden!
185*cdf0e10cSrcweir             {
186*cdf0e10cSrcweir                 ACT_KONTEXT(this);
187*cdf0e10cSrcweir                 ResetCursorStack();
188*cdf0e10cSrcweir                 Delete();
189*cdf0e10cSrcweir                 UpdateAttr();
190*cdf0e10cSrcweir             }
191*cdf0e10cSrcweir             if( IsBlockMode() )
192*cdf0e10cSrcweir             {
193*cdf0e10cSrcweir                 NormalizePam();
194*cdf0e10cSrcweir                 ClearMark();
195*cdf0e10cSrcweir                 EnterBlockMode();
196*cdf0e10cSrcweir             }
197*cdf0e10cSrcweir             else
198*cdf0e10cSrcweir                 EnterStdMode();
199*cdf0e10cSrcweir             return 1L;
200*cdf0e10cSrcweir         }
201*cdf0e10cSrcweir         else
202*cdf0e10cSrcweir             EnterStdMode();
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	// JP 29.06.95: nie eine davor stehende Tabelle loeschen.
206*cdf0e10cSrcweir 	sal_Bool bSwap = sal_False;
207*cdf0e10cSrcweir 	const SwTableNode * pWasInTblNd = SwCrsrShell::IsCrsrInTbl();
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	if( SwCrsrShell::IsSttPara())
210*cdf0e10cSrcweir 	{
211*cdf0e10cSrcweir         // --> FME 2007-02-15 #i4032# Don't actually call a 'delete' if we
212*cdf0e10cSrcweir         // changed the table cell, compare DelRight().
213*cdf0e10cSrcweir         const SwStartNode * pSNdOld = pWasInTblNd ?
214*cdf0e10cSrcweir                                       GetSwCrsr()->GetNode()->FindTableBoxStartNode() :
215*cdf0e10cSrcweir                                       0;
216*cdf0e10cSrcweir         // <--
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         /* If the cursor is at the beginning of a paragraph, try to step
219*cdf0e10cSrcweir            backwards. On failure we are done. */
220*cdf0e10cSrcweir 		if( !SwCrsrShell::Left(1,CRSR_SKIP_CHARS) )
221*cdf0e10cSrcweir 			return 0;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 		/* If the cursor entered or left a table (or both) we are done. No step
224*cdf0e10cSrcweir            back. */
225*cdf0e10cSrcweir         const SwTableNode* pIsInTblNd = SwCrsrShell::IsCrsrInTbl();
226*cdf0e10cSrcweir         if( pIsInTblNd != pWasInTblNd )
227*cdf0e10cSrcweir 			return 0;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir         const SwStartNode* pSNdNew = pIsInTblNd ?
230*cdf0e10cSrcweir                                      GetSwCrsr()->GetNode()->FindTableBoxStartNode() :
231*cdf0e10cSrcweir                                      0;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir         // --> FME 2007-02-15 #i4032# Don't actually call a 'delete' if we
234*cdf0e10cSrcweir         // changed the table cell, compare DelRight().
235*cdf0e10cSrcweir         if ( pSNdOld != pSNdNew )
236*cdf0e10cSrcweir             return 0;
237*cdf0e10cSrcweir         // <--
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 		OpenMark();
240*cdf0e10cSrcweir 		SwCrsrShell::Right(1,CRSR_SKIP_CHARS);
241*cdf0e10cSrcweir 		SwCrsrShell::SwapPam();
242*cdf0e10cSrcweir 		bSwap = sal_True;
243*cdf0e10cSrcweir 	}
244*cdf0e10cSrcweir 	else
245*cdf0e10cSrcweir 	{
246*cdf0e10cSrcweir 		OpenMark();
247*cdf0e10cSrcweir 		SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir 	long nRet = Delete();
250*cdf0e10cSrcweir 	if( !nRet && bSwap )
251*cdf0e10cSrcweir 		SwCrsrShell::SwapPam();
252*cdf0e10cSrcweir 	CloseMark( 0 != nRet );
253*cdf0e10cSrcweir 	return nRet;
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir long SwWrtShell::DelRight()
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir 		// werden verodert, wenn Tabellenselektion vorliegt;
259*cdf0e10cSrcweir         // wird hier auf nsSelectionType::SEL_TBL umgesetzt.
260*cdf0e10cSrcweir 	long nRet = 0;
261*cdf0e10cSrcweir 	int nSelection = GetSelectionType();
262*cdf0e10cSrcweir 	if(nSelection & nsSelectionType::SEL_TBL_CELLS)
263*cdf0e10cSrcweir 		nSelection = nsSelectionType::SEL_TBL;
264*cdf0e10cSrcweir 	if(nSelection & nsSelectionType::SEL_TXT)
265*cdf0e10cSrcweir 		nSelection = nsSelectionType::SEL_TXT;
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 	const SwTableNode * pWasInTblNd = NULL;
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     switch( nSelection & ~(nsSelectionType::SEL_BEZ) )
270*cdf0e10cSrcweir 	{
271*cdf0e10cSrcweir 	case nsSelectionType::SEL_POSTIT:
272*cdf0e10cSrcweir     case nsSelectionType::SEL_TXT:
273*cdf0e10cSrcweir     case nsSelectionType::SEL_TBL:
274*cdf0e10cSrcweir     case nsSelectionType::SEL_NUM:
275*cdf0e10cSrcweir 			//	wenn eine Selektion existiert, diese loeschen.
276*cdf0e10cSrcweir 		if( IsSelection() )
277*cdf0e10cSrcweir 		{
278*cdf0e10cSrcweir             if( !IsBlockMode() || HasSelection() )
279*cdf0e10cSrcweir             {
280*cdf0e10cSrcweir                 //OS: wieder einmal Basic: ACT_KONTEXT muss vor
281*cdf0e10cSrcweir                 //EnterStdMode verlassen werden!
282*cdf0e10cSrcweir                 {
283*cdf0e10cSrcweir                     ACT_KONTEXT(this);
284*cdf0e10cSrcweir                     ResetCursorStack();
285*cdf0e10cSrcweir                     Delete();
286*cdf0e10cSrcweir                     UpdateAttr();
287*cdf0e10cSrcweir                 }
288*cdf0e10cSrcweir                 if( IsBlockMode() )
289*cdf0e10cSrcweir                 {
290*cdf0e10cSrcweir                     NormalizePam();
291*cdf0e10cSrcweir                     ClearMark();
292*cdf0e10cSrcweir                     EnterBlockMode();
293*cdf0e10cSrcweir                 }
294*cdf0e10cSrcweir                 else
295*cdf0e10cSrcweir                     EnterStdMode();
296*cdf0e10cSrcweir                 nRet = 1L;
297*cdf0e10cSrcweir                 break;
298*cdf0e10cSrcweir             }
299*cdf0e10cSrcweir             else
300*cdf0e10cSrcweir                 EnterStdMode();
301*cdf0e10cSrcweir 		}
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 		pWasInTblNd = IsCrsrInTbl();
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir         if( nsSelectionType::SEL_TXT & nSelection && SwCrsrShell::IsSttPara() &&
306*cdf0e10cSrcweir             SwCrsrShell::IsEndPara() )
307*cdf0e10cSrcweir         {
308*cdf0e10cSrcweir             // save cursor
309*cdf0e10cSrcweir             SwCrsrShell::Push();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir             bool bDelFull = false;
312*cdf0e10cSrcweir             if ( SwCrsrShell::Right(1,CRSR_SKIP_CHARS) )
313*cdf0e10cSrcweir 		    {
314*cdf0e10cSrcweir             	const SwTableNode * pCurrTblNd = IsCrsrInTbl();
315*cdf0e10cSrcweir 			    bDelFull = pCurrTblNd && pCurrTblNd != pWasInTblNd;
316*cdf0e10cSrcweir             }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir             // restore cursor
319*cdf0e10cSrcweir             SwCrsrShell::Pop( sal_False );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir     	    if( bDelFull )
322*cdf0e10cSrcweir 		    {
323*cdf0e10cSrcweir     			DelFullPara();
324*cdf0e10cSrcweir 			    UpdateAttr();
325*cdf0e10cSrcweir 			    break;
326*cdf0e10cSrcweir 		    }
327*cdf0e10cSrcweir 		}
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         {
330*cdf0e10cSrcweir             /* #108049# Save the startnode of the current cell */
331*cdf0e10cSrcweir             const SwStartNode * pSNdOld;
332*cdf0e10cSrcweir             pSNdOld = GetSwCrsr()->GetNode()->
333*cdf0e10cSrcweir                 FindTableBoxStartNode();
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir             if ( SwCrsrShell::IsEndPara() )
336*cdf0e10cSrcweir             {
337*cdf0e10cSrcweir                 // --> FME 2005-01-28 #i41424# Introduced a couple of
338*cdf0e10cSrcweir                 // Push()-Pop() pairs here. The reason for this is that a
339*cdf0e10cSrcweir                 // Right()-Left() combination does not make sure, that
340*cdf0e10cSrcweir                 // the cursor will be in its initial state, because there
341*cdf0e10cSrcweir                 // may be a numbering in front of the next paragraph.
342*cdf0e10cSrcweir                 SwCrsrShell::Push();
343*cdf0e10cSrcweir                 // <--
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir                 if ( SwCrsrShell::Right(1, CRSR_SKIP_CHARS) )
346*cdf0e10cSrcweir                 {
347*cdf0e10cSrcweir                     if (IsCrsrInTbl() || (pWasInTblNd != IsCrsrInTbl()))
348*cdf0e10cSrcweir                     {
349*cdf0e10cSrcweir                         /* #108049# Save the startnode of the current
350*cdf0e10cSrcweir                             cell. May be different to pSNdOld as we have
351*cdf0e10cSrcweir                             moved. */
352*cdf0e10cSrcweir                         const SwStartNode * pSNdNew = GetSwCrsr()
353*cdf0e10cSrcweir                             ->GetNode()->FindTableBoxStartNode();
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir                         /* #108049# Only move instead of deleting if we
356*cdf0e10cSrcweir                             have moved to a different cell */
357*cdf0e10cSrcweir                         if (pSNdOld != pSNdNew)
358*cdf0e10cSrcweir                         {
359*cdf0e10cSrcweir                             SwCrsrShell::Pop( sal_True );
360*cdf0e10cSrcweir                             break;
361*cdf0e10cSrcweir                         }
362*cdf0e10cSrcweir                     }
363*cdf0e10cSrcweir                 }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir                 // restore cursor
366*cdf0e10cSrcweir                 SwCrsrShell::Pop( sal_False );
367*cdf0e10cSrcweir             }
368*cdf0e10cSrcweir         }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir 		OpenMark();
371*cdf0e10cSrcweir 		SwCrsrShell::Right(1,CRSR_SKIP_CELLS);
372*cdf0e10cSrcweir 		nRet = Delete();
373*cdf0e10cSrcweir 		CloseMark( 0 != nRet );
374*cdf0e10cSrcweir 		break;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     case nsSelectionType::SEL_FRM:
377*cdf0e10cSrcweir     case nsSelectionType::SEL_GRF:
378*cdf0e10cSrcweir     case nsSelectionType::SEL_OLE:
379*cdf0e10cSrcweir     case nsSelectionType::SEL_DRW:
380*cdf0e10cSrcweir     case nsSelectionType::SEL_DRW_TXT:
381*cdf0e10cSrcweir     case nsSelectionType::SEL_DRW_FORM:
382*cdf0e10cSrcweir         {
383*cdf0e10cSrcweir             /*  #108205# Remember object's position. */
384*cdf0e10cSrcweir             Point aTmpPt = GetObjRect().TopLeft();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir             DelSelectedObj();
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir             /*  #108205# Set cursor to remembered position. */
389*cdf0e10cSrcweir             SetCrsr(&aTmpPt);
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir             LeaveSelFrmMode();
392*cdf0e10cSrcweir             UnSelectFrm();
393*cdf0e10cSrcweir             // --> OD 2006-07-06 #134369#
394*cdf0e10cSrcweir             ASSERT( !IsFrmSelected(),
395*cdf0e10cSrcweir                     "<SwWrtShell::DelRight(..)> - <SwWrtShell::UnSelectFrm()> should unmark all objects" )
396*cdf0e10cSrcweir             // <--
397*cdf0e10cSrcweir             // --> OD 2006-07-10 #134369#
398*cdf0e10cSrcweir             // leave draw mode, if necessary.
399*cdf0e10cSrcweir             {
400*cdf0e10cSrcweir                 if (GetView().GetDrawFuncPtr())
401*cdf0e10cSrcweir                 {
402*cdf0e10cSrcweir                     GetView().GetDrawFuncPtr()->Deactivate();
403*cdf0e10cSrcweir                     GetView().SetDrawFuncPtr(NULL);
404*cdf0e10cSrcweir                 }
405*cdf0e10cSrcweir                 if ( GetView().IsDrawMode() )
406*cdf0e10cSrcweir                 {
407*cdf0e10cSrcweir                     GetView().LeaveDrawCreate();
408*cdf0e10cSrcweir                 }
409*cdf0e10cSrcweir             }
410*cdf0e10cSrcweir             // <--
411*cdf0e10cSrcweir         }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir         // --> OD 2006-07-07 #134369#
414*cdf0e10cSrcweir         // <IsFrmSelected()> can't be true - see above.
415*cdf0e10cSrcweir         // <--
416*cdf0e10cSrcweir 		{
417*cdf0e10cSrcweir 			nSelection = GetSelectionType();
418*cdf0e10cSrcweir             if ( nsSelectionType::SEL_FRM & nSelection ||
419*cdf0e10cSrcweir                  nsSelectionType::SEL_GRF & nSelection ||
420*cdf0e10cSrcweir                  nsSelectionType::SEL_OLE & nSelection ||
421*cdf0e10cSrcweir                  nsSelectionType::SEL_DRW & nSelection )
422*cdf0e10cSrcweir 			{
423*cdf0e10cSrcweir 				EnterSelFrmMode();
424*cdf0e10cSrcweir 				GotoNextFly();
425*cdf0e10cSrcweir 			}
426*cdf0e10cSrcweir 		}
427*cdf0e10cSrcweir 		nRet = 1;
428*cdf0e10cSrcweir 		break;
429*cdf0e10cSrcweir 	}
430*cdf0e10cSrcweir 	return nRet;
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir long SwWrtShell::DelToEndOfPara()
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir 	ACT_KONTEXT(this);
438*cdf0e10cSrcweir 	ResetCursorStack();
439*cdf0e10cSrcweir 	Push();
440*cdf0e10cSrcweir 	SetMark();
441*cdf0e10cSrcweir 	if( !MovePara(fnParaCurr,fnParaEnd))
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		Pop(sal_False);
444*cdf0e10cSrcweir 		return 0;
445*cdf0e10cSrcweir 	}
446*cdf0e10cSrcweir 	long nRet = Delete();
447*cdf0e10cSrcweir 	Pop(sal_False);
448*cdf0e10cSrcweir 	if( nRet )
449*cdf0e10cSrcweir 		UpdateAttr();
450*cdf0e10cSrcweir 	return nRet;
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir long SwWrtShell::DelToStartOfPara()
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir 	ACT_KONTEXT(this);
458*cdf0e10cSrcweir 	ResetCursorStack();
459*cdf0e10cSrcweir 	Push();
460*cdf0e10cSrcweir 	SetMark();
461*cdf0e10cSrcweir 	if( !MovePara(fnParaCurr,fnParaStart))
462*cdf0e10cSrcweir 	{
463*cdf0e10cSrcweir 		Pop(sal_False);
464*cdf0e10cSrcweir 		return 0;
465*cdf0e10cSrcweir 	}
466*cdf0e10cSrcweir 	long nRet = Delete();
467*cdf0e10cSrcweir 	Pop(sal_False);
468*cdf0e10cSrcweir 	if( nRet )
469*cdf0e10cSrcweir 		UpdateAttr();
470*cdf0e10cSrcweir 	return nRet;
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir /*
473*cdf0e10cSrcweir  * alle Loeschoperationen sollten mit Find statt mit
474*cdf0e10cSrcweir  * Nxt-/PrvDelim arbeiten, da letzteren mit Wrap Around arbeiten
475*cdf0e10cSrcweir  * -- das ist wohl nicht gewuenscht.
476*cdf0e10cSrcweir  */
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir long SwWrtShell::DelToStartOfSentence()
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	if(IsStartOfDoc())
483*cdf0e10cSrcweir 		return 0;
484*cdf0e10cSrcweir 	OpenMark();
485*cdf0e10cSrcweir 	long nRet = _BwdSentence() ? Delete() : 0;
486*cdf0e10cSrcweir 	CloseMark( 0 != nRet );
487*cdf0e10cSrcweir 	return nRet;
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir long SwWrtShell::DelToEndOfSentence()
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	if(IsEndOfDoc())
495*cdf0e10cSrcweir 		return 0;
496*cdf0e10cSrcweir 	OpenMark();
497*cdf0e10cSrcweir 	long nRet = _FwdSentence() ? Delete() : 0;
498*cdf0e10cSrcweir 	CloseMark( 0 != nRet );
499*cdf0e10cSrcweir 	return nRet;
500*cdf0e10cSrcweir }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir long SwWrtShell::DelNxtWord()
505*cdf0e10cSrcweir {
506*cdf0e10cSrcweir 	if(IsEndOfDoc())
507*cdf0e10cSrcweir 		return 0;
508*cdf0e10cSrcweir 	ACT_KONTEXT(this);
509*cdf0e10cSrcweir 	ResetCursorStack();
510*cdf0e10cSrcweir 	EnterStdMode();
511*cdf0e10cSrcweir 	SetMark();
512*cdf0e10cSrcweir 	if(IsEndWrd() && !IsSttWrd())
513*cdf0e10cSrcweir         _NxtWrdForDelete(); // --> OD 2008-08-06 #i92468#
514*cdf0e10cSrcweir 	if(IsSttWrd() || IsEndPara())
515*cdf0e10cSrcweir         _NxtWrdForDelete(); // --> OD 2008-08-06 #i92468#
516*cdf0e10cSrcweir 	else
517*cdf0e10cSrcweir 		_EndWrd();
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir 	long nRet = Delete();
520*cdf0e10cSrcweir 	if( nRet )
521*cdf0e10cSrcweir 		UpdateAttr();
522*cdf0e10cSrcweir 	else
523*cdf0e10cSrcweir 		SwapPam();
524*cdf0e10cSrcweir 	ClearMark();
525*cdf0e10cSrcweir 	return nRet;
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir long SwWrtShell::DelPrvWord()
531*cdf0e10cSrcweir {
532*cdf0e10cSrcweir 	if(IsStartOfDoc())
533*cdf0e10cSrcweir 		return 0;
534*cdf0e10cSrcweir 	ACT_KONTEXT(this);
535*cdf0e10cSrcweir 	ResetCursorStack();
536*cdf0e10cSrcweir 	EnterStdMode();
537*cdf0e10cSrcweir 	SetMark();
538*cdf0e10cSrcweir     if ( !IsSttWrd() ||
539*cdf0e10cSrcweir          !_PrvWrdForDelete() ) // --> OD 2008-08-06 #i92468#
540*cdf0e10cSrcweir 	{
541*cdf0e10cSrcweir 		if( IsEndWrd() )
542*cdf0e10cSrcweir 		{
543*cdf0e10cSrcweir             if ( _PrvWrdForDelete() ) // --> OD 2008-08-06 #i92468#
544*cdf0e10cSrcweir 			{
545*cdf0e10cSrcweir 				// skip over all-1 spaces
546*cdf0e10cSrcweir 				short n = -1;
547*cdf0e10cSrcweir 				while( ' ' == GetChar( sal_False, n ))
548*cdf0e10cSrcweir 					--n;
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 				if( ++n )
551*cdf0e10cSrcweir 					ExtendSelection( sal_False, -n );
552*cdf0e10cSrcweir 			}
553*cdf0e10cSrcweir 		}
554*cdf0e10cSrcweir 		else if( IsSttPara())
555*cdf0e10cSrcweir             _PrvWrdForDelete(); // --> OD 2008-08-06 #i92468#
556*cdf0e10cSrcweir 		else
557*cdf0e10cSrcweir 			_SttWrd();
558*cdf0e10cSrcweir 	}
559*cdf0e10cSrcweir 	long nRet = Delete();
560*cdf0e10cSrcweir 	if( nRet )
561*cdf0e10cSrcweir 		UpdateAttr();
562*cdf0e10cSrcweir 	else
563*cdf0e10cSrcweir 		SwapPam();
564*cdf0e10cSrcweir 	ClearMark();
565*cdf0e10cSrcweir 	return nRet;
566*cdf0e10cSrcweir }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir 
571