2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-02 14:13:40 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2003-12-11 10:58:44 +00:00
|
|
|
|
|
|
|
#include "toolkit/controls/tkscrollbar.hxx"
|
|
|
|
#include "toolkit/helper/property.hxx"
|
|
|
|
#include "toolkit/helper/unopropertyarrayhelper.hxx"
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
|
2008-01-14 11:57:45 +00:00
|
|
|
// for introspection
|
|
|
|
#include <toolkit/awt/vclxwindows.hxx>
|
|
|
|
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
namespace toolkit
|
|
|
|
{
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
//= UnoControlScrollBarModel
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-01-07 11:05:58 +02:00
|
|
|
UnoControlScrollBarModel::UnoControlScrollBarModel( const uno::Reference< uno::XComponentContext >& i_factory )
|
2010-12-06 14:14:11 +01:00
|
|
|
:UnoControlModel( i_factory )
|
2003-12-11 10:58:44 +00:00
|
|
|
{
|
2008-01-14 11:57:45 +00:00
|
|
|
UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXScrollBar );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString UnoControlScrollBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
|
2003-12-11 10:58:44 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString::createFromAscii( szServiceName_UnoControlScrollBarModel );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
uno::Any UnoControlScrollBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
|
|
|
|
{
|
|
|
|
switch ( nPropId )
|
|
|
|
{
|
2004-05-10 11:49:19 +00:00
|
|
|
case BASEPROPERTY_LIVE_SCROLL:
|
2014-02-24 11:13:09 +01:00
|
|
|
return uno::makeAny( false );
|
2003-12-11 10:58:44 +00:00
|
|
|
case BASEPROPERTY_DEFAULTCONTROL:
|
2013-04-07 12:06:47 +02:00
|
|
|
return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlScrollBar ) );
|
2003-12-11 10:58:44 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return UnoControlModel::ImplGetDefaultValue( nPropId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
::cppu::IPropertyArrayHelper& UnoControlScrollBarModel::getInfoHelper()
|
|
|
|
{
|
|
|
|
static UnoPropertyArrayHelper* pHelper = NULL;
|
|
|
|
if ( !pHelper )
|
|
|
|
{
|
|
|
|
uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
|
|
|
|
pHelper = new UnoPropertyArrayHelper( aIDs );
|
|
|
|
}
|
|
|
|
return *pHelper;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
uno::Reference< beans::XPropertySetInfo > UnoControlScrollBarModel::getPropertySetInfo( ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
|
|
|
|
return xInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
//= UnoControlScrollBarModel
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2013-01-07 11:05:58 +02:00
|
|
|
UnoScrollBarControl::UnoScrollBarControl()
|
|
|
|
:UnoControlBase()
|
2010-12-06 14:14:11 +01:00
|
|
|
,maAdjustmentListeners( *this )
|
2003-12-11 10:58:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString UnoScrollBarControl::GetComponentServiceName()
|
2003-12-11 10:58:44 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString("ScrollBar");
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::uno::XInterface
|
|
|
|
uno::Any UnoScrollBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Any aRet = ::cppu::queryInterface( rType,
|
2012-05-04 15:51:56 +02:00
|
|
|
(static_cast< awt::XAdjustmentListener* >(this)),
|
|
|
|
(static_cast< awt::XScrollBar* >(this)) );
|
2003-12-11 10:58:44 +00:00
|
|
|
return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::lang::XTypeProvider
|
|
|
|
IMPL_XTYPEPROVIDER_START( UnoScrollBarControl )
|
|
|
|
getCppuType( ( uno::Reference< awt::XAdjustmentListener>* ) NULL ),
|
|
|
|
getCppuType( ( uno::Reference< awt::XScrollBar>* ) NULL ),
|
|
|
|
UnoControlBase::getTypes()
|
|
|
|
IMPL_XTYPEPROVIDER_END
|
|
|
|
|
|
|
|
void UnoScrollBarControl::dispose() throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
lang::EventObject aEvt;
|
|
|
|
aEvt.Source = (::cppu::OWeakObject*)this;
|
|
|
|
maAdjustmentListeners.disposeAndClear( aEvt );
|
|
|
|
UnoControl::dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
UnoControl::createPeer( rxToolkit, rParentPeer );
|
|
|
|
|
|
|
|
uno::Reference < awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
xScrollBar->addAdjustmentListener( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::awt::XAdjustmentListener
|
|
|
|
void UnoScrollBarControl::adjustmentValueChanged( const ::com::sun::star::awt::AdjustmentEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
switch ( rEvent.Type )
|
|
|
|
{
|
|
|
|
case ::com::sun::star::awt::AdjustmentType_ADJUST_LINE:
|
|
|
|
case ::com::sun::star::awt::AdjustmentType_ADJUST_PAGE:
|
|
|
|
case ::com::sun::star::awt::AdjustmentType_ADJUST_ABS:
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if ( xScrollBar.is() )
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= xScrollBar->getValue();
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), aAny, false );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
2011-03-01 19:08:19 +01:00
|
|
|
OSL_FAIL( "UnoScrollBarControl::adjustmentValueChanged - unknown Type" );
|
2003-12-11 10:58:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( maAdjustmentListeners.getLength() )
|
|
|
|
maAdjustmentListeners.adjustmentValueChanged( rEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::awt::XScrollBar
|
|
|
|
void UnoScrollBarControl::addAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
maAdjustmentListeners.addInterface( l );
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::removeAdjustmentListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XAdjustmentListener > & l ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
maAdjustmentListeners.removeInterface( l );
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setValue( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Any aAny;
|
|
|
|
aAny <<= nValue;
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE ), aAny, true );
|
2003-12-11 10:58:44 +00:00
|
|
|
aAny <<= nVisible;
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VISIBLESIZE ), aAny, true );
|
2003-12-11 10:58:44 +00:00
|
|
|
aAny <<= nMax;
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE_MAX ), aAny, true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getValue() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getValue();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLVALUE_MAX ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getMaximum() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getMaximum();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINEINCREMENT ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getLineIncrement() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getLineIncrement();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BLOCKINCREMENT ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getBlockIncrement() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getBlockIncrement();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VISIBLESIZE ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getVisibleSize() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getVisibleSize();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnoScrollBarControl::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2014-02-24 11:13:09 +01:00
|
|
|
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ORIENTATION ), uno::makeAny( n ), true );
|
2003-12-11 10:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 UnoScrollBarControl::getOrientation() throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-09-08 14:58:05 +00:00
|
|
|
sal_Int32 n = 0;
|
2003-12-11 10:58:44 +00:00
|
|
|
if ( getPeer().is() )
|
|
|
|
{
|
|
|
|
uno::Reference< awt::XScrollBar > xScrollBar( getPeer(), uno::UNO_QUERY );
|
|
|
|
n = xScrollBar->getOrientation();
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
} // namespace toolkit
|
2014-02-25 22:29:44 +01:00
|
|
|
|
2003-12-11 10:58:44 +00:00
|
|
|
|
2014-01-24 10:48:03 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
stardiv_Toolkit_UnoControlScrollBarModel_get_implementation(
|
|
|
|
css::uno::XComponentContext *context,
|
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
|
|
|
{
|
|
|
|
return cppu::acquire(new toolkit::UnoControlScrollBarModel(context));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
stardiv_Toolkit_UnoScrollBarControl_get_implementation(
|
|
|
|
css::uno::XComponentContext *,
|
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
|
|
|
{
|
|
|
|
return cppu::acquire(new toolkit::UnoScrollBarControl());
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|