LCOV - code coverage report
Current view: top level - ucb/source/sorter - sortdynres.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 65 231 28.1 %
Date: 2012-08-25 Functions: 24 51 47.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 47 475 9.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                 :            : 
      30                 :            : #include <vector>
      31                 :            : #include <sortdynres.hxx>
      32                 :            : #include <cppuhelper/interfacecontainer.hxx>
      33                 :            : #include <com/sun/star/ucb/ContentResultSetCapability.hpp>
      34                 :            : #include <com/sun/star/ucb/ListActionType.hpp>
      35                 :            : #include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
      36                 :            : #include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
      37                 :            : #include <com/sun/star/ucb/XSourceInitialization.hpp>
      38                 :            : 
      39                 :            : //-----------------------------------------------------------------------------
      40                 :            : using namespace com::sun::star::beans;
      41                 :            : using namespace com::sun::star::lang;
      42                 :            : using namespace com::sun::star::sdbc;
      43                 :            : using namespace com::sun::star::ucb;
      44                 :            : using namespace com::sun::star::uno;
      45                 :            : using namespace cppu;
      46                 :            : 
      47                 :            : using ::rtl::OUString;
      48                 :            : 
      49                 :            : //=========================================================================
      50                 :            : 
      51                 :            : //  The mutex to synchronize access to containers.
      52                 :          0 : static osl::Mutex& getContainerMutex()
      53                 :            : {
      54                 :            :     static osl::Mutex* pMutex = NULL;
      55         [ #  # ]:          0 :     if( !pMutex )
      56                 :            :     {
      57 [ #  # ][ #  # ]:          0 :         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
      58         [ #  # ]:          0 :         if( !pMutex )
      59                 :            :         {
      60 [ #  # ][ #  # ]:          0 :             static osl::Mutex aMutex;
         [ #  # ][ #  # ]
      61                 :          0 :             pMutex = &aMutex;
      62         [ #  # ]:          0 :         }
      63                 :            :     }
      64                 :            : 
      65                 :          0 :     return *pMutex;
      66                 :            : }
      67                 :            : 
      68                 :            : //=========================================================================
      69                 :            : //
      70                 :            : // SortedDynamicResultSet
      71                 :            : //
      72                 :            : //=========================================================================
      73                 :            : 
      74                 :        146 : SortedDynamicResultSet::SortedDynamicResultSet(
      75                 :            :                         const Reference < XDynamicResultSet > &xOriginal,
      76                 :            :                         const Sequence < NumberedSortingInfo > &aOptions,
      77                 :            :                         const Reference < XAnyCompareFactory > &xCompFac,
      78 [ +  - ][ +  - ]:        146 :                         const Reference < XMultiServiceFactory > &xSMgr )
                 [ +  - ]
      79                 :            : {
      80                 :        146 :     mpDisposeEventListeners = NULL;
      81         [ +  - ]:        146 :     mpOwnListener           = new SortedDynamicResultSetListener( this );
      82                 :            : 
      83 [ +  - ][ +  - ]:        146 :     mxOwnListener = Reference< XDynamicResultSetListener >( mpOwnListener );
                 [ +  - ]
      84                 :            : 
      85         [ +  - ]:        146 :     mxOriginal  = xOriginal;
      86         [ +  - ]:        146 :     maOptions   = aOptions;
      87         [ +  - ]:        146 :     mxCompFac   = xCompFac;
      88         [ +  - ]:        146 :     mxSMgr      = xSMgr;
      89                 :            : 
      90                 :        146 :     mpOne = NULL;
      91                 :        146 :     mpTwo = NULL;
      92                 :            : 
      93                 :        146 :     mbGotWelcome    = sal_False;
      94                 :        146 :     mbUseOne        = sal_True;
      95                 :        146 :     mbStatic        = sal_False;
      96                 :        146 : }
      97                 :            : 
      98                 :            : //--------------------------------------------------------------------------
      99 [ +  - ][ +  - ]:        146 : SortedDynamicResultSet::~SortedDynamicResultSet()
                 [ +  - ]
     100                 :            : {
     101         [ +  - ]:        146 :     mpOwnListener->impl_OwnerDies();
     102                 :        146 :     mxOwnListener.clear();
     103                 :            : 
     104 [ #  # ][ -  + ]:        146 :     delete mpDisposeEventListeners;
     105                 :            : 
     106                 :        146 :     mxOne.clear();
     107                 :        146 :     mxTwo.clear();
     108                 :        146 :     mxOriginal.clear();
     109                 :            : 
     110                 :        146 :     mpOne = NULL;
     111                 :        146 :     mpTwo = NULL;
     112         [ -  + ]:        292 : }
     113                 :            : 
     114                 :            : //--------------------------------------------------------------------------
     115                 :            : // XInterface methods.
     116                 :            : //--------------------------------------------------------------------------
     117                 :            : 
     118 [ #  # ][ #  # ]:        584 : XINTERFACE_IMPL_4( SortedDynamicResultSet,
                 [ #  # ]
     119                 :            :                    XTypeProvider,
     120                 :            :                    XServiceInfo,
     121                 :            :                    XComponent,      /* base class of XDynamicResultSet */
     122                 :            :                    XDynamicResultSet );
     123                 :            : 
     124                 :            : //--------------------------------------------------------------------------
     125                 :            : // XTypeProvider methods.
     126                 :            : //--------------------------------------------------------------------------
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 : XTYPEPROVIDER_IMPL_3( SortedDynamicResultSet,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     129                 :            :                       XTypeProvider,
     130                 :            :                          XServiceInfo,
     131                 :            :                       XDynamicResultSet );
     132                 :            : 
     133                 :            : //--------------------------------------------------------------------------
     134                 :            : // XServiceInfo methods.
     135                 :            : //--------------------------------------------------------------------------
     136                 :            : 
     137 [ #  # ][ #  # ]:          0 : XSERVICEINFO_NOFACTORY_IMPL_1( SortedDynamicResultSet,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     138                 :            :                                    OUString( "com.sun.star.comp.ucb.SortedDynamicResultSet" ),
     139                 :            :                                    OUString( DYNAMIC_RESULTSET_SERVICE_NAME ) );
     140                 :            : 
     141                 :            : //--------------------------------------------------------------------------
     142                 :            : // XComponent methods.
     143                 :            : //--------------------------------------------------------------------------
     144                 :          0 : void SAL_CALL SortedDynamicResultSet::dispose()
     145                 :            :     throw( RuntimeException )
     146                 :            : {
     147         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 :     if ( mpDisposeEventListeners && mpDisposeEventListeners->getLength() )
         [ #  # ][ #  # ]
     150                 :            :     {
     151         [ #  # ]:          0 :         EventObject aEvt;
     152         [ #  # ]:          0 :         aEvt.Source = static_cast< XComponent * >( this );
     153 [ #  # ][ #  # ]:          0 :         mpDisposeEventListeners->disposeAndClear( aEvt );
     154                 :            :     }
     155                 :            : 
     156                 :          0 :     mxOne.clear();
     157                 :          0 :     mxTwo.clear();
     158                 :          0 :     mxOriginal.clear();
     159                 :            : 
     160                 :          0 :     mpOne = NULL;
     161                 :          0 :     mpTwo = NULL;
     162         [ #  # ]:          0 :     mbUseOne = sal_True;
     163                 :          0 : }
     164                 :            : 
     165                 :            : //--------------------------------------------------------------------------
     166                 :          0 : void SAL_CALL SortedDynamicResultSet::addEventListener(
     167                 :            :                             const Reference< XEventListener >& Listener )
     168                 :            :     throw( RuntimeException )
     169                 :            : {
     170         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     171                 :            : 
     172         [ #  # ]:          0 :     if ( !mpDisposeEventListeners )
     173                 :            :         mpDisposeEventListeners =
     174 [ #  # ][ #  # ]:          0 :                     new OInterfaceContainerHelper( getContainerMutex() );
     175                 :            : 
     176 [ #  # ][ #  # ]:          0 :     mpDisposeEventListeners->addInterface( Listener );
     177                 :          0 : }
     178                 :            : 
     179                 :            : //--------------------------------------------------------------------------
     180                 :          0 : void SAL_CALL SortedDynamicResultSet::removeEventListener(
     181                 :            :                             const Reference< XEventListener >& Listener )
     182                 :            :     throw( RuntimeException )
     183                 :            : {
     184         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     185                 :            : 
     186         [ #  # ]:          0 :     if ( mpDisposeEventListeners )
     187 [ #  # ][ #  # ]:          0 :         mpDisposeEventListeners->removeInterface( Listener );
     188                 :          0 : }
     189                 :            : 
     190                 :            : //--------------------------------------------------------------------------
     191                 :            : // XDynamicResultSet methods.
     192                 :            : // ------------------------------------------------------------------------------
     193                 :            : Reference< XResultSet > SAL_CALL
     194                 :        146 : SortedDynamicResultSet::getStaticResultSet()
     195                 :            :     throw( ListenerAlreadySetException, RuntimeException )
     196                 :            : {
     197         [ +  - ]:        146 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     198                 :            : 
     199         [ -  + ]:        146 :     if ( mxListener.is() )
     200         [ #  # ]:          0 :         throw ListenerAlreadySetException();
     201                 :            : 
     202                 :        146 :     mbStatic = sal_True;
     203                 :            : 
     204         [ +  - ]:        146 :     if ( mxOriginal.is() )
     205                 :            :     {
     206 [ +  - ][ +  - ]:        146 :         mpOne = new SortedResultSet( mxOriginal->getStaticResultSet() );
                 [ +  - ]
     207 [ +  - ][ +  - ]:        146 :         mxOne = mpOne;
     208         [ +  - ]:        146 :         mpOne->Initialize( maOptions, mxCompFac );
     209                 :            :     }
     210                 :            : 
     211         [ +  - ]:        146 :     return mxOne;
     212                 :            : }
     213                 :            : 
     214                 :            : // ------------------------------------------------------------------------------
     215                 :            : void SAL_CALL
     216                 :          0 : SortedDynamicResultSet::setListener( const Reference< XDynamicResultSetListener >& Listener )
     217                 :            :     throw( ListenerAlreadySetException, RuntimeException )
     218                 :            : {
     219         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     220                 :            : 
     221         [ #  # ]:          0 :     if ( mxListener.is() )
     222         [ #  # ]:          0 :         throw ListenerAlreadySetException();
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :     addEventListener( Reference< XEventListener >::query( Listener ) );
     225                 :            : 
     226         [ #  # ]:          0 :     mxListener = Listener;
     227                 :            : 
     228         [ #  # ]:          0 :     if ( mxOriginal.is() )
     229 [ #  # ][ #  # ]:          0 :         mxOriginal->setListener( mxOwnListener );
                 [ #  # ]
     230                 :          0 : }
     231                 :            : 
     232                 :            : // ------------------------------------------------------------------------------
     233                 :            : void SAL_CALL
     234                 :          0 : SortedDynamicResultSet::connectToCache(
     235                 :            :         const Reference< XDynamicResultSet > & xCache )
     236                 :            :         throw( ListenerAlreadySetException,
     237                 :            :                AlreadyInitializedException,
     238                 :            :                ServiceNotFoundException,
     239                 :            :                RuntimeException )
     240                 :            : {
     241         [ #  # ]:          0 :     if( mxListener.is() )
     242         [ #  # ]:          0 :         throw ListenerAlreadySetException();
     243                 :            : 
     244         [ #  # ]:          0 :     if( mbStatic )
     245         [ #  # ]:          0 :         throw ListenerAlreadySetException();
     246                 :            : 
     247         [ #  # ]:          0 :     Reference< XSourceInitialization > xTarget( xCache, UNO_QUERY );
     248 [ #  # ][ #  # ]:          0 :     if( xTarget.is() && mxSMgr.is() )
                 [ #  # ]
     249                 :            :     {
     250                 :          0 :         Reference< XCachedDynamicResultSetStubFactory > xStubFactory;
     251                 :            :         try
     252                 :            :         {
     253                 :            :             xStubFactory = Reference< XCachedDynamicResultSetStubFactory >(
     254         [ #  # ]:          0 :                 mxSMgr->createInstance(
     255                 :          0 :                     OUString( "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
     256 [ #  # ][ #  # ]:          0 :                 UNO_QUERY );
         [ #  # ][ #  # ]
     257                 :            :         }
     258         [ #  # ]:          0 :         catch ( Exception const & )
     259                 :            :         {
     260                 :            :         }
     261                 :            : 
     262         [ #  # ]:          0 :         if( xStubFactory.is() )
     263                 :            :         {
     264         [ #  # ]:          0 :             xStubFactory->connectToCache(
     265 [ #  # ][ #  # ]:          0 :                   this, xCache, Sequence< NumberedSortingInfo > (), NULL );
         [ #  # ][ #  # ]
                 [ #  # ]
     266                 :          0 :             return;
     267         [ #  # ]:          0 :         }
     268                 :            :     }
     269         [ #  # ]:          0 :     throw ServiceNotFoundException();
     270                 :            : }
     271                 :            : 
     272                 :            : // ------------------------------------------------------------------------------
     273                 :            : sal_Int16 SAL_CALL
     274                 :          0 : SortedDynamicResultSet::getCapabilities()
     275                 :            :     throw( RuntimeException )
     276                 :            : {
     277         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     278                 :            : 
     279                 :          0 :     sal_Int16 nCaps = 0;
     280                 :            : 
     281         [ #  # ]:          0 :     if ( mxOriginal.is() )
     282 [ #  # ][ #  # ]:          0 :         nCaps = mxOriginal->getCapabilities();
     283                 :            : 
     284                 :          0 :     nCaps |= ContentResultSetCapability::SORTED;
     285                 :            : 
     286         [ #  # ]:          0 :     return nCaps;
     287                 :            : }
     288                 :            : 
     289                 :            : //--------------------------------------------------------------------------
     290                 :            : // XDynamicResultSetListener methods.
     291                 :            : // ------------------------------------------------------------------------------
     292                 :            : 
     293                 :            : /** In the first notify-call the listener gets the two
     294                 :            :  <type>XResultSet</type>s and has to hold them. The <type>XResultSet</type>s
     295                 :            :  are implementations of the service <type>ContentResultSet</type>.
     296                 :            : 
     297                 :            :  <p>The notified new <type>XResultSet</type> will stay valid after returning
     298                 :            :  notification. The old one will become invalid after returning notification.
     299                 :            : 
     300                 :            :  <p>While in notify-call the listener is allowed to read old and new version,
     301                 :            :  except in the first call, where only the new Resultset is valid.
     302                 :            : 
     303                 :            :  <p>The Listener is allowed to blockade this call, until he really want to go
     304                 :            :  to the new version. The only situation, where the listener has to return the
     305                 :            :  update call at once is, while he disposes his broadcaster or while he is
     306                 :            :  removing himsef as listener (otherwise you deadlock)!!!
     307                 :            : */
     308                 :            : void SAL_CALL
     309                 :          0 : SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
     310                 :            :     throw( RuntimeException )
     311                 :            : {
     312         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     313                 :            : 
     314                 :          0 :     sal_Bool bHasNew = sal_False;
     315                 :          0 :     sal_Bool bHasModified = sal_False;
     316                 :            : 
     317                 :          0 :     SortedResultSet *pCurSet = NULL;
     318                 :            : 
     319                 :            :     // exchange mxNew and mxOld and immediately afterwards copy the tables
     320                 :            :     // from Old to New
     321         [ #  # ]:          0 :     if ( mbGotWelcome )
     322                 :            :     {
     323         [ #  # ]:          0 :         if ( mbUseOne )
     324                 :            :         {
     325                 :          0 :             mbUseOne = sal_False;
     326         [ #  # ]:          0 :             mpTwo->CopyData( mpOne );
     327                 :          0 :             pCurSet = mpTwo;
     328                 :            :         }
     329                 :            :         else
     330                 :            :         {
     331                 :          0 :             mbUseOne = sal_True;
     332         [ #  # ]:          0 :             mpOne->CopyData( mpTwo );
     333                 :          0 :             pCurSet = mpOne;
     334                 :            :         }
     335                 :            :     }
     336                 :            : 
     337                 :          0 :     Any  aRet;
     338                 :            : 
     339                 :            :     try {
     340      [ #  #  # ]:          0 :         aRet = pCurSet->getPropertyValue( OUString("IsRowCountFinal") );
                 [ #  # ]
     341                 :            :     }
     342         [ #  # ]:          0 :     catch (const UnknownPropertyException&) {}
     343         [ #  # ]:          0 :     catch (const WrappedTargetException&) {}
     344                 :            : 
     345                 :          0 :     long nOldCount = pCurSet->GetCount();
     346                 :          0 :     sal_Bool bWasFinal = false;
     347                 :            : 
     348                 :          0 :     aRet >>= bWasFinal;
     349                 :            : 
     350                 :            :     // handle the actions in the list
     351         [ #  # ]:          0 :     for ( long i=0; i<Changes.Changes.getLength(); i++ )
     352                 :            :     {
     353                 :          0 :         const ListAction aAction = Changes.Changes[i];
     354   [ #  #  #  #  :          0 :         switch ( aAction.ListActionType )
                   #  # ]
     355                 :            :         {
     356                 :            :             case ListActionType::WELCOME:
     357                 :            :                 {
     358         [ #  # ]:          0 :                     WelcomeDynamicResultSetStruct aWelcome;
     359 [ #  # ][ #  # ]:          0 :                     if ( aAction.ActionInfo >>= aWelcome )
     360                 :            :                     {
     361         [ #  # ]:          0 :                         mpTwo = new SortedResultSet( aWelcome.Old );
     362 [ #  # ][ #  # ]:          0 :                         mxTwo = mpTwo;
     363         [ #  # ]:          0 :                         mpOne = new SortedResultSet( aWelcome.New );
     364 [ #  # ][ #  # ]:          0 :                         mxOne = mpOne;
     365         [ #  # ]:          0 :                         mpOne->Initialize( maOptions, mxCompFac );
     366                 :          0 :                         mbGotWelcome = sal_True;
     367                 :          0 :                         mbUseOne = sal_True;
     368                 :          0 :                         pCurSet = mpOne;
     369                 :            : 
     370         [ #  # ]:          0 :                         aWelcome.Old = mxTwo;
     371         [ #  # ]:          0 :                         aWelcome.New = mxOne;
     372                 :            : 
     373         [ #  # ]:          0 :                         ListAction *pWelcomeAction = new ListAction;
     374         [ #  # ]:          0 :                         pWelcomeAction->ActionInfo <<= aWelcome;
     375                 :          0 :                         pWelcomeAction->Position = 0;
     376                 :          0 :                         pWelcomeAction->Count = 0;
     377                 :          0 :                         pWelcomeAction->ListActionType = ListActionType::WELCOME;
     378                 :            : 
     379         [ #  # ]:          0 :                         maActions.Insert( pWelcomeAction );
     380                 :            :                     }
     381                 :            :                     else
     382                 :            :                     {
     383                 :            :                         // throw RuntimeException();
     384                 :            :                     }
     385         [ #  # ]:          0 :                     break;
     386                 :            :                 }
     387                 :            :             case ListActionType::INSERTED:
     388                 :            :                 {
     389         [ #  # ]:          0 :                     pCurSet->InsertNew( aAction.Position, aAction.Count );
     390                 :          0 :                     bHasNew = sal_True;
     391                 :          0 :                     break;
     392                 :            :                 }
     393                 :            :             case ListActionType::REMOVED:
     394                 :            :                 {
     395                 :            :                     pCurSet->Remove( aAction.Position,
     396                 :            :                                      aAction.Count,
     397         [ #  # ]:          0 :                                      &maActions );
     398                 :          0 :                     break;
     399                 :            :                 }
     400                 :            :             case ListActionType::MOVED:
     401                 :            :                 {
     402                 :          0 :                     long nOffset = 0;
     403         [ #  # ]:          0 :                     if ( aAction.ActionInfo >>= nOffset )
     404                 :            :                     {
     405                 :            :                         pCurSet->Move( aAction.Position,
     406                 :            :                                        aAction.Count,
     407         [ #  # ]:          0 :                                        nOffset );
     408                 :            :                     }
     409                 :            :                     break;
     410                 :            :                 }
     411                 :            :             case ListActionType::PROPERTIES_CHANGED:
     412                 :            :                 {
     413         [ #  # ]:          0 :                     pCurSet->SetChanged( aAction.Position, aAction.Count );
     414                 :          0 :                     bHasModified = sal_True;
     415                 :          0 :                     break;
     416                 :            :                 }
     417                 :          0 :             default: break;
     418                 :            :         }
     419                 :          0 :     }
     420                 :            : 
     421         [ #  # ]:          0 :     if ( bHasModified )
     422         [ #  # ]:          0 :         pCurSet->ResortModified( &maActions );
     423                 :            : 
     424         [ #  # ]:          0 :     if ( bHasNew )
     425         [ #  # ]:          0 :         pCurSet->ResortNew( &maActions );
     426                 :            : 
     427                 :            :     // send the new actions with a notify to the listeners
     428         [ #  # ]:          0 :     SendNotify();
     429                 :            : 
     430                 :            :     // check for propertyChangeEvents
     431 [ #  # ][ #  # ]:          0 :     pCurSet->CheckProperties( nOldCount, bWasFinal );
     432                 :          0 : }
     433                 :            : 
     434                 :            : //-----------------------------------------------------------------
     435                 :            : // XEventListener
     436                 :            : //-----------------------------------------------------------------
     437                 :            : void SAL_CALL
     438                 :          0 : SortedDynamicResultSet::impl_disposing( const EventObject& )
     439                 :            :     throw( RuntimeException )
     440                 :            : {
     441                 :          0 :     mxListener.clear();
     442                 :          0 :     mxOriginal.clear();
     443                 :          0 : }
     444                 :            : 
     445                 :            : // ------------------------------------------------------------------------------
     446                 :            : // private methods
     447                 :            : // ------------------------------------------------------------------------------
     448                 :          0 : void SortedDynamicResultSet::SendNotify()
     449                 :            : {
     450                 :          0 :     long nCount = maActions.Count();
     451                 :            : 
     452 [ #  # ][ #  # ]:          0 :     if ( nCount && mxListener.is() )
                 [ #  # ]
     453                 :            :     {
     454         [ #  # ]:          0 :         Sequence< ListAction > aActionList( maActions.Count() );
     455         [ #  # ]:          0 :         ListAction *pActionList = aActionList.getArray();
     456                 :            : 
     457         [ #  # ]:          0 :         for ( long i=0; i<nCount; i++ )
     458                 :            :         {
     459         [ #  # ]:          0 :             pActionList[ i ] = *(maActions.GetAction( i ));
     460                 :            :         }
     461                 :            : 
     462         [ #  # ]:          0 :         ListEvent aNewEvent;
     463         [ #  # ]:          0 :         aNewEvent.Changes = aActionList;
     464                 :            : 
     465 [ #  # ][ #  # ]:          0 :         mxListener->notify( aNewEvent );
         [ #  # ][ #  # ]
     466                 :            :     }
     467                 :            : 
     468                 :            :     // clean up
     469                 :          0 :     maActions.Clear();
     470                 :          0 : }
     471                 :            : 
     472                 :            : //=========================================================================
     473                 :            : //
     474                 :            : // SortedDynamicResultSetFactory
     475                 :            : //
     476                 :            : //=========================================================================
     477                 :         11 : SortedDynamicResultSetFactory::SortedDynamicResultSetFactory(
     478                 :         11 :                         const Reference< XMultiServiceFactory > & rSMgr )
     479                 :            : {
     480         [ +  - ]:         11 :     mxSMgr = rSMgr;
     481                 :         11 : }
     482                 :            : 
     483                 :            : //--------------------------------------------------------------------------
     484                 :         11 : SortedDynamicResultSetFactory::~SortedDynamicResultSetFactory()
     485                 :            : {
     486         [ -  + ]:         22 : }
     487                 :            : 
     488                 :            : //--------------------------------------------------------------------------
     489                 :            : // XInterface methods.
     490                 :            : //--------------------------------------------------------------------------
     491                 :            : 
     492 [ +  - ][ +  + ]:       1110 : XINTERFACE_IMPL_3( SortedDynamicResultSetFactory,
                 [ +  - ]
     493                 :            :                    XTypeProvider,
     494                 :            :                    XServiceInfo,
     495                 :            :                    XSortedDynamicResultSetFactory );
     496                 :            : 
     497                 :            : //--------------------------------------------------------------------------
     498                 :            : // XTypeProvider methods.
     499                 :            : //--------------------------------------------------------------------------
     500                 :            : 
     501 [ #  # ][ #  # ]:          0 : XTYPEPROVIDER_IMPL_3( SortedDynamicResultSetFactory,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     502                 :            :                       XTypeProvider,
     503                 :            :                          XServiceInfo,
     504                 :            :                       XSortedDynamicResultSetFactory );
     505                 :            : 
     506                 :            : //--------------------------------------------------------------------------
     507                 :            : // XServiceInfo methods.
     508                 :            : //--------------------------------------------------------------------------
     509                 :            : 
     510 [ +  - ][ +  - ]:         44 : XSERVICEINFO_IMPL_1( SortedDynamicResultSetFactory,
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     511                 :            :                          OUString( "com.sun.star.comp.ucb.SortedDynamicResultSetFactory" ),
     512                 :         11 :                          OUString( DYNAMIC_RESULTSET_FACTORY_NAME ) );
     513                 :            : 
     514                 :            : //--------------------------------------------------------------------------
     515                 :            : // Service factory implementation.
     516                 :            : //--------------------------------------------------------------------------
     517                 :            : 
     518 [ +  - ][ +  - ]:         11 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( SortedDynamicResultSetFactory );
     519                 :            : 
     520                 :            : //--------------------------------------------------------------------------
     521                 :            : // SortedDynamicResultSetFactory methods.
     522                 :            : //--------------------------------------------------------------------------
     523                 :            : Reference< XDynamicResultSet > SAL_CALL
     524                 :        146 : SortedDynamicResultSetFactory::createSortedDynamicResultSet(
     525                 :            :                 const Reference< XDynamicResultSet > & Source,
     526                 :            :                 const Sequence< NumberedSortingInfo > & Info,
     527                 :            :                 const Reference< XAnyCompareFactory > & CompareFactory )
     528                 :            :     throw( RuntimeException )
     529                 :            : {
     530                 :        146 :     Reference< XDynamicResultSet > xRet;
     531 [ +  - ][ +  - ]:        146 :     xRet = new SortedDynamicResultSet( Source, Info, CompareFactory, mxSMgr );
                 [ +  - ]
     532                 :        146 :     return xRet;
     533                 :            : }
     534                 :            : 
     535                 :            : //=========================================================================
     536                 :            : //
     537                 :            : // EventList
     538                 :            : //
     539                 :            : //=========================================================================
     540                 :            : 
     541                 :        146 : void EventList::Clear()
     542                 :            : {
     543         [ -  + ]:        292 :     for ( std::deque< LISTACTION* >::size_type i = 0;
     544                 :        146 :           i < maData.size(); ++i )
     545                 :            :     {
     546         [ #  # ]:          0 :         delete maData[i];
     547                 :            :     }
     548                 :            : 
     549                 :        146 :     maData.clear();
     550                 :        146 : }
     551                 :            : 
     552                 :            : //--------------------------------------------------------------------------
     553                 :          0 : void EventList::AddEvent( long nType, long nPos, long nCount )
     554                 :            : {
     555                 :          0 :     ListAction *pAction = new ListAction;
     556                 :          0 :     pAction->Position = nPos;
     557                 :          0 :     pAction->Count = nCount;
     558                 :          0 :     pAction->ListActionType = nType;
     559                 :            : 
     560                 :          0 :     Insert( pAction );
     561                 :          0 : }
     562                 :            : 
     563                 :            : //=================================================================
     564                 :            : //
     565                 :            : // SortedDynamicResultSetListener
     566                 :            : //
     567                 :            : //=================================================================
     568                 :            : 
     569                 :        146 : SortedDynamicResultSetListener::SortedDynamicResultSetListener(
     570         [ +  - ]:        146 :                                 SortedDynamicResultSet *mOwner )
     571                 :            : {
     572                 :        146 :     mpOwner = mOwner;
     573                 :        146 : }
     574                 :            : 
     575                 :            : //-----------------------------------------------------------------
     576         [ +  - ]:        146 : SortedDynamicResultSetListener::~SortedDynamicResultSetListener()
     577                 :            : {
     578         [ -  + ]:        292 : }
     579                 :            : 
     580                 :            : //-----------------------------------------------------------------
     581                 :            : // XInterface methods.
     582                 :            : //-----------------------------------------------------------------
     583                 :            : 
     584 [ #  # ][ #  # ]:        584 : XINTERFACE_IMPL_2( SortedDynamicResultSetListener,
                 [ #  # ]
     585                 :            :                    XEventListener,  /* base class of XDynamicResultSetListener */
     586                 :            :                    XDynamicResultSetListener );
     587                 :            : 
     588                 :            : //-----------------------------------------------------------------
     589                 :            : // XEventListener ( base of XDynamicResultSetListener )
     590                 :            : //-----------------------------------------------------------------
     591                 :            : void SAL_CALL
     592                 :          0 : SortedDynamicResultSetListener::disposing( const EventObject& Source )
     593                 :            :     throw( RuntimeException )
     594                 :            : {
     595         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     596                 :            : 
     597         [ #  # ]:          0 :     if ( mpOwner )
     598 [ #  # ][ #  # ]:          0 :         mpOwner->impl_disposing( Source );
     599                 :          0 : }
     600                 :            : 
     601                 :            : //-----------------------------------------------------------------
     602                 :            : // XDynamicResultSetListener
     603                 :            : //-----------------------------------------------------------------
     604                 :            : void SAL_CALL
     605                 :          0 : SortedDynamicResultSetListener::notify( const ListEvent& Changes )
     606                 :            :     throw( RuntimeException )
     607                 :            : {
     608         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     609                 :            : 
     610         [ #  # ]:          0 :     if ( mpOwner )
     611 [ #  # ][ #  # ]:          0 :         mpOwner->impl_notify( Changes );
     612                 :          0 : }
     613                 :            : 
     614                 :            : //-----------------------------------------------------------------
     615                 :            : // own methods:
     616                 :            : //-----------------------------------------------------------------
     617                 :            : void SAL_CALL
     618                 :        146 : SortedDynamicResultSetListener::impl_OwnerDies()
     619                 :            : {
     620         [ +  - ]:        146 :     osl::Guard< osl::Mutex > aGuard( maMutex );
     621         [ +  - ]:        146 :     mpOwner = NULL;
     622                 :        146 : }
     623                 :            : 
     624                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10