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