LCOV - code coverage report
Current view: top level - svx/source/stbctrls - xmlsecctrl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 79 0.0 %
Date: 2014-04-14 Functions: 0 10 0.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           0 : 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             : 
      64           0 :     if (_rStb.GetDPIScaleFactor() > 1)
      65             :     {
      66           0 :         Image arr[3] = {mpImpl->maImage, mpImpl->maImageBroken, mpImpl->maImageNotValidated};
      67             : 
      68           0 :         for (int i = 0; i < 3; i++)
      69             :         {
      70           0 :             BitmapEx b = arr[i].GetBitmapEx();
      71           0 :             b.Scale(_rStb.GetDPIScaleFactor(), _rStb.GetDPIScaleFactor(), BMP_SCALE_FAST);
      72           0 :             arr[i] = Image(b);
      73           0 :         }
      74             : 
      75           0 :         mpImpl->maImage = arr[0];
      76           0 :         mpImpl->maImageBroken = arr[1];
      77           0 :         mpImpl->maImageNotValidated = arr[2];
      78             :     }
      79             : 
      80           0 : }
      81             : 
      82           0 : XmlSecStatusBarControl::~XmlSecStatusBarControl()
      83             : {
      84           0 :     delete mpImpl;
      85           0 : }
      86             : 
      87           0 : void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
      88             : {
      89           0 :     if( SFX_ITEM_AVAILABLE != eState )
      90             :     {
      91           0 :         mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
      92             :     }
      93           0 :     else if( pState->ISA( SfxUInt16Item ) )
      94             :     {
      95           0 :         mpImpl->mnState = ( ( SfxUInt16Item* ) pState )->GetValue();
      96             :     }
      97             :     else
      98             :     {
      99             :         SAL_WARN( "svx.stbcrtls", "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
     100           0 :         mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
     101             :     }
     102             : 
     103           0 :     if( GetStatusBar().AreItemsVisible() )              // necessary ?
     104           0 :         GetStatusBar().SetItemData( GetId(), 0 );
     105             : 
     106           0 :     GetStatusBar().SetItemText( GetId(), "" );    // necessary ?
     107             : 
     108           0 :     sal_uInt16 nResId = RID_SVXSTR_XMLSEC_NO_SIG;
     109           0 :     if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
     110           0 :         nResId = RID_SVXSTR_XMLSEC_SIG_OK;
     111           0 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
     112           0 :         nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK;
     113           0 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
     114           0 :         nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY;
     115           0 :     else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK )
     116           0 :         nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG;
     117             : 
     118           0 :     GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) );
     119           0 : }
     120             : 
     121           0 : void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
     122             : {
     123           0 :     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
     124             :     {
     125           0 :         PopupMenu aPopupMenu( ResId( RID_SVXMNU_XMLSECSTATBAR, DIALOG_MGR() ) );
     126           0 :         if( aPopupMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
     127             :         {
     128           0 :             ::com::sun::star::uno::Any a;
     129           0 :             SfxUInt16Item aState( GetSlotId(), 0 );
     130           0 :             INetURLObject aObj( m_aCommandURL );
     131             : 
     132           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     133           0 :             aArgs[0].Name  = aObj.GetURLPath();
     134           0 :             aState.QueryValue( a );
     135           0 :             aArgs[0].Value = a;
     136             : 
     137           0 :             execute( aArgs );
     138           0 :         }
     139             :     }
     140             :     else
     141           0 :         SfxStatusBarControl::Command( rCEvt );
     142           0 : }
     143             : 
     144           0 : void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
     145             : {
     146           0 :     OutputDevice*       pDev = rUsrEvt.GetDevice();
     147             :     DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
     148           0 :     Rectangle           aRect = rUsrEvt.GetRect();
     149           0 :     Color               aOldLineColor = pDev->GetLineColor();
     150           0 :     Color               aOldFillColor = pDev->GetFillColor();
     151             : 
     152           0 :     pDev->SetLineColor();
     153           0 :     pDev->SetFillColor( pDev->GetBackground().GetColor() );
     154             : 
     155           0 :     long yOffset = (aRect.GetHeight() - mpImpl->maImage.GetSizePixel().Height()) / 2;
     156             : 
     157           0 :     if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
     158             :     {
     159           0 :         aRect.Top() += yOffset;
     160           0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage );
     161             :     }
     162           0 :     else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
     163             :     {
     164           0 :         aRect.Top() += yOffset;
     165           0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken );
     166             :     }
     167           0 :     else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
     168           0 :         || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
     169             :     {
     170           0 :         aRect.Top() += yOffset;
     171           0 :         pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated );
     172             :     }
     173             :     else
     174           0 :         pDev->DrawRect( aRect );
     175             : 
     176           0 :     pDev->SetLineColor( aOldLineColor );
     177           0 :     pDev->SetFillColor( aOldFillColor );
     178           0 : }
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10