LCOV - code coverage report
Current view: top level - vcl/source/window - window4.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 88 33.0 %
Date: 2012-08-25 Functions: 6 12 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 126 10.3 %

           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 "vcl/window.hxx"
      31                 :            : #include "vcl/arrange.hxx"
      32                 :            : 
      33                 :            : #include "window.h"
      34                 :            : #include "svdata.hxx"
      35                 :            : 
      36                 :            : #include "com/sun/star/beans/PropertyValue.hpp"
      37                 :            : 
      38                 :            : #include <map>
      39                 :            : #include <vector>
      40                 :            : 
      41                 :            : using namespace com::sun::star;
      42                 :            : 
      43                 :            : namespace vcl
      44                 :            : {
      45                 :            :     struct ExtWindowImpl
      46                 :            :     {
      47                 :      16733 :         ExtWindowImpl()
      48                 :      16733 :         : mbOwnedByParent( false )
      49                 :      16733 :         {}
      50                 :      16733 :         ~ExtWindowImpl()
      51                 :      16733 :         {}
      52                 :            : 
      53                 :            :         boost::shared_ptr< WindowArranger >      mxLayout;
      54                 :            :         bool                                     mbOwnedByParent;
      55                 :            :         rtl::OUString                            maIdentifier;
      56                 :            :     };
      57                 :            : }
      58                 :            : 
      59                 :     120493 : void Window::ImplDeleteOwnedChildren()
      60                 :            : {
      61                 :     120493 :     Window* pChild = mpWindowImpl->mpFirstChild;
      62         [ +  + ]:     137226 :     while ( pChild )
      63                 :            :     {
      64                 :      16733 :         Window* pDeleteCandidate = pChild;
      65                 :      16733 :         pChild = pChild->mpWindowImpl->mpNext;
      66                 :      16733 :         vcl::ExtWindowImpl* pDelImpl = pDeleteCandidate->ImplGetExtWindowImpl();
      67 [ -  + ][ +  - ]:      16733 :         if( pDelImpl && pDelImpl->mbOwnedByParent )
      68         [ #  # ]:          0 :             delete pDeleteCandidate;
      69                 :            :     }
      70                 :     120493 : }
      71                 :            : 
      72                 :     120493 : void Window::ImplFreeExtWindowImpl()
      73                 :            : {
      74                 :     120493 :     ImplDeleteOwnedChildren();
      75         [ +  - ]:     120493 :     if( mpWindowImpl )
      76                 :            :     {
      77         [ +  + ]:     120493 :         delete mpWindowImpl->mpExtImpl;
      78                 :     120493 :         mpWindowImpl->mpExtImpl = NULL;
      79                 :            :     }
      80                 :     120493 : }
      81                 :            : 
      82                 :      16733 : vcl::ExtWindowImpl* Window::ImplGetExtWindowImpl() const
      83                 :            : {
      84                 :      16733 :     vcl::ExtWindowImpl* pImpl = NULL;
      85         [ +  - ]:      16733 :     if( mpWindowImpl )
      86                 :            :     {
      87 [ +  - ][ +  - ]:      16733 :         if( ! mpWindowImpl->mpExtImpl && ! mpWindowImpl->mbInDtor )
      88         [ +  - ]:      16733 :             mpWindowImpl->mpExtImpl = new vcl::ExtWindowImpl();
      89                 :      16733 :         pImpl = mpWindowImpl->mpExtImpl;
      90                 :            :     }
      91                 :      16733 :     return pImpl;
      92                 :            : }
      93                 :            : 
      94                 :     147946 : void Window::ImplExtResize()
      95                 :            : {
      96 [ +  - ][ -  + ]:     147946 :     if( mpWindowImpl && mpWindowImpl->mpExtImpl )
      97                 :            :     {
      98         [ #  # ]:          0 :         if( mpWindowImpl->mpExtImpl->mxLayout.get() )
      99 [ #  # ][ #  # ]:          0 :             mpWindowImpl->mpExtImpl->mxLayout->setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
     100                 :            :     }
     101                 :     147946 : }
     102                 :            : 
     103                 :          0 : boost::shared_ptr< vcl::WindowArranger > Window::getLayout()
     104                 :            : {
     105                 :          0 :     boost::shared_ptr< vcl::WindowArranger > xRet;
     106         [ #  # ]:          0 :     vcl::ExtWindowImpl* pImpl = ImplGetExtWindowImpl();
     107         [ #  # ]:          0 :     if( pImpl )
     108                 :            :     {
     109         [ #  # ]:          0 :         if( ! pImpl->mxLayout.get() )
     110                 :            :         {
     111 [ #  # ][ #  # ]:          0 :             pImpl->mxLayout.reset( new vcl::LabelColumn() );
                 [ #  # ]
     112         [ #  # ]:          0 :             pImpl->mxLayout->setParentWindow( this );
     113         [ #  # ]:          0 :             pImpl->mxLayout->setOuterBorder( -1 );
     114                 :            :         }
     115         [ #  # ]:          0 :         xRet = pImpl->mxLayout;
     116                 :            :     }
     117                 :            : 
     118                 :          0 :     return xRet;
     119                 :            : }
     120                 :            : 
     121                 :          0 : void Window::addWindow( Window* i_pWin, bool i_bTakeOwnership )
     122                 :            : {
     123                 :          0 :     vcl::ExtWindowImpl* pImpl = ImplGetExtWindowImpl();
     124 [ #  # ][ #  # ]:          0 :     if( pImpl && i_pWin )
     125                 :            :     {
     126                 :          0 :         vcl::ExtWindowImpl* pChildImpl = i_pWin->ImplGetExtWindowImpl();
     127         [ #  # ]:          0 :         if( pChildImpl )
     128                 :            :         {
     129                 :          0 :             i_pWin->SetParent( this );
     130                 :          0 :             pChildImpl->mbOwnedByParent = i_bTakeOwnership;
     131                 :            :         }
     132                 :            :     }
     133                 :          0 : }
     134                 :            : 
     135                 :          0 : Window* Window::findWindow( const rtl::OUString& i_rIdentifier ) const
     136                 :            : {
     137         [ #  # ]:          0 :     if( getIdentifier() == i_rIdentifier )
     138                 :          0 :         return const_cast<Window*>(this);
     139                 :            : 
     140                 :          0 :     Window* pChild = mpWindowImpl->mpFirstChild;
     141         [ #  # ]:          0 :     while ( pChild )
     142                 :            :     {
     143                 :          0 :         Window* pResult = pChild->findWindow( i_rIdentifier );
     144         [ #  # ]:          0 :         if( pResult )
     145                 :          0 :             return pResult;
     146                 :          0 :         pChild = pChild->mpWindowImpl->mpNext;
     147                 :            :     }
     148                 :            : 
     149                 :          0 :     return NULL;
     150                 :            : }
     151                 :            : 
     152                 :          0 : const rtl::OUString& Window::getIdentifier() const
     153                 :            : {
     154 [ #  # ][ #  # ]:          0 :     static rtl::OUString aEmptyStr;
     155                 :            : 
     156 [ #  # ][ #  # ]:          0 :     return (mpWindowImpl && mpWindowImpl->mpExtImpl) ? mpWindowImpl->mpExtImpl->maIdentifier : aEmptyStr;
     157                 :            : }
     158                 :            : 
     159                 :          0 : void Window::setProperties( const uno::Sequence< beans::PropertyValue >& i_rProps )
     160                 :            : {
     161                 :          0 :     const beans::PropertyValue* pVals = i_rProps.getConstArray();
     162         [ #  # ]:          0 :     for( sal_Int32 i = 0; i < i_rProps.getLength(); i++ )
     163                 :            :     {
     164         [ #  # ]:          0 :         if ( pVals[i].Name == "Enabled" )
     165                 :            :         {
     166                 :          0 :             sal_Bool bVal = sal_True;
     167         [ #  # ]:          0 :             if( pVals[i].Value >>= bVal )
     168         [ #  # ]:          0 :                 Enable( bVal );
     169                 :            :         }
     170         [ #  # ]:          0 :         else if ( pVals[i].Name == "Visible" )
     171                 :            :         {
     172                 :          0 :             sal_Bool bVal = sal_True;
     173         [ #  # ]:          0 :             if( pVals[i].Value >>= bVal )
     174         [ #  # ]:          0 :                 Show( bVal );
     175                 :            :         }
     176         [ #  # ]:          0 :         else if ( pVals[i].Name == "Text" )
     177                 :            :         {
     178                 :          0 :             rtl::OUString aText;
     179         [ #  # ]:          0 :             if( pVals[i].Value >>= aText )
     180 [ #  # ][ #  # ]:          0 :                 SetText( aText );
                 [ #  # ]
     181                 :            :         }
     182                 :            :     }
     183                 :          0 : }
     184                 :            : 
     185                 :          0 : uno::Sequence< beans::PropertyValue > Window::getProperties() const
     186                 :            : {
     187                 :          0 :     uno::Sequence< beans::PropertyValue > aProps( 3 );
     188 [ #  # ][ #  # ]:          0 :     aProps[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) );
     189 [ #  # ][ #  # ]:          0 :     aProps[0].Value = uno::makeAny( sal_Bool( IsEnabled() ) );
                 [ #  # ]
     190 [ #  # ][ #  # ]:          0 :     aProps[1].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) );
     191 [ #  # ][ #  # ]:          0 :     aProps[1].Value = uno::makeAny( sal_Bool( IsVisible() ) );
                 [ #  # ]
     192 [ #  # ][ #  # ]:          0 :     aProps[2].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
     193 [ #  # ][ #  # ]:          0 :     aProps[2].Value = uno::makeAny( rtl::OUString( GetText() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     194                 :            : 
     195                 :          0 :     return aProps;
     196                 :            : }
     197                 :            : 
     198                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10