From a3100ff384a815e3088fc9ab5b43c3e5ff701cc3 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Mon, 14 Sep 2009 12:27:12 +0000 Subject: #cr6875455# introduce a ReferenceDevice property for various control types --- toolkit/inc/toolkit/helper/property.hxx | 1 + toolkit/source/awt/vclxwindow.cxx | 26 ++++++++++++++++++++++++++ toolkit/source/awt/vclxwindows.cxx | 6 ++++++ toolkit/source/controls/unocontrolmodel.cxx | 7 ++++++- toolkit/source/helper/property.cxx | 15 +++++++++------ 5 files changed, 48 insertions(+), 7 deletions(-) (limited to 'toolkit') diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index fbfe90494279..f82df1f5b53f 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -197,6 +197,7 @@ namespace rtl { #define BASEPROPERTY_GRID_COLUMNMODEL 143 #define BASEPROPERTY_GRID_SELECTIONMODE 144 #define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool +#define BASEPROPERTY_REFERENCE_DEVICE 146 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 337400c08713..93486d86e739 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,7 @@ using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::lang::EventObject; using ::com::sun::star::awt::XWindowListener2; using ::com::sun::star::awt::XDockableWindowListener; +using ::com::sun::star::awt::XDevice; using ::com::sun::star::style::VerticalAlignment; using ::com::sun::star::style::VerticalAlignment_TOP; using ::com::sun::star::style::VerticalAlignment_MIDDLE; @@ -1639,6 +1641,19 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: sal_uInt16 nPropType = GetPropertyId( PropertyName ); switch ( nPropType ) { + case BASEPROPERTY_REFERENCE_DEVICE: + { + // TODO: at the moment, the refdevice is hackily implemented for Button and derived classes only + Control* pControl = dynamic_cast< Control* >( pWindow ); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) + break; + Reference< XDevice > xDevice( Value, UNO_QUERY ); + OutputDevice* pDevice = VCLUnoHelper::GetOutputDevice( xDevice ); + pControl->SetReferenceDevice( pDevice ); + } + break; + case BASEPROPERTY_CONTEXT_WRITING_MODE: { OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode ); @@ -2157,6 +2172,17 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: sal_uInt16 nPropType = GetPropertyId( PropertyName ); switch ( nPropType ) { + case BASEPROPERTY_REFERENCE_DEVICE: + { + // TODO: at the moment, the refdevice is hackily implemented for Button and derived classes only + Button* pButton = dynamic_cast< Button* >( GetWindow() ); + if ( !pButton ) + break; + + // TODO: hmm ... it seems there is no way to query an OutputDevice for its XDevice ...? + } + break; + case BASEPROPERTY_CONTEXT_WRITING_MODE: aProp <<= mpImpl->mnContextWritingMode; break; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index b49fa1a621d6..ff5dd437ef52 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -408,6 +408,7 @@ void VCLXButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, 0); VCLXImageConsumer::ImplGetPropertyIds( rIds ); } @@ -817,6 +818,7 @@ void VCLXCheckBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, 0); VCLXImageConsumer::ImplGetPropertyIds( rIds ); } @@ -1116,6 +1118,7 @@ void VCLXRadioButton::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, 0); VCLXImageConsumer::ImplGetPropertyIds( rIds ); } @@ -1540,6 +1543,7 @@ void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_ALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 0); VCLXWindow::ImplGetPropertyIds( rIds ); @@ -2759,6 +2763,7 @@ void VCLXFixedText::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, 0); VCLXWindow::ImplGetPropertyIds( rIds ); } @@ -3762,6 +3767,7 @@ void VCLXComboBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_ALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, + BASEPROPERTY_REFERENCE_DEVICE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, 0); // no, don't call VCLXEdit here - it has properties which we do *not* want to have at at combo box diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index cc5faa27eec8..a4febcd33b33 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -262,7 +263,11 @@ void UnoControlModel::ImplPropertyChanged( sal_uInt16 ) switch ( nPropId ) { case BASEPROPERTY_GRAPHIC: - aDefault <<= makeAny( Reference< graphic::XGraphic >() ); + aDefault <<= Reference< graphic::XGraphic >(); + break; + + case BASEPROPERTY_REFERENCE_DEVICE: + aDefault <<= Reference< awt::XDevice >(); break; case BASEPROPERTY_VERTICALALIGN: diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index e71c03bae47d..a59af95a2e1f 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; +using ::com::sun::star::awt::XDevice; using ::com::sun::star::awt::FontDescriptor; using ::com::sun::star::style::VerticalAlignment; @@ -275,12 +277,13 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "URL", URL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "WritingMode", WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), DECL_PROP_3 ( "ContextWritingMode", CONTEXT_WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT ), - DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_3 ( "GridDataModel", GRID_DATAMODEL, Reference< ::com::sun::star::awt::grid::XGridDataModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ) + DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_3 ( "GridDataModel", GRID_DATAMODEL, Reference< ::com::sun::star::awt::grid::XGridDataModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ) }; pPropertyInfos = aImplPropertyInfos; nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo ); -- cgit From 8e2308c3ff142e3b7232908bacdcdb85ac1f9683 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Thu, 17 Sep 2009 21:11:28 +0000 Subject: setZoom: care for rounding errors which occur during implicit conversion from float to double --- toolkit/source/awt/vclxwindow.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 93486d86e739..501ed7f009f1 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -2586,7 +2586,14 @@ void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) throw(::com::sun::sta ::vos::OGuard aGuard( GetMutex() ); if ( GetWindow() ) - GetWindow()->SetZoom( Fraction( fZoomX ) ); + { + // Fraction::Fraction takes a double, but we have a float only. + // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to + // 1.200000000047something. To prevent this, we convert explicitly to double, and round it. + double nZoom( fZoomX ); + nZoom = ::rtl::math::round( nZoom, 4 ); + GetWindow()->SetZoom( Fraction( nZoom ) ); + } } // ::com::sun::star::lang::XEventListener -- cgit From 1b51c3004bec95184cf605a74c06cb4414f8270f Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 25 Sep 2009 09:49:45 +0000 Subject: getProperty( RefDevice ) implemented now --- toolkit/source/awt/vclxwindow.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 501ed7f009f1..40413091aaf2 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -1643,7 +1643,6 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: { case BASEPROPERTY_REFERENCE_DEVICE: { - // TODO: at the moment, the refdevice is hackily implemented for Button and derived classes only Control* pControl = dynamic_cast< Control* >( pWindow ); OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); if ( !pControl ) @@ -2174,12 +2173,14 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: { case BASEPROPERTY_REFERENCE_DEVICE: { - // TODO: at the moment, the refdevice is hackily implemented for Button and derived classes only - Button* pButton = dynamic_cast< Button* >( GetWindow() ); - if ( !pButton ) + Control* pControl = dynamic_cast< Control* >( GetWindow() ); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) break; - // TODO: hmm ... it seems there is no way to query an OutputDevice for its XDevice ...? + VCLXDevice* pDevice = new VCLXDevice; + pDevice->SetOutputDevice( pControl->GetReferenceDevice() ); + aProp <<= Reference< XDevice >( pDevice ); } break; -- cgit