diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-06-15 20:02:53 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-06-15 20:02:53 +0200 |
commit | 5ed103d2dd5f8ee2f13183263c0930f84437bdc7 (patch) | |
tree | ab1c7cf7a0b884df473eeda6048030ee8629972b /vbahelper/inc | |
parent | f9561071999b3c5c8505d648c14fff7b1bcd0caa (diff) |
mib16: contributed bugfixes and various new symbols in VBA compatibility implementation
Diffstat (limited to 'vbahelper/inc')
-rw-r--r-- | vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 11 | ||||
-rw-r--r-- | vbahelper/inc/vbahelper/vbacollectionimpl.hxx | 92 | ||||
-rw-r--r-- | vbahelper/inc/vbahelper/vbadocumentbase.hxx | 3 | ||||
-rw-r--r-- | vbahelper/inc/vbahelper/vbafontbase.hxx | 9 | ||||
-rw-r--r-- | vbahelper/inc/vbahelper/vbahelper.hxx | 20 | ||||
-rw-r--r-- | vbahelper/inc/vbahelper/vbahelperinterface.hxx | 53 |
6 files changed, 181 insertions, 7 deletions
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index e72015413192..e2a5a3bff5da 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -34,8 +34,12 @@ typedef InheritedHelperInterfaceImpl1< ov::XApplicationBase > ApplicationBase_BASE; +struct VbaApplicationBase_Impl; + class VBAHELPER_DLLPUBLIC VbaApplicationBase : public ApplicationBase_BASE { + VbaApplicationBase_Impl* m_pImpl; + protected: VbaApplicationBase( const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaApplicationBase(); @@ -49,11 +53,18 @@ public: virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException); virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getInteractive() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); + virtual void SAL_CALL OnTime( const ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::uno::RuntimeException); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); + // XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 6d596c31ba53..36102116c7b3 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -24,6 +24,7 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #ifndef OOVBAAPI_VBA_COLLECTION_IMPL_HXX #define OOVBAAPI_VBA_COLLECTION_IMPL_HXX @@ -44,8 +45,91 @@ #include <vector> +// ============================================================================ + typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE; +// ============================================================================ + +/** A wrapper that holds a com.sun.star.container.XIndexAccess and provides a + com.sun.star.container.XEnumeration. + + Can be used to provide an enumeration from an index container that contains + completely constructed/initialized VBA implementation objects. CANNOT be + used to provide an enumeration from an index container with other objects + (e.g. UNO objects) where construction of the VBA objects is needed first. + */ +class VBAHELPER_DLLPUBLIC SimpleIndexAccessToEnumeration : public EnumerationHelper_BASE +{ +public: + explicit SimpleIndexAccessToEnumeration( + const css::uno::Reference< css::container::XIndexAccess >& rxIndexAccess ) throw (css::uno::RuntimeException) : + mxIndexAccess( rxIndexAccess ), mnIndex( 0 ) {} + + virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException) + { + return mnIndex < mxIndexAccess->getCount(); + } + + virtual css::uno::Any SAL_CALL nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + if( !hasMoreElements() ) + throw css::container::NoSuchElementException(); + return mxIndexAccess->getByIndex( mnIndex++ ); + } + +private: + css::uno::Reference< css::container::XIndexAccess > mxIndexAccess; + sal_Int32 mnIndex; +}; + +// ============================================================================ + +/** A wrapper that holds a com.sun.star.container.XEnumeration or a + com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects. + + The method nextElement() needs to be implemented by the derived class. This + class can be used to convert an enumeration or an index container + containing UNO objects to an enumeration providing the related VBA objects. + */ +class VBAHELPER_DLLPUBLIC SimpleEnumerationBase : public EnumerationHelper_BASE +{ +public: + explicit SimpleEnumerationBase( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::container::XEnumeration >& rxEnumeration ) throw (css::uno::RuntimeException) : + mxParent( rxParent ), mxContext( rxContext ), mxEnumeration( rxEnumeration ) {} + + explicit SimpleEnumerationBase( + const css::uno::Reference< ov::XHelperInterface >& rxParent, + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::container::XIndexAccess >& rxIndexAccess ) throw (css::uno::RuntimeException) : + mxParent( rxParent ), mxContext( rxContext ), mxEnumeration( new SimpleIndexAccessToEnumeration( rxIndexAccess ) ) {} + + virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException) + { + return mxEnumeration->hasMoreElements(); + } + + virtual css::uno::Any SAL_CALL nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + return createCollectionObject( mxEnumeration->nextElement() ); + } + + /** Derived classes implement creation of a VBA implementation object from + the passed container element. */ + virtual css::uno::Any createCollectionObject( const css::uno::Any& rSource ) = 0; + +protected: + css::uno::Reference< ov::XHelperInterface > mxParent; + css::uno::Reference< css::uno::XComponentContext > mxContext; + css::uno::Reference< css::container::XEnumeration > mxEnumeration; +}; + +// ============================================================================ + +// deprecated, use SimpleEnumerationBase instead! class VBAHELPER_DLLPUBLIC EnumerationHelperImpl : public EnumerationHelper_BASE { protected: @@ -181,6 +265,14 @@ protected: // need to adjust for vba index ( for which first element is 1 ) return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) ); } + + virtual void UpdateCollectionIndex( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) + { + css::uno::Reference< css::container::XNameAccess > xNameAccess( xIndexAccess, css::uno::UNO_QUERY_THROW ); + m_xIndexAccess = xIndexAccess; + m_xNameAccess = xNameAccess; + } + public: ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); } //XCollection diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 36648ff6849b..7131e1963b26 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -53,6 +53,9 @@ public: virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn + + // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, const css::uno::Any &aFileName, diff --git a/vbahelper/inc/vbahelper/vbafontbase.hxx b/vbahelper/inc/vbahelper/vbafontbase.hxx index b820804f1fe2..d1272c9dcf48 100644 --- a/vbahelper/inc/vbahelper/vbafontbase.hxx +++ b/vbahelper/inc/vbahelper/vbafontbase.hxx @@ -63,8 +63,15 @@ class VBAHELPER_DLLPUBLIC VbaFontBase : public VbaFontBase_BASE protected: css::uno::Reference< css::beans::XPropertySet > mxFont; css::uno::Reference< css::container::XIndexAccess > mxPalette; + bool mbFormControl; + public: - VbaFontBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPalette, css::uno::Reference< css::beans::XPropertySet > xPropertySet ) throw ( css::uno::RuntimeException ); + VbaFontBase( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::container::XIndexAccess >& xPalette, + const css::uno::Reference< css::beans::XPropertySet >& xPropertySet, + bool bFormControl = false ) throw ( css::uno::RuntimeException ); virtual ~VbaFontBase();// {} // Attributes diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 166ad76475d8..33613bb76091 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/awt/XUnitConversion.hpp> #include <basic/basmgr.hxx> #include <basic/sberrors.hxx> #include <cppuhelper/implbase1.hxx> @@ -74,8 +75,8 @@ namespace ooo VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::script::XTypeConverter > getTypeConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); - VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl) ; - VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl, css::uno::Sequence< css::beans::PropertyValue >& sProps ) ; + VBAHELPER_DLLPUBLIC void dispatchRequests( const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString& aUrl ); + VBAHELPER_DLLPUBLIC void dispatchRequests( const css::uno::Reference< css::frame::XModel>& xModel, const rtl::OUString& aUrl, const css::uno::Sequence< css::beans::PropertyValue >& sProps ); VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, USHORT nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON ); VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 ); VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 ); @@ -92,7 +93,9 @@ namespace ooo VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic ) VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); - VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints ); + VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm ); VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& ); VBAHELPER_DLLPUBLIC void setCursorHelper( const css::uno::Reference< css::frame::XModel >& xModel, const Pointer& rPointer, sal_Bool bOverWrite ); VBAHELPER_DLLPUBLIC void setDefaultPropByIntrospection( const css::uno::Any& aObj, const css::uno::Any& aValue ) throw ( css::uno::RuntimeException ); @@ -103,8 +106,6 @@ class VBAHELPER_DLLPUBLIC Millimeter { //Factor to translate between points and hundredths of millimeters: private: - static const double factor; - double m_nMillimeter; public: @@ -178,12 +179,19 @@ public: virtual double getWidth(); virtual void setWidth( double nWidth); }; + #define VBA_LEFT "PositionX" #define VBA_TOP "PositionY" +#define VBA_HEIGHT "Height" +#define VBA_WIDTH "Width" class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes { - + css::uno::Reference< css::awt::XUnitConversion > mxControlUnits; css::uno::Reference< css::beans::XPropertySet > mxModel; + + sal_Int32 ConvertLogicToPixel( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nSourceUnit ); + sal_Int32 ConvertPixelToLogic( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nTargetUnit ); + public: UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl ); virtual double getLeft(); diff --git a/vbahelper/inc/vbahelper/vbahelperinterface.hxx b/vbahelper/inc/vbahelper/vbahelperinterface.hxx index 5695ab36b4fa..21339631e1ed 100644 --- a/vbahelper/inc/vbahelper/vbahelperinterface.hxx +++ b/vbahelper/inc/vbahelper/vbahelperinterface.hxx @@ -115,4 +115,57 @@ public: InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} }; + +// ============================================================================ + +/** Helper macro to implement the method 'getServiceImplName()' of the + 'ooo.vba.XHelperInterface' interface. Will return the class name as service + implementation name. + */ +#define VBAHELPER_IMPL_GETSERVICEIMPLNAME( classname ) \ +::rtl::OUString& classname::getServiceImplName() \ +{ \ + static ::rtl::OUString saImplName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( #classname ) ); \ + return saImplName; \ +} + +// ---------------------------------------------------------------------------- + +/** Helper macro to implement the method 'getServiceNames()' for a single + service name. + */ +#define VBAHELPER_IMPL_GETSERVICENAMES( classname, servicename ) \ +css::uno::Sequence< ::rtl::OUString > classname::getServiceNames() \ +{ \ + static css::uno::Sequence< ::rtl::OUString > saServiceNames; \ + if( saServiceNames.getLength() == 0 ) \ + { \ + saServiceNames.realloc( 1 ); \ + saServiceNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( servicename ) ); \ + } \ + return saServiceNames; \ +} + +// ---------------------------------------------------------------------------- + +/** Helper macro to declare the methods 'getServiceImplName()' and + 'getServiceNames()' of the 'ooo.vba.XHelperInterface' interface in a class + declaration. + */ +#define VBAHELPER_DECL_XHELPERINTERFACE \ + virtual ::rtl::OUString& getServiceImplName(); \ + virtual css::uno::Sequence< ::rtl::OUString > getServiceNames(); + +// ---------------------------------------------------------------------------- + +/** Helper macro to implement the methods 'getServiceImplName()' and + 'getServiceNames()' of the 'ooo.vba.XHelperInterface' interface. Will + return the class name as service implementation name. + */ +#define VBAHELPER_IMPL_XHELPERINTERFACE( classname, servicename ) \ +VBAHELPER_IMPL_GETSERVICEIMPLNAME( classname ) \ +VBAHELPER_IMPL_GETSERVICENAMES( classname, servicename ) + +// ============================================================================ + #endif |