Update ooo320-m1
[ooovba.git] / xmlsecurity / source / dialogs / stbcontrl.cxx
blob8f8f18e332af4460f8c647caddc66db74a877277
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stbcontrl.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #ifndef _STATUS_HXX //autogen
37 #include <vcl/status.hxx>
38 #endif
39 #ifndef _MENU_HXX //autogen
40 #include <vcl/menu.hxx>
41 #endif
42 #include <vcl/image.hxx>
43 //#ifndef _SFXITEMPOOL_HXX
44 //#include <svtools/itempool.hxx>
45 //#endif
46 #include <sfx2/app.hxx>
47 #include <sfx2/module.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/objsh.hxx>
51 #include <svtools/eitem.hxx>
54 #include <xmlsecurity/stbcontrl.hxx>
56 #define PAINT_OFFSET 5
58 //#include "sizeitem.hxx"
59 //#include "dialmgr.hxx"
60 //#include "dlgutil.hxx"
61 //#include "stbctrls.h"
63 //#include "dialogs.hrc"
65 /*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
66 #include <unotools/localedatawrapper.hxx>
67 #endif
68 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
69 #include <comphelper/processfactory.hxx>
70 #endif*/
74 SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxBoolItem );
77 class FunctionPopup_Impl : public PopupMenu
79 public:
80 FunctionPopup_Impl( USHORT nCheck );
82 USHORT GetSelected() const { return nSelected; }
84 private:
85 USHORT nSelected;
87 virtual void Select();
90 // -----------------------------------------------------------------------
92 FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) :
93 PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
94 nSelected( 0 )
96 if (nCheck)
97 CheckItem( nCheck );
100 // -----------------------------------------------------------------------
102 void FunctionPopup_Impl::Select()
104 nSelected = GetCurItemId();
110 struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
112 Point maPos;
113 Size maSize;
114 bool mbSigned;
115 Image maImage;
119 XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nId, StatusBar& _rStb, SfxBindings& _rBind )
120 :SfxStatusBarControl( _nId, _rStb, _rBind )
122 ,mpImpl( new XmlSecStatusBarControl_Impl )
124 mpImpl->mbSigned = false;
125 // pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
128 XmlSecStatusBarControl::~XmlSecStatusBarControl()
130 delete mpImpl;
133 void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
135 GetStatusBar().SetHelpText( GetId(), String() ); // necessary ?
136 GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ?
138 if( SFX_ITEM_AVAILABLE != eState )
140 mpImpl->mbSigned = false;
142 else if( pState->ISA( SfxBoolItem ) )
144 mpImpl->mbSigned = ( ( SfxBoolItem* ) pState )->GetValue();
146 else
148 DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
149 mpImpl->mbSigned = false;
152 if( GetStatusBar().AreItemsVisible() ) // necessary ?
153 GetStatusBar().SetItemData( GetId(), 0 );
155 GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
158 void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
160 // can / has to be done when integrated in Office!
161 // if( rCEvt.GetCommand() == .... )
162 if( false )
164 // GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L );
166 else
167 SfxStatusBarControl::Command( rCEvt );
170 void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
172 OutputDevice* pDev = rUsrEvt.GetDevice();
173 DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
174 const Rectangle& rRect = rUsrEvt.GetRect();
175 StatusBar& rBar = GetStatusBar();
176 Point aItemPos = rBar.GetItemTextPos( GetId() );
177 Color aOldLineColor = pDev->GetLineColor();
178 Color aOldFillColor = pDev->GetFillColor();
180 // just 4 testing until we've got a bitmap
181 pDev->SetLineColor();
182 pDev->SetFillColor( pDev->GetBackground().GetColor() );
184 String s( String::CreateFromAscii( mpImpl->mbSigned? "X" : "-" ) );
185 pDev->DrawRect( rRect );
186 pDev->DrawText( Point( rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( s ) / 2, aItemPos.Y() ), s );
188 pDev->SetLineColor( aOldLineColor );
189 pDev->SetFillColor( aOldFillColor );