xmlsecctrl.cxx (f6e50924) xmlsecctrl.cxx (07662b26)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svx.hxx"
26
27// include ---------------------------------------------------------------

--- 45 unchanged lines hidden (view full) ---

73SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxUInt16Item );
74
75struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
76{
77 Point maPos;
78 Size maSize;
79 sal_uInt16 mnState;
80 Image maImage;
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svx.hxx"
26
27// include ---------------------------------------------------------------

--- 45 unchanged lines hidden (view full) ---

73SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxUInt16Item );
74
75struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
76{
77 Point maPos;
78 Size maSize;
79 sal_uInt16 mnState;
80 Image maImage;
81 Image maImageBroken;
82 Image maImageNotValidated;
81 Image maImageBroken;
82 Image maImageNotValidated;
83};
84
85
83};
84
85
86XmlSecStatusBarControl::XmlSecStatusBarControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& _rStb )
87 :SfxStatusBarControl( _nSlotId, _nId, _rStb )
86XmlSecStatusBarControl::XmlSecStatusBarControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& _rStb )
87 :SfxStatusBarControl( _nSlotId, _nId, _rStb )
88
89 ,mpImpl( new XmlSecStatusBarControl_Impl )
90{
91 mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
92
88
89 ,mpImpl( new XmlSecStatusBarControl_Impl )
90{
91 mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
92
93 sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode();
94 mpImpl->maImage = Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_H : RID_SVXBMP_SIGNET ) );
95 mpImpl->maImageBroken =
96 Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_BROKEN_H : RID_SVXBMP_SIGNET_BROKEN ) );
97 mpImpl->maImageNotValidated =
98 Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_NOTVALIDATED_H : RID_SVXBMP_SIGNET_NOTVALIDATED ) );
93 sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode();
94 mpImpl->maImage = Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_H : RID_SVXBMP_SIGNET ) );
95 mpImpl->maImageBroken =
96 Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_BROKEN_H : RID_SVXBMP_SIGNET_BROKEN ) );
97 mpImpl->maImageNotValidated =
98 Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_NOTVALIDATED_H : RID_SVXBMP_SIGNET_NOTVALIDATED ) );
99}
100
101XmlSecStatusBarControl::~XmlSecStatusBarControl()
102{
103 delete mpImpl;
104}
105
106void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )

--- 8 unchanged lines hidden (view full) ---

115 mpImpl->mnState = ( ( SfxUInt16Item* ) pState )->GetValue();
116 }
117 else
118 {
119 DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
120 mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
121 }
122
99}
100
101XmlSecStatusBarControl::~XmlSecStatusBarControl()
102{
103 delete mpImpl;
104}
105
106void XmlSecStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )

--- 8 unchanged lines hidden (view full) ---

115 mpImpl->mnState = ( ( SfxUInt16Item* ) pState )->GetValue();
116 }
117 else
118 {
119 DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
120 mpImpl->mnState = (sal_uInt16)SIGNATURESTATE_UNKNOWN;
121 }
122
123 if( GetStatusBar().AreItemsVisible() ) // necessary ?
123 if( GetStatusBar().AreItemsVisible() ) // necessary ?
124 GetStatusBar().SetItemData( GetId(), 0 );
125
124 GetStatusBar().SetItemData( GetId(), 0 );
125
126 GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
126 GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
127
127
128 sal_uInt16 nResId = RID_SVXSTR_XMLSEC_NO_SIG;
129 if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
130 nResId = RID_SVXSTR_XMLSEC_SIG_OK;
131 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
132 nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK;
133 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
134 nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY;
135 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK )
136 nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG;
128 sal_uInt16 nResId = RID_SVXSTR_XMLSEC_NO_SIG;
129 if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
130 nResId = RID_SVXSTR_XMLSEC_SIG_OK;
131 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
132 nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK;
133 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
134 nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY;
135 else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK )
136 nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG;
137
137
138 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) );
138 GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) );
139}
140
141void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
142{
143 if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
144 {
145 PopupMenu aPopupMenu( ResId( RID_SVXMNU_XMLSECSTATBAR, DIALOG_MGR() ) );
146 if( aPopupMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
147 {
139}
140
141void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
142{
143 if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
144 {
145 PopupMenu aPopupMenu( ResId( RID_SVXMNU_XMLSECSTATBAR, DIALOG_MGR() ) );
146 if( aPopupMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
147 {
148 ::com::sun::star::uno::Any a;
149 SfxUInt16Item aState( GetSlotId(), 0 );
150 INetURLObject aObj( m_aCommandURL );
148 ::com::sun::star::uno::Any a;
149 SfxUInt16Item aState( GetSlotId(), 0 );
150 INetURLObject aObj( m_aCommandURL );
151
151
152 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
153 aArgs[0].Name = aObj.GetURLPath();
154 aState.QueryValue( a );
155 aArgs[0].Value = a;
152 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
153 aArgs[0].Name = aObj.GetURLPath();
154 aState.QueryValue( a );
155 aArgs[0].Value = a;
156
156
157 execute( aArgs );
157 execute( aArgs );
158 }
159 }
160 else
161 SfxStatusBarControl::Command( rCEvt );
162}
163
164void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
165{

--- 8 unchanged lines hidden (view full) ---

174 pDev->SetLineColor();
175 pDev->SetFillColor( pDev->GetBackground().GetColor() );
176
177 if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
178 {
179 ++aRect.Top();
180 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage );
181 }
158 }
159 }
160 else
161 SfxStatusBarControl::Command( rCEvt );
162}
163
164void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
165{

--- 8 unchanged lines hidden (view full) ---

174 pDev->SetLineColor();
175 pDev->SetFillColor( pDev->GetBackground().GetColor() );
176
177 if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
178 {
179 ++aRect.Top();
180 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage );
181 }
182 else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
183 {
184 ++aRect.Top();
185 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken );
186 }
187 else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
188 || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
189 {
190 ++aRect.Top();
191 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated );
192 }
182 else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
183 {
184 ++aRect.Top();
185 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken );
186 }
187 else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
188 || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
189 {
190 ++aRect.Top();
191 pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated );
192 }
193 else
194 pDev->DrawRect( aRect );
195
196 pDev->SetLineColor( aOldLineColor );
197 pDev->SetFillColor( aOldFillColor );
198}
199
200long XmlSecStatusBarControl::GetDefItemWidth( StatusBar& )
201{
202 return 16;
203}
204
193 else
194 pDev->DrawRect( aRect );
195
196 pDev->SetLineColor( aOldLineColor );
197 pDev->SetFillColor( aOldFillColor );
198}
199
200long XmlSecStatusBarControl::GetDefItemWidth( StatusBar& )
201{
202 return 16;
203}
204
205/* vim: set noet sw=4 ts=4: */