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