1*d107581fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d107581fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d107581fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d107581fSAndrew Rist * distributed with this work for additional information 6*d107581fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d107581fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d107581fSAndrew Rist * "License"); you may not use this file except in compliance 9*d107581fSAndrew Rist * with the License. You may obtain a copy of the License at 10*d107581fSAndrew Rist * 11*d107581fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*d107581fSAndrew Rist * 13*d107581fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d107581fSAndrew Rist * software distributed under the License is distributed on an 15*d107581fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d107581fSAndrew Rist * KIND, either express or implied. See the License for the 17*d107581fSAndrew Rist * specific language governing permissions and limitations 18*d107581fSAndrew Rist * under the License. 19*d107581fSAndrew Rist * 20*d107581fSAndrew Rist *************************************************************/ 21*d107581fSAndrew Rist 22*d107581fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_starmath.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <tools/globname.hxx> 29cdf0e10cSrcweir #include <vcl/status.hxx> 30cdf0e10cSrcweir #include <sfx2/msg.hxx> 31cdf0e10cSrcweir #include <sfx2/app.hxx> 32cdf0e10cSrcweir #include <sfx2/objface.hxx> 33cdf0e10cSrcweir #include <svl/whiter.hxx> 34cdf0e10cSrcweir #include <sfx2/request.hxx> 35cdf0e10cSrcweir #include <sfx2/sfx.hrc> 36cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 37cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 38cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen 39cdf0e10cSrcweir #include <svx/svxids.hrc> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #include <vcl/msgbox.hxx> 42cdf0e10cSrcweir #include <vcl/virdev.hxx> 43cdf0e10cSrcweir #include <unotools/syslocale.hxx> 44cdf0e10cSrcweir #include <tools/rtti.hxx> 45cdf0e10cSrcweir #include "smmod.hxx" 46cdf0e10cSrcweir #include "symbol.hxx" 47cdf0e10cSrcweir #include "config.hxx" 48cdf0e10cSrcweir #ifndef _DIALOG_HXX 49cdf0e10cSrcweir #include "dialog.hxx" 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #include "edit.hxx" 52cdf0e10cSrcweir #include "view.hxx" 53cdf0e10cSrcweir #include "starmath.hrc" 54cdf0e10cSrcweir 55cdf0e10cSrcweir TYPEINIT1( SmModule, SfxModule ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir #define SmModule 58cdf0e10cSrcweir #include "smslots.hxx" 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include <svx/xmlsecctrl.hxx> 61cdf0e10cSrcweir 62cdf0e10cSrcweir 63cdf0e10cSrcweir 64cdf0e10cSrcweir SmResId::SmResId( sal_uInt16 nId ) 65cdf0e10cSrcweir : ResId(nId, *SM_MOD()->GetResMgr()) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir ///////////////////////////////////////////////////////////////// 70cdf0e10cSrcweir 71cdf0e10cSrcweir SmLocalizedSymbolData::SmLocalizedSymbolData() : 72cdf0e10cSrcweir Resource( SmResId(RID_LOCALIZED_NAMES) ), 73cdf0e10cSrcweir aUiSymbolNamesAry ( SmResId(RID_UI_SYMBOL_NAMES) ), 74cdf0e10cSrcweir aExportSymbolNamesAry ( SmResId(RID_EXPORT_SYMBOL_NAMES) ), 75cdf0e10cSrcweir aUiSymbolSetNamesAry ( SmResId(RID_UI_SYMBOLSET_NAMES) ), 76cdf0e10cSrcweir aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES) ), 77cdf0e10cSrcweir p50NamesAry ( 0 ), 78cdf0e10cSrcweir p60NamesAry ( 0 ), 79cdf0e10cSrcweir n50NamesLang ( LANGUAGE_NONE ), 80cdf0e10cSrcweir n60NamesLang ( LANGUAGE_NONE ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir FreeResource(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir SmLocalizedSymbolData::~SmLocalizedSymbolData() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir delete p50NamesAry; 89cdf0e10cSrcweir delete p60NamesAry; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir 93cdf0e10cSrcweir const String SmLocalizedSymbolData::GetUiSymbolName( const String &rExportName ) const 94cdf0e10cSrcweir { 95cdf0e10cSrcweir String aRes; 96cdf0e10cSrcweir 97cdf0e10cSrcweir const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); 98cdf0e10cSrcweir const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray(); 99cdf0e10cSrcweir const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray(); 100cdf0e10cSrcweir sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count()); 101cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount && !aRes.Len(); ++i) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir if (rExportName == rExportNames.GetString(i)) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir aRes = rUiNames.GetString(i); 106cdf0e10cSrcweir break; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir return aRes; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir 114cdf0e10cSrcweir const String SmLocalizedSymbolData::GetExportSymbolName( const String &rUiName ) const 115cdf0e10cSrcweir { 116cdf0e10cSrcweir String aRes; 117cdf0e10cSrcweir 118cdf0e10cSrcweir const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); 119cdf0e10cSrcweir const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray(); 120cdf0e10cSrcweir const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray(); 121cdf0e10cSrcweir sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count()); 122cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount && !aRes.Len(); ++i) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir if (rUiName == rUiNames.GetString(i)) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir aRes = rExportNames.GetString(i); 127cdf0e10cSrcweir break; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir return aRes; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir 135cdf0e10cSrcweir const String SmLocalizedSymbolData::GetUiSymbolSetName( const String &rExportName ) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir String aRes; 138cdf0e10cSrcweir 139cdf0e10cSrcweir const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); 140cdf0e10cSrcweir const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray(); 141cdf0e10cSrcweir const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray(); 142cdf0e10cSrcweir sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count()); 143cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount && !aRes.Len(); ++i) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir if (rExportName == rExportNames.GetString(i)) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir aRes = rUiNames.GetString(i); 148cdf0e10cSrcweir break; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir return aRes; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156cdf0e10cSrcweir const String SmLocalizedSymbolData::GetExportSymbolSetName( const String &rUiName ) const 157cdf0e10cSrcweir { 158cdf0e10cSrcweir String aRes; 159cdf0e10cSrcweir 160cdf0e10cSrcweir const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); 161cdf0e10cSrcweir const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray(); 162cdf0e10cSrcweir const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray(); 163cdf0e10cSrcweir sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count()); 164cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount && !aRes.Len(); ++i) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir if (rUiName == rUiNames.GetString(i)) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir aRes = rExportNames.GetString(i); 169cdf0e10cSrcweir break; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir return aRes; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir const ResStringArray* SmLocalizedSymbolData::Get50NamesArray( LanguageType nLang ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir if (nLang != n50NamesLang) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir int nRID; 182cdf0e10cSrcweir switch (nLang) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir case LANGUAGE_FRENCH : nRID = RID_FRENCH_50_NAMES; break; 185cdf0e10cSrcweir case LANGUAGE_ITALIAN : nRID = RID_ITALIAN_50_NAMES; break; 186cdf0e10cSrcweir case LANGUAGE_SWEDISH : nRID = RID_SWEDISH_50_NAMES; break; 187cdf0e10cSrcweir case LANGUAGE_SPANISH : nRID = RID_SPANISH_50_NAMES; break; 188cdf0e10cSrcweir default : nRID = -1; break; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir delete p50NamesAry; 191cdf0e10cSrcweir p50NamesAry = 0; 192cdf0e10cSrcweir n50NamesLang = nLang; 193cdf0e10cSrcweir if (-1 != nRID) 194cdf0e10cSrcweir p50NamesAry = new SmNamesArray( n50NamesLang, nRID ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir return p50NamesAry ? &p50NamesAry->GetNamesArray() : 0; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir 201cdf0e10cSrcweir const ResStringArray* SmLocalizedSymbolData::Get60NamesArray( LanguageType nLang ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir if (nLang != n60NamesLang) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir int nRID; 206cdf0e10cSrcweir switch (nLang) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir case LANGUAGE_FRENCH : nRID = RID_FRENCH_60_NAMES; break; 209cdf0e10cSrcweir case LANGUAGE_ITALIAN : nRID = RID_ITALIAN_60_NAMES; break; 210cdf0e10cSrcweir case LANGUAGE_SWEDISH : nRID = RID_SWEDISH_60_NAMES; break; 211cdf0e10cSrcweir case LANGUAGE_SPANISH : nRID = RID_SPANISH_60_NAMES; break; 212cdf0e10cSrcweir default : nRID = -1; break; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir delete p60NamesAry; 215cdf0e10cSrcweir p60NamesAry = 0; 216cdf0e10cSrcweir n60NamesLang = nLang; 217cdf0e10cSrcweir if (-1 != nRID) 218cdf0e10cSrcweir p60NamesAry = new SmNamesArray( n60NamesLang, nRID ); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir return p60NamesAry ? &p60NamesAry->GetNamesArray() : 0; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir ///////////////////////////////////////////////////////////////// 225cdf0e10cSrcweir 226cdf0e10cSrcweir SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION)) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR)); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir 232cdf0e10cSrcweir SmModule::SmModule(SfxObjectFactory* pObjFact) : 233cdf0e10cSrcweir SfxModule(SfxApplication::CreateResManager("sm"), sal_False, pObjFact, NULL), 234cdf0e10cSrcweir pColorConfig( 0 ), 235cdf0e10cSrcweir pConfig( 0 ), 236cdf0e10cSrcweir pLocSymbolData( 0 ), 237cdf0e10cSrcweir pSysLocale( 0 ), 238cdf0e10cSrcweir pVirtualDev( 0 ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir SetName( C2S("StarMath" )); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir 244cdf0e10cSrcweir SmModule::~SmModule() 245cdf0e10cSrcweir { 246cdf0e10cSrcweir delete pConfig; 247cdf0e10cSrcweir if (pColorConfig) 248cdf0e10cSrcweir pColorConfig->RemoveListener(this); 249cdf0e10cSrcweir delete pColorConfig; 250cdf0e10cSrcweir delete pLocSymbolData; 251cdf0e10cSrcweir delete pSysLocale; 252cdf0e10cSrcweir delete pVirtualDev; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir void SmModule::_CreateSysLocale() const 256cdf0e10cSrcweir { 257cdf0e10cSrcweir SmModule* pThis = (SmModule*)this; 258cdf0e10cSrcweir pThis->pSysLocale = new SvtSysLocale; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir void SmModule::_CreateVirtualDev() const 262cdf0e10cSrcweir { 263cdf0e10cSrcweir SmModule* pThis = (SmModule*)this; 264cdf0e10cSrcweir pThis->pVirtualDev = new VirtualDevice; 265cdf0e10cSrcweir pThis->pVirtualDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir //invalidate all graphic and edit windows 271cdf0e10cSrcweir const TypeId aSmViewTypeId = TYPE(SmViewShell); 272cdf0e10cSrcweir SfxViewShell* pViewShell = SfxViewShell::GetFirst(); 273cdf0e10cSrcweir while (pViewShell) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir if ((pViewShell->IsA(aSmViewTypeId))) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir SmViewShell *pSmView = (SmViewShell *) pViewShell; 278cdf0e10cSrcweir pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg ); 279cdf0e10cSrcweir SmEditWindow *pEditWin = pSmView->GetEditWindow(); 280cdf0e10cSrcweir if (pEditWin) 281cdf0e10cSrcweir pEditWin->ApplyColorConfigValues( rColorCfg ); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir pViewShell = SfxViewShell::GetNext( *pViewShell ); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir svtools::ColorConfig & SmModule::GetColorConfig() 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if(!pColorConfig) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir pColorConfig = new svtools::ColorConfig; 292cdf0e10cSrcweir ApplyColorConfigValues( *pColorConfig ); 293cdf0e10cSrcweir pColorConfig->AddListener(this); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir return *pColorConfig; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir ApplyColorConfigValues(*pColorConfig); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir SmConfig * SmModule::GetConfig() 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if(!pConfig) 306cdf0e10cSrcweir pConfig = new SmConfig; 307cdf0e10cSrcweir return pConfig; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir SmSymbolManager & SmModule::GetSymbolManager() 311cdf0e10cSrcweir { 312cdf0e10cSrcweir return GetConfig()->GetSymbolManager(); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir SmLocalizedSymbolData & SmModule::GetLocSymbolData() const 316cdf0e10cSrcweir { 317cdf0e10cSrcweir if (!pLocSymbolData) 318cdf0e10cSrcweir ((SmModule *) this)->pLocSymbolData = new SmLocalizedSymbolData; 319cdf0e10cSrcweir return *pLocSymbolData; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir void SmModule::GetState(SfxItemSet &rSet) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir SfxWhichIter aIter(rSet); 325cdf0e10cSrcweir 326cdf0e10cSrcweir for (sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich()) 327cdf0e10cSrcweir switch (nWh) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir case SID_CONFIGEVENT : 330cdf0e10cSrcweir rSet.DisableItem(SID_CONFIGEVENT); 331cdf0e10cSrcweir break; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir /* -----------------15.02.99 12:45------------------- 336cdf0e10cSrcweir * 337cdf0e10cSrcweir * --------------------------------------------------*/ 338cdf0e10cSrcweir SfxItemSet* SmModule::CreateItemSet( sal_uInt16 nId ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir SfxItemSet* pRet = 0; 341cdf0e10cSrcweir if(nId == SID_SM_EDITOPTIONS) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir pRet = new SfxItemSet(GetPool(), 344cdf0e10cSrcweir //TP_SMPRINT 345cdf0e10cSrcweir SID_PRINTSIZE, SID_PRINTSIZE, 346cdf0e10cSrcweir SID_PRINTZOOM, SID_PRINTZOOM, 347cdf0e10cSrcweir SID_PRINTTITLE, SID_PRINTTITLE, 348cdf0e10cSrcweir SID_PRINTTEXT, SID_PRINTTEXT, 349cdf0e10cSrcweir SID_PRINTFRAME, SID_PRINTFRAME, 350cdf0e10cSrcweir SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, 351cdf0e10cSrcweir SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, 352cdf0e10cSrcweir 0 ); 353cdf0e10cSrcweir 354cdf0e10cSrcweir GetConfig()->ConfigToItemSet(*pRet); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir return pRet; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir /* -----------------15.02.99 12:45------------------- 359cdf0e10cSrcweir * 360cdf0e10cSrcweir * --------------------------------------------------*/ 361cdf0e10cSrcweir void SmModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir if(nId == SID_SM_EDITOPTIONS) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir GetConfig()->ItemSetToConfig(rSet); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } 368cdf0e10cSrcweir /* -----------------15.02.99 12:45------------------- 369cdf0e10cSrcweir * 370cdf0e10cSrcweir * --------------------------------------------------*/ 371cdf0e10cSrcweir SfxTabPage* SmModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir SfxTabPage* pRet = 0; 374cdf0e10cSrcweir if(nId == SID_SM_TP_PRINTOPTIONS) 375cdf0e10cSrcweir pRet = SmPrintOptionsTabPage::Create( pParent, rSet ); 376cdf0e10cSrcweir return pRet; 377cdf0e10cSrcweir 378cdf0e10cSrcweir } 379