1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 // include ---------------------------------------------------------------
32 #include <tools/shl.hxx>
33 #ifndef _STATUS_HXX //autogen
34 #include <vcl/status.hxx>
36 #ifndef _MENU_HXX //autogen
37 #include <vcl/menu.hxx>
39 #include <vcl/image.hxx>
40 //#ifndef _SFXITEMPOOL_HXX
41 //#include <svl/itempool.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/module.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/objsh.hxx>
48 #include <svl/eitem.hxx>
51 #include <xmlsecurity/stbcontrl.hxx>
53 #define PAINT_OFFSET 5
55 //#include "sizeitem.hxx"
56 //#include "dialmgr.hxx"
57 //#include "dlgutil.hxx"
58 //#include "stbctrls.h"
60 //#include "dialogs.hrc"
62 /*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
63 #include <unotools/localedatawrapper.hxx>
65 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
66 #include <comphelper/processfactory.hxx>
71 SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl
, SfxBoolItem
);
74 class FunctionPopup_Impl : public PopupMenu
77 FunctionPopup_Impl( USHORT nCheck );
79 USHORT GetSelected() const { return nSelected; }
84 virtual void Select();
87 // -----------------------------------------------------------------------
89 FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) :
90 PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
97 // -----------------------------------------------------------------------
99 void FunctionPopup_Impl::Select()
101 nSelected = GetCurItemId();
107 struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
116 XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nId
, StatusBar
& _rStb
, SfxBindings
& _rBind
)
117 :SfxStatusBarControl( _nId
, _rStb
, _rBind
)
119 ,mpImpl( new XmlSecStatusBarControl_Impl
)
121 mpImpl
->mbSigned
= false;
122 // pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
125 XmlSecStatusBarControl::~XmlSecStatusBarControl()
130 void XmlSecStatusBarControl::StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
132 GetStatusBar().SetHelpText( GetId(), String() ); // necessary ?
133 GetStatusBar().SetHelpId( GetId(), nSID
); // necessary ?
135 if( SFX_ITEM_AVAILABLE
!= eState
)
137 mpImpl
->mbSigned
= false;
139 else if( pState
->ISA( SfxBoolItem
) )
141 mpImpl
->mbSigned
= ( ( SfxBoolItem
* ) pState
)->GetValue();
145 DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
146 mpImpl
->mbSigned
= false;
149 if( GetStatusBar().AreItemsVisible() ) // necessary ?
150 GetStatusBar().SetItemData( GetId(), 0 );
152 GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
155 void XmlSecStatusBarControl::Command( const CommandEvent
& rCEvt
)
157 // can / has to be done when integrated in Office!
158 // if( rCEvt.GetCommand() == .... )
161 // GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L );
164 SfxStatusBarControl::Command( rCEvt
);
167 void XmlSecStatusBarControl::Paint( const UserDrawEvent
& rUsrEvt
)
169 OutputDevice
* pDev
= rUsrEvt
.GetDevice();
170 DBG_ASSERT( pDev
, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
171 const Rectangle
& rRect
= rUsrEvt
.GetRect();
172 StatusBar
& rBar
= GetStatusBar();
173 Point aItemPos
= rBar
.GetItemTextPos( GetId() );
174 Color aOldLineColor
= pDev
->GetLineColor();
175 Color aOldFillColor
= pDev
->GetFillColor();
177 // just 4 testing until we've got a bitmap
178 pDev
->SetLineColor();
179 pDev
->SetFillColor( pDev
->GetBackground().GetColor() );
181 String
s( String::CreateFromAscii( mpImpl
->mbSigned
? "X" : "-" ) );
182 pDev
->DrawRect( rRect
);
183 pDev
->DrawText( Point( rRect
.Left() + rRect
.GetWidth() / 2 - pDev
->GetTextWidth( s
) / 2, aItemPos
.Y() ), s
);
185 pDev
->SetLineColor( aOldLineColor
);
186 pDev
->SetFillColor( aOldFillColor
);