xref: /aoo42x/main/sw/source/ui/shells/textsh1.cxx (revision 23d8f725)
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/i18n/WordType.hpp>
28 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
29 
30 #include <comphelper/processfactory.hxx>
31 #include <svx/dialogs.hrc>
32 #include <hintids.hxx>
33 #include <cmdid.h>
34 #include <helpid.h>
35 
36 #include <i18npool/mslangid.hxx>
37 #include <svl/languageoptions.hxx>
38 #include <editeng/langitem.hxx>
39 #include <svtools/langtab.hxx>
40 #include <svl/slstitm.hxx>
41 #include <string.h>
42 #include <svl/stritem.hxx>
43 #include <svx/htmlmode.hxx>
44 #include <svl/whiter.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/objitem.hxx>
48 #include <vcl/msgbox.hxx>
49 #include <vcl/unohelp2.hxx>
50 #include <sfx2/request.hxx>
51 #include <svl/eitem.hxx>
52 #include <svl/macitem.hxx>
53 #include <editeng/lrspitem.hxx>
54 #include <editeng/ulspitem.hxx>
55 #include <editeng/colritem.hxx>
56 #include <editeng/tstpitem.hxx>
57 #include <editeng/brshitem.hxx>
58 #include <editeng/svxacorr.hxx>
59 #include <svl/cjkoptions.hxx>
60 #include <svl/ctloptions.hxx>
61 #include <IDocumentSettingAccess.hxx>
62 #include <charfmt.hxx>
63 #include <editeng/fontitem.hxx>
64 #include <svx/SmartTagItem.hxx>
65 #include <svx/dialmgr.hxx>
66 #include <fmtinfmt.hxx>
67 #include <swwait.hxx>
68 #include <wrtsh.hxx>
69 #include <wview.hxx>
70 #include <swmodule.hxx>
71 #include <viewopt.hxx>
72 #include <uitool.hxx>
73 #include <swevent.hxx>
74 #include <fmthdft.hxx>
75 #include <pagedesc.hxx>
76 #include <textsh.hxx>
77 #include <IMark.hxx>
78 #include <swdtflvr.hxx>
79 #include <docstat.hxx>
80 #include <outline.hxx>
81 #include <tablemgr.hxx>
82 #include <swundo.hxx>		// fuer Undo-IDs
83 #include <reffld.hxx>
84 #include <docsh.hxx>
85 #include <mdiexp.hxx>
86 #include <inputwin.hxx>
87 #include <pardlg.hxx>
88 #include <frmatr.hxx>
89 #include <fmtcol.hxx>
90 #include <cellatr.hxx>
91 #include <edtwin.hxx>
92 #include <redlndlg.hxx>
93 #include "fldmgr.hxx"
94 
95 #include <globals.hrc>
96 #include <shells.hrc>
97 #include <app.hrc>
98 #include <web.hrc>
99 #include "paratr.hxx"
100 #include <crsskip.hxx>
101 #include <docstat.hxx>
102 #include <vcl/svapp.hxx>
103 #include <sfx2/app.hxx>
104 #include <breakit.hxx>
105 
106 #include <SwSmartTagMgr.hxx>
107 
108 #include <editeng/acorrcfg.hxx>
109 #include "swabstdlg.hxx"
110 #include "misc.hrc"
111 #include "chrdlg.hrc"
112 #include <IDocumentStatistics.hxx>
113 
114 #include <sfx2/sfxdlg.hxx>
115 #include <svl/languageoptions.hxx>
116 #include <unotools/lingucfg.hxx>
117 #include <com/sun/star/beans/XPropertySet.hpp>
118 #include <com/sun/star/util/XChangesBatch.hpp>
119 #include <com/sun/star/uno/Any.hxx>
120 #include <editeng/unolingu.hxx>
121 #include <unotools/syslocaleoptions.hxx>
122 #include <doc.hxx>
123 #include <view.hxx>
124 #include <ndtxt.hxx>
125 #include <pam.hxx>
126 #include <sfx2/objface.hxx>
127 #include <langhelper.hxx>
128 
129 #ifndef _NBDTMGFACT_HXX
130 #include <svx/nbdtmgfact.hxx>
131 #endif
132 #ifndef _NBDTMG_HXX
133 #include <svx/nbdtmg.hxx>
134 #endif
135 
136 
137 #include <numrule.hxx>
138 
139 
140 using namespace ::com::sun::star;
141 using namespace svx::sidebar;
142 
143 
144 void lcl_CharDialog( SwWrtShell &rWrtSh, sal_Bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
145 {
146 	FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rWrtSh.GetView()));
147 	SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
148 	SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(),
149 						RES_CHRATR_BEGIN,      RES_CHRATR_END-1,
150 						RES_TXTATR_INETFMT,    RES_TXTATR_INETFMT,
151 						RES_BACKGROUND,        RES_BACKGROUND,
152 						FN_PARAM_SELECTION,    FN_PARAM_SELECTION,
153 						SID_HTML_MODE,         SID_HTML_MODE,
154 						SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,   SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
155 						0 );
156 	rWrtSh.GetCurAttr( aCoreSet );
157 	sal_Bool bSel = rWrtSh.HasSelection();
158 	sal_Bool bSelectionPut = sal_False;
159 	if(bSel || rWrtSh.IsInWord())
160 	{
161 		if(!bSel)
162 		{
163 			rWrtSh.StartAction();
164 			rWrtSh.Push();
165 			if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
166 				rWrtSh.SelWrd();
167 		}
168 		aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelTxt()));
169 		bSelectionPut = sal_True;
170 		if(!bSel)
171 		{
172 			rWrtSh.Pop(sal_False);
173 			rWrtSh.EndAction();
174 		}
175 	}
176 		aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
177 					rWrtSh.GetScalingOfSelectedText() ) );
178 	// Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in
179 	// ein RES_BACKGROUND verwandelt und wieder zurueck ...
180 	const SfxPoolItem *pTmpBrush;
181 	if( SFX_ITEM_SET == aCoreSet.GetItemState( RES_CHRATR_BACKGROUND, sal_True, &pTmpBrush ) )
182 	{
183 		SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
184 		aTmpBrush.SetWhich( RES_BACKGROUND );
185 		aCoreSet.Put( aTmpBrush );
186 	}
187 
188 	aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
189 	SfxAbstractTabDialog* pDlg = NULL;
190 	if ( bUseDialog && GetActiveView() )
191 	{
192 		SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
193 		DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
194 
195 		pDlg = pFact->CreateSwCharDlg( rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR );
196 		DBG_ASSERT(pDlg, "Dialogdiet fail!");
197 		if( FN_INSERT_HYPERLINK == nSlot )
198 			pDlg->SetCurPageId(TP_CHAR_URL);
199 	}
200 	if (nSlot == SID_CHAR_DLG_EFFECT)
201 	{
202 		pDlg->SetCurPageId(TP_CHAR_EXT);
203 	}
204 
205 	const SfxItemSet* pSet = NULL;
206 	if ( !bUseDialog )
207 		pSet = pArgs;
208 	else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
209 	{
210 		pSet = pDlg->GetOutputItemSet();
211 	}
212 
213 	if ( pSet)
214 	{
215 		SfxItemSet aTmpSet( *pSet );
216 		if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, sal_False, &pTmpBrush ) )
217 		{
218 			SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
219 			aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
220 			aTmpSet.Put( aTmpBrush );
221 		}
222 
223 		aTmpSet.ClearItem( RES_BACKGROUND );
224 
225 		const SfxPoolItem* pSelectionItem;
226 		sal_Bool bInsert = sal_False;
227 		xub_StrLen nInsert = 0;
228 
229 		// aus ungeklaerter Ursache ist das alte Item wieder im Set
230 		if( !bSelectionPut && SFX_ITEM_SET == aTmpSet.GetItemState(FN_PARAM_SELECTION, sal_False, &pSelectionItem) )
231 		{
232 			String sInsert = ((const SfxStringItem*)pSelectionItem)->GetValue();
233 			bInsert = sInsert.Len() != 0;
234 			if(bInsert)
235 			{
236 				nInsert = sInsert.Len();
237 				rWrtSh.StartAction();
238 				rWrtSh.Insert( sInsert );
239 				rWrtSh.SetMark();
240 				rWrtSh.ExtendSelection(sal_False, sInsert.Len());
241 				SfxRequest aReq( rWrtSh.GetView().GetViewFrame(), FN_INSERT_STRING );
242 				aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sInsert ) );
243 				aReq.Done();
244 				SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_LEFT );
245 				aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) );
246 				aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_True) );
247 				aReq1.Done();
248 			}
249 		}
250 		aTmpSet.ClearItem(FN_PARAM_SELECTION);
251 
252 		SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
253 		if(bSel && rWrtSh.IsSelFullPara() && pColl && pColl->IsAutoUpdateFmt())
254 		{
255 			rWrtSh.AutoUpdatePara(pColl, aTmpSet);
256 		}
257 		else
258 			rWrtSh.SetAttrSet( aTmpSet );
259 		if (pReq)
260 			pReq->Done(aTmpSet);
261 		if(bInsert)
262 		{
263 			SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_RIGHT );
264 			aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) );
265 			aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_False) );
266 			aReq1.Done();
267 			rWrtSh.SwapPam();
268 			rWrtSh.ClearMark();
269 			rWrtSh.DontExpandFmt();
270 			rWrtSh.EndAction();
271 		}
272 	}
273 
274 	delete pDlg;
275 }
276 
277 /*--------------------------------------------------------------------
278 	Beschreibung:
279  --------------------------------------------------------------------*/
280 
281 short lcl_AskRedlineMode(Window *pWin)
282 {
283 	MessBox aQBox( pWin, 0,
284 					String( SW_RES( STR_REDLINE_TITLE ) ),
285 					String( SW_RES( STR_REDLINE_MSG ) ) );
286 	aQBox.SetImage( QueryBox::GetStandardImage() );
287 	sal_uInt16 nBtnFlags = BUTTONDIALOG_DEFBUTTON |
288 						BUTTONDIALOG_OKBUTTON |
289 						BUTTONDIALOG_FOCUSBUTTON;
290 
291 	aQBox.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL)), RET_OK, nBtnFlags);
292 	aQBox.GetPushButton( RET_OK )->SetHelpId(HID_AUTOFORMAT_ACCEPT);
293 	aQBox.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL)), RET_CANCEL, BUTTONDIALOG_CANCELBUTTON);
294 	aQBox.GetPushButton( RET_CANCEL )->SetHelpId(HID_AUTOFORMAT_REJECT  );
295 	aQBox.AddButton(String(SW_RES(STR_REDLINE_EDIT)), 2, 0);
296 	aQBox.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG);
297 	aQBox.SetButtonHelpText( RET_OK, aEmptyStr );
298 
299 	return aQBox.Execute();
300 }
301 
302 void SwTextShell::Execute(SfxRequest &rReq)
303 {
304     sal_Bool bUseDialog = sal_True;
305     const SfxItemSet *pArgs = rReq.GetArgs();
306     SwWrtShell& rWrtSh = GetShell();
307     const SfxPoolItem* pItem = 0;
308     sal_uInt16 nSlot = rReq.GetSlot();
309     if(pArgs)
310         pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
311     switch( nSlot )
312     {
313         case SID_LANGUAGE_STATUS:
314         {
315             // get the language
316             String aNewLangTxt;
317             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False );
318             if (pItem2)
319                 aNewLangTxt = pItem2->GetValue();
320 
321             //!! Remember the view frame right now...
322             //!! (call to GetView().GetViewFrame() will break if the
323             //!! SwTextShell got destroyed meanwhile.)
324             SfxViewFrame *pViewFrame = GetView().GetViewFrame();
325 
326             if (aNewLangTxt.EqualsAscii( "*" ))
327             {
328                 // open the dialog "Tools/Options/Language Settings - Language"
329                 // to set the documents default language
330                 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
331                 if (pFact)
332                 {
333                     VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS );
334                     pDlg->Execute();
335                     delete pDlg;
336                 }
337             }
338             else
339             {
340                 //!! We have to use StartAction / EndAction bracketing in
341                 //!! order to prevent possible destruction of the SwTextShell
342                 //!! due to the selection changes coming below.
343                 rWrtSh.StartAction();
344                 // prevent view from jumping because of (temporary) selection changes
345                 rWrtSh.LockView( sal_True );
346 
347                 // save selection for later restoration
348                 rWrtSh.Push();
349 
350                 // setting the new language...
351                 if (aNewLangTxt.Len() > 0)
352                 {
353                     const String aSelectionLangPrefix( String::CreateFromAscii("Current_") );
354                     const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") );
355                     const String aDocumentLangPrefix( String::CreateFromAscii("Default_") );
356                     const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") );
357                     const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") );
358 
359                     SfxItemSet aCoreSet( GetPool(),
360                             RES_CHRATR_LANGUAGE,        RES_CHRATR_LANGUAGE,
361                             RES_CHRATR_CJK_LANGUAGE,    RES_CHRATR_CJK_LANGUAGE,
362                             RES_CHRATR_CTL_LANGUAGE,    RES_CHRATR_CTL_LANGUAGE,
363                             0 );
364 
365                     xub_StrLen nPos = 0;
366                     bool bForSelection = true;
367                     bool bForParagraph = false;
368                     if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 )))
369                     {
370                         // ... for the current selection
371                         aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() );
372                         bForSelection = true;
373                     }
374                     else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 )))
375                     {
376                         // ... for the current paragraph language
377                         aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() );
378                         bForSelection = true;
379                         bForParagraph = true;
380                     }
381                     else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 )))
382                     {
383                         // ... as default document language
384                         aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() );
385                         bForSelection = false;
386                     }
387 
388                     if (bForParagraph)
389                         SwLangHelper::SelectCurrentPara( rWrtSh );
390 
391                     if (!bForSelection) // document language to be changed...
392                     {
393                         rWrtSh.SelAll();
394                         rWrtSh.ExtendedSelectAll();
395                     }
396 
397                     rWrtSh.StartUndo( ( !bForParagraph && !bForSelection ) ? UNDO_SETDEFTATTR : UNDO_EMPTY );
398                     if (aNewLangTxt == aStrNone)
399                         SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet );
400                     else if (aNewLangTxt == aStrResetLangs)
401                         SwLangHelper::ResetLanguages( rWrtSh, bForSelection );
402                     else
403                         SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet );
404                     rWrtSh.EndUndo();
405 
406                 }
407 
408                 // restore selection...
409                 rWrtSh.Pop( sal_False );
410 
411                 rWrtSh.LockView( sal_False );
412                 rWrtSh.EndAction();
413             }
414 
415             // invalidate slot to get the new language displayed
416             pViewFrame->GetBindings().Invalidate( nSlot );
417 
418             rReq.Done();
419             break;
420         }
421 
422         case SID_THES:
423         {
424             // replace word/selection with text from selected sub menu entry
425             String aReplaceText;
426             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False );
427             if (pItem2)
428                 aReplaceText = pItem2->GetValue();
429             if (aReplaceText.Len() > 0)
430             {
431                 SwView &rView2 = rWrtSh.GetView();
432                 const bool bSelection = rWrtSh.HasSelection();
433                 const String aLookUpText = rView2.GetThesaurusLookUpText( bSelection );
434                 rView2.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection );
435             }
436         }
437         break;
438 
439 		case SID_CHARMAP:
440 		{
441             InsertSymbol( rReq );
442 		}
443 		break;
444 		case FN_INSERT_FOOTNOTE:
445 		case FN_INSERT_ENDNOTE:
446         {
447             String aStr;
448             SFX_REQUEST_ARG( rReq, pFont, SfxStringItem, FN_PARAM_1 , sal_False );
449 //            SFX_REQUEST_ARG( rReq, pCharset, SfxInt16Item, FN_PARAM_2 , sal_False );
450             SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, nSlot , sal_False );
451             if ( pNameItem )
452                 aStr = pNameItem->GetValue();
453             sal_Bool bFont = pFont && pFont->GetValue().Len();
454             rWrtSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE );
455             rWrtSh.InsertFootnote( aStr, nSlot == FN_INSERT_ENDNOTE, !bFont );
456             if ( bFont )
457             {
458                 rWrtSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False );
459                 SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
460                 rWrtSh.GetCurAttr( aSet );
461                 SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
462                 SvxFontItem aFont( rFont.GetFamily(), pFont->GetValue(),
463                                     rFont.GetStyleName(), rFont.GetPitch(), RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT );
464                                     //pCharset ? (CharSet) pCharset->GetValue() : RTL_TEXTENCODING_DONTKNOW );
465                 rWrtSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND );
466                 rWrtSh.ResetSelect(0, sal_False);
467                 rWrtSh.EndSelect();
468                 rWrtSh.GotoFtnTxt();
469             }
470             rWrtSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE );
471             rReq.Done();
472         }
473 		break;
474 		case FN_INSERT_FOOTNOTE_DLG:
475 		{
476 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
477             DBG_ASSERT(pFact, "Dialogdiet fail!");
478             AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE,
479 														GetView().GetWindow(), rWrtSh, sal_False );
480             DBG_ASSERT(pDlg, "Dialogdiet fail!");
481 			pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand());
482             if ( pDlg->Execute() == RET_OK )
483             {
484                 sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE;
485                 SfxRequest aReq( GetView().GetViewFrame(), nId );
486                 if ( pDlg->GetStr().Len() )
487                     aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) );
488                 if ( pDlg->GetFontName().Len() )
489                     aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) );
490                 //aReq.AppendItem( SfxStringItem( FN_PARAM_2, pDlg->GetCharSet() ) );
491                 ExecuteSlot( aReq );
492             }
493 
494             rReq.Ignore();
495             delete pDlg;
496 		}
497 		break;
498 		case FN_FORMAT_FOOTNOTE_DLG:
499 		{
500             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
501             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
502 
503             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rWrtSh, DLG_DOC_FOOTNOTE );
504             DBG_ASSERT(pDlg, "Dialogdiet fail!");
505 			pDlg->Execute();
506 			delete pDlg;
507 			break;
508 		}
509 		case SID_INSERTDOC:
510         {
511             GetView().ExecuteInsertDoc( rReq, pItem );
512 			break;
513         }
514 		case FN_FORMAT_RESET:
515 		{
516 			// #i78856, reset all attributes but not the language attributes
517 			// (for this build an array of all relevant attributes and
518 			// remove the languages from that)
519 			SvUShortsSort aAttribs;
520 
521             sal_uInt16 __FAR_DATA aResetableSetRange[] = {
522                 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
523                 RES_CHRATR_BEGIN, RES_CHRATR_LANGUAGE - 1,
524                 RES_CHRATR_LANGUAGE + 1, RES_CHRATR_CJK_LANGUAGE - 1,
525                 RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1,
526                 RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1,
527                 RES_PARATR_BEGIN, RES_PARATR_END-1,
528                 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
529                 RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
530                 RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
531                 RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
532                 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
533                 0
534             };
535             sal_uInt16 __FAR_DATA *pUShorts = aResetableSetRange;
536 			while (*pUShorts)
537 			{
538 				sal_uInt16 nL = pUShorts[1] - pUShorts[0] + 1;
539 				sal_uInt16 nE = pUShorts[0];
540 				for (sal_uInt16 i = 0; i < nL; ++i)
541 					aAttribs.Insert( nE++ );
542 				pUShorts += 2;
543 			}
544 
545 			rWrtSh.ResetAttr( &aAttribs );
546 			rReq.Done();
547 			break;
548 		}
549 		case FN_INSERT_BREAK_DLG:
550 		{
551             sal_uInt16 nKind=0, nPageNumber=0;
552             String aTemplateName;
553             if ( pItem )
554             {
555                 nKind = ((SfxInt16Item*)pItem)->GetValue();
556                 SFX_REQUEST_ARG( rReq, pTemplate, SfxStringItem, FN_PARAM_1 , sal_False );
557                 SFX_REQUEST_ARG( rReq, pNumber, SfxUInt16Item, FN_PARAM_2 , sal_False );
558                 if ( pTemplate )
559                     aTemplateName = pTemplate->GetValue();
560                 if ( pNumber )
561                     nPageNumber = pNumber->GetValue();
562             }
563             else
564             {
565                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
566                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
567 
568                 AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg( GetView().GetWindow(), rWrtSh, DLG_BREAK );
569                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
570                 if ( pDlg->Execute() == RET_OK )
571                 {
572                     nKind = pDlg->GetKind();
573                     aTemplateName = pDlg->GetTemplateName();
574                     nPageNumber = pDlg->GetPageNumber();
575                     rReq.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG, nKind ) );
576                     rReq.AppendItem( SfxUInt16Item( FN_PARAM_2, nPageNumber ) );
577                     rReq.AppendItem( SfxStringItem( FN_PARAM_1, aTemplateName ) );
578                     rReq.Done();
579                 }
580                 else
581                     rReq.Ignore();
582                 delete pDlg;
583             }
584 
585             switch ( nKind )
586             {
587                 case 1 :
588                     rWrtSh.InsertLineBreak(); break;
589                 case 2 :
590                     rWrtSh.InsertColumnBreak(); break;
591                 case 3 :
592                 {
593                     rWrtSh.StartAllAction();
594                     if( aTemplateName.Len() )
595                         rWrtSh.InsertPageBreak( &aTemplateName, nPageNumber );
596                     else
597                         rWrtSh.InsertPageBreak();
598                     rWrtSh.EndAllAction();
599                 }
600             }
601 
602 			break;
603 		}
604 		case FN_INSERT_BOOKMARK:
605 		{
606             if ( pItem )
607             {
608                 ::rtl::OUString sName = ((SfxStringItem*)pItem)->GetValue();
609                 rWrtSh.SetBookmark( KeyCode(), sName, aEmptyStr );
610             }
611             else
612             {
613                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
614                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
615 
616                 VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK );
617                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
618 				pDlg->Execute();
619                 delete pDlg;
620             }
621 
622             break;
623 		}
624         case FN_DELETE_BOOKMARK:
625         {
626             if ( pItem )
627             {
628                 IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess();
629                 pMarkAccess->deleteMark( pMarkAccess->findMark(((SfxStringItem*)pItem)->GetValue()) );
630             }
631             break;
632         }
633 		case FN_AUTOFORMAT_REDLINE_APPLY:
634 		{
635 			SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags());
636 			// das muss fuer die Nachbearbeitung immer sal_False sein
637 			aFlags.bAFmtByInput = sal_False;
638 			aFlags.bWithRedlining = sal_True;
639 			rWrtSh.AutoFormat( &aFlags );
640 			aFlags.bWithRedlining = sal_False;
641 
642 			SfxViewFrame* pVFrame = GetView().GetViewFrame();
643 			if (pVFrame->HasChildWindow(FN_REDLINE_ACCEPT))
644 				pVFrame->ToggleChildWindow(FN_REDLINE_ACCEPT);
645 
646             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
647             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
648 
649             AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg( &GetView().GetEditWin(), DLG_MOD_REDLINE_ACCEPT );
650             DBG_ASSERT(pDlg, "Dialogdiet fail!");
651 
652 			switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
653 			{
654 				case RET_OK:
655                 {
656                     pDlg->AcceptAll(sal_True);
657                     SfxRequest aReq( pVFrame, FN_AUTOFORMAT_APPLY );
658                     aReq.Done();
659                     rReq.Ignore();
660 					break;
661                 }
662 
663 				case RET_CANCEL:
664                     pDlg->AcceptAll(sal_False);
665                     rReq.Ignore();
666 					break;
667 
668 				case 2:
669                     pDlg->Execute();
670                     rReq.Done();
671 					break;
672 			}
673             delete pDlg;
674 		}
675 		break;
676 
677 		case FN_AUTOFORMAT_APPLY:
678 		{
679 			SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags());
680 			// das muss fuer die Nachbearbeitung immer sal_False sein
681 			aFlags.bAFmtByInput = sal_False;
682 			rWrtSh.AutoFormat( &aFlags );
683             rReq.Done();
684 		}
685 		break;
686 		case FN_AUTOFORMAT_AUTO:
687 		{
688 			SvxAutoCorrCfg*	pACfg = SvxAutoCorrCfg::Get();
689             sal_Bool bSet = pItem ? ((const SfxBoolItem*)pItem)->GetValue() : !pACfg->IsAutoFmtByInput();
690 			if( bSet != pACfg->IsAutoFmtByInput() )
691             {
692 				pACfg->SetAutoFmtByInput( bSet );
693                 GetView().GetViewFrame()->GetBindings().Invalidate( nSlot );
694                 if ( !pItem )
695                     rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), bSet ) );
696                 rReq.Done();
697             }
698 		}
699 		break;
700 		case FN_AUTO_CORRECT:
701 		{
702 			// erstmal auf Blank defaulten
703 			sal_Unicode cChar = ' ';
704 			rWrtSh.AutoCorrect( *SvxAutoCorrCfg::Get()->GetAutoCorrect(), cChar );
705 			rReq.Done();
706 		}
707 		break;
708         case FN_TABLE_SORT_DIALOG:
709 		case FN_SORTING_DLG:
710 		{
711             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
712             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
713 
714             VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING );
715             DBG_ASSERT(pDlg, "Dialogdiet fail!");
716 			pDlg->Execute();
717 			delete pDlg;
718 			rReq.Done();
719 		}
720 		break;
721 		case FN_NUMBERING_OUTLINE_DLG:
722 		{
723 			SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
724 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
725             DBG_ASSERT(pFact, "Dialogdiet fail!");
726             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
727 														GetView().GetWindow(), &aTmp, rWrtSh);
728             DBG_ASSERT(pDlg, "Dialogdiet fail!");
729 			pDlg->Execute();
730 			delete pDlg;
731 			rReq.Done();
732 		}
733 			break;
734 		case FN_CALCULATE:
735 			{
736 				SwTransferable* pTransfer = new SwTransferable( rWrtSh );
737 /*??*/          uno::Reference<
738                     datatransfer::XTransferable > xRef(
739 													pTransfer );
740 				pTransfer->CalculateAndCopy();
741 				rReq.Done();
742 			}
743 			break;
744 		case FN_GOTO_REFERENCE:
745 		{
746 			SwField *pFld = rWrtSh.GetCurFld();
747 			if(pFld && pFld->GetTypeId() == TYP_GETREFFLD)
748 			{
749 				rWrtSh.StartAllAction();
750 				rWrtSh.SwCrsrShell::GotoRefMark( ((SwGetRefField*)pFld)->GetSetRefName(),
751 									((SwGetRefField*)pFld)->GetSubType(),
752 									((SwGetRefField*)pFld)->GetSeqNo() );
753 				rWrtSh.EndAllAction();
754 				rReq.Done();
755 			}
756 		}
757 			break;
758 		case FN_EDIT_FORMULA:
759 		{
760             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
761             SfxViewFrame* pVFrame = GetView().GetViewFrame();
762             if(pItem)
763             {
764                 //if the ChildWindow is active it has to be removed
765                 if( pVFrame->HasChildWindow( nId ) )
766                 {
767                     pVFrame->ToggleChildWindow( nId );
768                     pVFrame->GetBindings().InvalidateAll( sal_True );
769                 }
770 
771                 String sFormula(((const SfxStringItem*)pItem)->GetValue());
772                 SwFldMgr aFldMgr;
773                 rWrtSh.StartAllAction();
774                 sal_Bool bDelSel;
775                 if( 0 != (bDelSel = rWrtSh.HasSelection()) )
776                 {
777                     rWrtSh.StartUndo( UNDO_START );
778                     rWrtSh.DelRight();
779                 }
780                 else
781                 {
782                     rWrtSh.EnterStdMode();
783                 }
784 
785                 if( !bDelSel && aFldMgr.GetCurFld() && TYP_FORMELFLD == aFldMgr.GetCurTypeId() )
786                     aFldMgr.UpdateCurFld( aFldMgr.GetCurFld()->GetFormat(), aEmptyStr, sFormula );
787                 else if( sFormula.Len() )
788                 {
789                     if( rWrtSh.IsCrsrInTbl() )
790                     {
791                         SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
792                         aSet.Put( SwTblBoxFormula( sFormula ));
793                         rWrtSh.SetTblBoxFormulaAttrs( aSet );
794                         rWrtSh.UpdateTable();
795                     }
796                     else
797                     {
798                         SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter();
799                         sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM);
800                         SwInsertFld_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, aEmptyStr, sFormula, nSysNumFmt);
801                         aFldMgr.InsertFld(aData);
802                     }
803                 }
804 
805                 if( bDelSel )
806                     rWrtSh.EndUndo( UNDO_END );
807                 rWrtSh.EndAllAction();
808                 rReq.Done();
809             }
810             else
811             {
812                 rWrtSh.EndAllTblBoxEdit();
813                 pVFrame->ToggleChildWindow( nId );
814                 if( !pVFrame->HasChildWindow( nId ) )
815                     pVFrame->GetBindings().InvalidateAll( sal_True );
816                 rReq.Ignore();
817             }
818 		}
819 
820 		break;
821 		case FN_TABLE_UNSET_READ_ONLY:
822 		{
823 			rWrtSh.UnProtectTbls();
824 		}
825 		break;
826 		case FN_EDIT_HYPERLINK:
827 			GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG);
828 		break;
829         case FN_REMOVE_HYPERLINK:
830         {
831             sal_Bool bSel = rWrtSh.HasSelection();
832             if(!bSel)
833             {
834                 rWrtSh.StartAction();
835                 rWrtSh.Push();
836                 if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
837                     rWrtSh.SelWrd();
838             }
839             //now remove the attribute
840             SvUShortsSort aAttribs;
841             aAttribs.Insert( RES_TXTATR_INETFMT );
842             rWrtSh.ResetAttr( &aAttribs );
843             if(!bSel)
844             {
845                 rWrtSh.Pop(sal_False);
846                 rWrtSh.EndAction();
847             }
848         }
849         break;
850         case SID_ATTR_BRUSH_CHAR :
851         case SID_ATTR_CHAR_SCALEWIDTH :
852         case SID_ATTR_CHAR_ROTATED :
853         case FN_TXTATR_INET :
854 		case FN_INSERT_HYPERLINK:
855         {
856             sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
857             if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
858                 bUseDialog = sal_False;
859             // intentionally no break
860         }
861 		case SID_CHAR_DLG:
862 		case SID_CHAR_DLG_EFFECT:
863 		{
864             lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
865 		}
866         break;
867         case SID_CHAR_DLG_FOR_PARAGRAPH:
868         {
869 			rWrtSh.Push();			//save current cursor
870             SwLangHelper::SelectCurrentPara( rWrtSh );
871             lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
872 			rWrtSh.Pop( sal_False );	//restore old cursor
873         }
874 		break;
875         case SID_ATTR_LRSPACE :
876 		case SID_ATTR_ULSPACE :
877         case SID_ATTR_BRUSH :
878 		case SID_PARA_VERTALIGN :
879         case SID_ATTR_PARA_NUMRULE :
880 		case SID_ATTR_PARA_REGISTER :
881         case SID_ATTR_PARA_PAGENUM :
882         case FN_FORMAT_LINENUMBER :
883         case FN_NUMBER_NEWSTART :
884         case FN_NUMBER_NEWSTART_AT :
885         case FN_FORMAT_DROPCAPS :
886         case FN_DROP_TEXT:
887         case SID_ATTR_PARA_LRSPACE:
888         {
889             sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
890             if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
891                 bUseDialog = sal_False;
892             // intentionally no break
893 
894         }
895 		case SID_PARA_DLG:
896 		{
897             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
898             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
899             SfxItemSet aCoreSet( GetPool(),
900                             RES_PARATR_BEGIN,           RES_PARATR_END - 1,
901                             // --> OD 2008-02-25 #refactorlists#
902                             RES_PARATR_LIST_BEGIN,      RES_PARATR_LIST_END - 1,
903                             // <--
904                             RES_FRMATR_BEGIN,           RES_FRMATR_END - 1,
905                             SID_ATTR_TABSTOP_POS,       SID_ATTR_TABSTOP_POS,
906                             SID_ATTR_TABSTOP_DEFAULTS,  SID_ATTR_TABSTOP_DEFAULTS,
907                             SID_ATTR_TABSTOP_OFFSET,    SID_ATTR_TABSTOP_OFFSET,
908                             SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_INNER,
909                             SID_ATTR_PARA_MODEL,        SID_ATTR_PARA_KEEP,
910                             SID_ATTR_PARA_PAGENUM,      SID_ATTR_PARA_PAGENUM,
911                             SID_HTML_MODE,              SID_HTML_MODE,
912                             FN_PARAM_1,                 FN_PARAM_1,
913                             FN_NUMBER_NEWSTART,         FN_NUMBER_NEWSTART_AT,
914                             FN_DROP_TEXT,               FN_DROP_CHAR_STYLE_NAME,
915                             0);
916             // --> OD 2008-01-16 #newlistlevelattrs#
917             // get also the list level indent values merged as LR-SPACE item, if needed.
918             rWrtSh.GetCurAttr( aCoreSet, true );
919             // <--
920             aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE,
921                             ::GetHtmlMode(GetView().GetDocShell())));
922 
923             // Tabulatoren, DefaultTabs ins ItemSet Stecken
924             const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
925                             GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
926 
927             sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
928             SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
929             aCoreSet.Put( aDefDistItem );
930 
931             // Aktueller Tab
932             SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
933             aCoreSet.Put( aTabPos );
934 
935             // linker Rand als Offset
936             //#i24363# tab stops relative to indent
937             const long nOff = rWrtSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) ?
938                 ((SvxLRSpaceItem&)aCoreSet.Get( RES_LR_SPACE )).GetTxtLeft() : 0;
939             SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
940             aCoreSet.Put( aOff );
941 
942             // BoxInfo setzen
943             ::PrepareBoxInfo( aCoreSet, rWrtSh );
944 
945             //aktuelles Seitenformat
946             ::SwToSfxPageDescAttr( aCoreSet );
947 
948             sal_uInt16 nDefPage = 0;
949             if( pItem )
950                 nDefPage = ((SfxUInt16Item *)pItem)->GetValue();
951 
952             // Numerierungseigenschaften
953             if(rWrtSh.GetCurNumRule())
954             {
955                 SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart() );
956                 aCoreSet.Put(aStart);
957                 // --> OD 2008-02-29 #refactorlists#
958 //                SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT,
959 //                                                rWrtSh.IsNodeNumStart());
960                 SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT,
961                                         rWrtSh.GetNodeNumStart() );
962                 // <--
963                 aCoreSet.Put(aStartAt);
964             }
965             SfxAbstractTabDialog* pDlg = NULL;
966 
967             if ( bUseDialog && GetActiveView() )
968 			{
969                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
970                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
971 
972                 pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet,DLG_STD, DLG_PARA,NULL, sal_False, nDefPage );
973                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
974 			}
975             SfxItemSet* pSet = NULL;
976             if ( !bUseDialog )
977             {
978                 if ( nSlot == SID_ATTR_PARA_LRSPACE)
979 		{
980 			SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pArgs->Get(nSlot));
981 			aParaMargin.SetWhich( RES_LR_SPACE);
982 			aCoreSet.Put(aParaMargin);
983 			pSet = &aCoreSet;
984 
985 		} else
986                     pSet = (SfxItemSet*) pArgs;
987 
988             }
989             else if ( NULL != pDlg && pDlg->Execute() == RET_OK )
990             {
991                 // Defaults evtl umsetzen
992                 pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
993                 sal_uInt16 nNewDist;
994                 if( SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, sal_False, &pItem ) &&
995                     nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) )
996                 {
997                     SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
998                     MakeDefTabs( nNewDist, aDefTabs );
999                     rWrtSh.SetDefault( aDefTabs );
1000                     pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
1001                 }
1002 
1003                 if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_1,sal_False,&pItem) )
1004                 {
1005                     pSet->Put(SfxStringItem(FN_DROP_TEXT, ((const SfxStringItem*)pItem)->GetValue()));
1006                     pSet->ClearItem(FN_PARAM_1);
1007                 }
1008 
1009                 if( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_DROP, sal_False, &pItem ))
1010                 {
1011                     String sCharStyleName;
1012                     if(((const SwFmtDrop*)pItem)->GetCharFmt())
1013                         sCharStyleName = ((const SwFmtDrop*)pItem)->GetCharFmt()->GetName();
1014                     pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
1015                 }
1016             }
1017 
1018             if ( pSet )
1019             {
1020                 rReq.Done( *pSet );
1021                 ::SfxToSwPageDescAttr( rWrtSh, *pSet );
1022                 // --> OD 2006-12-06 #i56253#
1023                 // enclose all undos.
1024                 // Thus, check conditions, if actions will be performed.
1025                 const bool bUndoNeeded( pSet->Count() ||
1026                         SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ||
1027                         SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) );
1028                 if ( bUndoNeeded )
1029                 {
1030                     rWrtSh.StartUndo( UNDO_INSATTR );
1031                 }
1032                 // <--
1033                 if( pSet->Count() )
1034                 {
1035                     rWrtSh.StartAction();
1036 //                    rWrtSh.StartUndo( UNDO_START );
1037                     if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, sal_False, &pItem) )
1038                     {
1039                         if ( ((SfxStringItem*)pItem)->GetValue().Len() )
1040                             rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
1041                     }
1042                     rWrtSh.SetAttrSet( *pSet );
1043 //                    rWrtSh.EndUndo( UNDO_END );
1044                     rWrtSh.EndAction();
1045                     SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
1046                     if(pColl && pColl->IsAutoUpdateFmt())
1047                     {
1048                         rWrtSh.AutoUpdatePara(pColl, *pSet);
1049                     }
1050                 }
1051 
1052                 if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) )
1053                 {
1054                     //SetNumRuleStart(sal_True) restarts the numbering at the value
1055                     //that is defined at the starting point of the numbering level
1056                     //otherwise the SetNodeNumStart() value determines the start
1057                     //if it's set to something different than (sal_uInt16)0xFFFF
1058 
1059                     sal_Bool bStart = ((SfxBoolItem&)pSet->Get(FN_NUMBER_NEWSTART)).GetValue();
1060                     // --> OD 2007-06-11 #b6560525#
1061                     // Default value for restart value has to be (sal_uInt16)0xFFFF
1062                     // in order to indicate that the restart value of the list
1063                     // style has to be used on restart.
1064                     sal_uInt16 nNumStart = (sal_uInt16)0xFFFF;
1065                     // <--
1066 					if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
1067                     {
1068                         nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
1069                     }
1070                     rWrtSh.SetNumRuleStart(bStart);
1071                     rWrtSh.SetNodeNumStart(nNumStart);
1072                 }
1073                 else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
1074                 {
1075                     sal_uInt16 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
1076                     rWrtSh.SetNodeNumStart(nNumStart);
1077                     rWrtSh.SetNumRuleStart(sal_False);
1078                 }
1079                 // --> OD 2006-12-06 #i56253#
1080                 if ( bUndoNeeded )
1081                 {
1082                     rWrtSh.EndUndo( UNDO_INSATTR );
1083                 }
1084                 // <--
1085             }
1086 
1087             delete pDlg;
1088 		}
1089 		break;
1090         case FN_NUM_CONTINUE:
1091         {
1092             // --> OD 2008-03-18 #refactorlists#
1093             String sContinuedListId;
1094             const SwNumRule* pRule =
1095                 rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId );
1096             // --> OD 2009-08-26 #i86492#
1097             // Search also for bullet list
1098             if ( !pRule )
1099             {
1100                 pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId );
1101             }
1102             // <--
1103             if ( pRule )
1104             {
1105                 rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId );
1106             }
1107             // <--
1108         }
1109         break;
1110 		case FN_SELECT_PARA:
1111 		{
1112 			if(!rWrtSh.IsSttOfPara())
1113 				rWrtSh.SttPara(sal_False);
1114 			else
1115 				rWrtSh.EnterStdMode();
1116 			rWrtSh.EndPara(sal_True);
1117 		}
1118 		break;
1119 
1120 		case SID_DEC_INDENT:
1121 		case SID_INC_INDENT:
1122 			//According to the requirement, modified the behavior when user
1123 			//using the indent button on the toolbar. Now if we increase/decrease indent for a
1124 			//paragraph which has bullet style it will increase/decrease the bullet level.
1125 			{
1126 				//If the current paragraph has bullet call the function to
1127 				//increase or decrease the bullet level.
1128 				//Why could I know wheter a paragraph has bullet or not by checking the below conditions?
1129 				//Please refer to the "case KEY_TAB:" section in SwEditWin::KeyInput(..) :
1130 				//		if( rSh.GetCurNumRule() && rSh.IsSttOfPara() &&
1131 				//					!rSh.HasReadonlySel() )
1132 				//				eKeyState = KS_NumDown;
1133 				//Above code demonstrates that when the cursor is at the start of a paragraph which has bullet,
1134 				//press TAB will increase the bullet level.
1135 				//So I copied from that ^^
1136 				if ( rWrtSh.GetCurNumRule() && !rWrtSh.HasReadonlySel() )
1137 				{
1138 					rWrtSh.NumUpDown( SID_INC_INDENT == nSlot );
1139 				}
1140 				else//execute the original processing functions
1141 				{
1142 					//below is copied of the old codes
1143 			rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot,
1144 									rReq.GetModifier() != KEY_MOD1 );
1145 				}
1146 			}
1147 			//rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot,
1148 			//						rReq.GetModifier() != KEY_MOD1 );
1149 			rReq.Done();
1150 			break;
1151 		case FN_DEC_INDENT_OFFSET:
1152 		case FN_INC_INDENT_OFFSET:
1153 			rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot,
1154 									rReq.GetModifier() == KEY_MOD1 );
1155 			rReq.Done();
1156 			break;
1157 
1158 		case SID_ATTR_CHAR_COLOR2:
1159 		{
1160 			if(pItem)
1161 			{
1162 				Color aSet = ((const SvxColorItem*)pItem)->GetValue();
1163                 SwEditWin& rEditWin = GetView().GetEditWin();
1164 				rEditWin.SetTextColor(aSet);
1165 				SwApplyTemplate* pApply = rEditWin.GetApplyTemplate();
1166 				SvxColorItem aItem(aSet, RES_CHRATR_COLOR);
1167 
1168 				// besteht eine Selektion, wird sie gleich gefaerbt
1169 				if(!pApply && rWrtSh.HasSelection())
1170 				{
1171                     rWrtSh.SetAttrItem(SvxColorItem (aSet, RES_CHRATR_COLOR));
1172 				}
1173 				else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT)
1174 				{
1175                     GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_EXT);
1176 				}
1177 
1178                 rReq.Done();
1179 			}
1180 		}
1181 		break;
1182 		case SID_ATTR_CHAR_COLOR_BACKGROUND:
1183 		{
1184             SwEditWin& rEdtWin = GetView().GetEditWin();
1185 			SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
1186 			rEdtWin.SetTextBackColorTransparent(0 == pItem);
1187 			Color aSet;
1188 			if(pItem)
1189 			{
1190 				aSet = ((const SvxColorItem*)pItem)->GetValue();
1191 				rEdtWin.SetTextBackColor(aSet);
1192 			}
1193 			if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI()))
1194 			{
1195 				SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND);
1196 				if(pItem)
1197 					aBrushItem.SetColor(aSet);
1198 				else
1199 					aBrushItem.SetColor(Color(COL_TRANSPARENT));
1200 				rWrtSh.SetAttrItem( aBrushItem );
1201 			}
1202 			else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
1203 			{
1204                 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT);
1205 			}
1206 
1207             rReq.Done();
1208 
1209 		}
1210 		break;
1211 		case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
1212 		case SID_ATTR_CHAR_COLOR_EXT:
1213 		{
1214 			SwEditWin& rEdtWin = GetView().GetEditWin();
1215 			SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
1216 			SwApplyTemplate aTempl;
1217 			sal_Bool bSelection = rWrtSh.HasSelection();
1218 			if(bSelection)
1219 			{
1220 
1221 				if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
1222 				{
1223 					rWrtSh.SetAttrItem(
1224                         SvxBrushItem( rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) );
1225 				}
1226 				else
1227 					rWrtSh.SetAttrItem(
1228                         SvxColorItem( rEdtWin.GetTextColor(), RES_CHRATR_COLOR) );
1229 			}
1230 			else
1231 			{
1232 				if(!pApply || pApply->nColor != nSlot)
1233 					aTempl.nColor = nSlot;
1234 				rEdtWin.SetApplyTemplate(aTempl);
1235 			}
1236 
1237 			rReq.Done();
1238 		}
1239 		break;
1240 
1241 		case FN_NUM_BULLET_MOVEDOWN:
1242 			if (!rWrtSh.IsAddMode())
1243 				rWrtSh.MoveParagraph(1);
1244 			rReq.Done();
1245 			break;
1246 
1247 		case FN_NUM_BULLET_MOVEUP:
1248 			if (!rWrtSh.IsAddMode())
1249 				rWrtSh.MoveParagraph(-1);
1250 			rReq.Done();
1251 			break;
1252 		case SID_RUBY_DIALOG:
1253 		case SID_HYPERLINK_DIALOG:
1254 		{
1255 			SfxRequest aReq(nSlot, SFX_CALLMODE_SLOT, SFX_APP()->GetPool());
1256 		    GetView().GetViewFrame()->ExecuteSlot( aReq);
1257             rReq.Ignore();
1258 		}
1259 		break;
1260     case FN_INSERT_PAGEHEADER:
1261     case FN_INSERT_PAGEFOOTER:
1262     if(pArgs && pArgs->Count())
1263     {
1264         String sStyleName;
1265         if(pItem)
1266             sStyleName = ((const SfxStringItem*)pItem)->GetValue();
1267         sal_Bool bOn = sal_True;
1268         if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem))
1269             bOn = ((const SfxBoolItem*)pItem)->GetValue();
1270         ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
1271         rReq.Done();
1272     }
1273     break;
1274     case FN_READONLY_SELECTION_MODE :
1275         if(GetView().GetDocShell()->IsReadOnly())
1276         {
1277             rWrtSh.SetReadonlySelectionOption(
1278                 !rWrtSh.GetViewOptions()->IsSelectionInReadonly());
1279             rWrtSh.ShowCrsr();
1280         }
1281     break;
1282     case FN_SELECTION_MODE_DEFAULT:
1283     case FN_SELECTION_MODE_BLOCK :
1284     {
1285         bool bSetBlockMode = !rWrtSh.IsBlockMode();
1286         if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
1287             bSetBlockMode = ((const SfxBoolItem*)pItem)->GetValue();
1288         if( ( nSlot == FN_SELECTION_MODE_DEFAULT ) ^ bSetBlockMode )
1289             rWrtSh.EnterBlockMode();
1290         else
1291             rWrtSh.EnterStdMode();
1292         SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
1293         rBnd.Invalidate(FN_STAT_SELMODE);
1294         rBnd.Update(FN_STAT_SELMODE);
1295     }
1296     break;
1297     case SID_OPEN_HYPERLINK:
1298     case FN_COPY_HYPERLINK_LOCATION:
1299     {
1300         SfxItemSet aSet(GetPool(),
1301                         RES_TXTATR_INETFMT,
1302                         RES_TXTATR_INETFMT);
1303         rWrtSh.GetCurAttr(aSet);
1304         if(SFX_ITEM_SET <= aSet.GetItemState( RES_TXTATR_INETFMT, sal_True ))
1305         {
1306             const SwFmtINetFmt& rINetFmt = dynamic_cast<const SwFmtINetFmt&>( aSet.Get(RES_TXTATR_INETFMT, sal_True) );
1307             if( nSlot == FN_COPY_HYPERLINK_LOCATION )
1308             {
1309                 ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard();
1310                 vcl::unohelper::TextDataObject::CopyStringTo(
1311                         rINetFmt.GetValue(),
1312                         xClipboard );
1313             }
1314             else
1315                 rWrtSh.ClickToINetAttr(rINetFmt, URLLOAD_NOFILTER);
1316         }
1317     }
1318     break;
1319     case SID_OPEN_XML_FILTERSETTINGS:
1320     {
1321 		try
1322 		{
1323             uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
1324 			if( xDialog.is() )
1325 			{
1326 				xDialog->execute();
1327 			}
1328 		}
1329         catch( uno::Exception& )
1330 		{
1331 		}
1332 		rReq.Ignore ();
1333 	}
1334 	break;
1335 	case FN_FORMAT_APPLY_HEAD1:
1336 	{
1337 	}
1338 	break;
1339 	case FN_FORMAT_APPLY_HEAD2:
1340 	{
1341 	}
1342 	break;
1343 	case FN_FORMAT_APPLY_HEAD3:
1344 	{
1345 	}
1346 	break;
1347 	case FN_FORMAT_APPLY_DEFAULT:
1348 	{
1349 	}
1350 	break;
1351 	case FN_FORMAT_APPLY_TEXTBODY:
1352 	{
1353 	}
1354 	break;
1355     case FN_WORDCOUNT_DIALOG:
1356     {
1357         SwWrtShell &rSh = GetShell();
1358         SwDocStat aCurr;
1359         SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
1360         {
1361             SwWait aWait( *GetView().GetDocShell(), true );
1362             rSh.StartAction();
1363             rSh.CountWords( aCurr );
1364             rSh.UpdateDocStat( aDocStat );
1365             rSh.EndAction();
1366         }
1367 
1368         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1369         DBG_ASSERT(pFact, "Dialogdiet fail!");
1370         AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
1371         pDialog->SetValues(aCurr, aDocStat );
1372         pDialog->Execute();
1373         delete pDialog;
1374     }
1375     break;
1376     default:
1377 		ASSERT(!this, falscher Dispatcher);
1378 		return;
1379 	}
1380 }
1381 
1382 
1383 /*--------------------------------------------------------------------
1384 	Beschreibung:
1385  --------------------------------------------------------------------*/
1386 
1387 
1388 void SwTextShell::GetState( SfxItemSet &rSet )
1389 {
1390 	SwWrtShell &rSh = GetShell();
1391 	SfxWhichIter aIter( rSet );
1392 	sal_uInt16 nWhich = aIter.FirstWhich();
1393 	while ( nWhich )
1394 	{
1395 		switch ( nWhich )
1396 		{
1397         case SID_LANGUAGE_STATUS:
1398             {
1399                 // the value of used script types
1400                 String aScriptTypesInUse( String::CreateFromInt32( rSh.GetScriptType() ) );
1401 
1402                 SvtLanguageTable aLangTable;
1403 
1404                 // get keyboard language
1405                 String aKeyboardLang;
1406                 LanguageType nLang = LANGUAGE_DONTKNOW;
1407                 SwEditWin& rEditWin = GetView().GetEditWin();
1408                 nLang = rEditWin.GetInputLanguage();
1409                 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
1410                     aKeyboardLang = aLangTable.GetString( nLang );
1411 
1412                 // get the language that is in use
1413                 const String aMultipleLanguages = String::CreateFromAscii("*");
1414                 String aCurrentLang = aMultipleLanguages;
1415                 nLang = SwLangHelper::GetCurrentLanguage( rSh );
1416                 if (nLang != LANGUAGE_DONTKNOW)
1417                     aCurrentLang = aLangTable.GetString( nLang );
1418 
1419                 // build sequence for status value
1420                 uno::Sequence< ::rtl::OUString > aSeq( 4 );
1421                 aSeq[0] = aCurrentLang;
1422                 aSeq[1] = aScriptTypesInUse;
1423                 aSeq[2] = aKeyboardLang;
1424                 aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( rSh );
1425 
1426                 // set sequence as status value
1427                 SfxStringListItem aItem( SID_LANGUAGE_STATUS );
1428                 aItem.SetStringList( aSeq );
1429                 rSet.Put( aItem, SID_LANGUAGE_STATUS );
1430             }
1431         break;
1432 
1433         case SID_THES:
1434         {
1435             // is there a valid selection to get text from?
1436             String aText;
1437             sal_Bool bValid = !rSh.HasSelection() ||
1438                     (rSh.IsSelOnePara() && !rSh.IsMultiSelection());
1439             // prevent context menu from showing when cursor is not in or at the end of a word
1440             // (GetCurWord will return the next word if there is none at the current position...)
1441             const sal_Int16 nWordType = ::i18n::WordType::DICTIONARY_WORD;
1442             bool bWord = rSh.IsInWord( nWordType ) || rSh.IsStartWord( nWordType ) || rSh.IsEndWord( nWordType );
1443             if (bValid && bWord)
1444                aText = rSh.HasSelection()? rSh.GetSelTxt() : rSh.GetCurWord();
1445 
1446             LanguageType nLang = rSh.GetCurLang();
1447             lang::Locale aLocale = SvxCreateLocale( nLang );
1448             String aLangText( MsLangId::convertLanguageToIsoString( nLang ) );
1449 
1450             // set word and locale to look up as status value
1451             String aStatusVal( aText );
1452             aStatusVal.AppendAscii( "#" );
1453             aStatusVal += aLangText;
1454 
1455             rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
1456 
1457             // disable "Thesaurus" context menu entry if there is nothing to look up
1458             uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
1459             if (aText.Len() == 0 ||
1460                 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
1461                 rSet.DisableItem( SID_THES );
1462         }
1463         break;
1464 
1465         case FN_NUMBER_NEWSTART :
1466             if(!rSh.GetCurNumRule())
1467                     rSet.DisableItem(nWhich);
1468             else
1469                 rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART,
1470                     rSh.IsNumRuleStart()));
1471         break;
1472 
1473         case FN_EDIT_FORMULA:
1474         case SID_CHARMAP:
1475             {
1476                 const int nType = rSh.GetSelectionType();
1477                 if (!(nType & nsSelectionType::SEL_TXT) &&
1478                     !(nType & nsSelectionType::SEL_TBL) &&
1479                     !(nType & nsSelectionType::SEL_NUM))
1480                 {
1481                     rSet.DisableItem(nWhich);
1482                 }
1483                 else if ( nWhich == FN_EDIT_FORMULA
1484                           && rSh.CrsrInsideInputFld() )
1485                 {
1486                     rSet.DisableItem( nWhich );
1487                 }
1488             }
1489             break;
1490 
1491         case FN_INSERT_ENDNOTE:
1492         case FN_INSERT_FOOTNOTE:
1493         case FN_INSERT_FOOTNOTE_DLG:
1494             {
1495                 const sal_uInt16 nNoType =
1496                     FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE;
1497                 if ( (rSh.GetFrmType(0,sal_True) & nNoType) )
1498                     rSet.DisableItem(nWhich);
1499 
1500                 if ( rSh.CrsrInsideInputFld() )
1501                 {
1502                     rSet.DisableItem( nWhich );
1503                 }
1504             }
1505             break;
1506 
1507         case FN_INSERT_HYPERLINK:
1508         case SID_INSERTDOC:
1509         case FN_INSERT_GLOSSARY:
1510         case FN_EXPAND_GLOSSARY:
1511             if ( rSh.CrsrInsideInputFld() )
1512             {
1513                 rSet.DisableItem( nWhich );
1514             }
1515             break;
1516 
1517         case FN_INSERT_TABLE:
1518             if ( rSh.CrsrInsideInputFld()
1519                  || rSh.GetTableFmt()
1520                  || (rSh.GetFrmType(0,sal_True) & FRMTYPE_FOOTNOTE) )
1521             {
1522                 rSet.DisableItem( nWhich );
1523             }
1524             break;
1525 
1526 		case FN_CALCULATE:
1527 			if ( !rSh.IsSelection() )
1528 				rSet.DisableItem(nWhich);
1529 			break;
1530 		case FN_GOTO_REFERENCE:
1531 			{
1532 				SwField *pFld = rSh.GetCurFld();
1533 				if ( !pFld || (pFld &&  pFld->GetTypeId() != TYP_GETREFFLD) )
1534 					rSet.DisableItem(nWhich);
1535 			}
1536 			break;
1537 		case FN_AUTOFORMAT_AUTO:
1538 			{
1539 				rSet.Put( SfxBoolItem( nWhich, SvxAutoCorrCfg::Get()->IsAutoFmtByInput() ));
1540 			}
1541 			break;
1542 
1543         case FN_GLOSSARY_DLG:
1544             {
1545                 if ( rSh.CrsrInsideInputFld() )
1546                 {
1547                     rSet.DisableItem( nWhich );
1548                 }
1549                 else
1550                 {
1551                     rSet.Put(SfxBoolItem(nWhich), sal_True);
1552                 }
1553             }
1554             break;
1555 
1556 		case SID_DEC_INDENT:
1557 		case SID_INC_INDENT:
1558 			{
1559 				//if the paragrah has bullet we'll do the following things:
1560 				//1: if the bullet level is the first level, disable the decrease-indent button
1561 				//2: if the bullet level is the last level, disable the increase-indent button
1562 				if ( rSh.GetCurNumRule() && !rSh.HasReadonlySel() )
1563 				{
1564 					sal_uInt8 nLevel = rSh.GetNumLevel();
1565 					if ( nLevel == (MAXLEVEL-1) && nWhich == SID_INC_INDENT ||
1566 						nLevel == 0 && nWhich == SID_DEC_INDENT )
1567 					{
1568 						rSet.DisableItem( nWhich );
1569 					}
1570 				}
1571 				else//if the paragraph has no bullet, execute the original functions
1572 				{
1573 					//below is copied of the old codes
1574 				sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1575 				nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
1576 				if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin(
1577 										SID_INC_INDENT == nWhich, sal_True ))
1578 					rSet.DisableItem( nWhich );
1579 				}
1580 				//old code begins
1581 				//sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1582 				//nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
1583 				//if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin(
1584 				//	SID_INC_INDENT == nWhich, TRUE ))
1585 				//	rSet.DisableItem( nWhich );
1586 				//old code ends
1587 			}
1588 			break;
1589 
1590 		case FN_DEC_INDENT_OFFSET:
1591 		case FN_INC_INDENT_OFFSET:
1592 			{
1593 				sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1594 				nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
1595 				if( (nHtmlMode == HTMLMODE_ON) ||
1596 					!rSh.IsMoveLeftMargin( FN_INC_INDENT_OFFSET == nWhich,
1597 											sal_False ))
1598 					rSet.DisableItem( nWhich );
1599 			}
1600 			break;
1601 
1602 		case SID_ATTR_CHAR_COLOR2:
1603 			{
1604 				rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2));
1605 			}
1606 			break;
1607 		case SID_ATTR_CHAR_COLOR_BACKGROUND:
1608 			{
1609               if(GetView().GetEditWin().IsTextBackColorTransparent())
1610                   rSet.Put(SvxColorItem(Color(COL_TRANSPARENT), SID_ATTR_CHAR_COLOR_BACKGROUND));
1611               else
1612 					rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND));
1613 			}
1614 			break;
1615 		case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
1616 		case SID_ATTR_CHAR_COLOR_EXT:
1617 			{
1618 				SwEditWin& rEdtWin = GetView().GetEditWin();
1619 				SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
1620 				rSet.Put(SfxBoolItem(nWhich, pApply && pApply->nColor == nWhich));
1621 			}
1622 			break;
1623 
1624         case FN_INSERT_BOOKMARK:
1625             if( rSh.IsTableMode()
1626                 || rSh.CrsrInsideInputFld() )
1627             {
1628                 rSet.DisableItem( nWhich );
1629             }
1630             break;
1631 
1632 
1633         case FN_INSERT_BREAK:
1634             if ( rSh.HasReadonlySel()
1635                  && !rSh.CrsrInsideInputFld() )
1636             {
1637                 rSet.DisableItem( nWhich );
1638             }
1639             break;
1640 
1641 
1642         case FN_INSERT_BREAK_DLG:
1643         case FN_INSERT_COLUMN_BREAK:
1644         case FN_INSERT_PAGEBREAK:
1645             if( rSh.CrsrInsideInputFld() )
1646             {
1647                 rSet.DisableItem( nWhich );
1648             }
1649             break;
1650 
1651 		case FN_INSERT_PAGEHEADER:
1652 		case FN_INSERT_PAGEFOOTER:
1653 			{
1654 #ifndef CHECK_MENU
1655 				rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() ));
1656 #else
1657 				// Seitenvorlagen besorgen
1658 				sal_Bool bFound = sal_False;
1659 				sal_uInt16 n, nCnt = rSh.GetPageDescCnt();
1660 				for( n = 0; n < nCnt; ++n )
1661 				{
1662 					const SwPageDesc& rDesc = rSh.GetPageDesc( n );
1663 					if( FN_INSERT_PAGEHEADER == nWhich
1664 						? !rDesc.GetMaster().GetHeader().IsActive()
1665 						: !rDesc.GetMaster().GetFooter().IsActive() )
1666 					{
1667 						bFound = sal_True;
1668 						break;
1669 					}
1670 				}
1671 
1672 				if( bFound )
1673 					rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() ));
1674 				else
1675 					rSet.DisableItem( nWhich );
1676 #endif
1677 			}
1678 			break;
1679             case FN_TABLE_SORT_DIALOG:
1680             case FN_SORTING_DLG:
1681                 if(!rSh.HasSelection() ||
1682                         (FN_TABLE_SORT_DIALOG == nWhich && !rSh.GetTableFmt()))
1683 					rSet.DisableItem( nWhich );
1684 			break;
1685 
1686             case SID_RUBY_DIALOG:
1687                 {
1688                     SvtCJKOptions aCJKOptions;
1689                     if( !aCJKOptions.IsRubyEnabled()
1690                         || rSh.CrsrInsideInputFld() )
1691                     {
1692                         GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
1693                         rSet.DisableItem(nWhich);
1694                     }
1695                     else
1696                         GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
1697                 }
1698                 break;
1699 
1700             case SID_HYPERLINK_DIALOG:
1701                 if( GetView().GetDocShell()->IsReadOnly()
1702                     || ( !GetView().GetViewFrame()->HasChildWindow(nWhich)
1703                          && rSh.HasReadonlySel() )
1704                     || rSh.CrsrInsideInputFld() )
1705                 {
1706                     rSet.DisableItem(nWhich);
1707                 }
1708                 else
1709                 {
1710                     rSet.Put(SfxBoolItem( nWhich, 0 != GetView().GetViewFrame()->GetChildWindow( nWhich ) ));
1711                 }
1712                 break;
1713 
1714             case FN_EDIT_HYPERLINK:
1715             case FN_REMOVE_HYPERLINK:
1716             case FN_COPY_HYPERLINK_LOCATION:
1717                 {
1718                     SfxItemSet aSet(GetPool(),
1719                         RES_TXTATR_INETFMT,
1720                         RES_TXTATR_INETFMT);
1721                     rSh.GetCurAttr(aSet);
1722                     if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_True ) || rSh.HasReadonlySel())
1723                     {
1724                         rSet.DisableItem(nWhich);
1725                     }
1726                 }
1727                 break;
1728 
1729             case SID_TRANSLITERATE_HALFWIDTH:
1730             case SID_TRANSLITERATE_FULLWIDTH:
1731             case SID_TRANSLITERATE_HIRAGANA:
1732             case SID_TRANSLITERATE_KATAGANA:
1733             {
1734                 SvtCJKOptions aCJKOptions;
1735                 if(!aCJKOptions.IsChangeCaseMapEnabled())
1736                 {
1737                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
1738                     rSet.DisableItem(nWhich);
1739                 }
1740                 else
1741                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
1742             }
1743             break;
1744             case FN_READONLY_SELECTION_MODE :
1745                 if(!GetView().GetDocShell()->IsReadOnly())
1746                     rSet.DisableItem( nWhich );
1747                 else
1748                 {
1749                     rSet.Put(SfxBoolItem(nWhich, rSh.GetViewOptions()->IsSelectionInReadonly()));
1750                 }
1751             break;
1752             case FN_SELECTION_MODE_DEFAULT:
1753             case FN_SELECTION_MODE_BLOCK :
1754                     rSet.Put(SfxBoolItem(nWhich, (nWhich == FN_SELECTION_MODE_DEFAULT) != rSh.IsBlockMode()));
1755             break;
1756             case  SID_OPEN_HYPERLINK:
1757             {
1758                 SfxItemSet aSet(GetPool(),
1759                                 RES_TXTATR_INETFMT,
1760                                 RES_TXTATR_INETFMT);
1761                 rSh.GetCurAttr(aSet);
1762                 if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_False ))
1763                     rSet.DisableItem(nWhich);
1764             }
1765             break;
1766             case  SID_OPEN_SMARTTAGMENU:
1767             {
1768                  uno::Sequence< rtl::OUString > aSmartTagTypes;
1769                  uno::Sequence< uno::Reference< container::XStringKeyMap > > aStringKeyMaps;
1770                  uno::Reference<text::XTextRange> xRange;
1771 
1772                  rSh.GetSmartTagTerm( aSmartTagTypes, aStringKeyMaps, xRange );
1773 
1774                  if ( xRange.is() && aSmartTagTypes.getLength() )
1775                  {
1776                      uno::Sequence < uno::Sequence< uno::Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence;
1777                      uno::Sequence < uno::Sequence< sal_Int32 > > aActionIndicesSequence;
1778 
1779                      const SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get();
1780                      rSmartTagMgr.GetActionSequences( aSmartTagTypes,
1781                                                       aActionComponentsSequence,
1782                                                       aActionIndicesSequence );
1783 
1784                      uno::Reference <frame::XController> xController = GetView().GetController();
1785                      const lang::Locale aLocale( SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) );
1786                      const rtl::OUString aApplicationName( rSmartTagMgr.GetApplicationName() );
1787                      const rtl::OUString aRangeText = xRange->getString();
1788 
1789                      const SvxSmartTagItem aItem( nWhich,
1790                                                   aActionComponentsSequence,
1791                                                   aActionIndicesSequence,
1792                                                   aStringKeyMaps,
1793                                                   xRange,
1794                                                   xController,
1795                                                   aLocale,
1796                                                   aApplicationName,
1797                                                   aRangeText );
1798 
1799                      rSet.Put( aItem );
1800                  }
1801                  else
1802                      rSet.DisableItem(nWhich);
1803             }
1804             break;
1805             case FN_NUM_NUMBERING_ON:
1806                 rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON,rSh.SelectionHasNumber()));
1807             break;
1808             case FN_NUM_BULLET_ON:
1809                 rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON,rSh.SelectionHasBullet()));
1810             break;
1811             case FN_BUL_NUM_RULE_INDEX:
1812             case FN_NUM_NUM_RULE_INDEX:
1813 		{
1814 			SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetCurNumRule());
1815 			sal_uInt16	nActNumLvl = (sal_uInt16)0xFFFF;
1816 			rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
1817 			rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
1818 			if( pCurRule )
1819 			{
1820 				nActNumLvl = GetShell().GetNumLevel();
1821 				if( nActNumLvl < MAXLEVEL )
1822 				{
1823 					nActNumLvl = 1<<nActNumLvl;
1824 				}
1825 				SvxNumRule aSvxRule = pCurRule->MakeSvxNumRule();
1826 				if ( GetShell().HasBullet())
1827 				{
1828 					rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
1829 					rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
1830 					NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
1831 					if ( pBullets )
1832 					{
1833 						sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
1834 						rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
1835 					}
1836 				}else if ( GetShell().HasNumber() )
1837 				{
1838 					rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
1839 					rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
1840 					NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
1841 					if ( pNumbering )
1842 					{
1843 						sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
1844 						rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
1845 					}
1846 				}
1847 			}
1848 		}
1849             break;
1850             case FN_NUM_CONTINUE:
1851             {
1852                 {
1853                     // --> OD 2009-08-26 #i86492#
1854                     // Search also for bullet list
1855                     String aDummy;
1856                     const SwNumRule* pRule =
1857                             rSh.SearchNumRule( false, true, false, -1, aDummy );
1858                     if ( !pRule )
1859                     {
1860                         pRule = rSh.SearchNumRule( false, false, false, -1, aDummy );
1861                     }
1862                     // <--
1863                     if ( !pRule )
1864                         rSet.DisableItem(nWhich);
1865                 }
1866             }
1867             break;
1868             case SID_INSERT_RLM :
1869             case SID_INSERT_LRM :
1870             case SID_INSERT_ZWNBSP :
1871             case SID_INSERT_ZWSP:
1872             {
1873                 SvtCTLOptions aCTLOptions;
1874                 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
1875                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
1876                 if(!bEnabled)
1877                     rSet.DisableItem(nWhich);
1878             }
1879             break;
1880         }
1881         nWhich = aIter.NextWhich();
1882 	}
1883 }
1884 /* -----------------------------2002/07/05 10:31------------------------------
1885     Switch on/off header of footer of a page style - if an empty name is
1886     given all styles are changed
1887  ---------------------------------------------------------------------------*/
1888 void SwTextShell::ChangeHeaderOrFooter(
1889     const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
1890 {
1891     SwWrtShell& rSh = GetShell();
1892     rSh.StartAllAction();
1893     rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
1894     sal_Bool bExecute = sal_True;
1895     sal_Bool bCrsrSet = sal_False;
1896     for( sal_uInt16 nFrom = 0, nTo = rSh.GetPageDescCnt();
1897             nFrom < nTo; ++nFrom )
1898     {
1899         int bChgd = sal_False;
1900         SwPageDesc aDesc( rSh.GetPageDesc( nFrom ));
1901         String sTmp(aDesc.GetName());
1902         if( !rStyleName.Len() || rStyleName == sTmp )
1903         {
1904             if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
1905                     ((bHeader && aDesc.GetMaster().GetHeader().IsActive()) ||
1906                         (!bHeader && aDesc.GetMaster().GetFooter().IsActive())))
1907             {
1908                 bShowWarning = sal_False;
1909                 //Actions have to be closed while the dialog is showing
1910                 rSh.EndAllAction();
1911 
1912                 Window* pParent = &GetView().GetViewFrame()->GetWindow();
1913                 sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
1914                                         DIALOG_MGR() ) ).Execute();
1915                 bExecute = bRet;
1916                 rSh.StartAllAction();
1917             }
1918             if( bExecute )
1919             {
1920                 bChgd = sal_True;
1921                 SwFrmFmt &rMaster = aDesc.GetMaster();
1922                 if(bHeader)
1923                     rMaster.SetFmtAttr( SwFmtHeader( bOn ));
1924                 else
1925                     rMaster.SetFmtAttr( SwFmtFooter( bOn ));
1926                 if( bOn )
1927                 {
1928                     SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
1929                     SwFrmFmt* pFmt = bHeader ?
1930                         (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
1931                         (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
1932                     pFmt->SetFmtAttr( aUL );
1933                 }
1934             }
1935             if( bChgd )
1936             {
1937                 rSh.ChgPageDesc( nFrom, aDesc );
1938 
1939                 if( !bCrsrSet && bOn )
1940                     bCrsrSet = rSh.SetCrsrInHdFt(
1941                             !rStyleName.Len() ? (sal_uInt16)0xFFFF : nFrom,
1942                             bHeader );
1943             }
1944         }
1945     }
1946     rSh.EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
1947     rSh.EndAllAction();
1948 }
1949 
1950