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