12503e1a5SAriel Constenla-Haile /**************************************************************
22503e1a5SAriel Constenla-Haile *
32503e1a5SAriel Constenla-Haile * Licensed to the Apache Software Foundation (ASF) under one
42503e1a5SAriel Constenla-Haile * or more contributor license agreements. See the NOTICE file
52503e1a5SAriel Constenla-Haile * distributed with this work for additional information
62503e1a5SAriel Constenla-Haile * regarding copyright ownership. The ASF licenses this file
72503e1a5SAriel Constenla-Haile * to you under the Apache License, Version 2.0 (the
82503e1a5SAriel Constenla-Haile * "License"); you may not use this file except in compliance
92503e1a5SAriel Constenla-Haile * with the License. You may obtain a copy of the License at
102503e1a5SAriel Constenla-Haile *
112503e1a5SAriel Constenla-Haile * http://www.apache.org/licenses/LICENSE-2.0
122503e1a5SAriel Constenla-Haile *
132503e1a5SAriel Constenla-Haile * Unless required by applicable law or agreed to in writing,
142503e1a5SAriel Constenla-Haile * software distributed under the License is distributed on an
152503e1a5SAriel Constenla-Haile * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162503e1a5SAriel Constenla-Haile * KIND, either express or implied. See the License for the
172503e1a5SAriel Constenla-Haile * specific language governing permissions and limitations
182503e1a5SAriel Constenla-Haile * under the License.
192503e1a5SAriel Constenla-Haile *
202503e1a5SAriel Constenla-Haile *************************************************************/
212503e1a5SAriel Constenla-Haile
222503e1a5SAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove
232503e1a5SAriel Constenla-Haile #include "precompiled_framework.hxx"
242503e1a5SAriel Constenla-Haile
252503e1a5SAriel Constenla-Haile #include <uielement/statusbaritem.hxx>
262503e1a5SAriel Constenla-Haile #include <vcl/status.hxx>
272503e1a5SAriel Constenla-Haile #include <vcl/svapp.hxx>
282503e1a5SAriel Constenla-Haile #include <vos/mutex.hxx>
292503e1a5SAriel Constenla-Haile
302503e1a5SAriel Constenla-Haile #include <com/sun/star/ui/ItemStyle.hpp>
312503e1a5SAriel Constenla-Haile
322503e1a5SAriel Constenla-Haile using namespace com::sun::star::ui;
332503e1a5SAriel Constenla-Haile
342503e1a5SAriel Constenla-Haile using rtl::OUString;
352503e1a5SAriel Constenla-Haile using com::sun::star::uno::RuntimeException;
362503e1a5SAriel Constenla-Haile
372503e1a5SAriel Constenla-Haile namespace framework
382503e1a5SAriel Constenla-Haile {
392503e1a5SAriel Constenla-Haile
402503e1a5SAriel Constenla-Haile namespace
412503e1a5SAriel Constenla-Haile {
impl_convertItemBitsToItemStyle(sal_Int16 nItemBits)422503e1a5SAriel Constenla-Haile static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
432503e1a5SAriel Constenla-Haile {
442503e1a5SAriel Constenla-Haile sal_uInt16 nStyle( 0 );
452503e1a5SAriel Constenla-Haile
462503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
472503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_RIGHT;
482503e1a5SAriel Constenla-Haile else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
492503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_LEFT;
502503e1a5SAriel Constenla-Haile else
512503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::ALIGN_CENTER;
522503e1a5SAriel Constenla-Haile
532503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
542503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_FLAT;
552503e1a5SAriel Constenla-Haile else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
562503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_OUT3D;
572503e1a5SAriel Constenla-Haile else
582503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::DRAW_IN3D;
592503e1a5SAriel Constenla-Haile
602503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
612503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::AUTO_SIZE;
622503e1a5SAriel Constenla-Haile
632503e1a5SAriel Constenla-Haile if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
642503e1a5SAriel Constenla-Haile nStyle |= ItemStyle::OWNER_DRAW;
652503e1a5SAriel Constenla-Haile
662503e1a5SAriel Constenla-Haile return nStyle;
672503e1a5SAriel Constenla-Haile }
682503e1a5SAriel Constenla-Haile }
692503e1a5SAriel Constenla-Haile
StatusbarItem(StatusBar * pStatusBar,AddonStatusbarItemData * pItemData,sal_uInt16 nId,const rtl::OUString & aCommand)702503e1a5SAriel Constenla-Haile StatusbarItem::StatusbarItem(
712503e1a5SAriel Constenla-Haile StatusBar *pStatusBar,
722503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pItemData,
732503e1a5SAriel Constenla-Haile sal_uInt16 nId,
742503e1a5SAriel Constenla-Haile const rtl::OUString& aCommand )
752503e1a5SAriel Constenla-Haile : StatusbarItem_Base( m_aMutex )
762503e1a5SAriel Constenla-Haile , m_pStatusBar( pStatusBar )
772503e1a5SAriel Constenla-Haile , m_pItemData( pItemData )
782503e1a5SAriel Constenla-Haile , m_nId( nId )
792503e1a5SAriel Constenla-Haile , m_nStyle( 0 )
802503e1a5SAriel Constenla-Haile , m_aCommand( aCommand )
812503e1a5SAriel Constenla-Haile {
822503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
832503e1a5SAriel Constenla-Haile m_nStyle = impl_convertItemBitsToItemStyle(
842503e1a5SAriel Constenla-Haile m_pStatusBar->GetItemBits( m_nId ) );
852503e1a5SAriel Constenla-Haile }
862503e1a5SAriel Constenla-Haile
~StatusbarItem()872503e1a5SAriel Constenla-Haile StatusbarItem::~StatusbarItem()
882503e1a5SAriel Constenla-Haile {
892503e1a5SAriel Constenla-Haile }
902503e1a5SAriel Constenla-Haile
disposing()912503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::disposing()
922503e1a5SAriel Constenla-Haile {
932503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
942503e1a5SAriel Constenla-Haile m_pItemData = 0;
952503e1a5SAriel Constenla-Haile m_pStatusBar = 0;
962503e1a5SAriel Constenla-Haile }
972503e1a5SAriel Constenla-Haile
getCommand()982503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getCommand()
992503e1a5SAriel Constenla-Haile throw (RuntimeException)
1002503e1a5SAriel Constenla-Haile {
1012503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1022503e1a5SAriel Constenla-Haile return m_aCommand;
1032503e1a5SAriel Constenla-Haile }
1042503e1a5SAriel Constenla-Haile
getItemId()1052503e1a5SAriel Constenla-Haile ::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
1062503e1a5SAriel Constenla-Haile throw (RuntimeException)
1072503e1a5SAriel Constenla-Haile {
1082503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1092503e1a5SAriel Constenla-Haile return m_nId;
1102503e1a5SAriel Constenla-Haile }
1112503e1a5SAriel Constenla-Haile
getWidth()1122503e1a5SAriel Constenla-Haile ::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
1132503e1a5SAriel Constenla-Haile throw (RuntimeException)
1142503e1a5SAriel Constenla-Haile {
1152503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1162503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1172503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
1182503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemWidth( m_nId );
1192503e1a5SAriel Constenla-Haile
1202503e1a5SAriel Constenla-Haile return ::sal_uInt32(0);
1212503e1a5SAriel Constenla-Haile }
1222503e1a5SAriel Constenla-Haile
getStyle()1232503e1a5SAriel Constenla-Haile ::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
1242503e1a5SAriel Constenla-Haile throw (RuntimeException)
1252503e1a5SAriel Constenla-Haile {
1262503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1272503e1a5SAriel Constenla-Haile return m_nStyle;
1282503e1a5SAriel Constenla-Haile }
1292503e1a5SAriel Constenla-Haile
getOffset()1302503e1a5SAriel Constenla-Haile ::sal_Int32 SAL_CALL StatusbarItem::getOffset()
1312503e1a5SAriel Constenla-Haile throw (RuntimeException)
1322503e1a5SAriel Constenla-Haile {
1332503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1342503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1352503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
1362503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemOffset( m_nId );
1372503e1a5SAriel Constenla-Haile
1382503e1a5SAriel Constenla-Haile return ::sal_Int32(0);
1392503e1a5SAriel Constenla-Haile }
1402503e1a5SAriel Constenla-Haile
getItemRect()1412503e1a5SAriel Constenla-Haile ::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
1422503e1a5SAriel Constenla-Haile throw (RuntimeException)
1432503e1a5SAriel Constenla-Haile {
1442503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1452503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1462503e1a5SAriel Constenla-Haile ::com::sun::star::awt::Rectangle aAWTRect;
1472503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
1482503e1a5SAriel Constenla-Haile {
1492503e1a5SAriel Constenla-Haile Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
1502503e1a5SAriel Constenla-Haile return ::com::sun::star::awt::Rectangle( aRect.Left(),
1512503e1a5SAriel Constenla-Haile aRect.Top(),
1522503e1a5SAriel Constenla-Haile aRect.GetWidth(),
1532503e1a5SAriel Constenla-Haile aRect.GetHeight() );
1542503e1a5SAriel Constenla-Haile }
1552503e1a5SAriel Constenla-Haile
1562503e1a5SAriel Constenla-Haile return aAWTRect;
1572503e1a5SAriel Constenla-Haile }
1582503e1a5SAriel Constenla-Haile
getText()1592503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getText()
1602503e1a5SAriel Constenla-Haile throw (RuntimeException)
1612503e1a5SAriel Constenla-Haile {
1622503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1632503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1642503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
1652503e1a5SAriel Constenla-Haile return m_pStatusBar->GetItemText( m_nId );
1662503e1a5SAriel Constenla-Haile
1672503e1a5SAriel Constenla-Haile return OUString();
1682503e1a5SAriel Constenla-Haile }
1692503e1a5SAriel Constenla-Haile
setText(const OUString & rText)1702503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setText( const OUString& rText )
1712503e1a5SAriel Constenla-Haile throw (RuntimeException)
1722503e1a5SAriel Constenla-Haile {
1732503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1742503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1752503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
176*be099857Smseidel m_pStatusBar->SetItemText( m_nId, rText );
1772503e1a5SAriel Constenla-Haile }
1782503e1a5SAriel Constenla-Haile
getHelpText()1792503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getHelpText()
1802503e1a5SAriel Constenla-Haile throw (RuntimeException)
1812503e1a5SAriel Constenla-Haile {
1822503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1832503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1842503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
1852503e1a5SAriel Constenla-Haile return m_pStatusBar->GetHelpText( m_nId );
1862503e1a5SAriel Constenla-Haile
1872503e1a5SAriel Constenla-Haile return OUString();
1882503e1a5SAriel Constenla-Haile }
1892503e1a5SAriel Constenla-Haile
setHelpText(const OUString & rHelpText)1902503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
1912503e1a5SAriel Constenla-Haile throw (RuntimeException)
1922503e1a5SAriel Constenla-Haile {
1932503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1942503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
1952503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
196*be099857Smseidel m_pStatusBar->SetHelpText( m_nId, rHelpText );
1972503e1a5SAriel Constenla-Haile }
1982503e1a5SAriel Constenla-Haile
getQuickHelpText()1992503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getQuickHelpText()
2002503e1a5SAriel Constenla-Haile throw (RuntimeException)
2012503e1a5SAriel Constenla-Haile {
2022503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2032503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2042503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2052503e1a5SAriel Constenla-Haile return m_pStatusBar->GetHelpText( m_nId );
2062503e1a5SAriel Constenla-Haile
2072503e1a5SAriel Constenla-Haile return OUString();
2082503e1a5SAriel Constenla-Haile }
2092503e1a5SAriel Constenla-Haile
setQuickHelpText(const OUString & rQuickHelpText)2102503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
2112503e1a5SAriel Constenla-Haile throw (RuntimeException)
2122503e1a5SAriel Constenla-Haile {
2132503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2142503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2152503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2162503e1a5SAriel Constenla-Haile m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
2172503e1a5SAriel Constenla-Haile }
2182503e1a5SAriel Constenla-Haile
getAccessibleName()2192503e1a5SAriel Constenla-Haile OUString SAL_CALL StatusbarItem::getAccessibleName()
2202503e1a5SAriel Constenla-Haile throw (RuntimeException)
2212503e1a5SAriel Constenla-Haile {
2222503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2232503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2242503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2252503e1a5SAriel Constenla-Haile return m_pStatusBar->GetAccessibleName( m_nId );
2262503e1a5SAriel Constenla-Haile
2272503e1a5SAriel Constenla-Haile return OUString();
2282503e1a5SAriel Constenla-Haile }
2292503e1a5SAriel Constenla-Haile
setAccessibleName(const OUString & rAccessibleName)2302503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
2312503e1a5SAriel Constenla-Haile throw (RuntimeException)
2322503e1a5SAriel Constenla-Haile {
2332503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2342503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2352503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2362503e1a5SAriel Constenla-Haile m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
2372503e1a5SAriel Constenla-Haile }
2382503e1a5SAriel Constenla-Haile
getVisible()2392503e1a5SAriel Constenla-Haile ::sal_Bool SAL_CALL StatusbarItem::getVisible()
2402503e1a5SAriel Constenla-Haile throw (RuntimeException)
2412503e1a5SAriel Constenla-Haile {
2422503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2432503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2442503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2452503e1a5SAriel Constenla-Haile return m_pStatusBar->IsItemVisible( m_nId );
2462503e1a5SAriel Constenla-Haile
2472503e1a5SAriel Constenla-Haile return sal_False;
2482503e1a5SAriel Constenla-Haile }
2492503e1a5SAriel Constenla-Haile
setVisible(::sal_Bool bVisible)2502503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::setVisible( ::sal_Bool bVisible )
2512503e1a5SAriel Constenla-Haile throw (RuntimeException)
2522503e1a5SAriel Constenla-Haile {
2532503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2542503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2552503e1a5SAriel Constenla-Haile if ( !m_pStatusBar )
2562503e1a5SAriel Constenla-Haile return;
2572503e1a5SAriel Constenla-Haile
2582503e1a5SAriel Constenla-Haile if ( bVisible != m_pStatusBar->IsItemVisible( m_nId ) )
2592503e1a5SAriel Constenla-Haile {
2602503e1a5SAriel Constenla-Haile if ( bVisible )
2612503e1a5SAriel Constenla-Haile m_pStatusBar->ShowItem( m_nId );
2622503e1a5SAriel Constenla-Haile else
2632503e1a5SAriel Constenla-Haile m_pStatusBar->HideItem( m_nId );
2642503e1a5SAriel Constenla-Haile }
2652503e1a5SAriel Constenla-Haile }
2662503e1a5SAriel Constenla-Haile
repaint()2672503e1a5SAriel Constenla-Haile void SAL_CALL StatusbarItem::repaint( )
2682503e1a5SAriel Constenla-Haile throw (RuntimeException)
2692503e1a5SAriel Constenla-Haile {
2702503e1a5SAriel Constenla-Haile vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2712503e1a5SAriel Constenla-Haile osl::MutexGuard aGuard( m_aMutex );
2722503e1a5SAriel Constenla-Haile if ( m_pStatusBar )
2732503e1a5SAriel Constenla-Haile {
2742503e1a5SAriel Constenla-Haile m_pStatusBar->RedrawItem( m_nId );
2752503e1a5SAriel Constenla-Haile }
2762503e1a5SAriel Constenla-Haile }
2772503e1a5SAriel Constenla-Haile
2782503e1a5SAriel Constenla-Haile }
279