xref: /trunk/main/sw/source/ui/app/appopt.cxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #define _SVSTDARR_STRINGSDTOR
26 #include <svl/svstdarr.hxx>
27 
28 #include <com/sun/star/i18n/ScriptType.hpp>
29 
30 #include <hintids.hxx>
31 #include <cmdid.h>          // Function-Ids
32 #include <vcl/msgbox.hxx>
33 #include <svl/eitem.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/printer.hxx>
37 #include <svx/htmlmode.hxx>
38 #include <sfx2/bindings.hxx>
39 #include <editeng/brshitem.hxx>
40 #include <editeng/tstpitem.hxx>
41 #include <svx/optgrid.hxx>
42 #include <svx/svxdlg.hxx>
43 #include <svx/dialogs.hrc>
44 #include <i18npool/mslangid.hxx>
45 #include <fontcfg.hxx>
46 #include <optload.hxx>
47 #include <optcomp.hxx>
48 #include <edtwin.hxx>
49 #include <swmodule.hxx>
50 #include <view.hxx>
51 #include <doc.hxx>
52 #include <wrtsh.hxx>
53 #include <IDocumentDeviceAccess.hxx>
54 #include <uitool.hxx>
55 #include <initui.hxx>                   // fuer ::GetGlossaries()
56 #include <fldbas.hxx>      //fuer UpdateFields
57 #include <wview.hxx>
58 #include <cfgitems.hxx>
59 #include <prtopt.hxx>
60 #include <pview.hxx>
61 #include <usrpref.hxx>
62 #include <modcfg.hxx>
63 #include <glosdoc.hxx>
64 #include <uiitems.hxx>
65 #include <editeng/langitem.hxx>
66 #include <unotools/lingucfg.hxx>
67 #include <editeng/unolingu.hxx>
68 #include <globals.hrc>
69 #include <globals.h>        // globale Konstanten z.B.
70 #include <svl/slstitm.hxx>
71 #include "swabstdlg.hxx"
72 #include <swwrtshitem.hxx>
73 
74 #include <unomid.h>
75 
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::lang;
78 
79 /* -----------------12.02.99 12:28-------------------
80  *
81  * --------------------------------------------------*/
82 
83 SfxItemSet*  SwModule::CreateItemSet( sal_uInt16 nId )
84 {
85     sal_Bool bTextDialog = (nId == SID_SW_EDITOPTIONS) ? sal_True : sal_False;
86 
87     // hier werden die Optionen fuer die Web- und den Textdialog zusmmengesetzt
88         SwViewOption aViewOpt = *GetUsrPref(!bTextDialog);
89         SwMasterUsrPref* pPref = bTextDialog ? pUsrPref : pWebUsrPref;
90         //kein MakeUsrPref, da hier nur die Optionen von Textdoks genommen werden duerfen
91         SwView* pAppView = GetView();
92         if(pAppView && pAppView->GetViewFrame() != SfxViewFrame::Current())
93             pAppView = 0;
94         if(pAppView)
95         {
96         // wenn Text dann nicht WebView und umgekehrt
97             sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pAppView);
98             if( (bWebView &&  !bTextDialog) ||(!bWebView &&  bTextDialog))
99             {
100                 aViewOpt = *pAppView->GetWrtShell().GetViewOptions();
101             }
102             else
103                 pAppView = 0; // mit View kann hier nichts gewonnen werden
104         }
105 
106     /********************************************************************/
107     /* Optionen/Bearbeiten                                              */
108     /********************************************************************/
109     SfxItemSet* pRet = new SfxItemSet (GetPool(),   FN_PARAM_DOCDISP,       FN_PARAM_ELEM,
110                                     SID_PRINTPREVIEW,       SID_PRINTPREVIEW,
111                                     SID_ATTR_GRID_OPTIONS,  SID_ATTR_GRID_OPTIONS,
112                                     FN_PARAM_PRINTER,       FN_PARAM_STDFONTS,
113                                     FN_PARAM_WRTSHELL,      FN_PARAM_WRTSHELL,
114                                     FN_PARAM_ADDPRINTER,    FN_PARAM_ADDPRINTER,
115                                     SID_ATTR_METRIC,        SID_ATTR_METRIC,
116                                     SID_ATTR_DEFTABSTOP,    SID_ATTR_DEFTABSTOP,
117                                     RES_BACKGROUND,         RES_BACKGROUND,
118                                     SID_HTML_MODE,          SID_HTML_MODE,
119                                     FN_PARAM_SHADOWCURSOR,  FN_PARAM_SHADOWCURSOR,
120                                     FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED,
121                                     FN_HSCROLL_METRIC,      FN_VSCROLL_METRIC,
122                                     SID_ATTR_LANGUAGE,      SID_ATTR_LANGUAGE,
123                                     SID_ATTR_CHAR_CJK_LANGUAGE,   SID_ATTR_CHAR_CJK_LANGUAGE,
124                                     SID_ATTR_CHAR_CTL_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
125 #ifdef DBG_UTIL
126                                     FN_PARAM_SWTEST,        FN_PARAM_SWTEST,
127 #endif
128                                     0);
129 
130     pRet->Put( SwDocDisplayItem( aViewOpt, FN_PARAM_DOCDISP) );
131     pRet->Put( SwElemItem( aViewOpt, FN_PARAM_ELEM) );
132     if( bTextDialog )
133     {
134         pRet->Put( SwShadowCursorItem( aViewOpt, FN_PARAM_SHADOWCURSOR ));
135         pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea()));
136     }
137 
138     if( pAppView )
139     {
140         SwWrtShell& rWrtShell = pAppView->GetWrtShell();
141 
142         SfxPrinter* pPrt = rWrtShell.getIDocumentDeviceAccess()->getPrinter( false );
143         if( pPrt )
144             pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));
145         pRet->Put(SwPtrItem(FN_PARAM_WRTSHELL, &rWrtShell));
146 
147         pRet->Put((const SvxLanguageItem&)
148             rWrtShell.GetDefault(RES_CHRATR_LANGUAGE), SID_ATTR_LANGUAGE);
149 
150         pRet->Put((const SvxLanguageItem&)
151             rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE), SID_ATTR_CHAR_CJK_LANGUAGE);
152 
153         pRet->Put((const SvxLanguageItem&)
154             rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE), SID_ATTR_CHAR_CTL_LANGUAGE);
155     }
156     else
157     {
158 /*      Der Drucker wird jetzt von der TabPage erzeugt und auch geloescht
159  *      SfxItemSet* pSet = new SfxItemSet( SFX_APP()->GetPool(),
160                     SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
161                     SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
162                     0 );
163 
164         pPrt = new SfxPrinter(pSet);
165         pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));*/
166 
167         SvtLinguConfig aLinguCfg;
168         Locale aLocale;
169         LanguageType nLang;
170 
171         using namespace ::com::sun::star::i18n::ScriptType;
172 
173         Any aLang = aLinguCfg.GetProperty(C2U("DefaultLocale"));
174         aLang >>= aLocale;
175         nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), LATIN);
176         pRet->Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE));
177 
178         aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CJK"));
179         aLang >>= aLocale;
180         nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), ASIAN);
181         pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE));
182 
183         aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CTL"));
184         aLang >>= aLocale;
185         nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), COMPLEX);
186         pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE));
187     }
188     if(bTextDialog)
189         pRet->Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig()));
190     if( PTR_CAST( SwPagePreView, SfxViewShell::Current())!=0)
191     {
192         SfxBoolItem aBool(SfxBoolItem(SID_PRINTPREVIEW, sal_True));
193         pRet->Put(aBool);
194     }
195 
196     FieldUnit eUnit = pPref->GetHScrollMetric();
197     if(pAppView)
198         pAppView->GetHRulerMetric(eUnit);
199     pRet->Put(SfxUInt16Item( FN_HSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit)));
200 
201     eUnit = pPref->GetVScrollMetric();
202     if(pAppView)
203         pAppView->GetVRulerMetric(eUnit);
204     pRet->Put(SfxUInt16Item( FN_VSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit) ));
205     pRet->Put(SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(pPref->GetMetric()) ));
206     if(bTextDialog)
207     {
208         if(pAppView)
209         {
210             const SvxTabStopItem& rDefTabs =
211                     (const SvxTabStopItem&)pAppView->GetWrtShell().
212                                         GetDefault(RES_PARATR_TABSTOP);
213                 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, (sal_uInt16)::GetTabDist(rDefTabs)));
214         }
215         else
216             pRet->Put(SfxUInt16Item( SID_ATTR_DEFTABSTOP, (sal_uInt16)pPref->GetDefTab()));
217     }
218 
219     /*-----------------01.02.97 11.13-------------------
220     Optionen fuer GridTabPage
221     --------------------------------------------------*/
222 
223     SvxGridItem aGridItem( SID_ATTR_GRID_OPTIONS);
224 
225     aGridItem.SetUseGridSnap( aViewOpt.IsSnap());
226     aGridItem.SetSynchronize( aViewOpt.IsSynchronize());
227     aGridItem.SetGridVisible( aViewOpt.IsGridVisible());
228 
229     const Size& rSnapSize = aViewOpt.GetSnapSize();
230     aGridItem.SetFldDrawX( (sal_uInt16) (rSnapSize.Width() ));
231     aGridItem.SetFldDrawY( (sal_uInt16) (rSnapSize.Height()));
232 
233     aGridItem.SetFldDivisionX( aViewOpt.GetDivisionX());
234     aGridItem.SetFldDivisionY( aViewOpt.GetDivisionY());
235 
236     pRet->Put(aGridItem);
237 
238     /*-----------------01.02.97 13.02-------------------
239         Optionen fuer PrintTabPage
240     --------------------------------------------------*/
241     const SwPrintData* pOpt = pAppView ?
242                         &pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() :
243                         0;
244 
245     if(!pOpt)
246         pOpt = GetPrtOptions(!bTextDialog);
247 
248     SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, *pOpt );
249     pRet->Put(aAddPrinterItem);
250 
251     /*-----------------01.02.97 13.12-------------------
252         Optionen fuer Web-Hintergrund
253     --------------------------------------------------*/
254     if(!bTextDialog)
255     {
256         pRet->Put(SvxBrushItem(aViewOpt.GetRetoucheColor(), RES_BACKGROUND));
257     }
258 
259 #ifdef DBG_UTIL
260     /*-----------------01.02.97 13.02-------------------
261         Test-Optionen
262     --------------------------------------------------*/
263         SwTestItem aTestItem(FN_PARAM_SWTEST);
264         aTestItem.bTest1 = aViewOpt.IsTest1();
265         aTestItem.bTest2 = aViewOpt.IsTest2();
266         aTestItem.bTest3 = aViewOpt.IsTest3();
267         aTestItem.bTest4 =  aViewOpt.IsTest4();
268         aTestItem.bTest5 = aViewOpt.IsTest5();
269         aTestItem.bTest6 = aViewOpt.IsTest6();
270         aTestItem.bTest7 = aViewOpt.IsTest7();
271         aTestItem.bTest8 = aViewOpt.IsTest8();
272         aTestItem.bTest9 = SwViewOption::IsTest9();
273         aTestItem.bTest10 = aViewOpt.IsTest10();
274         pRet->Put(aTestItem);
275 #endif
276     /*-----------------01.02.97 13.04-------------------
277 
278     --------------------------------------------------*/
279     if(!bTextDialog)
280         pRet->Put(SfxUInt16Item(SID_HTML_MODE, HTMLMODE_ON));
281 //  delete pPrt;
282     return pRet;
283 }
284 /* -----------------12.02.99 12:28-------------------
285  *
286  * --------------------------------------------------*/
287 void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
288 {
289     sal_Bool bTextDialog = nId == SID_SW_EDITOPTIONS;
290     SwView* pAppView = GetView();
291     if(pAppView && pAppView->GetViewFrame() != SfxViewFrame::Current())
292         pAppView = 0;
293     if(pAppView)
294     {
295         // the text dialog mustn't apply data to the web view and vice versa
296         sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pAppView);
297         if( bWebView == bTextDialog)
298             pAppView = 0; //
299     }
300 
301     SwViewOption aViewOpt = *GetUsrPref(!bTextDialog);
302     SwMasterUsrPref* pPref = bTextDialog ? pUsrPref : pWebUsrPref;
303 
304     const SfxPoolItem* pItem;
305     SfxBindings *pBindings = pAppView ? &pAppView->GetViewFrame()->GetBindings()
306                                  : NULL;
307 
308     /*---------------------------------------------------------------------
309             Seite Dokumentansicht auswerten
310     -----------------------------------------------------------------------*/
311     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_DOCDISP, sal_False, &pItem ))
312     {
313         const SwDocDisplayItem* pDocDispItem = (const SwDocDisplayItem*)pItem;
314 
315         if(!aViewOpt.IsViewMetaChars())
316         {
317             if(     (!aViewOpt.IsTab( sal_True ) &&  pDocDispItem->bTab) ||
318                     (!aViewOpt.IsBlank( sal_True ) && pDocDispItem->bSpace) ||
319                     (!aViewOpt.IsParagraph( sal_True ) && pDocDispItem->bParagraphEnd) ||
320                     (!aViewOpt.IsLineBreak( sal_True ) && pDocDispItem->bManualBreak) )
321             {
322                 aViewOpt.SetViewMetaChars(sal_True);
323                 if(pBindings)
324                     pBindings->Invalidate(FN_VIEW_META_CHARS);
325             }
326 
327         }
328         pDocDispItem->FillViewOptions( aViewOpt );
329         if(pBindings)
330         {
331             pBindings->Invalidate(FN_VIEW_GRAPHIC);
332             pBindings->Invalidate(FN_VIEW_HIDDEN_PARA);
333         }
334     }
335 
336     /*---------------------------------------------------------------------
337                 Elemente - Item auswerten
338     -----------------------------------------------------------------------*/
339 
340     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ELEM, sal_False, &pItem ) )
341     {
342         const SwElemItem* pElemItem = (const SwElemItem*)pItem;
343         pElemItem->FillViewOptions( aViewOpt );
344 
345     }
346 
347     if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_METRIC, sal_False, &pItem ) )
348     {
349         SFX_APP()->SetOptions(rSet);
350         const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
351         ::SetDfltMetric((FieldUnit)pMetricItem->GetValue(), !bTextDialog);
352     }
353     if( SFX_ITEM_SET == rSet.GetItemState(FN_HSCROLL_METRIC, sal_False, &pItem ) )
354     {
355         const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
356         FieldUnit eUnit = (FieldUnit)pMetricItem->GetValue();
357         pPref->SetHScrollMetric(eUnit);
358         if(pAppView)
359             pAppView->ChangeTabMetric(eUnit);
360     }
361 
362     if( SFX_ITEM_SET == rSet.GetItemState(FN_VSCROLL_METRIC, sal_False, &pItem ) )
363     {
364         const SfxUInt16Item* pMetricItem = (const SfxUInt16Item*)pItem;
365         FieldUnit eUnit = (FieldUnit)pMetricItem->GetValue();
366         pPref->SetVScrollMetric(eUnit);
367         if(pAppView)
368             pAppView->ChangeVRulerMetric(eUnit);
369     }
370 
371     if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem ) )
372     {
373         sal_uInt16 nTabDist = ((const SfxUInt16Item*)pItem)->GetValue();
374         pPref->SetDefTab(nTabDist);
375         if(pAppView)
376         {
377             SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
378             MakeDefTabs( nTabDist, aDefTabs );
379             pAppView->GetWrtShell().SetDefault( aDefTabs );
380         }
381     }
382 
383 
384     /*-----------------01.02.97 11.36-------------------
385         Hintergrund nur im WebDialog
386     --------------------------------------------------*/
387     if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND))
388     {
389         const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rSet.Get(
390                                 RES_BACKGROUND);
391         aViewOpt.SetRetoucheColor( rBrushItem.GetColor() );
392     }
393 
394     /*--------------------------------------------------------------------
395             Seite Rastereinstellungen auswerten
396     ----------------------------------------------------------------------*/
397 
398     if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS, sal_False, &pItem ))
399     {
400         const SvxGridItem* pGridItem = (const SvxGridItem*)pItem;
401 
402         aViewOpt.SetSnap( pGridItem->GetUseGridSnap() );
403         aViewOpt.SetSynchronize(pGridItem->GetSynchronize());
404         if( aViewOpt.IsGridVisible() != pGridItem->GetGridVisible() )
405             aViewOpt.SetGridVisible( pGridItem->GetGridVisible());
406         Size aSize = Size( pGridItem->GetFldDrawX()  ,
407                             pGridItem->GetFldDrawY()  );
408         if( aViewOpt.GetSnapSize() != aSize )
409             aViewOpt.SetSnapSize( aSize );
410         short nDiv = (short)pGridItem->GetFldDivisionX() ;
411         if( aViewOpt.GetDivisionX() != nDiv  )
412             aViewOpt.SetDivisionX( nDiv );
413         nDiv = (short)pGridItem->GetFldDivisionY();
414         if( aViewOpt.GetDivisionY() != nDiv  )
415             aViewOpt.SetDivisionY( nDiv  );
416 
417         if(pBindings)
418         {
419             pBindings->Invalidate(SID_GRID_VISIBLE);
420             pBindings->Invalidate(SID_GRID_USE);
421         }
422     }
423 
424     //--------------------------------------------------------------------------
425     //      Writer Drucker Zusatzeinstellungen auswerten
426     //----------------------------------------------------------------------------
427 
428     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER, sal_False, &pItem ))
429     {
430         SwPrintOptions* pOpt = GetPrtOptions(!bTextDialog);
431         if (pOpt)
432         {
433             const SwAddPrinterItem* pAddPrinterAttr = (const SwAddPrinterItem*)pItem;
434             *pOpt = *pAddPrinterAttr;
435 
436             if(pAppView)
437                 pAppView->GetWrtShell().getIDocumentDeviceAccess()->setPrintData( *pOpt );
438         }
439 
440     }
441 
442     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_SHADOWCURSOR, sal_False, &pItem ))
443     {
444         ((SwShadowCursorItem*)pItem)->FillViewOptions( aViewOpt );
445         if(pBindings)
446             pBindings->Invalidate(FN_SHADOWCURSOR);
447     }
448 
449     if( pAppView )
450     {
451         SwWrtShell &rWrtSh = pAppView->GetWrtShell();
452         const bool bAlignFormulas = rWrtSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
453         pPref->SetAlignMathObjectsToBaseline( bAlignFormulas );
454 
455         // don't align formulas in documents that are currently loading
456         if (bAlignFormulas && !rWrtSh.GetDoc()->IsInReading())
457             rWrtSh.AlignAllFormulasToBaseline();
458     }
459 
460     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_CRSR_IN_PROTECTED, sal_False, &pItem ))
461     {
462         aViewOpt.SetCursorInProtectedArea(((const SfxBoolItem*)pItem)->GetValue());
463     }
464 
465 
466 #ifdef DBG_UTIL
467     /*--------------------------------------------------------------------------
468                 Writer Testseite auswerten
469     ----------------------------------------------------------------------------*/
470 
471             if( SFX_ITEM_SET == rSet.GetItemState(
472                         FN_PARAM_SWTEST, sal_False, &pItem ))
473             {
474                 const SwTestItem* pTestItem = (const SwTestItem*)pItem;
475                 aViewOpt.SetTest1((sal_Bool)pTestItem->bTest1);
476                 aViewOpt.SetTest2((sal_Bool)pTestItem->bTest2);
477                 aViewOpt.SetTest3((sal_Bool)pTestItem->bTest3);
478                 aViewOpt.SetTest4((sal_Bool)pTestItem->bTest4);
479                 aViewOpt.SetTest5((sal_Bool)pTestItem->bTest5);
480                 aViewOpt.SetTest6((sal_Bool)pTestItem->bTest6);
481                 aViewOpt.SetTest7((sal_Bool)pTestItem->bTest7);
482                 aViewOpt.SetTest8((sal_Bool)pTestItem->bTest8);
483                 SwViewOption::SetTest9((sal_Bool)pTestItem->bTest9);
484                 aViewOpt.SetTest10((sal_Bool)pTestItem->bTest10);
485             }
486 #endif
487         // dann an der akt. View und Shell die entsp. Elemente setzen
488     ApplyUsrPref( aViewOpt, pAppView, bTextDialog? VIEWOPT_DEST_TEXT : VIEWOPT_DEST_WEB);
489 }
490 /* -----------------12.02.99 12:28-------------------
491  *
492  * --------------------------------------------------*/
493 SfxTabPage* SwModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
494 {
495     SfxTabPage* pRet = NULL;
496     SfxAllItemSet aSet(*(rSet.GetPool()));
497     switch( nId )
498     {
499         case RID_SW_TP_CONTENT_OPT:
500         case RID_SW_TP_HTML_CONTENT_OPT:
501         {
502             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
503             if ( pFact )
504             {
505                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
506                 if ( fnCreatePage )
507                     pRet = (*fnCreatePage)( pParent, rSet );
508             }
509             break;
510         }
511         case RID_SW_TP_HTML_OPTGRID_PAGE:
512         case RID_SVXPAGE_GRID:
513             pRet = SvxGridTabPage::Create(pParent, rSet);
514         break;
515 
516         case RID_SW_TP_STD_FONT:
517         case RID_SW_TP_STD_FONT_CJK:
518         case RID_SW_TP_STD_FONT_CTL:
519         {
520             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
521             if ( pFact )
522             {
523                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
524                 if ( fnCreatePage )
525                     pRet = (*fnCreatePage)( pParent, rSet );
526             }
527             if(RID_SW_TP_STD_FONT != nId)
528             {
529                 aSet.Put (SfxUInt16Item(SID_FONTMODE_TYPE, RID_SW_TP_STD_FONT_CJK == nId ? FONT_GROUP_CJK : FONT_GROUP_CTL));
530                 pRet->PageCreated(aSet);
531             }
532         }
533         break;
534         case RID_SW_TP_HTML_OPTPRINT_PAGE:
535         case RID_SW_TP_OPTPRINT_PAGE:
536         {
537             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
538             if ( pFact )
539             {
540                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
541                 if ( fnCreatePage )
542                     pRet = (*fnCreatePage)( pParent, rSet );
543             }
544             aSet.Put (SfxBoolItem(SID_FAX_LIST, sal_True));
545             pRet->PageCreated(aSet);
546         }
547         break;
548         case RID_SW_TP_HTML_OPTTABLE_PAGE:
549         case RID_SW_TP_OPTTABLE_PAGE:
550         {
551             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
552             if ( pFact )
553             {
554                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
555                 if ( fnCreatePage )
556                     pRet = (*fnCreatePage)( pParent, rSet );
557             }
558             SwView* pCurrView = GetView();
559             if(pCurrView)
560             {
561                 // wenn Text dann nicht WebView und umgekehrt
562                 sal_Bool bWebView = 0 != PTR_CAST(SwWebView, pCurrView);
563                 if( (bWebView &&  RID_SW_TP_HTML_OPTTABLE_PAGE == nId) ||
564                     (!bWebView &&  RID_SW_TP_HTML_OPTTABLE_PAGE != nId) )
565                 {
566                     aSet.Put (SwWrtShellItem(SID_WRT_SHELL,pCurrView->GetWrtShellPtr()));
567                     pRet->PageCreated(aSet);
568                 }
569             }
570         }
571         break;
572         case RID_SW_TP_OPTSHDWCRSR:
573         case RID_SW_TP_HTML_OPTSHDWCRSR:
574         case RID_SW_TP_REDLINE_OPT:
575         case RID_SW_TP_OPTLOAD_PAGE:
576         case RID_SW_TP_OPTCOMPATIBILITY_PAGE:
577         case RID_SW_TP_MAILCONFIG:
578         {
579             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
580             if ( pFact )
581             {
582                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
583                 if ( fnCreatePage )
584                     pRet = (*fnCreatePage)( pParent, rSet );
585             }
586             if (pRet && (nId == RID_SW_TP_OPTSHDWCRSR || nId == RID_SW_TP_HTML_OPTSHDWCRSR))
587             {
588                 SwView* pCurrView = GetView();
589                 if(pCurrView)
590                 {
591                     aSet.Put( SwWrtShellItem( SID_WRT_SHELL, pCurrView->GetWrtShellPtr() ) );
592                     pRet->PageCreated(aSet);
593                 }
594             }
595         }
596         break;
597 #ifdef DBG_UTIL
598         case  RID_SW_TP_OPTTEST_PAGE:
599         {
600             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
601             if ( pFact )
602             {
603                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId );
604                 if ( fnCreatePage )
605                     pRet = (*fnCreatePage)( pParent, rSet );
606             }
607             break;
608         }
609 #endif
610         case  RID_SW_TP_BACKGROUND:
611         {
612             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
613             if ( pFact )
614             {
615                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND );
616                 if ( fnCreatePage )
617                     pRet = (*fnCreatePage)( pParent, rSet );
618             }
619             break;
620         }
621         case TP_OPTCAPTION_PAGE:
622         case RID_SW_TP_OPTCAPTION_PAGE:
623         {
624             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
625             if ( pFact )
626             {
627                 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SW_TP_OPTCAPTION_PAGE );
628                 if ( fnCreatePage )
629                     pRet = (*fnCreatePage)( pParent, rSet );
630             }
631         }
632         break;
633     }
634 
635     DBG_ASSERT( pRet, "SwModule::CreateTabPage(): Unknown tabpage id" );
636     return pRet;
637 }
638 
639 /* vim: set noet sw=4 ts=4: */
640