LibreOffice Module toolkit (master) 1
tkscrollbar.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
21#include <helper/property.hxx>
22#include <com/sun/star/uno/XComponentContext.hpp>
25
27
29
30namespace toolkit
31{
32
33
34 using namespace ::com::sun::star;
35
36
37 //= UnoControlScrollBarModel
38
39
40 UnoControlScrollBarModel::UnoControlScrollBarModel( const uno::Reference< uno::XComponentContext >& i_factory )
41 :UnoControlModel( i_factory )
42 {
43 UNO_CONTROL_MODEL_REGISTER_PROPERTIES<VCLXScrollBar>();
44 }
45
46
47 OUString UnoControlScrollBarModel::getServiceName( )
48 {
49 return "stardiv.vcl.controlmodel.ScrollBar";
50 }
51
52 OUString UnoControlScrollBarModel::getImplementationName()
53 {
54 return "stardiv.Toolkit.UnoControlScrollBarModel";
55 }
56
57 css::uno::Sequence<OUString>
58 UnoControlScrollBarModel::getSupportedServiceNames()
59 {
61 s.realloc(s.getLength() + 2);
62 auto ps = s.getArray();
63 ps[s.getLength() - 2] = "com.sun.star.awt.UnoControlScrollBarModel";
64 ps[s.getLength() - 1] = "stardiv.vcl.controlmodel.ScrollBar";
65 return s;
66 }
67
68 uno::Any UnoControlScrollBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
69 {
70 switch ( nPropId )
71 {
73 return uno::Any( false );
75 return uno::Any( OUString( "stardiv.vcl.control.ScrollBar" ) );
76
77 default:
79 }
80 }
81
82
83 ::cppu::IPropertyArrayHelper& UnoControlScrollBarModel::getInfoHelper()
84 {
85 static UnoPropertyArrayHelper aHelper( ImplGetPropertyIds() );
86 return aHelper;
87 }
88
89
90 uno::Reference< beans::XPropertySetInfo > UnoControlScrollBarModel::getPropertySetInfo( )
91 {
92 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
93 return xInfo;
94 }
95
96
97 //= UnoControlScrollBarModel
98
99 UnoScrollBarControl::UnoScrollBarControl()
100 :maAdjustmentListeners( *this )
101 {
102 }
103
105 {
106 return "ScrollBar";
107 }
108
109 // css::uno::XInterface
111 {
112 uno::Any aRet = ::cppu::queryInterface( rType,
113 static_cast< awt::XAdjustmentListener* >(this),
114 static_cast< awt::XScrollBar* >(this) );
115 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
116 }
117
119
120 // css::lang::XTypeProvider
121 css::uno::Sequence< css::uno::Type > UnoScrollBarControl::getTypes()
122 {
123 static const ::cppu::OTypeCollection aTypeList(
128 );
129 return aTypeList.getTypes();
130 }
131
133 {
134 lang::EventObject aEvt;
135 aEvt.Source = static_cast<cppu::OWeakObject*>(this);
136 maAdjustmentListeners.disposeAndClear( aEvt );
138 }
139
140 void UnoScrollBarControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer )
141 {
142 UnoControl::createPeer( rxToolkit, rParentPeer );
143
144 uno::Reference < awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
145 xScrollBar->addAdjustmentListener( this );
146 }
147
148 // css::awt::XAdjustmentListener
149 void UnoScrollBarControl::adjustmentValueChanged( const css::awt::AdjustmentEvent& rEvent )
150 {
151 switch ( rEvent.Type )
152 {
153 case css::awt::AdjustmentType_ADJUST_LINE:
154 case css::awt::AdjustmentType_ADJUST_PAGE:
155 case css::awt::AdjustmentType_ADJUST_ABS:
156 {
157 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
158
159 if ( xScrollBar.is() )
160 {
161 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), uno::Any(xScrollBar->getValue()), false );
162 }
163 }
164 break;
165 default:
166 {
167 OSL_FAIL( "UnoScrollBarControl::adjustmentValueChanged - unknown Type" );
168
169 }
170 }
171
172 if ( maAdjustmentListeners.getLength() )
173 maAdjustmentListeners.adjustmentValueChanged( rEvent );
174 }
175
176 // css::awt::XScrollBar
177 void UnoScrollBarControl::addAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
178 {
179 maAdjustmentListeners.addInterface( l );
180 }
181
182 void UnoScrollBarControl::removeAdjustmentListener( const css::uno::Reference< css::awt::XAdjustmentListener > & l )
183 {
184 maAdjustmentListeners.removeInterface( l );
185 }
186
188 {
190 }
191
192 void UnoScrollBarControl::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax )
193 {
197 }
198
200 {
201 sal_Int32 n = 0;
202 if ( getPeer().is() )
203 {
204 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
205 n = xScrollBar->getValue();
206 }
207 return n;
208 }
209
211 {
213 }
214
216 {
217 sal_Int32 n = 0;
218 if ( getPeer().is() )
219 {
220 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
221 n = xScrollBar->getMaximum();
222 }
223 return n;
224 }
225
227 {
229 }
230
232 {
233 sal_Int32 n = 0;
234 if ( getPeer().is() )
235 {
236 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
237 n = xScrollBar->getLineIncrement();
238 }
239 return n;
240 }
241
243 {
245 }
246
248 {
249 sal_Int32 n = 0;
250 if ( getPeer().is() )
251 {
252 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
253 n = xScrollBar->getBlockIncrement();
254 }
255 return n;
256 }
257
259 {
261 }
262
264 {
265 sal_Int32 n = 0;
266 if ( getPeer().is() )
267 {
268 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
269 n = xScrollBar->getVisibleSize();
270 }
271 return n;
272 }
273
275 {
277 }
278
280 {
281 sal_Int32 n = 0;
282 if ( getPeer().is() )
283 {
284 uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
285 n = xScrollBar->getOrientation();
286 }
287 return n;
288 }
289
291 {
292 return "stardiv.Toolkit.UnoScrollBarControl";
293 }
294
296 {
298 s.realloc(s.getLength() + 2);
299 auto ps = s.getArray();
300 ps[s.getLength() - 2] = "com.sun.star.awt.UnoControlScrollBar";
301 ps[s.getLength() - 1] = "stardiv.vcl.control.ScrollBar";
302 return s;
303 }
304
305} // namespace toolkit
306
307
308extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
310 css::uno::XComponentContext *context,
311 css::uno::Sequence<css::uno::Any> const &)
312{
313 return cppu::acquire(new toolkit::UnoControlScrollBarModel(context));
314}
315
316extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
318 css::uno::XComponentContext *,
319 css::uno::Sequence<css::uno::Any> const &)
320{
321 return cppu::acquire(new toolkit::UnoScrollBarControl());
322}
323
324/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ImplSetPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue, bool bUpdateThis)
virtual css::uno::Any ImplGetDefaultValue(sal_uInt16 nPropId) const
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL dispose() override
Definition: unocontrol.cxx:346
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryAggregation(css::uno::Type const &rType) SAL_OVERRIDE
UnoControlScrollBarModel(const css::uno::Reference< css::uno::XComponentContext > &i_factory)
void SAL_CALL removeAdjustmentListener(const css::uno::Reference< css::awt::XAdjustmentListener > &l) override
void SAL_CALL setValues(sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax) override
void SAL_CALL setVisibleSize(sal_Int32 n) override
void SAL_CALL setValue(sal_Int32 n) override
OUString GetComponentServiceName() const override
AdjustmentListenerMultiplexer maAdjustmentListeners
Definition: tkscrollbar.hxx:64
sal_Int32 SAL_CALL getBlockIncrement() override
sal_Int32 SAL_CALL getLineIncrement() override
void SAL_CALL setLineIncrement(sal_Int32 n) override
sal_Int32 SAL_CALL getVisibleSize() override
void SAL_CALL dispose() override
void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
sal_Int32 SAL_CALL getMaximum() override
sal_Int32 SAL_CALL getValue() override
void SAL_CALL setBlockIncrement(sal_Int32 n) override
sal_Int32 SAL_CALL getOrientation() override
OUString SAL_CALL getImplementationName() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL setOrientation(sal_Int32 n) override
void SAL_CALL setMaximum(sal_Int32 n) override
void SAL_CALL adjustmentValueChanged(const css::awt::AdjustmentEvent &rEvent) override
void SAL_CALL addAdjustmentListener(const css::uno::Reference< css::awt::XAdjustmentListener > &l) override
css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
Any aHelper
sal_Int16 nValue
sal_Int64 n
#define IMPL_IMPLEMENTATION_ID(ClassName)
Definition: macros.hxx:27
Type
const OUString & GetPropertyName(sal_uInt16 nPropertyId)
Definition: property.cxx:295
#define BASEPROPERTY_LINEINCREMENT
Definition: property.hxx:112
#define BASEPROPERTY_VISIBLESIZE
Definition: property.hxx:114
#define BASEPROPERTY_ORIENTATION
Definition: property.hxx:115
#define BASEPROPERTY_BLOCKINCREMENT
Definition: property.hxx:113
#define BASEPROPERTY_SCROLLVALUE_MAX
Definition: property.hxx:111
#define BASEPROPERTY_LIVE_SCROLL
Definition: property.hxx:136
#define BASEPROPERTY_DEFAULTCONTROL
Definition: property.hxx:52
#define BASEPROPERTY_SCROLLVALUE
Definition: property.hxx:110
bool hasValue()
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_Toolkit_UnoScrollBarControl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_Toolkit_UnoControlScrollBarModel_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)