LCOV - code coverage report
Current view: top level - svtools/source/toolpanel - tablayouter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 77 0.0 %
Date: 2012-08-25 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 80 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       4                 :            :  *
       5                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       6                 :            :  *
       7                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       8                 :            :  *
       9                 :            :  * This file is part of OpenOffice.org.
      10                 :            :  *
      11                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      12                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      13                 :            :  * only, as published by the Free Software Foundation.
      14                 :            :  *
      15                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      16                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      17                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18                 :            :  * GNU Lesser General Public License version 3 for more details
      19                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      20                 :            :  *
      21                 :            :  * You should have received a copy of the GNU Lesser General Public License
      22                 :            :  * version 3 along with OpenOffice.org.  If not, see
      23                 :            :  * <http://www.openoffice.org/license.html>
      24                 :            :  * for a copy of the LGPLv3 License.
      25                 :            :  *
      26                 :            : ************************************************************************/
      27                 :            : 
      28                 :            : 
      29                 :            : #include "svtools/toolpanel/tablayouter.hxx"
      30                 :            : #include "svtools/toolpanel/toolpaneldeck.hxx"
      31                 :            : #include "svtools/toolpanel/paneltabbar.hxx"
      32                 :            : #include "svtaccessiblefactory.hxx"
      33                 :            : 
      34                 :            : #include <tools/gen.hxx>
      35                 :            : #include <tools/diagnose_ex.h>
      36                 :            : 
      37                 :            : //........................................................................
      38                 :            : namespace svt
      39                 :            : {
      40                 :            : //........................................................................
      41                 :            : 
      42                 :            :     using ::com::sun::star::uno::Reference;
      43                 :            :     using ::com::sun::star::accessibility::XAccessible;
      44                 :            : 
      45                 :            :     //====================================================================
      46                 :            :     //= TabDeckLayouter_Data
      47                 :            :     //====================================================================
      48         [ #  # ]:          0 :     struct TabDeckLayouter_Data
      49                 :            :     {
      50                 :            :         TabAlignment                    eAlignment;
      51                 :            :         IToolPanelDeck&                 rPanels;
      52                 :            :         ::std::auto_ptr< PanelTabBar >  pTabBar;
      53                 :            :         AccessibleFactoryAccess         aAccessibleFactory;
      54                 :            : 
      55                 :          0 :         TabDeckLayouter_Data( Window& i_rParent, IToolPanelDeck& i_rPanels,
      56                 :            :                 const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
      57                 :            :             :eAlignment( i_eAlignment )
      58                 :            :             ,rPanels( i_rPanels )
      59 [ #  # ][ #  # ]:          0 :             ,pTabBar( new PanelTabBar( i_rParent, i_rPanels, i_eAlignment, i_eItemContent ) )
      60                 :            :         {
      61         [ #  # ]:          0 :             pTabBar->Show();
      62                 :          0 :         }
      63                 :            :     };
      64                 :            : 
      65                 :            :     //====================================================================
      66                 :            :     //= helper
      67                 :            :     //====================================================================
      68                 :            :     namespace
      69                 :            :     {
      70                 :          0 :         static bool lcl_isVerticalTabBar( const TabAlignment i_eAlignment )
      71                 :            :         {
      72                 :            :             return  ( i_eAlignment == TABS_RIGHT )
      73 [ #  # ][ #  # ]:          0 :                 ||  ( i_eAlignment == TABS_LEFT );
      74                 :            :         }
      75                 :            : 
      76                 :          0 :         static bool lcl_checkDisposed( const TabDeckLayouter_Data& i_rData )
      77                 :            :         {
      78         [ #  # ]:          0 :             if ( !i_rData.pTabBar.get() )
      79                 :            :             {
      80                 :            :                 OSL_FAIL( "lcl_checkDisposed: already disposed!" );
      81                 :          0 :                 return true;
      82                 :            :             }
      83                 :          0 :             return false;
      84                 :            :         }
      85                 :            :     }
      86                 :            : 
      87                 :            :     //====================================================================
      88                 :            :     //= TabDeckLayouter
      89                 :            :     //====================================================================
      90                 :            :     //--------------------------------------------------------------------
      91                 :          0 :     TabDeckLayouter::TabDeckLayouter( Window& i_rParent, IToolPanelDeck& i_rPanels,
      92                 :            :             const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
      93 [ #  # ][ #  # ]:          0 :         :m_pData( new TabDeckLayouter_Data( i_rParent, i_rPanels, i_eAlignment, i_eItemContent ) )
      94                 :            :     {
      95                 :          0 :     }
      96                 :            : 
      97                 :            :     //--------------------------------------------------------------------
      98         [ #  # ]:          0 :     TabDeckLayouter::~TabDeckLayouter()
      99                 :            :     {
     100         [ #  # ]:          0 :     }
     101                 :            : 
     102                 :            :     //--------------------------------------------------------------------
     103                 :          0 :     IMPLEMENT_IREFERENCE( TabDeckLayouter )
     104                 :            : 
     105                 :            :     //--------------------------------------------------------------------
     106                 :          0 :     TabItemContent TabDeckLayouter::GetTabItemContent() const
     107                 :            :     {
     108         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     109                 :          0 :             return TABITEM_IMAGE_AND_TEXT;
     110                 :          0 :         return m_pData->pTabBar->GetTabItemContent();
     111                 :            :     }
     112                 :            : 
     113                 :            :     //--------------------------------------------------------------------
     114                 :          0 :     void TabDeckLayouter::SetTabItemContent( const TabItemContent& i_eItemContent )
     115                 :            :     {
     116         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     117                 :          0 :             return;
     118                 :          0 :         m_pData->pTabBar->SetTabItemContent( i_eItemContent );
     119                 :            :     }
     120                 :            : 
     121                 :            :     //--------------------------------------------------------------------
     122                 :          0 :     TabAlignment TabDeckLayouter::GetTabAlignment() const
     123                 :            :     {
     124         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     125                 :          0 :             return TABS_RIGHT;
     126                 :          0 :         return m_pData->eAlignment;
     127                 :            :     }
     128                 :            : 
     129                 :            :     //--------------------------------------------------------------------
     130                 :          0 :     Rectangle TabDeckLayouter::Layout( const Rectangle& i_rDeckPlayground )
     131                 :            :     {
     132         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     133                 :          0 :             return i_rDeckPlayground;
     134                 :            : 
     135         [ #  # ]:          0 :         const Size aPreferredSize( m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_PREFERRED ) );
     136         [ #  # ]:          0 :         if ( lcl_isVerticalTabBar( m_pData->eAlignment ) )
     137                 :            :         {
     138         [ #  # ]:          0 :             Size aTabBarSize =  ( aPreferredSize.Width() < i_rDeckPlayground.GetWidth() )
     139                 :            :                             ?   aPreferredSize
     140 [ #  # ][ #  # ]:          0 :                             :   m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_MINIMUM );
     141         [ #  # ]:          0 :             aTabBarSize.Height() = i_rDeckPlayground.GetHeight();
     142                 :            : 
     143                 :          0 :             Rectangle aPanelRect( i_rDeckPlayground );
     144         [ #  # ]:          0 :             if ( m_pData->eAlignment == TABS_RIGHT )
     145                 :            :             {
     146                 :          0 :                 aPanelRect.Right() -= aTabBarSize.Width();
     147         [ #  # ]:          0 :                 Point aTabBarTopLeft( aPanelRect.TopRight() );
     148                 :          0 :                 aTabBarTopLeft.X() += 1;
     149         [ #  # ]:          0 :                 m_pData->pTabBar->SetPosSizePixel( aTabBarTopLeft, aTabBarSize );
     150                 :            :             }
     151                 :            :             else
     152                 :            :             {
     153         [ #  # ]:          0 :                 m_pData->pTabBar->SetPosSizePixel( aPanelRect.TopLeft(), aTabBarSize );
     154                 :          0 :                 aPanelRect.Left() += aTabBarSize.Width();
     155                 :            :             }
     156         [ #  # ]:          0 :             if ( aPanelRect.Left() >= aPanelRect.Right() )
     157         [ #  # ]:          0 :                 aPanelRect = Rectangle();
     158                 :            : 
     159                 :          0 :             return aPanelRect;
     160                 :            :         }
     161                 :            : 
     162         [ #  # ]:          0 :         Size aTabBarSize =  ( aPreferredSize.Height() < i_rDeckPlayground.GetHeight() )
     163                 :            :                         ?   aPreferredSize
     164 [ #  # ][ #  # ]:          0 :                         :   m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_MINIMUM );
     165         [ #  # ]:          0 :         aTabBarSize.Width() = i_rDeckPlayground.GetWidth();
     166                 :            : 
     167                 :          0 :         Rectangle aPanelRect( i_rDeckPlayground );
     168         [ #  # ]:          0 :         if ( m_pData->eAlignment == TABS_TOP )
     169                 :            :         {
     170         [ #  # ]:          0 :             m_pData->pTabBar->SetPosSizePixel( aPanelRect.TopLeft(), aTabBarSize );
     171                 :          0 :             aPanelRect.Top() += aTabBarSize.Height();
     172                 :            :         }
     173                 :            :         else
     174                 :            :         {
     175                 :          0 :             aPanelRect.Bottom() -= aTabBarSize.Height();
     176         [ #  # ]:          0 :             Point aTabBarTopLeft( aPanelRect.BottomLeft() );
     177                 :          0 :             aTabBarTopLeft.Y() -= 1;
     178         [ #  # ]:          0 :             m_pData->pTabBar->SetPosSizePixel( aTabBarTopLeft, aTabBarSize );
     179                 :            :         }
     180         [ #  # ]:          0 :         if ( aPanelRect.Top() >= aPanelRect.Bottom() )
     181         [ #  # ]:          0 :             aPanelRect = Rectangle();
     182                 :            : 
     183                 :          0 :         return aPanelRect;
     184                 :            :     }
     185                 :            : 
     186                 :            :     //--------------------------------------------------------------------
     187                 :          0 :     void TabDeckLayouter::Destroy()
     188                 :            :     {
     189                 :          0 :         m_pData->pTabBar.reset();
     190                 :          0 :     }
     191                 :            : 
     192                 :            :     //--------------------------------------------------------------------
     193                 :          0 :     void TabDeckLayouter::SetFocusToPanelSelector()
     194                 :            :     {
     195         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     196                 :          0 :             return;
     197                 :          0 :         m_pData->pTabBar->GrabFocus();
     198                 :            :     }
     199                 :            : 
     200                 :            :     //--------------------------------------------------------------------
     201                 :          0 :     size_t TabDeckLayouter::GetAccessibleChildCount() const
     202                 :            :     {
     203         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     204                 :          0 :             return 0;
     205                 :            : 
     206                 :          0 :         return 1;
     207                 :            :     }
     208                 :            : 
     209                 :            :     //--------------------------------------------------------------------
     210                 :          0 :     Reference< XAccessible > TabDeckLayouter::GetAccessibleChild( const size_t i_nChildIndex, const Reference< XAccessible >& i_rParentAccessible )
     211                 :            :     {
     212                 :            :         (void)i_nChildIndex;
     213                 :            :         (void)i_rParentAccessible;
     214         [ #  # ]:          0 :         if ( lcl_checkDisposed( *m_pData ) )
     215                 :          0 :             return NULL;
     216                 :            : 
     217                 :          0 :         return m_pData->pTabBar->GetAccessible( sal_True );
     218                 :            :     }
     219                 :            : 
     220                 :            : //........................................................................
     221                 :            : } // namespace svt
     222                 :            : //........................................................................
     223                 :            : 
     224                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10