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

Generated by: LCOV version 1.10