From b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 18 Apr 2013 18:26:28 +0200 Subject: execute move of global headers see https://gerrit.libreoffice.org/#/c/3367/ and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a --- include/vbahelper/helperdecl.hxx | 49 +++++ include/vbahelper/vbaaccesshelper.hxx | 73 +++++++ include/vbahelper/vbaapplicationbase.hxx | 69 ++++++ include/vbahelper/vbacollectionimpl.hxx | 352 ++++++++++++++++++++++++++++++ include/vbahelper/vbadialogbase.hxx | 45 ++++ include/vbahelper/vbadialogsbase.hxx | 45 ++++ include/vbahelper/vbadllapi.h | 34 +++ include/vbahelper/vbadocumentbase.hxx | 65 ++++++ include/vbahelper/vbadocumentsbase.hxx | 60 +++++ include/vbahelper/vbaeventshelperbase.hxx | 184 ++++++++++++++++ include/vbahelper/vbafontbase.hxx | 96 ++++++++ include/vbahelper/vbaglobalbase.hxx | 45 ++++ include/vbahelper/vbahelper.hxx | 256 ++++++++++++++++++++++ include/vbahelper/vbahelperinterface.hxx | 185 ++++++++++++++++ include/vbahelper/vbapagesetupbase.hxx | 61 ++++++ include/vbahelper/vbapropvalue.hxx | 54 +++++ include/vbahelper/vbashape.hxx | 109 +++++++++ include/vbahelper/vbashaperange.hxx | 82 +++++++ include/vbahelper/vbashapes.hxx | 74 +++++++ include/vbahelper/vbatextframe.hxx | 61 ++++++ include/vbahelper/vbawindowbase.hxx | 76 +++++++ 21 files changed, 2075 insertions(+) create mode 100644 include/vbahelper/helperdecl.hxx create mode 100644 include/vbahelper/vbaaccesshelper.hxx create mode 100644 include/vbahelper/vbaapplicationbase.hxx create mode 100644 include/vbahelper/vbacollectionimpl.hxx create mode 100644 include/vbahelper/vbadialogbase.hxx create mode 100644 include/vbahelper/vbadialogsbase.hxx create mode 100644 include/vbahelper/vbadllapi.h create mode 100644 include/vbahelper/vbadocumentbase.hxx create mode 100644 include/vbahelper/vbadocumentsbase.hxx create mode 100644 include/vbahelper/vbaeventshelperbase.hxx create mode 100644 include/vbahelper/vbafontbase.hxx create mode 100644 include/vbahelper/vbaglobalbase.hxx create mode 100644 include/vbahelper/vbahelper.hxx create mode 100644 include/vbahelper/vbahelperinterface.hxx create mode 100644 include/vbahelper/vbapagesetupbase.hxx create mode 100644 include/vbahelper/vbapropvalue.hxx create mode 100644 include/vbahelper/vbashape.hxx create mode 100644 include/vbahelper/vbashaperange.hxx create mode 100644 include/vbahelper/vbashapes.hxx create mode 100644 include/vbahelper/vbatextframe.hxx create mode 100644 include/vbahelper/vbawindowbase.hxx (limited to 'include/vbahelper') diff --git a/include/vbahelper/helperdecl.hxx b/include/vbahelper/helperdecl.hxx new file mode 100644 index 000000000000..a8a3d75142e0 --- /dev/null +++ b/include/vbahelper/helperdecl.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef OOVBAAPI_SERV_DECL +#define OOVBAAPI_SERV_DECL +#include +#include + +namespace comphelper { +namespace service_decl { +template > +struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl, WithArgsT > +{ + typedef serviceimpl_base< detail::OwnServiceImpl, WithArgsT > baseT; + /** Default ctor. Implementation class without args, expecting + component context as single argument. + */ + vba_service_class_() : baseT() {} + template + /** Ctor to pass a post processing function/functor. + + @tpl PostProcessDefaultT let your compiler deduce this + @param postProcessFunc function/functor that gets the yet unacquired + ImplT_ pointer returning a + uno::Reference + */ + explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} +}; + +} // namespace service_decl +} // namespace comphelper +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbaaccesshelper.hxx b/include/vbahelper/vbaaccesshelper.hxx new file mode 100644 index 000000000000..11bbff2426a9 --- /dev/null +++ b/include/vbahelper/vbaaccesshelper.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef OOVBAAPI_VBA_ACCESS_HELPER_HXX +#define OOVBAAPI_VBA_ACCESS_HELPER_HXX + +#include +#include +#include +#include +#include +//#define VBAHELPER_DLLIMPLEMENTATION +#include +#include + +namespace ooo +{ + namespace vba + { + + VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell ) + { + css::uno::Any aUnoVar; + if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) + throw css::lang::IllegalArgumentException(); + css::uno::Reference< css::lang::XMultiServiceFactory > xVBAFactory( aUnoVar, css::uno::UNO_QUERY_THROW ); + return xVBAFactory; + } + + VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::Exception) + { + OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" ); + OUString sVarName( OUString::createFromAscii( _pAsciiName ) ); + css::uno::Reference< css::uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs ); + return xIf; + } + + + VBAHELPER_DLLPRIVATE inline bool isAlienDoc( SfxObjectShell& rDocShell, const char* pMimeType ) + { + bool bRes( false ); + const SfxMedium *pMedium = rDocShell.GetMedium(); + const SfxFilter *pFilt = pMedium ? pMedium->GetFilter() : NULL; + if ( pFilt && pFilt->IsAlienFormat() ) + bRes = ( pFilt->GetMimeType().compareToAscii( pMimeType ) == 0 ); + return bRes; + } + VBAHELPER_DLLPRIVATE inline bool isAlienExcelDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-excel" ); } + //VBAHELPER_DLLPRIVATE inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-word" ); } + // word seems to return an erroneous mime type :-/ "application/msword" not consistent with the excel one + VBAHELPER_DLLPRIVATE inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/msword" ); } + + } // openoffice +} // org + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbaapplicationbase.hxx b/include/vbahelper/vbaapplicationbase.hxx new file mode 100644 index 000000000000..c63bce52c263 --- /dev/null +++ b/include/vbahelper/vbaapplicationbase.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_APPLICATION_BASE_HXX +#define VBA_APPLICATION_BASE_HXX + +#include +#include +#include +#include + +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(); + + virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException) = 0; +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 (css::uno::RuntimeException); + virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( ::sal_Bool bVisible ) throw (css::uno::RuntimeException); + virtual void SAL_CALL OnKey( const OUString& Key, const ::com::sun::star::uno::Any& Procedure ) throw (::com::sun::star::uno::RuntimeException); + virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL Run( const 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 css::uno::Any& aEarliestTime, const OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException); + virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Undo() throw (css::uno::RuntimeException); + virtual void SAL_CALL Quit() throw (css::uno::RuntimeException); + + // XHelperInterface + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbacollectionimpl.hxx b/include/vbahelper/vbacollectionimpl.hxx new file mode 100644 index 000000000000..780741e06a62 --- /dev/null +++ b/include/vbahelper/vbacollectionimpl.hxx @@ -0,0 +1,352 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef OOVBAAPI_VBA_COLLECTION_IMPL_HXX +#define OOVBAAPI_VBA_COLLECTION_IMPL_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "vbahelper/vbahelper.hxx" +#include "vbahelper/vbahelperinterface.hxx" + +#include + +// ============================================================================ + +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 createCollectionObject() 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: + css::uno::WeakReference< ov::XHelperInterface > m_xParent; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::container::XEnumeration > m_xEnumeration; +public: + + EnumerationHelperImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } + 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 +// only requirement is the object needs to implement XName + + + +typedef ::cppu::WeakImplHelper3< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess > XNamedCollectionHelper_BASE; + +template< typename Ifc1 > +class XNamedObjectCollectionHelper : public XNamedCollectionHelper_BASE +{ +public: +typedef std::vector< css::uno::Reference< Ifc1 > > XNamedVec; +private: + + class XNamedEnumerationHelper : public EnumerationHelper_BASE + { + XNamedVec mXNamedVec; + typename XNamedVec::iterator mIt; + public: + XNamedEnumerationHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), mIt( mXNamedVec.begin() ) {} + + virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException) + { + return ( mIt != mXNamedVec.end() ); + } + + virtual css::uno::Any SAL_CALL nextElement( ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + if ( hasMoreElements() ) + return css::uno::makeAny( *mIt++ ); + throw css::container::NoSuchElementException(); + } + }; + +protected: + XNamedVec mXNamedVec; + typename XNamedVec::iterator cachePos; +public: + XNamedObjectCollectionHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), cachePos(mXNamedVec.begin()) {} + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) throw (css::uno::RuntimeException) { return Ifc1::static_type(0); } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (css::uno::RuntimeException) { return ( mXNamedVec.size() > 0 ); } + // XNameAcess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) + { + if ( !hasByName(aName) ) + throw css::container::NoSuchElementException(); + return css::uno::makeAny( *cachePos ); + } + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (css::uno::RuntimeException) + { + css::uno::Sequence< OUString > sNames( mXNamedVec.size() ); + OUString* pString = sNames.getArray(); + typename XNamedVec::iterator it = mXNamedVec.begin(); + typename XNamedVec::iterator it_end = mXNamedVec.end(); + + for ( ; it != it_end; ++it, ++pString ) + { + css::uno::Reference< css::container::XNamed > xName( *it, css::uno::UNO_QUERY_THROW ); + *pString = xName->getName(); + } + return sNames; + } + virtual ::sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (css::uno::RuntimeException) + { + cachePos = mXNamedVec.begin(); + typename XNamedVec::iterator it_end = mXNamedVec.end(); + for ( ; cachePos != it_end; ++cachePos ) + { + css::uno::Reference< css::container::XNamed > xName( *cachePos, css::uno::UNO_QUERY_THROW ); + if ( aName.equals( xName->getName() ) ) + break; + } + return ( cachePos != it_end ); + } + + // XElementAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (css::uno::RuntimeException) { return mXNamedVec.size(); } + virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException ) + { + if ( Index < 0 || Index >= getCount() ) + throw css::lang::IndexOutOfBoundsException(); + + return css::uno::makeAny( mXNamedVec[ Index ] ); + + } + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) throw (css::uno::RuntimeException) + { + return new XNamedEnumerationHelper( mXNamedVec ); + } +}; + +// including a HelperInterface implementation +template< typename Ifc1 > +class ScVbaCollectionBase : public InheritedHelperInterfaceImpl< Ifc1 > +{ +typedef InheritedHelperInterfaceImpl< Ifc1 > BaseColBase; +protected: + css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess; + css::uno::Reference< css::container::XNameAccess > m_xNameAccess; + sal_Bool mbIgnoreCase; + + virtual css::uno::Any getItemByStringIndex( const OUString& sIndex ) throw (css::uno::RuntimeException) + { + if ( !m_xNameAccess.is() ) + throw css::uno::RuntimeException( OUString( "ScVbaCollectionBase string index access not supported by this object" ), css::uno::Reference< css::uno::XInterface >() ); + + if( mbIgnoreCase ) + { + css::uno::Sequence< OUString > sElementNames = m_xNameAccess->getElementNames(); + for( sal_Int32 i = 0; i < sElementNames.getLength(); i++ ) + { + OUString aName = sElementNames[i]; + if( aName.equalsIgnoreAsciiCase( sIndex ) ) + { + return createCollectionObject( m_xNameAccess->getByName( aName ) ); + } + } + } + return createCollectionObject( m_xNameAccess->getByName( sIndex ) ); + } + + virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException) + { + if ( !m_xIndexAccess.is() ) + throw css::uno::RuntimeException( OUString( "ScVbaCollectionBase numeric index access not supported by this object" ), css::uno::Reference< css::uno::XInterface >() ); + if ( nIndex <= 0 ) + { + throw css::lang::IndexOutOfBoundsException( + OUString( "index is 0 or negative" ), + css::uno::Reference< css::uno::XInterface >() ); + } + // 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, sal_Bool bIgnoreCase = sal_False ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ), mbIgnoreCase( bIgnoreCase ) { m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); } + //XCollection + virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException) + { + return m_xIndexAccess->getCount(); + } + + virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw (css::uno::RuntimeException) + { + if ( Index1.getValueTypeClass() != css::uno::TypeClass_STRING ) + { + sal_Int32 nIndex = 0; + + if ( ( Index1 >>= nIndex ) != sal_True ) + { + OUString message; + message = OUString( "Couldn't convert index to Int32"); + throw css::lang::IndexOutOfBoundsException( message, + css::uno::Reference< css::uno::XInterface >() ); + } + return getItemByIntIndex( nIndex ); + } + OUString aStringSheet; + + Index1 >>= aStringSheet; + return getItemByStringIndex( aStringSheet ); + } + // XDefaultMethod + OUString SAL_CALL getDefaultMethodName( ) throw (css::uno::RuntimeException) + { + const static OUString sName( "Item" ); + return sName; + } + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0; + // XElementAccess + virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException) + { + return ( m_xIndexAccess->getCount() > 0 ); + } + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0; + +}; + +typedef ::cppu::WeakImplHelper1 XCollection_InterfacesBASE; + +typedef ScVbaCollectionBase< XCollection_InterfacesBASE > CollImplBase1; +// compatible with the old collections ( pre XHelperInterface base class ) ( some internal objects still use this ) +class VBAHELPER_DLLPUBLIC ScVbaCollectionBaseImpl : public CollImplBase1 +{ +public: + ScVbaCollectionBaseImpl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : CollImplBase1( xParent, xContext, xIndexAccess){} + +}; + +template // where Ifc must implement XCollectionTest +class CollTestImplHelper : public ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > > +{ +typedef ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > > ImplBase1; + +public: + CollTestImplHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, sal_Bool bIgnoreCase = sal_False ) throw( css::uno::RuntimeException ) : ImplBase1( xParent, xContext, xIndexAccess, bIgnoreCase ) {} +}; + + +#endif //SC_VBA_COLLECTION_IMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbadialogbase.hxx b/include/vbahelper/vbadialogbase.hxx new file mode 100644 index 000000000000..bb706cbaf17a --- /dev/null +++ b/include/vbahelper/vbadialogbase.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_DIALOG_BASE_HXX +#define VBA_DIALOG_BASE_HXX + +#include +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ov::XDialogBase > VbaDialogBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaDialogBase : public VbaDialogBase_BASE +{ +protected: + sal_Int32 mnIndex; + css::uno::Reference< css::frame::XModel > m_xModel; +public: + VbaDialogBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):VbaDialogBase_BASE( xParent, xContext ), mnIndex( nIndex ), m_xModel( xModel ) {} + virtual ~VbaDialogBase() {} + + // Methods + virtual void SAL_CALL Show() throw (css::uno::RuntimeException); + virtual OUString mapIndexToName( sal_Int32 nIndex ) = 0; +}; + +#endif /* VBA_DIALOG_BASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbadialogsbase.hxx b/include/vbahelper/vbadialogsbase.hxx new file mode 100644 index 000000000000..54c1fd33f107 --- /dev/null +++ b/include/vbahelper/vbadialogsbase.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_DIALOGS_BASE_HXX +#define VBA_DIALOGS_BASE_HXX + +#include +#include +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ov::XDialogsBase > VbaDialogsBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaDialogsBase : public VbaDialogsBase_BASE +{ +protected: + css::uno::Reference< css::frame::XModel > m_xModel; +public: + VbaDialogsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): VbaDialogsBase_BASE( xParent, xContext ), m_xModel( xModel ) {} + virtual ~VbaDialogsBase() {} + + // XCollection + virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException); +}; + +#endif /* VBA_DIALOGS_BASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbadllapi.h b/include/vbahelper/vbadllapi.h new file mode 100644 index 000000000000..43beae86b676 --- /dev/null +++ b/include/vbahelper/vbadllapi.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_VBADLLAPI_H +#define INCLUDED_VBADLLAPI_H + +#include "sal/types.h" + +#if defined(VBAHELPER_DLLIMPLEMENTATION) +#define VBAHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define VBAHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define VBAHELPER_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_SVLDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbadocumentbase.hxx b/include/vbahelper/vbadocumentbase.hxx new file mode 100644 index 000000000000..77e799078a97 --- /dev/null +++ b/include/vbahelper/vbadocumentbase.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_DOCUMENTBASE_HXX +#define VBA_DOCUMENTBASE_HXX + +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentBase > VbaDocumentBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE +{ +protected: + css::uno::Reference< css::frame::XModel > mxModel; + css::uno::Reference< css::uno::XInterface > mxVBProject; +protected: + virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; } +public: + VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, + css::uno::Reference< css::frame::XModel > xModel ); + VbaDocumentBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ); + virtual ~VbaDocumentBase() {} + + // Attributes + virtual OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual OUString SAL_CALL getPath() throw (css::uno::RuntimeException); + virtual OUString SAL_CALL getFullName() throw (css::uno::RuntimeException); + 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); + + // Methods + virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, + const css::uno::Any &aFileName, + const css::uno::Any &bRouteWorkbook ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Protect( const css::uno::Any &aPassword ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Unprotect( const css::uno::Any &aPassword ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Save() throw (css::uno::RuntimeException); + virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); + + // XHelperInterface + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); +}; + +#endif /* VBA_DOCUMENTBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbadocumentsbase.hxx b/include/vbahelper/vbadocumentsbase.hxx new file mode 100644 index 000000000000..b8386d6e291e --- /dev/null +++ b/include/vbahelper/vbadocumentsbase.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_WORKBOOKS_HXX +#define VBA_WORKBOOKS_HXX + + +#include +#include +#include + +typedef CollTestImplHelper< ooo::vba::XDocumentsBase > VbaDocumentsBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaDocumentsBase : public VbaDocumentsBase_BASE +{ +public: + enum DOCUMENT_TYPE + { + WORD_DOCUMENT = 1, + EXCEL_DOCUMENT + }; + +private: + DOCUMENT_TYPE meDocType; + +public: + VbaDocumentsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, DOCUMENT_TYPE eDocType ) throw (css::uno::RuntimeException); + virtual ~VbaDocumentsBase() {} + + // XEnumerationAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0; + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0; + + // VbaDocumentsBase_BASE + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0; + +protected: + css::uno::Any createDocument() throw (css::uno::RuntimeException); + void closeDocuments() throw (css::uno::RuntimeException); + css::uno::Any openDocument( const OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException); +}; + +#endif /* SC_VBA_WORKBOOKS_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbaeventshelperbase.hxx b/include/vbahelper/vbaeventshelperbase.hxx new file mode 100644 index 000000000000..627970f9f623 --- /dev/null +++ b/include/vbahelper/vbaeventshelperbase.hxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX +#define VBAHELPER_VBAEVENTSHELPERBASE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include "vbahelper/vbahelper.hxx" + +namespace com { namespace sun { namespace star { + namespace script { namespace vba { class XVBAModuleInfo; } } + namespace uno { class XComponentContext; } +} } } + +// ============================================================================ + +typedef ::cppu::WeakImplHelper3< + css::script::vba::XVBAEventProcessor, + css::document::XEventListener, + css::util::XChangesListener > VbaEventsHelperBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE +{ +public: + VbaEventsHelperBase( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~VbaEventsHelperBase(); + + // script::vba::XVBAEventProcessor + virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::util::VetoException, css::uno::RuntimeException); + + // document::XEventListener + virtual void SAL_CALL notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException); + + // util::XChangesListener + virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& rEvent ) throw (css::uno::RuntimeException); + + // lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& rEvent ) throw (css::uno::RuntimeException); + + // little helpers --------------------------------------------------------- + + /** Helper to execute event handlers without throwing any exceptions. */ + void processVbaEventNoThrow( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ); + + /** Throws, if the passed sequence does not contain a value at the specified index. */ + static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( (nIndex < 0) || (nIndex >= rArgs.getLength()) ) throw css::lang::IllegalArgumentException(); } + + /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */ + template< typename Type > + static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { checkArgument( rArgs, nIndex ); if( !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); } + +protected: + // ------------------------------------------------------------------------ + + struct EventHandlerInfo + { + sal_Int32 mnEventId; + sal_Int32 mnModuleType; + OUString maMacroName; + sal_Int32 mnCancelIndex; + css::uno::Any maUserData; + }; + + /** Registers a supported event handler. + + @param nEventId Event identifier from com.sun.star.script.vba.VBAEventId. + @param nModuleType Type of the module containing the event handler. + @param pcMacroName Name of the associated VBA event handler macro. + @param nCancelIndex 0-based index of Cancel parameter, or -1. + @param rUserData User data for free usage in derived implementations. */ + void registerEventHandler( + sal_Int32 nEventId, + sal_Int32 nModuleType, + const sal_Char* pcMacroName, + sal_Int32 nCancelIndex = -1, + const css::uno::Any& rUserData = css::uno::Any() ); + + // ------------------------------------------------------------------------ + + struct EventQueueEntry + { + sal_Int32 mnEventId; + css::uno::Sequence< css::uno::Any > maArgs; + inline /*implicit*/ EventQueueEntry( sal_Int32 nEventId ) : mnEventId( nEventId ) {} + inline EventQueueEntry( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) : mnEventId( nEventId ), maArgs( rArgs ) {} + }; + typedef ::std::deque< EventQueueEntry > EventQueue; + + /** Derived classes do additional prpeparations and return whether the + event handler has to be called. */ + virtual bool implPrepareEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the argument list for the specified VBA event handler. */ + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException) = 0; + + /** Derived classes may do additional postprocessing. Called even if the + event handler does not exist, or if an error occurred during execution. */ + virtual void implPostProcessEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + bool bCancel ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the name of the Basic document module. */ + virtual OUString implGetDocumentModuleName( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; + +private: + typedef ::std::map< sal_Int32, OUString > ModulePathMap; + + /** Starts listening at the document model. */ + void startListening(); + /** Stops listening at the document model. */ + void stopListening(); + + /** Returns the event handler info struct for the specified event, or throws. */ + const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException); + + /** Searches the event handler in the document and returns its full script path. */ + OUString getEventHandlerPath( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + + /** On first call, accesses the Basic library containing the VBA source code. */ + void ensureVBALibrary() throw (css::uno::RuntimeException); + + /** Returns the type of the Basic module with the specified name. */ + sal_Int32 getModuleType( const OUString& rModuleName ) throw (css::uno::RuntimeException); + + /** Updates the map containing paths to event handlers for a Basic module. */ + ModulePathMap& updateModulePathMap( const OUString& rModuleName ) throw (css::uno::RuntimeException); + +protected: + css::uno::Reference< css::frame::XModel > mxModel; + SfxObjectShell* mpShell; + +private: + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap; + typedef boost::unordered_map< OUString, ModulePathMap, OUStringHash > EventHandlerPathMap; + + EventHandlerInfoMap maEventInfos; + EventHandlerPathMap maEventPaths; + css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos; + OUString maLibraryName; + bool mbDisposed; +}; + +// ============================================================================ + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbafontbase.hxx b/include/vbahelper/vbafontbase.hxx new file mode 100644 index 000000000000..ddfb30899f82 --- /dev/null +++ b/include/vbahelper/vbafontbase.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBAHELPER_FONTBASE_HXX +#define VBAHELPER_FONTBASE_HXX + +#include + +#include +#include +#include + +// use local constants there is no need to expose these constants +// externally. Looking at the Format->Character dialog it seem that +// these may infact be even be calculated. Leave hardcoded for now +// #FIXEME #TBD investigate the code for dialog mentioned above + +// The font baseline is not specified. +const short NORMAL = 0; + +// specifies a superscripted. +const short SUPERSCRIPT = 33; + +// specifies a subscripted. +const short SUBSCRIPT = -33; + +// specifies a hight of superscripted font + const sal_Int8 SUPERSCRIPTHEIGHT = 58; + +// specifies a hight of subscripted font +const sal_Int8 SUBSCRIPTHEIGHT = 58; + +// specifies a hight of normal font +const short NORMALHEIGHT = 100; + +typedef InheritedHelperInterfaceImpl1< ov::XFontBase > VbaFontBase_BASE; + +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, + const css::uno::Reference< css::beans::XPropertySet >& xPropertySet, + bool bFormControl = false ) throw ( css::uno::RuntimeException ); + virtual ~VbaFontBase();// {} + + // Attributes + virtual css::uno::Any SAL_CALL getSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSize( const css::uno::Any& _size ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getColorIndex() throw (css::uno::RuntimeException); + virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getBold() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBold( const css::uno::Any& _bold ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getUnderline() throw (css::uno::RuntimeException) = 0; + virtual void SAL_CALL setUnderline( const css::uno::Any& _underline ) throw (css::uno::RuntimeException) = 0; + virtual css::uno::Any SAL_CALL getStrikethrough() throw (css::uno::RuntimeException); + virtual void SAL_CALL setStrikethrough( const css::uno::Any& _strikethrough ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getShadow() throw (css::uno::RuntimeException); + virtual void SAL_CALL setShadow( const css::uno::Any& _shadow ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getItalic() throw (css::uno::RuntimeException); + virtual void SAL_CALL setItalic( const css::uno::Any& _italic ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getSubscript() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSubscript( const css::uno::Any& _subscript ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getSuperscript() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSuperscript( const css::uno::Any& _superscript ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const css::uno::Any& _name ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getColor() throw (css::uno::RuntimeException) ; + virtual void SAL_CALL setColor( const css::uno::Any& _color ) throw (css::uno::RuntimeException) ; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbaglobalbase.hxx b/include/vbahelper/vbaglobalbase.hxx new file mode 100644 index 000000000000..4c30a26c95c0 --- /dev/null +++ b/include/vbahelper/vbaglobalbase.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_GLOBAL_BASE_HXX +#define VBA_GLOBAL_BASE_HXX + +#include "vbahelperinterface.hxx" +#include + +typedef InheritedHelperInterfaceImpl1< ov::XGlobalsBase > Globals_BASE; +class VBAHELPER_DLLPUBLIC VbaGlobalsBase : public Globals_BASE +{ +protected: + OUString msDocCtxName; + OUString msApplication; + + bool hasServiceName( const OUString& serviceName ); + void init( const css::uno::Sequence< css::beans::PropertyValue >& aInitArgs ); + +public: + VbaGlobalsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const OUString& sDocCtxName ); + virtual ~VbaGlobalsBase(); + // XMultiServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException); + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) throw (css::uno::RuntimeException); +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbahelper.hxx b/include/vbahelper/vbahelper.hxx new file mode 100644 index 000000000000..be5d73906c53 --- /dev/null +++ b/include/vbahelper/vbahelper.hxx @@ -0,0 +1,256 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef OOVBAAPI_VBA_HELPER_HXX +#define OOVBAAPI_VBA_HELPER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vbaaccesshelper.hxx" + +namespace ooo +{ + namespace vba + { + template < class T > + css::uno::Reference< T > getXSomethingFromArgs( css::uno::Sequence< css::uno::Any > const & args, sal_Int32 nPos, bool bCanBeNull = true ) throw (css::lang::IllegalArgumentException) + { + if ( args.getLength() < ( nPos + 1) ) + throw css::lang::IllegalArgumentException(); + css::uno::Reference< T > aSomething( args[ nPos ], css::uno::UNO_QUERY ); + if ( !bCanBeNull && !aSomething.is() ) + throw css::lang::IllegalArgumentException(); + return aSomething; + } + + class XHelperInterface; + + /** Returns the VBA document implementation object representing the passed UNO document model. */ + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getVBADocument( const css::uno::Reference< css::frame::XModel >& xModel ); + VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); + VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException); + + css::uno::Reference< css::frame::XModel > getCurrentDoc( const OUString& sKey ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getThisWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); + VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); + + 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( const css::uno::Reference< css::frame::XModel>& xModel, const OUString& aUrl ); + VBAHELPER_DLLPUBLIC void dispatchRequests (const css::uno::Reference< css::frame::XModel>& xModel, const OUString & aUrl, const css::uno::Sequence< css::beans::PropertyValue >& sProps ); + VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, sal_uInt16 nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON ); + VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 ); + VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 ); + VBAHELPER_DLLPUBLIC css::uno::Any OORGBToXLRGB( const css::uno::Any& ); + VBAHELPER_DLLPUBLIC css::uno::Any XLRGBToOORGB( const css::uno::Any& ); + // provide a NULL object that can be passed as variant so that + // the object when passed to IsNull will return true. aNULL + // contains an empty object reference + VBAHELPER_DLLPUBLIC const css::uno::Any& aNULL(); + VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection ); + VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges, SfxViewShell* ); + VBAHELPER_DLLPUBLIC void WaitUntilPreviewIsClosed( SfxViewFrame* ); + + /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException); + + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Throws, if the Any is empty or contains an incompatible type. */ + VBAHELPER_DLLPUBLIC OUString extractStringFromAny( const css::uno::Any& rAny, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); + /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string. + Returns rDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */ + VBAHELPER_DLLPUBLIC OUString extractStringFromAny( const css::uno::Any& rAny, const OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException); + + VBAHELPER_DLLPUBLIC OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException ); + VBAHELPER_DLLPUBLIC OUString VBAToRegexp(const OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic ) + VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical); + VBAHELPER_DLLPUBLIC double PixelsToPoints( const 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 ); + VBAHELPER_DLLPUBLIC css::uno::Any getPropertyValue( const css::uno::Sequence< css::beans::PropertyValue >& aProp, const OUString& aName ); + VBAHELPER_DLLPUBLIC sal_Bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const OUString& aName, const css::uno::Any& aValue ); + VBAHELPER_DLLPUBLIC void setOrAppendPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const OUString& aName, const css::uno::Any& aValue ); + +class VBAHELPER_DLLPUBLIC Millimeter +{ +//Factor to translate between points and hundredths of millimeters: +private: + double m_nMillimeter; + +public: + Millimeter(); + + Millimeter(double mm); + + void setInPoints(double points) ; + double getInHundredthsOfOneMillimeter(); + static sal_Int32 getInHundredthsOfOneMillimeter(double points); + static double getInPoints(int _hmm); +}; + +class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace the ShapeHelper below +{ +public: + virtual ~AbstractGeometryAttributes() {} + virtual double getLeft() const = 0; + virtual void setLeft( double ) = 0; + virtual double getTop() const = 0; + virtual void setTop( double ) = 0; + virtual double getHeight() const = 0; + virtual void setHeight( double ) = 0; + virtual double getWidth() const = 0; + virtual void setWidth( double ) = 0; + + virtual double getInnerHeight() const { return 0.0; } + virtual void setInnerHeight( double ) {} + virtual double getInnerWidth() const { return 0.0; } + virtual void setInnerWidth( double ) {} + virtual double getOffsetX() const { return 0.0; } + virtual double getOffsetY() const { return 0.0; } +}; + +namespace msforms { + class XShape; +} + +class VBAHELPER_DLLPUBLIC ShapeHelper +{ +protected: + css::uno::Reference< css::drawing::XShape > xShape; +public: + ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ); + + double getHeight() const; + void setHeight(double _fheight) throw ( css::script::BasicErrorException ); + double getWidth() const; + void setWidth(double _fWidth) throw ( css::script::BasicErrorException ); + double getLeft() const; + void setLeft(double _fLeft); + double getTop() const; + void setTop(double _fTop); +}; + +class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeometryAttributes +{ + std::auto_ptr< ShapeHelper > m_pShapeHelper; +public: + ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape ); + virtual double getLeft() const; + virtual void setLeft( double nLeft ); + virtual double getTop() const; + virtual void setTop( double nTop ); + virtual double getHeight() const; + virtual void setHeight( double nHeight ); + virtual double getWidth() const; + virtual void setWidth( double nWidth); + virtual ~ConcreteXShapeGeometryAttributes(); +}; + +#define VBA_LEFT "PositionX" +#define VBA_TOP "PositionY" +class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes +{ +public: + UserFormGeometryHelper( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::awt::XControl >& xControl, + double fOffsetX, double fOffsetY ); + virtual double getLeft() const; + virtual void setLeft( double fLeft ); + virtual double getTop() const; + virtual void setTop( double fTop ); + virtual double getWidth() const; + virtual void setWidth( double fWidth ); + virtual double getHeight() const; + virtual void setHeight( double fHeight ); + virtual double getInnerWidth() const; + virtual void setInnerWidth( double fWidth ); + virtual double getInnerHeight() const; + virtual void setInnerHeight( double fHeight ); + virtual double getOffsetX() const; + virtual double getOffsetY() const; + +private: + double implGetPos( bool bPosY ) const; + void implSetPos( double fPos, bool bPosY ); + double implGetSize( bool bHeight, bool bOuter ) const; + void implSetSize( double fSize, bool bHeight, bool bOuter ); + +private: + css::uno::Reference< css::awt::XWindow > mxWindow; + css::uno::Reference< css::beans::XPropertySet > mxModelProps; + css::uno::Reference< css::awt::XUnitConversion > mxUnitConv; + double mfOffsetX; + double mfOffsetY; + sal_Bool mbDialog; +}; + +class VBAHELPER_DLLPUBLIC ContainerUtilities +{ + +public: + static OUString getUniqueName( const css::uno::Sequence< OUString >& _slist, const OUString& _sElementName, const OUString& _sSuffixSeparator); + static OUString getUniqueName( const css::uno::Sequence< OUString >& _slist, const OUString _sElementName, const OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix ); + + static sal_Int32 FieldInList( const css::uno::Sequence< OUString >& SearchList, const OUString& SearchString ); +}; + +// really just a a place holder to ease the porting pain +class VBAHELPER_DLLPUBLIC DebugHelper +{ +public: + static void exception( const OUString& DetailedMessage, const css::uno::Exception& ex, int err, const OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException ); + + static void exception( int err, const OUString& additionalArgument ) throw( css::script::BasicErrorException ); + + static void exception( const css::uno::Exception& ex ) throw( css::script::BasicErrorException ); +}; + + } // vba +} // ooo + +namespace ov = ooo::vba; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbahelperinterface.hxx b/include/vbahelper/vbahelperinterface.hxx new file mode 100644 index 000000000000..a37bb59dc129 --- /dev/null +++ b/include/vbahelper/vbahelperinterface.hxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef OOVBAAPI_VBA_HELPERINTERFACE_HXX +#define OOVBAAPI_VBA_HELPERINTERFACE_HXX + +#include +#include +#include +#include +#include +#include + +// use this class when you have an a object like +// interface XAnInterface which contains XHelperInterface in its inheritance hierarchy +// interface XAnInterface +// { +// interface XHelperInterface; +// [attribute, string] name; +// } +// or +// interface XAnInterface : XHelperInterface; +// { +// [attribute, string] name; +// } +// +// then this class can provide a default implementation of XHelperInterface, +// you can use it like this +// typedef InheritedHelperInterfaceImpl< XAnInterface > > AnInterfaceImpl_BASE; +// class AnInterfaceImpl : public AnInterfaceImpl_BASE +// { +// public: +// AnInterface( const Reference< HelperInterface >& xParent ) : AnInterfaceImpl_BASE( xParent ) {} +// // implement XAnInterface methods only, no need to implement the XHelperInterface +// // methods +// virtual void setName( const OUString& ); +// virtual OUString getName(); +// } +// + +template< typename Ifc1 > +class SAL_DLLPUBLIC_TEMPLATE InheritedHelperInterfaceImpl : public Ifc1 +{ +protected: + css::uno::WeakReference< ov::XHelperInterface > mxParent; + css::uno::Reference< css::uno::XComponentContext > mxContext; +public: + InheritedHelperInterfaceImpl() {} + InheritedHelperInterfaceImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxContext( xContext ) {} + InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {} + virtual OUString getServiceImplName() = 0; + virtual css::uno::Sequence getServiceNames() = 0; + + // XHelperInterface Methods + virtual ::sal_Int32 SAL_CALL getCreator() throw (css::script::BasicErrorException, css::uno::RuntimeException) + { + return 0x53756E4F; + } + virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return mxParent; } + + virtual css::uno::Any SAL_CALL Application( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { + // The application could certainly be passed around in the context - seems + // to make sense + css::uno::Reference< css::container::XNameAccess > xNameAccess( mxContext, css::uno::UNO_QUERY_THROW ); + return xNameAccess->getByName( "Application" ); + } + + // XServiceInfo Methods + virtual OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException) { return getServiceImplName(); } + virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (css::uno::RuntimeException) + { + css::uno::Sequence< OUString > sServices = getSupportedServiceNames(); + const OUString* pStart = sServices.getConstArray(); + const OUString* pEnd = pStart + sServices.getLength(); + for ( ; pStart != pEnd ; ++pStart ) + if ( (*pStart).equals( ServiceName ) ) + return sal_True; + return sal_False; + } + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (css::uno::RuntimeException) + { + css::uno::Sequence< OUString > aNames = getServiceNames(); + return aNames; + } + }; + +template< typename Ifc1 > +class SAL_DLLPUBLIC_TEMPLATE InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; +public: + InheritedHelperInterfaceImpl1< Ifc1 >() {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; + +template< typename Ifc1, typename Ifc2 > +class SAL_DLLPUBLIC_TEMPLATE InheritedHelperInterfaceImpl2 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > Base; +public: + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >() {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; + +template< typename Ifc1, typename Ifc2, typename Ifc3 > +class SAL_DLLPUBLIC_TEMPLATE InheritedHelperInterfaceImpl3 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > Base; +public: + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >() {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( 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 ) \ +OUString classname::getServiceImplName() \ +{ \ + return OUString( #classname ); \ +} + +// ---------------------------------------------------------------------------- + +/** Helper macro to implement the method 'getServiceNames()' for a single + service name. + */ +#define VBAHELPER_IMPL_GETSERVICENAMES( classname, servicename ) \ +css::uno::Sequence< OUString > classname::getServiceNames() \ +{ \ + static css::uno::Sequence< OUString > saServiceNames; \ + if( saServiceNames.getLength() == 0 ) \ + { \ + saServiceNames.realloc( 1 ); \ + saServiceNames[ 0 ] = 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 OUString getServiceImplName(); \ + virtual css::uno::Sequence< 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbapagesetupbase.hxx b/include/vbahelper/vbapagesetupbase.hxx new file mode 100644 index 000000000000..b063353af36a --- /dev/null +++ b/include/vbahelper/vbapagesetupbase.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_PAGESETUPBASE_HXX +#define VBA_PAGESETUPBASE_HXX + +#include +#include +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ooo::vba::XPageSetupBase > VbaPageSetupBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaPageSetupBase : public VbaPageSetupBase_BASE +{ +protected: + css::uno::Reference< css::frame::XModel > mxModel; + css::uno::Reference< css::beans::XPropertySet > mxPageProps; + sal_Int32 mnOrientLandscape; + sal_Int32 mnOrientPortrait; + + VbaPageSetupBase( const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); +public: + virtual ~VbaPageSetupBase(){} + + // Attribute + virtual double SAL_CALL getTopMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTopMargin( double margin ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getBottomMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setBottomMargin( double margin ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getRightMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRightMargin( double margin ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getLeftMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLeftMargin( double margin ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getHeaderMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setHeaderMargin( double margin ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getFooterMargin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setFooterMargin( double margin ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException); + virtual void SAL_CALL setOrientation( sal_Int32 orientation ) throw (css::uno::RuntimeException); +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbapropvalue.hxx b/include/vbahelper/vbapropvalue.hxx new file mode 100644 index 000000000000..816f93f8c445 --- /dev/null +++ b/include/vbahelper/vbapropvalue.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef SC_VBA_PROPVALULE_HXX +#define SC_VBA_PROPVALULE_HXX +#include +#include + +#include + +typedef ::cppu::WeakImplHelper1< ov::XPropValue > PropValueImpl_BASE; + +class VBAHELPER_DLLPUBLIC PropListener +{ +public: + virtual void setValueEvent( const css::uno::Any& value ) = 0; + virtual css::uno::Any getValueEvent() = 0; + +protected: + ~PropListener() {} +}; + + +class VBAHELPER_DLLPUBLIC ScVbaPropValue : public PropValueImpl_BASE +{ + PropListener* m_pListener; +public: + ScVbaPropValue( PropListener* pListener ); + + // Attributes + virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); + virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + + OUString SAL_CALL getDefaultPropertyName() throw (css::uno::RuntimeException) { return OUString("Value"); } + +}; +#endif //SC_VBA_PROPVALULE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbashape.hxx b/include/vbahelper/vbashape.hxx new file mode 100644 index 000000000000..58e4f2865545 --- /dev/null +++ b/include/vbahelper/vbashape.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef SC_VBA_SHAPE_HXX +#define SC_VBA_SHAPE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef ::cppu::WeakImplHelper2< ov::msforms::XShape, css::lang::XEventListener > ListeningShape; + +typedef InheritedHelperInterfaceImpl< ListeningShape > ScVbaShape_BASE; + +class VBAHELPER_DLLPUBLIC ScVbaShape : public ScVbaShape_BASE +{ +protected: + SAL_WNODEPRECATED_DECLARATIONS_PUSH + std::auto_ptr< ov::ShapeHelper > m_pShapeHelper; + SAL_WNODEPRECATED_DECLARATIONS_POP + css::uno::Reference< css::drawing::XShape > m_xShape; + css::uno::Reference< css::drawing::XShapes > m_xShapes; + css::uno::Reference< css::beans::XPropertySet > m_xPropertySet; + sal_Int32 m_nType; + css::uno::Reference< css::frame::XModel > m_xModel; + css::uno::Any m_aRange; + virtual void addListeners(); + virtual void removeShapeListener() throw( css::uno::RuntimeException ); + virtual void removeShapesListener() throw( css::uno::RuntimeException ); + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); +public: + ScVbaShape( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::drawing::XShapes >& xShapes, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nType ) throw ( css::lang::IllegalArgumentException ); + virtual ~ScVbaShape(); + css::uno::Any getRange() { return m_aRange; }; + void setRange( css::uno::Any aRange ) { m_aRange = aRange; }; + + static sal_Int32 getType( const css::uno::Reference< css::drawing::XShape > xShape ) throw (css::uno::RuntimeException); + + // Attributes + virtual OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const OUString& _name ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException); + virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getZOrderPosition() throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException); + virtual double SAL_CALL getRotation() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRotation( double _rotation ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XLineFormat > SAL_CALL getLine() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XFillFormat > SAL_CALL getFill() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XPictureFormat > SAL_CALL getPictureFormat() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getLockAspectRatio() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLockAspectRatio( ::sal_Bool _lockaspectratio ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getLockAnchor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLockAnchor( ::sal_Bool _lockanchor ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRelativeHorizontalPosition() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRelativeHorizontalPosition( ::sal_Int32 _relativehorizontalposition ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRelativeVerticalPosition() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRelativeVerticalPosition( ::sal_Int32 _relativeverticalposition ) throw (css::uno::RuntimeException); + + // Methods + virtual css::uno::Any SAL_CALL SAL_CALL TextFrame( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL SAL_CALL WrapFormat( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Delete() throw (css::uno::RuntimeException); + virtual void SAL_CALL ZOrder( sal_Int32 ZOrderCmd ) throw (css::uno::RuntimeException); + virtual void SAL_CALL IncrementRotation( double Increment ) throw (css::uno::RuntimeException); + virtual void SAL_CALL IncrementLeft( double Increment ) throw (css::uno::RuntimeException); + virtual void SAL_CALL IncrementTop( double Increment ) throw (css::uno::RuntimeException); + virtual void SAL_CALL ScaleHeight( double Factor, sal_Bool RelativeToOriginalSize, sal_Int32 Scale ) throw (css::uno::RuntimeException); + virtual void SAL_CALL ScaleWidth( double Factor, sal_Bool RelativeToOriginalSize, sal_Int32 Scale ) throw (css::uno::RuntimeException); + // Replace?? + virtual void SAL_CALL Select( const css::uno::Any& Replace ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL ShapeRange( const css::uno::Any& index ) throw ( css::uno::RuntimeException ); + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& rEventObject ) throw( css::uno::RuntimeException ); +}; +#endif//SC_VBA_SHAPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbashaperange.hxx b/include/vbahelper/vbashaperange.hxx new file mode 100644 index 000000000000..e1a447ee3dbf --- /dev/null +++ b/include/vbahelper/vbashaperange.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef SC_VBA_SHAPERANGE_HXX +#define SC_VBA_SHAPERANGE_HXX + +#include +#include +#include +#include +#include +#include + +typedef CollTestImplHelper< ov::msforms::XShapeRange > ScVbaShapeRange_BASE; + +class VBAHELPER_DLLPUBLIC ScVbaShapeRange : public ScVbaShapeRange_BASE +{ +private: + css::uno::Reference< css::drawing::XDrawPage > m_xDrawPage; + css::uno::Reference< css::drawing::XShapes > m_xShapes; +protected: + css::uno::Reference< css::frame::XModel > m_xModel; + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); + css::uno::Reference< css::drawing::XShapes > getShapes() throw (css::uno::RuntimeException) ; +public: + ScVbaShapeRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xShapes, const css::uno::Reference< css::drawing::XDrawPage>& xDrawShape, const css::uno::Reference< css::frame::XModel >& xModel ); + + // Methods + virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ::ooo::vba::msforms::XShape > SAL_CALL Group() throw (css::uno::RuntimeException); + virtual void SAL_CALL IncrementRotation( double Increment ) throw (css::uno::RuntimeException); + virtual void SAL_CALL IncrementLeft( double Increment ) throw (css::uno::RuntimeException) ; + virtual void SAL_CALL IncrementTop( double Increment ) throw (css::uno::RuntimeException); + virtual OUString SAL_CALL getName() throw (css::uno::RuntimeException); + virtual void SAL_CALL setName( const OUString& _name ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException); + virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XLineFormat > SAL_CALL getLine() throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XFillFormat > SAL_CALL getFill() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getLockAspectRatio() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLockAspectRatio( ::sal_Bool _lockaspectratio ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getLockAnchor() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLockAnchor( ::sal_Bool _lockanchor ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRelativeHorizontalPosition() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRelativeHorizontalPosition( ::sal_Int32 _relativehorizontalposition ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRelativeVerticalPosition() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRelativeVerticalPosition( ::sal_Int32 _relativeverticalposition ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL SAL_CALL TextFrame( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL SAL_CALL WrapFormat( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL ZOrder( sal_Int32 ZOrderCmd ) throw (css::uno::RuntimeException); + //XEnumerationAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); + // ScVbaCollectionBaseImpl + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); +}; + +#endif//SC_VBA_SHAPERANGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbashapes.hxx b/include/vbahelper/vbashapes.hxx new file mode 100644 index 000000000000..4c4b7c3e5a49 --- /dev/null +++ b/include/vbahelper/vbashapes.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef SC_VBA_SHAPES_HXX +#define SC_VBA_SHAPES_HXX + +#include +#include +#include +#include + +#include + +#include + +typedef CollTestImplHelper< ov::msforms::XShapes > ScVbaShapes_BASE; + +class VBAHELPER_DLLPUBLIC ScVbaShapes : public ScVbaShapes_BASE +{ +private: + css::uno::Reference< css::drawing::XShapes > m_xShapes; + css::uno::Reference< css::drawing::XDrawPage > m_xDrawPage; + sal_Int32 m_nNewShapeCount; + void initBaseCollection(); +protected: + css::uno::Reference< css::frame::XModel > m_xModel; + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); + virtual css::uno::Reference< css::container::XIndexAccess > getShapesByArrayIndices( const css::uno::Any& Index ) throw (css::uno::RuntimeException); + css::uno::Reference< css::drawing::XShape > createShape( OUString service ) throw (css::uno::RuntimeException); + css::uno::Any AddRectangle( sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWidth, sal_Int32 nLineHeight, css::uno::Any aRange ) throw (css::uno::RuntimeException); + css::uno::Any AddEllipse( sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWidth, sal_Int32 nLineHeight, css::uno::Any aRange ) throw (css::uno::RuntimeException); + css::uno::Any AddTextboxInWriter( sal_Int32 _nOrientation, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (css::uno::RuntimeException); + OUString createName( OUString sName ); + //TODO helperapi using a writer document + //css::awt::Point calculateTopLeftMargin( css::uno::Reference< ov::XHelperInterface > xDocument ); + +public: + ScVbaShapes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess > xShapes, const css::uno::Reference< css::frame::XModel >& xModel ); + static void setDefaultShapeProperties( css::uno::Reference< css::drawing::XShape > xShape ) throw (css::uno::RuntimeException); + static void setShape_NameProperty( css::uno::Reference< css::drawing::XShape > xShape, OUString sName ); + //XEnumerationAccess + virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); + + virtual void SAL_CALL SelectAll() throw (css::uno::RuntimeException); + //helper::calc + virtual css::uno::Any SAL_CALL AddLine( sal_Int32 StartX, sal_Int32 StartY, sal_Int32 endX, sal_Int32 endY ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL AddShape( sal_Int32 _nType, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL AddTextbox( sal_Int32 _nOrientation, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (css::uno::RuntimeException); + virtual css::uno::Reference< ov::msforms::XShapeRange > SAL_CALL Range( const css::uno::Any& shapes ) throw (css::uno::RuntimeException); + // ScVbaCollectionBaseImpl + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2 ) throw (css::uno::RuntimeException); +}; + +#endif//SC_VBA_SHAPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbatextframe.hxx b/include/vbahelper/vbatextframe.hxx new file mode 100644 index 000000000000..d8f44e32c826 --- /dev/null +++ b/include/vbahelper/vbatextframe.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef VBA_TEXTFRAME_HXX +#define VBA_TEXTFRAME_HXX +#include +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ov::msforms::XTextFrame > VbaTextFrame_BASE; + +class VBAHELPER_DLLPUBLIC VbaTextFrame : public VbaTextFrame_BASE +{ +protected: + css::uno::Reference< css::drawing::XShape > m_xShape; + css::uno::Reference< css::beans::XPropertySet > m_xPropertySet; +protected: + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); + virtual void setAsMSObehavior(); + sal_Int32 getMargin( OUString sMarginType ); + void setMargin( OUString sMarginType, float fMargin ); +public: + VbaTextFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext , css::uno::Reference< css::drawing::XShape > xShape); + virtual ~VbaTextFrame() {} + // Attributes + virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoSize( sal_Bool _autosize ) throw (css::uno::RuntimeException); + virtual float SAL_CALL getMarginBottom() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMarginBottom( float _marginbottom ) throw (css::uno::RuntimeException); + virtual float SAL_CALL getMarginTop() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMarginTop( float _margintop ) throw (css::uno::RuntimeException); + virtual float SAL_CALL getMarginLeft() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMarginLeft( float _marginleft ) throw (css::uno::RuntimeException); + virtual float SAL_CALL getMarginRight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMarginRight( float _marginright ) throw (css::uno::RuntimeException); + + // Methods + virtual css::uno::Any SAL_CALL Characters( ) throw (css::uno::RuntimeException); + +}; + +#endif//SC_VBA_TEXTFRAME_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vbahelper/vbawindowbase.hxx b/include/vbahelper/vbawindowbase.hxx new file mode 100644 index 000000000000..33ef793eecd8 --- /dev/null +++ b/include/vbahelper/vbawindowbase.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef VBA_WINDOWBASE_HXX +#define VBA_WINDOWBASE_HXX + +#include +#include +#include +#include + +typedef InheritedHelperInterfaceImpl1< ov::XWindowBase > WindowBaseImpl_BASE; + +class VBAHELPER_DLLPUBLIC VbaWindowBase : public WindowBaseImpl_BASE +{ +public: + VbaWindowBase( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XModel >& xModel, + const css::uno::Reference< css::frame::XController >& xController ) + throw (css::uno::RuntimeException); + VbaWindowBase( + css::uno::Sequence< css::uno::Any > const& aArgs, + css::uno::Reference< css::uno::XComponentContext > const& xContext ) + throw (css::uno::RuntimeException); + + // XWindowBase + virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ; + virtual void SAL_CALL setHeight( sal_Int32 _height ) throw (css::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL getLeft() throw (css::uno::RuntimeException) ; + virtual void SAL_CALL setLeft( sal_Int32 _left ) throw (css::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL getTop() throw (css::uno::RuntimeException) ; + virtual void SAL_CALL setTop( sal_Int32 _top ) throw (css::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException) ; + virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException) ; + + // XHelperInterface + virtual OUString getServiceImplName(); + virtual css::uno::Sequence getServiceNames(); + +protected: + css::uno::Reference< css::frame::XController > getController() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow > getWindow() throw (css::uno::RuntimeException); + css::uno::Reference< css::awt::XWindow2 > getWindow2() throw (css::uno::RuntimeException); + + css::uno::Reference< css::frame::XModel > m_xModel; + +private: + void construct( const css::uno::Reference< css::frame::XController >& xController ) throw (css::uno::RuntimeException); + + css::uno::WeakReference< css::frame::XController > m_xController; + css::uno::WeakReference< css::awt::XWindow > m_xWindow; +}; + +#endif //VBA_WINDOWBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit