summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-04-05 14:17:24 +0100
committerNoel Power <noel.power@novell.com>2012-04-17 14:30:31 +0100
commitf39d0b837742c69488e43e919f7f1a927c2859ed (patch)
tree27da4d582e3e1fd422237dd015b115c8569f236f
parent0a9161263b8e2e5df424dda3c8f80ef5067bbcc9 (diff)
add support for MousePointer attribute in controls
For Useforms it doesn't quite work exactly as MSO, for examply if we set the MousePointer for the Userform it works as expected until we mouse over another control at which point the mouse pointer is changed to that of the control. In MSO it would appear that the Userform mousepointer is king, perhaps all that is necessary is to apply the mouse pointer to each contained control, needs some investigation. Also only a limited number of the possible mouse pointer styles are processed, the conversions of mso -> lo pointer styles ( and vice-versa ) and not really tested to see if they all make sense
-rw-r--r--oovbaapi/ooo/vba/msforms/XControl.idl1
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx84
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx2
3 files changed, 85 insertions, 2 deletions
diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 5ece205ee465..9f2c6ee78720 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -44,6 +44,7 @@ interface XControl
[attribute] string RowSource;
[attribute] boolean Enabled;
[attribute] boolean Visible;
+ [attribute] long MousePointer;
//Size. there are some defferent between Mso and OOo.
//Mso use double but OOo use long. OOo 1 = 1/100mm but Mso use pt.
//in Dialogs Mso uses pixels
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index f092f17cf331..caf5491f7370 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/document/XCodeNameQuery.hpp>
#include <com/sun/star/form/XChangeListener.hpp>
#include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/msforms/fmMousePointer.hpp>
#ifdef VBA_OOBUILD_HACK
#include <svtools/bindablecontrolhelper.hxx>
#endif
@@ -64,8 +65,8 @@
#include "vbasystemaxcontrol.hxx"
#include "vbaimage.hxx"
#include <vbahelper/helperdecl.hxx>
-
-
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -422,6 +423,85 @@ void SAL_CALL ScVbaControl::setForeColor( ::sal_Int32 _forecolor ) throw (::com:
m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) ), uno::makeAny( XLRGBToOORGB( _forecolor ) ) );
}
+struct PointerStyles
+{
+ long msoPointerStyle;
+ PointerStyle loPointStyle;
+};
+
+// 1 -> 1 map of styles ( some dubious choices in there though )
+PointerStyles styles[] = {
+ /// assuming pointer default is Arrow
+ { msforms::fmMousePointer::fmMousePointerDefault, POINTER_ARROW },
+ { msforms::fmMousePointer::fmMousePointerArrow, POINTER_ARROW },
+ { msforms::fmMousePointer::fmMousePointerCross, POINTER_CROSS },
+ { msforms::fmMousePointer::fmMousePointerIBeam, POINTER_TEXT },
+ { msforms::fmMousePointer::fmMousePointerSizeNESW, POINTER_AUTOSCROLL_NSWE }, // #TODO not correct, need to check, need to find the right one
+ { msforms::fmMousePointer::fmMousePointerSizeNS, POINTER_AUTOSCROLL_NS },
+ { msforms::fmMousePointer::fmMousePointerSizeNWSE, POINTER_AUTOSCROLL_NSWE }, // #TODO not correct, need to check, need to find the right one
+ { msforms::fmMousePointer::fmMousePointerSizeWE, POINTER_AUTOSCROLL_WE },
+ { msforms::fmMousePointer::fmMousePointerUpArrow, POINTER_WINDOW_NSIZE },
+ { msforms::fmMousePointer::fmMousePointerHourGlass, POINTER_WAIT },
+ { msforms::fmMousePointer::fmMousePointerNoDrop, POINTER_NOTALLOWED },
+ { msforms::fmMousePointer::fmMousePointerAppStarting, POINTER_WAIT },
+ { msforms::fmMousePointer::fmMousePointerHelp, POINTER_HELP },
+ { msforms::fmMousePointer::fmMousePointerSizeAll, POINTER_CROSS },
+ { msforms::fmMousePointer::fmMousePointerCustom, POINTER_ARROW }, // not supported I guess
+
+};
+
+long lcl_loPointerToMsoPointer( PointerStyle eType )
+{
+ long nRet = msforms::fmMousePointer::fmMousePointerDefault;
+ for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+ {
+ if ( styles[ i ].loPointStyle == eType )
+ {
+ nRet = styles[ i ].msoPointerStyle;
+ break;
+ }
+ }
+ return nRet;
+}
+
+Pointer lcl_msoPointerToLOPointer( long msoPointerStyle )
+{
+ Pointer aPointer( POINTER_ARROW );
+ for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+ {
+ if ( styles[ i ].msoPointerStyle == msoPointerStyle )
+ {
+ aPointer = Pointer( styles[ i ].loPointStyle );
+ break;
+ }
+ }
+ return aPointer;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaControl::getMousePointer() throw (::com::sun::star::uno::RuntimeException)
+{
+ PointerStyle eType = POINTER_ARROW; // default ?
+ Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+ if ( pWindow )
+ {
+ eType = pWindow->GetPointer().GetStyle();
+ }
+ return lcl_loPointerToMsoPointer( eType );
+}
+
+void SAL_CALL
+ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::star::uno::RuntimeException)
+{
+ Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+ if ( pWindow )
+ {
+ Pointer aPointer( POINTER_ARROW );
+ aPointer = lcl_msoPointerToLOPointer( _mousepointer );
+ pWindow->SetPointer( aPointer );
+ }
+}
+
void ScVbaControl::fireEvent( script::ScriptEvent& evt )
{
uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 77129807c683..871d9a663fec 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -107,6 +107,8 @@ public:
virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMousePointer() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::star::uno::RuntimeException);
//remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
virtual void removeResouce() throw( css::uno::RuntimeException );
virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);