LCOV - code coverage report
Current view: top level - sc/source/core/tool - adiasync.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 60 18.3 %
Date: 2012-08-25 Functions: 5 10 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 103 4.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <sfx2/objsh.hxx>
      30                 :            : 
      31                 :            : #include "adiasync.hxx"
      32                 :            : #include "brdcst.hxx"
      33                 :            : #include "global.hxx"
      34                 :            : #include "document.hxx"
      35                 :            : #include "sc.hrc"       // FID_DATACHANGED
      36                 :            : #include <osl/thread.h>
      37                 :            : 
      38                 :            : 
      39                 :            : //------------------------------------------------------------------------
      40                 :            : 
      41                 :         51 : ScAddInAsyncs theAddInAsyncTbl;
      42                 :         51 : static ScAddInAsync aSeekObj;
      43                 :            : 
      44                 :            : 
      45                 :            : extern "C" {
      46                 :          0 : void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData )
      47                 :            : {
      48                 :          0 :     ScAddInAsync::CallBack( sal_uLong( nHandle ), pData );
      49                 :          0 : }
      50                 :            : }
      51                 :            : 
      52                 :            : 
      53                 :            : 
      54                 :         51 : ScAddInAsync::ScAddInAsync() :
      55                 :            :     SvtBroadcaster(),
      56                 :         51 :     nHandle( 0 )
      57                 :            : {   // nur fuer aSeekObj !
      58                 :         51 : }
      59                 :            : 
      60                 :            : 
      61                 :            : 
      62                 :          0 : ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, FuncData* pFuncData, ScDocument* pDoc) :
      63                 :            :     SvtBroadcaster(),
      64                 :            :     pStr( NULL ),
      65                 :            :     mpFuncData(pFuncData),
      66                 :            :     nHandle( nHandleP ),
      67                 :          0 :     meType(pFuncData->GetAsyncType()),
      68                 :          0 :     bValid( false )
      69                 :            : {
      70 [ #  # ][ #  # ]:          0 :     pDocs = new ScAddInDocs();
      71         [ #  # ]:          0 :     pDocs->insert( pDoc );
      72         [ #  # ]:          0 :     theAddInAsyncTbl.insert( this );
      73                 :          0 : }
      74                 :            : 
      75                 :            : 
      76                 :            : 
      77                 :         51 : ScAddInAsync::~ScAddInAsync()
      78                 :            : {
      79                 :            :     // aSeekObj hat das alles nicht, Handle 0 gibt es sonst nicht
      80         [ -  + ]:         51 :     if ( nHandle )
      81                 :            :     {
      82                 :            :         // im dTor wg. theAddInAsyncTbl.DeleteAndDestroy in ScGlobal::Clear
      83         [ #  # ]:          0 :         mpFuncData->Unadvice( (double)nHandle );
      84 [ #  # ][ #  # ]:          0 :         if ( meType == PTR_STRING && pStr )      // mit Typvergleich wg. Union!
      85 [ #  # ][ #  # ]:          0 :             delete pStr;
      86         [ #  # ]:          0 :         delete pDocs;
      87                 :            :     }
      88         [ -  + ]:         51 : }
      89                 :            : 
      90                 :            : 
      91                 :            : 
      92                 :          0 : ScAddInAsync* ScAddInAsync::Get( sal_uLong nHandleP )
      93                 :            : {
      94                 :          0 :     ScAddInAsync* pRet = 0;
      95                 :          0 :     aSeekObj.nHandle = nHandleP;
      96         [ #  # ]:          0 :     ScAddInAsyncs::iterator it = theAddInAsyncTbl.find( &aSeekObj );
      97         [ #  # ]:          0 :     if ( it != theAddInAsyncTbl.end() )
      98                 :          0 :         pRet = *it;
      99                 :          0 :     aSeekObj.nHandle = 0;
     100                 :          0 :     return pRet;
     101                 :            : }
     102                 :            : 
     103                 :            : 
     104                 :            : 
     105                 :          0 : void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
     106                 :            : {
     107                 :            :     ScAddInAsync* p;
     108 [ #  # ][ #  # ]:          0 :     if ( (p = Get( nHandleP )) == NULL )
     109                 :            :         return;
     110                 :            :     // keiner mehr dran? Unadvice und weg damit
     111         [ #  # ]:          0 :     if ( !p->HasListeners() )
     112                 :            :     {
     113                 :            :         // nicht im dTor wg. theAddInAsyncTbl.DeleteAndDestroy in ScGlobal::Clear
     114         [ #  # ]:          0 :         theAddInAsyncTbl.erase( p );
     115 [ #  # ][ #  # ]:          0 :         delete p;
     116                 :            :         return ;
     117                 :            :     }
     118      [ #  #  # ]:          0 :     switch ( p->meType )
     119                 :            :     {
     120                 :            :         case PTR_DOUBLE :
     121                 :          0 :             p->nVal = *(double*)pData;
     122                 :          0 :             break;
     123                 :            :         case PTR_STRING :
     124         [ #  # ]:          0 :             if ( p->pStr )
     125 [ #  # ][ #  # ]:          0 :                 *p->pStr = String( (sal_Char*)pData, osl_getThreadTextEncoding() );
         [ #  # ][ #  # ]
     126                 :            :             else
     127 [ #  # ][ #  # ]:          0 :                 p->pStr = new String( (sal_Char*)pData, osl_getThreadTextEncoding() );
                 [ #  # ]
     128                 :          0 :             break;
     129                 :            :         default :
     130                 :            :             OSL_FAIL( "unbekannter AsyncType" );
     131                 :            :             return;
     132                 :            :     }
     133                 :          0 :     p->bValid = sal_True;
     134 [ #  # ][ #  # ]:          0 :     p->Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) );
                 [ #  # ]
     135                 :            : 
     136         [ #  # ]:          0 :     for ( ScAddInDocs::iterator it = p->pDocs->begin(); it != p->pDocs->end(); ++it )
     137                 :            :     {
     138                 :          0 :         ScDocument* pDoc = *it;
     139         [ #  # ]:          0 :         pDoc->TrackFormulas();
     140 [ #  # ][ #  # ]:          0 :         pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
                 [ #  # ]
     141                 :            :     }
     142                 :            : }
     143                 :            : 
     144                 :            : 
     145                 :            : 
     146                 :       1611 : void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
     147                 :            : {
     148         [ -  + ]:       1611 :     if ( !theAddInAsyncTbl.empty() )
     149                 :            :     {
     150 [ #  # ][ #  # ]:          0 :         for( ScAddInAsyncs::reverse_iterator iter1 = theAddInAsyncTbl.rbegin(); iter1 != theAddInAsyncTbl.rend(); ++iter1 )
                 [ #  # ]
     151                 :            :         {   // rueckwaerts wg. Pointer-Aufrueckerei im Array
     152         [ #  # ]:          0 :             ScAddInAsync* pAsync = *iter1;
     153                 :          0 :             ScAddInDocs* p = pAsync->pDocs;
     154         [ #  # ]:          0 :             ScAddInDocs::iterator iter2 = p->find( pDocumentP );
     155         [ #  # ]:          0 :             if( iter2 != p->end() )
     156                 :            :             {
     157         [ #  # ]:          0 :                 p->erase( iter2 );
     158         [ #  # ]:          0 :                 if ( p->empty() )
     159                 :            :                 {   // dieses AddIn wird nicht mehr benutzt
     160         [ #  # ]:          0 :                     theAddInAsyncTbl.erase( --(iter1.base()) );
     161 [ #  # ][ #  # ]:          0 :                     delete pAsync;
     162                 :            :                 }
     163                 :            :             }
     164                 :            :         }
     165                 :            :     }
     166 [ +  - ][ +  - ]:       1764 : }
     167                 :            : 
     168                 :            : 
     169                 :            : 
     170                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10