1*2503e1a5SAriel Constenla-Haile /**************************************************************
2*2503e1a5SAriel Constenla-Haile *
3*2503e1a5SAriel Constenla-Haile * Licensed to the Apache Software Foundation (ASF) under one
4*2503e1a5SAriel Constenla-Haile * or more contributor license agreements. See the NOTICE file
5*2503e1a5SAriel Constenla-Haile * distributed with this work for additional information
6*2503e1a5SAriel Constenla-Haile * regarding copyright ownership. The ASF licenses this file
7*2503e1a5SAriel Constenla-Haile * to you under the Apache License, Version 2.0 (the
8*2503e1a5SAriel Constenla-Haile * "License"); you may not use this file except in compliance
9*2503e1a5SAriel Constenla-Haile * with the License. You may obtain a copy of the License at
10*2503e1a5SAriel Constenla-Haile *
11*2503e1a5SAriel Constenla-Haile * http://www.apache.org/licenses/LICENSE-2.0
12*2503e1a5SAriel Constenla-Haile *
13*2503e1a5SAriel Constenla-Haile * Unless required by applicable law or agreed to in writing,
14*2503e1a5SAriel Constenla-Haile * software distributed under the License is distributed on an
15*2503e1a5SAriel Constenla-Haile * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2503e1a5SAriel Constenla-Haile * KIND, either express or implied. See the License for the
17*2503e1a5SAriel Constenla-Haile * specific language governing permissions and limitations
18*2503e1a5SAriel Constenla-Haile * under the License.
19*2503e1a5SAriel Constenla-Haile *
20*2503e1a5SAriel Constenla-Haile *************************************************************/
21*2503e1a5SAriel Constenla-Haile
22*2503e1a5SAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove
23*2503e1a5SAriel Constenla-Haile #include "precompiled_framework.hxx"
24*2503e1a5SAriel Constenla-Haile
25*2503e1a5SAriel Constenla-Haile #include <uielement/statusbaritem.hxx>
26*2503e1a5SAriel Constenla-Haile #include <vcl/status.hxx>
27*2503e1a5SAriel Constenla-Haile #include <vcl/svapp.hxx>
28*2503e1a5SAriel Constenla-Haile #include <vos/mutex.hxx>
29*2503e1a5SAriel Constenla-Haile
30*2503e1a5SAriel Constenla-Haile #include <com/sun/star/ui/ItemStyle.hpp>
31*2503e1a5SAriel Constenla-Haile
32*2503e1a5SAriel Constenla-Haile using namespace com::sun::star::ui;
33*2503e1a5SAriel Constenla-Haile
34*2503e1a5SAriel Constenla-Haile using rtl::OUString;
35*2503e1a5SAriel Constenla-Haile using com::sun::star::uno::RuntimeException;
36*2503e1a5SAriel Constenla-Haile
37*2503e1a5SAriel Constenla-Haile namespace framework
38*2503e1a5SAriel Constenla-Haile {
39*2503e1a5SAriel Constenla-Haile
40*2503e1a5SAriel Constenla-Haile namespace
41*2503e1a5SAriel Constenla-Haile {
impl_convertItemBitsToItemStyle(sal_Int16 nItemBits)42*2503e1a5SAriel Constenla-Haile static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
43*2503e1a5SAriel Constenla-Haile {
44*2503e1a5SAriel Constenla-Haile sal_uInt16 nStyle( 0 );
45*2503e1a5SAriel Constenla-Haile
46*2503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
47*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_RIGHT;
48*2503e1a5SAriel Constenla-Haile else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
49*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_LEFT;
50*2503e1a5SAriel Constenla-Haile else
51*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_CENTER;
52*2503e1a5SAriel Constenla-Haile
53*2503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
54*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_FLAT;
55*2503e1a5SAriel Constenla-Haile else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
56*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_OUT3D;
57*2503e1a5SAriel Constenla-Haile else
58*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_IN3D;
59*2503e1a5SAriel Constenla-Haile
60*2503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
61*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::AUTO_SIZE;
62*2503e1a5SAriel Constenla-Haile
63*2503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
64*2503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::OWNER_DRAW;
65*2503e1a5SAriel Constenla-Haile
66*2503e1a5SAriel Constenla-Haile return nStyle;
67*2503e1a5SAriel Constenla-Haile }
68*2503e1a5SAriel Constenla-Haile }
69*2503e1a5SAriel Constenla-Haile
StatusbarItem(StatusBar * pStatusBar,AddonStatusbarItemData * pItemData,sal_uInt16 nId,const rtl::OUString & aCommand)70*2503e1a5SAriel Constenla-Haile StatusbarItem::StatusbarItem(
71*2503e1a5SAriel Constenla-Haile StatusBar *pStatusBar,
72*2503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pItemData,
73*2503e1a5SAriel Constenla-Haile sal_uInt16 nId,
74*2503e1a5SAriel Constenla-Haile const rtl::OUString& aCommand )
75*2503e1a5SAriel Constenla-Haile : StatusbarItem_Base( m_aMutex )
76*2503e1a5SAriel Constenla-Haile , m_pStatusBar( pStatusBar )
77*2503e1a5SAriel Constenla-Haile , m_pItemData( pItemData )
78*2503e1a5SAriel Constenla-Haile , m_nId( nId )
79*2503e1a5SAriel Constenla-Haile , m_nStyle( 0 )
80*2503e1a5SAriel Constenla-Haile , m_aCommand( aCommand )
81*2503e1a5SAriel Constenla-Haile {
82*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
83*2503e1a5SAriel Constenla-Haile m_nStyle = impl_convertItemBitsToItemStyle(
84*2503e1a5SAriel Constenla-Haile m_pStatusBar->GetItemBits( m_nId ) );
85*2503e1a5SAriel Constenla-Haile }
86*2503e1a5SAriel Constenla-Haile
~StatusbarItem()87*2503e1a5SAriel Constenla-Haile StatusbarItem::~StatusbarItem()
88*2503e1a5SAriel Constenla-Haile {
89*2503e1a5SAriel Constenla-Haile }
90*2503e1a5SAriel Constenla-Haile
disposing()91*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::disposing()
92*2503e1a5SAriel Constenla-Haile {
93*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
94*2503e1a5SAriel Constenla-Haile m_pItemData = 0;
95*2503e1a5SAriel Constenla-Haile m_pStatusBar = 0;
96*2503e1a5SAriel Constenla-Haile }
97*2503e1a5SAriel Constenla-Haile
getCommand()98*2503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getCommand()
99*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
100*2503e1a5SAriel Constenla-Haile {
101*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
102*2503e1a5SAriel Constenla-Haile return m_aCommand;
103*2503e1a5SAriel Constenla-Haile }
104*2503e1a5SAriel Constenla-Haile
getItemId()105*2503e1a5SAriel Constenla-Haile ::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
106*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
107*2503e1a5SAriel Constenla-Haile {
108*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
109*2503e1a5SAriel Constenla-Haile return m_nId;
110*2503e1a5SAriel Constenla-Haile }
111*2503e1a5SAriel Constenla-Haile
getWidth()112*2503e1a5SAriel Constenla-Haile ::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
113*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
114*2503e1a5SAriel Constenla-Haile {
115*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
116*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
117*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
118*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemWidth( m_nId );
119*2503e1a5SAriel Constenla-Haile
120*2503e1a5SAriel Constenla-Haile return ::sal_uInt32(0);
121*2503e1a5SAriel Constenla-Haile }
122*2503e1a5SAriel Constenla-Haile
getStyle()123*2503e1a5SAriel Constenla-Haile ::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
124*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
125*2503e1a5SAriel Constenla-Haile {
126*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
127*2503e1a5SAriel Constenla-Haile return m_nStyle;
128*2503e1a5SAriel Constenla-Haile }
129*2503e1a5SAriel Constenla-Haile
getOffset()130*2503e1a5SAriel Constenla-Haile ::sal_Int32 SAL_CALL StatusbarItem::getOffset()
131*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
132*2503e1a5SAriel Constenla-Haile {
133*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
134*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
135*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
136*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemOffset( m_nId );
137*2503e1a5SAriel Constenla-Haile
138*2503e1a5SAriel Constenla-Haile return ::sal_Int32(0);
139*2503e1a5SAriel Constenla-Haile }
140*2503e1a5SAriel Constenla-Haile
getItemRect()141*2503e1a5SAriel Constenla-Haile ::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
142*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
143*2503e1a5SAriel Constenla-Haile {
144*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
145*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
146*2503e1a5SAriel Constenla-Haile ::com::sun::star::awt::Rectangle aAWTRect;
147*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
148*2503e1a5SAriel Constenla-Haile {
149*2503e1a5SAriel Constenla-Haile Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
150*2503e1a5SAriel Constenla-Haile return ::com::sun::star::awt::Rectangle( aRect.Left(),
151*2503e1a5SAriel Constenla-Haile aRect.Top(),
152*2503e1a5SAriel Constenla-Haile aRect.GetWidth(),
153*2503e1a5SAriel Constenla-Haile aRect.GetHeight() );
154*2503e1a5SAriel Constenla-Haile }
155*2503e1a5SAriel Constenla-Haile
156*2503e1a5SAriel Constenla-Haile return aAWTRect;
157*2503e1a5SAriel Constenla-Haile }
158*2503e1a5SAriel Constenla-Haile
getText()159*2503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getText()
160*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
161*2503e1a5SAriel Constenla-Haile {
162*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
163*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
164*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
165*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemText( m_nId );
166*2503e1a5SAriel Constenla-Haile
167*2503e1a5SAriel Constenla-Haile return OUString();
168*2503e1a5SAriel Constenla-Haile }
169*2503e1a5SAriel Constenla-Haile
setText(const OUString & rText)170*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setText( const OUString& rText )
171*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
172*2503e1a5SAriel Constenla-Haile {
173*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
174*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
175*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
176*2503e1a5SAriel Constenla-Haile m_pStatusBar->SetItemText( m_nId, rText );;
177*2503e1a5SAriel Constenla-Haile }
178*2503e1a5SAriel Constenla-Haile
getHelpText()179*2503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getHelpText()
180*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
181*2503e1a5SAriel Constenla-Haile {
182*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
183*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
184*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
185*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetHelpText( m_nId );
186*2503e1a5SAriel Constenla-Haile
187*2503e1a5SAriel Constenla-Haile return OUString();
188*2503e1a5SAriel Constenla-Haile }
189*2503e1a5SAriel Constenla-Haile
setHelpText(const OUString & rHelpText)190*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
191*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
192*2503e1a5SAriel Constenla-Haile {
193*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
194*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
195*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
196*2503e1a5SAriel Constenla-Haile m_pStatusBar->SetHelpText( m_nId, rHelpText );;
197*2503e1a5SAriel Constenla-Haile }
198*2503e1a5SAriel Constenla-Haile
getQuickHelpText()199*2503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getQuickHelpText()
200*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
201*2503e1a5SAriel Constenla-Haile {
202*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
203*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
204*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
205*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetHelpText( m_nId );
206*2503e1a5SAriel Constenla-Haile
207*2503e1a5SAriel Constenla-Haile return OUString();
208*2503e1a5SAriel Constenla-Haile }
209*2503e1a5SAriel Constenla-Haile
setQuickHelpText(const OUString & rQuickHelpText)210*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
211*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
212*2503e1a5SAriel Constenla-Haile {
213*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
214*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
215*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
216*2503e1a5SAriel Constenla-Haile m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
217*2503e1a5SAriel Constenla-Haile }
218*2503e1a5SAriel Constenla-Haile
getAccessibleName()219*2503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getAccessibleName()
220*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
221*2503e1a5SAriel Constenla-Haile {
222*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
223*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
224*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
225*2503e1a5SAriel Constenla-Haile return m_pStatusBar->GetAccessibleName( m_nId );
226*2503e1a5SAriel Constenla-Haile
227*2503e1a5SAriel Constenla-Haile return OUString();
228*2503e1a5SAriel Constenla-Haile }
229*2503e1a5SAriel Constenla-Haile
setAccessibleName(const OUString & rAccessibleName)230*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
231*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
232*2503e1a5SAriel Constenla-Haile {
233*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
234*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
235*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
236*2503e1a5SAriel Constenla-Haile m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
237*2503e1a5SAriel Constenla-Haile }
238*2503e1a5SAriel Constenla-Haile
getVisible()239*2503e1a5SAriel Constenla-Haile ::sal_Bool SAL_CALL StatusbarItem::getVisible()
240*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
241*2503e1a5SAriel Constenla-Haile {
242*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
243*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
244*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
245*2503e1a5SAriel Constenla-Haile return m_pStatusBar->IsItemVisible( m_nId );
246*2503e1a5SAriel Constenla-Haile
247*2503e1a5SAriel Constenla-Haile return sal_False;
248*2503e1a5SAriel Constenla-Haile }
249*2503e1a5SAriel Constenla-Haile
setVisible(::sal_Bool bVisible)250*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setVisible( ::sal_Bool bVisible )
251*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
252*2503e1a5SAriel Constenla-Haile {
253*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
254*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
255*2503e1a5SAriel Constenla-Haile if ( !m_pStatusBar )
256*2503e1a5SAriel Constenla-Haile return;
257*2503e1a5SAriel Constenla-Haile
258*2503e1a5SAriel Constenla-Haile if ( bVisible != m_pStatusBar->IsItemVisible( m_nId ) )
259*2503e1a5SAriel Constenla-Haile {
260*2503e1a5SAriel Constenla-Haile if ( bVisible )
261*2503e1a5SAriel Constenla-Haile m_pStatusBar->ShowItem( m_nId );
262*2503e1a5SAriel Constenla-Haile else
263*2503e1a5SAriel Constenla-Haile m_pStatusBar->HideItem( m_nId );
264*2503e1a5SAriel Constenla-Haile }
265*2503e1a5SAriel Constenla-Haile }
266*2503e1a5SAriel Constenla-Haile
repaint()267*2503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::repaint( )
268*2503e1a5SAriel Constenla-Haile throw (RuntimeException)
269*2503e1a5SAriel Constenla-Haile {
270*2503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
271*2503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
272*2503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
273*2503e1a5SAriel Constenla-Haile {
274*2503e1a5SAriel Constenla-Haile m_pStatusBar->RedrawItem( m_nId );
275*2503e1a5SAriel Constenla-Haile }
276*2503e1a5SAriel Constenla-Haile }
277*2503e1a5SAriel Constenla-Haile
278*2503e1a5SAriel Constenla-Haile }
279