00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "precompiled_starmath.hxx"
00038
00039
00040
00041 #ifndef _GLOBNAME_HXX //autogen
00042 #include <tools/globname.hxx>
00043 #endif
00044 #ifndef _SV_STATUS_HXX //autogen
00045 #include <vcl/status.hxx>
00046 #endif
00047 #ifndef _SFXMSG_HXX //autogen
00048 #include <sfx2/msg.hxx>
00049 #endif
00050 #ifndef _SFXAPP_HXX //autogen
00051 #include <sfx2/app.hxx>
00052 #endif
00053 #ifndef _SFXOBJFACE_HXX //autogen
00054 #include <sfx2/objface.hxx>
00055 #endif
00056 #ifndef _SFX_WHITER_HXX //autogen
00057 #include <svtools/whiter.hxx>
00058 #endif
00059 #ifndef _SFXREQUEST_HXX //autogen
00060 #include <sfx2/request.hxx>
00061 #endif
00062 #ifndef _SFX_HRC //autogen
00063 #include <sfx2/sfx.hrc>
00064 #endif
00065 #ifndef _SFXVIEWSH_HXX
00066 #include <sfx2/viewsh.hxx>
00067 #endif
00068 #ifndef _SV_WRKWIN_HXX //autogen
00069 #include <vcl/wrkwin.hxx>
00070 #endif
00071 #ifndef _SVX_SVXIDS_HRC //autogen
00072 #include <svx/svxids.hrc>
00073 #endif
00074 #ifndef _SV_MSGBOX_HXX //autogen
00075 #include <vcl/msgbox.hxx>
00076 #endif
00077 #ifndef _SV_VIRDEV_HXX
00078 #include <vcl/virdev.hxx>
00079 #endif
00080 #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
00081 #include <svtools/syslocale.hxx>
00082 #endif
00083 #ifndef _RTTI_HXX
00084 #include <tools/rtti.hxx>
00085 #endif
00086
00087 #ifndef _SMMOD_HXX
00088 #include "smmod.hxx"
00089 #endif
00090 #ifndef SYMBOL_HXX
00091 #include "symbol.hxx"
00092 #endif
00093 #ifndef _CONFIG_HXX
00094 #include "config.hxx"
00095 #endif
00096 #ifndef _DIALOG_HXX
00097 #include "dialog.hxx"
00098 #endif
00099 #ifndef EDIT_HXX
00100 #include "edit.hxx"
00101 #endif
00102 #ifndef VIEW_HXX
00103 #include "view.hxx"
00104 #endif
00105 #include "starmath.hrc"
00106
00107 TYPEINIT1( SmModule, SfxModule );
00108
00109 #define SmModule
00110 #include "smslots.hxx"
00111
00112 #include <svx/xmlsecctrl.hxx>
00113
00114
00115
00116 SmResId::SmResId( USHORT nId )
00117 : ResId(nId, *SM_MOD()->GetResMgr())
00118 {
00119 }
00120
00122
00123 SmLocalizedSymbolData::SmLocalizedSymbolData() :
00124 Resource( SmResId(RID_LOCALIZED_NAMES) ),
00125 aUiSymbolNamesAry ( SmResId(RID_UI_SYMBOL_NAMES) ),
00126 aExportSymbolNamesAry ( SmResId(RID_EXPORT_SYMBOL_NAMES) ),
00127 aUiSymbolSetNamesAry ( SmResId(RID_UI_SYMBOLSET_NAMES) ),
00128 aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES) ),
00129 p50NamesAry ( 0 ),
00130 p60NamesAry ( 0 ),
00131 n50NamesLang ( LANGUAGE_NONE ),
00132 n60NamesLang ( LANGUAGE_NONE )
00133 {
00134 FreeResource();
00135 }
00136
00137
00138 SmLocalizedSymbolData::~SmLocalizedSymbolData()
00139 {
00140 delete p50NamesAry;
00141 delete p60NamesAry;
00142 }
00143
00144
00145 const String SmLocalizedSymbolData::GetUiSymbolName( const String &rExportName ) const
00146 {
00147 String aRes;
00148
00149 const SmLocalizedSymbolData &rData = SM_MOD1()->GetLocSymbolData();
00150 const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
00151 const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
00152 USHORT nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count());
00153 for (USHORT i = 0; i < nCount && !aRes.Len(); ++i)
00154 {
00155 if (rExportName == rExportNames.GetString(i))
00156 {
00157 aRes = rUiNames.GetString(i);
00158 break;
00159 }
00160 }
00161
00162 return aRes;
00163 }
00164
00165
00166 const String SmLocalizedSymbolData::GetExportSymbolName( const String &rUiName ) const
00167 {
00168 String aRes;
00169
00170 const SmLocalizedSymbolData &rData = SM_MOD1()->GetLocSymbolData();
00171 const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
00172 const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
00173 USHORT nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count());
00174 for (USHORT i = 0; i < nCount && !aRes.Len(); ++i)
00175 {
00176 if (rUiName == rUiNames.GetString(i))
00177 {
00178 aRes = rExportNames.GetString(i);
00179 break;
00180 }
00181 }
00182
00183 return aRes;
00184 }
00185
00186
00187 const String SmLocalizedSymbolData::GetUiSymbolSetName( const String &rExportName ) const
00188 {
00189 String aRes;
00190
00191 const SmLocalizedSymbolData &rData = SM_MOD1()->GetLocSymbolData();
00192 const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
00193 const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
00194 USHORT nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count());
00195 for (USHORT i = 0; i < nCount && !aRes.Len(); ++i)
00196 {
00197 if (rExportName == rExportNames.GetString(i))
00198 {
00199 aRes = rUiNames.GetString(i);
00200 break;
00201 }
00202 }
00203
00204 return aRes;
00205 }
00206
00207
00208 const String SmLocalizedSymbolData::GetExportSymbolSetName( const String &rUiName ) const
00209 {
00210 String aRes;
00211
00212 const SmLocalizedSymbolData &rData = SM_MOD1()->GetLocSymbolData();
00213 const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
00214 const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
00215 USHORT nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count());
00216 for (USHORT i = 0; i < nCount && !aRes.Len(); ++i)
00217 {
00218 if (rUiName == rUiNames.GetString(i))
00219 {
00220 aRes = rExportNames.GetString(i);
00221 break;
00222 }
00223 }
00224
00225 return aRes;
00226 }
00227
00228
00229 const ResStringArray* SmLocalizedSymbolData::Get50NamesArray( LanguageType nLang )
00230 {
00231 if (nLang != n50NamesLang)
00232 {
00233 int nRID;
00234 switch (nLang)
00235 {
00236 case LANGUAGE_FRENCH : nRID = RID_FRENCH_50_NAMES; break;
00237 case LANGUAGE_ITALIAN : nRID = RID_ITALIAN_50_NAMES; break;
00238 case LANGUAGE_SWEDISH : nRID = RID_SWEDISH_50_NAMES; break;
00239 case LANGUAGE_SPANISH : nRID = RID_SPANISH_50_NAMES; break;
00240 default : nRID = -1; break;
00241 }
00242 delete p50NamesAry;
00243 p50NamesAry = 0;
00244 n50NamesLang = nLang;
00245 if (-1 != nRID)
00246 p50NamesAry = new SmNamesArray( n50NamesLang, nRID );
00247 }
00248
00249 return p50NamesAry ? &p50NamesAry->GetNamesArray() : 0;
00250 }
00251
00252
00253 const ResStringArray* SmLocalizedSymbolData::Get60NamesArray( LanguageType nLang )
00254 {
00255 if (nLang != n60NamesLang)
00256 {
00257 int nRID;
00258 switch (nLang)
00259 {
00260 case LANGUAGE_FRENCH : nRID = RID_FRENCH_60_NAMES; break;
00261 case LANGUAGE_ITALIAN : nRID = RID_ITALIAN_60_NAMES; break;
00262 case LANGUAGE_SWEDISH : nRID = RID_SWEDISH_60_NAMES; break;
00263 case LANGUAGE_SPANISH : nRID = RID_SPANISH_60_NAMES; break;
00264 default : nRID = -1; break;
00265 }
00266 delete p60NamesAry;
00267 p60NamesAry = 0;
00268 n60NamesLang = nLang;
00269 if (-1 != nRID)
00270 p60NamesAry = new SmNamesArray( n60NamesLang, nRID );
00271 }
00272
00273 return p60NamesAry ? &p60NamesAry->GetNamesArray() : 0;
00274 }
00275
00277
00278 SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION))
00279 {
00280 SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR));
00281 }
00282
00283
00284 SmModule::SmModule(SfxObjectFactory* pObjFact) :
00285 SfxModule(SfxApplication::CreateResManager("sm"), FALSE, pObjFact, NULL),
00286 pColorConfig( 0 ),
00287 pConfig( 0 ),
00288 pLocSymbolData( 0 ),
00289 pSysLocale( 0 ),
00290 pVirtualDev( 0 )
00291 {
00292 SetName( C2S("StarMath" ));
00293 }
00294
00295
00296 SmModule::~SmModule()
00297 {
00298 delete pConfig;
00299 delete pColorConfig;
00300 delete pLocSymbolData;
00301 delete pSysLocale;
00302 delete pVirtualDev;
00303 }
00304
00305 void SmModule::_CreateSysLocale() const
00306 {
00307 SmModule* pThis = (SmModule*)this;
00308 pThis->pSysLocale = new SvtSysLocale;
00309 }
00310
00311 void SmModule::_CreateVirtualDev() const
00312 {
00313 SmModule* pThis = (SmModule*)this;
00314 pThis->pVirtualDev = new VirtualDevice;
00315 pThis->pVirtualDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
00316 }
00317
00318 void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg )
00319 {
00320
00321 const TypeId aSmViewTypeId = TYPE(SmViewShell);
00322 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
00323 while (pViewShell)
00324 {
00325 if ((pViewShell->IsA(aSmViewTypeId)))
00326 {
00327 SmViewShell *pSmView = (SmViewShell *) pViewShell;
00328 pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg );
00329 SmEditWindow *pEditWin = pSmView->GetEditWindow();
00330 if (pEditWin)
00331 pEditWin->ApplyColorConfigValues( rColorCfg );
00332 }
00333 pViewShell = SfxViewShell::GetNext( *pViewShell );
00334 }
00335 }
00336
00337 svtools::ColorConfig & SmModule::GetColorConfig()
00338 {
00339 if(!pColorConfig)
00340 {
00341 pColorConfig = new svtools::ColorConfig;
00342 ApplyColorConfigValues( *pColorConfig );
00343 StartListening( *pColorConfig );
00344 }
00345 return *pColorConfig;
00346 }
00347
00348 void SmModule::Notify( SfxBroadcaster & , const SfxHint &rHint )
00349 {
00350 if (rHint.ISA(SfxSimpleHint))
00351 {
00352 ULONG nHintId = ((SfxSimpleHint&)rHint).GetId();
00353 if (SFX_HINT_COLORS_CHANGED == nHintId)
00354 ApplyColorConfigValues(*pColorConfig);
00355 }
00356 }
00357
00358 SmConfig * SmModule::GetConfig()
00359 {
00360 if(!pConfig)
00361 pConfig = new SmConfig;
00362 return pConfig;
00363 }
00364
00365 SmSymSetManager & SmModule::GetSymSetManager()
00366 {
00367 return GetConfig()->GetSymSetManager();
00368 }
00369
00370 SmLocalizedSymbolData & SmModule::GetLocSymbolData() const
00371 {
00372 if (!pLocSymbolData)
00373 ((SmModule *) this)->pLocSymbolData = new SmLocalizedSymbolData;
00374 return *pLocSymbolData;
00375 }
00376
00377 void SmModule::GetState(SfxItemSet &rSet)
00378 {
00379 SfxWhichIter aIter(rSet);
00380
00381 for (USHORT nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
00382 switch (nWh)
00383 {
00384 case SID_CONFIGEVENT :
00385 rSet.DisableItem(SID_CONFIGEVENT);
00386 break;
00387 }
00388 }
00389
00390 void SmModule::FillStatusBar(StatusBar &rBar)
00391 {
00392 rBar.InsertItem(SID_TEXTSTATUS, 300, SIB_LEFT | SIB_IN);
00393 rBar.InsertItem(SID_ATTR_ZOOM, rBar.GetTextWidth(C2S(" 100% ")));
00394 rBar.InsertItem(SID_MODIFYSTATUS, rBar.GetTextWidth(C2S(" * ")));
00395 rBar.InsertItem( SID_SIGNATURE, XmlSecStatusBarControl::GetDefItemWidth( rBar ), SIB_USERDRAW );
00396 rBar.SetHelpId(SID_SIGNATURE, SID_SIGNATURE);
00397
00398 }
00399
00400
00401
00402
00403 SfxItemSet* SmModule::CreateItemSet( USHORT nId )
00404 {
00405 SfxItemSet* pRet = 0;
00406 if(nId == SID_SM_EDITOPTIONS)
00407 {
00408 pRet = new SfxItemSet(GetPool(),
00409
00410 SID_PRINTSIZE, SID_PRINTSIZE,
00411 SID_PRINTZOOM, SID_PRINTZOOM,
00412 SID_PRINTTITLE, SID_PRINTTITLE,
00413 SID_PRINTTEXT, SID_PRINTTEXT,
00414 SID_PRINTFRAME, SID_PRINTFRAME,
00415 SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
00416 0 );
00417
00418 GetConfig()->ConfigToItemSet(*pRet);
00419 }
00420 return pRet;
00421 }
00422
00423
00424
00425 void SmModule::ApplyItemSet( USHORT nId, const SfxItemSet& rSet )
00426 {
00427 if(nId == SID_SM_EDITOPTIONS)
00428 {
00429 GetConfig()->ItemSetToConfig(rSet);
00430 }
00431 }
00432
00433
00434
00435 SfxTabPage* SmModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItemSet& rSet )
00436 {
00437 SfxTabPage* pRet = 0;
00438 if(nId == SID_SM_TP_PRINTOPTIONS)
00439 pRet = SmPrintOptionsTabPage::Create( pParent, rSet );
00440 return pRet;
00441
00442 }