LibreOffice Module reportdesign (master) 1
statusbarcontroller.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <statusbarcontroller.hxx>
21
23#include <comphelper/types.hxx>
25#include <svx/zoomctrl.hxx>
26#include <svx/svxids.hrc>
27#include <sfx2/zoomitem.hxx>
29
30#include <vcl/svapp.hxx>
31#include <vcl/status.hxx>
32#include <osl/mutex.hxx>
34#include <com/sun/star/awt/XWindow.hpp>
35#include <com/sun/star/beans/PropertyValue.hpp>
36
37namespace rptui
38{
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;
45
47{
48 return "com.sun.star.report.comp.StatusbarController";
49}
50
51sal_Bool SAL_CALL OStatusbarController::supportsService( const OUString& ServiceName )
52{
54}
55
57{
58 return { "com.sun.star.frame.StatusbarController" };
59}
60
62
63OStatusbarController::OStatusbarController(const Reference< XComponentContext >& rxContext)
64: ::svt::StatusbarController(rxContext, Reference< XFrame >(), OUString(), 0)
65,m_nSlotId(0)
66,m_nId(1)
67{
68}
69
70void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments )
71{
73 SolarMutexGuard aSolarMutexGuard;
74 ::osl::MutexGuard aGuard(m_aMutex);
75
77 if ( !pStatusBar )
78 return;
79
80 const sal_uInt16 nCount = pStatusBar->GetItemCount();
81 for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
82 {
83 const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos);
84 if ( pStatusBar->GetItemCommand(nItemId) == m_aCommandURL )
85 {
86 m_nId = nItemId;
87 break;
88 }
89 }
90
92 if ( m_aCommandURL == ".uno:ZoomSlider" )
93 {
94 m_nSlotId = SID_ATTR_ZOOMSLIDER;
95 pController = new SvxZoomSliderControl(m_nSlotId,m_nId,*pStatusBar);
96 }
97 else if ( m_aCommandURL == ".uno:Zoom" )
98 {
99 m_nSlotId = SID_ATTR_ZOOM;
100 pController = new SvxZoomStatusBarControl(m_nSlotId,m_nId,*pStatusBar);
101 }
102
103 if ( pController )
104 {
105 m_rController.set( pController );
106 if ( m_rController.is() )
107 {
108 m_rController->initialize(_rArguments);
109 m_rController->update();
110 }
111 }
112
114 update();
115}
116// XStatusListener
117void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent)
118{
119 SolarMutexGuard aSolarGuard;
120 ::osl::MutexGuard aGuard(m_aMutex);
121
122 if ( !m_rController.is() )
123 return;
124
125 if ( m_aCommandURL == ".uno:ZoomSlider" )
126 {
128 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 )
129 {
130 SvxZoomSliderItem aZoomSlider(100,20,400);
131 aZoomSlider.PutValue(_aEvent.State, 0);
132 static_cast<SvxZoomSliderControl*>(m_rController.get())->StateChangedAtStatusBarControl(m_nSlotId,SfxItemState::DEFAULT,&aZoomSlider);
133 }
134 }
135 else if ( m_aCommandURL == ".uno:Zoom" )
136 {
138 if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 )
139 {
140 SvxZoomItem aZoom;
141 aZoom.PutValue(_aEvent.State, 0 );
142 static_cast<SvxZoomStatusBarControl*>(m_rController.get())->StateChangedAtStatusBarControl(m_nSlotId,SfxItemState::DEFAULT,&aZoom);
143 }
144 }
145}
146
147// XStatusbarController
148sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const css::awt::MouseEvent& _aEvent)
149{
150 return m_rController.is() && m_rController->mouseButtonDown(_aEvent);
151}
152
153sal_Bool SAL_CALL OStatusbarController::mouseMove( const css::awt::MouseEvent& _aEvent)
154{
155 return m_rController.is() && m_rController->mouseMove(_aEvent);
156}
157
158sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const css::awt::MouseEvent& _aEvent)
159{
160 return m_rController.is() && m_rController->mouseButtonUp(_aEvent);
161}
162
164 const css::awt::Point& aPos,
165 ::sal_Int32 nCommand,
166 sal_Bool bMouseEvent,
167 const css::uno::Any& aData )
168{
169 if ( m_rController.is() )
170 m_rController->command( aPos, nCommand, bMouseEvent, aData );
171}
172
174 const css::uno::Reference< css::awt::XGraphics >& xGraphics,
175 const css::awt::Rectangle& rOutputRectangle,
176 ::sal_Int32 nStyle )
177{
178 if ( m_rController.is() )
179 m_rController->paint( xGraphics, rOutputRectangle, nStyle );
180}
181
183 const css::awt::Point& aPos )
184{
185 if ( m_rController.is() )
186 m_rController->click( aPos );
187}
188
190 const css::awt::Point& aPos )
191{
192 if ( m_rController.is() )
193 m_rController->doubleClick( aPos );
194}
195
197{
199 if ( m_rController.is() )
200 m_rController->update();
201}
202
203// XComponent
205{
206 if ( m_rController.is() )
207 ::comphelper::disposeComponent( m_rController );
208
210}
211
212} // rptui
213
214extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
216 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
217{
218 return cppu::acquire(new rptui::OStatusbarController(context));
219}
220
221
222/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
virtual sal_Bool SAL_CALL mouseButtonDown(const css::awt::MouseEvent &aMouseEvent) override
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &Event) override
virtual void SAL_CALL update() override
css::uno::Reference< css::frame::XStatusbarController > m_rController
virtual sal_Bool SAL_CALL mouseButtonUp(const css::awt::MouseEvent &aMouseEvent) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL doubleClick(const css::awt::Point &aPos) override
virtual void SAL_CALL click(const css::awt::Point &aPos) override
virtual sal_Bool SAL_CALL mouseMove(const css::awt::MouseEvent &aMouseEvent) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void SAL_CALL paint(const css::uno::Reference< css::awt::XGraphics > &xGraphics, const css::awt::Rectangle &rOutputRectangle, ::sal_Int32 nStyle) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void SAL_CALL dispose() override
virtual void SAL_CALL command(const css::awt::Point &aPos, ::sal_Int32 nCommand, sal_Bool bMouseEvent, const css::uno::Any &aData) override
css::uno::Reference< css::awt::XWindow > m_xParentWindow
void addStatusListener(const OUString &aCommandURL)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void SAL_CALL update() override
virtual void SAL_CALL dispose() override
int nCount
std::mutex m_aMutex
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
constexpr OUStringLiteral aData
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_OStatusbarController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
unsigned char sal_Bool