1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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 "com.sun.star.report.comp.StatusbarController";
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 { "com.sun.star.frame.StatusbarController" };
61 IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController
, ::svt::StatusbarController
,OStatusbarController_BASE
)
63 OStatusbarController::OStatusbarController(const Reference
< XComponentContext
>& rxContext
)
64 : ::svt::StatusbarController(rxContext
, Reference
< XFrame
>(), OUString(), 0)
70 void SAL_CALL
OStatusbarController::initialize( const Sequence
< Any
>& _rArguments
)
72 StatusbarController::initialize(_rArguments
);
73 SolarMutexGuard aSolarMutexGuard
;
74 ::osl::MutexGuard
aGuard(m_aMutex
);
76 VclPtr
< StatusBar
> pStatusBar
= static_cast<StatusBar
*>(VCLUnoHelper::GetWindow(m_xParentWindow
));
80 const sal_uInt16 nCount
= pStatusBar
->GetItemCount();
81 for (sal_uInt16 nPos
= 0; nPos
< nCount
; ++nPos
)
83 const sal_uInt16 nItemId
= pStatusBar
->GetItemId(nPos
);
84 if ( pStatusBar
->GetItemCommand(nItemId
) == m_aCommandURL
)
91 rtl::Reference
<SfxStatusBarControl
> pController
;
92 if ( m_aCommandURL
== ".uno:ZoomSlider" )
94 m_nSlotId
= SID_ATTR_ZOOMSLIDER
;
95 pController
= new SvxZoomSliderControl(m_nSlotId
,m_nId
,*pStatusBar
);
97 else if ( m_aCommandURL
== ".uno:Zoom" )
99 m_nSlotId
= SID_ATTR_ZOOM
;
100 pController
= new SvxZoomStatusBarControl(m_nSlotId
,m_nId
,*pStatusBar
);
105 m_rController
.set( pController
);
106 if ( m_rController
.is() )
108 m_rController
->initialize(_rArguments
);
109 m_rController
->update();
113 addStatusListener(m_aCommandURL
);
117 void SAL_CALL
OStatusbarController::statusChanged( const FeatureStateEvent
& _aEvent
)
119 SolarMutexGuard aSolarGuard
;
120 ::osl::MutexGuard
aGuard(m_aMutex
);
122 if ( !m_rController
.is() )
125 if ( m_aCommandURL
== ".uno:ZoomSlider" )
127 Sequence
< PropertyValue
> aSeq
;
128 if ( (_aEvent
.State
>>= aSeq
) && aSeq
.getLength() == 2 )
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
);
135 else if ( m_aCommandURL
== ".uno:Zoom" )
137 Sequence
< PropertyValue
> aSeq
;
138 if ( (_aEvent
.State
>>= aSeq
) && aSeq
.getLength() == 3 )
141 aZoom
.PutValue(_aEvent
.State
, 0 );
142 static_cast<SvxZoomStatusBarControl
*>(m_rController
.get())->StateChangedAtStatusBarControl(m_nSlotId
,SfxItemState::DEFAULT
,&aZoom
);
147 // XStatusbarController
148 sal_Bool SAL_CALL
OStatusbarController::mouseButtonDown(const css::awt::MouseEvent
& _aEvent
)
150 return m_rController
.is() && m_rController
->mouseButtonDown(_aEvent
);
153 sal_Bool SAL_CALL
OStatusbarController::mouseMove( const css::awt::MouseEvent
& _aEvent
)
155 return m_rController
.is() && m_rController
->mouseMove(_aEvent
);
158 sal_Bool SAL_CALL
OStatusbarController::mouseButtonUp( const css::awt::MouseEvent
& _aEvent
)
160 return m_rController
.is() && m_rController
->mouseButtonUp(_aEvent
);
163 void SAL_CALL
OStatusbarController::command(
164 const css::awt::Point
& aPos
,
165 ::sal_Int32 nCommand
,
166 sal_Bool bMouseEvent
,
167 const css::uno::Any
& aData
)
169 if ( m_rController
.is() )
170 m_rController
->command( aPos
, nCommand
, bMouseEvent
, aData
);
173 void SAL_CALL
OStatusbarController::paint(
174 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
,
175 const css::awt::Rectangle
& rOutputRectangle
,
178 if ( m_rController
.is() )
179 m_rController
->paint( xGraphics
, rOutputRectangle
, nStyle
);
182 void SAL_CALL
OStatusbarController::click(
183 const css::awt::Point
& aPos
)
185 if ( m_rController
.is() )
186 m_rController
->click( aPos
);
189 void SAL_CALL
OStatusbarController::doubleClick(
190 const css::awt::Point
& aPos
)
192 if ( m_rController
.is() )
193 m_rController
->doubleClick( aPos
);
196 void SAL_CALL
OStatusbarController::update()
198 ::svt::StatusbarController::update();
199 if ( m_rController
.is() )
200 m_rController
->update();
204 void SAL_CALL
OStatusbarController::dispose()
206 if ( m_rController
.is() )
207 ::comphelper::disposeComponent( m_rController
);
209 svt::StatusbarController::dispose();
214 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
215 reportdesign_OStatusbarController_get_implementation(
216 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
218 return cppu::acquire(new rptui::OStatusbarController(context
));
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */