LCOV - code coverage report
Current view: top level - framework/source/uielement - statusbaritem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 32 118 27.1 %
Date: 2014-04-11 Functions: 6 22 27.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <uielement/statusbaritem.hxx>
      21             : #include <vcl/status.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : 
      24             : #include <com/sun/star/ui/ItemStyle.hpp>
      25             : 
      26             : using namespace com::sun::star::ui;
      27             : 
      28             : using rtl::OUString;
      29             : using com::sun::star::uno::RuntimeException;
      30             : 
      31             : namespace framework
      32             : {
      33             : 
      34             : namespace
      35             : {
      36        7205 : static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
      37             : {
      38        7205 :     sal_uInt16 nStyle( 0 );
      39             : 
      40        7205 :     if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
      41          17 :         nStyle |= ItemStyle::ALIGN_RIGHT;
      42        7188 :     else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
      43        2364 :         nStyle |= ItemStyle::ALIGN_LEFT;
      44             :     else
      45        4824 :         nStyle |= ItemStyle::ALIGN_CENTER;
      46             : 
      47        7205 :     if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
      48           0 :         nStyle |= ItemStyle::DRAW_FLAT;
      49        7205 :     else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
      50           0 :         nStyle |= ItemStyle::DRAW_OUT3D;
      51             :     else
      52        7205 :         nStyle |= ItemStyle::DRAW_IN3D;
      53             : 
      54        7205 :     if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
      55        2867 :         nStyle |= ItemStyle::AUTO_SIZE;
      56             : 
      57        7205 :     if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
      58        3611 :         nStyle |= ItemStyle::OWNER_DRAW;
      59             : 
      60        7205 :     return nStyle;
      61             : }
      62             : }
      63             : 
      64        7205 : StatusbarItem::StatusbarItem(
      65             :     StatusBar              *pStatusBar,
      66             :     AddonStatusbarItemData *pItemData,
      67             :     sal_uInt16              nId,
      68             :     const rtl::OUString&    aCommand )
      69             :     : StatusbarItem_Base( m_aMutex )
      70             :     , m_pStatusBar( pStatusBar )
      71             :     , m_pItemData( pItemData )
      72             :     , m_nId( nId )
      73             :     , m_nStyle( 0 )
      74        7205 :     , m_aCommand( aCommand )
      75             : {
      76        7205 :     if ( m_pStatusBar )
      77             :         m_nStyle = impl_convertItemBitsToItemStyle(
      78        7205 :             m_pStatusBar->GetItemBits( m_nId ) );
      79        7205 : }
      80             : 
      81       14410 : StatusbarItem::~StatusbarItem()
      82             : {
      83       14410 : }
      84             : 
      85        7205 : void SAL_CALL StatusbarItem::disposing()
      86             : {
      87        7205 :     osl::MutexGuard aGuard( m_aMutex );
      88        7205 :     m_pItemData = 0;
      89        7205 :     m_pStatusBar = 0;
      90        7205 : }
      91             : 
      92           0 : OUString SAL_CALL StatusbarItem::getCommand()
      93             : throw (RuntimeException, std::exception)
      94             : {
      95           0 :     osl::MutexGuard aGuard( m_aMutex );
      96           0 :     return m_aCommand;
      97             : }
      98             : 
      99           0 : ::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
     100             : throw (RuntimeException, std::exception)
     101             : {
     102           0 :     osl::MutexGuard aGuard( m_aMutex );
     103           0 :     return m_nId;
     104             : }
     105             : 
     106           0 : ::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
     107             : throw (RuntimeException, std::exception)
     108             : {
     109           0 :     SolarMutexGuard aGuard;
     110           0 :     if ( m_pStatusBar )
     111           0 :         return m_pStatusBar->GetItemWidth( m_nId );
     112             : 
     113           0 :     return ::sal_uInt32(0);
     114             : }
     115             : 
     116           0 : ::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
     117             : throw (RuntimeException, std::exception)
     118             : {
     119           0 :     osl::MutexGuard aGuard( m_aMutex );
     120           0 :     return m_nStyle;
     121             : }
     122             : 
     123           0 : ::sal_Int32 SAL_CALL StatusbarItem::getOffset()
     124             : throw (RuntimeException, std::exception)
     125             : {
     126           0 :     SolarMutexGuard aGuard;
     127           0 :     if ( m_pStatusBar )
     128           0 :         return m_pStatusBar->GetItemOffset( m_nId );
     129             : 
     130           0 :     return ::sal_Int32(0);
     131             : }
     132             : 
     133           0 : ::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
     134             : throw (RuntimeException, std::exception)
     135             : {
     136           0 :     SolarMutexGuard aGuard;
     137           0 :     ::com::sun::star::awt::Rectangle aAWTRect;
     138           0 :     if ( m_pStatusBar )
     139             :     {
     140           0 :         Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
     141           0 :         return ::com::sun::star::awt::Rectangle( aRect.Left(),
     142           0 :                                                  aRect.Top(),
     143           0 :                                                  aRect.GetWidth(),
     144           0 :                                                  aRect.GetHeight() );
     145             :     }
     146             : 
     147           0 :     return aAWTRect;
     148             : }
     149             : 
     150           0 : OUString SAL_CALL StatusbarItem::getText()
     151             : throw (RuntimeException, std::exception)
     152             : {
     153           0 :     SolarMutexGuard aGuard;
     154           0 :     if ( m_pStatusBar )
     155           0 :         return m_pStatusBar->GetItemText( m_nId );
     156             : 
     157           0 :     return OUString();
     158             : }
     159             : 
     160        1130 : void SAL_CALL StatusbarItem::setText( const OUString& rText )
     161             : throw (RuntimeException, std::exception)
     162             : {
     163        1130 :     SolarMutexGuard aGuard;
     164        1130 :     if ( m_pStatusBar )
     165        1130 :         m_pStatusBar->SetItemText( m_nId, rText );;
     166        1130 : }
     167             : 
     168           0 : OUString SAL_CALL StatusbarItem::getHelpText()
     169             : throw (RuntimeException, std::exception)
     170             : {
     171           0 :     SolarMutexGuard aGuard;
     172           0 :     if ( m_pStatusBar )
     173           0 :         return m_pStatusBar->GetHelpText( m_nId );
     174             : 
     175           0 :     return OUString();
     176             : }
     177             : 
     178           0 : void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
     179             : throw (RuntimeException, std::exception)
     180             : {
     181           0 :     SolarMutexGuard aGuard;
     182           0 :     if ( m_pStatusBar )
     183           0 :         m_pStatusBar->SetHelpText( m_nId, rHelpText );;
     184           0 : }
     185             : 
     186           0 : OUString SAL_CALL StatusbarItem::getQuickHelpText()
     187             : throw (RuntimeException, std::exception)
     188             : {
     189           0 :     SolarMutexGuard aGuard;
     190           0 :     if ( m_pStatusBar )
     191           0 :         return m_pStatusBar->GetHelpText( m_nId );
     192             : 
     193           0 :     return OUString();
     194             : }
     195             : 
     196           0 : void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
     197             : throw (RuntimeException, std::exception)
     198             : {
     199           0 :     SolarMutexGuard aGuard;
     200           0 :     if ( m_pStatusBar )
     201           0 :         m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
     202           0 : }
     203             : 
     204           0 : OUString SAL_CALL StatusbarItem::getAccessibleName()
     205             : throw (RuntimeException, std::exception)
     206             : {
     207           0 :     SolarMutexGuard aGuard;
     208           0 :     if ( m_pStatusBar )
     209           0 :         return m_pStatusBar->GetAccessibleName( m_nId );
     210             : 
     211           0 :     return OUString();
     212             : }
     213             : 
     214           0 : void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
     215             : throw (RuntimeException, std::exception)
     216             : {
     217           0 :     SolarMutexGuard aGuard;
     218           0 :     if ( m_pStatusBar )
     219           0 :         m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
     220           0 : }
     221             : 
     222           0 : sal_Bool SAL_CALL StatusbarItem::getVisible()
     223             : throw (RuntimeException, std::exception)
     224             : {
     225           0 :     SolarMutexGuard aGuard;
     226           0 :     if ( m_pStatusBar )
     227           0 :         return m_pStatusBar->IsItemVisible( m_nId );
     228             : 
     229           0 :     return sal_False;
     230             : }
     231             : 
     232           0 : void SAL_CALL StatusbarItem::setVisible( sal_Bool bVisible )
     233             : throw (RuntimeException, std::exception)
     234             : {
     235           0 :     SolarMutexGuard aGuard;
     236           0 :     if ( !m_pStatusBar )
     237           0 :         return;
     238             : 
     239           0 :     if ( bool(bVisible) != m_pStatusBar->IsItemVisible( m_nId ) )
     240             :     {
     241           0 :         if ( bVisible )
     242           0 :             m_pStatusBar->ShowItem( m_nId );
     243             :         else
     244           0 :             m_pStatusBar->HideItem( m_nId );
     245           0 :     }
     246             : }
     247             : 
     248           0 : void SAL_CALL StatusbarItem::repaint(  )
     249             : throw (RuntimeException, std::exception)
     250             : {
     251           0 :     SolarMutexGuard aGuard;
     252           0 :     if ( m_pStatusBar )
     253             :     {
     254           0 :         m_pStatusBar->RedrawItem( m_nId );
     255           0 :     }
     256           0 : }
     257             : 
     258             : }
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10