fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / uielement / statusbaritem.cxx
blobb2af4348ad008b6d81be6a0ad0c60d17ebc3d5fc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <uielement/statusbaritem.hxx>
21 #include <vcl/status.hxx>
22 #include <vcl/svapp.hxx>
24 #include <com/sun/star/ui/ItemStyle.hpp>
26 using namespace com::sun::star::ui;
28 using rtl::OUString;
29 using com::sun::star::uno::RuntimeException;
31 namespace framework
34 namespace
36 static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
38 sal_uInt16 nStyle( 0 );
40 if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
41 nStyle |= ItemStyle::ALIGN_RIGHT;
42 else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
43 nStyle |= ItemStyle::ALIGN_LEFT;
44 else
45 nStyle |= ItemStyle::ALIGN_CENTER;
47 if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
48 nStyle |= ItemStyle::DRAW_FLAT;
49 else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
50 nStyle |= ItemStyle::DRAW_OUT3D;
51 else
52 nStyle |= ItemStyle::DRAW_IN3D;
54 if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
55 nStyle |= ItemStyle::AUTO_SIZE;
57 if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
58 nStyle |= ItemStyle::OWNER_DRAW;
60 return nStyle;
64 StatusbarItem::StatusbarItem(
65 StatusBar *pStatusBar,
66 AddonStatusbarItemData *pItemData,
67 sal_uInt16 nId,
68 const rtl::OUString& aCommand )
69 : StatusbarItem_Base( m_aMutex )
70 , m_pStatusBar( pStatusBar )
71 , m_pItemData( pItemData )
72 , m_nId( nId )
73 , m_nStyle( 0 )
74 , m_aCommand( aCommand )
76 if ( m_pStatusBar )
77 m_nStyle = impl_convertItemBitsToItemStyle(
78 m_pStatusBar->GetItemBits( m_nId ) );
81 StatusbarItem::~StatusbarItem()
85 void SAL_CALL StatusbarItem::disposing()
87 osl::MutexGuard aGuard( m_aMutex );
88 m_pItemData = 0;
89 m_pStatusBar = 0;
92 OUString SAL_CALL StatusbarItem::getCommand()
93 throw (RuntimeException, std::exception)
95 osl::MutexGuard aGuard( m_aMutex );
96 return m_aCommand;
99 ::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
100 throw (RuntimeException, std::exception)
102 osl::MutexGuard aGuard( m_aMutex );
103 return m_nId;
106 ::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
107 throw (RuntimeException, std::exception)
109 SolarMutexGuard aGuard;
110 if ( m_pStatusBar )
111 return m_pStatusBar->GetItemWidth( m_nId );
113 return ::sal_uInt32(0);
116 ::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
117 throw (RuntimeException, std::exception)
119 osl::MutexGuard aGuard( m_aMutex );
120 return m_nStyle;
123 ::sal_Int32 SAL_CALL StatusbarItem::getOffset()
124 throw (RuntimeException, std::exception)
126 SolarMutexGuard aGuard;
127 if ( m_pStatusBar )
128 return m_pStatusBar->GetItemOffset( m_nId );
130 return ::sal_Int32(0);
133 ::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
134 throw (RuntimeException, std::exception)
136 SolarMutexGuard aGuard;
137 ::com::sun::star::awt::Rectangle aAWTRect;
138 if ( m_pStatusBar )
140 Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
141 return ::com::sun::star::awt::Rectangle( aRect.Left(),
142 aRect.Top(),
143 aRect.GetWidth(),
144 aRect.GetHeight() );
147 return aAWTRect;
150 OUString SAL_CALL StatusbarItem::getText()
151 throw (RuntimeException, std::exception)
153 SolarMutexGuard aGuard;
154 if ( m_pStatusBar )
155 return m_pStatusBar->GetItemText( m_nId );
157 return OUString();
160 void SAL_CALL StatusbarItem::setText( const OUString& rText )
161 throw (RuntimeException, std::exception)
163 SolarMutexGuard aGuard;
164 if ( m_pStatusBar )
165 m_pStatusBar->SetItemText( m_nId, rText );;
168 OUString SAL_CALL StatusbarItem::getHelpText()
169 throw (RuntimeException, std::exception)
171 SolarMutexGuard aGuard;
172 if ( m_pStatusBar )
173 return m_pStatusBar->GetHelpText( m_nId );
175 return OUString();
178 void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
179 throw (RuntimeException, std::exception)
181 SolarMutexGuard aGuard;
182 if ( m_pStatusBar )
183 m_pStatusBar->SetHelpText( m_nId, rHelpText );;
186 OUString SAL_CALL StatusbarItem::getQuickHelpText()
187 throw (RuntimeException, std::exception)
189 SolarMutexGuard aGuard;
190 if ( m_pStatusBar )
191 return m_pStatusBar->GetHelpText( m_nId );
193 return OUString();
196 void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
197 throw (RuntimeException, std::exception)
199 SolarMutexGuard aGuard;
200 if ( m_pStatusBar )
201 m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
204 OUString SAL_CALL StatusbarItem::getAccessibleName()
205 throw (RuntimeException, std::exception)
207 SolarMutexGuard aGuard;
208 if ( m_pStatusBar )
209 return m_pStatusBar->GetAccessibleName( m_nId );
211 return OUString();
214 void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
215 throw (RuntimeException, std::exception)
217 SolarMutexGuard aGuard;
218 if ( m_pStatusBar )
219 m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
222 sal_Bool SAL_CALL StatusbarItem::getVisible()
223 throw (RuntimeException, std::exception)
225 SolarMutexGuard aGuard;
226 if ( m_pStatusBar )
227 return m_pStatusBar->IsItemVisible( m_nId );
229 return sal_False;
232 void SAL_CALL StatusbarItem::setVisible( sal_Bool bVisible )
233 throw (RuntimeException, std::exception)
235 SolarMutexGuard aGuard;
236 if ( !m_pStatusBar )
237 return;
239 if ( bool(bVisible) != m_pStatusBar->IsItemVisible( m_nId ) )
241 if ( bVisible )
242 m_pStatusBar->ShowItem( m_nId );
243 else
244 m_pStatusBar->HideItem( m_nId );
248 void SAL_CALL StatusbarItem::repaint( )
249 throw (RuntimeException, std::exception)
251 SolarMutexGuard aGuard;
252 if ( m_pStatusBar )
254 m_pStatusBar->RedrawItem( m_nId );
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */