xref: /aoo41x/main/sw/source/ui/wrtsh/wrtsh1.cxx (revision 43f0f119)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <com/sun/star/container/XChild.hpp>
28 #include <com/sun/star/embed/XVisualObject.hpp>
29 #include <com/sun/star/embed/EmbedMisc.hpp>
30 #include <com/sun/star/embed/EmbedStates.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
33 #include <com/sun/star/chart2/XChartDocument.hpp>
34 #include <com/sun/star/util/XModifiable.hpp>
35 
36 #include <math.h>	// prevent conflict between exception and std::exception
37 #include <hintids.hxx>
38 #include <svx/svdview.hxx>
39 #include <sot/factory.hxx>
40 #include <svl/itemiter.hxx>
41 #include <vcl/sound.hxx>
42 #include <tools/bigint.hxx>
43 #include <sot/storage.hxx>
44 #include <svtools/insdlg.hxx>
45 #include <sfx2/frmdescr.hxx>
46 #include <sfx2/ipclient.hxx>
47 #include <svtools/ehdl.hxx>
48 #include <svtools/soerr.hxx>
49 #include <tools/cachestr.hxx>
50 #include <unotools/moduleoptions.hxx>
51 #include <editeng/sizeitem.hxx>
52 #include <editeng/brkitem.hxx>
53 #include <editeng/svxacorr.hxx>
54 #include <vcl/graph.hxx>
55 #include <sfx2/printer.hxx>
56 #include <unotools/charclass.hxx>
57 #include <comphelper/storagehelper.hxx>
58 #include <svx/svxdlg.hxx>
59 #include <svx/extrusionbar.hxx>
60 #include <svx/fontworkbar.hxx>
61 #include <frmfmt.hxx>
62 #include <fmtftn.hxx>
63 #include <fmtpdsc.hxx>
64 #include <wdocsh.hxx>
65 #include <basesh.hxx>
66 #include <swmodule.hxx>
67 #include <wrtsh.hxx>
68 #include <view.hxx>
69 #include <uitool.hxx>
70 #include <cmdid.h>
71 #include <cfgitems.hxx>
72 #include <pagedesc.hxx>
73 #include <frmmgr.hxx>
74 #include <shellio.hxx>
75 #include <uinums.hxx>  // fuer Anwenden einer
76 #include <swundo.hxx>  // fuer Undo-Ids
77 #include <swcli.hxx>
78 #include <poolfmt.hxx>
79 #include <wview.hxx>
80 #include <edtwin.hxx>
81 #include <fmtcol.hxx>
82 #include <swtable.hxx>
83 #include <caption.hxx>
84 #include <viscrs.hxx>
85 #include <swdtflvr.hxx>
86 #include <crsskip.hxx>
87 #include <doc.hxx>
88 #include <wrtsh.hrc>
89 #include <SwStyleNameMapper.hxx>
90 #include <sfx2/request.hxx>
91 #include <paratr.hxx>
92 #include <ndtxt.hxx>
93 #include <editeng/acorrcfg.hxx>
94 #include <IMark.hxx>
95 #include <sfx2/bindings.hxx>
96 
97 // -> #111827#
98 #include <SwRewriter.hxx>
99 #include <comcore.hrc>
100 // <- #111827#
101 
102 #include <toolkit/helper/vclunohelper.hxx>
103 #include <sfx2/viewfrm.hxx>
104 
105 #include <editeng/acorrcfg.hxx>
106 
107 #include "PostItMgr.hxx"
108 #include <sfx2/msgpool.hxx>
109 
110 using namespace sw::mark;
111 using namespace com::sun::star;
112 
113 #define COMMON_INI_LIST \
114 		fnDrag(&SwWrtShell::BeginDrag),\
115         fnSetCrsr(&SwWrtShell::SetCrsr),\
116 		fnEndDrag(&SwWrtShell::EndDrag),\
117 		fnKillSel(&SwWrtShell::Ignore),\
118         pModeStack(0), \
119         ePageMove(MV_NO),\
120         pCrsrStack(0),  \
121         rView(rShell),\
122         bDestOnStack(sal_False), \
123         fnLeaveSelect(&SwWrtShell::SttLeaveSelect)
124 
125 #define BITFLD_INI_LIST \
126 		bClearMark = \
127 		bIns = sal_True;\
128 		bAddMode = \
129 		bBlockMode = \
130 		bExtMode = \
131 		bInSelect = \
132 		bCopy = \
133 		bLayoutMode = \
134 		bNoEdit = \
135 		bSelWrd = \
136 		bSelLn = \
137 		bIsInClickToEdit = \
138 		mbRetainSelection = sal_False;
139 
140 
141 SvxAutoCorrect* lcl_IsAutoCorr()
142 {
143    	SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get()->GetAutoCorrect();
144     if( pACorr && !pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
145 							AddNonBrkSpace | ChgOrdinalNumber |
146                             ChgToEnEmDash | SetINetAttr | Autocorrect ))
147 		pACorr = 0;
148 	return pACorr;
149 }
150 
151 void SwWrtShell::NoEdit(sal_Bool bHideCrsr)
152 {
153 	if(bHideCrsr)
154 		HideCrsr();
155 	bNoEdit = sal_True;
156 }
157 
158 
159 
160 void SwWrtShell::Edit()
161 {
162 	if (CanInsert())
163 	{
164 		ShowCrsr();
165 		bNoEdit = sal_False;
166 	}
167 }
168 
169 
170 
171 sal_Bool SwWrtShell::IsEndWrd()
172 {
173 	MV_KONTEXT(this);
174 	if(IsEndPara() && !IsSttPara())
175 		return sal_True;
176 
177 	return IsEndWord();
178 }
179 
180 
181 /*------------------------------------------------------------------------
182  Beschreibung:	Abfrage, ob Einfuegen moeglich ist; gfs. Beep
183 ------------------------------------------------------------------------*/
184 
185 
186 
187 sal_Bool SwWrtShell::_CanInsert()
188 {
189 	if(!CanInsert())
190 	{
191 		Sound::Beep();
192 		return sal_False;
193 	}
194 	return sal_True;
195 }
196 /*------------------------------------------------------------------------
197  Beschreibung:	String einfuegen
198 ------------------------------------------------------------------------*/
199 
200 void SwWrtShell::InsertByWord( const String & rStr)
201 {
202 	if( rStr.Len() )
203 	{
204 		sal_Bool bDelim = GetAppCharClass().isLetterNumeric( rStr, 0 );
205 		xub_StrLen nPos = 0, nStt = 0;
206 		for( ; nPos < rStr.Len(); nPos++ )
207    		{
208 			sal_Bool bTmpDelim = GetAppCharClass().isLetterNumeric( rStr, nPos );
209 			if( bTmpDelim != bDelim )
210 			{
211 				Insert( rStr.Copy( nStt, nPos - nStt ));
212 				nStt = nPos;
213 			}
214 		}
215 		if( nStt != nPos )
216 			Insert( rStr.Copy( nStt, nPos - nStt ));
217 	}
218 }
219 
220 
221 void SwWrtShell::Insert( const String &rStr )
222 {
223 	ResetCursorStack();
224 	if( !_CanInsert() )
225 		return;
226 
227 	sal_Bool bStarted = sal_False, bHasSel = HasSelection(),
228 		bCallIns = bIns /*|| bHasSel*/;
229     bool bDeleted = false;
230 
231     if( bHasSel || ( !bIns && SelectHiddenRange() ) )
232 	{
233 			// nur hier klammern, da das normale Insert schon an der
234 			// Editshell geklammert ist
235 		StartAllAction();
236 
237         // #111827#
238         SwRewriter aRewriter;
239 
240         aRewriter.AddRule(UNDO_ARG1, GetCrsrDescr());
241         aRewriter.AddRule(UNDO_ARG2, String(SW_RES(STR_YIELDS)));
242         {
243             String aTmpStr;
244             aTmpStr += String(SW_RES(STR_START_QUOTE));
245             aTmpStr += rStr;
246             aTmpStr += String(SW_RES(STR_END_QUOTE));
247 
248             aRewriter.AddRule(UNDO_ARG3, rStr);
249         }
250 
251 		StartUndo(UNDO_REPLACE, &aRewriter);
252 		bStarted = sal_True;
253         bDeleted = DelRight() != 0;
254 	}
255 
256     /*
257 JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das
258 			naechste Zeichen.
259 	if( bHasSel && !bIns && 1 < rStr.Len() )
260 	{
261 		// falls mehrere Zeichen anstehen, nur das erste einfuegen,
262 		// der Rest muss dann aber Ueberschrieben werden.
263 		SwEditShell::Insert( rStr.GetChar( 0 ) );
264 		SwEditShell::Overwrite( rStr.Copy( 1 ) );
265 	}
266 	else
267 */
268     bCallIns ?
269         SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr );
270 
271 
272 	if( bStarted )
273 	{
274 		EndAllAction();
275         EndUndo();
276 	}
277 //    delete pChgFlg;
278 }
279 
280 /* Begrenzung auf maximale Hoehe geht nicht, da die maximale Hoehe
281  * des aktuellen Frames nicht erfragt werden kann. */
282 
283 
284 
285 void SwWrtShell::Insert( const String &rPath, const String &rFilter,
286 						 const Graphic &rGrf, SwFlyFrmAttrMgr *pFrmMgr,
287 						 sal_Bool bRule )
288 {
289 	ResetCursorStack();
290 	if ( !_CanInsert() )
291 		return;
292 
293 	StartAllAction();
294 
295     SwRewriter aRewriter;
296     aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_GRAPHIC));
297 
298 	StartUndo(UNDO_INSERT, &aRewriter);
299 
300 	if ( HasSelection() )
301 		DelRight();
302 		// eingefuegte Grafik in eigenen Absatz, falls am Ende
303 		// eines nichtleeren Absatzes
304 	//For i120928,avoid to split node
305 	//if ( IsEndPara() && !IsSttPara() )
306 	//	SwFEShell::SplitNode();
307 
308 	EnterSelFrmMode();
309 
310 	sal_Bool bSetGrfSize = sal_True;
311 	sal_Bool bOwnMgr	 = sal_False;
312 
313 	if ( !pFrmMgr )
314 	{
315 		bOwnMgr = sal_True;
316 		pFrmMgr = new SwFlyFrmAttrMgr( sal_True, this, FRMMGR_TYPE_GRF );
317 
318 		// VORSICHT
319 		// GetAttrSet nimmt einen Abgleich vor
320 		// Beim Einfuegen ist eine SwFrmSize vorhanden wegen der
321 		// DEF-Rahmengroesse
322 		// Diese muss fuer die optimale Groesse explizit entfernt werden
323 		pFrmMgr->DelAttr(RES_FRM_SIZE);
324 	}
325 	else
326 	{
327 		Size aSz( pFrmMgr->GetSize() );
328 		if ( !aSz.Width() || !aSz.Height() )
329 		{
330 			aSz.Width() = aSz.Height() = 567;
331 			pFrmMgr->SetSize( aSz );
332 		}
333 		else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT )
334 			bSetGrfSize = sal_False;
335 
336         pFrmMgr->SetHeightSizeType(ATT_FIX_SIZE);
337 
338 	}
339 
340 	// Einfuegen der Grafik
341 	SwFEShell::Insert(rPath, rFilter, &rGrf, &pFrmMgr->GetAttrSet());
342 	if ( bOwnMgr )
343 		pFrmMgr->UpdateAttrMgr();
344 
345 	if( bSetGrfSize && !bRule )
346 	{
347 		Size aGrfSize, aBound = GetGraphicDefaultSize();
348 		GetGrfSize( aGrfSize );
349 
350 		//Die GrafikSize noch um die Randattribute vergroessern, denn die
351 		//Zaehlen beim Rahmen mit.
352 		aGrfSize.Width() += pFrmMgr->CalcWidthBorder();
353 		aGrfSize.Height()+= pFrmMgr->CalcHeightBorder();
354 
355 		const BigInt aTempWidth( aGrfSize.Width() );
356 		const BigInt aTempHeight( aGrfSize.Height());
357 
358 		// ggf. Breite anpassen, Hoehe dann proportional verkleinern
359 		if( aGrfSize.Width() > aBound.Width() )
360 		{
361 			aGrfSize.Width()  = aBound.Width();
362 			aGrfSize.Height() = ((BigInt)aBound.Width()) * aTempHeight / aTempWidth;
363 		}
364 		// ggf. Hoehe anpassen, Breite dann proportional verkleinern
365 		if( aGrfSize.Height() > aBound.Height() )
366 		{
367 			aGrfSize.Height() = aBound.Height();
368 			aGrfSize.Width() =  ((BigInt)aBound.Height()) * aTempWidth / aTempHeight;
369 		}
370 		pFrmMgr->SetSize( aGrfSize );
371 		pFrmMgr->UpdateFlyFrm();
372 	}
373 	if ( bOwnMgr )
374 		delete pFrmMgr;
375 
376     EndUndo();
377 	EndAllAction();
378 }
379 
380 
381 /*------------------------------------------------------------------------
382    Beschreibung: Fuegt ein OLE-Objekt in die CORE ein.
383 				 Wenn kein Object uebergeben wird, so wird eins erzeugt.
384 ------------------------------------------------------------------------*/
385 
386 
387 void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName *pName,
388                             sal_Bool bActivate, sal_uInt16 nSlotId )
389 {
390 	ResetCursorStack();
391 	if( !_CanInsert() )
392 		return;
393 
394     if( !xRef.is() )
395 	{
396         // temporary storage
397         svt::EmbeddedObjectRef xObj;
398         uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetTemporaryStorage();
399 		sal_Bool bDoVerb = sal_True;
400 		if ( pName )
401 		{
402             comphelper::EmbeddedObjectContainer aCnt( xStor );
403             ::rtl::OUString aName;
404             // TODO/LATER: get aspect?
405             xObj.Assign( aCnt.CreateEmbeddedObject( pName->GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
406 		}
407 		else
408 		{
409             SvObjectServerList aServerList;
410 			switch (nSlotId)
411 			{
412 				case SID_INSERT_OBJECT:
413 				{
414                     aServerList.FillInsertObjects();
415                     aServerList.Remove( SwDocShell::Factory().GetClassId() );
416                     // Intentionally no break!
417 				}
418 
419                 // TODO/LATER: recording! Convert properties to items
420 				case SID_INSERT_PLUGIN:
421                     /*
422                     if(pReq)
423                     {
424 						INetURLObject* pURL = aDlg.GetURL();
425 						if(pURL)
426                             pReq->AppendItem(SfxStringItem(FN_PARAM_2, pURL->GetMainURL(INetURLObject::NO_DECODE)));
427 						pReq->AppendItem(SfxStringItem(FN_PARAM_3 , aDlg.GetCommands()));
428                     } */
429 				case SID_INSERT_FLOATINGFRAME:
430                     /*
431                     if(pReq && xFloatingFrame.Is())
432                     {
433                         const SfxFrameDescriptor* pDescriptor = xFloatingFrame->GetFrameDescriptor();
434                         pReq->AppendItem(SfxStringItem(FN_PARAM_1, pDescriptor->GetName()));
435                         pReq->AppendItem(
436                                 SfxStringItem( FN_PARAM_2,
437                                     pDescriptor->GetURL().GetMainURL(INetURLObject::NO_DECODE)));
438                         pReq->AppendItem(SvxSizeItem(FN_PARAM_3, pDescriptor->GetMargin()));
439                         pReq->AppendItem(SfxByteItem(FN_PARAM_4, pDescriptor->GetScrollingMode()));
440                         pReq->AppendItem(SfxBoolItem(FN_PARAM_5, pDescriptor->HasFrameBorder()));
441                     }*/
442                 {
443                     SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
444                     const SfxSlot* pSlot = pSlotPool->GetSlot(nSlotId);
445                     rtl::OString aCmd(".uno:");
446                     aCmd += pSlot->GetUnoName();
447                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
448                     SfxAbstractInsertObjectDialog* pDlg =
449                             pFact->CreateInsertObjectDialog( GetWin(), rtl::OUString( aCmd, aCmd.getLength(), RTL_TEXTENCODING_UTF8 ), xStor, &aServerList );
450                     if ( pDlg )
451                     {
452                         pDlg->Execute();
453                         bDoVerb = pDlg->IsCreateNew();
454 						::rtl::OUString aIconMediaType;
455 						uno::Reference< io::XInputStream > xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
456                         xObj.Assign( pDlg->GetObject(),
457 									 xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
458 						if ( xIconMetaFile.is() )
459 							xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
460 
461                         DELETEZ( pDlg );
462                     }
463 
464                     break;
465                 }
466 
467 				default:
468 					break;
469 			}
470 		}
471 
472         if ( xObj.is() )
473 		{
474             if( InsertOleObject( xObj ) && bActivate && bDoVerb )
475 			{
476                 SfxInPlaceClient* pClient = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
477                 if ( !pClient )
478 				{
479                     pClient = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
480 					SetCheckForOLEInCaption( sal_True );
481 				}
482 
483 				if ( xObj.GetViewAspect() == embed::Aspects::MSOLE_ICON )
484 				{
485 					SwRect aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
486 					aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
487 					MapMode aMapMode( MAP_TWIP );
488 					Size aSize = xObj.GetSize( &aMapMode );
489 					aArea.Width( aSize.Width() );
490 					aArea.Height( aSize.Height() );
491 					RequestObjectResize( aArea, xObj.GetObject() );
492 				}
493 				else
494                 	CalcAndSetScale( xObj );
495 
496                 //#50270# Error brauchen wir nicht handeln, das erledigt das
497                 //DoVerb in der SfxViewShell
498                 pClient->DoVerb( SVVERB_SHOW );
499 
500                 // TODO/LATER: set document name - should be done in Client
501                 //if ( !ERRCODE_TOERROR( nErr ) )
502                 //    xIPObj->SetDocumentName( GetView().GetDocShell()->GetTitle() );
503 			}
504 		}
505 	}
506 	else
507 	{
508 		if( HasSelection() )
509 			DelRight();
510         InsertOleObject( xRef );
511 	}
512 }
513 
514 /*------------------------------------------------------------------------
515  Beschreibung:	 Object in die Core einfuegen.
516 				 Vom ClipBoard oder Insert
517 ------------------------------------------------------------------------*/
518 
519 sal_Bool SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrmFmt **pFlyFrmFmt )
520 {
521     ResetCursorStack();
522 	StartAllAction();
523 
524 	StartUndo(UNDO_INSERT);
525 
526 	//Some differences between StarMath and any other objects:
527 	//1. Selections should be deleted. For StarMath the Text should be
528 	//   passed to the Object
529 	//2. If the cursor is at the end of an non empty paragraph a paragraph
530 	//   break should be insertet. StarMath objects are character bound and
531 	//   no break should be inserted.
532 	//3. If an selektion is passed to a StarMath object, this object should
533 	//   not be activated. sal_False should be returned then.
534     sal_Bool bStarMath = sal_True;
535     sal_Bool bActivate = sal_True;
536 
537 	// set parent to get correct VisArea(in case of object needing parent printer)
538 	uno::Reference < container::XChild > xChild( xRef.GetObject(), uno::UNO_QUERY );
539 	if ( xChild.is() )
540 		xChild->setParent( pDoc->GetDocShell()->GetModel() );
541 
542 	SvGlobalName aCLSID( xRef->getClassID() );
543 	bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
544 	if( IsSelection() )
545 	{
546 		if( bStarMath )
547 		{
548 			String aMathData;
549 			GetSelectedText( aMathData, GETSELTXT_PARABRK_TO_ONLYCR );
550 
551 			if( aMathData.Len() && svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) )
552 			{
553 				uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY );
554 				if ( xSet.is() )
555 				{
556 					try
557 					{
558 						xSet->setPropertyValue( ::rtl::OUString::createFromAscii("Formula"), uno::makeAny( ::rtl::OUString( aMathData ) ) );
559                         bActivate = sal_False;
560 					}
561 					catch ( uno::Exception& )
562 					{
563 					}
564 				}
565 			}
566 		}
567 		DelRight();
568 	}
569 
570 	if ( !bStarMath )
571 		SwFEShell::SplitNode( sal_False, sal_False );
572 
573 	EnterSelFrmMode();
574 
575 	SwFlyFrmAttrMgr aFrmMgr( sal_True, this, FRMMGR_TYPE_OLE );
576 	aFrmMgr.SetHeightSizeType(ATT_FIX_SIZE);
577 
578 	SwRect aBound;
579 	CalcBoundRect( aBound, aFrmMgr.GetAnchor() );
580 
581 	//The Size should be suggested by the OLE server
582 	MapMode aMapMode( MAP_TWIP );
583 	Size aSz = xRef.GetSize( &aMapMode );
584 
585 	//Object size can be limited
586 	if ( aSz.Width() > aBound.Width() )
587 	{
588 		//Immer proportional begrenzen.
589 		aSz.Height() = aSz.Height() * aBound.Width() / aSz.Width();
590 		aSz.Width() = aBound.Width();
591 	}
592 	aFrmMgr.SetSize( aSz );
593     SwFlyFrmFmt *pFmt = SwFEShell::InsertObject( xRef, &aFrmMgr.GetAttrSet() );
594 
595     // --> #i972#
596     if ( bStarMath && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) )
597         AlignFormulaToBaseline( xRef.GetObject() );
598     // <--
599 
600     if (pFlyFrmFmt)
601         *pFlyFrmFmt = pFmt;
602 
603     if ( SotExchange::IsChart( aCLSID ) )
604     {
605         uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY );
606         if ( xEmbeddedObj.is() )
607         {
608             bool bDisableDataTableDialog = false;
609             svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj );
610             uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
611             if ( xProps.is() &&
612                  ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
613                  bDisableDataTableDialog )
614             {
615                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
616                     uno::makeAny( sal_False ) );
617                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
618                     uno::makeAny( sal_False ) );
619                 uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
620                 if ( xModifiable.is() )
621                 {
622                     xModifiable->setModified( sal_True );
623                 }
624             }
625         }
626     }
627 
628 	EndAllAction();
629 	GetView().AutoCaption(OLE_CAP, &aCLSID);
630 
631     SwRewriter aRewriter;
632 
633 	if ( bStarMath )
634 		aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_MATH_FORMULA));
635 	else if ( SotExchange::IsChart( aCLSID ) )
636 		aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_CHART));
637 	else
638 		aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_OLE));
639 
640     EndUndo(UNDO_INSERT, &aRewriter);
641 
642     return bActivate;
643 }
644 
645 /*------------------------------------------------------------------------
646 	Beschreibung: Das aktuelle selektierte OLE-Objekt wird mit dem
647 				  Verb in den Server geladen.
648 ------------------------------------------------------------------------*/
649 
650 
651 
652 void SwWrtShell::LaunchOLEObj( long nVerb )
653 {
654 	if ( GetCntType() == CNT_OLE &&
655          !GetView().GetViewFrame()->GetFrame().IsInPlace() )
656 	{
657         svt::EmbeddedObjectRef& xRef = GetOLEObject();
658         ASSERT( xRef.is(), "OLE not found" );
659         SfxInPlaceClient* pCli=0;
660 
661         pCli = GetView().FindIPClient( xRef.GetObject(), &GetView().GetEditWin() );
662         if ( !pCli )
663             pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xRef );
664 
665         ((SwOleClient*)pCli)->SetInDoVerb( sal_True );
666 
667         CalcAndSetScale( xRef );
668         pCli->DoVerb( nVerb );
669 
670         ((SwOleClient*)pCli)->SetInDoVerb( sal_False );
671         CalcAndSetScale( xRef );
672 	}
673 }
674 
675 void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset )
676 {
677     try
678     {
679         sal_Int32 nState = xObj->getCurrentState();
680         if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE
681           || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE )
682         {
683             SfxInPlaceClient* pCli =
684 				GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) );
685             if ( pCli )
686             {
687                 Rectangle aArea = pCli->GetObjArea();
688                 aArea += rOffset;
689                 pCli->SetObjArea( aArea );
690             }
691         }
692     }
693     catch( uno::Exception& )
694     {}
695 }
696 
697 
698 void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
699                                   const SwRect *pFlyPrtRect,
700                                   const SwRect *pFlyFrmRect,
701                                   const bool bNoTxtFrmPrtAreaChanged )
702 {
703 	//Einstellen der Skalierung am Client. Diese ergibt sich aus der Differenz
704 	//zwischen der VisArea des Objektes und der ObjArea.
705     ASSERT( xObj.is(), "ObjectRef not  valid" );
706 
707     sal_Int64 nAspect = xObj.GetViewAspect();
708     if ( nAspect == embed::Aspects::MSOLE_ICON )
709         return; // the replacement image is completely controlled by container in this case
710 
711     sal_Int64 nMisc = 0;
712     sal_Bool bLinkingChart = sal_False;
713 
714     try
715     {
716         nMisc = xObj->getStatus( nAspect );
717 
718         //Das kann ja wohl nur ein nicht aktives Objekt sein. Diese bekommen
719         //auf Wunsch die neue Groesse als VisArea gesetzt (StarChart)
720         if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc )
721         {
722             // TODO/MBA: testing
723             SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
724                         : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
725             if( !aRect.IsEmpty() )
726             {
727                 // TODO/LEAN: getMapUnit can switch object to running state
728                 // xObj.TryRunningState();
729 
730                 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
731 
732                 // TODO/LATER: needs complete VisArea?!
733                 Size aSize( OutputDevice::LogicToLogic( aRect.SVRect(), MAP_TWIP, aUnit ).GetSize() );
734                 awt::Size aSz;
735                 aSz.Width = aSize.Width();
736                 aSz.Height = aSize.Height();
737                 xObj->setVisualAreaSize( nAspect, aSz );
738                 // --> OD 2005-05-02 #i48419# - action 'UpdateReplacement' doesn't
739                 // have to change the modified state of the document.
740                 // This is only a workaround for the defect, that this action
741                 // modifies a document after load, because unnecessarily the
742                 // replacement graphic is updated, in spite of the fact that
743                 // nothing has been changed.
744                 // If the replacement graphic changes by this action, the document
745                 // will be already modified via other mechanisms.
746                 {
747                     bool bResetEnableSetModified(false);
748                     if ( GetDoc()->GetDocShell()->IsEnableSetModified() )
749                     {
750                         GetDoc()->GetDocShell()->EnableSetModified( sal_False );
751                         bResetEnableSetModified = true;
752                     }
753 
754                     //#i79576# don't destroy chart replacement images on load
755                     //#i79578# don't request a new replacement image for charts to often
756                     //a chart sends a modified call to the framework if it was changed
757                     //thus the replacement update is already handled elsewhere
758                     if ( !SotExchange::IsChart( xObj->getClassID() ) )
759                         xObj.UpdateReplacement();
760 
761                     if ( bResetEnableSetModified )
762                     {
763                         GetDoc()->GetDocShell()->EnableSetModified( sal_True );
764                     }
765                 }
766                 // <--
767             }
768 
769             // TODO/LATER: this is only a workaround,
770             uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY );
771             bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() );
772         }
773     }
774     catch ( uno::Exception& )
775     {
776         // TODO/LATER: handle the error
777         return;
778     }
779 
780     SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
781     if ( !pCli )
782     {
783         if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc)
784              || bLinkingChart
785             // TODO/LATER: ResizeOnPrinterChange
786              //|| SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->GetMiscStatus()
787              // --> OD #i117189# - refine condition for non-resizable objects
788              // non-resizable objects need to be set the size back by this method
789              || ( bNoTxtFrmPrtAreaChanged && nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
790         {
791             pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
792         }
793         else
794             return;
795     }
796 
797     // TODO/LEAN: getMapUnit can switch object to running state
798     // xObj.TryRunningState();
799 
800     awt::Size aSize;
801     try
802     {
803         aSize = xObj->getVisualAreaSize( nAspect );
804     }
805     catch( embed::NoVisualAreaSizeException& )
806     {
807         DBG_ERROR( "Can't get visual area size!\n" );
808         // the scaling will not be done
809     }
810     catch( uno::Exception& )
811     {
812         // TODO/LATER: handle the error
813         DBG_ERROR( "Can't get visual area size!\n" );
814         return;
815     }
816 
817     Size _aVisArea( aSize.Width, aSize.Height );
818 
819 	Fraction aScaleWidth( 1, 1 );
820 	Fraction aScaleHeight( 1, 1 );
821 
822 	sal_Bool bUseObjectSize = sal_False;
823 
824 	// solange keine vernuenftige Size vom Object kommt, kann nichts
825 	// skaliert werden
826     if( _aVisArea.Width() && _aVisArea.Height() )
827 	{
828 		const MapMode aTmp( MAP_TWIP );
829         MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
830         _aVisArea = OutputDevice::LogicToLogic( _aVisArea, aUnit, aTmp);
831 		Size aObjArea;
832 		if ( pFlyPrtRect )
833 			aObjArea = pFlyPrtRect->SSize();
834 		else
835             aObjArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ).SSize();
836 
837         // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea
838 		long nX, nY;
839 		SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY );
840         if( !( _aVisArea.Width() - nX <= aObjArea.Width() &&
841                _aVisArea.Width() + nX >= aObjArea.Width() &&
842                _aVisArea.Height()- nY <= aObjArea.Height()&&
843                _aVisArea.Height()+ nY >= aObjArea.Height() ))
844 		{
845             // TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE
846             /*
847             if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & nMisc )
848 			{
849 				//This type of objects should never be resized.
850 				//If this request comes from the Writer core (inaktive Object
851 				//ist resized), the Object should be resized too.
852 				//If this request comes from the Object itself, the Frame
853 				//in the Writer core should be resized.
854 				if ( pFlyPrtRect )		//Request from core?
855 				{
856 					xObj->SetVisArea( OutputDevice::LogicToLogic(
857 						pFlyPrtRect->SVRect(), MAP_TWIP, xObj->GetMapUnit() ));
858 				}
859 				else
860 				{
861                     SwRect aTmp( Point( LONG_MIN, LONG_MIN ), _aVisArea );
862 					RequestObjectResize( aTmp, xObj );
863 				}
864 				//Der Rest erledigt sich, weil wir eh wiederkommen sollten, evtl.
865 				//sogar rekursiv.
866 				return;
867 			}
868             else*/
869 
870 			if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE )
871 			{
872 				// the object must not be scaled, the size stored in object must be used for restoring
873 				bUseObjectSize = sal_True;
874 			}
875 			else
876 			{
877                 aScaleWidth = Fraction( aObjArea.Width(),   _aVisArea.Width() );
878                 aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height());
879 			}
880 		}
881 	}
882 
883 	//Jetzt ist auch der guenstige Zeitpunkt die ObjArea einzustellen.
884 	//Die Scalierung muss beruecksichtigt werden.
885 	SwRect aArea;
886 	if ( pFlyPrtRect )
887 	{
888 		aArea = *pFlyPrtRect;
889 		aArea += pFlyFrmRect->Pos();
890 	}
891 	else
892 	{
893         aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
894         aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
895 	}
896 
897 	if ( bUseObjectSize )
898 	{
899         // --> this moves non-resizable object so that when adding borders the baseline remains the same
900         const SwFlyFrmFmt *pFlyFrmFmt = dynamic_cast< const SwFlyFrmFmt * >( GetFlyFrmFmt() );
901         ASSERT( pFlyFrmFmt, "Could not find fly frame." );
902         if ( pFlyFrmFmt )
903         {
904             const Point &rPoint = pFlyFrmFmt->GetLastFlyFrmPrtRectPos();
905             SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
906                         : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
907             aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct.
908         }
909         // <--
910         aArea.Width ( _aVisArea.Width() );
911         aArea.Height( _aVisArea.Height() );
912 		RequestObjectResize( aArea, xObj.GetObject() );
913 	}
914 	else
915 	{
916 		aArea.Width ( Fraction( aArea.Width()  ) / pCli->GetScaleWidth() );
917 		aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight());
918 	}
919 
920     pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight );
921 }
922 
923 
924 
925 void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt,
926 							const SwRect &rFrm )
927 {
928     SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin());
929     if ( !pCli )
930         pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
931     CalcAndSetScale( xObj, &rPrt, &rFrm );
932 }
933 
934 /*------------------------------------------------------------------------
935  Beschreibung:	Einfuegen harter Seitenumbruch;
936 				Selektionen werden ueberschrieben
937 ------------------------------------------------------------------------*/
938 
939 
940 
941 void SwWrtShell::InsertPageBreak(const String *pPageDesc, sal_uInt16 nPgNum )
942 {
943 	ResetCursorStack();
944 	if( _CanInsert() )
945 	{
946 		ACT_KONTEXT(this);
947         StartUndo(UNDO_UI_INSERT_PAGE_BREAK);
948 
949 		if ( !IsCrsrInTbl() )
950 		{
951 			if(HasSelection())
952 				DelRight();
953 			SwFEShell::SplitNode();
954 		}
955 
956 		const SwPageDesc *pDesc = pPageDesc
957 								? FindPageDescByName( *pPageDesc, sal_True ) : 0;
958 		if( pDesc )
959 		{
960 			SwFmtPageDesc aDesc( pDesc );
961 			aDesc.SetNumOffset( nPgNum );
962 			SetAttr( aDesc );
963 		}
964 		else
965             SetAttr( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
966         EndUndo(UNDO_UI_INSERT_PAGE_BREAK);
967 	}
968 }
969 /*------------------------------------------------------------------------
970  Beschreibung:	Einfuegen harter Zeilenumbruch;
971 				Selektionen werden ueberschrieben
972 ------------------------------------------------------------------------*/
973 
974 
975 void SwWrtShell::InsertLineBreak()
976 {
977 	ResetCursorStack();
978 	if( _CanInsert() )
979 	{
980 		if(HasSelection())
981 			DelRight();
982 
983 		const sal_Unicode cIns = 0x0A;
984 		SvxAutoCorrect* pACorr = lcl_IsAutoCorr();
985 	    if( pACorr )
986 			AutoCorrect( *pACorr, cIns );
987 		else
988 			SwWrtShell::Insert( String( cIns ) );
989 	}
990 }
991 /*------------------------------------------------------------------------
992  Beschreibung:	Einfuegen harter Spaltenumbruch;
993 				Selektionen werden ueberschrieben
994 ------------------------------------------------------------------------*/
995 
996 
997 void SwWrtShell::InsertColumnBreak()
998 {
999 	ACT_KONTEXT(this);
1000 	ResetCursorStack();
1001 	if( _CanInsert() )
1002 	{
1003         StartUndo(UNDO_UI_INSERT_COLUMN_BREAK);
1004 
1005 		if ( !IsCrsrInTbl() )
1006 		{
1007 			if(HasSelection())
1008 				DelRight();
1009 			SwFEShell::SplitNode( sal_False, sal_False );
1010 		}
1011         SetAttr(SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK));
1012 
1013         EndUndo(UNDO_UI_INSERT_COLUMN_BREAK);
1014 	}
1015 }
1016 
1017 /*------------------------------------------------------------------------
1018  Beschreibung:	Einfuegen Fussnote
1019  Parameter: 	rStr -- optionales Fussnotenzeichen
1020 ------------------------------------------------------------------------*/
1021 
1022 
1023 void SwWrtShell::InsertFootnote(const String &rStr, sal_Bool bEndNote, sal_Bool bEdit )
1024 {
1025 	ResetCursorStack();
1026 	if( _CanInsert() )
1027 	{
1028 		if(HasSelection())
1029         {
1030             //collapse cursor to the end
1031             if(!IsCrsrPtAtEnd())
1032                 SwapPam();
1033             ClearMark();
1034         }
1035 
1036 		SwFmtFtn aFootNote( bEndNote );
1037 		if(rStr.Len())
1038 			aFootNote.SetNumStr( rStr );
1039 
1040 		SetAttr(aFootNote);
1041 
1042 		if( bEdit )
1043 		{
1044 			// zur Bearbeiung des Fussnotentextes
1045 			Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
1046 			GotoFtnTxt();
1047 		}
1048 	}
1049 }
1050 /*------------------------------------------------------------------------
1051  Beschreibung:	SplitNode; hier auch, da
1052 					- selektierter Inhalt geloescht wird;
1053 					- der Cursorstack gfs. zurueckgesetzt wird.
1054 ------------------------------------------------------------------------*/
1055 
1056 
1057 void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart )
1058 {
1059 	ResetCursorStack();
1060 	if( _CanInsert() )
1061 	{
1062 		ACT_KONTEXT(this);
1063 
1064         rView.GetEditWin().FlushInBuffer();
1065 		sal_Bool bHasSel = HasSelection();
1066 		if( bHasSel )
1067 		{
1068 			StartUndo( UNDO_INSERT );
1069 			DelRight();
1070 		}
1071 
1072 		SwFEShell::SplitNode( bAutoFmt, bCheckTableStart );
1073 		if( bHasSel )
1074 			EndUndo( UNDO_INSERT );
1075 	}
1076 }
1077 
1078 /*------------------------------------------------------------------------
1079  Beschreibung:	Numerierung anschalten
1080  Parameter: 	Optionale Angabe eines Namens fuer die benannte Liste;
1081 				dieser bezeichnet eine Position, wenn er in eine
1082 				Zahl konvertierbar ist und kleiner ist als nMaxRules.
1083 -------------------------------------------------------------------------*/
1084 
1085 
1086 // zum Testen der CharFormate an der Numerierung
1087 // extern void SetNumChrFmt( SwWrtShell*, SwNumRules& );
1088 
1089 // -> #i40041#
1090 // --> OD 2005-10-25 #b6340308#
1091 // Preconditions (as far as OD has figured out):
1092 // - <SwEditShell::HasNumber()> is sal_False, if <bNum> is sal_True
1093 // - <SwEditShell::HasBullet()> is sal_False, if <bNum> is sal_False
1094 // Behavior of method is determined by the current situation at the current
1095 // cursor position in the document.
1096 void SwWrtShell::NumOrBulletOn(sal_Bool bNum)
1097 {
1098     // determine numbering rule found at current cursor position in the docment.
1099     const SwNumRule* pCurRule = GetCurNumRule();
1100 
1101     StartUndo(UNDO_NUMORNONUM);
1102 
1103     const SwNumRule * pNumRule = pCurRule;
1104 
1105     // --> OD 2005-10-25 #b6340308#
1106     // - activate outline rule respectively turning on outline rule for
1107     //   current text node. But, only for turning on a numbering (<bNum> == sal_True).
1108     // - overwrite found numbering rule at current cursor position, if
1109     //   no numbering rule can be retrieved from the paragraph style.
1110     bool bContinueFoundNumRule( false );
1111     bool bActivateOutlineRule( false );
1112     int nActivateOutlineLvl( MAXLEVEL );    // only relevant, if <bActivateOutlineRule> == sal_True
1113     SwTxtFmtColl * pColl = GetCurTxtFmtColl();
1114     if ( pColl )
1115     {
1116         // --> OD 2005-10-25 #b6340308# - retrieve numbering rule at paragraph
1117         // style, which is found at current cursor position in the document.
1118         SwNumRule* pCollRule = pDoc->FindNumRulePtr(pColl->GetNumRule().GetValue());
1119         // --> OD 2005-10-25 #125993# - The outline numbering rule isn't allowed
1120         // to be derived from a parent paragraph style to a derived one.
1121         // Thus check, if the found outline numbering rule is directly
1122         // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL
1123         if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() )
1124         {
1125             const SwNumRule* pDirectCollRule =
1126                     pDoc->FindNumRulePtr(pColl->GetNumRule( sal_False ).GetValue());
1127             if ( !pDirectCollRule )
1128             {
1129                 pCollRule = 0;
1130             }
1131         }
1132         // --> OD 2006-11-20 #i71764#
1133         // Document setting OUTLINE_LEVEL_YIELDS_OUTLINE_RULE has no influence
1134         // any more.
1135 //        if ( pCollRule == NULL &&
1136 //             NO_NUMBERING != pColl->GetOutlineLevel() &&
1137 //             GetDoc()->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE) )
1138 //        {
1139 //            pCollRule = GetDoc()->GetOutlineNumRule();
1140 //        }
1141         // <--
1142 
1143         // <--
1144         // --> OD 2005-10-25 #b6340308#
1145         if ( !pCollRule )
1146         {
1147             pNumRule = pCollRule;
1148         }
1149         // --> OD 2006-06-12 #b6435904#
1150         // no activation or continuation of outline numbering in Writer/Web document
1151         else if ( bNum &&
1152                   !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) &&
1153                   pCollRule == GetDoc()->GetOutlineNumRule() )
1154         // <--
1155         {
1156             if ( pNumRule == pCollRule )
1157             {
1158                 // check, if text node at current cursor positioned is counted.
1159                 // If not, let it been counted. Then it has to be checked,
1160                 // of the outline numbering has to be activated or continued.
1161                 SwTxtNode* pTxtNode =
1162                             GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1163                 if ( pTxtNode && !pTxtNode->IsCountedInList() )
1164                 {
1165                     // check, if numbering of the outline level of the pararaph
1166                     // style is active. If not, activate this outline level.
1167 					nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
1168                     ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),	//<-end,zhaojianwei
1169                             "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
1170                     if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&		//<-end,zhaojianwei
1171                          pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1172                             == SVX_NUM_NUMBER_NONE )
1173                     {
1174                         // activate outline numbering
1175                         bActivateOutlineRule = true;
1176                     }
1177                     else
1178                     {
1179                         // turning on outline numbering at current cursor position
1180                         bContinueFoundNumRule = true;
1181                     }
1182                 }
1183                 else
1184                 {
1185                     // --> OD 2009-08-27 #i101234#
1186                     // activate outline numbering, because from the precondition
1187                     // it's known, that <SwEdit::HasNumber()> == sal_False
1188                     bActivateOutlineRule = true;
1189 					nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei
1190                 }
1191             }
1192             else if ( !pNumRule )
1193             {
1194                 // --> OD 2009-08-27 #i101234#
1195                 // Check, if corresponding list level of the outline numbering
1196                 // has already a numbering format set.
1197                 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration
1198                 if ( pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1199                                 == SVX_NUM_NUMBER_NONE )
1200                 {
1201                     // activate outline numbering, because from the precondition
1202                     // it's known, that <SwEdit::HasNumber()> == sal_False
1203                     bActivateOutlineRule = true;
1204                 }
1205                 else
1206                 {
1207                     // turning on outline numbering at current cursor position
1208                     bContinueFoundNumRule = true;
1209                 }
1210                 // <--
1211             }
1212             else
1213             {
1214                 // check, if numbering of the outline level of the pararaph
1215                 // style is active. If not, activate this outline level.
1216 				nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//#outline level,zhaojianwei
1217                 ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),//#outline level,zhaojianwei
1218                         "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
1219                 if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&//#outline level,zhaojianwei
1220                      pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
1221                         == SVX_NUM_NUMBER_NONE )
1222                 {
1223                     // activate outline numbering
1224                     bActivateOutlineRule = true;
1225                 }
1226                 else
1227                 {
1228                     // turning on outline numbering at current cursor position
1229                     bContinueFoundNumRule = true;
1230                 }
1231             }
1232             pNumRule = pCollRule;
1233         }
1234     }
1235 
1236     // --> OD 2005-10-25 #b6340308#
1237     // Only automatic numbering/bullet rules should be changed.
1238     // Note: The outline numbering rule is also an automatic one. It's only
1239     //       changed, if it has to be activated.
1240     if ( pNumRule )
1241     {
1242         if ( !pNumRule->IsAutoRule() )
1243         {
1244             pNumRule = 0;
1245         }
1246         else if ( pNumRule == GetDoc()->GetOutlineNumRule() &&
1247                   !bActivateOutlineRule && !bContinueFoundNumRule )
1248         {
1249             pNumRule = 0;
1250         }
1251     }
1252     // <--
1253 
1254     // --> OD 2005-10-25 #b6340308#
1255     // Search for a previous numbering/bullet rule to continue it.
1256     // --> OD 2008-03-18 #refactorlists#
1257     String sContinuedListId;
1258     if ( !pNumRule )
1259     {
1260         pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(),
1261                                             false, bNum, false, 0,
1262                                             sContinuedListId );
1263         bContinueFoundNumRule = pNumRule != 0;
1264     }
1265     // <--
1266 
1267     if (pNumRule)
1268     {
1269         SwNumRule aNumRule(*pNumRule);
1270 
1271         // --> OD 2005-10-25 #b6340308#
1272         // do not change found numbering/bullet rule, if it should only be continued.
1273         if ( !bContinueFoundNumRule )
1274         {
1275             SwTxtNode * pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1276 
1277             if (pTxtNode)
1278             {
1279                 // --> OD 2005-10-26 #b6340308# - use above retrieve outline
1280                 // level, if outline numbering has to be activated.
1281                 int nLevel = bActivateOutlineRule  ////#outline level,zhaojianwei,need more consideration
1282                               ? nActivateOutlineLvl
1283                               : pTxtNode->GetActualListLevel();
1284                 // <--
1285 
1286                 if (nLevel < 0)
1287                     nLevel = 0;
1288 
1289                 if (nLevel >= MAXLEVEL)
1290                     nLevel = MAXLEVEL - 1;
1291 
1292                 SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel)));
1293 
1294                 if (bNum)
1295                     aFmt.SetNumberingType(SVX_NUM_ARABIC);
1296                 else
1297                 {
1298                     // --> OD 2008-06-03 #i63395#
1299                     // Only apply user defined default bullet font
1300                     if ( numfunc::IsDefBulletFontUserDefined() )
1301                     {
1302                         const Font* pFnt = &numfunc::GetDefBulletFont();
1303                         aFmt.SetBulletFont( pFnt );
1304                     }
1305                     // <--
1306                     aFmt.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel)));
1307                     aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1308                     // #i93908# clear suffix for bullet lists
1309                     aFmt.SetPrefix(::rtl::OUString());
1310                     aFmt.SetSuffix(::rtl::OUString());
1311                 }
1312                 aNumRule.Set(static_cast<sal_uInt16>(nLevel), aFmt);
1313             }
1314         }
1315         // <--
1316 
1317         // --> OD 2008-02-08 #newlistlevelattrs#
1318         // reset indent attribute on applying list style
1319         // --> OD 2008-03-27 #refactorlists#
1320         SetCurNumRule( aNumRule, false, sContinuedListId, true );
1321         // <--
1322     }
1323     else
1324     {
1325         // --> OD 2009-08-27 #i95907#
1326         const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
1327                                     numfunc::GetDefaultPositionAndSpaceMode() );
1328         // --> OD 2008-02-11 #newlistlevelattrs#
1329         SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode );
1330         // <--
1331         // <--
1332         // Zeichenvorlage an die Numerierung haengen
1333         SwCharFmt* pChrFmt;
1334         SwDocShell* pDocSh = GetView().GetDocShell();
1335         // --> OD 2008-06-03 #i63395#
1336         // Only apply user defined default bullet font
1337         const Font* pFnt = numfunc::IsDefBulletFontUserDefined()
1338                            ? &numfunc::GetDefBulletFont()
1339                            : 0;
1340         // <--
1341 
1342         if (bNum)
1343         {
1344             pChrFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
1345         }
1346         else
1347         {
1348             pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL );
1349         }
1350 
1351         const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1352         const SwTwips nWidthOfTabs = pTxtNode
1353                                      ? pTxtNode->GetWidthOfLeadingTabs()
1354                                      : 0;
1355         GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() );
1356 
1357         const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
1358         const bool bRightToLeft = IsInRightToLeftText();
1359         for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
1360         {
1361             SwNumFmt aFmt( aNumRule.Get( nLvl ) );
1362             aFmt.SetCharFmt( pChrFmt );
1363 
1364             if (! bNum)
1365             {
1366                 // --> OD 2008-06-03 #i63395#
1367                 // Only apply user defined default bullet font
1368                 if ( pFnt )
1369                 {
1370                     aFmt.SetBulletFont( pFnt );
1371                 }
1372                 aFmt.SetBulletChar( numfunc::GetBulletChar(nLvl) );
1373                 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1374                 // #i93908# clear suffix for bullet lists
1375                 aFmt.SetPrefix(::rtl::OUString());
1376                 aFmt.SetSuffix(::rtl::OUString());
1377             }
1378 
1379             // --> OD 2009-08-26 #i95907#
1380             if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1381             {
1382                 if(bHtml && nLvl)
1383                 {
1384                     // 1/2" fuer HTML
1385                     aFmt.SetLSpace(720);
1386                     aFmt.SetAbsLSpace(nLvl * 720);
1387                 }
1388                 else if ( nWidthOfTabs > 0 )
1389                 {
1390                     aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720);
1391                 }
1392             }
1393             // <--
1394 
1395             // --> FME 2005-01-21 #i38904#  Default alignment for
1396             // numbering/bullet should be rtl in rtl paragraph:
1397             if ( bRightToLeft )
1398             {
1399                 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
1400             }
1401             // <--
1402 
1403             aNumRule.Set( nLvl, aFmt );
1404         }
1405 
1406         // --> OD 2009-08-26 #i95907#
1407         if ( pTxtNode &&
1408              ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1409         {
1410             // --> OD 2010-01-05 #b6884103#
1411 //            short nTxtNodeFirstLineOffset( 0 );
1412 //            pTxtNode->GetFirstLineOfsWithNum( nTxtNodeFirstLineOffset );
1413 //            const SwTwips nTxtNodeIndent = pTxtNode->GetLeftMarginForTabCalculation() +
1414 //                                           nTxtNodeFirstLineOffset;
1415             const SwTwips nTxtNodeIndent = pTxtNode->GetAdditionalIndentForStartingNewList();
1416             // <--
1417             if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 )
1418             {
1419                 // --> OD 2010-05-05 #i111172#
1420                 // If text node is already inside a list, assure that the indents
1421                 // are the same. Thus, adjust the indent change value by subtracting
1422                 // indents of to be applied list style.
1423                 SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs;
1424                 if ( pTxtNode->GetNumRule() )
1425                 {
1426                     const SwNumFmt aFmt( aNumRule.Get( 0 ) );
1427                     if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1428                     {
1429                         nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent();
1430                     }
1431                 }
1432                 // <--
1433                 aNumRule.ChangeIndent( nIndentChange );
1434             }
1435         }
1436         // <--
1437         // --> OD 2008-02-08 #newlistlevelattrs#
1438         // reset indent attribute on applying list style
1439         // --> OD 2008-03-17 #refactorlists#
1440         // start new list
1441         SetCurNumRule( aNumRule, true, String(), true );
1442         // <--
1443     }
1444 
1445     EndUndo(UNDO_NUMORNONUM);
1446 }
1447 // <- #i40041#
1448 
1449 void SwWrtShell::NumOn()
1450 {
1451     NumOrBulletOn(sal_True);
1452 }
1453 
1454 void SwWrtShell::NumOrBulletOff()
1455 {
1456     const SwNumRule * pCurNumRule = GetCurNumRule();
1457 
1458     if (pCurNumRule)
1459     {
1460         if (pCurNumRule->IsOutlineRule())
1461         {
1462             SwNumRule aNumRule(*pCurNumRule);
1463 
1464             SwTxtNode * pTxtNode =
1465                 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1466 
1467             if (pTxtNode)
1468             {
1469                 sal_uInt16 nLevel = sal::static_int_cast<sal_uInt16, sal_Int32>(pTxtNode->GetActualListLevel());
1470                 SwNumFmt aFmt(aNumRule.Get(nLevel));
1471 
1472                 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
1473                 aNumRule.Set(nLevel, aFmt);
1474 
1475                 // --> OD 2008-03-17 #refactorlists#
1476                 // no start or continuation of a list - the outline style is only changed.
1477                 SetCurNumRule( aNumRule, false );
1478                 // <--
1479             }
1480         }
1481         else
1482         {
1483             DelNumRules();
1484         }
1485 
1486         // --> OD 2005-10-24 #126346# - Cursor can not be anymore in front of
1487         // a label, because numbering/bullet is switched off.
1488         SetInFrontOfLabel( sal_False );
1489         // <--
1490     }
1491 }
1492 // <- #i29560#
1493 
1494 /*------------------------------------------------------------------------
1495  Beschreibung:	Default-Bulletliste erfragen
1496 ------------------------------------------------------------------------*/
1497 
1498 void SwWrtShell::BulletOn()
1499 {
1500     NumOrBulletOn(sal_False);
1501 }
1502 
1503 
1504 /*--------------------------------------------------
1505 
1506 --------------------------------------------------*/
1507 SelectionType SwWrtShell::GetSelectionType() const
1508 {
1509 	// ContentType kann nicht ermittelt werden innerhalb einer
1510 	// Start-/Endactionklammerung.
1511 	// Da es keinen ungueltigen Wert gibt, wird TEXT geliefert.
1512 	// Der Wert ist egal, da in EndAction ohnehin aktualisiert wird.
1513 
1514 	if ( BasicActionPend() )
1515         return IsSelFrmMode() ? nsSelectionType::SEL_FRM : nsSelectionType::SEL_TXT;
1516 
1517 //	if ( IsTableMode() )
1518 //      return nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS;
1519 
1520 	SwView &_rView = ((SwView&)GetView());
1521     if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() )
1522 		return nsSelectionType::SEL_POSTIT;
1523  	int nCnt;
1524 
1525 	// Rahmen einfuegen ist kein DrawMode
1526     if ( !_rView.GetEditWin().IsFrmAction() &&
1527             (IsObjSelected() || (_rView.IsDrawMode() && !IsFrmSelected()) ))
1528 	{
1529 		if (GetDrawView()->IsTextEdit())
1530             nCnt = nsSelectionType::SEL_DRW_TXT;
1531 		else
1532 		{
1533 			if (GetView().IsFormMode())	// Nur Forms selektiert
1534                 nCnt = nsSelectionType::SEL_DRW_FORM;
1535 			else
1536                 nCnt = nsSelectionType::SEL_DRW;            // Irgendein Draw-Objekt
1537 
1538             if (_rView.IsBezierEditMode())
1539                 nCnt |= nsSelectionType::SEL_BEZ;
1540 			else if( GetDrawView()->GetContext() == SDRCONTEXT_MEDIA )
1541                 nCnt |= nsSelectionType::SEL_MEDIA;
1542 
1543             if (svx::checkForSelectedCustomShapes(
1544                     const_cast<SdrView *>(GetDrawView()),
1545                     true /* bOnlyExtruded */ ))
1546             {
1547                 nCnt |= nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE;
1548             }
1549             sal_uInt32 nCheckStatus = 0;
1550             if (svx::checkForSelectedFontWork(
1551                     const_cast<SdrView *>(GetDrawView()), nCheckStatus ))
1552             {
1553                 nCnt |= nsSelectionType::SEL_FONTWORK;
1554             }
1555 		}
1556 
1557 		return nCnt;
1558 	}
1559 
1560 	nCnt = GetCntType();
1561 
1562 	if ( IsFrmSelected() )
1563 	{
1564         if (_rView.IsDrawMode())
1565             _rView.LeaveDrawCreate();   // Aufraeumen (Bug #45639)
1566 		if ( !(nCnt & (CNT_GRF | CNT_OLE)) )
1567             return nsSelectionType::SEL_FRM;
1568 	}
1569 
1570 	if ( IsCrsrInTbl() )
1571         nCnt |= nsSelectionType::SEL_TBL;
1572 
1573 	if ( IsTableMode() )
1574         nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS);
1575 
1576     // --> FME 2005-01-12 #i39855#
1577     // Do not pop up numbering toolbar, if the text node has a numbering
1578     // of type SVX_NUM_NUMBER_NONE.
1579     const SwNumRule* pNumRule = GetCurNumRule();
1580     if ( pNumRule )
1581     {
1582         const SwTxtNode* pTxtNd =
1583             GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1584 
1585         // --> OD 2008-03-19 #refactorlists#
1586         if ( pTxtNd && pTxtNd->IsInList() )
1587         // <--
1588         {
1589             const SwNumFmt& rFmt = pNumRule->Get(sal::static_int_cast< sal_uInt8, sal_Int32>(pTxtNd->GetActualListLevel()));
1590             if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
1591                 nCnt |= nsSelectionType::SEL_NUM;
1592         }
1593     }
1594     // <--
1595 
1596 	return nCnt;
1597 }
1598 
1599 /*------------------------------------------------------------------------
1600  Beschreibung:	Finden der TextCollection mit dem Name rCollname
1601  Return:				Pointer auf die Collection oder 0, wenn keine
1602 								TextCollection mit diesem Namen existiert oder
1603 								diese eine Defaultvorlage ist.
1604 ------------------------------------------------------------------------*/
1605 
1606 
1607 SwTxtFmtColl *SwWrtShell::GetParaStyle(const String &rCollName, GetStyle eCreate )
1608 {
1609 	SwTxtFmtColl* pColl = FindTxtFmtCollByName( rCollName );
1610 	if( !pColl && GETSTYLE_NOCREATE != eCreate )
1611 	{
1612 		sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1613 		if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
1614 			pColl = GetTxtCollFromPool( nId );
1615 	}
1616 	return pColl;
1617 }
1618 /*------------------------------------------------------------------------
1619  Beschreibung:	Finden der Zeichenvorlage mit dem Name rCollname
1620  Return:				Pointer auf die Collection oder 0, wenn keine
1621 								Zeichenvorlage mit diesem Namen existiert oder
1622 								diese eine Defaultvorlage oder automatische Vorlage ist.
1623 ------------------------------------------------------------------------*/
1624 
1625 
1626 
1627 SwCharFmt *SwWrtShell::GetCharStyle(const String &rFmtName, GetStyle eCreate )
1628 {
1629 	SwCharFmt* pFmt = FindCharFmtByName( rFmtName );
1630 	if( !pFmt && GETSTYLE_NOCREATE != eCreate )
1631 	{
1632 		sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1633 		if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
1634 			pFmt = (SwCharFmt*)GetFmtFromPool( nId );
1635 	}
1636 	return pFmt;
1637 }
1638 
1639 /*------------------------------------------------------------------------
1640  Beschreibung:	Finden des Tabellenformates mit dem Name rFmtname
1641  Return:				Pointer auf das Format oder 0, wenn kein
1642 								Rahmenformat mit diesem Namen existiert oder
1643 								dieses eine Defaultformat oder automatisches Format ist.
1644 ------------------------------------------------------------------------*/
1645 
1646 
1647 
1648 SwFrmFmt *SwWrtShell::GetTblStyle(const String &rFmtName)
1649 {
1650 	SwFrmFmt *pFmt = 0;
1651 	for( sal_uInt16 i = GetTblFrmFmtCount(); i; )
1652 		if( !( pFmt = &GetTblFrmFmt( --i ) )->IsDefault() &&
1653 			pFmt->GetName() == rFmtName && IsUsed( *pFmt ) )
1654 			return pFmt;
1655 	return 0;
1656 }
1657 
1658 
1659 /*------------------------------------------------------------------------
1660  Beschreibung:	Anwenden der Vorlagen
1661 ------------------------------------------------------------------------*/
1662 
1663 
1664 
1665 void SwWrtShell::SetPageStyle(const String &rCollName)
1666 {
1667 	if( !SwCrsrShell::HasSelection() && !IsSelFrmMode() && !IsObjSelected() )
1668 	{
1669 		SwPageDesc* pDesc = FindPageDescByName( rCollName, sal_True );
1670 		if( pDesc )
1671 			ChgCurPageDesc( *pDesc );
1672 	}
1673 }
1674 
1675 /*------------------------------------------------------------------------
1676  Beschreibung:	Zugriff Vorlagen
1677 ------------------------------------------------------------------------*/
1678 
1679 
1680 
1681 String SwWrtShell::GetCurPageStyle( const sal_Bool bCalcFrm ) const
1682 {
1683 	return GetPageDesc(GetCurPageDesc( bCalcFrm )).GetName();
1684 }
1685 
1686 /*------------------------------------------------------------------------
1687  Beschreibung:	Aktuelle Vorlage anhand der geltenden Attribute aendern
1688 ------------------------------------------------------------------------*/
1689 
1690 
1691 void SwWrtShell::QuickUpdateStyle()
1692 {
1693 	SwTxtFmtColl *pColl = GetCurTxtFmtColl();
1694 
1695 	// Standard kann nicht geaendert werden
1696 	if(pColl && !pColl->IsDefault())
1697 	{
1698 		FillByEx(pColl);
1699 			// Vorlage auch anwenden, um harte Attributierung
1700 			// zu entfernen
1701 		SetTxtFmtColl(pColl);
1702 	}
1703 }
1704 
1705 
1706 void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet)
1707 {
1708 	SfxItemSet aCoreSet( GetAttrPool(),
1709 			RES_CHRATR_BEGIN, 			RES_CHRATR_END - 1,
1710 			RES_PARATR_BEGIN, 			RES_PARATR_END - 1,
1711 			RES_FRMATR_BEGIN, 			RES_FRMATR_END - 1,
1712 			SID_ATTR_TABSTOP_POS, 		SID_ATTR_TABSTOP_POS,
1713 			SID_ATTR_TABSTOP_DEFAULTS, 	SID_ATTR_TABSTOP_DEFAULTS,
1714 			SID_ATTR_TABSTOP_OFFSET, 	SID_ATTR_TABSTOP_OFFSET,
1715 			SID_ATTR_BORDER_INNER,		SID_ATTR_BORDER_INNER,
1716 			SID_ATTR_PARA_MODEL,		SID_ATTR_PARA_KEEP,
1717 			SID_ATTR_PARA_PAGENUM,		SID_ATTR_PARA_PAGENUM,
1718 			0	);
1719     GetCurAttr( aCoreSet );
1720 	sal_Bool bReset = sal_False;
1721 	SfxItemIter aParaIter( aCoreSet );
1722 	const SfxPoolItem* pParaItem = aParaIter.FirstItem();
1723 	while( pParaItem )
1724 	{
1725 		if(!IsInvalidItem(pParaItem))
1726 		{
1727 			sal_uInt16 nWhich = pParaItem->Which();
1728 			if(SFX_ITEM_SET == aCoreSet.GetItemState(nWhich) &&
1729 			   SFX_ITEM_SET == rStyleSet.GetItemState(nWhich))
1730 			{
1731 				aCoreSet.ClearItem(nWhich);
1732 				bReset = sal_True;
1733 			}
1734 		}
1735 		pParaItem = aParaIter.NextItem();
1736 	}
1737 	StartAction();
1738 	if(bReset)
1739 	{
1740 		ResetAttr();
1741 		SetAttr(aCoreSet);
1742 	}
1743 	pDoc->ChgFmt(*pColl, rStyleSet );
1744 	EndAction();
1745 }
1746 
1747 /*-----------------12.03.97 12.24-------------------
1748 
1749 --------------------------------------------------*/
1750 
1751 void SwWrtShell::AutoUpdateFrame( SwFrmFmt* pFmt, const SfxItemSet& rStyleSet )
1752 {
1753 	StartAction();
1754 
1755 	ResetFlyFrmAttr( 0, &rStyleSet );
1756     pFmt->SetFmtAttr( rStyleSet );
1757 
1758 	EndAction();
1759 }
1760 
1761 
1762 void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar )
1763 {
1764 	ResetCursorStack();
1765 	if(_CanInsert())
1766 	{
1767 		sal_Bool bStarted = sal_False;
1768 		if(HasSelection())
1769 		{
1770 				// nur hier klammern, da das normale Insert schon an der
1771 				// Editshell geklammert ist
1772 			StartAllAction();
1773 			StartUndo(UNDO_INSERT);
1774 			bStarted = sal_True;
1775 			DelRight();
1776 		}
1777 		SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );
1778 
1779 		if(bStarted)
1780 		{
1781 			EndAllAction();
1782 			EndUndo(UNDO_INSERT);
1783 		}
1784 	}
1785 }
1786 
1787 
1788 /*
1789  * eine Art kontrollierter copy ctor
1790  */
1791 
1792 SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell )
1793     : SwFEShell( rSh, _pWin ),
1794 	 COMMON_INI_LIST
1795 {
1796 	BITFLD_INI_LIST
1797 	SET_CURR_SHELL( this );
1798 
1799 	SetSfxViewShell( (SfxViewShell *)&rShell );
1800 	SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
1801 
1802 	// place the cursor on the first field...
1803 	IFieldmark *pBM = NULL;
1804 	if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) {
1805 	    GotoFieldmark(pBM);
1806 	}
1807 }
1808 
1809 
1810 SwWrtShell::SwWrtShell( SwDoc& rDoc, Window *_pWin, SwView &rShell,
1811                         const SwViewOption *pViewOpt )
1812     : SwFEShell( rDoc, _pWin, pViewOpt),
1813 	  COMMON_INI_LIST
1814 {
1815 	BITFLD_INI_LIST
1816 	SET_CURR_SHELL( this );
1817 	SetSfxViewShell( (SfxViewShell *)&rShell );
1818 	SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
1819 }
1820 
1821 /*
1822  * ctor
1823  */
1824 
1825 
1826 
1827 SwWrtShell::~SwWrtShell()
1828 {
1829 	SET_CURR_SHELL( this );
1830 	while(IsModePushed())
1831 		PopMode();
1832 	while(PopCrsr(sal_False))
1833 		;
1834 	SwTransferable::ClearSelection( *this );
1835 }
1836 
1837 sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr )
1838 {
1839 	sal_Bool bRet = SwCrsrShell::Pop( bOldCrsr );
1840 	if( bRet && IsSelection() )
1841 	{
1842 		fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
1843 		fnKillSel = &SwWrtShell::ResetSelect;
1844 	}
1845 	return bRet;
1846 }
1847 
1848 /*--------------------------------------------------------------------
1849 	Beschreibung:
1850  --------------------------------------------------------------------*/
1851 sal_Bool SwWrtShell::CanInsert()
1852 {
1853     return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL)));
1854 }
1855 
1856 // die Core erzeugt eine Selektion, das SttSelect muss gerufen werden
1857 void SwWrtShell::NewCoreSelection()
1858 {
1859 	SttSelect();
1860 }
1861 
1862 // --------------
1863 void SwWrtShell::ChgDBData(const SwDBData& aDBData)
1864 {
1865     SwEditShell::ChgDBData(aDBData);
1866     //notify the db-beamer if available
1867     GetView().NotifyDBChanged();
1868 }
1869 
1870 String SwWrtShell::GetSelDescr() const
1871 {
1872     String aResult;
1873 
1874     int nSelType = GetSelectionType();
1875     switch (nSelType)
1876     {
1877     case nsSelectionType::SEL_GRF:
1878         aResult = SW_RES(STR_GRAPHIC);
1879 
1880         break;
1881     case nsSelectionType::SEL_FRM:
1882         {
1883             const SwFrmFmt * pFrmFmt = GetCurFrmFmt();
1884 
1885             if (pFrmFmt)
1886                 aResult = pFrmFmt->GetDescription();
1887         }
1888         break;
1889     case nsSelectionType::SEL_DRW:
1890         {
1891             aResult = SW_RES(STR_DRAWING_OBJECTS);
1892         }
1893         break;
1894     default:
1895         if (0 != pDoc)
1896             aResult = GetCrsrDescr();
1897     }
1898 
1899     return aResult;
1900 }
1901 
1902 void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt )
1903 {
1904 	SwFEShell::ApplyViewOptions( rOpt );
1905     //#i115062# invalidate meta character slot
1906     GetView().GetViewFrame()->GetBindings().Invalidate( FN_VIEW_META_CHARS );
1907 }
1908 
1909 
1910