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