update dev300-m58
[ooovba.git] / reportdesign / source / ui / misc / statusbarcontroller.cxx
blob8cba08853da525b2620a3def3ca0c3ba071702e6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statusbarcontroller.cxx,v $
10 * $Revision: 1.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_reportdesign.hxx"
33 #include "statusbarcontroller.hxx"
35 #include <svx/zoomsliderctrl.hxx>
36 #include <svx/zoomctrl.hxx>
37 #include <svx/svxids.hrc>
38 #include <svx/zoomitem.hxx>
39 #include <svx/zoomslideritem.hxx>
41 #include <vcl/svapp.hxx>
42 #include <vcl/status.hxx>
43 #include <vos/mutex.hxx>
44 #include <toolkit/helper/vclunohelper.hxx>
46 namespace rptui
48 using namespace svt;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::beans;
51 using namespace com::sun::star::lang;
52 using namespace ::com::sun::star::frame;
53 using namespace ::com::sun::star::util;
55 ::rtl::OUString SAL_CALL OStatusbarController::getImplementationName() throw( RuntimeException )
57 return getImplementationName_Static();
60 //------------------------------------------------------------------------------
61 ::rtl::OUString OStatusbarController::getImplementationName_Static() throw( RuntimeException )
63 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.StatusbarController"));
65 //------------------------------------------------------------------------------
66 Sequence< ::rtl::OUString> OStatusbarController::getSupportedServiceNames_Static(void) throw( RuntimeException )
68 Sequence< ::rtl::OUString> aSupported(1);
69 aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StatusbarController"));
70 return aSupported;
72 // -----------------------------------------------------------------------------
73 ::sal_Bool SAL_CALL OStatusbarController::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
75 return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
77 //-------------------------------------------------------------------------
78 Sequence< ::rtl::OUString> SAL_CALL OStatusbarController::getSupportedServiceNames() throw(RuntimeException)
80 return getSupportedServiceNames_Static();
82 // -------------------------------------------------------------------------
83 Reference< XInterface > OStatusbarController::create(Reference< XComponentContext > const & xContext)
85 return *(new OStatusbarController(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY)));
87 IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE)
89 OStatusbarController::OStatusbarController(const Reference< XMultiServiceFactory >& _rxORB)
90 : m_nSlotId(0)
91 ,m_nId(1)
93 m_xServiceManager = _rxORB;
95 // -----------------------------------------------------------------------------
96 void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
98 StatusbarController::initialize(_rArguments);
99 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
100 ::osl::MutexGuard aGuard(m_aMutex);
102 StatusBar* pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow));
103 if ( pStatusBar )
105 const USHORT nCount = pStatusBar->GetItemCount();
106 for (USHORT nPos = 0; nPos < nCount; ++nPos)
108 const USHORT nItemId = pStatusBar->GetItemId(nPos);
109 if ( pStatusBar->GetItemCommand(nItemId) == String(m_aCommandURL) )
111 m_nId = nItemId;
112 break;
115 if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") )
117 m_pController = TStatusbarHelper::createFromQuery(new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar));
118 } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") )
119 else if ( m_aCommandURL.equalsAscii(".uno:Zoom") )
121 m_pController = TStatusbarHelper::createFromQuery(new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar));
124 if ( m_pController.is() )
126 m_pController->initialize(_rArguments);
127 m_pController->update();
130 addStatusListener(m_aCommandURL);
131 update();
134 // XStatusListener
135 void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)throw ( RuntimeException )
137 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
138 ::osl::MutexGuard aGuard(m_aMutex);
140 if ( m_pController.is() )
142 if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") )
144 Sequence< PropertyValue > aSeq;
145 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 )
147 SvxZoomSliderItem aZoomSlider(100,20,400);
148 aZoomSlider.PutValue(_aEvent.State);
149 static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider);
151 } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") )
152 else if ( m_aCommandURL.equalsAscii(".uno:Zoom") )
154 Sequence< PropertyValue > aSeq;
155 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 )
157 SvxZoomItem aZoom;
158 aZoom.PutValue(_aEvent.State);
159 static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom);
165 // XStatusbarController
166 ::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
168 return m_pController.is() && m_pController.getRef()->mouseButtonDown(_aEvent);
171 ::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
173 return m_pController.is() && m_pController.getRef()->mouseMove(_aEvent);
176 ::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
178 return m_pController.is() && m_pController.getRef()->mouseButtonUp(_aEvent);
181 void SAL_CALL OStatusbarController::command(
182 const ::com::sun::star::awt::Point& aPos,
183 ::sal_Int32 nCommand,
184 ::sal_Bool bMouseEvent,
185 const ::com::sun::star::uno::Any& aData )
186 throw (::com::sun::star::uno::RuntimeException)
188 if ( m_pController.is() )
189 m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData );
192 void SAL_CALL OStatusbarController::paint(
193 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
194 const ::com::sun::star::awt::Rectangle& rOutputRectangle,
195 ::sal_Int32 nItemId,
196 ::sal_Int32 nStyle )
197 throw (::com::sun::star::uno::RuntimeException)
199 if ( m_pController.is() )
200 m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle );
203 void SAL_CALL OStatusbarController::click() throw (::com::sun::star::uno::RuntimeException)
205 if ( m_pController.is() )
206 m_pController.getRef()->click();
209 void SAL_CALL OStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException)
211 if ( m_pController.is() )
212 m_pController.getRef()->doubleClick();
214 // -----------------------------------------------------------------------------
215 void SAL_CALL OStatusbarController::update() throw ( RuntimeException )
217 ::svt::StatusbarController::update();
218 Reference< XUpdatable > xUp(m_pController.getRef(),UNO_QUERY);
219 if ( xUp.is() )
220 xUp->update();
222 // -----------------------------------------------------------------------------
223 // XComponent
224 void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException)
226 Reference< XComponent > xComp( m_pController.getRef(), UNO_QUERY );
227 ::comphelper::disposeComponent(xComp);
228 m_pController.dispose();
229 svt::StatusbarController::dispose();
231 // =============================================================================
232 } // rptui
233 // =============================================================================