LCOV - code coverage report
Current view: top level - unotools/source/config - itemholder1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 90 108 83.3 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 84 168 50.0 %

           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                 :            : 
      21                 :            : #include "itemholder1.hxx"
      22                 :            : 
      23                 :            : #include <comphelper/processfactory.hxx>
      24                 :            : #include <com/sun/star/lang/XComponent.hpp>
      25                 :            : 
      26                 :            : #include <unotools/misccfg.hxx>
      27                 :            : #include <unotools/useroptions.hxx>
      28                 :            : #include <unotools/accelcfg.hxx>
      29                 :            : #include <unotools/cmdoptions.hxx>
      30                 :            : #include <unotools/compatibility.hxx>
      31                 :            : #include <unotools/defaultoptions.hxx>
      32                 :            : #include <unotools/dynamicmenuoptions.hxx>
      33                 :            : #include <unotools/eventcfg.hxx>
      34                 :            : #include <unotools/extendedsecurityoptions.hxx>
      35                 :            : #include <unotools/fltrcfg.hxx>
      36                 :            : #include <unotools/fontoptions.hxx>
      37                 :            : #include <unotools/historyoptions.hxx>
      38                 :            : #include <unotools/internaloptions.hxx>
      39                 :            : #include <unotools/lingucfg.hxx>
      40                 :            : #include <unotools/localisationoptions.hxx>
      41                 :            : #include <unotools/moduleoptions.hxx>
      42                 :            : #include <unotools/pathoptions.hxx>
      43                 :            : #include <unotools/printwarningoptions.hxx>
      44                 :            : #include <unotools/optionsdlg.hxx>
      45                 :            : #include <unotools/saveopt.hxx>
      46                 :            : #include <unotools/searchopt.hxx>
      47                 :            : #include <unotools/securityoptions.hxx>
      48                 :            : #include <unotools/startoptions.hxx>
      49                 :            : #include <unotools/viewoptions.hxx>
      50                 :            : #include <unotools/workingsetoptions.hxx>
      51                 :            : #include <unotools/xmlaccelcfg.hxx>
      52                 :            : #include <unotools/options.hxx>
      53                 :            : #include <unotools/syslocaleoptions.hxx>
      54                 :            : 
      55                 :            : //-----------------------------------------------
      56                 :            : // namespaces
      57                 :            : 
      58                 :            : namespace css = ::com::sun::star;
      59                 :            : 
      60                 :            : 
      61                 :            : //-----------------------------------------------
      62                 :        266 : ItemHolder1::ItemHolder1()
      63 [ +  - ][ +  - ]:        266 :     : ItemHolderMutexBase()
      64                 :            : {
      65                 :            :     try
      66                 :            :     {
      67         [ +  - ]:        266 :         css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
      68                 :            :         css::uno::Reference< css::lang::XComponent > xCfg(
      69         [ +  - ]:        266 :             xSMGR->createInstance(::rtl::OUString("com.sun.star.configuration.ConfigurationProvider")),
      70 [ +  - ][ +  - ]:        266 :             css::uno::UNO_QUERY);
      71         [ +  - ]:        266 :         if (xCfg.is())
      72 [ +  - ][ +  - ]:        266 :             xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this));
         [ +  - ][ #  # ]
      73                 :            :     }
      74                 :            : #ifdef DBG_UTIL
      75                 :            :     catch(const css::uno::Exception& rEx)
      76                 :            :     {
      77                 :            :         static sal_Bool bMessage = sal_True;
      78                 :            :         if(bMessage)
      79                 :            :         {
      80                 :            :             bMessage = sal_False;
      81                 :            :             ::rtl::OString sMsg("CreateInstance with arguments exception: ");
      82                 :            :             sMsg += ::rtl::OString(rEx.Message.getStr(),
      83                 :            :                         rEx.Message.getLength(),
      84                 :            :                         RTL_TEXTENCODING_ASCII_US);
      85                 :            :             OSL_FAIL(sMsg.getStr());
      86                 :            :         }
      87                 :            :     }
      88                 :            : #else
      89         [ #  # ]:          0 :     catch(css::uno::Exception&){}
      90                 :            : #endif
      91                 :        266 : }
      92                 :            : 
      93                 :            : //-----------------------------------------------
      94         [ +  - ]:        266 : ItemHolder1::~ItemHolder1()
      95                 :            : {
      96         [ +  - ]:        266 :     impl_releaseAllItems();
      97         [ -  + ]:        532 : }
      98                 :            : 
      99                 :            : //-----------------------------------------------
     100                 :       3720 : void ItemHolder1::holdConfigItem(EItem eItem)
     101                 :            : {
     102 [ +  + ][ +  - ]:       3720 :     static ItemHolder1* pHolder = new ItemHolder1();
         [ +  - ][ #  # ]
     103                 :       3720 :     pHolder->impl_addItem(eItem);
     104                 :       3720 : }
     105                 :            : 
     106                 :            : //-----------------------------------------------
     107                 :        266 : void SAL_CALL ItemHolder1::disposing(const css::lang::EventObject&)
     108                 :            :     throw(css::uno::RuntimeException)
     109                 :            : {
     110         [ +  - ]:        266 :     css::uno::Reference< css::uno::XInterface > xSelfHold(static_cast< css::lang::XEventListener* >(this), css::uno::UNO_QUERY);
     111         [ +  - ]:        266 :     impl_releaseAllItems();
     112                 :        266 : }
     113                 :            : 
     114                 :            : //-----------------------------------------------
     115                 :       3720 : void ItemHolder1::impl_addItem(EItem eItem)
     116                 :            : {
     117         [ +  - ]:       3720 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     118                 :            : 
     119                 :       3720 :     TItems::const_iterator pIt;
     120 [ +  - ][ +  - ]:      63112 :     for (  pIt  = m_lItems.begin();
                 [ +  + ]
     121                 :      31556 :            pIt != m_lItems.end()  ;
     122                 :            :          ++pIt                    )
     123                 :            :     {
     124                 :      27836 :         const TItemInfo& rInfo = *pIt;
     125         [ -  + ]:      27836 :         if (rInfo.eItem == eItem)
     126                 :       3720 :             return;
     127                 :            :     }
     128                 :            : 
     129                 :       3720 :     TItemInfo aNewItem;
     130                 :       3720 :     aNewItem.eItem = eItem;
     131         [ +  - ]:       3720 :     impl_newItem(aNewItem);
     132         [ +  + ]:       3720 :     if (aNewItem.pItem)
     133 [ +  - ][ +  - ]:       3720 :         m_lItems.push_back(aNewItem);
                 [ +  - ]
     134                 :            : }
     135                 :            : 
     136                 :            : //-----------------------------------------------
     137                 :        532 : void ItemHolder1::impl_releaseAllItems()
     138                 :            : {
     139         [ +  - ]:        532 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     140                 :            : 
     141                 :        532 :     TItems::iterator pIt;
     142 [ +  - ][ +  + ]:       7966 :     for (  pIt  = m_lItems.begin();
     143                 :       3983 :            pIt != m_lItems.end()  ;
     144                 :            :          ++pIt                    )
     145                 :            :     {
     146                 :       3451 :         TItemInfo& rInfo = *pIt;
     147         [ +  - ]:       3451 :         impl_deleteItem(rInfo);
     148                 :            :     }
     149         [ +  - ]:        532 :     m_lItems.clear();
     150                 :        532 : }
     151                 :            : 
     152                 :            : //-----------------------------------------------
     153                 :       3720 : void ItemHolder1::impl_newItem(TItemInfo& rItem)
     154                 :            : {
     155   [ -  +  +  -  :       3720 :     switch(rItem.eItem)
          +  +  -  -  +  
          +  +  -  +  +  
          +  -  +  -  +  
          +  -  +  +  +  
          +  +  +  -  -  
                +  +  - ]
     156                 :            :     {
     157                 :            :         case E_ACCELCFG :
     158         [ #  # ]:          0 :             rItem.pItem = new SvtAcceleratorConfiguration();
     159                 :          0 :             break;
     160                 :            : 
     161                 :            :         case E_CMDOPTIONS :
     162         [ +  - ]:        233 :             rItem.pItem = new SvtCommandOptions();
     163                 :        233 :             break;
     164                 :            : 
     165                 :            :         case E_COMPATIBILITY :
     166         [ +  - ]:         73 :             rItem.pItem = new SvtCompatibilityOptions();
     167                 :         73 :             break;
     168                 :            : 
     169                 :            :         case E_DEFAULTOPTIONS :
     170         [ #  # ]:          0 :             rItem.pItem = new SvtDefaultOptions();
     171                 :          0 :             break;
     172                 :            : 
     173                 :            :         case E_DYNAMICMENUOPTIONS :
     174         [ +  - ]:         60 :             rItem.pItem = new SvtDynamicMenuOptions();
     175                 :         60 :             break;
     176                 :            : 
     177                 :            :         case E_EVENTCFG :
     178                 :            :             //rItem.pItem = new GlobalEventConfig();
     179                 :        269 :             break;
     180                 :            : 
     181                 :            :         case E_EXTENDEDSECURITYOPTIONS :
     182         [ #  # ]:          0 :             rItem.pItem = new SvtExtendedSecurityOptions();
     183                 :          0 :             break;
     184                 :            : 
     185                 :            :         case E_FLTRCFG :
     186                 :            : // no ref count            rItem.pItem = new SvtFilterOptions();
     187                 :          0 :             break;
     188                 :            : 
     189                 :            :         case E_FONTOPTIONS :
     190         [ +  - ]:         52 :             rItem.pItem = new SvtFontOptions();
     191                 :         52 :             break;
     192                 :            : 
     193                 :            :         case E_HISTORYOPTIONS :
     194         [ +  - ]:        233 :             rItem.pItem = new SvtHistoryOptions();
     195                 :        233 :             break;
     196                 :            : 
     197                 :            :         case E_INTERNALOPTIONS :
     198         [ +  - ]:        233 :             rItem.pItem = new SvtInternalOptions();
     199                 :        233 :             break;
     200                 :            : 
     201                 :            :         case E_JAVAOPTIONS :
     202                 :            : // no ref count            rItem.pItem = new SvtJavaOptions();
     203                 :          0 :             break;
     204                 :            : 
     205                 :            :         case E_LINGUCFG :
     206         [ +  - ]:        139 :             rItem.pItem = new SvtLinguConfig();
     207                 :        139 :             break;
     208                 :            : 
     209                 :            :         case E_LOCALISATIONOPTIONS :
     210         [ +  - ]:        233 :             rItem.pItem = new SvtLocalisationOptions();
     211                 :        233 :             break;
     212                 :            : 
     213                 :            :         case E_MODULEOPTIONS :
     214         [ +  - ]:        131 :             rItem.pItem = new SvtModuleOptions();
     215                 :        131 :             break;
     216                 :            : 
     217                 :            :         case E_OPTIONSDLGOPTIONS :
     218         [ #  # ]:          0 :             rItem.pItem = new SvtOptionsDialogOptions();
     219                 :          0 :             break;
     220                 :            : 
     221                 :            :         case E_PATHOPTIONS :
     222         [ +  - ]:        233 :             rItem.pItem = new SvtPathOptions();
     223                 :        233 :             break;
     224                 :            : 
     225                 :            :         case E_PRINTWARNINGOPTIONS :
     226         [ #  # ]:          0 :             rItem.pItem = new SvtPrintWarningOptions();
     227                 :          0 :             break;
     228                 :            : 
     229                 :            :         case E_MISCCFG :
     230         [ +  - ]:        123 :             rItem.pItem = new ::utl::MiscCfg();
     231                 :        123 :             break;
     232                 :            : 
     233                 :            :         case E_SAVEOPTIONS :
     234         [ +  - ]:        119 :             rItem.pItem = new SvtSaveOptions();
     235                 :        119 :             break;
     236                 :            : 
     237                 :            :         case E_SEARCHOPT :
     238                 :            : // no ref count            rItem.pItem = new SvtSearchOptions();
     239                 :          0 :             break;
     240                 :            : 
     241                 :            :         case E_SECURITYOPTIONS :
     242         [ +  - ]:        128 :             rItem.pItem = new SvtSecurityOptions();
     243                 :        128 :             break;
     244                 :            : 
     245                 :            :         case E_STARTOPTIONS :
     246         [ +  - ]:        158 :             rItem.pItem = new SvtStartOptions();
     247                 :        158 :             break;
     248                 :            : 
     249                 :            :         case E_VIEWOPTIONS_DIALOG :
     250 [ +  - ][ +  - ]:        233 :             rItem.pItem = new SvtViewOptions(E_DIALOG, ::rtl::OUString());
     251                 :        233 :             break;
     252                 :            : 
     253                 :            :         case E_VIEWOPTIONS_TABDIALOG :
     254 [ +  - ][ +  - ]:        233 :             rItem.pItem = new SvtViewOptions(E_TABDIALOG, ::rtl::OUString());
     255                 :        233 :             break;
     256                 :            : 
     257                 :            :         case E_VIEWOPTIONS_TABPAGE :
     258 [ +  - ][ +  - ]:        233 :             rItem.pItem = new SvtViewOptions(E_TABPAGE, ::rtl::OUString());
     259                 :        233 :             break;
     260                 :            : 
     261                 :            :         case E_VIEWOPTIONS_WINDOW :
     262 [ +  - ][ +  - ]:        233 :             rItem.pItem = new SvtViewOptions(E_WINDOW, ::rtl::OUString());
     263                 :        233 :             break;
     264                 :            : 
     265                 :            :         case E_WORKINGSETOPTIONS :
     266         [ #  # ]:          0 :             rItem.pItem = new SvtWorkingSetOptions();
     267                 :          0 :             break;
     268                 :            : 
     269                 :            :         case E_XMLACCELCFG :
     270                 :            :             // ??? TODO
     271                 :          0 :             break;
     272                 :            : 
     273                 :            :         case E_USEROPTIONS :
     274         [ +  - ]:        105 :             rItem.pItem = new SvtUserOptions();
     275                 :        105 :             break;
     276                 :            : 
     277                 :            :         case E_SYSLOCALEOPTIONS :
     278         [ +  - ]:        266 :             rItem.pItem = new SvtSysLocaleOptions();
     279                 :        266 :             break;
     280                 :            : 
     281                 :            :         default:
     282                 :            :             OSL_FAIL( "unknown item type" );
     283                 :          0 :             break;
     284                 :            :     }
     285                 :       3720 : }
     286                 :            : 
     287                 :            : //-----------------------------------------------
     288                 :       3451 : void ItemHolder1::impl_deleteItem(TItemInfo& rItem)
     289                 :            : {
     290         [ +  - ]:       3451 :     if (rItem.pItem)
     291                 :            :     {
     292         [ +  - ]:       3451 :         delete rItem.pItem;
     293                 :       3451 :         rItem.pItem = 0;
     294                 :            :     }
     295                 :       3451 : }
     296                 :            : 
     297                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10