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