LCOV - code coverage report
Current view: top level - framework/source/helper - oframes.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 101 83.2 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 83 204 40.7 %

           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 <helper/oframes.hxx>
      30                 :            : 
      31                 :            : #include <threadhelp/resetableguard.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      34                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      35                 :            : 
      36                 :            : #include <vcl/svapp.hxx>
      37                 :            : 
      38                 :            : namespace framework{
      39                 :            : 
      40                 :            : using namespace ::com::sun::star::container     ;
      41                 :            : using namespace ::com::sun::star::frame         ;
      42                 :            : using namespace ::com::sun::star::lang          ;
      43                 :            : using namespace ::com::sun::star::uno           ;
      44                 :            : using namespace ::cppu                          ;
      45                 :            : using namespace ::osl                           ;
      46                 :            : using namespace ::std                           ;
      47                 :            : 
      48                 :            : using rtl::OUString;
      49                 :            : 
      50                 :            : //*****************************************************************************************************************
      51                 :            : //  constructor
      52                 :            : //*****************************************************************************************************************
      53                 :       1983 : OFrames::OFrames(   const   css::uno::Reference< XMultiServiceFactory >&    xFactory        ,
      54                 :            :                     const   css::uno::Reference< XFrame >&              xOwner          ,
      55                 :            :                             FrameContainer*                     pFrameContainer )
      56                 :            :         //  Init baseclasses first
      57                 :       1983 :         :   ThreadHelpBase              ( &Application::GetSolarMutex() )
      58                 :            :         // Init member
      59                 :            :         ,   m_xFactory                  ( xFactory                      )
      60                 :            :         ,   m_xOwner                    ( xOwner                        )
      61                 :            :         ,   m_pFrameContainer           ( pFrameContainer               )
      62 [ +  - ][ +  - ]:       1983 :         ,   m_bRecursiveSearchProtection( sal_False                     )
      63                 :            : {
      64                 :            :     // Safe impossible cases
      65                 :            :     // Method is not defined for ALL incoming parameters!
      66                 :            :     LOG_ASSERT( impldbg_checkParameter_OFramesCtor( xFactory, xOwner, pFrameContainer ), "OFrames::OFrames()\nInvalid parameter detected!\n" )
      67                 :       1983 : }
      68                 :            : 
      69                 :            : //*****************************************************************************************************************
      70                 :            : //  (proteced!) destructor
      71                 :            : //*****************************************************************************************************************
      72 [ +  - ][ +  - ]:       1892 : OFrames::~OFrames()
      73                 :            : {
      74                 :            :     // Reset instance, free memory ....
      75         [ +  - ]:       1892 :     impl_resetObject();
      76         [ -  + ]:       3784 : }
      77                 :            : 
      78                 :            : //*****************************************************************************************************************
      79                 :            : //  XFrames
      80                 :            : //*****************************************************************************************************************
      81                 :       1747 : void SAL_CALL OFrames::append( const css::uno::Reference< XFrame >& xFrame ) throw( RuntimeException )
      82                 :            : {
      83                 :            :     // Ready for multithreading
      84         [ +  - ]:       1747 :     ResetableGuard aGuard( m_aLock );
      85                 :            : 
      86                 :            :     // Safe impossible cases
      87                 :            :     // Method is not defined for ALL incoming parameters!
      88                 :            :     LOG_ASSERT( impldbg_checkParameter_append( xFrame ), "OFrames::append()\nInvalid parameter detected!\n" )
      89                 :            : 
      90                 :            :     // Do the follow only, if owner instance valid!
      91                 :            :     // Lock owner for follow operations - make a "hard reference"!
      92 [ +  - ][ +  - ]:       1747 :     css::uno::Reference< XFramesSupplier > xOwner( m_xOwner.get(), UNO_QUERY );
      93         [ +  - ]:       1747 :     if ( xOwner.is() == sal_True )
      94                 :            :     {
      95                 :            :         // Append frame to the end of the container ...
      96         [ +  - ]:       1747 :         m_pFrameContainer->append( xFrame );
      97                 :            :         // Set owner of this instance as parent of the new frame in container!
      98 [ +  - ][ +  - ]:       1747 :         xFrame->setCreator( xOwner );
      99         [ +  - ]:       1747 :     }
     100                 :            :     // Else; Do nothing! Ouer owner is dead.
     101                 :            :     LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::append()\nOuer owner is dead - you can't append any frames ...!\n" )
     102                 :       1747 : }
     103                 :            : 
     104                 :            : //*****************************************************************************************************************
     105                 :            : //  XFrames
     106                 :            : //*****************************************************************************************************************
     107                 :       1656 : void SAL_CALL OFrames::remove( const css::uno::Reference< XFrame >& xFrame ) throw( RuntimeException )
     108                 :            : {
     109                 :            :     // Ready for multithreading
     110         [ +  - ]:       1656 :     ResetableGuard aGuard( m_aLock );
     111                 :            : 
     112                 :            :     // Safe impossible cases
     113                 :            :     // Method is not defined for ALL incoming parameters!
     114                 :            :     LOG_ASSERT( impldbg_checkParameter_remove( xFrame ), "OFrames::remove()\nInvalid parameter detected!\n" )
     115                 :            : 
     116                 :            :     // Do the follow only, if owner instance valid!
     117                 :            :     // Lock owner for follow operations - make a "hard reference"!
     118 [ +  - ][ +  - ]:       1656 :     css::uno::Reference< XFramesSupplier > xOwner( m_xOwner.get(), UNO_QUERY );
     119         [ +  - ]:       1656 :     if ( xOwner.is() == sal_True )
     120                 :            :     {
     121                 :            :         // Search frame and remove it from container ...
     122         [ +  - ]:       1656 :         m_pFrameContainer->remove( xFrame );
     123                 :            :         // Don't reset owner-property of removed frame!
     124                 :            :         // This must do the caller of this method himself.
     125                 :            :         // See documentation of interface XFrames for further informations.
     126         [ +  - ]:       1656 :     }
     127                 :            :     // Else; Do nothing! Ouer owner is dead.
     128                 :            :     LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::remove()\nOuer owner is dead - you can't remove any frames ...!\n" )
     129                 :       1656 : }
     130                 :            : 
     131                 :            : //*****************************************************************************************************************
     132                 :            : //  XFrames
     133                 :            : //*****************************************************************************************************************
     134                 :         16 : Sequence< css::uno::Reference< XFrame > > SAL_CALL OFrames::queryFrames( sal_Int32 nSearchFlags ) throw( RuntimeException )
     135                 :            : {
     136                 :            :     // Ready for multithreading
     137         [ +  - ]:         16 :     ResetableGuard aGuard( m_aLock );
     138                 :            : 
     139                 :            :     // Safe impossible cases
     140                 :            :     // Method is not defined for ALL incoming parameters!
     141                 :            :     LOG_ASSERT( impldbg_checkParameter_queryFrames( nSearchFlags ), "OFrames::queryFrames()\nInvalid parameter detected!\n" )
     142                 :            : 
     143                 :            :     // Set default return value. (empty sequence)
     144         [ +  - ]:         16 :     Sequence< css::uno::Reference< XFrame > > seqFrames;
     145                 :            : 
     146                 :            :     // Do the follow only, if owner instance valid.
     147                 :            :     // Lock owner for follow operations - make a "hard reference"!
     148 [ +  - ][ +  - ]:         16 :     css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
     149         [ +  - ]:         16 :     if ( xOwner.is() == sal_True )
     150                 :            :     {
     151                 :            :         // Work only, if search was not started here ...!
     152         [ +  - ]:         16 :         if( m_bRecursiveSearchProtection == sal_False )
     153                 :            :         {
     154                 :            :             // This class is a helper for services, which must implement XFrames.
     155                 :            :             // His parent and children are MY parent and children to.
     156                 :            :             // All searchflags are supported by this implementation!
     157                 :            :             // If some flags should not be supported - don't call me with this flags!!!
     158                 :            : 
     159                 :            :             //_____________________________________________________________________________________________________________
     160                 :            :             // Search with AUTO-flag is not supported yet!
     161                 :            :             // We think about right implementation.
     162                 :            :             LOG_ASSERT( !(nSearchFlags & FrameSearchFlag::AUTO), "OFrames::queryFrames()\nSearch with AUTO-flag is not supported yet!\nWe think about right implementation.\n" )
     163                 :            :             // If searched for tasks ...
     164                 :            :             // Its not supported yet.
     165                 :            :             LOG_ASSERT( !(nSearchFlags & FrameSearchFlag::AUTO), "OFrames::queryFrames()\nSearch for tasks not supported yet!\n" )
     166                 :            : 
     167                 :            :             //_____________________________________________________________________________________________________________
     168                 :            :             // Search for ALL and GLOBAL is superflous!
     169                 :            :             // We support all necessary flags, from which these two flags are derived.
     170                 :            :             //      ALL     = PARENT + SELF  + CHILDREN + SIBLINGS
     171                 :            :             //      GLOBAL  = ALL    + TASKS
     172                 :            : 
     173                 :            :             //_____________________________________________________________________________________________________________
     174                 :            :             // Add parent to list ... if any exist!
     175         [ -  + ]:         16 :             if( nSearchFlags & FrameSearchFlag::PARENT )
     176                 :            :             {
     177 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< XFrame > xParent( xOwner->getCreator(), UNO_QUERY );
                 [ #  # ]
     178         [ #  # ]:          0 :                 if( xParent.is() == sal_True )
     179                 :            :                 {
     180         [ #  # ]:          0 :                     Sequence< css::uno::Reference< XFrame > > seqParent( 1 );
     181 [ #  # ][ #  # ]:          0 :                     seqParent[0] = xParent;
     182 [ #  # ][ #  # ]:          0 :                     impl_appendSequence( seqFrames, seqParent );
     183                 :          0 :                 }
     184                 :            :             }
     185                 :            : 
     186                 :            :             //_____________________________________________________________________________________________________________
     187                 :            :             // Add owner to list if SELF is searched.
     188         [ +  + ]:         16 :             if( nSearchFlags & FrameSearchFlag::SELF )
     189                 :            :             {
     190         [ +  - ]:          8 :                 Sequence< css::uno::Reference< XFrame > > seqSelf( 1 );
     191 [ +  - ][ +  - ]:          8 :                 seqSelf[0] = xOwner;
     192 [ +  - ][ +  - ]:          8 :                 impl_appendSequence( seqFrames, seqSelf );
     193                 :            :             }
     194                 :            : 
     195                 :            :             //_____________________________________________________________________________________________________________
     196                 :            :             // Add SIBLINGS to list.
     197         [ -  + ]:         16 :             if( nSearchFlags & FrameSearchFlag::SIBLINGS )
     198                 :            :             {
     199                 :            :                 // Else; start a new search.
     200                 :            :                 // Protect this instance against recursive calls from parents.
     201                 :          0 :                 m_bRecursiveSearchProtection = sal_True;
     202                 :            :                 // Ask parent of my owner for frames and append results to return list.
     203 [ #  # ][ #  # ]:          0 :                 css::uno::Reference< XFramesSupplier > xParent( xOwner->getCreator(), UNO_QUERY );
                 [ #  # ]
     204                 :            :                 // If a parent exist ...
     205         [ #  # ]:          0 :                 if ( xParent.is() == sal_True )
     206                 :            :                 {
     207                 :            :                     // ... ask him for right frames.
     208 [ #  # ][ #  # ]:          0 :                     impl_appendSequence( seqFrames, xParent->getFrames()->queryFrames( nSearchFlags ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     209                 :            :                 }
     210                 :            :                 // We have all searched informations.
     211                 :            :                 // Reset protection-mode.
     212                 :          0 :                 m_bRecursiveSearchProtection = sal_False;
     213                 :            :             }
     214                 :            : 
     215                 :            :             //_____________________________________________________________________________________________________________
     216                 :            :             // If searched for children, step over all elements in container and collect the informations.
     217         [ +  - ]:         16 :             if ( nSearchFlags & FrameSearchFlag::CHILDREN )
     218                 :            :             {
     219                 :            :                 // Don't search for parents, siblings and self at childrens!
     220                 :            :                 // These things are supported by this instance himself.
     221                 :         16 :                 sal_Int32 nChildSearchFlags = FrameSearchFlag::SELF | FrameSearchFlag::CHILDREN;
     222                 :            :                 // Step over all items of container and ask childrens for frames.
     223         [ +  - ]:         16 :                 sal_uInt32 nCount = m_pFrameContainer->getCount();
     224         [ +  + ]:         24 :                 for ( sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex )
     225                 :            :                 {
     226                 :            :                     // We don't must control this conversion.
     227                 :            :                     // We have done this at append()!
     228 [ +  - ][ +  - ]:          8 :                     css::uno::Reference< XFramesSupplier > xItem( (*m_pFrameContainer)[nIndex], UNO_QUERY );
     229 [ +  - ][ +  - ]:          8 :                     impl_appendSequence( seqFrames, xItem->getFrames()->queryFrames( nChildSearchFlags ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     230                 :          8 :                 }
     231                 :            :             }
     232                 :            :         }
     233                 :            :     }
     234                 :            :     // Else; Do nothing! Ouer owner is dead.
     235                 :            :     LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::queryFrames()\nOuer owner is dead - you can't query for frames ...!\n" )
     236                 :            : 
     237                 :            :     // Resturn result of this operation.
     238         [ +  - ]:         16 :     return seqFrames;
     239                 :            : }
     240                 :            : 
     241                 :            : //*****************************************************************************************************************
     242                 :            : //  XIndexAccess
     243                 :            : //*****************************************************************************************************************
     244                 :      11302 : sal_Int32 SAL_CALL OFrames::getCount() throw( RuntimeException )
     245                 :            : {
     246                 :            :     // Ready for multithreading
     247         [ +  - ]:      11302 :     ResetableGuard aGuard( m_aLock );
     248                 :            : 
     249                 :            :     // Set default return value.
     250                 :      11302 :     sal_Int32 nCount = 0;
     251                 :            : 
     252                 :            :     // Do the follow only, if owner instance valid.
     253                 :            :     // Lock owner for follow operations - make a "hard reference"!
     254 [ +  - ][ +  - ]:      11302 :     css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
     255         [ +  - ]:      11302 :     if ( xOwner.is() == sal_True )
     256                 :            :     {
     257                 :            :         // Set CURRENT size of container for return.
     258         [ +  - ]:      11302 :         nCount = m_pFrameContainer->getCount();
     259                 :            :     }
     260                 :            : 
     261                 :            :     // Return result.
     262         [ +  - ]:      11302 :     return nCount;
     263                 :            : }
     264                 :            : 
     265                 :            : //*****************************************************************************************************************
     266                 :            : //  XIndexAccess
     267                 :            : //*****************************************************************************************************************
     268                 :      22335 : Any SAL_CALL OFrames::getByIndex( sal_Int32 nIndex ) throw( IndexOutOfBoundsException   ,
     269                 :            :                                                             WrappedTargetException      ,
     270                 :            :                                                             RuntimeException            )
     271                 :            : {
     272                 :            :     // Ready for multithreading
     273         [ +  - ]:      22335 :     ResetableGuard aGuard( m_aLock );
     274                 :            : 
     275         [ +  - ]:      22335 :       sal_uInt32 nCount = m_pFrameContainer->getCount();
     276 [ +  - ][ -  + ]:      22335 :       if ( nIndex < 0 || ( sal::static_int_cast< sal_uInt32 >( nIndex ) >= nCount ))
                 [ -  + ]
     277                 :            :           throw IndexOutOfBoundsException( OUString("OFrames::getByIndex - Index out of bounds"),
     278 [ #  # ][ #  # ]:          0 :                                            (OWeakObject *)this );
     279                 :            : 
     280                 :            :     // Set default return value.
     281                 :      22335 :     Any aReturnValue;
     282                 :            : 
     283                 :            :     // Do the follow only, if owner instance valid.
     284                 :            :     // Lock owner for follow operations - make a "hard reference"!
     285 [ +  - ][ +  - ]:      22335 :     css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
     286         [ +  - ]:      22335 :     if ( xOwner.is() == sal_True )
     287                 :            :     {
     288                 :            :         // Get element form container.
     289                 :            :         // (If index not valid, FrameContainer return NULL!)
     290 [ +  - ][ +  - ]:      22335 :             aReturnValue <<= (*m_pFrameContainer)[nIndex];
     291                 :            :     }
     292                 :            : 
     293                 :            :     // Return result of this operation.
     294         [ +  - ]:      22335 :     return aReturnValue;
     295                 :            : }
     296                 :            : 
     297                 :            : //*****************************************************************************************************************
     298                 :            : //  XElementAccess
     299                 :            : //*****************************************************************************************************************
     300                 :          0 : Type SAL_CALL OFrames::getElementType() throw( RuntimeException )
     301                 :            : {
     302                 :            :     // This "container" support XFrame-interfaces only!
     303                 :          0 :     return ::getCppuType( (const css::uno::Reference< XFrame >*)NULL );
     304                 :            : }
     305                 :            : 
     306                 :            : //*****************************************************************************************************************
     307                 :            : //  XElementAccess
     308                 :            : //*****************************************************************************************************************
     309                 :         96 : sal_Bool SAL_CALL OFrames::hasElements() throw( RuntimeException )
     310                 :            : {
     311                 :            :     // Ready for multithreading
     312         [ +  - ]:         96 :     ResetableGuard aGuard( m_aLock );
     313                 :            : 
     314                 :            :     // Set default return value.
     315                 :         96 :     sal_Bool bHasElements = sal_False;
     316                 :            :     // Do the follow only, if owner instance valid.
     317                 :            :     // Lock owner for follow operations - make a "hard reference"!
     318 [ +  - ][ +  - ]:         96 :     css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
     319         [ +  - ]:         96 :     if ( xOwner.is() == sal_True )
     320                 :            :     {
     321                 :            :         // If some elements exist ...
     322 [ +  - ][ -  + ]:         96 :         if ( m_pFrameContainer->getCount() > 0 )
     323                 :            :         {
     324                 :            :             // ... change this state value!
     325                 :          0 :             bHasElements = sal_True;
     326                 :            :         }
     327                 :            :     }
     328                 :            :     // Return result of this operation.
     329         [ +  - ]:         96 :     return bHasElements;
     330                 :            : }
     331                 :            : 
     332                 :            : //*****************************************************************************************************************
     333                 :            : //  proteced method
     334                 :            : //*****************************************************************************************************************
     335                 :       1892 : void OFrames::impl_resetObject()
     336                 :            : {
     337                 :            :     // Attention:
     338                 :            :     // Write this for multiple calls - NOT AT THE SAME TIME - but for more then one call again)!
     339                 :            :     // It exist two ways to call this method. From destructor and from disposing().
     340                 :            :     // I can't say, which one is the first. Normaly the disposing-call - but other way ....
     341                 :            : 
     342                 :            :     // This instance can't work if the weakreference to owner is invalid!
     343                 :            :     // Destroy this to reset this object.
     344         [ +  - ]:       1892 :     m_xOwner = WeakReference< XFrame >();
     345                 :            :     // Reset pointer to shared container to!
     346                 :       1892 :     m_pFrameContainer = NULL;
     347                 :       1892 : }
     348                 :            : 
     349                 :            : //*****************************************************************************************************************
     350                 :            : //  private method
     351                 :            : //*****************************************************************************************************************
     352                 :         16 : void OFrames::impl_appendSequence(          Sequence< css::uno::Reference< XFrame > >&  seqDestination  ,
     353                 :            :                                      const  Sequence< css::uno::Reference< XFrame > >&  seqSource       )
     354                 :            : {
     355                 :            :     // Get some informations about the sequences.
     356                 :         16 :     sal_Int32                       nSourceCount        = seqSource.getLength();
     357                 :         16 :     sal_Int32                       nDestinationCount   = seqDestination.getLength();
     358                 :         16 :     const css::uno::Reference< XFrame >*        pSourceAccess       = seqSource.getConstArray();
     359         [ +  - ]:         16 :     css::uno::Reference< XFrame >*          pDestinationAccess  = seqDestination.getArray();
     360                 :            : 
     361                 :            :     // Get memory for result list.
     362         [ +  - ]:         16 :     Sequence< css::uno::Reference< XFrame > >   seqResult           ( nSourceCount + nDestinationCount );
     363         [ +  - ]:         16 :     css::uno::Reference< XFrame >*          pResultAccess       = seqResult.getArray();
     364                 :         16 :     sal_Int32                       nResultPosition     = 0;
     365                 :            : 
     366                 :            :     // Copy all items from first sequence.
     367         [ +  + ]:         32 :     for ( sal_Int32 nSourcePosition=0; nSourcePosition<nSourceCount; ++nSourcePosition )
     368                 :            :     {
     369         [ +  - ]:         16 :         pResultAccess[nResultPosition] = pSourceAccess[nSourcePosition];
     370                 :         16 :         ++nResultPosition;
     371                 :            :     }
     372                 :            : 
     373                 :            :     // Don't manipulate nResultPosition between these two loops!
     374                 :            :     // Its the current position in the result list.
     375                 :            : 
     376                 :            :     // Copy all items from second sequence.
     377         [ -  + ]:         16 :     for ( sal_Int32 nDestinationPosition=0; nDestinationPosition<nDestinationCount; ++nDestinationPosition )
     378                 :            :     {
     379         [ #  # ]:          0 :         pResultAccess[nResultPosition] = pDestinationAccess[nDestinationPosition];
     380                 :          0 :         ++nResultPosition;
     381                 :            :     }
     382                 :            : 
     383                 :            :     // Return result of this operation.
     384         [ +  - ]:         16 :     seqDestination.realloc( 0 );
     385 [ +  - ][ +  - ]:         16 :     seqDestination = seqResult;
     386                 :         16 : }
     387                 :            : 
     388                 :            : //_________________________________________________________________________________________________________________
     389                 :            : //  debug methods
     390                 :            : //_________________________________________________________________________________________________________________
     391                 :            : 
     392                 :            : /*-----------------------------------------------------------------------------------------------------------------
     393                 :            :     The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
     394                 :            :     we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
     395                 :            : 
     396                 :            :     ATTENTION
     397                 :            : 
     398                 :            :         If you miss a test for one of this parameters, contact the autor or add it himself !(?)
     399                 :            :         But ... look for right testing! See using of this methods!
     400                 :            : -----------------------------------------------------------------------------------------------------------------*/
     401                 :            : 
     402                 :            : #ifdef ENABLE_ASSERTIONS
     403                 :            : 
     404                 :            : //*****************************************************************************************************************
     405                 :            : // An instance of this class can only work with valid initialization.
     406                 :            : // We share the mutex with ouer owner class, need a valid factory to instanciate new services and
     407                 :            : // use the access to ouer owner for some operations.
     408                 :            : sal_Bool OFrames::impldbg_checkParameter_OFramesCtor(   const   css::uno::Reference< XMultiServiceFactory >&    xFactory        ,
     409                 :            :                                                         const   css::uno::Reference< XFrame >&              xOwner          ,
     410                 :            :                                                                 FrameContainer*                     pFrameContainer )
     411                 :            : {
     412                 :            :     // Set default return value.
     413                 :            :     sal_Bool bOK = sal_True;
     414                 :            :     // Check parameter.
     415                 :            :     if  (
     416                 :            :             ( &xFactory         ==  NULL        )   ||
     417                 :            :             ( &xOwner           ==  NULL        )   ||
     418                 :            :             ( xFactory.is()     ==  sal_False   )   ||
     419                 :            :             ( xOwner.is()       ==  sal_False   )   ||
     420                 :            :             ( pFrameContainer   ==  NULL        )
     421                 :            :         )
     422                 :            :     {
     423                 :            :         bOK = sal_False ;
     424                 :            :     }
     425                 :            :     // Return result of check.
     426                 :            :     return bOK ;
     427                 :            : }
     428                 :            : 
     429                 :            : //*****************************************************************************************************************
     430                 :            : // Its only allowed to add valid references to container.
     431                 :            : // AND - alle frames must support XFrames-interface!
     432                 :            : sal_Bool OFrames::impldbg_checkParameter_append( const css::uno::Reference< XFrame >& xFrame )
     433                 :            : {
     434                 :            :     // Set default return value.
     435                 :            :     sal_Bool bOK = sal_True;
     436                 :            :     // Check parameter.
     437                 :            :     if  (
     438                 :            :             ( &xFrame       ==  NULL        )   ||
     439                 :            :             ( xFrame.is()   ==  sal_False   )
     440                 :            :         )
     441                 :            :     {
     442                 :            :         bOK = sal_False ;
     443                 :            :     }
     444                 :            :     // Return result of check.
     445                 :            :     return bOK ;
     446                 :            : }
     447                 :            : 
     448                 :            : //*****************************************************************************************************************
     449                 :            : // Its only allowed to add valid references to container...
     450                 :            : // ... => You can only delete valid references!
     451                 :            : sal_Bool OFrames::impldbg_checkParameter_remove( const css::uno::Reference< XFrame >& xFrame )
     452                 :            : {
     453                 :            :     // Set default return value.
     454                 :            :     sal_Bool bOK = sal_True;
     455                 :            :     // Check parameter.
     456                 :            :     if  (
     457                 :            :             ( &xFrame       ==  NULL        )   ||
     458                 :            :             ( xFrame.is()   ==  sal_False   )
     459                 :            :         )
     460                 :            :     {
     461                 :            :         bOK = sal_False ;
     462                 :            :     }
     463                 :            :     // Return result of check.
     464                 :            :     return bOK ;
     465                 :            : }
     466                 :            : 
     467                 :            : //*****************************************************************************************************************
     468                 :            : // A search for frames must initiate with right flags.
     469                 :            : // Some one are superflous and not supported yet. But here we control only the range of incoming parameter!
     470                 :            : sal_Bool OFrames::impldbg_checkParameter_queryFrames( sal_Int32 nSearchFlags )
     471                 :            : {
     472                 :            :     // Set default return value.
     473                 :            :     sal_Bool bOK = sal_True;
     474                 :            :     // Check parameter.
     475                 :            :     if  (
     476                 :            :             (    nSearchFlags != FrameSearchFlag::AUTO        ) &&
     477                 :            :             ( !( nSearchFlags &  FrameSearchFlag::PARENT    ) ) &&
     478                 :            :             ( !( nSearchFlags &  FrameSearchFlag::SELF      ) ) &&
     479                 :            :             ( !( nSearchFlags &  FrameSearchFlag::CHILDREN  ) ) &&
     480                 :            :             ( !( nSearchFlags &  FrameSearchFlag::CREATE    ) ) &&
     481                 :            :             ( !( nSearchFlags &  FrameSearchFlag::SIBLINGS  ) ) &&
     482                 :            :             ( !( nSearchFlags &  FrameSearchFlag::TASKS     ) ) &&
     483                 :            :             ( !( nSearchFlags &  FrameSearchFlag::ALL       ) ) &&
     484                 :            :             ( !( nSearchFlags &  FrameSearchFlag::GLOBAL    ) )
     485                 :            :         )
     486                 :            :     {
     487                 :            :         bOK = sal_False ;
     488                 :            :     }
     489                 :            :     // Return result of check.
     490                 :            :     return bOK ;
     491                 :            : }
     492                 :            : 
     493                 :            : #endif  //  #ifdef ENABLE_ASSERTIONS
     494                 :            : 
     495                 :            : }       //  namespace framework
     496                 :            : 
     497                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10