LCOV - code coverage report
Current view: top level - starmath/source - smmod.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 166 50.6 %
Date: 2012-08-25 Functions: 24 35 68.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 80 246 32.5 %

           Branch data     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 [ -  + ][ +  - ]:        204 : TYPEINIT1( SmModule, SfxModule );
      45                 :            : 
      46                 :            : #define SmModule
      47                 :            : #include "smslots.hxx"
      48                 :            : 
      49                 :            : #include <svx/xmlsecctrl.hxx>
      50                 :            : 
      51                 :            : 
      52                 :            : 
      53                 :       4978 : SmResId::SmResId( sal_uInt16 nId )
      54                 :       4978 :     : ResId(nId, *SM_MOD()->GetResMgr())
      55                 :            : {
      56                 :       4978 : }
      57                 :            : 
      58                 :            : /////////////////////////////////////////////////////////////////
      59                 :            : 
      60                 :         12 : 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                 :            :     aExportSymbolSetNamesAry( SmResId(RID_EXPORT_SYMBOLSET_NAMES) ),
      66                 :            :     p50NamesAry             ( 0 ),
      67                 :            :     p60NamesAry             ( 0 ),
      68                 :            :     n50NamesLang            ( LANGUAGE_NONE ),
      69 [ +  - ][ +  - ]:         12 :     n60NamesLang            ( LANGUAGE_NONE )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      70                 :            : {
      71         [ +  - ]:         12 :     FreeResource();
      72                 :         12 : }
      73                 :            : 
      74                 :            : 
      75 [ +  - ][ +  - ]:          6 : SmLocalizedSymbolData::~SmLocalizedSymbolData()
         [ +  - ][ +  - ]
      76                 :            : {
      77 [ -  + ][ #  # ]:          6 :     delete p50NamesAry;
      78 [ -  + ][ #  # ]:          6 :     delete p60NamesAry;
      79                 :          6 : }
      80                 :            : 
      81                 :            : 
      82                 :        396 : const String SmLocalizedSymbolData::GetUiSymbolName( const String &rExportName ) const
      83                 :            : {
      84                 :        396 :     String aRes;
      85                 :            : 
      86 [ +  - ][ +  - ]:        396 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
      87                 :        396 :     const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
      88                 :        396 :     const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
      89                 :        396 :     sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count());
      90 [ +  - ][ +  - ]:      13266 :     for (sal_uInt16 i = 0;  i < nCount  &&  !aRes.Len();  ++i)
                 [ +  - ]
      91                 :            :     {
      92 [ +  - ][ +  - ]:      13266 :         if (rExportNames.GetString(i).equals(rExportName))
                 [ +  + ]
      93                 :            :         {
      94 [ +  - ][ +  - ]:        396 :             aRes = rUiNames.GetString(i);
      95                 :        396 :             break;
      96                 :            :         }
      97                 :            :     }
      98                 :            : 
      99                 :        396 :     return aRes;
     100                 :            : }
     101                 :            : 
     102                 :            : 
     103                 :          0 : const String SmLocalizedSymbolData::GetExportSymbolName( const String &rUiName ) const
     104                 :            : {
     105                 :          0 :     String aRes;
     106                 :            : 
     107 [ #  # ][ #  # ]:          0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     108                 :          0 :     const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
     109                 :          0 :     const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
     110                 :          0 :     sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count());
     111 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 i = 0;  i < nCount  &&  !aRes.Len();  ++i)
                 [ #  # ]
     112                 :            :     {
     113 [ #  # ][ #  # ]:          0 :         if (rUiNames.GetString(i).equals(rUiName))
                 [ #  # ]
     114                 :            :         {
     115 [ #  # ][ #  # ]:          0 :             aRes = rExportNames.GetString(i);
     116                 :          0 :             break;
     117                 :            :         }
     118                 :            :     }
     119                 :            : 
     120                 :          0 :     return aRes;
     121                 :            : }
     122                 :            : 
     123                 :            : 
     124                 :        402 : const String SmLocalizedSymbolData::GetUiSymbolSetName( const String &rExportName ) const
     125                 :            : {
     126                 :        402 :     String aRes;
     127                 :            : 
     128 [ +  - ][ +  - ]:        402 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     129                 :        402 :     const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
     130                 :        402 :     const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
     131                 :        402 :     sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count());
     132 [ +  - ][ +  - ]:        474 :     for (sal_uInt16 i = 0;  i < nCount  &&  !aRes.Len();  ++i)
                 [ +  - ]
     133                 :            :     {
     134 [ +  - ][ +  - ]:        474 :         if (rExportNames.GetString(i).equals(rExportName))
                 [ +  + ]
     135                 :            :         {
     136 [ +  - ][ +  - ]:        402 :             aRes = rUiNames.GetString(i);
     137                 :        402 :             break;
     138                 :            :         }
     139                 :            :     }
     140                 :            : 
     141                 :        402 :     return aRes;
     142                 :            : }
     143                 :            : 
     144                 :            : 
     145                 :          0 : const String SmLocalizedSymbolData::GetExportSymbolSetName( const String &rUiName ) const
     146                 :            : {
     147                 :          0 :     String aRes;
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 :     const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
     150                 :          0 :     const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
     151                 :          0 :     const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
     152                 :          0 :     sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count());
     153 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 i = 0;  i < nCount  &&  !aRes.Len();  ++i)
                 [ #  # ]
     154                 :            :     {
     155 [ #  # ][ #  # ]:          0 :         if (rUiNames.GetString(i).equals(rUiName))
                 [ #  # ]
     156                 :            :         {
     157 [ #  # ][ #  # ]:          0 :             aRes = rExportNames.GetString(i);
     158                 :          0 :             break;
     159                 :            :         }
     160                 :            :     }
     161                 :            : 
     162                 :          0 :     return aRes;
     163                 :            : }
     164                 :            : 
     165                 :            : 
     166                 :          0 : const ResStringArray* SmLocalizedSymbolData::Get50NamesArray( LanguageType nLang )
     167                 :            : {
     168         [ #  # ]:          0 :     if (nLang != n50NamesLang)
     169                 :            :     {
     170                 :            :         int nRID;
     171   [ #  #  #  #  :          0 :         switch (nLang)
                      # ]
     172                 :            :         {
     173                 :          0 :             case LANGUAGE_FRENCH    : nRID = RID_FRENCH_50_NAMES;  break;
     174                 :          0 :             case LANGUAGE_ITALIAN   : nRID = RID_ITALIAN_50_NAMES;  break;
     175                 :          0 :             case LANGUAGE_SWEDISH   : nRID = RID_SWEDISH_50_NAMES;  break;
     176                 :          0 :             case LANGUAGE_SPANISH   : nRID = RID_SPANISH_50_NAMES;  break;
     177                 :          0 :             default                 : nRID = -1;  break;
     178                 :            :         }
     179         [ #  # ]:          0 :         delete p50NamesAry;
     180                 :          0 :         p50NamesAry = 0;
     181                 :          0 :         n50NamesLang = nLang;
     182         [ #  # ]:          0 :         if (-1 != nRID)
     183         [ #  # ]:          0 :             p50NamesAry = new SmNamesArray( n50NamesLang, nRID );
     184                 :            :     }
     185                 :            : 
     186         [ #  # ]:          0 :     return p50NamesAry ? &p50NamesAry->GetNamesArray() : 0;
     187                 :            : }
     188                 :            : 
     189                 :            : 
     190                 :          0 : const ResStringArray* SmLocalizedSymbolData::Get60NamesArray( LanguageType nLang )
     191                 :            : {
     192         [ #  # ]:          0 :     if (nLang != n60NamesLang)
     193                 :            :     {
     194                 :            :         int nRID;
     195   [ #  #  #  #  :          0 :         switch (nLang)
                      # ]
     196                 :            :         {
     197                 :          0 :             case LANGUAGE_FRENCH    : nRID = RID_FRENCH_60_NAMES;  break;
     198                 :          0 :             case LANGUAGE_ITALIAN   : nRID = RID_ITALIAN_60_NAMES;  break;
     199                 :          0 :             case LANGUAGE_SWEDISH   : nRID = RID_SWEDISH_60_NAMES;  break;
     200                 :          0 :             case LANGUAGE_SPANISH   : nRID = RID_SPANISH_60_NAMES;  break;
     201                 :          0 :             default                 : nRID = -1;  break;
     202                 :            :         }
     203         [ #  # ]:          0 :         delete p60NamesAry;
     204                 :          0 :         p60NamesAry = 0;
     205                 :          0 :         n60NamesLang = nLang;
     206         [ #  # ]:          0 :         if (-1 != nRID)
     207         [ #  # ]:          0 :             p60NamesAry = new SmNamesArray( n60NamesLang, nRID );
     208                 :            :     }
     209                 :            : 
     210         [ #  # ]:          0 :     return p60NamesAry ? &p60NamesAry->GetNamesArray() : 0;
     211                 :            : }
     212                 :            : 
     213                 :            : /////////////////////////////////////////////////////////////////
     214                 :            : 
     215 [ +  + ][ +  - ]:        414 : SFX_IMPL_INTERFACE(SmModule, SfxModule, SmResId(RID_APPLICATION))
         [ +  - ][ +  - ]
     216                 :            : {
     217 [ +  - ][ +  - ]:         10 :     SFX_STATUSBAR_REGISTRATION(SmResId(RID_STATUSBAR));
     218                 :         10 : }
     219                 :            : 
     220                 :            : 
     221                 :         10 : SmModule::SmModule(SfxObjectFactory* pObjFact) :
     222                 :            :     SfxModule(SfxApplication::CreateResManager("sm"), sal_False, pObjFact, NULL),
     223                 :            :     pColorConfig( 0 ),
     224                 :            :     pConfig( 0 ),
     225                 :            :     pLocSymbolData( 0 ),
     226                 :            :     pSysLocale( 0 ),
     227                 :         10 :     pVirtualDev( 0 )
     228                 :            : {
     229 [ +  - ][ +  - ]:         10 :     SetName(rtl::OUString("StarMath"));
                 [ +  - ]
     230                 :            : 
     231         [ +  - ]:         10 :     SvxModifyControl::RegisterControl(SID_DOC_MODIFIED, this);
     232                 :         10 : }
     233                 :            : 
     234                 :            : 
     235         [ +  - ]:          4 : SmModule::~SmModule()
     236                 :            : {
     237 [ +  - ][ +  - ]:          4 :     delete pConfig;
     238         [ +  - ]:          4 :     if (pColorConfig)
     239         [ +  - ]:          4 :         pColorConfig->RemoveListener(this);
     240 [ +  - ][ +  - ]:          4 :     delete pColorConfig;
     241 [ -  + ][ #  # ]:          4 :     delete pLocSymbolData;
     242 [ +  - ][ +  - ]:          4 :     delete pSysLocale;
     243 [ +  - ][ +  - ]:          4 :     delete pVirtualDev;
     244         [ -  + ]:          8 : }
     245                 :            : 
     246                 :         10 : void SmModule::_CreateSysLocale() const
     247                 :            : {
     248                 :         10 :     SmModule* pThis = (SmModule*)this;
     249         [ +  - ]:         10 :     pThis->pSysLocale = new SvtSysLocale;
     250                 :         10 : }
     251                 :            : 
     252                 :         10 : void SmModule::_CreateVirtualDev() const
     253                 :            : {
     254                 :         10 :     SmModule* pThis = (SmModule*)this;
     255         [ +  - ]:         10 :     pThis->pVirtualDev = new VirtualDevice;
     256                 :         10 :     pThis->pVirtualDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
     257                 :         10 : }
     258                 :            : 
     259                 :         10 : void SmModule::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg )
     260                 :            : {
     261                 :            :     //invalidate all graphic and edit windows
     262                 :         10 :     const TypeId aSmViewTypeId = TYPE(SmViewShell);
     263                 :         10 :     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     264         [ +  + ]:         36 :     while (pViewShell)
     265                 :            :     {
     266         [ -  + ]:         26 :         if ((pViewShell->IsA(aSmViewTypeId)))
     267                 :            :         {
     268                 :          0 :             SmViewShell *pSmView = (SmViewShell *) pViewShell;
     269                 :          0 :             pSmView->GetGraphicWindow().ApplyColorConfigValues( rColorCfg );
     270                 :          0 :             SmEditWindow *pEditWin = pSmView->GetEditWindow();
     271         [ #  # ]:          0 :             if (pEditWin)
     272                 :          0 :                 pEditWin->ApplyColorConfigValues( rColorCfg );
     273                 :            :         }
     274                 :         26 :         pViewShell = SfxViewShell::GetNext( *pViewShell );
     275                 :            :     }
     276                 :         10 : }
     277                 :            : 
     278                 :      91893 : svtools::ColorConfig & SmModule::GetColorConfig()
     279                 :            : {
     280         [ +  + ]:      91893 :     if(!pColorConfig)
     281                 :            :     {
     282         [ +  - ]:         10 :         pColorConfig = new svtools::ColorConfig;
     283                 :         10 :         ApplyColorConfigValues( *pColorConfig );
     284                 :         10 :         pColorConfig->AddListener(this);
     285                 :            :     }
     286                 :      91893 :     return *pColorConfig;
     287                 :            : }
     288                 :            : 
     289                 :          0 : void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
     290                 :            : {
     291                 :          0 :     ApplyColorConfigValues(*pColorConfig);
     292                 :          0 : }
     293                 :            : 
     294                 :       6541 : SmConfig * SmModule::GetConfig()
     295                 :            : {
     296         [ +  + ]:       6541 :     if(!pConfig)
     297         [ +  - ]:         10 :         pConfig = new SmConfig;
     298                 :       6541 :     return pConfig;
     299                 :            : }
     300                 :            : 
     301                 :       4260 : SmSymbolManager & SmModule::GetSymbolManager()
     302                 :            : {
     303                 :       4260 :     return GetConfig()->GetSymbolManager();
     304                 :            : }
     305                 :            : 
     306                 :       1590 : SmLocalizedSymbolData & SmModule::GetLocSymbolData() const
     307                 :            : {
     308         [ +  + ]:       1590 :     if (!pLocSymbolData)
     309         [ +  - ]:          6 :         ((SmModule *) this)->pLocSymbolData = new SmLocalizedSymbolData;
     310                 :       1590 :     return *pLocSymbolData;
     311                 :            : }
     312                 :            : 
     313                 :          0 : void SmModule::GetState(SfxItemSet &rSet)
     314                 :            : {
     315         [ #  # ]:          0 :     SfxWhichIter aIter(rSet);
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
                 [ #  # ]
     318         [ #  # ]:          0 :         switch (nWh)
     319                 :            :         {
     320                 :            :             case SID_CONFIGEVENT :
     321         [ #  # ]:          0 :                 rSet.DisableItem(SID_CONFIGEVENT);
     322                 :          0 :                 break;
     323         [ #  # ]:          0 :         }
     324                 :          0 : }
     325                 :            : 
     326                 :          0 : SfxItemSet*  SmModule::CreateItemSet( sal_uInt16 nId )
     327                 :            : {
     328                 :          0 :     SfxItemSet*  pRet = 0;
     329         [ #  # ]:          0 :     if(nId == SID_SM_EDITOPTIONS)
     330                 :            :     {
     331                 :          0 :         pRet = new SfxItemSet(GetPool(),
     332                 :            :                              //TP_SMPRINT
     333                 :            :                              SID_PRINTSIZE,         SID_PRINTSIZE,
     334                 :            :                              SID_PRINTZOOM,         SID_PRINTZOOM,
     335                 :            :                              SID_PRINTTITLE,        SID_PRINTTITLE,
     336                 :            :                              SID_PRINTTEXT,         SID_PRINTTEXT,
     337                 :            :                              SID_PRINTFRAME,        SID_PRINTFRAME,
     338                 :            :                              SID_NO_RIGHT_SPACES,   SID_NO_RIGHT_SPACES,
     339                 :            :                              SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
     340         [ #  # ]:          0 :                              0 );
     341                 :            : 
     342                 :          0 :             GetConfig()->ConfigToItemSet(*pRet);
     343                 :            :     }
     344                 :          0 :     return pRet;
     345                 :            : }
     346                 :          0 : void SmModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
     347                 :            : {
     348         [ #  # ]:          0 :     if(nId == SID_SM_EDITOPTIONS)
     349                 :            :     {
     350                 :          0 :         GetConfig()->ItemSetToConfig(rSet);
     351                 :            :     }
     352                 :          0 : }
     353                 :          0 : SfxTabPage*  SmModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
     354                 :            : {
     355                 :          0 :     SfxTabPage*  pRet = 0;
     356         [ #  # ]:          0 :     if(nId == SID_SM_TP_PRINTOPTIONS)
     357                 :          0 :         pRet = SmPrintOptionsTabPage::Create( pParent, rSet );
     358                 :          0 :     return pRet;
     359                 :            : 
     360 [ +  - ][ +  - ]:         30 : }
     361                 :            : 
     362                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10