summaryrefslogtreecommitdiff
path: root/vbahelper/inc
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-06-15 20:02:53 +0200
committerDaniel Rentz <dr@openoffice.org>2010-06-15 20:02:53 +0200
commite75b5851a46b983ac3e02dd316856f0a15ad3846 (patch)
treed6b8bf3107e5c767911181d5c9bb9309c1220a8f /vbahelper/inc
parent53663a5b057105466ceaa1de74bd866229a21e66 (diff)
mib16: contributed bugfixes and various new symbols in VBA compatibility implementation
Diffstat (limited to 'vbahelper/inc')
-rw-r--r--vbahelper/inc/vbahelper/vbaapplicationbase.hxx13
-rw-r--r--vbahelper/inc/vbahelper/vbacollectionimpl.hxx94
-rw-r--r--vbahelper/inc/vbahelper/vbadocumentbase.hxx3
-rw-r--r--vbahelper/inc/vbahelper/vbafontbase.hxx9
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx20
-rw-r--r--vbahelper/inc/vbahelper/vbahelperinterface.hxx53
6 files changed, 183 insertions, 9 deletions
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
index edcefa8778..afbd896b2b 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();
@@ -44,16 +48,23 @@ protected:
public:
// XHelperInterface ( parent is itself )
virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return this; }
-
+
virtual sal_Bool SAL_CALL getScreenUpdating() throw (css::uno::RuntimeException);
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 40b920251e..20b220c1f5 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:
@@ -57,7 +141,7 @@ public:
virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); }
};
-// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces
+// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces
// only requirement is the object needs to implement XName
@@ -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 68703aa095..29335304db 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 5e79ec54c6..c49be459d5 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 dad98b977e..024b0d3aa8 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 3f1da84e22..45fb518572 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