tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / reportdesign / source / ui / misc / statusbarcontroller.cxx
blob8c44f1473635e08553d2cd6c3925a565a26a5ec1
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 <statusbarcontroller.hxx>
22 #include <cppuhelper/supportsservice.hxx>
23 #include <comphelper/types.hxx>
24 #include <svx/zoomsliderctrl.hxx>
25 #include <svx/zoomctrl.hxx>
26 #include <svx/svxids.hrc>
27 #include <sfx2/zoomitem.hxx>
28 #include <svx/zoomslideritem.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/status.hxx>
32 #include <osl/mutex.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <com/sun/star/awt/XWindow.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
37 namespace rptui
39 using namespace svt;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::beans;
42 using namespace com::sun::star::lang;
43 using namespace ::com::sun::star::frame;
44 using namespace ::com::sun::star::util;
46 OUString SAL_CALL OStatusbarController::getImplementationName()
48 return u"com.sun.star.report.comp.StatusbarController"_ustr;
51 sal_Bool SAL_CALL OStatusbarController::supportsService( const OUString& ServiceName )
53 return cppu::supportsService(this, ServiceName);
56 Sequence< OUString> SAL_CALL OStatusbarController::getSupportedServiceNames()
58 return { u"com.sun.star.frame.StatusbarController"_ustr };
61 IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE)
63 OStatusbarController::OStatusbarController(const Reference< XComponentContext >& rxContext)
64 : ::svt::StatusbarController(rxContext, Reference< XFrame >(), OUString(), 0)
65 ,m_nSlotId(0)
66 ,m_nId(1)
70 void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments )
72 StatusbarController::initialize(_rArguments);
73 SolarMutexGuard aSolarMutexGuard;
75 VclPtr< StatusBar > pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow));
76 if ( !pStatusBar )
77 return;
79 const sal_uInt16 nCount = pStatusBar->GetItemCount();
80 for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
82 const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos);
83 if ( pStatusBar->GetItemCommand(nItemId) == m_aCommandURL )
85 m_nId = nItemId;
86 break;
90 rtl::Reference<SfxStatusBarControl> pController;
91 if ( m_aCommandURL == ".uno:ZoomSlider" )
93 m_nSlotId = SID_ATTR_ZOOMSLIDER;
94 pController = new SvxZoomSliderControl(m_nSlotId,m_nId,*pStatusBar);
96 else if ( m_aCommandURL == ".uno:Zoom" )
98 m_nSlotId = SID_ATTR_ZOOM;
99 pController = new SvxZoomStatusBarControl(m_nSlotId,m_nId,*pStatusBar);
102 if ( pController )
104 m_rController.set( pController );
105 if ( m_rController.is() )
107 m_rController->initialize(_rArguments);
108 m_rController->update();
112 addStatusListener(m_aCommandURL);
113 update();
115 // XStatusListener
116 void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)
118 SolarMutexGuard aSolarGuard;
120 if ( !m_rController.is() )
121 return;
123 if ( m_aCommandURL == ".uno:ZoomSlider" )
125 Sequence< PropertyValue > aSeq;
126 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 )
128 SvxZoomSliderItem aZoomSlider(100,20,400);
129 aZoomSlider.PutValue(_aEvent.State, 0);
130 static_cast<SvxZoomSliderControl*>(m_rController.get())->StateChangedAtStatusBarControl(m_nSlotId,SfxItemState::DEFAULT,&aZoomSlider);
133 else if ( m_aCommandURL == ".uno:Zoom" )
135 Sequence< PropertyValue > aSeq;
136 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 )
138 SvxZoomItem aZoom;
139 aZoom.PutValue(_aEvent.State, 0 );
140 static_cast<SvxZoomStatusBarControl*>(m_rController.get())->StateChangedAtStatusBarControl(m_nSlotId,SfxItemState::DEFAULT,&aZoom);
145 // XStatusbarController
146 sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const css::awt::MouseEvent& _aEvent)
148 return m_rController.is() && m_rController->mouseButtonDown(_aEvent);
151 sal_Bool SAL_CALL OStatusbarController::mouseMove( const css::awt::MouseEvent& _aEvent)
153 return m_rController.is() && m_rController->mouseMove(_aEvent);
156 sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const css::awt::MouseEvent& _aEvent)
158 return m_rController.is() && m_rController->mouseButtonUp(_aEvent);
161 void SAL_CALL OStatusbarController::command(
162 const css::awt::Point& aPos,
163 ::sal_Int32 nCommand,
164 sal_Bool bMouseEvent,
165 const css::uno::Any& aData )
167 if ( m_rController.is() )
168 m_rController->command( aPos, nCommand, bMouseEvent, aData );
171 void SAL_CALL OStatusbarController::paint(
172 const css::uno::Reference< css::awt::XGraphics >& xGraphics,
173 const css::awt::Rectangle& rOutputRectangle,
174 ::sal_Int32 nStyle )
176 if ( m_rController.is() )
177 m_rController->paint( xGraphics, rOutputRectangle, nStyle );
180 void SAL_CALL OStatusbarController::click(
181 const css::awt::Point& aPos )
183 if ( m_rController.is() )
184 m_rController->click( aPos );
187 void SAL_CALL OStatusbarController::doubleClick(
188 const css::awt::Point& aPos )
190 if ( m_rController.is() )
191 m_rController->doubleClick( aPos );
194 void SAL_CALL OStatusbarController::update()
196 ::svt::StatusbarController::update();
197 if ( m_rController.is() )
198 m_rController->update();
201 // XComponent
202 void SAL_CALL OStatusbarController::dispose()
204 if ( m_rController.is() )
205 ::comphelper::disposeComponent( m_rController );
207 svt::StatusbarController::dispose();
210 } // rptui
212 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
213 reportdesign_OStatusbarController_get_implementation(
214 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
216 return cppu::acquire(new rptui::OStatusbarController(context));
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */