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