LCOV - code coverage report
Current view: top level - starmath/source - smmod.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 136 0.0 %
Date: 2014-04-14 Functions: 0 33 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/globname.hxx>
      21             : #include <vcl/status.hxx>
      22             : #include <sfx2/msg.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/objface.hxx>
      25             : #include <svl/whiter.hxx>
      26             : #include <sfx2/request.hxx>
      27             : #include <sfx2/sfx.hrc>
      28             : #include <sfx2/viewsh.hxx>
      29             : #include <vcl/wrkwin.hxx>
      30             : #include <svx/svxids.hrc>
      31             : #include <vcl/msgbox.hxx>
      32             : #include <vcl/virdev.hxx>
      33             : #include <unotools/syslocale.hxx>
      34             : #include <tools/rtti.hxx>
      35             : #include "smmod.hxx"
      36             : #include "symbol.hxx"
      37             : #include "config.hxx"
      38             : #include "dialog.hxx"
      39             : #include "edit.hxx"
      40             : #include "view.hxx"
      41             : #include "starmath.hrc"
      42             : #include "svx/modctrl.hxx"
      43             : 
      44           0 : TYPEINIT1( SmModule, SfxModule );
      45             : 
      46             : #define SmModule
      47             : #include "smslots.hxx"
      48             : 
      49             : #include <svx/xmlsecctrl.hxx>
      50             : 
      51             : 
      52             : 
      53           0 : SmResId::SmResId( sal_uInt16 nId )
      54           0 :     : ResId(nId, *SM_MOD()->GetResMgr())
      55             : {
      56           0 : }
      57             : 
      58             : 
      59             : 
      60           0 : SmLocalizedSymbolData::SmLocalizedSymbolData() :
      61             :     Resource( SmResId(RID_LOCALIZED_NAMES) ),
      62             :     aUiSymbolNamesAry       ( SmResId(RID_UI_SYMBOL_NAMES) ),
      63             :     aExportSymbolNamesAry   ( SmResId(RID_EXPORT_SYMBOL_NAMES) ),
      64             :     aUiSymbolSetNamesAry    ( SmResId(RID_UI_SYMBOLSET_NAMES) ),
      65           0 :     aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES) )
      66             : {
      67           0 :     FreeResource();
      68           0 : }
      69             : 
      70             : 
      71           0 : SmLocalizedSymbolData::~SmLocalizedSymbolData()
      72             : {
      73           0 : }
      74             : 
      75             : 
      76           0 : const OUString SmLocalizedSymbolData::GetUiSymbolName( const OUString &rExportName ) const
      77             : {
      78           0 :     OUString aRes;
      79             : 
      80           0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
      81           0 :     const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
      82           0 :     const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
      83           0 :     sal_uInt32 nCount = rExportNames.Count();
      84           0 :     for (sal_uInt32 i = 0;  i < nCount  &&  aRes.isEmpty();  ++i)
      85             :     {
      86           0 :         if (rExportNames.GetString(i).equals(rExportName))
      87             :         {
      88           0 :             aRes = rUiNames.GetString(i);
      89           0 :             break;
      90             :         }
      91             :     }
      92             : 
      93           0 :     return aRes;
      94             : }
      95             : 
      96             : 
      97           0 : const OUString SmLocalizedSymbolData::GetExportSymbolName( const OUString &rUiName ) const
      98             : {
      99           0 :     OUString aRes;
     100             : 
     101           0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     102           0 :     const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
     103           0 :     const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
     104           0 :     sal_uInt32 nCount = rUiNames.Count();
     105           0 :     for (sal_uInt32 i = 0;  i < nCount  &&  aRes.isEmpty();  ++i)
     106             :     {
     107           0 :         if (rUiNames.GetString(i).equals(rUiName))
     108             :         {
     109           0 :             aRes = rExportNames.GetString(i);
     110           0 :             break;
     111             :         }
     112             :     }
     113             : 
     114           0 :     return aRes;
     115             : }
     116             : 
     117             : 
     118           0 : const OUString SmLocalizedSymbolData::GetUiSymbolSetName( const OUString &rExportName ) const
     119             : {
     120           0 :     OUString aRes;
     121             : 
     122           0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     123           0 :     const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
     124           0 :     const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
     125           0 :     sal_uInt32 nCount = rExportNames.Count();
     126           0 :     for (sal_uInt32 i = 0;  i < nCount  &&  aRes.isEmpty();  ++i)
     127             :     {
     128           0 :         if (rExportNames.GetString(i).equals(rExportName))
     129             :         {
     130           0 :             aRes = rUiNames.GetString(i);
     131           0 :             break;
     132             :         }
     133             :     }
     134             : 
     135           0 :     return aRes;
     136             : }
     137             : 
     138             : 
     139           0 : const OUString SmLocalizedSymbolData::GetExportSymbolSetName( const OUString &rUiName ) const
     140             : {
     141           0 :     OUString aRes;
     142             : 
     143           0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     144           0 :     const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
     145           0 :     const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
     146           0 :     sal_uInt32 nCount = rUiNames.Count();
     147           0 :     for (sal_uInt32 i = 0;  i < nCount  &&  aRes.isEmpty();  ++i)
     148             :     {
     149           0 :         if (rUiNames.GetString(i).equals(rUiName))
     150             :         {
     151           0 :             aRes = rExportNames.GetString(i);
     152           0 :             break;
     153             :         }
     154             :     }
     155             : 
     156           0 :     return aRes;
     157             : }
     158             : 
     159             : 
     160             : 
     161           0 : SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION))
     162             : {
     163           0 :     SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR));
     164           0 : }
     165             : 
     166             : 
     167           0 : SmModule::SmModule(SfxObjectFactory* pObjFact) :
     168             :     SfxModule(SfxApplication::CreateResManager("sm"), false, pObjFact, NULL),
     169             :     pColorConfig( 0 ),
     170             :     pConfig( 0 ),
     171             :     pLocSymbolData( 0 ),
     172             :     pSysLocale( 0 ),
     173           0 :     pVirtualDev( 0 )
     174             : {
     175           0 :     SetName(OUString("StarMath"));
     176             : 
     177           0 :     SvxModifyControl::RegisterControl(SID_DOC_MODIFIED, this);
     178           0 : }
     179             : 
     180             : 
     181           0 : SmModule::~SmModule()
     182             : {
     183           0 :     delete pConfig;
     184           0 :     if (pColorConfig)
     185           0 :         pColorConfig->RemoveListener(this);
     186           0 :     delete pColorConfig;
     187           0 :     delete pLocSymbolData;
     188           0 :     delete pSysLocale;
     189           0 :     delete pVirtualDev;
     190           0 : }
     191             : 
     192           0 : void SmModule::_CreateSysLocale() const
     193             : {
     194           0 :     SmModule* pThis = (SmModule*)this;
     195           0 :     pThis->pSysLocale = new SvtSysLocale;
     196           0 : }
     197             : 
     198           0 : void SmModule::_CreateVirtualDev() const
     199             : {
     200           0 :     SmModule* pThis = (SmModule*)this;
     201           0 :     pThis->pVirtualDev = new VirtualDevice;
     202           0 :     pThis->pVirtualDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
     203           0 : }
     204             : 
     205           0 : void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg )
     206             : {
     207             :     //invalidate all graphic and edit windows
     208           0 :     const TypeId aSmViewTypeId = TYPE(SmViewShell);
     209           0 :     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     210           0 :     while (pViewShell)
     211             :     {
     212           0 :         if ((pViewShell->IsA(aSmViewTypeId)))
     213             :         {
     214           0 :             SmViewShell *pSmView = (SmViewShell *) pViewShell;
     215           0 :             pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg );
     216           0 :             SmEditWindow *pEditWin = pSmView->GetEditWindow();
     217           0 :             if (pEditWin)
     218           0 :                 pEditWin->ApplyColorConfigValues( rColorCfg );
     219             :         }
     220           0 :         pViewShell = SfxViewShell::GetNext( *pViewShell );
     221             :     }
     222           0 : }
     223             : 
     224           0 : svtools::ColorConfig & SmModule::GetColorConfig()
     225             : {
     226           0 :     if(!pColorConfig)
     227             :     {
     228           0 :         pColorConfig = new svtools::ColorConfig;
     229           0 :         ApplyColorConfigValues( *pColorConfig );
     230           0 :         pColorConfig->AddListener(this);
     231             :     }
     232           0 :     return *pColorConfig;
     233             : }
     234             : 
     235           0 : void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
     236             : {
     237           0 :     ApplyColorConfigValues(*pColorConfig);
     238           0 : }
     239             : 
     240           0 : SmConfig * SmModule::GetConfig()
     241             : {
     242           0 :     if(!pConfig)
     243           0 :         pConfig = new SmConfig;
     244           0 :     return pConfig;
     245             : }
     246             : 
     247           0 : SmSymbolManager & SmModule::GetSymbolManager()
     248             : {
     249           0 :     return GetConfig()->GetSymbolManager();
     250             : }
     251             : 
     252           0 : SmLocalizedSymbolData & SmModule::GetLocSymbolData() const
     253             : {
     254           0 :     if (!pLocSymbolData)
     255           0 :         ((SmModule *) this)->pLocSymbolData = new SmLocalizedSymbolData;
     256           0 :     return *pLocSymbolData;
     257             : }
     258             : 
     259           0 : void SmModule::GetState(SfxItemSet &rSet)
     260             : {
     261           0 :     SfxWhichIter aIter(rSet);
     262             : 
     263           0 :     for (sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
     264           0 :         switch (nWh)
     265             :         {
     266             :             case SID_CONFIGEVENT :
     267           0 :                 rSet.DisableItem(SID_CONFIGEVENT);
     268           0 :                 break;
     269           0 :         }
     270           0 : }
     271             : 
     272           0 : SfxItemSet*  SmModule::CreateItemSet( sal_uInt16 nId )
     273             : {
     274           0 :     SfxItemSet*  pRet = 0;
     275           0 :     if(nId == SID_SM_EDITOPTIONS)
     276             :     {
     277           0 :         pRet = new SfxItemSet(GetPool(),
     278             :                              //TP_SMPRINT
     279             :                              SID_PRINTSIZE,         SID_PRINTSIZE,
     280             :                              SID_PRINTZOOM,         SID_PRINTZOOM,
     281             :                              SID_PRINTTITLE,        SID_PRINTTITLE,
     282             :                              SID_PRINTTEXT,         SID_PRINTTEXT,
     283             :                              SID_PRINTFRAME,        SID_PRINTFRAME,
     284             :                              SID_NO_RIGHT_SPACES,   SID_NO_RIGHT_SPACES,
     285             :                              SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
     286           0 :                              0 );
     287             : 
     288           0 :             GetConfig()->ConfigToItemSet(*pRet);
     289             :     }
     290           0 :     return pRet;
     291             : }
     292           0 : void SmModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
     293             : {
     294           0 :     if(nId == SID_SM_EDITOPTIONS)
     295             :     {
     296           0 :         GetConfig()->ItemSetToConfig(rSet);
     297             :     }
     298           0 : }
     299           0 : SfxTabPage*  SmModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
     300             : {
     301           0 :     SfxTabPage*  pRet = 0;
     302           0 :     if(nId == SID_SM_TP_PRINTOPTIONS)
     303           0 :         pRet = SmPrintOptionsTabPage::Create( pParent, rSet );
     304           0 :     return pRet;
     305             : 
     306           0 : }
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10