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
;
28 using com::sun::star::uno::RuntimeException
;
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
;
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
;
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
;
63 StatusbarItem::StatusbarItem(
64 StatusBar
*pStatusBar
,
65 AddonStatusbarItemData
*pItemData
,
67 const rtl::OUString
& aCommand
)
68 : StatusbarItem_Base( m_aMutex
)
69 , m_pStatusBar( pStatusBar
)
70 , m_pItemData( pItemData
)
73 , m_aCommand( aCommand
)
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
);
91 OUString SAL_CALL
StatusbarItem::getCommand()
92 throw (RuntimeException
)
94 osl::MutexGuard
aGuard( m_aMutex
);
98 ::sal_uInt16 SAL_CALL
StatusbarItem::getItemId()
99 throw (RuntimeException
)
101 osl::MutexGuard
aGuard( m_aMutex
);
105 ::sal_uInt32 SAL_CALL
StatusbarItem::getWidth()
106 throw (RuntimeException
)
108 SolarMutexGuard aGuard
;
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
);
122 ::sal_Int32 SAL_CALL
StatusbarItem::getOffset()
123 throw (RuntimeException
)
125 SolarMutexGuard aGuard
;
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
;
139 Rectangle aRect
= m_pStatusBar
->GetItemRect( m_nId
);
140 return ::com::sun::star::awt::Rectangle( aRect
.Left(),
149 OUString SAL_CALL
StatusbarItem::getText()
150 throw (RuntimeException
)
152 SolarMutexGuard aGuard
;
154 return m_pStatusBar
->GetItemText( m_nId
);
159 void SAL_CALL
StatusbarItem::setText( const OUString
& rText
)
160 throw (RuntimeException
)
162 SolarMutexGuard aGuard
;
164 m_pStatusBar
->SetItemText( m_nId
, rText
);;
167 OUString SAL_CALL
StatusbarItem::getHelpText()
168 throw (RuntimeException
)
170 SolarMutexGuard aGuard
;
172 return m_pStatusBar
->GetHelpText( m_nId
);
177 void SAL_CALL
StatusbarItem::setHelpText( const OUString
& rHelpText
)
178 throw (RuntimeException
)
180 SolarMutexGuard aGuard
;
182 m_pStatusBar
->SetHelpText( m_nId
, rHelpText
);;
185 OUString SAL_CALL
StatusbarItem::getQuickHelpText()
186 throw (RuntimeException
)
188 SolarMutexGuard aGuard
;
190 return m_pStatusBar
->GetHelpText( m_nId
);
195 void SAL_CALL
StatusbarItem::setQuickHelpText( const OUString
& rQuickHelpText
)
196 throw (RuntimeException
)
198 SolarMutexGuard aGuard
;
200 m_pStatusBar
->SetQuickHelpText( m_nId
, rQuickHelpText
);
203 OUString SAL_CALL
StatusbarItem::getAccessibleName()
204 throw (RuntimeException
)
206 SolarMutexGuard aGuard
;
208 return m_pStatusBar
->GetAccessibleName( m_nId
);
213 void SAL_CALL
StatusbarItem::setAccessibleName( const OUString
& rAccessibleName
)
214 throw (RuntimeException
)
216 SolarMutexGuard aGuard
;
218 m_pStatusBar
->SetAccessibleName( m_nId
, rAccessibleName
);
221 ::sal_Bool SAL_CALL
StatusbarItem::getVisible()
222 throw (RuntimeException
)
224 SolarMutexGuard aGuard
;
226 return m_pStatusBar
->IsItemVisible( m_nId
);
231 void SAL_CALL
StatusbarItem::setVisible( ::sal_Bool bVisible
)
232 throw (RuntimeException
)
234 SolarMutexGuard aGuard
;
238 if ( bVisible
!= m_pStatusBar
->IsItemVisible( m_nId
) )
241 m_pStatusBar
->ShowItem( m_nId
);
243 m_pStatusBar
->HideItem( m_nId
);
247 void SAL_CALL
StatusbarItem::repaint( )
248 throw (RuntimeException
)
250 SolarMutexGuard aGuard
;
253 m_pStatusBar
->RedrawItem( m_nId
);