1*06b3ce53SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*06b3ce53SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*06b3ce53SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*06b3ce53SAndrew Rist * distributed with this work for additional information
6*06b3ce53SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*06b3ce53SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*06b3ce53SAndrew Rist * "License"); you may not use this file except in compliance
9*06b3ce53SAndrew Rist * with the License. You may obtain a copy of the License at
10*06b3ce53SAndrew Rist *
11*06b3ce53SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*06b3ce53SAndrew Rist *
13*06b3ce53SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*06b3ce53SAndrew Rist * software distributed under the License is distributed on an
15*06b3ce53SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06b3ce53SAndrew Rist * KIND, either express or implied. See the License for the
17*06b3ce53SAndrew Rist * specific language governing permissions and limitations
18*06b3ce53SAndrew Rist * under the License.
19*06b3ce53SAndrew Rist *
20*06b3ce53SAndrew Rist *************************************************************/
21*06b3ce53SAndrew Rist
22*06b3ce53SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #ifndef _STATUS_HXX //autogen
30cdf0e10cSrcweir #include <vcl/status.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _MENU_HXX //autogen
33cdf0e10cSrcweir #include <vcl/menu.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <vcl/image.hxx>
36cdf0e10cSrcweir //#ifndef _SFXITEMPOOL_HXX
37cdf0e10cSrcweir //#include <svl/itempool.hxx>
38cdf0e10cSrcweir //#endif
39cdf0e10cSrcweir #include <sfx2/app.hxx>
40cdf0e10cSrcweir #include <sfx2/module.hxx>
41cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42cdf0e10cSrcweir #include <sfx2/objsh.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include <svl/eitem.hxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include <xmlsecurity/stbcontrl.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #define PAINT_OFFSET 5
50cdf0e10cSrcweir
51cdf0e10cSrcweir //#include "sizeitem.hxx"
52cdf0e10cSrcweir //#include "dialmgr.hxx"
53cdf0e10cSrcweir //#include "dlgutil.hxx"
54cdf0e10cSrcweir //#include "stbctrls.h"
55cdf0e10cSrcweir
56cdf0e10cSrcweir //#include "dialogs.hrc"
57cdf0e10cSrcweir
58cdf0e10cSrcweir /*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
59cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
62cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
63cdf0e10cSrcweir #endif*/
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir
67cdf0e10cSrcweir SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxBoolItem );
68cdf0e10cSrcweir
69cdf0e10cSrcweir /*
70cdf0e10cSrcweir class FunctionPopup_Impl : public PopupMenu
71cdf0e10cSrcweir {
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir FunctionPopup_Impl( sal_uInt16 nCheck );
74cdf0e10cSrcweir
75cdf0e10cSrcweir sal_uInt16 GetSelected() const { return nSelected; }
76cdf0e10cSrcweir
77cdf0e10cSrcweir private:
78cdf0e10cSrcweir sal_uInt16 nSelected;
79cdf0e10cSrcweir
80cdf0e10cSrcweir virtual void Select();
81cdf0e10cSrcweir };
82cdf0e10cSrcweir
83cdf0e10cSrcweir // -----------------------------------------------------------------------
84cdf0e10cSrcweir
85cdf0e10cSrcweir FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt16 nCheck ) :
86cdf0e10cSrcweir PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
87cdf0e10cSrcweir nSelected( 0 )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir if (nCheck)
90cdf0e10cSrcweir CheckItem( nCheck );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir // -----------------------------------------------------------------------
94cdf0e10cSrcweir
95cdf0e10cSrcweir void FunctionPopup_Impl::Select()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir nSelected = GetCurItemId();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir */
100cdf0e10cSrcweir
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
104cdf0e10cSrcweir {
105cdf0e10cSrcweir Point maPos;
106cdf0e10cSrcweir Size maSize;
107cdf0e10cSrcweir bool mbSigned;
108cdf0e10cSrcweir Image maImage;
109cdf0e10cSrcweir };
110cdf0e10cSrcweir
111cdf0e10cSrcweir
XmlSecStatusBarControl(sal_uInt16 _nId,StatusBar & _rStb,SfxBindings & _rBind)112cdf0e10cSrcweir XmlSecStatusBarControl::XmlSecStatusBarControl( sal_uInt16 _nId, StatusBar& _rStb, SfxBindings& _rBind )
113cdf0e10cSrcweir :SfxStatusBarControl( _nId, _rStb, _rBind )
114cdf0e10cSrcweir
115cdf0e10cSrcweir ,mpImpl( new XmlSecStatusBarControl_Impl )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir mpImpl->mbSigned = false;
118cdf0e10cSrcweir // pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
~XmlSecStatusBarControl()121cdf0e10cSrcweir XmlSecStatusBarControl::~XmlSecStatusBarControl()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir delete mpImpl;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)126cdf0e10cSrcweir void XmlSecStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir GetStatusBar().SetHelpText( GetId(), String() ); // necessary ?
129cdf0e10cSrcweir GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ?
130cdf0e10cSrcweir
131cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE != eState )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir mpImpl->mbSigned = false;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir else if( pState->ISA( SfxBoolItem ) )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir mpImpl->mbSigned = ( ( SfxBoolItem* ) pState )->GetValue();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir {
141cdf0e10cSrcweir DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
142cdf0e10cSrcweir mpImpl->mbSigned = false;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir if( GetStatusBar().AreItemsVisible() ) // necessary ?
146cdf0e10cSrcweir GetStatusBar().SetItemData( GetId(), 0 );
147cdf0e10cSrcweir
148cdf0e10cSrcweir GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)151cdf0e10cSrcweir void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir // can / has to be done when integrated in Office!
154cdf0e10cSrcweir // if( rCEvt.GetCommand() == .... )
155cdf0e10cSrcweir if( false )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir // GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L );
158cdf0e10cSrcweir }
159cdf0e10cSrcweir else
160cdf0e10cSrcweir SfxStatusBarControl::Command( rCEvt );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
Paint(const UserDrawEvent & rUsrEvt)163cdf0e10cSrcweir void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir OutputDevice* pDev = rUsrEvt.GetDevice();
166cdf0e10cSrcweir DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
167cdf0e10cSrcweir const Rectangle& rRect = rUsrEvt.GetRect();
168cdf0e10cSrcweir StatusBar& rBar = GetStatusBar();
169cdf0e10cSrcweir Point aItemPos = rBar.GetItemTextPos( GetId() );
170cdf0e10cSrcweir Color aOldLineColor = pDev->GetLineColor();
171cdf0e10cSrcweir Color aOldFillColor = pDev->GetFillColor();
172cdf0e10cSrcweir
173cdf0e10cSrcweir // just 4 testing until we've got a bitmap
174cdf0e10cSrcweir pDev->SetLineColor();
175cdf0e10cSrcweir pDev->SetFillColor( pDev->GetBackground().GetColor() );
176cdf0e10cSrcweir
177cdf0e10cSrcweir String s( String::CreateFromAscii( mpImpl->mbSigned? "X" : "-" ) );
178cdf0e10cSrcweir pDev->DrawRect( rRect );
179cdf0e10cSrcweir pDev->DrawText( Point( rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( s ) / 2, aItemPos.Y() ), s );
180cdf0e10cSrcweir
181cdf0e10cSrcweir pDev->SetLineColor( aOldLineColor );
182cdf0e10cSrcweir pDev->SetFillColor( aOldFillColor );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185