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