bump product version to 4.1.6.2
[LibreOffice.git] / framework / source / uielement / statusbaritem.cxx
blob41618fbd1a80bc2704c08bdd95439b9c7f767754
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <uielement/statusbaritem.hxx>
20 #include <vcl/status.hxx>
21 #include <vcl/svapp.hxx>
23 #include <com/sun/star/ui/ItemStyle.hpp>
25 using namespace com::sun::star::ui;
27 using rtl::OUString;
28 using com::sun::star::uno::RuntimeException;
30 namespace framework
33 namespace
35 static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
37 sal_uInt16 nStyle( 0 );
39 if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
40 nStyle |= ItemStyle::ALIGN_RIGHT;
41 else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
42 nStyle |= ItemStyle::ALIGN_LEFT;
43 else
44 nStyle |= ItemStyle::ALIGN_CENTER;
46 if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
47 nStyle |= ItemStyle::DRAW_FLAT;
48 else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
49 nStyle |= ItemStyle::DRAW_OUT3D;
50 else
51 nStyle |= ItemStyle::DRAW_IN3D;
53 if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
54 nStyle |= ItemStyle::AUTO_SIZE;
56 if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
57 nStyle |= ItemStyle::OWNER_DRAW;
59 return nStyle;
63 StatusbarItem::StatusbarItem(
64 StatusBar *pStatusBar,
65 AddonStatusbarItemData *pItemData,
66 sal_uInt16 nId,
67 const rtl::OUString& aCommand )
68 : StatusbarItem_Base( m_aMutex )
69 , m_pStatusBar( pStatusBar )
70 , m_pItemData( pItemData )
71 , m_nId( nId )
72 , m_nStyle( 0 )
73 , m_aCommand( aCommand )
75 if ( m_pStatusBar )
76 m_nStyle = impl_convertItemBitsToItemStyle(
77 m_pStatusBar->GetItemBits( m_nId ) );
80 StatusbarItem::~StatusbarItem()
84 void SAL_CALL StatusbarItem::disposing()
86 osl::MutexGuard aGuard( m_aMutex );
87 m_pItemData = 0;
88 m_pStatusBar = 0;
91 OUString SAL_CALL StatusbarItem::getCommand()
92 throw (RuntimeException)
94 osl::MutexGuard aGuard( m_aMutex );
95 return m_aCommand;
98 ::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
99 throw (RuntimeException)
101 osl::MutexGuard aGuard( m_aMutex );
102 return m_nId;
105 ::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
106 throw (RuntimeException)
108 SolarMutexGuard aGuard;
109 if ( m_pStatusBar )
110 return m_pStatusBar->GetItemWidth( m_nId );
112 return ::sal_uInt32(0);
115 ::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
116 throw (RuntimeException)
118 osl::MutexGuard aGuard( m_aMutex );
119 return m_nStyle;
122 ::sal_Int32 SAL_CALL StatusbarItem::getOffset()
123 throw (RuntimeException)
125 SolarMutexGuard aGuard;
126 if ( m_pStatusBar )
127 return m_pStatusBar->GetItemOffset( m_nId );
129 return ::sal_Int32(0);
132 ::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
133 throw (RuntimeException)
135 SolarMutexGuard aGuard;
136 ::com::sun::star::awt::Rectangle aAWTRect;
137 if ( m_pStatusBar )
139 Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
140 return ::com::sun::star::awt::Rectangle( aRect.Left(),
141 aRect.Top(),
142 aRect.GetWidth(),
143 aRect.GetHeight() );
146 return aAWTRect;
149 OUString SAL_CALL StatusbarItem::getText()
150 throw (RuntimeException)
152 SolarMutexGuard aGuard;
153 if ( m_pStatusBar )
154 return m_pStatusBar->GetItemText( m_nId );
156 return OUString();
159 void SAL_CALL StatusbarItem::setText( const OUString& rText )
160 throw (RuntimeException)
162 SolarMutexGuard aGuard;
163 if ( m_pStatusBar )
164 m_pStatusBar->SetItemText( m_nId, rText );;
167 OUString SAL_CALL StatusbarItem::getHelpText()
168 throw (RuntimeException)
170 SolarMutexGuard aGuard;
171 if ( m_pStatusBar )
172 return m_pStatusBar->GetHelpText( m_nId );
174 return OUString();
177 void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
178 throw (RuntimeException)
180 SolarMutexGuard aGuard;
181 if ( m_pStatusBar )
182 m_pStatusBar->SetHelpText( m_nId, rHelpText );;
185 OUString SAL_CALL StatusbarItem::getQuickHelpText()
186 throw (RuntimeException)
188 SolarMutexGuard aGuard;
189 if ( m_pStatusBar )
190 return m_pStatusBar->GetHelpText( m_nId );
192 return OUString();
195 void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
196 throw (RuntimeException)
198 SolarMutexGuard aGuard;
199 if ( m_pStatusBar )
200 m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
203 OUString SAL_CALL StatusbarItem::getAccessibleName()
204 throw (RuntimeException)
206 SolarMutexGuard aGuard;
207 if ( m_pStatusBar )
208 return m_pStatusBar->GetAccessibleName( m_nId );
210 return OUString();
213 void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
214 throw (RuntimeException)
216 SolarMutexGuard aGuard;
217 if ( m_pStatusBar )
218 m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
221 ::sal_Bool SAL_CALL StatusbarItem::getVisible()
222 throw (RuntimeException)
224 SolarMutexGuard aGuard;
225 if ( m_pStatusBar )
226 return m_pStatusBar->IsItemVisible( m_nId );
228 return sal_False;
231 void SAL_CALL StatusbarItem::setVisible( ::sal_Bool bVisible )
232 throw (RuntimeException)
234 SolarMutexGuard aGuard;
235 if ( !m_pStatusBar )
236 return;
238 if ( bVisible != m_pStatusBar->IsItemVisible( m_nId ) )
240 if ( bVisible )
241 m_pStatusBar->ShowItem( m_nId );
242 else
243 m_pStatusBar->HideItem( m_nId );
247 void SAL_CALL StatusbarItem::repaint( )
248 throw (RuntimeException)
250 SolarMutexGuard aGuard;
251 if ( m_pStatusBar )
253 m_pStatusBar->RedrawItem( m_nId );