LCOV - code coverage report
Current view: top level - svx/source/stbctrls - xmlsecctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 67 59.7 %
Date: 2012-08-25 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 44 128 34.4 %

           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 <tools/shl.hxx>
      31                 :            : #include <vcl/status.hxx>
      32                 :            : #include <vcl/menu.hxx>
      33                 :            : #include <vcl/image.hxx>
      34                 :            : #include <sfx2/signaturestate.hxx>
      35                 :            : #include <sfx2/app.hxx>
      36                 :            : #include <sfx2/module.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : #include <sfx2/objsh.hxx>
      39                 :            : #include <sfx2/sfxsids.hrc>
      40                 :            : 
      41                 :            : #include <svl/intitem.hxx>
      42                 :            : 
      43                 :            : #include <svl/eitem.hxx>
      44                 :            : 
      45                 :            : #include <svx/dialogs.hrc>
      46                 :            : #include <svx/dialmgr.hxx>
      47                 :            : #include "svx/xmlsecctrl.hxx"
      48                 :            : #include <tools/urlobj.hxx>
      49                 :            : 
      50         [ +  - ]:       1302 : SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxUInt16Item );
      51                 :            : 
      52 [ +  - ][ +  - ]:       2286 : struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
         [ +  - ][ +  - ]
      53                 :            : {
      54                 :            :     Point       maPos;
      55                 :            :     Size        maSize;
      56                 :            :     sal_uInt16      mnState;
      57                 :            :     Image       maImage;
      58                 :            :     Image       maImageBroken;
      59                 :            :     Image       maImageNotValidated;
      60                 :            : };
      61                 :            : 
      62                 :            : 
      63                 :       1143 : XmlSecStatusBarControl::XmlSecStatusBarControl( sal_uInt16 _nSlotId,  sal_uInt16 _nId, StatusBar& _rStb )
      64                 :            :     :SfxStatusBarControl( _nSlotId, _nId, _rStb )
      65 [ +  - ][ +  - ]:       1143 :     ,mpImpl( new XmlSecStatusBarControl_Impl )
      66                 :            : {
      67                 :       1143 :     mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
      68                 :            : 
      69 [ +  - ][ +  - ]:       1143 :     mpImpl->maImage             = Image( SVX_RES( RID_SVXBMP_SIGNET              ) );
         [ +  - ][ +  - ]
      70 [ +  - ][ +  - ]:       1143 :     mpImpl->maImageBroken       = Image( SVX_RES( RID_SVXBMP_SIGNET_BROKEN       ) );
         [ +  - ][ +  - ]
      71 [ +  - ][ +  - ]:       1143 :     mpImpl->maImageNotValidated = Image( SVX_RES( RID_SVXBMP_SIGNET_NOTVALIDATED ) );
         [ +  - ][ +  - ]
      72                 :       1143 : }
      73                 :            : 
      74                 :       1143 : XmlSecStatusBarControl::~XmlSecStatusBarControl()
      75                 :            : {
      76 [ +  - ][ +  - ]:       1143 :     delete mpImpl;
      77         [ -  + ]:       2286 : }
      78                 :            : 
      79                 :       1885 : void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
      80                 :            : {
      81         [ -  + ]:       1885 :     if( SFX_ITEM_AVAILABLE != eState )
      82                 :            :     {
      83                 :          0 :         mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
      84                 :            :     }
      85         [ +  - ]:       1885 :     else if( pState->ISA( SfxUInt16Item ) )
      86                 :            :     {
      87                 :       1885 :         mpImpl->mnState = ( ( SfxUInt16Item* ) pState )->GetValue();
      88                 :            :     }
      89                 :            :     else
      90                 :            :     {
      91                 :            :         SAL_WARN( "svx.stbcrtls", "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
      92                 :          0 :         mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
      93                 :            :     }
      94                 :            : 
      95         [ +  - ]:       1885 :     if( GetStatusBar().AreItemsVisible() )              // necessary ?
      96                 :       1885 :         GetStatusBar().SetItemData( GetId(), 0 );
      97                 :            : 
      98         [ +  - ]:       1885 :     GetStatusBar().SetItemText( GetId(), String() );    // necessary ?
      99                 :            : 
     100                 :       1885 :     sal_uInt16 nResId = RID_SVXSTR_XMLSEC_NO_SIG;
     101         [ -  + ]:       1885 :     if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
     102                 :          0 :         nResId = RID_SVXSTR_XMLSEC_SIG_OK;
     103         [ -  + ]:       1885 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
     104                 :          0 :         nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK;
     105         [ -  + ]:       1885 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
     106                 :          0 :         nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY;
     107         [ -  + ]:       1885 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK )
     108                 :          0 :         nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG;
     109                 :            : 
     110 [ +  - ][ +  - ]:       1885 :     GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) );
         [ +  - ][ +  - ]
     111                 :       1885 : }
     112                 :            : 
     113                 :          0 : void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
     114                 :            : {
     115         [ #  # ]:          0 :     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
     116                 :            :     {
     117 [ #  # ][ #  # ]:          0 :         PopupMenu aPopupMenu( ResId( RID_SVXMNU_XMLSECSTATBAR, DIALOG_MGR() ) );
     118 [ #  # ][ #  # ]:          0 :         if( aPopupMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
     119                 :            :         {
     120                 :          0 :             ::com::sun::star::uno::Any a;
     121         [ #  # ]:          0 :             SfxUInt16Item aState( GetSlotId(), 0 );
     122         [ #  # ]:          0 :             INetURLObject aObj( m_aCommandURL );
     123                 :            : 
     124         [ #  # ]:          0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     125 [ #  # ][ #  # ]:          0 :             aArgs[0].Name  = aObj.GetURLPath();
     126         [ #  # ]:          0 :             aState.QueryValue( a );
     127         [ #  # ]:          0 :             aArgs[0].Value = a;
     128                 :            : 
     129 [ #  # ][ #  # ]:          0 :             execute( aArgs );
         [ #  # ][ #  # ]
     130         [ #  # ]:          0 :         }
     131                 :            :     }
     132                 :            :     else
     133                 :          0 :         SfxStatusBarControl::Command( rCEvt );
     134                 :          0 : }
     135                 :            : 
     136                 :       2772 : void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
     137                 :            : {
     138                 :       2772 :     OutputDevice*       pDev = rUsrEvt.GetDevice();
     139                 :            :     DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
     140                 :       2772 :     Rectangle           aRect = rUsrEvt.GetRect();
     141                 :       2772 :     Color               aOldLineColor = pDev->GetLineColor();
     142                 :       2772 :     Color               aOldFillColor = pDev->GetFillColor();
     143                 :            : 
     144         [ +  - ]:       2772 :     pDev->SetLineColor();
     145 [ +  - ][ +  - ]:       2772 :     pDev->SetFillColor( pDev->GetBackground().GetColor() );
     146                 :            : 
     147         [ -  + ]:       2772 :     if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
     148                 :            :     {
     149                 :          0 :         ++aRect.Top();
     150         [ #  # ]:          0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage );
     151                 :            :     }
     152         [ -  + ]:       2772 :     else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
     153                 :            :     {
     154                 :          0 :         ++aRect.Top();
     155         [ #  # ]:          0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken );
     156                 :            :     }
     157 [ +  - ][ -  + ]:       2772 :     else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
     158                 :            :         || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
     159                 :            :     {
     160                 :          0 :         ++aRect.Top();
     161         [ #  # ]:          0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated );
     162                 :            :     }
     163                 :            :     else
     164         [ +  - ]:       2772 :         pDev->DrawRect( aRect );
     165                 :            : 
     166         [ +  - ]:       2772 :     pDev->SetLineColor( aOldLineColor );
     167         [ +  - ]:       2772 :     pDev->SetFillColor( aOldFillColor );
     168                 :       2772 : }
     169                 :            : 
     170                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10