summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rentz [dr] <daniel.rentz@oracle.com>2011-03-25 10:40:25 +0100
committerDaniel Rentz [dr] <daniel.rentz@oracle.com>2011-03-25 10:40:25 +0100
commitb46dab973c91c3a94bcda188a9888fef3fd16426 (patch)
treeecf2283bed35cbd42e3fb5fb541194d70179e51d
parent61879c218dd0e6e94884e7c6e06e3c5c18540b4a (diff)
calcvba: #164410# improve VBA compatibility implementation in various areas: Excel symbols, MSForms symbols, document and forms event handling
-rw-r--r--basic/inc/basic/sbxdef.hxx3
-rwxr-xr-xbasic/inc/basic/vbahelper.hxx49
-rwxr-xr-xbasic/source/basmgr/vbahelper.cxx158
-rw-r--r--basic/source/classes/sb.cxx38
-rwxr-xr-xbasic/source/classes/sbunoobj.cxx39
-rw-r--r--basic/source/classes/sbxmod.cxx116
-rw-r--r--basic/source/comp/codegen.cxx2
-rw-r--r--basic/source/comp/dim.cxx7
-rwxr-xr-xbasic/source/comp/sbcomp.cxx446
-rw-r--r--basic/source/comp/symtbl.cxx1
-rw-r--r--basic/source/comp/token.cxx6
-rw-r--r--basic/source/inc/codegen.hxx3
-rw-r--r--basic/source/inc/namecont.hxx220
-rw-r--r--basic/source/inc/runtime.hxx2
-rwxr-xr-xbasic/source/inc/sbtrace.hxx15
-rw-r--r--basic/source/inc/scriptcont.hxx17
-rw-r--r--basic/source/inc/symtbl.hxx3
-rw-r--r--basic/source/runtime/methods.cxx47
-rw-r--r--[-rwxr-xr-x]basic/source/runtime/methods1.cxx7
-rw-r--r--basic/source/runtime/rtlproto.hxx1
-rw-r--r--basic/source/runtime/runtime.cxx25
-rw-r--r--basic/source/runtime/stdobj.cxx2
-rw-r--r--basic/source/runtime/step0.cxx2
-rw-r--r--basic/source/runtime/step1.cxx3
-rwxr-xr-xbasic/source/runtime/step2.cxx6
-rw-r--r--basic/source/uno/namecont.cxx229
-rw-r--r--basic/util/makefile.mk3
-rw-r--r--framework/source/uielement/menubarmanager.cxx64
-rw-r--r--oovbaapi/ooo/vba/XApplicationBase.idl1
-rwxr-xr-xoovbaapi/ooo/vba/XCollectionBase.idl56
-rw-r--r--oovbaapi/ooo/vba/XControlProvider.idl2
-rwxr-xr-xoovbaapi/ooo/vba/XExecutableDialog.idl58
-rw-r--r--oovbaapi/ooo/vba/excel/SheetObjects.idl26
-rw-r--r--oovbaapi/ooo/vba/excel/XApplication.idl17
-rw-r--r--oovbaapi/ooo/vba/makefile.mk2
-rwxr-xr-x[-rw-r--r--]oovbaapi/ooo/vba/msforms/XCheckBox.idl (renamed from oovbaapi/ooo/vba/msforms/XButton.idl)15
-rw-r--r--oovbaapi/ooo/vba/msforms/XComboBox.idl20
-rw-r--r--oovbaapi/ooo/vba/msforms/XCommandButton.idl56
-rw-r--r--oovbaapi/ooo/vba/msforms/XControl.idl1
-rwxr-xr-xoovbaapi/ooo/vba/msforms/XFrame.idl55
-rw-r--r--oovbaapi/ooo/vba/msforms/XGroupBox.idl9
-rw-r--r--oovbaapi/ooo/vba/msforms/XLabel.idl10
-rw-r--r--oovbaapi/ooo/vba/msforms/XListBox.idl14
-rwxr-xr-xoovbaapi/ooo/vba/msforms/XNewFont.idl57
-rw-r--r--oovbaapi/ooo/vba/msforms/XRadioButton.idl10
-rw-r--r--oovbaapi/ooo/vba/msforms/XTextBox.idl12
-rw-r--r--oovbaapi/ooo/vba/msforms/XToggleButton.idl13
-rw-r--r--oovbaapi/ooo/vba/msforms/XUserForm.idl2
-rw-r--r--oovbaapi/ooo/vba/msforms/makefile.mk5
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx25
-rw-r--r--sfx2/source/doc/objxtor.cxx87
-rwxr-xr-xvbahelper/Library_msforms.mk13
-rwxr-xr-xvbahelper/Library_vbahelper.mk14
-rwxr-xr-xvbahelper/Package_inc.mk2
-rwxr-xr-xvbahelper/inc/vbahelper/collectionbase.hxx214
-rw-r--r--vbahelper/inc/vbahelper/vbaapplicationbase.hxx1
-rw-r--r--vbahelper/inc/vbahelper/vbacollectionimpl.hxx4
-rw-r--r--vbahelper/inc/vbahelper/vbadocumentbase.hxx1
-rwxr-xr-xvbahelper/inc/vbahelper/vbaeventshelperbase.hxx68
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx121
-rw-r--r--vbahelper/inc/vbahelper/vbawindowbase.hxx37
-rwxr-xr-xvbahelper/inc/vbahelper/weakreference.hxx94
-rw-r--r--vbahelper/prj/build.lst2
-rw-r--r--vbahelper/source/msforms/vbabutton.cxx53
-rw-r--r--vbahelper/source/msforms/vbabutton.hxx15
-rw-r--r--vbahelper/source/msforms/vbacheckbox.cxx9
-rw-r--r--vbahelper/source/msforms/vbacheckbox.hxx5
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx95
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx13
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx117
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx24
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx188
-rw-r--r--vbahelper/source/msforms/vbacontrols.hxx27
-rw-r--r--vbahelper/source/msforms/vbaframe.cxx77
-rw-r--r--vbahelper/source/msforms/vbaframe.hxx27
-rw-r--r--vbahelper/source/msforms/vbalabel.cxx7
-rw-r--r--vbahelper/source/msforms/vbalabel.hxx1
-rw-r--r--vbahelper/source/msforms/vbalistbox.cxx9
-rw-r--r--vbahelper/source/msforms/vbalistbox.hxx3
-rw-r--r--vbahelper/source/msforms/vbamultipage.cxx11
-rw-r--r--vbahelper/source/msforms/vbamultipage.hxx9
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.cxx160
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.hxx73
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.cxx8
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.hxx1
-rw-r--r--vbahelper/source/msforms/vbatextbox.cxx34
-rw-r--r--vbahelper/source/msforms/vbatextbox.hxx5
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.cxx53
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.hxx12
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx36
-rw-r--r--vbahelper/source/msforms/vbauserform.hxx14
-rwxr-xr-xvbahelper/source/vbahelper/collectionbase.cxx333
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx25
-rw-r--r--vbahelper/source/vbahelper/vbacommandbar.cxx9
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.cxx72
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.hxx11
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.cxx27
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.hxx19
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarhelper.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx17
-rwxr-xr-xvbahelper/source/vbahelper/vbaeventshelperbase.cxx247
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx411
-rw-r--r--vbahelper/source/vbahelper/vbawindowbase.cxx140
103 files changed, 3869 insertions, 1167 deletions
diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx
index 6dc9fe1d8d66..cc669fd03649 100644
--- a/basic/inc/basic/sbxdef.hxx
+++ b/basic/inc/basic/sbxdef.hxx
@@ -108,6 +108,7 @@ enum SbxDataType {
const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000;
const sal_uInt32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000;
const sal_uInt32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible
+const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000;
#endif
@@ -320,6 +321,8 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion
#define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN
#define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one
// is used for objects, the other for variables only
+#define SBX_VAR_TO_DIM 0x2000 // Same value as SBX_NO_BROADCAST, cannot conflict as
+ // used for variables without broadcaster only
// Broadcaster-IDs:
#define SBX_HINT_DYING SFX_HINT_DYING
diff --git a/basic/inc/basic/vbahelper.hxx b/basic/inc/basic/vbahelper.hxx
index 0d99387965fe..f83548f7e02c 100755
--- a/basic/inc/basic/vbahelper.hxx
+++ b/basic/inc/basic/vbahelper.hxx
@@ -28,7 +28,9 @@
#ifndef BASIC_VBAHELPR_HXX
#define BASIC_VBAHELPR_HXX
+#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <rtl/ustring.hxx>
namespace basic {
namespace vba {
@@ -39,6 +41,21 @@ namespace vba {
// ============================================================================
+/** Creates and returns an enumeration of all open documents of the same type
+ as the specified document.
+
+ First, the global module manager (com.sun.star.frame.ModuleManager) is
+ asked for the type of the passed model, and all open documents with the
+ same type will be stored in an enumeration object.
+
+ @param rxModel
+ A document model determining the type of the documents.
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > createDocumentsEnumeration(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel );
+
+// ============================================================================
+
/** Locks or unlocks the controllers of all documents that have the same type
as the specified document.
@@ -80,6 +97,38 @@ void enableContainerWindowsOfAllDocuments(
// ============================================================================
+/** Registers the passed path as working directory for the application the
+ passed document belongs to.
+
+ @param rxModel
+ A document model determining the type of the application whose working
+ directory has been changed.
+
+ @param rPath
+ The new working directory.
+ */
+void registerCurrentDirectory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
+ const ::rtl::OUString& rPath );
+
+// ============================================================================
+
+/** Returns the working directory of the application the passed document
+ belongs to.
+
+ @param rxModel
+ A document model determining the type of the application whose working
+ directory is querried.
+
+ @return
+ The working directory of the specified application, or an empty string
+ on error (e.g. if the passed document reference is empty).
+ */
+::rtl::OUString getCurrentDirectory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel );
+
+// ============================================================================
+
} // namespace vba
} // namespace basic
diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index a09446f2e40b..0e9338b52c5e 100755
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -28,13 +28,18 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_basic.hxx"
-#include "basic/vbahelper.hxx"
+#include <basic/vbahelper.hxx>
+
+#include <map>
+#include <vector>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/instance.hxx>
namespace basic {
namespace vba {
@@ -45,64 +50,71 @@ using namespace ::com::sun::star;
namespace {
-/** Creates the global module manager needed to identify the type of documents.
+/** Create an instance of a module manager.
*/
uno::Reference< frame::XModuleManager > lclCreateModuleManager()
{
uno::Reference< frame::XModuleManager > xModuleManager;
try
{
- uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW );
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
xModuleManager.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), uno::UNO_QUERY );
}
catch( uno::Exception& )
{
}
- OSL_ENSURE( xModuleManager.is(), "::basic::vba::lclCreateModuleManager - cannot create module manager" );
return xModuleManager;
}
// ----------------------------------------------------------------------------
-/** Returns the document service name of the specified document.
+/** Implementation of an enumeration of all open documents of the same type.
*/
-::rtl::OUString lclIdentifyDocument( const uno::Reference< frame::XModuleManager >& rxModuleManager, const uno::Reference< frame::XModel >& rxModel )
+class DocumentsEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration >
{
- ::rtl::OUString aServiceName;
- if( rxModuleManager.is() )
- {
- try
- {
- aServiceName = rxModuleManager->identify( rxModel );
- }
- catch( uno::Exception& )
- {
- }
- OSL_ENSURE( aServiceName.getLength() > 0, "::basic::vba::lclIdentifyDocument - cannot identify document" );
- }
- return aServiceName;
-}
-
-// ----------------------------------------------------------------------------
+public:
+ DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel );
+ virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+private:
+ typedef ::std::vector< uno::Reference< frame::XModel > > ModelVector;
+ ModelVector maModels;
+ ModelVector::iterator maModelIt;
+};
-/** Returns an enumeration of all open documents.
- */
-uno::Reference< container::XEnumeration > lclCreateDocumentEnumeration()
+DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel )
{
- uno::Reference< container::XEnumeration > xEnumeration;
try
{
- uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW );
+ ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel );
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
uno::Reference< frame::XDesktop > xDesktop( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), uno::UNO_QUERY_THROW );
uno::Reference< container::XEnumerationAccess > xComponentsEA( xDesktop->getComponents(), uno::UNO_SET_THROW );
- xEnumeration = xComponentsEA->createEnumeration();
-
+ uno::Reference< container::XEnumeration > xEnumeration( xComponentsEA->createEnumeration(), uno::UNO_SET_THROW );
+ while( xEnumeration->hasMoreElements() )
+ {
+ uno::Reference< frame::XModel > xCurrModel( xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ if( xModuleManager->identify( xCurrModel ) == aIdentifier )
+ maModels.push_back( xCurrModel );
+ }
}
catch( uno::Exception& )
{
}
- OSL_ENSURE( xEnumeration.is(), "::basic::vba::lclCreateDocumentEnumeration - cannot create enumeration of all documents" );
- return xEnumeration;
+ maModelIt = maModels.begin();
+}
+
+sal_Bool SAL_CALL DocumentsEnumeration::hasMoreElements() throw (uno::RuntimeException)
+{
+ return maModelIt != maModels.end();
+}
+
+uno::Any SAL_CALL DocumentsEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( maModelIt == maModels.end() )
+ throw container::NoSuchElementException();
+ return uno::Any( *maModelIt++ );
}
// ----------------------------------------------------------------------------
@@ -163,37 +175,39 @@ typedef void (*ModifyDocumentFunc)( const uno::Reference< frame::XModel >&, sal_
*/
void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Reference< frame::XModel >& rxModel, sal_Bool bModificator )
{
- uno::Reference< frame::XModuleManager > xModuleManager = lclCreateModuleManager();
- uno::Reference< container::XEnumeration > xDocumentsEnum = lclCreateDocumentEnumeration();
- ::rtl::OUString aIdentifier = lclIdentifyDocument( xModuleManager, rxModel );
- if( xModuleManager.is() && xDocumentsEnum.is() && (aIdentifier.getLength() > 0) )
+ uno::Reference< container::XEnumeration > xDocumentsEnum( new DocumentsEnumeration( rxModel ) );
+ // iterate over all open documents
+ while( xDocumentsEnum->hasMoreElements() ) try
{
- // iterate over all open documents
- while( xDocumentsEnum->hasMoreElements() )
- {
- try
- {
- uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW );
- ::rtl::OUString aCurrIdentifier = lclIdentifyDocument( xModuleManager, xCurrModel );
- if( aCurrIdentifier == aIdentifier )
- pModifyDocumentFunc( xCurrModel, bModificator );
- }
- catch( uno::Exception& )
- {
- }
- }
+ uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW );
+ pModifyDocumentFunc( xCurrModel, bModificator );
}
- else
+ catch( uno::Exception& )
{
- // no module manager, no documents enumeration, no identifier -> at least process the passed document
- pModifyDocumentFunc( rxModel, bModificator );
}
}
+// ----------------------------------------------------------------------------
+
+struct CurrDirPool
+{
+ ::osl::Mutex maMutex;
+ ::std::map< ::rtl::OUString, ::rtl::OUString > maCurrDirs;
+};
+
+struct StaticCurrDirPool : public ::rtl::Static< CurrDirPool, StaticCurrDirPool > {};
+
} // namespace
// ============================================================================
+uno::Reference< container::XEnumeration > createDocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel )
+{
+ return new DocumentsEnumeration( rxModel );
+}
+
+// ============================================================================
+
void lockControllersOfAllDocuments( const uno::Reference< frame::XModel >& rxModel, sal_Bool bLockControllers )
{
lclIterateDocuments( &lclLockControllers, rxModel, bLockControllers );
@@ -208,5 +222,45 @@ void enableContainerWindowsOfAllDocuments( const uno::Reference< frame::XModel >
// ============================================================================
+void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, const ::rtl::OUString& rPath )
+{
+ if( rPath.getLength() > 0 )
+ {
+ CurrDirPool& rPool = StaticCurrDirPool::get();
+ ::osl::MutexGuard aGuard( rPool.maMutex );
+ try
+ {
+ uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW );
+ ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel );
+ if( aIdentifier.getLength() > 0 )
+ rPool.maCurrDirs[ aIdentifier ] = rPath;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+// ============================================================================
+
+::rtl::OUString getCurrentDirectory( const uno::Reference< frame::XModel >& rxModel )
+{
+ ::rtl::OUString aPath;
+ CurrDirPool& rPool = StaticCurrDirPool::get();
+ ::osl::MutexGuard aGuard( rPool.maMutex );
+ try
+ {
+ uno::Reference< frame::XModuleManager > xModuleManager( lclCreateModuleManager(), uno::UNO_SET_THROW );
+ ::rtl::OUString aIdentifier = xModuleManager->identify( rxModel );
+ aPath = rPool.maCurrDirs[ aIdentifier ];
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return aPath;
+}
+
+// ============================================================================
+
} // namespace vba
} // namespace basic
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index f8ffa46d48a5..bf7b00e2a633 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -42,6 +42,7 @@
#include <tools/shl.hxx>
#include <tools/rc.hxx>
#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
#include "sbunoobj.hxx"
#include "sbjsmeth.hxx"
#include "sbjsmod.hxx"
@@ -136,6 +137,7 @@ void DocBasicItem::startListening()
Any aThisComp;
mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp );
Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY );
+ mbDisposed = !xCloseBC.is();
if( xCloseBC.is() )
try { xCloseBC->addCloseListener( this ); } catch( uno::Exception& ) {}
}
@@ -437,7 +439,20 @@ SbxObject* SbiFactory::CreateObject( const String& rClass )
return new BasicCollection( aCollectionName );
}
else
- return NULL;
+ if( rClass.EqualsIgnoreCaseAscii( "FileSystemObject" ) )
+ {
+ try
+ {
+ Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW );
+ ::rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.FileSystemObject" ) );
+ Reference< XInterface > xInterface( xFactory->createInstance( aServiceName ), UNO_SET_THROW );
+ return new SbUnoObject( aServiceName, uno::makeAny( xInterface ) );
+ }
+ catch( Exception& )
+ {}
+ }
+
+ return NULL;
}
@@ -934,8 +949,14 @@ void StarBASIC::SetModified( sal_Bool b )
SbxBase::SetModified( b );
}
+extern void lcl_closeTraceFile();
+
StarBASIC::~StarBASIC()
{
+#ifdef DBG_TRACE_BASIC
+ lcl_closeTraceFile();
+#endif
+
// Needs to be first action as it can trigger events
disposeComVariablesForBasic( this );
@@ -2273,7 +2294,22 @@ void BasicCollection::CollRemove( SbxArray* pPar_ )
SbxVariable* p = pPar_->Get( 1 );
sal_Int32 nIndex = implGetIndex( p );
if( nIndex >= 0 && nIndex < (sal_Int32)xItemArray->Count32() )
+ {
xItemArray->Remove32( nIndex );
+
+ // Correct for stack if necessary
+ SbiInstance* pInst = pINST;
+ SbiRuntime* pRT = pInst ? pInst->pRun : NULL;
+ if( pRT )
+ {
+ SbiForStack* pStack = pRT->FindForStackItemForCollection( this );
+ if( pStack != NULL )
+ {
+ if( pStack->nCurCollectionIndex >= nIndex )
+ --pStack->nCurCollectionIndex;
+ }
+ }
+ }
else
SetError( SbERR_BAD_ARGUMENT );
}
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 13ae406cb305..6f20a68a274f 100755
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -1722,8 +1722,7 @@ String getBasicObjectTypeName( SbxObject* pObj )
return aName;
}
-bool checkUnoObjectType( SbUnoObject* pUnoObj,
- const String& aClass )
+bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass )
{
Any aToInspectObj = pUnoObj->getUnoAny();
TypeClass eType = aToInspectObj.getValueType().getTypeClass();
@@ -1740,6 +1739,21 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj,
Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
if( xTypeProvider.is() )
{
+ /* Although interfaces in the ooo.vba namespace obey the IDL rules and
+ have a leading 'X', in Basic we want to be able to do something
+ like 'Dim wb As Workbooks' or 'Dim lb As MSForms.Label'. Here we
+ add a leading 'X' to the class name and a leading dot to the entire
+ type name. This results e.g. in '.XWorkbooks' or '.MSForms.XLabel'
+ which matches the interface names 'ooo.vba.excel.XWorkbooks' or
+ 'ooo.vba.msforms.XLabel'.
+ */
+ ::rtl::OUString aClassName( sal_Unicode( '.' ) );
+ sal_Int32 nClassNameDot = rClass.lastIndexOf( '.' );
+ if( nClassNameDot >= 0 )
+ aClassName += rClass.copy( 0, nClassNameDot + 1 ) + ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass.copy( nClassNameDot + 1 );
+ else
+ aClassName += ::rtl::OUString( sal_Unicode( 'X' ) ) + rClass;
+
Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
const Type* pTypeArray = aTypeSeq.getConstArray();
sal_uInt32 nIfaceCount = aTypeSeq.getLength();
@@ -1753,8 +1767,8 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj,
DBG_ERROR("failed to get XIdlClass for type");
break;
}
- ::rtl::OUString sClassName = xClass->getName();
- if ( sClassName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) )
+ ::rtl::OUString aInterfaceName = xClass->getName();
+ if ( aInterfaceName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) )
{
// there is a hack in the extensions/source/ole/oleobj.cxx to return the typename of the automation object, lets check if it
// matches
@@ -1767,20 +1781,15 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj,
// can't check type, leave it pass
result = true;
else
- result = sTypeName.equals( aClass );
+ result = sTypeName.equals( rClass );
}
break; // finished checking automation object
}
- OSL_TRACE("Checking if object implements %s",
- OUStringToOString( defaultNameSpace + aClass,
- RTL_TEXTENCODING_UTF8 ).getStr() );
- // although interfaces in the ooo.vba.vba namespace
- // obey the idl rules and have a leading X, in basic we
- // want to be able to do something like
- // 'dim wrkbooks as WorkBooks'
- // so test assumes the 'X' has been dropped
- sal_Int32 indexLastDot = sClassName.lastIndexOf('.');
- if ( indexLastDot > -1 && sClassName.copy( indexLastDot + 1).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("X") ) + aClass ) )
+
+ // match interface name with passed class name
+ OSL_TRACE("Checking if object implements %s", OUStringToOString( aClassName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if ( (aClassName.getLength() < aInterfaceName.getLength()) &&
+ aInterfaceName.matchIgnoreAsciiCase( aClassName, aInterfaceName.getLength() - aClassName.getLength() ) )
{
result = true;
break;
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index c722e680fd8c..24b031e8f4e9 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -61,6 +61,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <com/sun/star/script/vba/VBAScriptEventId.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <com/sun/star/document/XEventListener.hpp>
@@ -88,10 +89,8 @@ using namespace com::sun::star;
#include <cppuhelper/implbase1.hxx>
#include <basic/sbobjmod.hxx>
#include <com/sun/star/uno/XAggregation.hpp>
-#include <map>
#include <com/sun/star/script/XInvocation.hpp>
- using namespace ::com::sun::star;
using namespace com::sun::star::lang;
using namespace com::sun::star::reflection;
using namespace com::sun::star::beans;
@@ -107,6 +106,7 @@ using namespace com::sun::star::script;
#include <cppuhelper/implbase1.hxx>
#include <comphelper/anytostring.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/VbQueryClose.hpp>
typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE;
typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
@@ -451,24 +451,36 @@ TYPEINIT1(SbUserFormModule,SbObjModule)
typedef std::vector<HighlightPortion> HighlightPortions;
-bool getDefaultVBAMode( StarBASIC* pb )
+uno::Reference< frame::XModel > getDocumentModel( StarBASIC* pb )
{
- bool bResult = false;
- if ( pb && pb->IsDocBasic() )
+ uno::Reference< frame::XModel > xModel;
+ if( pb && pb->IsDocBasic() )
{
uno::Any aDoc;
- if ( pb->GetUNOConstant( "ThisComponent", aDoc ) )
- {
- uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY );
- if ( xProp.is() )
- {
- uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY );
- if ( xVBAMode.is() )
- bResult = xVBAMode->getVBACompatibilityMode() == sal_True;
- }
- }
+ if( pb->GetUNOConstant( "ThisComponent", aDoc ) )
+ xModel.set( aDoc, uno::UNO_QUERY );
}
- return bResult;
+ return xModel;
+}
+
+uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Reference< frame::XModel >& rxModel )
+{
+ uno::Reference< vba::XVBACompatibility > xVBACompat;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW );
+ xVBACompat.set( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return xVBACompat;
+}
+
+bool getDefaultVBAMode( StarBASIC* pb )
+{
+ uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) );
+ return xVBACompat.is() && xVBACompat->getVBACompatibilityMode();
}
class AsyncQuitHandler
@@ -501,20 +513,6 @@ IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ )
return 0L;
}
-void VBAUnlockDocuments( StarBASIC* pBasic )
-{
- if ( pBasic && pBasic->IsDocBasic() )
- {
- SbUnoObject* pGlobs = dynamic_cast< SbUnoObject* >( pBasic->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ), SbxCLASS_DONTCARE ) );
- if ( pGlobs )
- {
- uno::Reference< frame::XModel > xModel( pGlobs->getUnoAny(), uno::UNO_QUERY );
- ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False );
- ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True );
- }
- }
-}
-
/////////////////////////////////////////////////////////////////////////////
// Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen
@@ -833,7 +831,7 @@ void SbModule::SetSource( const String& r )
void SbModule::SetSource32( const ::rtl::OUString& r )
{
// Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override
- SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) );
+ SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) );
aOUSource = r;
StartDefinitions();
SbiTokenizer aTok( r );
@@ -1031,6 +1029,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth )
sal_uInt16 nRes = 0;
sal_Bool bDelInst = sal_Bool( pINST == NULL );
StarBASICRef xBasic;
+ uno::Reference< frame::XModel > xModel;
+ uno::Reference< script::vba::XVBACompatibility > xVBACompat;
if( bDelInst )
{
#ifdef DBG_TRACE_BASIC
@@ -1041,6 +1041,23 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth )
pINST = new SbiInstance( (StarBASIC*) GetParent() );
+ /* If a VBA script in a document is started, get the VBA compatibility
+ interface from the document Basic library container, and notify all
+ VBA script listeners about the started script. */
+ if( mbVBACompat )
+ {
+ StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() );
+ if( pBasic && pBasic->IsDocBasic() ) try
+ {
+ xModel.set( getDocumentModel( pBasic ), uno::UNO_SET_THROW );
+ xVBACompat.set( getVBACompatibility( xModel ), uno::UNO_SET_THROW );
+ xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STARTED, GetName() );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
// Launcher problem
// i80726 The Find below will genarate an error in Testtool so we reset it unless there was one before already
sal_Bool bWasError = SbxBase::GetError() != 0;
@@ -1183,9 +1200,20 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth )
ResetCapturedAssertions();
#endif
- // VBA always ensures screenupdating is enabled after completing
- if ( mbVBACompat )
- VBAUnlockDocuments( PTR_CAST( StarBASIC, GetParent() ) );
+ if( xVBACompat.is() )
+ {
+ // notify all VBA script listeners about the stopped script
+ try
+ {
+ xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::SCRIPT_STOPPED, GetName() );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ // VBA always ensures screenupdating is enabled after completing
+ ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False );
+ ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True );
+ }
#ifdef DBG_TRACE_BASIC
dbg_DeInitTrace();
@@ -2276,8 +2304,9 @@ public:
uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY );
if ( xVbaMethodParameter.is() )
{
+#endif
sal_Int8 nCancel = 0;
- sal_Int8 nCloseMode = 0;
+ sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu;
Sequence< Any > aParams;
aParams.realloc(2);
@@ -2286,14 +2315,13 @@ public:
mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ),
aParams);
+#if IN_THE_FUTURE
xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]);
return;
}
}
}
-
- mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) );
#endif
}
//liuchen 2009-7-21
@@ -2403,15 +2431,14 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun )
Sequence< Any > aArguments;
triggerMethod( aMethodToRun, aArguments );
}
-void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& /*aArguments*/)
+
+void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments )
{
OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() );
// Search method
SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD );
if( pMeth )
{
-#if IN_THE_FUTURE
- //liuchen 2009-7-21, support Excel VBA UserForm_QueryClose event with parameters
if ( aArguments.getLength() > 0 ) // Setup parameters
{
SbxArrayRef xArray = new SbxArray;
@@ -2439,8 +2466,6 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any
pMeth->SetParameters( NULL );
}
else
-//liuchen 2009-7-21
-#endif
{
SbxValues aVals;
pMeth->Get( aVals );
@@ -2532,7 +2557,7 @@ void SbUserFormModule::Unload()
OSL_TRACE("** Unload() ");
sal_Int8 nCancel = 0;
- sal_Int8 nCloseMode = 1;
+ sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode;
Sequence< Any > aParams;
aParams.realloc(2);
@@ -2542,7 +2567,7 @@ void SbUserFormModule::Unload()
triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams);
aParams[0] >>= nCancel;
- if (nCancel == 1)
+ if (nCancel != 0) // Basic returns -1 for "True"
{
return;
}
@@ -2585,6 +2610,9 @@ void SbUserFormModule::InitObject()
SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE );
if ( m_xModel.is() && pGlobs )
{
+ // broadcast INITIALIZE_USERFORM script event before the dialog is created
+ Reference< script::vba::XVBACompatibility > xVBACompat( getVBACompatibility( m_xModel ), uno::UNO_SET_THROW );
+ xVBACompat->broadcastVBAScriptEvent( script::vba::VBAScriptEventId::INITIALIZE_USERFORM, GetName() );
uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW );
uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index a8c7e3f5330f..f59edfbb12e9 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -303,6 +303,8 @@ void SbiCodeGen::Save()
nUserData |= nDefaultId;
if( pPar->IsParamArray() )
nUserData |= PARAM_INFO_PARAMARRAY;
+ if( pPar->IsWithBrackets() )
+ nUserData |= PARAM_INFO_WITHBRACKETS;
if( nUserData )
{
SbxParamInfo* pParam = (SbxParamInfo*)pInfo->GetParam( i );
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 1ba8982404e4..03c4845569a7 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -51,7 +51,11 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bC
SbiDimList* pDim = NULL;
// Klammern?
if( Peek() == LPAREN )
+ {
pDim = new SbiDimList( this );
+ if( !pDim->GetDims() )
+ pDef->SetWithBrackets();
+ }
pDef->SetType( t );
if( bStatic )
pDef->SetStatic();
@@ -382,6 +386,9 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic )
if( nFixedStringLength >= 0 )
nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (sal_uInt32(nFixedStringLength) << 17)); // len = all bits above 0x10000
+ if( pDim != NULL && pDim->GetDims() > 0 )
+ nOpnd2 |= SBX_TYPE_VAR_TO_DIM_FLAG;
+
aGen.Gen( eOp2, pDef->GetId(), nOpnd2 );
}
diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx
index 12e368d1c7eb..49c025a9e0a4 100755
--- a/basic/source/comp/sbcomp.cxx
+++ b/basic/source/comp/sbcomp.cxx
@@ -44,12 +44,13 @@
#include <hash_map>
// Trace ini file (set NULL to ignore)
-static char GpTraceIniFile[] = "d:\\zBasic.Asm\\BasicTrace.ini";
+// can be overridden with the environment variable OOO_BASICTRACEINI
+static char GpTraceIniFile[] = "~/BasicTrace.ini";
//static char* GpTraceIniFile = NULL;
// Trace Settings, used if no ini file / not found in ini file
-static char GpTraceFileNameDefault[] = "d:\\zBasic.Asm\\BasicTrace.txt";
+static char GpTraceFileNameDefault[] = "~/BasicTrace.txt";
static char* GpTraceFileName = GpTraceFileNameDefault;
// GbTraceOn:
@@ -63,6 +64,12 @@ static bool GbTraceOn = true;
// with TraceCommand( "PCodeOn" / "PCodeOff" ), see below
static bool GbIncludePCodes = false;
+// GbInitOnlyAtOfficeStart:
+// true = Tracing is only intialized onces after Office start when
+// Basic runs the first time. Further calls to Basic, e.g. via events
+// use the same output file. The trace ini file is not read again.
+static bool GbInitOnlyAtOfficeStart = false;
+
static int GnIndentPerCallLevel = 4;
static int GnIndentForPCode = 2;
@@ -84,6 +91,37 @@ static int GnIndentForPCode = 2;
long as it can be converted to string
*/
+#ifdef DBG_TRACE_PROFILING
+
+#include <algorithm>
+#include <stack>
+#include "canvas/elapsedtime.hxx"
+
+//*** Profiling ***
+// GbTimerOn:
+// true = including time stamps
+static bool GbTimerOn = true;
+
+// GbTimeStampForEachStep:
+// true = prints time stamp after each command / pcode (very slow)
+static bool GbTimeStampForEachStep = false;
+
+// GbBlockAllAfterFirstFunctionUsage:
+// true = everything (commands, pcodes, functions) is only printed
+// for the first usage (improves performance when tracing / pro-
+// filing large macros)
+static bool GbBlockAllAfterFirstFunctionUsage = false;
+
+// GbBlockStepsAfterFirstFunctionUsage:
+// true = commands / pcodes are only printed for the first time
+// a function is executed. Afterwards only the entering/leaving
+// messages are logged (improves performance when tracing / pro-
+// filing large macros)
+static bool GbBlockStepsAfterFirstFunctionUsage = false;
+
+#endif
+
+
static void lcl_skipWhites( char*& rpc )
{
while( *rpc == ' ' || *rpc == '\t' )
@@ -174,11 +212,28 @@ static void lcl_ReadIniFile( const char* pIniFileName )
if( strcmp( VarNameBuffer, "GbIncludePCodes") == 0 )
GbIncludePCodes = (strcmp( ValBuffer, "true" ) == 0);
else
+ if( strcmp( VarNameBuffer, "GbInitOnlyAtOfficeStart") == 0 )
+ GbInitOnlyAtOfficeStart = (strcmp( ValBuffer, "true" ) == 0);
+ else
if( strcmp( VarNameBuffer, "GnIndentPerCallLevel") == 0 )
GnIndentPerCallLevel = strtol( ValBuffer, NULL, 10 );
else
if( strcmp( VarNameBuffer, "GnIndentForPCode") == 0 )
GnIndentForPCode = strtol( ValBuffer, NULL, 10 );
+#ifdef DBG_TRACE_PROFILING
+ else
+ if( strcmp( VarNameBuffer, "GbTimerOn") == 0 )
+ GbTimerOn = (strcmp( ValBuffer, "true" ) == 0);
+ else
+ if( strcmp( VarNameBuffer, "GbTimeStampForEachStep") == 0 )
+ GbTimeStampForEachStep = (strcmp( ValBuffer, "true" ) == 0);
+ else
+ if( strcmp( VarNameBuffer, "GbBlockAllAfterFirstFunctionUsage") == 0 )
+ GbBlockAllAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0);
+ else
+ if( strcmp( VarNameBuffer, "GbBlockStepsAfterFirstFunctionUsage") == 0 )
+ GbBlockStepsAfterFirstFunctionUsage = (strcmp( ValBuffer, "true" ) == 0);
+#endif
}
fclose( pFile );
}
@@ -209,14 +264,14 @@ static void lcl_PrepareTraceForModule( SbModule* pModule )
pModule->Disassemble( aDisassemblyStr );
}
-static void lcl_lineOut( const char* pFileName, const char* pStr, const char* pPreStr = NULL )
+static FILE* GpGlobalFile = NULL;
+
+static void lcl_lineOut( const char* pStr, const char* pPreStr = NULL, const char* pPostStr = NULL )
{
- const char* pPrintFirst = (pPreStr != NULL) ? pPreStr : "";
- FILE* pFile = fopen( pFileName, "a+" );
- if( pFile != NULL )
+ if( GpGlobalFile != NULL )
{
- fprintf( pFile, "%s%s\n", pPrintFirst, pStr );
- fclose( pFile );
+ fprintf( GpGlobalFile, "%s%s%s\n", pPreStr ? pPreStr : "", pStr, pPostStr ? pPostStr : "" );
+ fflush( GpGlobalFile );
}
}
@@ -304,32 +359,198 @@ String lcl_dumpMethodParameters( SbMethod* pMethod )
// Public functions
-
static bool GbSavTraceOn = false;
+
+#ifdef DBG_TRACE_PROFILING
+static canvas::tools::ElapsedTime* GpTimer = NULL;
+static double GdStartTime = 0.0;
+static double GdLastTime = 0.0;
+static bool GbBlockSteps = false;
+static bool GbBlockAll = false;
+
+struct FunctionItem
+{
+ String m_aCompleteFunctionName;
+ double m_dTotalTime;
+ double m_dNetTime;
+ int m_nCallCount;
+ bool m_bBlockAll;
+ bool m_bBlockSteps;
+
+ FunctionItem( void )
+ : m_dTotalTime( 0.0 )
+ , m_dNetTime( 0.0 )
+ , m_nCallCount( 0 )
+ , m_bBlockAll( false )
+ , m_bBlockSteps( false )
+ {}
+};
+typedef std::hash_map< ::rtl::OUString, FunctionItem*, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > FunctionItemMap;
+
+static std::stack< double > GaCallEnterTimeStack;
+static std::stack< FunctionItem* > GaFunctionItemStack;
+static FunctionItemMap GaFunctionItemMap;
+
+bool compareFunctionNetTime( FunctionItem* p1, FunctionItem* p2 )
+{
+ return (p1->m_dNetTime > p2->m_dNetTime);
+}
+
+void lcl_printTimeOutput( void )
+{
+ // Overall time output
+ lcl_lineOut( "" );
+ lcl_lineOut( "***** Time Output *****" );
+ char TimeBuffer[500];
+ double dTotalTime = GpTimer->getElapsedTime() - GdStartTime;
+ sprintf( TimeBuffer, "Total execution time = %f ms", dTotalTime*1000.0 );
+ lcl_lineOut( TimeBuffer );
+ lcl_lineOut( "" );
+
+ if( GbTimerOn )
+ {
+ lcl_lineOut( "Functions:" );
+
+ std::vector<FunctionItem*> avFunctionItems;
+
+ FunctionItemMap::iterator it;
+ for( it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it )
+ {
+ FunctionItem* pFunctionItem = it->second;
+ if( pFunctionItem != NULL )
+ avFunctionItems.push_back( pFunctionItem );
+ }
+
+ std::sort( avFunctionItems.begin(), avFunctionItems.end(), compareFunctionNetTime );
+
+ std::vector<FunctionItem*>::iterator itv;
+ for( itv = avFunctionItems.begin() ; itv != avFunctionItems.end() ; ++itv )
+ {
+ FunctionItem* pFunctionItem = *itv;
+ if( pFunctionItem != NULL )
+ {
+ rtl::OUString aCompleteFunctionName = pFunctionItem->m_aCompleteFunctionName;
+ const char* pName = OUStringToOString( aCompleteFunctionName, RTL_TEXTENCODING_ASCII_US ).getStr();
+ int nNameLen = aCompleteFunctionName.getLength();
+
+ double dFctTotalTime = pFunctionItem->m_dTotalTime;
+ double dFctNetTime = pFunctionItem->m_dNetTime;
+ double dFctTotalTimePercent = 100.0 * dFctTotalTime / dTotalTime;
+ double dFctNetTimePercent = 100.0 * dFctNetTime / dTotalTime;
+ int nSpaceCount = 30 - nNameLen;
+ if( nSpaceCount < 0 )
+ nSpaceCount = 2;
+ sprintf( TimeBuffer, "%s:%sCalled %d times\t%f ms (%f%%) / net %f (%f%%) ms",
+ pName, lcl_getSpaces( nSpaceCount ), pFunctionItem->m_nCallCount,
+ dFctTotalTime*1000.0, dFctTotalTimePercent, dFctNetTime*1000.0, dFctNetTimePercent );
+ lcl_lineOut( TimeBuffer );
+ }
+ }
+ }
+}
+#endif
+
+
+static bool GbInitTraceAlreadyCalled = false;
+
void dbg_InitTrace( void )
{
- if( GpTraceIniFile != NULL )
+ if( GbInitOnlyAtOfficeStart && GbInitTraceAlreadyCalled )
+ {
+#ifdef DBG_TRACE_PROFILING
+ if( GbTimerOn )
+ GpTimer->continueTimer();
+#endif
+ GpGlobalFile = fopen( GpTraceFileName, "a+" );
+ return;
+ }
+ GbInitTraceAlreadyCalled = true;
+
+ if( const sal_Char* pcIniFileName = ::getenv( "OOO_BASICTRACEINI" ) )
+ lcl_ReadIniFile( pcIniFileName );
+ else if( GpTraceIniFile != NULL )
lcl_ReadIniFile( GpTraceIniFile );
- FILE* pFile = fopen( GpTraceFileName, "w" );
- if( pFile != NULL )
- fclose( pFile );
+ GpGlobalFile = fopen( GpTraceFileName, "w" );
GbSavTraceOn = GbTraceOn;
if( !GbTraceOn )
- lcl_lineOut( GpTraceFileName, "### Program started with trace off ###" );
+ lcl_lineOut( "### Program started with trace off ###" );
+
+#ifdef DBG_TRACE_PROFILING
+ GpTimer = new canvas::tools::ElapsedTime();
+ GdStartTime = GpTimer->getElapsedTime();
+ GdLastTime = GdStartTime;
+ GbBlockSteps = false;
+ GbBlockAll = false;
+#endif
}
void dbg_DeInitTrace( void )
{
GbTraceOn = GbSavTraceOn;
+
+#ifdef DBG_TRACE_PROFILING
+ while( !GaCallEnterTimeStack.empty() )
+ GaCallEnterTimeStack.pop();
+ while( !GaFunctionItemStack.empty() )
+ GaFunctionItemStack.pop();
+
+ lcl_printTimeOutput();
+
+ for( FunctionItemMap::iterator it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it )
+ delete it->second;
+ GaFunctionItemMap.clear();
+
+ if( GpGlobalFile )
+ {
+ fclose( GpGlobalFile );
+ GpGlobalFile = NULL;
+ }
+
+ if( GbInitOnlyAtOfficeStart )
+ {
+ if( GbTimerOn )
+ GpTimer->pauseTimer();
+ }
+ else
+ {
+ delete GpTimer;
+ }
+#endif
}
static sal_Int32 GnLastCallLvl = 0;
+void dbg_tracePrint( const String& aStr, sal_Int32 nCallLvl, bool bCallLvlRelativeToCurrent )
+{
+ if( bCallLvlRelativeToCurrent )
+ nCallLvl += GnLastCallLvl;
+
+ int nIndent = nCallLvl * GnIndentPerCallLevel;
+ lcl_lineOut( OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) );
+}
+
void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
{
if( !GbTraceOn )
return;
+
+#ifdef DBG_TRACE_PROFILING
+ if( GbBlockSteps || GbBlockAll )
+ return;
+
+ double dCurTime = 0.0;
+ bool bPrintTimeStamp = false;
+ if( GbTimerOn )
+ {
+ GpTimer->pauseTimer();
+ dCurTime = GpTimer->getElapsedTime();
+ bPrintTimeStamp = GbTimeStampForEachStep;
+ }
+#else
+ bool bPrintTimeStamp = false;
+#endif
+
GnLastCallLvl = nCallLvl;
SbModule* pTraceMod = pModule;
@@ -346,14 +567,14 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr();
char Buffer[200];
sprintf( Buffer, "TRACE ERROR: Unknown module \"%s\"", pModuleNameStr );
- lcl_lineOut( GpTraceFileName, Buffer );
+ lcl_lineOut( Buffer );
return;
}
PCToTextDataMap* pInnerMap = it->second;
if( pInnerMap == NULL )
{
- lcl_lineOut( GpTraceFileName, "TRACE INTERNAL ERROR: No inner map" );
+ lcl_lineOut( "TRACE INTERNAL ERROR: No inner map" );
return;
}
@@ -363,7 +584,7 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr();
char Buffer[200];
sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", (int)nPC, pModuleNameStr );
- lcl_lineOut( GpTraceFileName, Buffer );
+ lcl_lineOut( Buffer );
return;
}
@@ -371,24 +592,67 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
const TraceTextData& rTraceTextData = itInner->second;
const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT;
+ bool bSTMT = false;
if( rStr_STMNT.getLength() )
- lcl_lineOut( GpTraceFileName, rStr_STMNT.getStr(), lcl_getSpaces( nIndent ) );
+ bSTMT = true;
+
+ char TimeBuffer[200];
+#ifdef DBG_TRACE_PROFILING
+ if( bPrintTimeStamp )
+ {
+ double dDiffTime = dCurTime - GdLastTime;
+ GdLastTime = dCurTime;
+ sprintf( TimeBuffer, "\t\t// Time = %f ms / += %f ms", dCurTime*1000.0, dDiffTime*1000.0 );
+ }
+#endif
+
+ if( bSTMT )
+ {
+ lcl_lineOut( rStr_STMNT.getStr(), lcl_getSpaces( nIndent ),
+ (bPrintTimeStamp && !GbIncludePCodes) ? TimeBuffer : NULL );
+ }
if( !GbIncludePCodes )
+ {
+#ifdef DBG_TRACE_PROFILING
+ if( GbTimerOn )
+ GpTimer->continueTimer();
+#endif
return;
+ }
nIndent += GnIndentForPCode;
const rtl::OString& rStr_PCode = rTraceTextData.m_aTraceStr_PCode;
if( rStr_PCode.getLength() )
- lcl_lineOut( GpTraceFileName, rStr_PCode.getStr(), lcl_getSpaces( nIndent ) );
+ {
+ lcl_lineOut( rStr_PCode.getStr(), lcl_getSpaces( nIndent ),
+ bPrintTimeStamp ? TimeBuffer : NULL );
+ }
+
+#ifdef DBG_TRACE_PROFILING
+ if( GbTimerOn )
+ GpTimer->continueTimer();
+#endif
}
+
void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallLvl, bool bLeave )
{
static const char* pSeparator = "' ================================================================================";
if( !GbTraceOn )
return;
+
+#ifdef DBG_TRACE_PROFILING
+ double dCurTime = 0.0;
+ double dExecutionTime = 0.0;
+ if( GbTimerOn )
+ {
+ dCurTime = GpTimer->getElapsedTime();
+ GpTimer->pauseTimer();
+ }
+#endif
+
GnLastCallLvl = nCallLvl;
SbModule* pTraceMod = pModule;
@@ -399,39 +663,116 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
pTraceMod = pClassModuleObj->getClassModule();
}
+ String aCompleteFunctionName = pTraceMod->GetName();
+ if( pMethod != NULL )
+ {
+ aCompleteFunctionName.AppendAscii( "::" );
+ String aMethodName = pMethod->GetName();
+ aCompleteFunctionName += aMethodName;
+ }
+ else
+ {
+ aCompleteFunctionName.AppendAscii( "/RunInit" );
+ }
+
+ bool bOwnBlockSteps = false;
+#ifdef DBG_TRACE_PROFILING
+ bool bOwnBlockAll = false;
+ FunctionItem* pFunctionItem = NULL;
+ if( GbTimerOn )
+ {
+ FunctionItemMap::iterator itFunctionItem = GaFunctionItemMap.find( aCompleteFunctionName );
+ if( itFunctionItem != GaFunctionItemMap.end() )
+ pFunctionItem = itFunctionItem->second;
+
+ if( pFunctionItem == NULL )
+ {
+ DBG_ASSERT( !bLeave, "No FunctionItem in leave!" );
+
+ pFunctionItem = new FunctionItem();
+ pFunctionItem->m_aCompleteFunctionName = aCompleteFunctionName;
+ GaFunctionItemMap[ aCompleteFunctionName ] = pFunctionItem;
+ }
+ else if( GbBlockAllAfterFirstFunctionUsage && !bLeave )
+ {
+ pFunctionItem->m_bBlockAll = true;
+ }
+ else if( GbBlockStepsAfterFirstFunctionUsage && !bLeave )
+ {
+ pFunctionItem->m_bBlockSteps = true;
+ }
+
+ if( bLeave )
+ {
+ bOwnBlockAll = GbBlockAll;
+ bOwnBlockSteps = GbBlockSteps;
+ GbBlockAll = false;
+ GbBlockSteps = false;
+
+ dExecutionTime = dCurTime - GaCallEnterTimeStack.top();
+ GaCallEnterTimeStack.pop();
+
+ pFunctionItem->m_dTotalTime += dExecutionTime;
+ pFunctionItem->m_dNetTime += dExecutionTime;
+ pFunctionItem->m_nCallCount++;
+
+ GaFunctionItemStack.pop();
+ if( !GaFunctionItemStack.empty() )
+ {
+ FunctionItem* pParentItem = GaFunctionItemStack.top();
+ if( pParentItem != NULL )
+ {
+ pParentItem->m_dNetTime -= dExecutionTime;
+
+ GbBlockSteps = pParentItem->m_bBlockSteps;
+ GbBlockAll = pParentItem->m_bBlockAll;
+ }
+ }
+ }
+ else
+ {
+ GbBlockSteps = bOwnBlockSteps = pFunctionItem->m_bBlockSteps;
+ GbBlockAll = bOwnBlockAll = pFunctionItem->m_bBlockAll;
+
+ GaCallEnterTimeStack.push( dCurTime );
+ GaFunctionItemStack.push( pFunctionItem );
+ }
+ }
+
+ if( bOwnBlockAll )
+ {
+ if( GbTimerOn )
+ GpTimer->continueTimer();
+ return;
+ }
+#endif
+
if( nCallLvl > 0 )
nCallLvl--;
int nIndent = nCallLvl * GnIndentPerCallLevel;
- if( !bLeave )
+ if( !bLeave && !bOwnBlockSteps )
{
- lcl_lineOut( GpTraceFileName, "" );
- lcl_lineOut( GpTraceFileName, pSeparator, lcl_getSpaces( nIndent ) );
+ lcl_lineOut( "" );
+ lcl_lineOut( pSeparator, lcl_getSpaces( nIndent ) );
}
String aStr;
if( bLeave )
{
- lcl_lineOut( GpTraceFileName, "}", lcl_getSpaces( nIndent ) );
- aStr.AppendAscii( "' Leaving " );
+ if( !bOwnBlockSteps )
+ {
+ lcl_lineOut( "}", lcl_getSpaces( nIndent ) );
+ aStr.AppendAscii( "' Leaving " );
+ }
}
else
{
aStr.AppendAscii( "Entering " );
}
- String aModuleName = pTraceMod->GetName();
- aStr += aModuleName;
- if( pMethod != NULL )
- {
- aStr.AppendAscii( "::" );
- String aMethodName = pMethod->GetName();
- aStr += aMethodName;
- }
- else
- {
- aStr.AppendAscii( "/RunInit" );
- }
+ if( !bLeave || !bOwnBlockSteps )
+ aStr += aCompleteFunctionName;
- if( pClassModuleObj != NULL )
+ if( !bOwnBlockSteps && pClassModuleObj != NULL )
{
aStr.AppendAscii( "[this=" );
aStr += pClassModuleObj->GetName();
@@ -440,18 +781,37 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
if( !bLeave )
aStr += lcl_dumpMethodParameters( pMethod );
- lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) );
+ const char* pPostStr = NULL;
+#ifdef DBG_TRACE_PROFILING
+ char TimeBuffer[200];
+ if( GbTimerOn && bLeave )
+ {
+ sprintf( TimeBuffer, " // Execution Time = %f ms", dExecutionTime*1000.0 );
+ pPostStr = TimeBuffer;
+ }
+#endif
+ lcl_lineOut( (!bLeave || !bOwnBlockSteps) ? OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr() : "}",
+ lcl_getSpaces( nIndent ), pPostStr );
if( !bLeave )
- lcl_lineOut( GpTraceFileName, "{", lcl_getSpaces( nIndent ) );
+ lcl_lineOut( "{", lcl_getSpaces( nIndent ) );
- if( bLeave )
- lcl_lineOut( GpTraceFileName, "" );
+ if( bLeave && !bOwnBlockSteps )
+ lcl_lineOut( "" );
+
+#ifdef DBG_TRACE_PROFILING
+ if( GbTimerOn )
+ GpTimer->continueTimer();
+#endif
}
void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, sal_Int32 nCallLvl )
{
if( !GbTraceOn )
return;
+#ifdef DBG_TRACE_PROFILING
+ if( GbBlockSteps || GbBlockAll )
+ return;
+#endif
GnLastCallLvl = nCallLvl;
rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US );
@@ -460,7 +820,7 @@ void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool b
const char* pHandledStr = bTraceErrHandled ? " / HANDLED" : "";
sprintf( Buffer, "*** ERROR%s, Id = %d, Msg = \"%s\" ***", pHandledStr, (int)nTraceErr, aOTraceErrMsg.getStr() );
int nIndent = nCallLvl * GnIndentPerCallLevel;
- lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) );
+ lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) );
}
void dbg_RegisterTraceTextForPC( SbModule* pModule, sal_uInt32 nPC,
@@ -540,7 +900,7 @@ void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
sprintf( Buffer, "### TRACE_PRINT: %s ###", pValStr );
int nIndent = GnLastCallLvl * GnIndentPerCallLevel;
- lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) );
+ lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) );
if( eOld != SbxERR_OK )
SbxBase::SetError( eOld );
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 2688b5be28cf..cc6dc04fde65 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -302,6 +302,7 @@ SbiSymDef::SbiSymDef( const String& rName ) : aName( rName )
bOpt =
bParamArray =
bWithEvents =
+ bWithBrackets =
bByVal =
bChained =
bGlobal = sal_False;
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index 8700ae4129ba..28c90ff0bd87 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -561,7 +561,8 @@ SbiToken SbiTokenizer::Next()
}
special:
// #i92642
- if( eCurTok != NIL && eCurTok != REM && eCurTok != EOLN && (tp->t == NAME || tp->t == LINE) )
+ bool bStartOfLine = (eCurTok == NIL || eCurTok == REM || eCurTok == EOLN);
+ if( !bStartOfLine && (tp->t == NAME || tp->t == LINE) )
return eCurTok = SYMBOL;
else if( tp->t == TEXT )
return eCurTok = SYMBOL;
@@ -628,6 +629,9 @@ special:
// #129904 Suppress system
if( eTok == STOP && aSym.CompareIgnoreCaseToAscii( "system" ) == COMPARE_EQUAL )
eCurTok = SYMBOL;
+
+ if( eTok == GET && bStartOfLine )
+ eCurTok = SYMBOL;
}
else
{
diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx
index a496322bb6d7..9ba99e7ceae8 100644
--- a/basic/source/inc/codegen.hxx
+++ b/basic/source/inc/codegen.hxx
@@ -87,6 +87,7 @@ public:
// #111897 PARAM_INFO flags start at 0x00010000 to not
// conflict with DefaultId in SbxParamInfo::nUserData
-#define PARAM_INFO_PARAMARRAY 0x0010000
+#define PARAM_INFO_PARAMARRAY 0x0010000
+#define PARAM_INFO_WITHBRACKETS 0x0020000
#endif
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 7fd6eb06f607..c0e8191be307 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -29,6 +29,7 @@
#define BASIC_NAMECONTAINER_HXX
#include <hash_map>
+
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -46,71 +47,41 @@
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/deployment/XPackage.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <com/sun/star/script/vba/XVBAScriptListener.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
+
#include <osl/mutex.hxx>
#include <unotools/eventlisteneradapter.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/compbase8.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/weakref.hxx>
#include <cppuhelper/component.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/basemutex.hxx>
#include <sot/storage.hxx>
+#include <comphelper/listenernotification.hxx>
#include <xmlscript/xmllib_imexp.hxx>
-#include <com/sun/star/deployment/XPackage.hpp>
-
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/compbase8.hxx>
-#include <cppuhelper/interfacecontainer.hxx>
-#include <com/sun/star/script/vba/XVBACompatibility.hpp>
class BasicManager;
namespace basic
{
-typedef ::cppu::WeakComponentImplHelper8<
- ::com::sun::star::lang::XInitialization,
- ::com::sun::star::script::XStorageBasedLibraryContainer,
- ::com::sun::star::script::XLibraryContainerPassword,
- ::com::sun::star::script::XLibraryContainerExport,
- ::com::sun::star::script::XLibraryContainer3,
- ::com::sun::star::container::XContainer,
- ::com::sun::star::script::vba::XVBACompatibility,
- ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper;
-
-typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer,
- ::com::sun::star::container::XContainer > NameContainerHelper;
-
+//============================================================================
-struct hashName_Impl
-{
- size_t operator()(const ::rtl::OUString Str) const
- {
- return (size_t)Str.hashCode();
- }
-};
+typedef ::cppu::WeakImplHelper3<
+ ::com::sun::star::container::XNameContainer,
+ ::com::sun::star::container::XContainer,
+ ::com::sun::star::util::XChangesNotifier > NameContainer_BASE;
-struct eqName_Impl
+class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE
{
- sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const
- {
- return ( Str1 == Str2 );
- }
-};
-
-typedef std::hash_map
-<
- ::rtl::OUString,
- sal_Int32,
- hashName_Impl,
- eqName_Impl
->
-NameContainerNameMap;
-
-
-//============================================================================
+ typedef std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap;
-class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper
-{
NameContainerNameMap mHashMap;
::com::sun::star::uno::Sequence< ::rtl::OUString > mNames;
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues;
@@ -119,14 +90,16 @@ class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper
::com::sun::star::uno::Type mType;
::com::sun::star::uno::XInterface* mpxEventSource;
- ::cppu::OInterfaceContainerHelper maListenerContainer;
+ ::cppu::OInterfaceContainerHelper maContainerListeners;
+ ::cppu::OInterfaceContainerHelper maChangesListeners;
public:
NameContainer( const ::com::sun::star::uno::Type& rType )
: mnElementCount( 0 )
, mType( rType )
, mpxEventSource( NULL )
- , maListenerContainer( m_aMutex )
+ , maContainerListeners( m_aMutex )
+ , maChangesListeners( m_aMutex )
{}
void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
@@ -173,21 +146,18 @@ public:
virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
::com::sun::star::container::XContainerListener >& xListener )
throw (::com::sun::star::uno::RuntimeException);
+
+ // Methods XChangesNotifier
+ virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XChangesListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XChangesListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
};
//============================================================================
-class SfxLibrary;
-
-enum InitMode
-{
- DEFAULT,
- CONTAINER_INIT_FILE,
- LIBRARY_INIT_FILE,
- OFFICE_DOCUMENT,
- OLD_BASIC_STORAGE
-};
-
class ModifiableHelper
{
private:
@@ -217,9 +187,42 @@ public:
}
};
-class SfxLibraryContainer :public LibraryContainerHelper
- ,public ::utl::OEventListenerAdapter
+//============================================================================
+
+typedef ::comphelper::OListenerContainerBase<
+ ::com::sun::star::script::vba::XVBAScriptListener,
+ ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE;
+
+class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE
+{
+public:
+ explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex );
+
+private:
+ virtual bool implTypedNotify(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener,
+ const ::com::sun::star::script::vba::VBAScriptEvent& rEvent )
+ throw (::com::sun::star::uno::Exception);
+};
+
+//============================================================================
+
+class SfxLibrary;
+
+typedef ::cppu::WeakComponentImplHelper8<
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::script::XStorageBasedLibraryContainer,
+ ::com::sun::star::script::XLibraryContainerPassword,
+ ::com::sun::star::script::XLibraryContainerExport,
+ ::com::sun::star::script::XLibraryContainer3,
+ ::com::sun::star::container::XContainer,
+ ::com::sun::star::script::vba::XVBACompatibility,
+ ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE;
+
+class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter
{
+ VBAScriptListenerContainer maVBAScriptListeners;
+ sal_Int32 mnRunningVBAScripts;
sal_Bool mbVBACompat;
protected:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
@@ -246,7 +249,14 @@ protected:
BasicManager* mpBasMgr;
sal_Bool mbOwnBasMgr;
- InitMode meInitMode;
+ enum InitMode
+ {
+ DEFAULT,
+ CONTAINER_INIT_FILE,
+ LIBRARY_INIT_FILE,
+ OFFICE_DOCUMENT,
+ OLD_BASIC_STORAGE
+ } meInitMode;
void implStoreLibrary( SfxLibrary* pLib,
const ::rtl::OUString& aName,
@@ -508,10 +518,24 @@ public:
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException) = 0;
// Methods XVBACompatibility
- virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getVBACompatibilityMode()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRunningVBAScripts()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVBAScriptListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVBAScriptListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName )
+ throw (::com::sun::star::uno::RuntimeException);
};
+//============================================================================
+
class LibraryContainerMethodGuard
{
private:
@@ -529,12 +553,12 @@ public:
}
};
-
//============================================================================
class SfxLibrary
: public ::com::sun::star::container::XNameContainer
, public ::com::sun::star::container::XContainer
+ , public ::com::sun::star::util::XChangesNotifier
, public ::cppu::BaseMutex
, public ::cppu::OComponentHelper
{
@@ -670,6 +694,14 @@ public:
::com::sun::star::container::XContainerListener >& xListener )
throw (::com::sun::star::uno::RuntimeException);
+ // Methods XChangesNotifier
+ virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XChangesListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XChangesListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
public:
struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } };
void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess )
@@ -681,18 +713,19 @@ protected:
virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
};
-//===================================================================
+//============================================================================
+
class ScriptSubPackageIterator
{
- com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage;
+ com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage;
- bool m_bIsValid;
- bool m_bIsBundle;
+ bool m_bIsValid;
+ bool m_bIsBundle;
com::sun::star::uno::Sequence< com::sun::star::uno::Reference
- < com::sun::star::deployment::XPackage > > m_aSubPkgSeq;
- sal_Int32 m_nSubPkgCount;
- sal_Int32 m_iNextSubPkg;
+ < com::sun::star::deployment::XPackage > > m_aSubPkgSeq;
+ sal_Int32 m_nSubPkgCount;
+ sal_Int32 m_iNextSubPkg;
com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
implDetectScriptPackage( const com::sun::star::uno::Reference
@@ -704,13 +737,7 @@ public:
com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib );
};
-enum IteratorState
-{
- USER_EXTENSIONS,
- SHARED_EXTENSIONS,
- BUNDLED_EXTENSIONS,
- END_REACHED
-};
+//============================================================================
class ScriptExtensionIterator
{
@@ -731,34 +758,37 @@ protected:
com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
implGetNextBundledScriptPackage( bool& rbPureDialogLib );
- com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
- IteratorState m_eState;
+ enum IteratorState
+ {
+ USER_EXTENSIONS,
+ SHARED_EXTENSIONS,
+ BUNDLED_EXTENSIONS,
+ END_REACHED
+ } m_eState;
com::sun::star::uno::Sequence< com::sun::star::uno::Reference
- < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
- bool m_bUserPackagesLoaded;
+ < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
+ bool m_bUserPackagesLoaded;
com::sun::star::uno::Sequence< com::sun::star::uno::Reference
- < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
- bool m_bSharedPackagesLoaded;
+ < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
+ bool m_bSharedPackagesLoaded;
com::sun::star::uno::Sequence< com::sun::star::uno::Reference
- < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
- bool m_bBundledPackagesLoaded;
+ < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
+ bool m_bBundledPackagesLoaded;
+ int m_iUserPackage;
+ int m_iSharedPackage;
+ int m_iBundledPackage;
- int m_iUserPackage;
- int m_iSharedPackage;
- int m_iBundledPackage;
-
-
-
- ScriptSubPackageIterator* m_pScriptSubPackageIterator;
+ ScriptSubPackageIterator* m_pScriptSubPackageIterator;
}; // end class ScriptExtensionIterator
-
+//============================================================================
} // namespace basic
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 46cd9d16521f..406bd487034c 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -465,6 +465,8 @@ public:
SbxArray* GetLocals();
SbxArray* GetParams();
+ SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection );
+
SbxBase* FindElementExtern( const String& rName );
static bool isVBAEnabled();
diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx
index d91c7bdf16e8..4fd139202b52 100755
--- a/basic/source/inc/sbtrace.hxx
+++ b/basic/source/inc/sbtrace.hxx
@@ -28,7 +28,20 @@
#ifndef _SBTRACE_HXX
#define _SBTRACE_HXX
-//#define DBG_TRACE_BASIC
+#define DBG_TRACE_BASIC
+
+// ###############################################################################
+// ###
+// ### ATTENTION:
+// ###
+// ### - DBG_TRACE_PROFILING can only be activated together with DBG_TRACE_BASIC
+// ###
+// ### - If you activate DBG_TRACE_PROFILING you also need to uncomment line
+// ### # SHL1STDLIBS+=$(CANVASTOOLSLIB) in basic/util/makefile.mk (search
+// ### for DBG_TRACE_PROFILING there)
+// ###
+// ###############################################################################
+//#define DBG_TRACE_PROFILING
#ifdef DBG_TRACE_BASIC
void dbg_InitTrace( void );
diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx
index d788a73da0fc..9ef4c41c6ce3 100644
--- a/basic/source/inc/scriptcont.hxx
+++ b/basic/source/inc/scriptcont.hxx
@@ -35,11 +35,11 @@
class BasicManager;
-//============================================================================
-
namespace basic
{
+//============================================================================
+
class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword
{
::rtl::OUString maScriptLanguage;
@@ -140,16 +140,15 @@ public:
};
//============================================================================
-typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap;
-typedef ::cppu::ImplHelper1 < ::com::sun::star::script::vba::XVBAModuleInfo
- > SfxScriptLibrary_BASE;
+typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE;
-class SfxScriptLibrary : public SfxLibrary
- , public SfxScriptLibrary_BASE
+class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE
{
friend class SfxScriptLibraryContainer;
+ typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap;
+
sal_Bool mbLoadedSource;
sal_Bool mbLoadedBinary;
ModuleInfoMap mModuleInfos;
@@ -194,7 +193,9 @@ protected:
virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const;
};
-} // namespace base
+//============================================================================
+
+} // namespace basic
#endif
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index c30445d87634..576639dc5a45 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -133,6 +133,7 @@ protected:
sal_Bool bGlobal : 1; // sal_True: Global-Variable
sal_Bool bParamArray : 1; // sal_True: ParamArray parameter
sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents
+ sal_Bool bWithBrackets : 1; // sal_True: Followed by ()
sal_uInt16 nDefaultId; // Symbol number of default value
short nFixedStringLength; // String length in: Dim foo As String*Length
public:
@@ -159,6 +160,7 @@ public:
void SetOptional() { bOpt = sal_True; }
void SetParamArray() { bParamArray = sal_True; }
void SetWithEvents() { bWithEvents = sal_True; }
+ void SetWithBrackets(){ bWithBrackets = sal_True; }
void SetByVal( sal_Bool bByVal_ = sal_True )
{ bByVal = bByVal_; }
void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; }
@@ -170,6 +172,7 @@ public:
sal_Bool IsOptional() const{ return bOpt; }
sal_Bool IsParamArray() const{ return bParamArray; }
sal_Bool IsWithEvents() const{ return bWithEvents; }
+ sal_Bool IsWithBrackets() const{ return bWithBrackets; }
sal_Bool IsByVal() const { return bByVal; }
sal_Bool IsStatic() const { return bStatic; }
sal_Bool IsNew() const { return bNew; }
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1d1f1c641547..640dd7e8bcbe 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -82,6 +82,7 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::ucb;
using namespace com::sun::star::io;
+using namespace com::sun::star::frame;
#endif /* _USE_UNO */
@@ -96,6 +97,7 @@ using namespace com::sun::star::io;
#include "iosys.hxx"
#include "ddectrl.hxx"
#include <sbintern.hxx>
+#include <basic/vbahelper.hxx>
#include <list>
#include <math.h>
@@ -118,6 +120,9 @@ using namespace com::sun::star::io;
#include <basic/sbobjmod.hxx>
+// from source/classes/sbxmod.cxx
+Reference< XModel > getDocumentModel( StarBASIC* );
+
static void FilterWhiteSpace( String& rStr )
{
rStr.EraseAllChars( ' ' );
@@ -382,22 +387,48 @@ RTLFUNC(Asc)
}
}
-RTLFUNC(Chr)
+void implChr( SbxArray& rPar, bool bChrW )
{
- (void)pBasic;
- (void)bWrite;
-
if ( rPar.Count() < 2 )
StarBASIC::Error( SbERR_BAD_ARGUMENT );
else
{
SbxVariableRef pArg = rPar.Get( 1 );
- sal_Unicode aCh = (sal_Unicode)pArg->GetUShort();
- String aStr( aCh );
+
+ String aStr;
+ if( !bChrW && SbiRuntime::isVBAEnabled() )
+ {
+ sal_Char c = (sal_Char)pArg->GetByte();
+ ByteString s( c );
+ aStr = String( s, gsl_getSystemTextEncoding() );
+ }
+ else
+ {
+ sal_Unicode aCh = (sal_Unicode)pArg->GetUShort();
+ aStr = String( aCh );
+ }
rPar.Get(0)->PutString( aStr );
}
}
+RTLFUNC(Chr)
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ bool bChrW = false;
+ implChr( rPar, bChrW );
+}
+
+RTLFUNC(ChrW)
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ bool bChrW = true;
+ implChr( rPar, bChrW );
+}
+
#ifdef UNX
#define _MAX_PATH 260
@@ -481,7 +512,6 @@ RTLFUNC(CurDir)
RTLFUNC(ChDir) // JSM
{
- (void)pBasic;
(void)bWrite;
rPar.Get(0)->PutEmpty();
@@ -504,6 +534,9 @@ RTLFUNC(ChDir) // JSM
if( bError )
StarBASIC::Error( SbERR_PATH_NOT_FOUND );
#endif
+ // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.)
+ if( SbiRuntime::isVBAEnabled() )
+ ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() );
}
else
StarBASIC::Error( SbERR_BAD_ARGUMENT );
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 2f6d18685803..20eca1f985ff 100755..100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -1075,6 +1075,10 @@ sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm,
{
sal_uInt8 aByte;
*pStrm >> aByte;
+
+ if( bBinary && SbiRuntime::isVBAEnabled() && aByte == 1 && pStrm->IsEof() )
+ aByte = 0;
+
rVar.PutByte( aByte );
}
break;
@@ -1185,7 +1189,8 @@ void PutGet( SbxArray& rPar, sal_Bool bPut )
}
sal_Int16 nFileNo = rPar.Get(1)->GetInteger();
SbxVariable* pVar2 = rPar.Get(2);
- sal_Bool bHasRecordNo = (sal_Bool)(pVar2->GetType() != SbxEMPTY);
+ SbxDataType eType2 = pVar2->GetType();
+ sal_Bool bHasRecordNo = (sal_Bool)(eType2 != SbxEMPTY && eType2 != SbxERROR);
long nRecordNo = pVar2->GetLong();
if ( nFileNo < 1 || ( bHasRecordNo && nRecordNo < 1 ) )
{
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index bba1867d3591..8594382bd733 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -157,6 +157,7 @@ extern RTLFUNC(Abs);
extern RTLFUNC(Asc);
extern RTLFUNC(Atn);
extern RTLFUNC(Chr);
+extern RTLFUNC(ChrW);
extern RTLFUNC(Cos);
extern RTLFUNC(CurDir);
extern RTLFUNC(ChDir); // JSM
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 10d25cc2292b..1a83a323931d 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -648,6 +648,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
// Methoden sind immer byval!
sal_Bool bByVal = v->IsA( TYPE(SbxMethod) );
SbxDataType t = v->GetType();
+ bool bTargetTypeIsArray = false;
if( p )
{
bByVal |= sal_Bool( ( p->eType & SbxBYREF ) == 0 );
@@ -656,9 +657,13 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
if( !bByVal && t != SbxVARIANT &&
(!v->IsFixed() || (SbxDataType)(v->GetType() & 0x0FFF ) != t) )
bByVal = sal_True;
+
+ bTargetTypeIsArray = (p->nUserData & PARAM_INFO_WITHBRACKETS) != 0;
}
if( bByVal )
{
+ if( bTargetTypeIsArray )
+ t = SbxOBJECT;
SbxVariable* v2 = new SbxVariable( t );
v2->SetFlag( SBX_READWRITE );
*v2 = *v;
@@ -1237,6 +1242,26 @@ void SbiRuntime::ClearForStack()
PopFor();
}
+SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* pCollection )
+{
+ SbiForStack* pRet = NULL;
+
+ SbiForStack* p = pForStk;
+ while( p )
+ {
+ SbxVariable* pVar = p->refEnd.Is() ? (SbxVariable*)p->refEnd : NULL;
+ if( p->eForType == FOR_EACH_COLLECTION && pVar != NULL &&
+ (pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection )
+ {
+ pRet = p;
+ break;
+ }
+ }
+
+ return pRet;
+}
+
+
//////////////////////////////////////////////////////////////////////////
//
// DLL-Aufrufe
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 92d8152e60f4..4004b40e882c 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -128,7 +128,7 @@ static Methods aMethods[] = {
{ "Chr", SbxSTRING, 1 | _FUNCTION, RTLNAME(Chr),0 },
{ "string", SbxINTEGER, 0,NULL,0 },
-{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(Chr),0},
+{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(ChrW),0},
{ "string", SbxINTEGER, 0,NULL,0 },
{ "CInt", SbxINTEGER, 1 | _FUNCTION, RTLNAME(CInt),0 },
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx
index 43c930e975d2..462726a4c55f 100644
--- a/basic/source/runtime/step0.cxx
+++ b/basic/source/runtime/step0.cxx
@@ -797,6 +797,8 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
// AB 2.4.1996, auch Arrays ohne Dimensionsangaben zulassen (VB-komp.)
if( pDims )
{
+ refVar->ResetFlag( SBX_VAR_TO_DIM );
+
for( sal_uInt16 i = 1; i < pDims->Count(); )
{
sal_Int32 lb = pDims->Get( i++ )->GetLong();
diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx
index 0a9572906cc8..4fd91b692a4b 100644
--- a/basic/source/runtime/step1.cxx
+++ b/basic/source/runtime/step1.cxx
@@ -38,8 +38,7 @@
#include "sbunoobj.hxx"
#include "errobject.hxx"
-bool checkUnoObjectType( SbUnoObject* refVal,
- const String& aClass );
+bool checkUnoObjectType( SbUnoObject* refVal, const ::rtl::OUString& aClass );
// Laden einer numerischen Konstanten (+ID)
diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index bbb3668b5b69..dc8ff0a5fd50 100755
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -624,7 +624,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
else if( bVBAEnabled ) // !pObj
{
SbxArray* pParam = pElem->GetParameters();
- if( pParam != NULL )
+ if( pParam != NULL && !pElem->IsSet( SBX_VAR_TO_DIM ) )
Error( SbERR_NO_OBJECT );
}
}
@@ -1141,6 +1141,10 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3
aStr.Fill( nCount, 0 );
pVar->PutString( aStr );
}
+
+ bool bVarToDim = ((nOp2 & SBX_TYPE_VAR_TO_DIM_FLAG) != 0);
+ if( bVarToDim )
+ pVar->SetFlag( SBX_VAR_TO_DIM );
}
// Einrichten einer lokalen Variablen (+StringID+Typ)
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index fbf1429f9753..ae110f4bcf6e 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -34,17 +34,13 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <vcl/svapp.hxx>
#include <vos/mutex.hxx>
-#ifndef __RSC //autogen
#include <tools/errinf.hxx>
-#endif
#include <osl/mutex.hxx>
#include <vos/diagnose.hxx>
#include <rtl/uri.hxx>
#include <rtl/strbuf.hxx>
#include <comphelper/processfactory.hxx>
-#ifndef INCLUDED_COMPHELPER_ANYTOSTRING_HXX
#include <comphelper/anytostring.hxx>
-#endif
#include "namecont.hxx"
#include <basic/basicmanagerrepository.hxx>
@@ -65,11 +61,9 @@
#include <com/sun/star/uno/DeploymentException.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/script/LibraryNotLoadedException.hpp>
-#include "com/sun/star/deployment/ExtensionManager.hpp"
+#include <com/sun/star/script/vba/VBAScriptEventId.hpp>
+#include <com/sun/star/deployment/ExtensionManager.hpp>
#include <comphelper/storagehelper.hxx>
-#ifndef _RTL_USTRING_HXX_
-#include <comphelper/anytostring.hxx>
-#endif
#include <cppuhelper/exc_hlp.hxx>
#include <basic/sbmod.hxx>
@@ -165,25 +159,29 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement )
// Fire event
- ContainerEvent aEvent;
- aEvent.Source = mpxEventSource;
- aEvent.Accessor <<= aName;
- aEvent.Element = aElement;
- aEvent.ReplacedElement = aOldElement;
+ if( maContainerListeners.getLength() > 0 )
+ {
+ ContainerEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Accessor <<= aName;
+ aEvent.Element = aElement;
+ aEvent.ReplacedElement = aOldElement;
+ maContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent );
+ }
- OInterfaceIteratorHelper aIterator( maListenerContainer );
- while( aIterator.hasMoreElements() )
+ /* After the container event has been fired (one listener will update the
+ core Basic manager), fire change event. Listeners can rely that the
+ Basic source code of the core Basic manager is up-to-date. */
+ if( maChangesListeners.getLength() > 0 )
{
- Reference< XInterface > xIface = aIterator.next();
- Reference< XContainerListener > xListener( xIface, UNO_QUERY );
- try
- {
- xListener->elementReplaced( aEvent );
- }
- catch(RuntimeException&)
- {
- aIterator.remove();
- }
+ ChangesEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Base <<= aEvent.Source;
+ aEvent.Changes.realloc( 1 );
+ aEvent.Changes[ 0 ].Accessor <<= aName;
+ aEvent.Changes[ 0 ].Element <<= aElement;
+ aEvent.Changes[ 0 ].ReplacedElement = aOldElement;
+ maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
}
}
@@ -211,33 +209,35 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement )
mHashMap[ aName ] = nCount;
mnElementCount++;
-
// Fire event
- ContainerEvent aEvent;
- aEvent.Source = mpxEventSource;
- aEvent.Accessor <<= aName;
- aEvent.Element = aElement;
+ if( maContainerListeners.getLength() > 0 )
+ {
+ ContainerEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Accessor <<= aName;
+ aEvent.Element = aElement;
+ maContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
+ }
- OInterfaceIteratorHelper aIterator( maListenerContainer );
- while( aIterator.hasMoreElements() )
+ /* After the container event has been fired (one listener will update the
+ core Basic manager), fire change event. Listeners can rely that the
+ Basic source code of the core Basic manager is up-to-date. */
+ if( maChangesListeners.getLength() > 0 )
{
- Reference< XInterface > xIface = aIterator.next();
- Reference< XContainerListener > xListener( xIface, UNO_QUERY );
- try
- {
- xListener->elementInserted( aEvent );
- }
- catch(RuntimeException&)
- {
- aIterator.remove();
- }
+ ChangesEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Base <<= aEvent.Source;
+ aEvent.Changes.realloc( 1 );
+ aEvent.Changes[ 0 ].Accessor <<= aName;
+ aEvent.Changes[ 0 ].Element <<= aElement;
+ maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
}
}
-void NameContainer::removeByName( const OUString& Name )
+void NameContainer::removeByName( const OUString& aName )
throw(NoSuchElementException, WrappedTargetException, RuntimeException)
{
- NameContainerNameMap::iterator aIt = mHashMap.find( Name );
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
if( aIt == mHashMap.end() )
{
throw NoSuchElementException();
@@ -259,26 +259,29 @@ void NameContainer::removeByName( const OUString& Name )
mValues.realloc( iLast );
mnElementCount--;
-
// Fire event
- ContainerEvent aEvent;
- aEvent.Source = mpxEventSource;
- aEvent.Accessor <<= Name;
- aEvent.Element = aOldElement;
+ if( maContainerListeners.getLength() > 0 )
+ {
+ ContainerEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Accessor <<= aName;
+ aEvent.Element = aOldElement;
+ maContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent );
+ }
- OInterfaceIteratorHelper aIterator( maListenerContainer );
- while( aIterator.hasMoreElements() )
+ /* After the container event has been fired (one listener will update the
+ core Basic manager), fire change event. Listeners can rely that the
+ Basic source code of the core Basic manager is up-to-date. */
+ if( maChangesListeners.getLength() > 0 )
{
- Reference< XInterface > xIface = aIterator.next();
- Reference< XContainerListener > xListener( xIface, UNO_QUERY );
- try
- {
- xListener->elementRemoved( aEvent );
- }
- catch(RuntimeException&)
- {
- aIterator.remove();
- }
+ ChangesEvent aEvent;
+ aEvent.Source = mpxEventSource;
+ aEvent.Base <<= aEvent.Source;
+ aEvent.Changes.realloc( 1 );
+ aEvent.Changes[ 0 ].Accessor <<= aName;
+ // aEvent.Changes[ 0 ].Element remains empty (meaning "replaced with nothing")
+ aEvent.Changes[ 0 ].ReplacedElement = aOldElement;
+ maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
}
}
@@ -290,7 +293,7 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi
if( !xListener.is() )
throw RuntimeException();
Reference< XInterface > xIface( xListener, UNO_QUERY );
- maListenerContainer.addInterface( xIface );
+ maContainerListeners.addInterface( xIface );
}
void SAL_CALL NameContainer::removeContainerListener( const Reference< XContainerListener >& xListener )
@@ -299,7 +302,26 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine
if( !xListener.is() )
throw RuntimeException();
Reference< XInterface > xIface( xListener, UNO_QUERY );
- maListenerContainer.removeInterface( xIface );
+ maContainerListeners.removeInterface( xIface );
+}
+
+// Methods XChangesNotifier
+void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListener >& xListener )
+ throw (RuntimeException)
+{
+ if( !xListener.is() )
+ throw RuntimeException();
+ Reference< XInterface > xIface( xListener, UNO_QUERY );
+ maChangesListeners.addInterface( xIface );
+}
+
+void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesListener >& xListener )
+ throw (RuntimeException)
+{
+ if( !xListener.is() )
+ throw RuntimeException();
+ Reference< XInterface > xIface( xListener, UNO_QUERY );
+ maChangesListeners.removeInterface( xIface );
}
//============================================================================
@@ -320,12 +342,28 @@ void ModifiableHelper::setModified( sal_Bool _bModified )
//============================================================================
+VBAScriptListenerContainer::VBAScriptListenerContainer( ::osl::Mutex& rMutex ) :
+ VBAScriptListenerContainer_BASE( rMutex )
+{
+}
+
+bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent ) throw (Exception)
+{
+ rxListener->notifyVBAScriptEvent( rEvent );
+ return true; // notify all other listeners too
+}
+
+//============================================================================
+
// Implementation class SfxLibraryContainer
DBG_NAME( SfxLibraryContainer )
// Ctor
SfxLibraryContainer::SfxLibraryContainer( void )
- : LibraryContainerHelper( maMutex )
+ : SfxLibraryContainer_BASE( maMutex )
+
+ , maVBAScriptListeners( maMutex )
+ , mnRunningVBAScripts( 0 )
, mbVBACompat( sal_False )
, maModifiable( *this, maMutex )
, maNameContainer( getCppuType( (Reference< XNameAccess >*) NULL ) )
@@ -2649,6 +2687,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource )
// OComponentHelper
void SAL_CALL SfxLibraryContainer::disposing()
{
+ Reference< XModel > xModel = mxOwnerDocument;
+ EventObject aEvent( xModel.get() );
+ maVBAScriptListeners.disposing( aEvent );
stopAllComponentListening();
mxOwnerDocument = WeakReference< XModel >();
}
@@ -2838,7 +2879,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa
*/
if( mbVBACompat ) try
{
- Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
+ Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
}
@@ -2848,6 +2889,43 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa
}
}
+sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException)
+{
+ LibraryContainerMethodGuard aGuard( *this );
+ return mnRunningVBAScripts;
+}
+
+void SAL_CALL SfxLibraryContainer::addVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException)
+{
+ maVBAScriptListeners.addTypedListener( rxListener );
+}
+
+void SAL_CALL SfxLibraryContainer::removeVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException)
+{
+ maVBAScriptListeners.removeTypedListener( rxListener );
+}
+
+void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) throw (RuntimeException)
+{
+ // own lock for accessing the number of running scripts
+ enterMethod();
+ switch( nIdentifier )
+ {
+ case vba::VBAScriptEventId::SCRIPT_STARTED:
+ ++mnRunningVBAScripts;
+ break;
+ case vba::VBAScriptEventId::SCRIPT_STOPPED:
+ --mnRunningVBAScripts;
+ break;
+ }
+ leaveMethod();
+
+ Reference< XModel > xModel = mxOwnerDocument; // weak-ref -> ref
+ Reference< XInterface > xSender( xModel, UNO_QUERY_THROW );
+ vba::VBAScriptEvent aEvent( xSender, nIdentifier, rModuleName );
+ maVBAScriptListeners.notify( aEvent );
+}
+
// Methods XServiceInfo
::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName )
throw (RuntimeException)
@@ -2941,7 +3019,9 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType )
aRet = Any( ::cppu::queryInterface( rType,
static_cast< XContainer * >( this ),
static_cast< XNameContainer * >( this ),
- static_cast< XNameAccess * >( this ) ) );
+ static_cast< XNameAccess * >( this ),
+ static_cast< XElementAccess * >( this ),
+ static_cast< XChangesNotifier * >( this ) ) );
//}
if( !aRet.hasValue() )
aRet = OComponentHelper::queryInterface( rType );
@@ -3083,6 +3163,7 @@ Sequence< Type > SfxLibrary::getTypes()
static OTypeCollection s_aTypes_NameContainer(
::getCppuType( (const Reference< XNameContainer > *)0 ),
::getCppuType( (const Reference< XContainer > *)0 ),
+ ::getCppuType( (const Reference< XChangesNotifier > *)0 ),
OComponentHelper::getTypes() );
s_pTypes_NameContainer = &s_aTypes_NameContainer;
}
@@ -3110,9 +3191,6 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId()
}
}
-
-//============================================================================
-
// Methods XContainer
void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener )
throw (RuntimeException)
@@ -3127,6 +3205,19 @@ void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerLi
maNameContainer.removeContainerListener( xListener );
}
+// Methods XChangesNotifier
+void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener )
+ throw (RuntimeException)
+{
+ maNameContainer.setEventSource( static_cast< XInterface* >( (OWeakObject*)this ) );
+ maNameContainer.addChangesListener( xListener );
+}
+
+void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListener >& xListener )
+ throw (RuntimeException)
+{
+ maNameContainer.removeChangesListener( xListener );
+}
//============================================================================
// Implementation class ScriptExtensionIterator
diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk
index 31a4dcca8f8b..ae4456cbc923 100644
--- a/basic/util/makefile.mk
+++ b/basic/util/makefile.mk
@@ -66,6 +66,9 @@ SHL1STDLIBS= \
$(VOSLIB) \
$(XMLSCRIPTLIB)
+# Uncomment the following line if DBG_TRACE_PROFILING is active in source/inc/sbtrace.hxx
+# SHL1STDLIBS+=$(CANVASTOOLSLIB)
+
.IF "$(SOLAR_JAVA)" != "TRUE"
SHL1STDLIBS+=$(SJLIB)
.ENDIF
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index fd8e0d3fbcd7..a74fbabb271e 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -134,16 +134,20 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier";
static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider";
-static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
-
-const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10;
-const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7;
-const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23;
-const sal_Int32 LEN_DESCRIPTOR_LABEL = 5;
-const sal_Int32 LEN_DESCRIPTOR_TYPE = 4;
-const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16;
-const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16;
-static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5;
+static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
+static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
+static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled";
+
+static const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10;
+static const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7;
+static const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23;
+static const sal_Int32 LEN_DESCRIPTOR_LABEL = 5;
+static const sal_Int32 LEN_DESCRIPTOR_TYPE = 4;
+static const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16;
+static const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16;
+static const sal_Int32 LEN_DESCRIPTOR_STYLE = 5;
+static const sal_Int32 LEN_DESCRIPTOR_ISVISIBLE = 9;
+static const sal_Int32 LEN_DESCRIPTOR_ENABLED = 7;
const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500;
@@ -1757,6 +1761,8 @@ void MenuBarManager::FillMenu(
rtl::OUString aLabel;
rtl::OUString aHelpURL;
rtl::OUString aModuleIdentifier( rModuleIdentifier );
+ sal_Bool bShow(sal_True);
+ sal_Bool bEnabled(sal_True);
sal_uInt16 nType = 0;
Reference< XIndexAccess > xIndexContainer;
Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider );
@@ -1768,29 +1774,26 @@ void MenuBarManager::FillMenu(
for ( int i = 0; i < aProp.getLength(); i++ )
{
rtl::OUString aPropName = aProp[i].Name;
- if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL,
- LEN_DESCRIPTOR_COMMANDURL ))
+ if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, LEN_DESCRIPTOR_COMMANDURL ))
aProp[i].Value >>= aCommandURL;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL,
- LEN_DESCRIPTOR_HELPURL ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, LEN_DESCRIPTOR_HELPURL ))
aProp[i].Value >>= aHelpURL;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER,
- LEN_DESCRIPTOR_CONTAINER ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, LEN_DESCRIPTOR_CONTAINER ))
aProp[i].Value >>= xIndexContainer;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL,
- LEN_DESCRIPTOR_LABEL ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, LEN_DESCRIPTOR_LABEL ))
aProp[i].Value >>= aLabel;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE,
- LEN_DESCRIPTOR_TYPE ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, LEN_DESCRIPTOR_TYPE ))
aProp[i].Value >>= nType;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER,
- LEN_DESCRIPTOR_MODULEIDENTIFIER ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, LEN_DESCRIPTOR_MODULEIDENTIFIER ))
aProp[i].Value >>= aModuleIdentifier;
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER,
- LEN_DESCRIPTOR_DISPATCHPROVIDER ))
+ else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, LEN_DESCRIPTOR_DISPATCHPROVIDER ))
aProp[i].Value >>= xDispatchProvider;
- else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN ))
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, LEN_DESCRIPTOR_STYLE ))
aProp[i].Value >>= nStyle;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ISVISIBLE, LEN_DESCRIPTOR_ISVISIBLE ))
+ aProp[i].Value >>= bShow;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ENABLED, LEN_DESCRIPTOR_ENABLED ))
+ aProp[i].Value >>= bEnabled;
}
if ( nType == ::com::sun::star::ui::ItemType::DEFAULT )
@@ -1809,6 +1812,17 @@ void MenuBarManager::FillMenu(
nBits |= MIB_RADIOCHECK;
pMenu->SetItemBits( nId, nBits );
}
+
+ if ( bShow )
+ pMenu->ShowItem( nId );
+ else
+ pMenu->HideItem( nId );
+
+ if ( bEnabled)
+ pMenu->EnableItem( nId, sal_True );
+ else
+ pMenu->EnableItem( nId, sal_False );
+
if ( xIndexContainer.is() )
{
PopupMenu* pNewPopupMenu = new PopupMenu;
diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl
index 1291276ae643..3d0e6c9ce0f5 100644
--- a/oovbaapi/ooo/vba/XApplicationBase.idl
+++ b/oovbaapi/ooo/vba/XApplicationBase.idl
@@ -45,7 +45,6 @@ interface XApplicationBase
[attribute, readonly] string Version;
[attribute, readonly] any VBE;
- [attribute, readonly] any VBProjects;
void Quit();
diff --git a/oovbaapi/ooo/vba/XCollectionBase.idl b/oovbaapi/ooo/vba/XCollectionBase.idl
new file mode 100755
index 000000000000..245b252f7856
--- /dev/null
+++ b/oovbaapi/ooo/vba/XCollectionBase.idl
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * Copyright 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ ************************************************************************/
+
+#ifndef OOO_VBA_XOLLECTIONBASE_IDL
+#define OOO_VBA_XOLLECTIONBASE_IDL
+
+#include <com/sun/star/container/XEnumerationAccess.idl>
+#include <com/sun/star/script/XDefaultMethod.idl>
+
+//=============================================================================
+
+module ooo { module vba {
+
+//=============================================================================
+
+/** Base interface for VBA collections.
+
+ Every VBA collection provides the number of items, an enumeration access of
+ all collection items (e.g. for the "For Each" loop), and a way to access
+ single items, usually via the method "Item".
+
+ The various VBA collection objects expect a specific number of arguments in
+ the "Item" method, therefore this method is not part of this base interface
+ but has to be specified seperately in every derived interface.
+ */
+interface XCollectionBase
+{
+ //-------------------------------------------------------------------------
+ /** Provides an enumeration of all items in this collection.
+ */
+ interface ::com::sun::star::container::XEnumerationAccess;
+
+ //-------------------------------------------------------------------------
+ /** Provides the name of the default item access method.
+
+ Usually this method is called "Item". The access method has to be
+ specified and implemented separately by every derived class.
+ */
+ interface ::com::sun::star::script::XDefaultMethod;
+
+ //-------------------------------------------------------------------------
+ /** Returns the number of items contained in this collection.
+ */
+ [attribute, readonly] long Count;
+
+ //-------------------------------------------------------------------------
+};
+
+//=============================================================================
+
+}; };
+
+#endif
diff --git a/oovbaapi/ooo/vba/XControlProvider.idl b/oovbaapi/ooo/vba/XControlProvider.idl
index 23f890d5a1c3..df8b53bdfc72 100644
--- a/oovbaapi/ooo/vba/XControlProvider.idl
+++ b/oovbaapi/ooo/vba/XControlProvider.idl
@@ -51,8 +51,6 @@ module ooo { module vba {
interface XControlProvider
{
::ooo::vba::msforms::XControl createControl( [in] ::com::sun::star::drawing::XControlShape xControl, [in] ::com::sun::star::frame::XModel xDocOwner );
- ::ooo::vba::msforms::XControl createUserformControl( [in] ::com::sun::star::awt::XControl xControl, [in] ::com::sun::star::awt::XControl xDialog, [in] ::com::sun::star::frame::XModel xDocOwner );
-
};
}; };
diff --git a/oovbaapi/ooo/vba/XExecutableDialog.idl b/oovbaapi/ooo/vba/XExecutableDialog.idl
new file mode 100755
index 000000000000..8754c8071348
--- /dev/null
+++ b/oovbaapi/ooo/vba/XExecutableDialog.idl
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __ooo_vba_XExecutableDialog_idl__
+#define __ooo_vba_XExecutableDialog_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+//=============================================================================
+
+module ooo { module vba {
+
+/** The VBA equivalent to the UNO interface
+ <type scope="com::sun::star::ui::dialogs">XExecutableDialog</type>.
+ */
+interface XExecutableDialog
+{
+ /** Executes the dialog.
+
+ @return
+ The return value is dependent on the calling context. Usually, on
+ cancelling the dialog the implementation will return <FALSE/>,
+ otherwise the return value will contain the expected result.
+ */
+ any execute();
+};
+
+//=============================================================================
+
+}; };
+
+#endif
+
+
diff --git a/oovbaapi/ooo/vba/excel/SheetObjects.idl b/oovbaapi/ooo/vba/excel/SheetObjects.idl
index 5947c52ff4a0..0a2a3fd9ffe9 100644
--- a/oovbaapi/ooo/vba/excel/SheetObjects.idl
+++ b/oovbaapi/ooo/vba/excel/SheetObjects.idl
@@ -74,10 +74,10 @@ interface XGraphicObjects : com::sun::star::uno::XInterface
/** Adds a new graphic object to the sheet this collection belongs to. The
type of the object is determined by the type of the collection.
- @param fLeft Position of the left border in points (1/72 inch).
- @param fTop Position of the top border in points (1/72 inch).
- @param fWidth Width of the object in points (1/72 inch).
- @param fHeight Height of the object in points (1/72 inch).
+ @param Left Position of the left border in points (1/72 inch).
+ @param Top Position of the top border in points (1/72 inch).
+ @param Width Width of the object in points (1/72 inch).
+ @param Height Height of the object in points (1/72 inch).
@return The created graphic object.
*/
@@ -102,10 +102,10 @@ interface XLineObjects : com::sun::star::uno::XInterface
/** Adds a new line object to the sheet this collection belongs to. The
type of the object is determined by the type of the collection.
- @param fX1 Position of the first X coordinate in points (1/72 inch).
- @param fY1 Position of the first Y coordinate in points (1/72 inch).
- @param fX2 Position of the last X coordinate in points (1/72 inch).
- @param fY2 Position of the last Y coordinate in points (1/72 inch).
+ @param X1 Position of the first X coordinate in points (1/72 inch).
+ @param Y1 Position of the first Y coordinate in points (1/72 inch).
+ @param X2 Position of the last X coordinate in points (1/72 inch).
+ @param Y2 Position of the last Y coordinate in points (1/72 inch).
@return The created line object.
*/
@@ -123,11 +123,11 @@ interface XDrawings : com::sun::star::uno::XInterface
{
/** Adds a new polygon object to the sheet this collection belongs to.
- @param fX1 Position of the first X coordinate in points (1/72 inch).
- @param fY1 Position of the first Y coordinate in points (1/72 inch).
- @param fX2 Position of the last X coordinate in points (1/72 inch).
- @param fY2 Position of the last Y coordinate in points (1/72 inch).
- @param bClosed True = outline closed (last and first point connected).
+ @param X1 Position of the first X coordinate in points (1/72 inch).
+ @param Y1 Position of the first Y coordinate in points (1/72 inch).
+ @param X2 Position of the last X coordinate in points (1/72 inch).
+ @param Y2 Position of the last Y coordinate in points (1/72 inch).
+ @param Closed True = outline closed (last and first point connected).
@return The created polygon object.
*/
diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index 5ec821dbe8bb..267c9589bfae 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -64,15 +64,12 @@ interface XApplication
[attribute] any CutCopyMode;
[attribute] any StatusBar;
[attribute] long Cursor;
- [attribute] boolean EnableEvents;
+ [attribute] boolean EnableEvents;
+ [attribute] string DefaultFilePath;
+ [attribute, readonly] string LibraryPath;
+ [attribute, readonly] string TemplatesPath;
+ [attribute, readonly] string PathSeparator;
- void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException);
-
- string getDefaultFilePath() raises(com::sun::star::script::BasicErrorException);
-
- string LibraryPath() raises(com::sun::star::script::BasicErrorException);
- string TemplatesPath() raises(com::sun::star::script::BasicErrorException);
- string PathSeparator() raises(com::sun::star::script::BasicErrorException);
//any CommandBars( [in] any Index );
any Workbooks( [in] any Index );
any Worksheets( [in] any Index );
@@ -93,10 +90,10 @@ interface XApplication
void Volatile([in] any Volatile);
void DoEvents();
any Caller( [in] any Index );
+ any GetOpenFilename( [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText, [in] any MultiSelect );
+ any GetSaveAsFilename( [in] any InitialFileName, [in] any FileFilter, [in] any FilterIndex, [in] any Title, [in] any ButtonText );
};
}; }; };
#endif
-
-
diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk
index 4f6d378cfe3f..d1adc1c4252e 100644
--- a/oovbaapi/ooo/vba/makefile.mk
+++ b/oovbaapi/ooo/vba/makefile.mk
@@ -39,6 +39,7 @@ PACKAGE=ooo$/vba
IDLFILES=\
XErrObject.idl \
XCollection.idl\
+ XCollectionBase.idl\
XVBAToOOEventDescGen.idl\
XPropValue.idl\
XHelperInterface.idl\
@@ -58,6 +59,7 @@ IDLFILES=\
XGlobalsBase.idl\
XDocumentProperty.idl\
XDocumentProperties.idl\
+ XExecutableDialog.idl\
XFontBase.idl\
XDialogsBase.idl\
XDialogBase.idl\
diff --git a/oovbaapi/ooo/vba/msforms/XButton.idl b/oovbaapi/ooo/vba/msforms/XCheckBox.idl
index 24cf1ba26c60..7520a559b0d5 100644..100755
--- a/oovbaapi/ooo/vba/msforms/XButton.idl
+++ b/oovbaapi/ooo/vba/msforms/XCheckBox.idl
@@ -24,20 +24,23 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#ifndef __ooo_vba_msforms_XButton_idl__
-#define __ooo_vba_msforms_XButton_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#ifndef __ooo_vba_msforms_XCheckBox_idl__
+#define __ooo_vba_msforms_XCheckBox_idl__
+
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
//=============================================================================
-interface XButton: com::sun::star::uno::XInterface
+
+interface XCheckBox
{
[attribute] string Caption;
+ [attribute] any Value;
+ [attribute, readonly] XNewFont Font;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl
index 5f2b66431eb8..d4e57b2347a4 100644
--- a/oovbaapi/ooo/vba/msforms/XComboBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl
@@ -24,26 +24,32 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XComboBox_idl__
#define __ooo_vba_msforms_XComboBox_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
-
+#include <ooo/vba/msforms/XNewFont.idl>
//=============================================================================
module ooo { module vba { module msforms {
-
//=============================================================================
-interface XComboBox: ::com::sun::star::uno::XInterface
+
+interface XComboBox
{
[attribute] any Value;
[attribute] any ListIndex;
- [attribute, readonly ] long ListCount;
+ [attribute, readonly] long ListCount;
[attribute] string Text;
+ [attribute] long Style;
+ [attribute] long DropButtonStyle;
+ [attribute] long DragBehavior;
+ [attribute] long EnterFieldBehavior;
+ [attribute] long ListStyle;
+ [attribute] long TextAlign;
+ [attribute, readonly] XNewFont Font;
+
void AddItem( [in] any pvargItem, [in] any pvargIndex );
void removeItem( [in] any index );
void Clear();
diff --git a/oovbaapi/ooo/vba/msforms/XCommandButton.idl b/oovbaapi/ooo/vba/msforms/XCommandButton.idl
new file mode 100644
index 000000000000..0e7697cbd162
--- /dev/null
+++ b/oovbaapi/ooo/vba/msforms/XCommandButton.idl
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __ooo_vba_msforms_XCommandButton_idl__
+#define __ooo_vba_msforms_XCommandButton_idl__
+
+#include <ooo/vba/msforms/XNewFont.idl>
+
+//=============================================================================
+
+module ooo { module vba { module msforms {
+
+//=============================================================================
+
+interface XCommandButton
+{
+ [attribute] string Caption;
+ [attribute] boolean AutoSize;
+ [attribute] boolean Cancel;
+ [attribute] boolean Default;
+ [attribute] long BackColor;
+ [attribute] long ForeColor;
+ [attribute, readonly] XNewFont Font;
+};
+
+//=============================================================================
+
+}; }; };
+
+#endif
+
+
diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 97ca9d152716..3cd1f2c3e75c 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -63,6 +63,7 @@ interface XControl
[attribute] string Name;
[attribute] string ControlTipText;
[attribute] string Tag;
+ [attribute] long TabIndex;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XFrame.idl b/oovbaapi/ooo/vba/msforms/XFrame.idl
new file mode 100755
index 000000000000..6038b61dd3bd
--- /dev/null
+++ b/oovbaapi/ooo/vba/msforms/XFrame.idl
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __ooo_vba_msforms_XFrame_idl__
+#define __ooo_vba_msforms_XFrame_idl__
+
+#include <ooo/vba/msforms/XNewFont.idl>
+
+//=============================================================================
+
+module ooo { module vba { module msforms {
+
+//=============================================================================
+
+interface XFrame
+{
+ [attribute] string Caption;
+ [attribute] long SpecialEffect;
+ [attribute] long BorderStyle;
+ [attribute, readonly] XNewFont Font;
+
+ any Controls( [in] any Index );
+};
+
+//=============================================================================
+
+}; }; };
+
+//=============================================================================
+
+#endif
diff --git a/oovbaapi/ooo/vba/msforms/XGroupBox.idl b/oovbaapi/ooo/vba/msforms/XGroupBox.idl
index 9ed6f9d45046..9718f23e1c66 100644
--- a/oovbaapi/ooo/vba/msforms/XGroupBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XGroupBox.idl
@@ -24,19 +24,22 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XGroupBox_idl__
#define __ooo_vba_msforms_XGroupBox_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
+
//=============================================================================
+
interface XGroupBox
{
[attribute] string Caption;
+ [attribute, readonly] XNewFont Font;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XLabel.idl b/oovbaapi/ooo/vba/msforms/XLabel.idl
index d757af5074d8..399127a091c8 100644
--- a/oovbaapi/ooo/vba/msforms/XLabel.idl
+++ b/oovbaapi/ooo/vba/msforms/XLabel.idl
@@ -24,21 +24,23 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XLabel_idl__
#define __ooo_vba_msforms_XLabel_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
//=============================================================================
-interface XLabel: com::sun::star::uno::XInterface
+
+interface XLabel
{
[attribute] string Caption;
[attribute] any Value;
+ [attribute, readonly] XNewFont Font;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XListBox.idl b/oovbaapi/ooo/vba/msforms/XListBox.idl
index bdc0c6bfc660..63f9cce0bdf8 100644
--- a/oovbaapi/ooo/vba/msforms/XListBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XListBox.idl
@@ -24,25 +24,27 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XListBox_idl__
#define __ooo_vba_msforms_XListBox_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
-
//=============================================================================
-interface XListBox: com::sun::star::uno::XInterface
+
+interface XListBox
{
[attribute] any Value;
[attribute] string Text;
[attribute] boolean MultiSelect;
[attribute] any ListIndex;
- [attribute, readonly ] long ListCount;
+ [attribute, readonly] long ListCount;
+ [attribute, readonly] XNewFont Font;
+
void AddItem( [in] any pvargItem, [in] any pvargIndex );
void removeItem( [in] any index );
void Clear();
diff --git a/oovbaapi/ooo/vba/msforms/XNewFont.idl b/oovbaapi/ooo/vba/msforms/XNewFont.idl
new file mode 100755
index 000000000000..755dd510b63a
--- /dev/null
+++ b/oovbaapi/ooo/vba/msforms/XNewFont.idl
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __ooo_vba_msforms_XNewFont_idl__
+#define __ooo_vba_msforms_XNewFont_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+//=============================================================================
+
+module ooo { module vba { module msforms {
+
+//=============================================================================
+
+interface XNewFont
+{
+ [attribute] string Name;
+ [attribute] double Size;
+ [attribute] short Charset;
+ [attribute] short Weight;
+ [attribute] boolean Bold;
+ [attribute] boolean Italic;
+ [attribute] boolean Underline;
+ [attribute] boolean Strikethrough;
+};
+
+//=============================================================================
+
+}; }; };
+
+//=============================================================================
+
+#endif
diff --git a/oovbaapi/ooo/vba/msforms/XRadioButton.idl b/oovbaapi/ooo/vba/msforms/XRadioButton.idl
index b2289ce33331..2aced0e92e30 100644
--- a/oovbaapi/ooo/vba/msforms/XRadioButton.idl
+++ b/oovbaapi/ooo/vba/msforms/XRadioButton.idl
@@ -24,21 +24,23 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XRadioButton_idl__
#define __ooo_vba_msforms_XRadioButton_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
//=============================================================================
-interface XRadioButton: com::sun::star::uno::XInterface
+
+interface XRadioButton
{
[attribute] string Caption;
[attribute] any Value;
+ [attribute, readonly] XNewFont Font;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XTextBox.idl b/oovbaapi/ooo/vba/msforms/XTextBox.idl
index 9c6b55e5ca6d..7ea6ca62898c 100644
--- a/oovbaapi/ooo/vba/msforms/XTextBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XTextBox.idl
@@ -24,23 +24,27 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XTextBox_idl__
#define __ooo_vba_msforms_XTextBox_idl__
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XNewFont.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
//=============================================================================
-interface XTextBox: com::sun::star::uno::XInterface
+
+interface XTextBox
{
[attribute] string Text;
[attribute] any Value;
[attribute] long MaxLength;
[attribute] boolean Multiline;
+ [attribute] long SpecialEffect;
+ [attribute] long BorderStyle;
+ [attribute, readonly] XNewFont Font;
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XToggleButton.idl b/oovbaapi/ooo/vba/msforms/XToggleButton.idl
index e66eea54babb..923f7e1e2203 100644
--- a/oovbaapi/ooo/vba/msforms/XToggleButton.idl
+++ b/oovbaapi/ooo/vba/msforms/XToggleButton.idl
@@ -24,22 +24,21 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef __ooo_vba_msforms_XToggleButton_idl__
#define __ooo_vba_msforms_XToggleButton_idl__
-#ifndef __ooo_vba_msforms_XButton_idl__
-#include <ooo/vba/msforms/XButton.idl>
-#endif
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
+#include <ooo/vba/msforms/XCommandButton.idl>
+
//=============================================================================
module ooo { module vba { module msforms {
+
//=============================================================================
+
interface XToggleButton
{
- interface XButton;
+ interface XCommandButton;
[attribute] any Value;
};
diff --git a/oovbaapi/ooo/vba/msforms/XUserForm.idl b/oovbaapi/ooo/vba/msforms/XUserForm.idl
index c06aa2902b53..1e54dd1b8f41 100644
--- a/oovbaapi/ooo/vba/msforms/XUserForm.idl
+++ b/oovbaapi/ooo/vba/msforms/XUserForm.idl
@@ -39,6 +39,8 @@ interface XUserForm
//interface ::ooo::vba::XHelperInterface;
interface ::com::sun::star::script::XInvocation;
[attribute] string Caption;
+ [attribute] double InnerWidth;
+ [attribute] double InnerHeight;
void Show();
void Hide();
void RePaint();
diff --git a/oovbaapi/ooo/vba/msforms/makefile.mk b/oovbaapi/ooo/vba/msforms/makefile.mk
index 56ac4caf87cb..1d7d9ee166e5 100644
--- a/oovbaapi/ooo/vba/msforms/makefile.mk
+++ b/oovbaapi/ooo/vba/msforms/makefile.mk
@@ -38,10 +38,13 @@ PACKAGE=ooo$/vba$/msforms
IDLFILES=\
MSFormReturnTypes.idl \
+ XCheckBox.idl \
XComboBox.idl \
- XButton.idl \
+ XCommandButton.idl \
XControl.idl \
+ XFrame.idl \
XLabel.idl \
+ XNewFont.idl \
XTextBox.idl \
XRadioButton.idl \
XShape.idl \
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 6c3694ea237d..ab2b52ae7d55 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -45,14 +45,13 @@
#include <com/sun/star/script/provider/XScriptProvider.hpp>
#include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <com/sun/star/lang/NoSuchMethodException.hpp>
#include <com/sun/star/reflection/XIdlMethod.hpp>
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/beans/XMaterialHolder.hpp>
#include <ooo/vba/XVBAToOOEventDescGen.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <vbahelper/vbaaccesshelper.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::awt;
@@ -175,19 +174,17 @@ namespace dlgprov
// handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" )
listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode );
listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel );
- // Note: in a future cws ( npower13_ObjectModule ) it will be possible
- // to determine the vba mode from the basiclibrary container, the tunnel hack
- // below can then be replaced
- SfxObjectShell* pFoundShell = NULL;
- if ( rxModel.is() )
+
+ // determine the VBA compatibility mode from the Basic library container
+ try
+ {
+ uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< script::vba::XVBACompatibility > xVBACompat(
+ xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW );
+ mbUseFakeVBAEvents = xVBACompat->getVBACompatibilityMode();
+ }
+ catch( uno::Exception& )
{
- uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY );
- if ( xObjShellTunnel.is() )
- {
- pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
- if ( pFoundShell )
- mbUseFakeVBAEvents = ooo::vba::isAlienExcelDoc( *pFoundShell );
- }
}
if ( mbUseFakeVBAEvents )
listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel );
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 3da1f374af1c..19169e90b984 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -29,6 +29,7 @@
#include "precompiled_sfx2.hxx"
#include "arrdecl.hxx"
+#include <map>
#include <cppuhelper/implbase1.hxx>
@@ -41,15 +42,9 @@
#include <com/sun/star/frame/XTitle.hpp>
#include <vos/mutex.hxx>
-#ifndef _SV_RESARY_HXX
#include <tools/resary.hxx>
-#endif
-#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
-#endif
-#ifndef _WRKWIN_HXX //autogen
#include <vcl/wrkwin.hxx>
-#endif
#include <vcl/svapp.hxx>
#include <svl/eitem.hxx>
#include <tools/rtti.hxx>
@@ -64,15 +59,11 @@
#include <sfx2/signaturestate.hxx>
#include <sfx2/sfxmodelfactory.hxx>
-#ifndef _BASIC_SBUNO_HXX
#include <basic/sbuno.hxx>
-#endif
#include <svtools/sfxecode.hxx>
#include <svtools/ehdl.hxx>
#include <unotools/printwarningoptions.hxx>
-#ifndef _UNOTOOLS_PROCESSFACTORY_HXX
#include <comphelper/processfactory.hxx>
-#endif
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
@@ -132,8 +123,37 @@ DBG_NAME(SfxObjectShell)
#define DocumentInfo
#include "sfxslots.hxx"
+namespace {
+
static WeakReference< XInterface > s_xCurrentComponent;
+// remember all registered components for VBA compatibility, to be able to remove them on disposing the model
+typedef ::std::map< XInterface*, ::rtl::OString > VBAConstantNameMap;
+static VBAConstantNameMap s_aRegisteredVBAConstants;
+
+::rtl::OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent )
+{
+ OSL_ENSURE( rxComponent.is(), "lclGetVBAGlobalConstName - missing component" );
+
+ VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( rxComponent.get() );
+ if( aIt != s_aRegisteredVBAConstants.end() )
+ return aIt->second;
+
+ uno::Reference< beans::XPropertySet > xProps( rxComponent, uno::UNO_QUERY );
+ if( xProps.is() ) try
+ {
+ ::rtl::OUString aConstName;
+ xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobalConstantName" ) ) ) >>= aConstName;
+ return ::rtl::OUStringToOString( aConstName, RTL_TEXTENCODING_ASCII_US );
+ }
+ catch( uno::Exception& ) // not supported
+ {
+ }
+ return ::rtl::OString();
+}
+
+} // namespace
+
//=========================================================================
@@ -164,14 +184,29 @@ void SAL_CALL SfxModelListener_Impl::notifyClosing( const com::sun::star::lang::
void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::EventObject& _rEvent ) throw ( com::sun::star::uno::RuntimeException )
{
- // am I ThisComponent in AppBasic?
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+
+ // am I ThisComponent in AppBasic?
if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source )
{
// remove ThisComponent reference from AppBasic
SfxObjectShell::SetCurrentComponent( Reference< XInterface >() );
}
+ /* Remove VBA component from AppBasic. As every application registers its
+ own current component, the disposed component may not be the "current
+ component" of the SfxObjectShell. */
+ if ( _rEvent.Source.is() )
+ {
+ VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( _rEvent.Source.get() );
+ if ( aIt != s_aRegisteredVBAConstants.end() )
+ {
+ if ( BasicManager* pAppMgr = SFX_APP()->GetBasicManager() )
+ pAppMgr->SetGlobalUNOConstant( aIt->second.getStr(), Any( Reference< XInterface >() ) );
+ s_aRegisteredVBAConstants.erase( aIt );
+ }
+ }
+
if ( !mpDoc->Get_Impl()->bClosing )
// GCC stuerzt ab, wenn schon im dtor, also vorher Flag abfragen
mpDoc->DoClose();
@@ -908,8 +943,8 @@ sal_uInt16 SfxObjectShell::GetAutoStyleFilterIndex()
void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComponent )
{
- Reference< XInterface > xTest(s_xCurrentComponent);
- if ( _rxComponent == xTest )
+ Reference< XInterface > xOldCurrentComp(s_xCurrentComponent);
+ if ( _rxComponent == xOldCurrentComp )
// nothing to do
return;
// note that "_rxComponent.get() == s_xCurrentComponent.get().get()" is /sufficient/, but not
@@ -920,7 +955,31 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
s_xCurrentComponent = _rxComponent;
if ( pAppMgr )
- pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) );
+ {
+ // set "ThisComponent" for Basic
+ pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) );
+
+ // set new current component for VBA compatibility
+ if ( _rxComponent.is() )
+ {
+ ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent );
+ if ( aVBAConstName.getLength() > 0 )
+ {
+ pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( _rxComponent ) );
+ s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName;
+ }
+ }
+ // no new component passed -> remove last registered VBA component
+ else if ( xOldCurrentComp.is() )
+ {
+ ::rtl::OString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp );
+ if ( aVBAConstName.getLength() > 0 )
+ {
+ pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( Reference< XInterface >() ) );
+ s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() );
+ }
+ }
+ }
}
Reference< XInterface > SfxObjectShell::GetCurrentComponent()
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk
index 3e23c492f32b..58a90a7ccd42 100755
--- a/vbahelper/Library_msforms.mk
+++ b/vbahelper/Library_msforms.mk
@@ -50,17 +50,17 @@ $(eval $(call gb_Library_add_linked_libs,msforms,\
comphelper \
cppu \
cppuhelper \
+ sal \
+ sb \
+ sfx \
svl \
svt \
+ svx \
+ stl \
+ tk \
tl \
- sal \
vbahelper \
- sfx \
- svx \
vcl \
- tk \
- sb \
- stl \
$(gb_STDLIBS) \
))
@@ -79,6 +79,7 @@ $(eval $(call gb_Library_add_exception_objects,msforms,\
vbahelper/source/msforms/vbalistbox \
vbahelper/source/msforms/vbalistcontrolhelper \
vbahelper/source/msforms/vbamultipage \
+ vbahelper/source/msforms/vbanewfont \
vbahelper/source/msforms/vbapages \
vbahelper/source/msforms/vbaprogressbar \
vbahelper/source/msforms/vbaradiobutton \
diff --git a/vbahelper/Library_vbahelper.mk b/vbahelper/Library_vbahelper.mk
index 722b66d709a1..af6b4089ada8 100755
--- a/vbahelper/Library_vbahelper.mk
+++ b/vbahelper/Library_vbahelper.mk
@@ -50,25 +50,27 @@ $(eval $(call gb_Library_set_defs,vbahelper,\
# add libraries to be linked to vbahelper; again these names need to be given as
# specified in Repository.mk
$(eval $(call gb_Library_add_linked_libs,vbahelper,\
+ comphelper \
cppu \
cppuhelper \
- comphelper \
- sb \
- tl \
+ msfilter \
sal \
+ sb \
sfx \
stl \
- svt \
- vcl \
svl \
- msfilter \
+ svt \
tk \
+ tl \
+ utl \
+ vcl \
$(gb_STDLIBS) \
))
# add all source files that shall be compiled with exceptions enabled
# the name is relative to $(SRCROOT) and must not contain an extension
$(eval $(call gb_Library_add_exception_objects,vbahelper,\
+ vbahelper/source/vbahelper/collectionbase \
vbahelper/source/vbahelper/vbaapplicationbase \
vbahelper/source/vbahelper/vbacolorformat \
vbahelper/source/vbahelper/vbacommandbar \
diff --git a/vbahelper/Package_inc.mk b/vbahelper/Package_inc.mk
index 6d8033aa5b02..385fbf15a625 100755
--- a/vbahelper/Package_inc.mk
+++ b/vbahelper/Package_inc.mk
@@ -26,6 +26,7 @@
#*************************************************************************
$(eval $(call gb_Package_Package,vbahelper_inc,$(SRCDIR)/vbahelper/inc))
+$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/collectionbase.hxx,vbahelper/collectionbase.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/helperdecl.hxx,vbahelper/helperdecl.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaaccesshelper.hxx,vbahelper/vbaaccesshelper.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaapplicationbase.hxx,vbahelper/vbaapplicationbase.hxx))
@@ -47,5 +48,6 @@ $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashaperange.hxx,
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashapes.hxx,vbahelper/vbashapes.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbatextframe.hxx,vbahelper/vbatextframe.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbawindowbase.hxx,vbahelper/vbawindowbase.hxx))
+$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/weakreference.hxx,vbahelper/weakreference.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/vbahelper/inc/vbahelper/collectionbase.hxx b/vbahelper/inc/vbahelper/collectionbase.hxx
new file mode 100755
index 000000000000..ebb5bf8f2b9a
--- /dev/null
+++ b/vbahelper/inc/vbahelper/collectionbase.hxx
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_COLLECTIONBASE_HXX
+#define VBAHELPER_COLLECTIONBASE_HXX
+
+#include <vector>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <ooo/vba/XCollectionBase.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbahelper.hxx>
+
+namespace vbahelper {
+
+// ============================================================================
+
+typedef ::cppu::WeakImplHelper1< ov::XCollectionBase > CollectionBase_BASE;
+
+/** Base class of VBA objects implementing the VBA collection concept.
+
+ This base class intentionally does not include the interface
+ XHelperInterface supported by all application VBA object. There may be
+ other VBA objects that do not support the special methods provided by
+ XHelperInterface.
+ */
+class VBAHELPER_DLLPUBLIC CollectionBase : public CollectionBase_BASE
+{
+public:
+ /** Enumerates different container types a VBA collection can be based on. */
+ enum ContainerType
+ {
+ /** Container elements are VBA items.
+
+ The initial container contains the final VBA items provided by the
+ VBA collection. No conversion takes place on item access.
+ */
+ CONTAINER_NATIVE_VBA,
+
+ /** Container elements will be converted to VBA items on demand.
+
+ The initial container contains intermediate objects (e.g. UNO
+ objects) which will be converted to VBA items everytime the item is
+ accessed (e.g. item access method, enumeration). Changes in the
+ initial container are reflected by the collection.
+ */
+ CONTAINER_CONVERT_ON_DEMAND,
+ };
+
+ // ------------------------------------------------------------------------
+
+ CollectionBase( const css::uno::Type& rElementType );
+
+ // ------------------------------------------------------------------------
+
+ // attributes
+ virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
+ // XDefaultMethod
+ virtual ::rtl::OUString SAL_CALL getDefaultMethodName() throw (css::uno::RuntimeException);
+
+ // ------------------------------------------------------------------------
+
+ /** Associates this collection with the passed UNO container.
+
+ @param rxElementAccess
+ The UNO container with the elements of this collection. Shall
+ support either XIndexAccess or XNameAccess, may support both.
+
+ If the container does not support XIndexAccess, index access is
+ simulated based on the order returned by the function
+ XNameAccess::getElementNames().
+
+ If the container does not support XNameAccess, name access is
+ simulated by iterating the elements via index access and asking the
+ elements for their name via the interface XNamed. If the elements
+ do not support XNamed, the elements cannot be accessed by name.
+
+ @param eContainerType
+ Specifies the type of the passed container.
+ */
+ void initContainer(
+ const css::uno::Reference< css::container::XElementAccess >& rxElementAccess,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Initializes this collection with copies of all elements in the passed
+ temporary STL vector.
+
+ @param rElements
+ The STL vector with the named elements of this collection.
+ @param eContainerType
+ Specifies the type of the passed vector.
+ */
+ void initElements(
+ const ::std::vector< css::uno::Reference< css::container::XNamed > >& rElements,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Initializes this collection with copies of all elements in the passed
+ temporary STL vector.
+
+ @param rElements
+ The STL vector with the named elements of this collection.
+ @param eContainerType
+ Specifies the type of the passed vector.
+ */
+ void initElements(
+ const ::std::vector< css::beans::NamedValue >& rElements,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Returns a VBA implementation object from the passed element.
+
+ If the container type is CONTAINER_NATIVE_VBA, returns the passed
+ object unmodified. If the container type is CONTAINER_CONVERT_ON_DEMAND,
+ calls the virtual function implCreateCollectionItem() that implements
+ creation of the VBA implmentation object.
+
+ @param rElement
+ The container element the VBA implementation object is based on.
+
+ @param rIndex
+ The index or name that has been used to access the item.
+ */
+ css::uno::Any createCollectionItem(
+ const css::uno::Any& rElement,
+ const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its one-based item index.
+
+ @param nIndex
+ The one-based index of the collection item.
+ */
+ css::uno::Any getItemByIndex( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its name.
+
+ @param rName
+ The name of the collection item.
+ */
+ css::uno::Any getItemByName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its index or name.
+
+ @param rIndex
+ The index or name of the collection item. May be empty, in that
+ case the entire collection is returned.
+ */
+ css::uno::Any getAnyItemOrThis( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item of a specific type specified by its index or
+ name.
+
+ @param rIndex
+ The index or name of the collection item.
+ */
+ template< typename XType >
+ inline css::uno::Reference< XType > getAnyItem( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException)
+ { css::uno::Any aRet; if( rIndex.hasValue() ) aRet = getAnyItemOrThis( rIndex ); return css::uno::Reference< XType >( aRet, css::uno::UNO_QUERY_THROW ); }
+
+protected:
+ /** Derived classes implement creation of a VBA implementation object from
+ the passed intermediate container element.
+
+ May be kept unimplemented if container type is CONTAINER_NATIVE_VBA.
+
+ @param rElement
+ The container element the VBA implementation object is based on.
+
+ @param rIndex
+ The index or name used to access the item. Can be used by
+ implementations as a hint how to find or convert the VBA object.
+ */
+ virtual css::uno::Any implCreateCollectionItem( const css::uno::Any& rElement, const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference< css::container::XIndexAccess > mxIndexAccess;
+ css::uno::Reference< css::container::XNameAccess > mxNameAccess;
+ css::uno::Type maElementType;
+ bool mbConvertOnDemand;
+};
+
+// ============================================================================
+
+} // namespace vbahelper
+
+#endif
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
index 6902bc7b5042..10cf0ba6ab70 100644
--- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
@@ -60,7 +60,6 @@ public:
virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException);
virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException);
virtual void SAL_CALL OnTime( const css::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
index 601d996a5e64..da0fd29267ae 100644
--- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
+++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
@@ -88,8 +88,8 @@ private:
/** A wrapper that holds a com.sun.star.container.XEnumeration or a
com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects.
- The method nextElement() needs to be implemented by the derived class. This
- class can be used to convert an enumeration or an index container
+ 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
diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx
index 2588b7da1720..d1c7320fbfb1 100644
--- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx
+++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx
@@ -37,6 +37,7 @@ 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; }
VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
index 659837535ace..dc554d6a043f 100755
--- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
@@ -28,20 +28,26 @@
#ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX
#define VBAHELPER_VBAEVENTSHELPERBASE_HXX
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
-#include <cppuhelper/implbase2.hxx>
-#include <map>
#include <deque>
+#include <hash_map>
+#include <map>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/util/XChangesListener.hpp>
+#include <cppuhelper/implbase3.hxx>
#include "vbahelper/vbahelper.hxx"
namespace com { namespace sun { namespace star {
+ namespace script { namespace vba { class XVBAModuleInfo; } }
namespace uno { class XComponentContext; }
} } }
// ============================================================================
-typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE;
+typedef ::cppu::WeakImplHelper3<
+ css::script::vba::XVBAEventProcessor,
+ css::document::XEventListener,
+ css::util::XChangesListener > VbaEventsHelperBase_BASE;
class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE
{
@@ -51,15 +57,24 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& xContext );
virtual ~VbaEventsHelperBase();
- // XVBAEventProcessor
+ // 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 void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, 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);
- // XEventListener
- virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (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(); }
@@ -72,12 +87,11 @@ public:
protected:
// ------------------------------------------------------------------------
- enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT };
struct EventHandlerInfo
{
sal_Int32 mnEventId;
+ sal_Int32 mnModuleType;
::rtl::OUString maMacroName;
- EventHandlerType meType;
sal_Int32 mnCancelIndex;
css::uno::Any maUserData;
};
@@ -85,14 +99,14 @@ protected:
/** 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 eType Document event or global event.
@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,
- EventHandlerType eType = EVENTHANDLER_DOCUMENT,
sal_Int32 nCancelIndex = -1,
const css::uno::Any& rUserData = css::uno::Any() );
@@ -124,7 +138,6 @@ protected:
virtual void implPostProcessEvent(
EventQueue& rEventQueue,
const EventHandlerInfo& rInfo,
- bool bSuccess,
bool bCancel ) throw (css::uno::RuntimeException) = 0;
/** Derived classes have to return the name of the Basic document module. */
@@ -133,25 +146,42 @@ protected:
const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0;
private:
+ typedef ::std::map< sal_Int32, ::rtl::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. */
::rtl::OUString getEventHandlerPath(
const EventHandlerInfo& rInfo,
- const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException);
+ const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
- /** Removes this instance from all broadcasters. */
- void stopListening();
+ /** 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 ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException);
+
+ /** Updates the map containing paths to event handlers for a Basic module. */
+ ModulePathMap& updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException);
protected:
css::uno::Reference< css::frame::XModel > mxModel;
SfxObjectShell* mpShell;
private:
- typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap;
+ typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap;
+ typedef ::std::hash_map< ::rtl::OUString, ModulePathMap, ::rtl::OUStringHash > EventHandlerPathMap;
- EventHandlerMap maEvents;
+ EventHandlerInfoMap maEventInfos;
+ EventHandlerPathMap maEventPaths;
+ css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos;
+ ::rtl::OUString maLibraryName;
bool mbDisposed;
};
diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx
index 22dc9a8f6cc8..bf20541eff1e 100644
--- a/vbahelper/inc/vbahelper/vbahelper.hxx
+++ b/vbahelper/inc/vbahelper/vbahelper.hxx
@@ -63,7 +63,12 @@ namespace ooo
throw css::lang::IllegalArgumentException();
return aSomething;
}
- VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell );
+
+ 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);
VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException);
@@ -90,18 +95,32 @@ namespace ooo
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* );
- /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value.
- Returns false, if the Any is empty or contains an incompatible type. */
- VBAHELPER_DLLPUBLIC bool extractBoolFromAny( bool& rbValue, const css::uno::Any& rAny );
- /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value.
+ /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value.
+ Throws, if the Any is empty or contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException);
+ /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value.
+ Returns nDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny, sal_Int32 nDefault ) throw (css::uno::RuntimeException);
+
+ /** 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 boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value.
+ Returns bDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny, bool bDefault ) 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 ::rtl::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 ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException);
VBAHELPER_DLLPUBLIC rtl::OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException );
VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic )
- VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical);
- VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
- VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical);
+ 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 >& );
@@ -135,14 +154,21 @@ class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace
{
public:
virtual ~AbstractGeometryAttributes() {}
- virtual double getLeft() = 0;
+ virtual double getLeft() const = 0;
virtual void setLeft( double ) = 0;
- virtual double getTop() = 0;
+ virtual double getTop() const = 0;
virtual void setTop( double ) = 0;
- virtual double getHeight() = 0;
+ virtual double getHeight() const = 0;
virtual void setHeight( double ) = 0;
- virtual double getWidth() = 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 {
@@ -156,20 +182,13 @@ protected:
public:
ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException );
- double getHeight();
-
- void setHeight(double _fheight) throw ( css::script::BasicErrorException );
-
- double getWidth();
-
+ double getHeight() const;
+ void setHeight(double _fheight) throw ( css::script::BasicErrorException );
+ double getWidth() const;
void setWidth(double _fWidth) throw ( css::script::BasicErrorException );
-
- double getLeft();
-
+ double getLeft() const;
void setLeft(double _fLeft);
-
- double getTop();
-
+ double getTop() const;
void setTop(double _fTop);
};
@@ -178,13 +197,13 @@ class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeom
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();
+ virtual double getLeft() const;
virtual void setLeft( double nLeft );
- virtual double getTop();
+ virtual double getTop() const;
virtual void setTop( double nTop );
- virtual double getHeight();
+ virtual double getHeight() const;
virtual void setHeight( double nHeight );
- virtual double getWidth();
+ virtual double getWidth() const;
virtual void setWidth( double nWidth);
virtual ~ConcreteXShapeGeometryAttributes();
};
@@ -195,19 +214,39 @@ public:
#define VBA_WIDTH "Width"
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;
-
-public:
- UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl );
- virtual double getLeft();
- virtual void setLeft( double nLeft );
- virtual double getTop();
- virtual void setTop( double nTop );
- virtual double getHeight();
- virtual void setHeight( double nHeight );
- virtual double getWidth();
- virtual void setWidth( double nWidth);
};
class VBAHELPER_DLLPUBLIC ContainerUtilities
@@ -230,8 +269,8 @@ public:
static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException );
};
- } // openoffice
-} // org
+ } // vba
+} // ooo
namespace ov = ooo::vba;
diff --git a/vbahelper/inc/vbahelper/vbawindowbase.hxx b/vbahelper/inc/vbahelper/vbawindowbase.hxx
index f42c2a19854e..e9f1d40e4bd4 100644
--- a/vbahelper/inc/vbahelper/vbawindowbase.hxx
+++ b/vbahelper/inc/vbahelper/vbawindowbase.hxx
@@ -24,24 +24,30 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef VBA_WINDOWBASE_HXX
#define VBA_WINDOWBASE_HXX
-#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/XWindowBase.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/awt/XDevice.hpp>
+#include <ooo/vba/XWindowBase.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/frame/XController.hpp>
#include <vbahelper/vbahelperinterface.hxx>
-typedef InheritedHelperInterfaceImpl1<ov::XWindowBase > WindowBaseImpl_BASE;
+typedef InheritedHelperInterfaceImpl1< ov::XWindowBase > WindowBaseImpl_BASE;
class VBAHELPER_DLLPUBLIC VbaWindowBase : public WindowBaseImpl_BASE
{
-protected:
- css::uno::Reference< css::frame::XModel > m_xModel;
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 );
- VbaWindowBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
+ 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) ;
@@ -58,6 +64,19 @@ public:
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> 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
diff --git a/vbahelper/inc/vbahelper/weakreference.hxx b/vbahelper/inc/vbahelper/weakreference.hxx
new file mode 100755
index 000000000000..661f3bc5d73e
--- /dev/null
+++ b/vbahelper/inc/vbahelper/weakreference.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_WEAKREFERENCE_HXX
+#define VBAHELPER_WEAKREFERENCE_HXX
+
+#include <cppuhelper/weakref.hxx>
+#include <rtl/ref.hxx>
+
+namespace vbahelper {
+
+// ============================================================================
+
+/** A weak reference holding any UNO implementation object.
+
+ The held object must implement the ::com::sun::star::uno::XWeak interface.
+
+ In difference to the ::com::sun::star::uno::WeakReference<> implementation
+ from cppuhelper/weakref.hxx, the class type of this weak reference is not
+ restricted to UNO interface types, but can be used for any C++ class type
+ implementing the XWeak interface somehow (e.g. ::cppu::WeakImplHelperN<>,
+ ::cppu::ImplInheritanceHelperN<>, etc.).
+ */
+template< typename ObjectType >
+class WeakReference
+{
+public:
+ /** Default constructor. Creates an empty weak reference.
+ */
+ inline explicit WeakReference() SAL_THROW( () ) : mpObject( 0 ) {}
+
+ /** Initializes this weak reference with the passed reference to an object.
+ */
+ inline explicit WeakReference( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) :
+ mxWeakRef( rxObject.get() ), mpObject( rxObject.get() ) {}
+
+ /** Releases this weak reference and takes over the passed reference.
+ */
+ inline WeakReference& SAL_CALL operator=( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () )
+ {
+ mxWeakRef = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak >( rxObject.get() );
+ mpObject = rxObject.get();
+ return *this;
+ }
+
+ /** Gets an RTL reference to the referenced object.
+
+ @return Reference or null, if the weakly referenced object is gone.
+ */
+ inline SAL_CALL operator ::rtl::Reference< ObjectType >() SAL_THROW( () )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak > xRef = mxWeakRef;
+ ::rtl::Reference< ObjectType > xObject;
+ if( xRef.is() )
+ xObject = mpObject;
+ else
+ mpObject = 0;
+ return xObject;
+ }
+
+private:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XWeak > mxWeakRef;
+ ObjectType* mpObject;
+};
+
+// ============================================================================
+
+} // namespace vbahelper
+
+#endif
diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst
index 312c9b062233..be2e516de360 100644
--- a/vbahelper/prj/build.lst
+++ b/vbahelper/prj/build.lst
@@ -1,3 +1,3 @@
-vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal LIBXSLT:libxslt NULL
+vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal unotools LIBXSLT:libxslt NULL
vba vbahelper usr1 - all vba_mkout NULL
vba vbahelper\prj nmake - all vba_prj NULL
diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx
index 21693128c899..775a05cbb5b5 100644
--- a/vbahelper/source/msforms/vbabutton.cxx
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -24,8 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbabutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -51,6 +52,56 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star
m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
}
+sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaButton::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx
index 1c65c293f76c..93a55e1bf73a 100644
--- a/vbahelper/source/msforms/vbabutton.hxx
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -27,12 +27,12 @@
#ifndef SC_VBA_BUTTON_HXX
#define SC_VBA_BUTTON_HXX
#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/msforms/XButton.hpp>
+#include <ooo/vba/msforms/XCommandButton.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XCommandButton > ButtonImpl_BASE;
class ScVbaButton : public ButtonImpl_BASE
{
@@ -41,6 +41,17 @@ public:
// Attributes
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx
index e9ea64f772b6..329586cf6b27 100644
--- a/vbahelper/source/msforms/vbacheckbox.cxx
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -24,9 +24,10 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbacheckbox.hxx"
+#include "vbanewfont.hxx"
#include <vbahelper/helperdecl.hxx>
-#include <vector>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -83,6 +84,12 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept
}
m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaCheckbox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx
index 34d0828e0c66..59e4d7e75e49 100644
--- a/vbahelper/source/msforms/vbacheckbox.hxx
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -27,12 +27,12 @@
#ifndef SC_VBA_CHECKBOX_HXX
#define SC_VBA_CHECKBOX_HXX
#include <cppuhelper/implbase2.hxx>
-#include <ooo/vba/msforms/XRadioButton.hpp>
+#include <ooo/vba/msforms/XCheckBox.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XCheckBox, css::script::XDefaultProperty > CheckBoxImpl_BASE;
class ScVbaCheckbox : public CheckBoxImpl_BASE
{
@@ -43,6 +43,7 @@ public:
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
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);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// XDefaultProperty
rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 0b5f1af30bb7..b0d1680e6101 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -24,8 +24,15 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbacombobox.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
+#include <ooo/vba/msforms/fmStyle.hpp>
+#include <ooo/vba/msforms/fmDropButtonStyle.hpp>
+#include <ooo/vba/msforms/fmDragBehavior.hpp>
+#include <ooo/vba/msforms/fmEnterFieldBehavior.hpp>
+#include <ooo/vba/msforms/fmListStyle.hpp>
+#include <ooo/vba/msforms/fmTextAlign.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -41,9 +48,17 @@ const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataF
ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialogType ) : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialogType( bDialogType )
{
- mpListHelper.reset( new ListControlHelper( m_xProps ) );
- // grab the default value property name
- m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ mpListHelper.reset( new ListControlHelper( m_xProps ) );
+ try
+ {
+ // grab the default value property name
+ m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ if( sSourceName.getLength() == 0 )
+ sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
}
// Attributes
@@ -103,7 +118,8 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
void SAL_CALL
ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
{
- m_xProps->setPropertyValue( sSourceName, _value );
+ // booleans are converted to uppercase strings
+ m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) );
}
// see Value
@@ -131,22 +147,22 @@ ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
void SAL_CALL
ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
- {
+{
mpListHelper->removeItem( index );
}
void SAL_CALL
ScVbaComboBox::Clear( ) throw (uno::RuntimeException)
- {
+{
mpListHelper->Clear();
- }
+}
void SAL_CALL
ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException)
{
ScVbaControl::setRowSource( _rowsource );
mpListHelper->setRowSource( _rowsource );
- }
+}
sal_Int32 SAL_CALL
ScVbaComboBox::getListCount() throw (uno::RuntimeException)
@@ -158,7 +174,66 @@ uno::Any SAL_CALL
ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
{
return mpListHelper->List( pvargIndex, pvarColumn );
- }
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmStyle::fmStyleDropDownCombo;
+}
+
+void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmDropButtonStyle::fmDropButtonStyleArrow;
+}
+
+void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmDragBehavior::fmDragBehaviorDisabled;
+}
+
+void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll;
+}
+
+void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getListStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmListStyle::fmListStylePlain;
+}
+
+void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign() throw (uno::RuntimeException)
+{
+ return msforms::fmTextAlign::fmTextAlignLeft;
+}
+
+void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
rtl::OUString&
ScVbaComboBox::getServiceImplName()
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index 28215d16dcd7..922f6f63ca62 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -58,6 +58,19 @@ public:
virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( sal_Int32 nStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDropButtonStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDragBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getEnterFieldBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getListStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// Methods
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index ed9f83a7c647..780191885049 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -43,8 +43,8 @@
#ifdef VBA_OOBUILD_HACK
#include <svtools/bindablecontrolhelper.hxx>
#endif
-#include"vbacontrol.hxx"
-#include"vbacombobox.hxx"
+#include "vbacontrol.hxx"
+#include "vbacombobox.hxx"
#include "vbabutton.hxx"
#include "vbalabel.hxx"
#include "vbatextbox.hxx"
@@ -397,99 +397,104 @@ void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag )
m_aControlTag = aTag;
}
-
-//ScVbaControlFactory
-
-ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel )
+sal_Int32 SAL_CALL ScVbaControl::getTabIndex() throw (uno::RuntimeException)
{
+ return 1;
}
-ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException)
+void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::RuntimeException)
{
- uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
- if ( xControlShape.is() ) // form controls
- return createControl( xControlShape, xParent );
- uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY );
- if ( !xControl.is() )
- throw uno::RuntimeException(); // really we should be more informative
- return createControl( xControl, xParent );
}
-ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException)
+//ScVbaControlFactory
+
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createShapeControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< drawing::XControlShape >& xControlShape,
+ const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
sal_Int32 nClassId = -1;
const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") );
xProps->getPropertyValue( sClassId ) >>= nClassId;
uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+ uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW );
+ ::std::auto_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xContext, xShape ) );
+
switch( nClassId )
{
case form::FormComponentType::COMBOBOX:
- return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::COMMANDBUTTON:
- return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::FIXEDTEXT:
- return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::TEXTFIELD:
- return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::RADIOBUTTON:
- return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::LISTBOX:
- return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::SPINBUTTON:
- return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::IMAGECONTROL:
- return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
- default:
- throw uno::RuntimeException( rtl::OUString::createFromAscii(
- "Donot support this Control Type." ), uno::Reference< uno::XInterface >() );
+ return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
}
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
}
-ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException)
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createUserformControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< awt::XControl >& xControl,
+ const uno::Reference< awt::XControl >& xDialog,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW );
uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW );
- ScVbaControl* pControl = NULL;
+ uno::Reference< msforms::XControl > xVBAControl;
uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+ ::std::auto_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xContext, xControl, fOffsetX, fOffsetY ) );
+
if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
- pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
- pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
- pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true );
+ xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) )
{
sal_Bool bToggle = sal_False;
xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle;
if ( bToggle )
- pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else
- pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
}
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
- pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true );
+ xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
- pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
- pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
- pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
- pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
- pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
- pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
- pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent );
+ xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
- pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) )
- pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
- else
- throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() );
- return pControl;
+ xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+
+ if( xVBAControl.is() )
+ return xVBAControl;
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
}
rtl::OUString&
@@ -520,7 +525,6 @@ class ControlProviderImpl : public ControlProvider_BASE
public:
ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {}
virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException);
- virtual uno::Reference< msforms::XControl > SAL_CALL createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException);
};
uno::Reference< msforms::XControl > SAL_CALL
@@ -528,27 +532,10 @@ ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape
{
uno::Reference< msforms::XControl > xControlToReturn;
if ( xControlShape.is() )
- {
- ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner );
- xControlToReturn.set( controlFactory.createControl( xDocOwner ) );
- }
+ xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner );
return xControlToReturn;
}
-uno::Reference< msforms::XControl > SAL_CALL
-ControlProviderImpl::createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException)
-{
- uno::Reference< msforms::XControl > xControlToReturn;
- if ( xControl.is() && xDialog.is() )
- {
-
- ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner );
- xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) );
- ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() );
- pControl->setGeometryHelper( new UserFormGeometryHelper( m_xCtx, xControl ) );
- }
- return xControlToReturn;
-}
namespace controlprovider
{
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 247eabfe95e8..e421f919b6a4 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -93,6 +93,8 @@ public:
virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException);
virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
//remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
virtual void removeResouce() throw( css::uno::RuntimeException );
//XHelperInterface
@@ -104,15 +106,21 @@ public:
class ScVbaControlFactory
{
public:
- ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel );
- ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException );
+ static css::uno::Reference< ov::msforms::XControl > createShapeControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape,
+ const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+
+ static css::uno::Reference< ov::msforms::XControl > createUserformControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xControl,
+ const css::uno::Reference< css::awt::XControl >& xDialog,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException);
+
private:
- ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException );
- ScVbaControl* createControl( const css::uno::Reference< css::drawing::XControlShape >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException );
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
- css::uno::Reference< css::uno::XInterface > m_xControl;
- css::uno::Reference< css::frame::XModel > m_xModel;
+ ScVbaControlFactory();
+ ~ScVbaControlFactory();
};
#endif//SC_VBA_CONTROL_HXX
diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
index 8d01687ef905..7411f7ad9463 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -27,13 +27,18 @@
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include "vbacontrols.hxx"
+#include "vbacontrol.hxx"
#include <cppuhelper/implbase2.hxx>
-#include <ooo/vba//XControlProvider.hpp>
+#include <ooo/vba/XControlProvider.hpp>
#include <hash_map>
using namespace com::sun::star;
@@ -153,11 +158,28 @@ class ControlsEnumWrapper : public EnumerationHelper_BASE
uno::Reference<uno::XComponentContext > m_xContext;
uno::Reference<container::XIndexAccess > m_xIndexAccess;
uno::Reference<awt::XControl > m_xDlg;
+ uno::Reference< frame::XModel > m_xModel;
+ double mfOffsetX;
+ double mfOffsetY;
sal_Int32 nIndex;
public:
- ControlsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< awt::XControl >& xDlg ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), m_xDlg( xDlg ), nIndex( 0 ) {}
+ ControlsEnumWrapper(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XIndexAccess >& xIndexAccess,
+ const uno::Reference< awt::XControl >& xDlg,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ m_xParent( xParent ),
+ m_xContext( xContext),
+ m_xIndexAccess( xIndexAccess ),
+ m_xDlg( xDlg ),
+ m_xModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ nIndex( 0 ) {}
virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
{
@@ -168,14 +190,12 @@ public:
{
if ( nIndex < m_xIndexAccess->getCount() )
{
- uno::Reference< frame::XModel > xModel;
uno::Reference< awt::XControl > xControl;
m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl;
- uno::Reference<lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
- uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), m_xContext ), uno::UNO_QUERY_THROW );
-
- uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, m_xDlg, xModel ) );
+ uno::Reference< msforms::XControl > xVBAControl;
+ if ( xControl.is() && m_xDlg.is() )
+ xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY );
return uno::makeAny( xVBAControl );
}
throw container::NoSuchElementException();
@@ -190,17 +210,24 @@ lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg )
return new ControlArrayWrapper( xDlg );
}
-ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
- const css::uno::Reference< awt::XControl >& xDialog )
- : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) )
+ScVbaControls::ScVbaControls(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const css::uno::Reference< awt::XControl >& xDialog,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ),
+ mxDialog( xDialog ),
+ mxModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY )
{
- mxDialog.set( xDialog, uno::UNO_QUERY );
}
uno::Reference< container::XEnumeration >
ScVbaControls::createEnumeration() throw (uno::RuntimeException)
{
- uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) );
+ uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) );
if ( !xEnum.is() )
throw uno::RuntimeException();
return xEnum;
@@ -210,15 +237,9 @@ uno::Any
ScVbaControls::createCollectionObject( const css::uno::Any& aSource )
{
// Create control from awt::XControl
- uno::Reference< awt::XControl > xControl;
- aSource >>= xControl;
- uno::Reference< frame::XModel > xModel;
- uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
- uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
-
- uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, mxDialog, xModel ) );
-
- return uno::makeAny( xVBAControl );
+ uno::Reference< awt::XControl > xControl( aSource, uno::UNO_QUERY_THROW );
+ uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY );
+ return uno::Any( xVBAControl );
}
void SAL_CALL
@@ -261,23 +282,117 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) );
sal_Int32 nInd = 0;
- while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 )
+ while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) )
{
aNewName = aComServiceName;
- aNewName += ::rtl::OUString::valueOf( nInd );
+ aNewName += ::rtl::OUString::valueOf( nInd++ );
}
}
+ double fDefWidth = 72.0, fDefHeight = 18.0;
if ( aComServiceName.getLength() )
{
- uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
+ // create a UNO control model based on the passed control type
+ uno::Reference< awt::XControlModel > xNewModel;
+ bool bFontSupport = false;
+ bool bNativeAX = false;
+ if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 24.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 72.0;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 216.0; fDefHeight = 144.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 25.5;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 63.8;
+ }
+ else
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bNativeAX = true;
+ }
+ // need to set a few font properties to get rid of the default DONT_KNOW values
+ if( bFontSupport )
+ {
+ uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) );
+ }
xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) );
uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
xNewControl = xControlContainer->getControl( aNewName );
- try
+ if( bNativeAX ) try
{
uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW );
@@ -299,6 +414,11 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) );
aResult <<= xNewControl;
aResult = createCollectionObject( aResult );
+ uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW );
+ if( fDefWidth > 0.0 )
+ xVBAControl->setWidth( fDefWidth );
+ if( fDefHeight > 0.0 )
+ xVBAControl->setHeight( fDefHeight );
}
else
throw uno::RuntimeException();
@@ -376,21 +496,5 @@ ScVbaControls::getElementType() throw (uno::RuntimeException)
{
return ooo::vba::msforms::XControl::static_type(0);
}
-rtl::OUString&
-ScVbaControls::getServiceImplName()
-{
- static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") );
- return sImplName;
-}
-uno::Sequence< rtl::OUString >
-ScVbaControls::getServiceNames()
-{
- static uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) );
- }
- return aServiceNames;
-}
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" )
diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx
index a72506609531..4b4838a45a8e 100644
--- a/vbahelper/source/msforms/vbacontrols.hxx
+++ b/vbahelper/source/msforms/vbacontrols.hxx
@@ -38,19 +38,17 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE;
class ScVbaControls : public ControlsImpl_BASE
{
- css::uno::Reference< css::awt::XControl > mxDialog;
-
-protected:
- virtual rtl::OUString& getServiceImplName();
- virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-
public:
- ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::awt::XControl >& xDialog );
+ ScVbaControls(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xDialog,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY );
// XControls
virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Object, const css::uno::Any& StringKey, const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) throw (css::uno::RuntimeException);
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
@@ -59,6 +57,15 @@ public:
// ScVbaCollectionBaseImpl
virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ double mfOffsetX;
+ double mfOffsetY;
};
+
#endif //SC_VBA_OLEOBJECTS_HXX
diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx
index c470ee0097e4..4a1fe6a58b49 100644
--- a/vbahelper/source/msforms/vbaframe.cxx
+++ b/vbahelper/source/msforms/vbaframe.cxx
@@ -24,62 +24,83 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbaframe.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
+#include "vbacontrols.hxx"
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+
+ScVbaFrame::ScVbaFrame(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< uno::XInterface >& xControl,
+ const uno::Reference< frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog ) :
+ FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ),
+ mxDialog( xDialog )
{
}
-// Attributes
-rtl::OUString SAL_CALL
-ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
+// XFrame attributes
+
+rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
{
rtl::OUString Label;
m_xProps->getPropertyValue( LABEL ) >>= Label;
return Label;
}
-void SAL_CALL
-ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
{
m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
}
-uno::Any SAL_CALL
-ScVbaFrame::getValue() throw (css::uno::RuntimeException)
+sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException)
{
- return uno::makeAny( getCaption() );
+ return msforms::fmSpecialEffect::fmSpecialEffectEtched;
}
-void SAL_CALL
-ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
{
- rtl::OUString sCaption;
- _value >>= sCaption;
- setCaption( sCaption );
}
-rtl::OUString&
-ScVbaFrame::getServiceImplName()
+sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException)
{
- static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") );
- return sImplName;
+ return msforms::fmBorderStyle::fmBorderStyleNone;
}
-uno::Sequence< rtl::OUString >
-ScVbaFrame::getServiceNames()
+void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
{
- static uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
- }
- return aServiceNames;
}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+// XFrame methods
+
+uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ // horizontal anchor of frame children is inside border line (add one unit to compensate border line width)
+ double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0;
+ // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width)
+ double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0;
+
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) );
+ if( rIndex.hasValue() )
+ return uno::Any( xControls->Item( rIndex, uno::Any() ) );
+ return uno::Any( xControls );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" )
diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx
index 567e58b57272..d76f31230bba 100644
--- a/vbahelper/source/msforms/vbaframe.hxx
+++ b/vbahelper/source/msforms/vbaframe.hxx
@@ -27,24 +27,39 @@
#ifndef SC_VBA_FRAME_HXX
#define SC_VBA_FRAME_HXX
#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/msforms/XLabel.hpp>
+#include <ooo/vba/msforms/XFrame.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE;
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XFrame > FrameImpl_BASE;
class ScVbaFrame : public FrameImpl_BASE
{
public:
- ScVbaFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper );
- // 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);
+ ScVbaFrame(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::uno::XInterface >& xControl,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
+ // XFrame attributes
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ // XFrame methods
+ css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
};
#endif //SC_VBA_LABEL_HXX
diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx
index 9bf7a7e001bf..d5aa1176e3d3 100644
--- a/vbahelper/source/msforms/vbalabel.cxx
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -24,8 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbalabel.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -64,6 +65,10 @@ ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run
setCaption( sCaption );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
rtl::OUString&
ScVbaLabel::getServiceImplName()
diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx
index af3bc074c54d..2dcee186d58b 100644
--- a/vbahelper/source/msforms/vbalabel.hxx
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -44,6 +44,7 @@ public:
virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx
index 17f8c8341588..8829c8ae7256 100644
--- a/vbahelper/source/msforms/vbalistbox.cxx
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -24,12 +24,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
#include "vbalistbox.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
#include <comphelper/anytostring.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -267,6 +267,11 @@ ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) t
return mpListHelper->List( pvargIndex, pvarColumn );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaListBox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx
index 3d0797e2b7b2..7dbda1837cb0 100644
--- a/vbahelper/source/msforms/vbalistbox.hxx
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -60,9 +60,10 @@ public:
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException);
virtual void SAL_CALL setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// Methods
+ virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx
index b6587c9b2367..78590f0fd85b 100644
--- a/vbahelper/source/msforms/vbamultipage.cxx
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -68,9 +68,16 @@ ScVbaMultiPage::getPages( sal_Int32 nPages )
return new PagesImpl( nPages );
}
-ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+ScVbaMultiPage::ScVbaMultiPage(
+ const uno::Reference< ov::XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< uno::XInterface >& xControl,
+ const uno::Reference< frame::XModel >& xModel,
+ AbstractGeometryAttributes* pGeomHelper,
+ const uno::Reference< awt::XControl >& xDialog ) :
+ MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
{
- mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
+ mxDialogProps.set( xDialog->getModel(), uno::UNO_QUERY_THROW );
// set dialog step to value of multipage pseudo model
setValue(getValue());
}
diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx
index 4a54525cf95f..328a71b61592 100644
--- a/vbahelper/source/msforms/vbamultipage.hxx
+++ b/vbahelper/source/msforms/vbamultipage.hxx
@@ -42,7 +42,14 @@ class ScVbaMultiPage : public MultiPageImpl_BASE
css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages );
css::uno::Reference< css::beans::XPropertySet > mxDialogProps;
public:
- ScVbaMultiPage( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper, const css::uno::Reference< css::uno::XInterface >& xDialog );
+ ScVbaMultiPage(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::uno::XInterface >& xControl,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
// Attributes
virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx
new file mode 100755
index 000000000000..f487b4e6919c
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbanewfont.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+VbaNewFont::VbaNewFont(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) :
+ VbaNewFont_BASE( rxParent, rxContext ),
+ mxProps( rxModelProps, uno::UNO_SET_THROW )
+{
+}
+
+// XNewFont attributes
+
+::rtl::OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ) );
+ return aAny.get< ::rtl::OUString >();
+}
+
+void SAL_CALL VbaNewFont::setName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ),
+ uno::Any( rName ) );
+}
+
+double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ) );
+ return aAny.get< float >();
+}
+
+void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ),
+ uno::Any( static_cast< float >( fSize ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ) );
+ return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) );
+}
+
+void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException)
+{
+ rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
+ if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) )
+ eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) );
+ if( eFontEnc == RTL_TEXTENCODING_DONTKNOW )
+ throw uno::RuntimeException();
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ),
+ uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException)
+{
+ return getBold() ? 700 : 400;
+}
+
+void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException)
+{
+ setBold( nWeight >= 700 );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ) );
+ return aAny.get< float >() > awt::FontWeight::NORMAL;
+}
+
+void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ),
+ uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ) );
+ return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE;
+}
+
+void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ),
+ uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE;
+}
+
+void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ),
+ uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE;
+}
+
+void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ),
+ uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" )
+
+// ============================================================================
diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx
new file mode 100755
index 000000000000..d59d5caa139c
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_MSFORMS_VBANEWFONT_HXX
+#define VBAHELPER_MSFORMS_VBANEWFONT_HXX
+
+#include <ooo/vba/msforms/XNewFont.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+// ============================================================================
+
+typedef InheritedHelperInterfaceImpl1< ov::msforms::XNewFont > VbaNewFont_BASE;
+
+class VbaNewFont : public VbaNewFont_BASE
+{
+public:
+ VbaNewFont(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::beans::XPropertySet >& rxModelProps ) throw (css::uno::RuntimeException);
+
+ // XNewFont attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSize( double fSize ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getCharset() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCharset( sal_Int16 nCharset ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getWeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWeight( sal_Int16 nWeight ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBold() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBold( sal_Bool bBold ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getItalic() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setItalic( sal_Bool bItalic ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getUnderline() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUnderline( sal_Bool bUnderline ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getStrikethrough() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStrikethrough( sal_Bool bStrikethrough ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::beans::XPropertySet > mxProps;
+};
+
+// ============================================================================
+
+#endif
diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx
index 94d12c5823ba..12ee1ad8ae41 100644
--- a/vbahelper/source/msforms/vbaradiobutton.cxx
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -24,8 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbaradiobutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -84,6 +85,11 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio
m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaRadioButton::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx
index a0de21ae5d0e..3da00eb0765e 100644
--- a/vbahelper/source/msforms/vbaradiobutton.hxx
+++ b/vbahelper/source/msforms/vbaradiobutton.hxx
@@ -42,6 +42,7 @@ public:
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
index 2d83d41d77c3..c9e4381f449a 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -24,16 +24,16 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <com/sun/star/text/XTextRange.hpp>
#include "vbatextbox.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
+#include <com/sun/star/text/XTextRange.hpp>
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
-
-
ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog )
{
}
@@ -48,7 +48,8 @@ ScVbaTextBox::getValue() throw (css::uno::RuntimeException)
void SAL_CALL
ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
{
- rtl::OUString sVal = getAnyAsString( _value );
+ // booleans are converted to uppercase strings
+ rtl::OUString sVal = extractStringFromAny( _value, true );
setText( sVal );
}
@@ -114,6 +115,29 @@ ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeExcept
(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
}
+sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException)
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectSunken;
+}
+
+void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaTextBox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx
index 0553e047488e..fb791db149e4 100644
--- a/vbahelper/source/msforms/vbatextbox.hxx
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -47,6 +47,11 @@ public:
virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getMultiline() throw (css::uno::RuntimeException);
virtual void SAL_CALL setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// XDefaultProperty
rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx
index 071651ff8a36..d1a3b40d6eb7 100644
--- a/vbahelper/source/msforms/vbatogglebutton.cxx
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -24,8 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbatogglebutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -79,6 +80,56 @@ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExcepti
m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
}
+sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaToggleButton::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx
index bfdd68d09642..d2bf4c6b7f17 100644
--- a/vbahelper/source/msforms/vbatogglebutton.hxx
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -43,9 +43,19 @@ public:
// 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);
-
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 16bc97babd7d..3eb799205389 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -54,7 +54,7 @@ ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Refer
m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
- setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) );
+ setGeometryHelper( new UserFormGeometryHelper( xContext, xControl, 0.0, 0.0 ) );
}
ScVbaUserForm::~ScVbaUserForm()
@@ -105,18 +105,38 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
}
rtl::OUString SAL_CALL
-ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException)
+ScVbaUserForm::getCaption() throw (uno::RuntimeException)
{
rtl::OUString sCaption;
m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption;
return sCaption;
}
void
-ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
{
m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
}
+double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerWidth();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerWidth( fInnerWidth );
+}
+
+double SAL_CALL ScVbaUserForm::getInnerHeight() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerHeight();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerHeight( fInnerHeight );
+}
+
void SAL_CALL
ScVbaUserForm::Hide( ) throw (uno::RuntimeException)
{
@@ -202,13 +222,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
if ( xControl.is() )
- {
- ScVbaControlFactory aFac( mxContext, xControl, m_xModel );
- uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) );
- ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
- pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) );
- aResult = uno::makeAny( xVBAControl );
- }
+ aResult <<= ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
}
return aResult;
@@ -225,7 +239,7 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
// if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects
// thus we have to provide a dummy object in this case
uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY );
- uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) );
if ( index.hasValue() )
return uno::makeAny( xControls->Item( index, uno::Any() ) );
return uno::makeAny( xControls );
diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx
index 71e8b4f62aa9..1777a979b9f2 100644
--- a/vbahelper/source/msforms/vbauserform.hxx
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -50,18 +50,22 @@ public:
// XUserForm
virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException);
- // XIntrospection
- virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getInnerWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerWidth( double fInnerWidth ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getInnerHeight() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerHeight( double fInnerHeight ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL Hide( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL UnloadObject( ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException);
+ // XIntrospection
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/vbahelper/collectionbase.cxx b/vbahelper/source/vbahelper/collectionbase.cxx
new file mode 100755
index 000000000000..7a99aabecdf8
--- /dev/null
+++ b/vbahelper/source/vbahelper/collectionbase.cxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbahelper/collectionbase.hxx>
+
+#include <map>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace vbahelper {
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+namespace {
+
+// ----------------------------------------------------------------------------
+
+class CollectionEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration >
+{
+public:
+ explicit CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection );
+ virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+private:
+ ::rtl::Reference< CollectionBase > mxCollection;
+ sal_Int32 mnCurrIndex;
+};
+
+CollectionEnumeration::CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ) :
+ mxCollection( rxCollection ),
+ mnCurrIndex( 1 ) // collection expects one-based indexes
+{
+}
+
+sal_Bool SAL_CALL CollectionEnumeration::hasMoreElements() throw (uno::RuntimeException)
+{
+ return mnCurrIndex <= mxCollection->getCount();
+}
+
+uno::Any SAL_CALL CollectionEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( hasMoreElements() )
+ return mxCollection->getItemByIndex( mnCurrIndex++ );
+ throw container::NoSuchElementException();
+}
+
+// ----------------------------------------------------------------------------
+
+struct IsLessIgnoreCase
+{
+ inline bool operator()( const ::rtl::OUString& rName1, const ::rtl::OUString& rName2 ) const
+ { return ::rtl_ustr_compareIgnoreAsciiCase_WithLength( rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0; }
+};
+
+// ----------------------------------------------------------------------------
+
+class SequenceToContainer : public ::cppu::WeakImplHelper2< container::XIndexAccess, container::XNameAccess >
+{
+public:
+ explicit SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType );
+ explicit SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType );
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException);
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
+
+private:
+ typedef uno::Sequence< ::rtl::OUString > ElementNameSequence;
+ typedef ::std::vector< uno::Any > ElementVector;
+ typedef ::std::map< ::rtl::OUString, uno::Any, IsLessIgnoreCase > ElementMap;
+
+ ElementNameSequence maElementNames;
+ ElementVector maElements;
+ ElementMap maElementMap;
+ uno::Type maElementType;
+};
+
+SequenceToContainer::SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ) :
+ maElementType( rElementType )
+{
+ maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) );
+ maElements.reserve( rElements.size() );
+ ::rtl::OUString* pElementName = maElementNames.getArray();
+ for( ::std::vector< uno::Reference< container::XNamed > >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName )
+ {
+ uno::Reference< container::XNamed > xNamed = *aIt;
+ *pElementName = xNamed->getName();
+ maElements.push_back( uno::Any( xNamed ) );
+ // same name may occur multiple times, VBA returns first occurance
+ if( maElementMap.count( *pElementName ) == 0 )
+ maElementMap[ *pElementName ] <<= xNamed;
+ }
+}
+
+SequenceToContainer::SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ) :
+ maElementType( rElementType )
+{
+ maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) );
+ maElements.reserve( rElements.size() );
+ ::rtl::OUString* pElementName = maElementNames.getArray();
+ for( ::std::vector< beans::NamedValue >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName )
+ {
+ *pElementName = aIt->Name;
+ maElements.push_back( aIt->Value );
+ // same name may occur multiple times, VBA returns first occurance
+ if( maElementMap.count( *pElementName ) == 0 )
+ maElementMap[ *pElementName ] = aIt->Value;
+ }
+}
+
+sal_Int32 SAL_CALL SequenceToContainer::getCount() throw (uno::RuntimeException)
+{
+ return static_cast< sal_Int32 >( maElements.size() );
+}
+
+uno::Any SAL_CALL SequenceToContainer::getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( (0 <= nIndex) && (nIndex < getCount()) )
+ return maElements[ static_cast< size_t >( nIndex ) ];
+ throw lang::IndexOutOfBoundsException();
+}
+
+uno::Any SAL_CALL SequenceToContainer::getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ElementMap::iterator aIt = maElementMap.find( rName );
+ if( aIt != maElementMap.end() )
+ return aIt->second;
+ throw container::NoSuchElementException();
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SequenceToContainer::getElementNames() throw (uno::RuntimeException)
+{
+ return maElementNames;
+}
+
+sal_Bool SAL_CALL SequenceToContainer::hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ return maElementMap.count( rName ) > 0;
+}
+
+uno::Type SAL_CALL SequenceToContainer::getElementType() throw (uno::RuntimeException)
+{
+ return maElementType;
+}
+
+sal_Bool SAL_CALL SequenceToContainer::hasElements() throw (uno::RuntimeException)
+{
+ return !maElements.empty();
+}
+
+} // namespace
+
+// ============================================================================
+
+CollectionBase::CollectionBase( const uno::Type& rElementType ) :
+ maElementType( rElementType ),
+ mbConvertOnDemand( false )
+{
+}
+
+sal_Int32 SAL_CALL CollectionBase::getCount() throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ return mxIndexAccess->getCount();
+ if( mxNameAccess.is() )
+ return mxNameAccess->getElementNames().getLength();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Reference< container::XEnumeration > SAL_CALL CollectionBase::createEnumeration() throw (uno::RuntimeException)
+{
+ return new CollectionEnumeration( this );
+}
+
+uno::Type SAL_CALL CollectionBase::getElementType() throw (uno::RuntimeException)
+{
+ return maElementType;
+}
+
+sal_Bool SAL_CALL CollectionBase::hasElements() throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ return mxIndexAccess->hasElements();
+ if( mxNameAccess.is() )
+ return mxNameAccess->hasElements();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+::rtl::OUString SAL_CALL CollectionBase::getDefaultMethodName() throw (uno::RuntimeException)
+{
+ static ::rtl::OUString saDefMethodName( RTL_CONSTASCII_USTRINGPARAM( "Item" ) );
+ return saDefMethodName;
+}
+
+// ----------------------------------------------------------------------------
+
+void CollectionBase::initContainer(
+ const uno::Reference< container::XElementAccess >& rxElementAccess,
+ ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ mxIndexAccess.set( rxElementAccess, uno::UNO_QUERY );
+ mxNameAccess.set( rxElementAccess, uno::UNO_QUERY );
+ switch( eContainerType )
+ {
+ case CONTAINER_NATIVE_VBA:
+ mbConvertOnDemand = false;
+ break;
+ case CONTAINER_CONVERT_ON_DEMAND:
+ mbConvertOnDemand = true;
+ break;
+ }
+}
+
+void CollectionBase::initElements( const ::std::vector< uno::Reference< container::XNamed > >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity
+ initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType );
+}
+
+void CollectionBase::initElements( const ::std::vector< beans::NamedValue >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity
+ initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType );
+}
+
+uno::Any CollectionBase::createCollectionItem( const uno::Any& rElement, const uno::Any& rIndex ) throw (css::uno::RuntimeException)
+{
+ uno::Any aItem = mbConvertOnDemand ? implCreateCollectionItem( rElement, rIndex ) : rElement;
+ if( aItem.hasValue() )
+ return aItem;
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item." ) ), 0 );
+}
+
+uno::Any CollectionBase::getItemByIndex( sal_Int32 nIndex ) throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ {
+ if( (1 <= nIndex) && (nIndex <= mxIndexAccess->getCount()) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxIndexAccess->getByIndex( nIndex - 1 ), uno::Any( nIndex ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 );
+ }
+ if( mxNameAccess.is() )
+ {
+ uno::Sequence< ::rtl::OUString > aElementNames = mxNameAccess->getElementNames();
+ if( (1 <= nIndex) && (nIndex <= aElementNames.getLength()) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxNameAccess->getByName( aElementNames[ nIndex - 1 ] ), uno::Any( aElementNames[ nIndex - 1 ] ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Any CollectionBase::getItemByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ if( mxNameAccess.is() )
+ {
+ if( rName.getLength() > 0 )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxNameAccess->getByName( rName ), uno::Any( rName ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 );
+ }
+ if( mxIndexAccess.is() )
+ {
+ for( sal_Int32 nIndex = 0, nSize = mxIndexAccess->getCount(); nIndex < nSize; ++nIndex )
+ {
+ uno::Any aElement = mxIndexAccess->getByIndex( nIndex );
+ uno::Reference< container::XNamed > xNamed( aElement, uno::UNO_QUERY );
+ if( xNamed.is() && xNamed->getName().equalsIgnoreAsciiCase( rName ) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( aElement, uno::Any( nIndex ) );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Any CollectionBase::getAnyItemOrThis( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ if( !rIndex.hasValue() )
+ return uno::Any( uno::Reference< XCollectionBase >( this ) );
+ if( rIndex.has< sal_Int32 >() )
+ return getItemByIndex( rIndex.get< sal_Int32 >() );
+ if( rIndex.has< ::rtl::OUString >() )
+ return getItemByName( rIndex.get< ::rtl::OUString >() );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item index." ) ), 0 );
+}
+
+// protected ------------------------------------------------------------------
+
+uno::Any CollectionBase::implCreateCollectionItem( const uno::Any& /*rElement*/, const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Creation of VBA implementation object not implemented." ) ), 0 );
+}
+
+// ============================================================================
+
+} // namespace vbahelper
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 54d280094f2c..6f782b629f40 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -387,9 +387,9 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException)
{
try // return empty object on error
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getCurrentDocument();
+ // "VBE" object does not have a parent, but pass document model to be able to determine application type
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= getCurrentDocument();
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext );
@@ -401,25 +401,6 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException)
return uno::Any();
}
-uno::Any SAL_CALL
-VbaApplicationBase::getVBProjects() throw (uno::RuntimeException)
-{
- try // return empty object on error
- {
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getCurrentDocument();
- uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
- uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext );
- return uno::Any( xVBProjects );
- }
- catch( uno::Exception& )
- {
- }
- return uno::Any();
-}
-
rtl::OUString&
VbaApplicationBase::getServiceImplName()
{
diff --git a/vbahelper/source/vbahelper/vbacommandbar.cxx b/vbahelper/source/vbahelper/vbacommandbar.cxx
index 1e8d21d53583..11cbacb79894 100644
--- a/vbahelper/source/vbahelper/vbacommandbar.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbar.cxx
@@ -154,14 +154,7 @@ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeExce
uno::Any SAL_CALL
ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
{
- uno::Reference< awt::XMenu > xMenu;
- if( m_bIsMenu )
- {
- uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager();
- uno::Reference< beans::XPropertySet > xPropertySet( xLayoutManager->getElement( m_sResourceUrl ), uno::UNO_QUERY_THROW );
- xMenu.set( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("XMenuBar") ), uno::UNO_QUERY );
- }
- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
if( aIndex.hasValue() )
{
return xCommandBarControls->Item( aIndex, uno::Any() );
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
index 157d54eca7d5..d57bc00644a5 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
@@ -91,50 +91,37 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
{
- /*sal_Bool bVisible = sal_True;
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
+ sal_Bool bVisible = sal_True;
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) );
if( aValue.hasValue() )
aValue >>= bVisible;
- return bVisible;*/
- return getEnabled();
-
+ return bVisible;
}
void SAL_CALL
ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
{
- /*uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) );
if( aValue.hasValue() )
{
- setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) );
+ setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ), uno::makeAny( _visible ) );
ApplyChange();
- }*/
- setEnabled( _visible);
+ }
}
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
{
sal_Bool bEnabled = sal_True;
- rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
- rtl::OUString aCommandURL ;
- if( m_xParentMenu.is() )
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) );
+ if( aValue.hasValue() )
{
- // currently only the menu in the MenuBat support Enable/Disable
- // FIXME: how to support the menu item in Toolbar
- bEnabled = m_xParentMenu->isItemEnabled( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ) );
+ aValue >>= bEnabled;
}
else
{
// emulated with Visible
- //bEnabled = getVisible();
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
- if (aValue >>= aCommandURL){
- if (0 == aCommandURL.indexOf(aCommandURLappendix)){
- bEnabled = sal_False;
- }
- }
-
+ bEnabled = getVisible();
}
return bEnabled;
}
@@ -142,30 +129,16 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
void SAL_CALL
ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
{
- rtl::OUString aCommandURL ;
- rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
- rtl::OUStringBuffer aCommandURLSringBuffer;
- if( m_xParentMenu.is() )
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) );
+ if( aValue.hasValue() )
{
- // currently only the menu in the MenuBat support Enable/Disable
- m_xParentMenu->enableItem( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ), _enabled );
+ setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ), uno::makeAny( _enabled ) );
+ ApplyChange();
}
else
{
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
- if (aValue >>= aCommandURL){
- if (0 == aCommandURL.indexOf(aCommandURLappendix)){
- aCommandURL = aCommandURL.copy(3);
- }
- if (false == _enabled){
- aCommandURLSringBuffer = aCommandURLappendix;
- }
- aCommandURLSringBuffer.append(aCommandURL);
- setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) );
- ApplyChange();
- }
// emulated with Visible
- //setVisible( _enabled );
+ setVisible( _enabled );
}
}
@@ -206,14 +179,7 @@ ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicE
if( !xSubMenu.is() )
throw uno::RuntimeException();
- uno::Reference< awt::XMenu > xMenu;
- if( m_xParentMenu.is() )
- {
- sal_Int16 nItemId = m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) );
- xMenu.set( m_xParentMenu->getPopupMenu( nItemId ), uno::UNO_QUERY );
- }
-
- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
if( aIndex.hasValue() )
{
return xCommandBarControls->Item( aIndex, uno::Any() );
@@ -241,12 +207,11 @@ ScVbaCommandBarControl::getServiceNames()
}
//////////// ScVbaCommandBarPopup //////////////////////////////
-ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
{
m_nPosition = nPosition;
m_bTemporary = bTemporary;
m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
- m_xParentMenu = xMenu;
}
rtl::OUString&
@@ -268,12 +233,11 @@ ScVbaCommandBarPopup::getServiceNames()
}
//////////// ScVbaCommandBarButton //////////////////////////////
-ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
{
m_nPosition = nPosition;
m_bTemporary = bTemporary;
m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
- m_xParentMenu = xMenu;
}
rtl::OUString&
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
index a165f8e1cccd..5066ba75eea0 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
@@ -43,10 +43,9 @@ class ScVbaCommandBarControl : public CommandBarControl_BASE
protected:
VbaCommandBarHelperRef pCBarHelper;
rtl::OUString m_sResourceUrl;
- css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
- css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
- css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
- css::uno::Reference< css::awt::XMenu > m_xParentMenu;
+ css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
sal_Int32 m_nPosition;
sal_Bool m_bTemporary;
@@ -87,7 +86,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop
class ScVbaCommandBarPopup : public CommandBarPopup_BASE
{
public:
- ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+ ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
{
@@ -102,7 +101,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut
class ScVbaCommandBarButton : public CommandBarButton_BASE
{
public:
- ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+ ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
{
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
index 634b4a0e9395..da218d007736 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
@@ -55,14 +55,20 @@ public:
}
};
-ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl, const uno::Reference< awt::XMenu >& xMenu ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_xMenu( xMenu )
+ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl )
{
m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False;
}
-uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu )
+uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL,
+ const rtl::OUString& sHelpURL,
+ const rtl::OUString& sLabel,
+ sal_uInt16 nType,
+ const uno::Any& aSubMenu,
+ sal_Bool isVisible,
+ sal_Bool isEnabled )
{
- uno::Sequence< beans::PropertyValue > aProps(5);
+ uno::Sequence< beans::PropertyValue > aProps(7);
aProps[0].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL );
aProps[0].Value <<= sCommandURL;
@@ -74,6 +80,10 @@ uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemDat
aProps[3].Value <<= nType;
aProps[4].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER );
aProps[4].Value = aSubMenu;
+ aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE );
+ aProps[5].Value <<= isVisible;
+ aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED );
+ aProps[6].Value <<= isEnabled;
return aProps;
}
@@ -124,9 +134,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
getPropertyValue( aProps, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu;
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
if( xSubMenu.is() )
- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
else
- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
}
@@ -202,7 +212,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
sal_uInt16 nItemType = 0;
if( IsMenu() )
{
- aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu );
+ aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true );
}
else
{
@@ -217,12 +227,11 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
- // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux.
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
if( nType == office::MsoControlType::msoControlPopup )
- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
else
- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
}
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
index 0b35773660d1..79a4a8c5a5fe 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
@@ -38,17 +38,22 @@ typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
class ScVbaCommandBarControls : public CommandBarControls_BASE
{
private:
- VbaCommandBarHelperRef pCBarHelper;
- css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
- rtl::OUString m_sResourceUrl;
- css::uno::Reference< css::awt::XMenu > m_xMenu;
- sal_Bool m_bIsMenu;
+ VbaCommandBarHelperRef pCBarHelper;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ rtl::OUString m_sResourceUrl;
+ sal_Bool m_bIsMenu;
- css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu );
+ css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL,
+ const rtl::OUString& sHelpURL,
+ const rtl::OUString& sLabel,
+ sal_uInt16 nType,
+ const css::uno::Any& aSubMenu,
+ sal_Bool isVisible,
+ sal_Bool isEnabled );
css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle );
public:
- ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw( css::uno::RuntimeException );
+ ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException );
sal_Bool IsMenu(){ return m_bIsMenu; }
// XEnumerationAccess
diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
index 1fa41d7141b3..93c6e5f55457 100644
--- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
@@ -47,6 +47,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
static const char ITEM_DESCRIPTOR_UINAME[] = "UIName";
+static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled";
static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 087e7188c8f6..b3053aa3d759 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/XApplicationBase.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/unwrapargs.hxx>
@@ -265,20 +266,22 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException)
uno::Any SAL_CALL
VbaDocumentBase::getVBProject() throw (uno::RuntimeException)
{
- try // return empty object on error
+ if( !mxVBProject.is() ) try
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getModel();
+ uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Any > aArgs( 3 );
+ aArgs[ 0 ] <<= xVBE; // the VBE
+ aArgs[ 1 ] <<= xVBE; // parent of a VBA project is the VBE
+ aArgs[ 2 ] <<= getModel(); // document model for script container access
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
- uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext(
+ mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext );
- return uno::Any( xVBProjects );
}
catch( uno::Exception& )
{
}
- return uno::Any();
+ return uno::Any( mxVBProject );
}
rtl::OUString&
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index 8000a7cdf66e..5e2cf949c473 100755
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -26,34 +26,40 @@
************************************************************************/
#include "vbahelper/vbaeventshelperbase.hxx"
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
#include <filter/msfilter/msvbahelper.hxx>
+#include <unotools/eventcfg.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
// ============================================================================
VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) :
mpShell( 0 ),
- mbDisposed( false )
+ mbDisposed( true )
{
try
{
mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false );
mpShell = getSfxObjShell( mxModel );
-
- // add dispose listener
- uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW );
- xComponent->addEventListener( this );
}
catch( uno::Exception& )
{
}
+ mbDisposed = mpShell == 0;
+ startListening();
}
VbaEventsHelperBase::~VbaEventsHelperBase()
{
- stopListening();
+ OSL_ENSURE( mbDisposed, "VbaEventsHelperBase::~VbaEventsHelperBase - missing disposing notification" );
}
sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
@@ -65,8 +71,8 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c
return getEventHandlerPath( rInfo, rArgs ).getLength() > 0;
}
-void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
- throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException)
+sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
+ throw (lang::IllegalArgumentException, util::VetoException, uno::RuntimeException)
{
/* Derived classes may add new event identifiers to be processed while
processing the original event. All unprocessed events are collected in
@@ -79,9 +85,9 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
handler receives the Cancel value of the previous event handler. */
bool bCancel = false;
- /* bSuccess will change to true if at least one event handler has been
- executed successfully. */
- bool bSuccess = false;
+ /* bExecuted will change to true if at least one event handler has been
+ found and executed. */
+ bool bExecuted = false;
/* Loop as long as there are more events to be processed. Derived classes
may add new events to be processed in the virtual implPrepareEvent()
@@ -98,15 +104,15 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId );
uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs;
aEventQueue.pop_front();
+ OSL_TRACE( "VbaEventsHelperBase::processVbaEvent( \"%s\" )", ::rtl::OUStringToOString( rInfo.maMacroName, RTL_TEXTENCODING_UTF8 ).getStr() );
/* Let derived classes prepare the event, they may add new events for
next iteration. If false is returned, the event handler must not be
called. */
- bool bEventSuccess = false;
if( implPrepareEvent( aEventQueue, rInfo, aEventArgs ) )
{
// search the event handler macro in the document
- ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
+ OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
if( aMacroPath.getLength() > 0 )
{
// build the argument list
@@ -120,96 +126,225 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
}
// execute the event handler
uno::Any aRet, aCaller;
- bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller );
- // extract new cancel value
+ executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller );
+ // extract new cancel value (may be boolean or any integer type)
if( rInfo.mnCancelIndex >= 0 )
{
- if( rInfo.mnCancelIndex >= aVbaArgs.getLength() )
- throw lang::IllegalArgumentException();
- // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32
- bool bNewCancel = false;
- sal_Int32 nNewCancel = 0;
- if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel )
- bCancel = bNewCancel;
- else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel )
- bCancel = nNewCancel != 0;
+ checkArgument( aVbaArgs, rInfo.mnCancelIndex );
+ bCancel = extractBoolFromAny( aVbaArgs[ rInfo.mnCancelIndex ] );
}
+ // event handler has been found
+ bExecuted = true;
}
- // global success, if at least one event handler succeeded
- bSuccess |= bEventSuccess;
}
// post processing (also, if event handler does not exist, or disabled, or on error
- implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel );
+ implPostProcessEvent( aEventQueue, rInfo, bCancel );
}
// if event handlers want to cancel the event, do so regardless of any errors
if( bCancel )
throw util::VetoException();
- // if no event handler finished successfully, throw
- if( !bSuccess )
- throw script::provider::ScriptFrameworkErrorException();
+ // return true, if at least one event handler has been found
+ return bExecuted;
}
-void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException)
+void SAL_CALL VbaEventsHelperBase::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException)
{
- OSL_TRACE( "VbaEventsHelperBase::disposing" );
- stopListening();
- mbDisposed = true;
+ OSL_TRACE( "VbaEventsHelperBase::notifyEvent( \"%s\" )", ::rtl::OUStringToOString( rEvent.EventName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
+ stopListening();
+}
+
+void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rEvent ) throw (uno::RuntimeException)
+{
+ // make sure the VBA library exists
+ try
+ {
+ ensureVBALibrary();
+ }
+ catch( uno::Exception& )
+ {
+ return;
+ }
+
+ // check that the sender of the event is the VBA library
+ uno::Reference< script::vba::XVBAModuleInfo > xSender( rEvent.Base, uno::UNO_QUERY );
+ if( mxModuleInfos.get() != xSender.get() )
+ return;
+
+ // process all changed modules
+ for( sal_Int32 nIndex = 0, nLength = rEvent.Changes.getLength(); nIndex < nLength; ++nIndex )
+ {
+ const util::ElementChange& rChange = rEvent.Changes[ nIndex ];
+ OUString aModuleName;
+ if( (rChange.Accessor >>= aModuleName) && (aModuleName.getLength() > 0) ) try
+ {
+ // invalidate event handler path map depending on module type
+ if( getModuleType( aModuleName ) == script::ModuleType::NORMAL )
+ // paths to global event handlers are stored with empty key (will be searched in all normal code modules)
+ maEventPaths.erase( OUString() );
+ else
+ // paths to class/form/document event handlers are keyed by module name
+ maEventPaths.erase( aModuleName );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& rEvent ) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xSender( rEvent.Source, uno::UNO_QUERY );
+ if( xSender.is() )
+ stopListening();
+}
+
+void VbaEventsHelperBase::processVbaEventNoThrow( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
+{
+ try
+ {
+ processVbaEvent( nEventId, rArgs );
+ }
+ catch( uno::Exception& )
+ {
+ }
}
// protected ------------------------------------------------------------------
-void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId,
- const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData )
+void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, sal_Int32 nModuleType,
+ const sal_Char* pcMacroName, sal_Int32 nCancelIndex, const uno::Any& rUserData )
{
- EventHandlerInfo& rInfo = maEvents[ nEventId ];
+ EventHandlerInfo& rInfo = maEventInfos[ nEventId ];
rInfo.mnEventId = nEventId;
- rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName );
- rInfo.meType = eType;
+ rInfo.mnModuleType = nModuleType;
+ rInfo.maMacroName = OUString::createFromAscii( pcMacroName );
rInfo.mnCancelIndex = nCancelIndex;
rInfo.maUserData = rUserData;
}
// private --------------------------------------------------------------------
+void VbaEventsHelperBase::startListening()
+{
+ if( mbDisposed )
+ return;
+
+ uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY );
+ if( xEventBroadcaster.is() )
+ try { xEventBroadcaster->addEventListener( this ); } catch( uno::Exception& ) {}
+}
+
+void VbaEventsHelperBase::stopListening()
+{
+ if( mbDisposed )
+ return;
+
+ uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY );
+ if( xEventBroadcaster.is() )
+ try { xEventBroadcaster->removeEventListener( this ); } catch( uno::Exception& ) {}
+
+ mxModel.clear();
+ mpShell = 0;
+ maEventInfos.clear();
+ mbDisposed = true;
+}
+
const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo(
sal_Int32 nEventId ) const throw (lang::IllegalArgumentException)
{
- EventHandlerMap::const_iterator aIt = maEvents.find( nEventId );
- if( aIt == maEvents.end() )
+ EventHandlerInfoMap::const_iterator aIt = maEventInfos.find( nEventId );
+ if( aIt == maEventInfos.end() )
throw lang::IllegalArgumentException();
return aIt->second;
}
-::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo,
- const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException)
+OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo,
+ const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException, uno::RuntimeException)
{
- ::rtl::OUString aMacroName;
- switch( rInfo.meType )
+ OUString aModuleName;
+ switch( rInfo.mnModuleType )
{
- case EVENTHANDLER_GLOBAL:
- aMacroName = rInfo.maMacroName;
+ // global event handlers may exist in any standard code module
+ case script::ModuleType::NORMAL:
break;
- case EVENTHANDLER_DOCUMENT:
- aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ).
- append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear();
+
+ // document event: get name of the code module associated to the event sender
+ case script::ModuleType::DOCUMENT:
+ aModuleName = implGetDocumentModuleName( rInfo, rArgs );
+ if( aModuleName.getLength() == 0 )
+ throw lang::IllegalArgumentException();
break;
+
+ default:
+ throw uno::RuntimeException(); // unsupported module type
}
- MacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false );
- return aMacroInfo.mbFound ? ::rtl::OUString( aMacroInfo.msResolvedMacro ) : ::rtl::OUString();
+
+ /* Performance improvement: Check the list of existing event handlers
+ instead of searching in Basic source code every time. */
+ EventHandlerPathMap::iterator aIt = maEventPaths.find( aModuleName );
+ ModulePathMap& rPathMap = (aIt == maEventPaths.end()) ? updateModulePathMap( aModuleName ) : aIt->second;
+ return rPathMap[ rInfo.mnEventId ];
}
-void VbaEventsHelperBase::stopListening()
+void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException)
{
- if( !mbDisposed ) try
+ if( !mxModuleInfos.is() ) try
{
- uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW );
- xComponent->removeEventListener( this );
+ maLibraryName = getDefaultProjectName( mpShell );
+ if( maLibraryName.getLength() == 0 )
+ throw uno::RuntimeException();
+ uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW );
+ mxModuleInfos.set( xBasicLibs->getByName( maLibraryName ), uno::UNO_QUERY_THROW );
+ // listen to changes in the VBA source code
+ uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModuleInfos, uno::UNO_QUERY_THROW );
+ xChangesNotifier->addChangesListener( this );
}
catch( uno::Exception& )
{
+ // error accessing the Basic library, so this object is useless
+ stopListening();
+ throw uno::RuntimeException();
+ }
+}
+
+sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) throw (uno::RuntimeException)
+{
+ // make sure the VBA library exists
+ ensureVBALibrary();
+
+ // no module specified: global event handler in standard code modules
+ if( rModuleName.getLength() == 0 )
+ return script::ModuleType::NORMAL;
+
+ // get module type from module info
+ try
+ {
+ return mxModuleInfos->getModuleInfo( rModuleName ).ModuleType;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ throw uno::RuntimeException();
+}
+
+VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (uno::RuntimeException)
+{
+ // get type of the specified module (throws on error)
+ sal_Int32 nModuleType = getModuleType( rModuleName );
+ // search for all event handlers
+ ModulePathMap& rPathMap = maEventPaths[ rModuleName ];
+ for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt )
+ {
+ const EventHandlerInfo& rInfo = aIt->second;
+ if( rInfo.mnModuleType == nModuleType )
+ rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName );
}
+ return rPathMap;
}
// ============================================================================
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index cfce8b49e3d1..827d387f031d 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -628,82 +628,85 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
dispatchExecute( pViewShell, SID_VIEWSHELL1 );
}
-bool extractBoolFromAny( bool& rbValue, const uno::Any& rAny )
+sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
{
- if( rAny >>= rbValue ) return true;
-
- sal_Int64 nSigned = 0;
- if( rAny >>= nSigned ) { rbValue = nSigned != 0; return true; }
-
- sal_uInt64 nUnsigned = 0;
- if( rAny >>= nUnsigned ) { rbValue = nUnsigned > 0; return true; }
-
- double fDouble = 0.0;
- if( rAny >>= fDouble ) { rbValue = fDouble != 0.0; return true; }
+ switch( rAny.getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_FLOAT:
+ return static_cast< sal_Int32 >( rAny.get< float >() );
+ case uno::TypeClass_DOUBLE:
+ return static_cast< sal_Int32 >( rAny.get< double >() );
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ return rAny.get< sal_Int32 >();
+ default:;
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to integer." ) ), 0 );
+}
- return false;
+sal_Int32 extractIntFromAny( const uno::Any& rAny, sal_Int32 nDefault ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractIntFromAny( rAny ) : nDefault;
}
bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
{
- bool bValue = false;
- if( extractBoolFromAny( bValue, rAny ) )
- return bValue;
- throw uno::RuntimeException();
+ switch( rAny.getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_FLOAT:
+ return rAny.get< float >() != 0.0;
+ case uno::TypeClass_DOUBLE:
+ return rAny.get< double >() != 0.0;
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ return rAny.get< sal_Int32 >() != 0;
+ case uno::TypeClass_HYPER:
+ return rAny.get< sal_Int64 >() != 0;
+ default:;
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to boolean." ) ), 0 );
}
-rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+bool extractBoolFromAny( const uno::Any& rAny, bool bDefault ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractBoolFromAny( rAny ) : bDefault;
+}
+
+::rtl::OUString extractStringFromAny( const uno::Any& rAny, bool bUppercaseBool ) throw (uno::RuntimeException)
{
- uno::Type aType = pvargItem.getValueType();
- uno::TypeClass eTypeClass = aType.getTypeClass();
- rtl::OUString sString;
- switch ( eTypeClass )
+ switch( rAny.getValueType().getTypeClass() )
{
- case uno::TypeClass_BOOLEAN:
- {
- sal_Bool bBool = sal_False;
- pvargItem >>= bBool;
- sString = rtl::OUString::valueOf( bBool );
- break;
- }
case uno::TypeClass_STRING:
- pvargItem >>= sString;
- break;
+ return rAny.get< ::rtl::OUString >();
+ case uno::TypeClass_BOOLEAN:
+ return bUppercaseBool ?
+ (rAny.get< bool >() ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TRUE" ) ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) )) :
+ ::rtl::OUString::valueOf( (sal_Bool)rAny.get< bool >() );
case uno::TypeClass_FLOAT:
- {
- float aFloat = 0;
- pvargItem >>= aFloat;
- sString = rtl::OUString::valueOf( aFloat );
- break;
- }
+ return ::rtl::OUString::valueOf( rAny.get< float >() );
case uno::TypeClass_DOUBLE:
- {
- double aDouble = 0;
- pvargItem >>= aDouble;
- sString = rtl::OUString::valueOf( aDouble );
- break;
- }
+ return ::rtl::OUString::valueOf( rAny.get< double >() );
+ case uno::TypeClass_BYTE:
case uno::TypeClass_SHORT:
case uno::TypeClass_LONG:
- case uno::TypeClass_BYTE:
- {
- sal_Int32 aNum = 0;
- pvargItem >>= aNum;
- sString = rtl::OUString::valueOf( aNum );
- break;
- }
-
+ return ::rtl::OUString::valueOf( rAny.get< sal_Int32 >() );
case uno::TypeClass_HYPER:
- {
- sal_Int64 aHyper = 0;
- pvargItem >>= aHyper;
- sString = rtl::OUString::valueOf( aHyper );
- break;
- }
- default:
- throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() );
+ return ::rtl::OUString::valueOf( rAny.get< sal_Int64 >() );
+ default:;
}
- return sString;
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to string." ) ), 0 );
+}
+
+::rtl::OUString extractStringFromAny( const uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractStringFromAny( rAny, bUppercaseBool ) : rDefault;
+}
+
+rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+{
+ return extractStringFromAny( pvargItem );
}
@@ -840,7 +843,7 @@ rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike )
return sResult.makeStringAndClear( );
}
-double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
+double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
{
double fConvertFactor = 1.0;
if( bVertical )
@@ -854,12 +857,12 @@ double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt:
return fConvertFactor;
}
-double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
+double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
{
double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
return PointsToHmm( fPoints ) * fConvertFactor;
}
-double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
+double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
{
double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
return HmmToPoints( fPixels/fConvertFactor );
@@ -994,128 +997,176 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r
// ====UserFormGeomentryHelper====
//---------------------------------------------
-UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
-: mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
+UserFormGeometryHelper::UserFormGeometryHelper(
+ const uno::Reference< uno::XComponentContext >& /*xContext*/,
+ const uno::Reference< awt::XControl >& xControl,
+ double fOffsetX, double fOffsetY ) :
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
{
if ( !xControl.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No control is provided!" ) ),
uno::Reference< uno::XInterface >() );
mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW );
+ mxModelProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
+ mxUnitConv.set( mxWindow, uno::UNO_QUERY_THROW );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getLeft()
+double UserFormGeometryHelper::getLeft() const
{
- return mxWindow->getPosSize().X;
+ return implGetPos( false );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setLeft( double nLeft )
+void UserFormGeometryHelper::setLeft( double fLeft )
{
- mxWindow->setPosSize( nLeft, mxWindow->getPosSize().Y, 0, 0, awt::PosSize::POS );
+ implSetPos( fLeft, false );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getTop()
+double UserFormGeometryHelper::getTop() const
{
- return mxWindow->getPosSize().Y;
+ return implGetPos( true );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setTop( double nTop )
+void UserFormGeometryHelper::setTop( double fTop )
{
- mxWindow->setPosSize( mxWindow->getPosSize().X, nTop, 0, 0, awt::PosSize::POS );
+ implSetPos( fTop, true );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getWidth()
+double UserFormGeometryHelper::getWidth() const
{
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // get the size with decoration
- Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
- return aResult.getWidth();
- }
- }
+ return implGetSize( false, true );
+}
- return mxWindow->getPosSize().Width;
+void UserFormGeometryHelper::setWidth( double fWidth )
+{
+ implSetSize( fWidth, false, true );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setWidth( double nWidth )
+double UserFormGeometryHelper::getHeight() const
{
- sal_Int64 nNewWidth = nWidth;
+ return implGetSize( true, true );
+}
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // set the size with decoration
- Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
- if ( !aRDecor.IsEmpty() )
- {
- sal_Int64 nDecor = aRDecor.getWidth();
- sal_Int64 nUnDecor = mxWindow->getPosSize().Width;
- if ( nWidth < nDecor - nUnDecor )
- nUnDecor = nDecor - nWidth; // avoid negative size
- nNewWidth = nWidth + nUnDecor - nDecor;
- }
- }
- }
+void UserFormGeometryHelper::setHeight( double fHeight )
+{
+ implSetSize( fHeight, true, true );
+}
- mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH );
+double UserFormGeometryHelper::getInnerWidth() const
+{
+ return implGetSize( false, false );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getHeight()
+void UserFormGeometryHelper::setInnerWidth( double fWidth )
+{
+ implSetSize( fWidth, false, false );
+}
+
+double UserFormGeometryHelper::getInnerHeight() const
{
- if ( mbDialog )
+ return implGetSize( true, false );
+}
+
+void UserFormGeometryHelper::setInnerHeight( double fHeight )
+{
+ implSetSize( fHeight, true, false );
+}
+
+double UserFormGeometryHelper::getOffsetX() const
+{
+ return mfOffsetX;
+}
+
+double UserFormGeometryHelper::getOffsetY() const
+{
+ return mfOffsetY;
+}
+
+// ----------------------------------------------------------------------------
+
+static const ::rtl::OUString saPosXName( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) );
+static const ::rtl::OUString saPosYName( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) );
+static const ::rtl::OUString saWidthName( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+static const ::rtl::OUString saHeightName( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
+
+double UserFormGeometryHelper::implGetPos( bool bPosY ) const
+{
+ sal_Int32 nPosAppFont = mxModelProps->getPropertyValue( bPosY ? saPosYName : saPosXName ).get< sal_Int32 >();
+ // appfont to pixel
+ awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosAppFont, nPosAppFont ), util::MeasureUnit::APPFONT );
+ // pixel to VBA points
+ awt::Point aPosPoint = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::POINT );
+ return bPosY ? (aPosPoint.Y - mfOffsetY) : (aPosPoint.X - mfOffsetX);
+}
+
+void UserFormGeometryHelper::implSetPos( double fPos, bool bPosY )
+{
+ // convert passed VBA points to pixels
+ sal_Int32 nPosPixel = static_cast< sal_Int32 >( fPos + (bPosY ? mfOffsetY : mfOffsetX) );
+ awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosPixel, nPosPixel ), util::MeasureUnit::POINT );
+ // pixel to appfont
+ awt::Point aPosAppFont = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::APPFONT );
+ mxModelProps->setPropertyValue( bPosY ? saPosYName : saPosXName, uno::Any( bPosY ? aPosAppFont.Y : aPosAppFont.X ) );
+}
+
+double UserFormGeometryHelper::implGetSize( bool bHeight, bool bOuter ) const
+{
+ sal_Int32 nSizeAppFont = mxModelProps->getPropertyValue( bHeight ? saHeightName : saWidthName ).get< sal_Int32 >();
+ // appfont to pixel
+ awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSizeAppFont, nSizeAppFont ), util::MeasureUnit::APPFONT );
+
+ /* The VBA symbols 'Width' and 'Height' return the outer size including
+ window decoration (in difference to the symbols 'InnerWidth' and
+ 'InnerHeight'), but the window API returns the inner size. */
+ if( mbDialog && bOuter )
{
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- // get the size with decoration
- Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
- return aResult.getHeight();
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ aSizePixel = awt::Size( aOuterRect.getWidth(), aOuterRect.getHeight() );
}
}
- return mxWindow->getPosSize().Height;
+ // pixel to VBA points
+ awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT );
+ return bHeight ? aSizePoint.Height : aSizePoint.Width;
}
-//---------------------------------------------
-void UserFormGeometryHelper::setHeight( double nHeight )
+void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter )
{
- sal_Int64 nNewHeight = nHeight;
- if ( mbDialog )
+ // convert passed VBA points to pixels
+ sal_Int32 nSize = static_cast< sal_Int32 >( fSize );
+ awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSize, nSize ), util::MeasureUnit::POINT );
+
+ /* The VBA symbols 'Width' and 'Height' set the outer size (in difference
+ to the symbols 'InnerWidth' and 'InnerHeight'), but the dialog model
+ expects the inner size. We have to remove the window extents from the
+ pixel height to get the same result. */
+ if ( mbDialog && bOuter )
{
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- // set the size with decoration
- Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
- if ( !aRDecor.IsEmpty() )
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ if( !aOuterRect.IsEmpty() )
{
- sal_Int64 nDecor = aRDecor.getHeight();
- sal_Int64 nUnDecor = mxWindow->getPosSize().Height;
- if ( nHeight < nDecor - nUnDecor )
- nUnDecor = nDecor - nHeight; // avoid negative size
- nNewHeight = nHeight + nUnDecor - nDecor;
+ awt::Rectangle aInnerRect = mxWindow->getPosSize();
+ sal_Int32 nDecorWidth = aOuterRect.getWidth() - aInnerRect.Width;
+ sal_Int32 nDecorHeight = aOuterRect.getHeight() - aInnerRect.Height;
+ aSizePixel.Width = ::std::max< sal_Int32 >( aSizePixel.Width - nDecorWidth, 1 );
+ aSizePixel.Height = ::std::max< sal_Int32 >( aSizePixel.Height - nDecorHeight, 1 );
}
}
}
- mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT );
+ awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT );
+ mxModelProps->setPropertyValue( bHeight ? saHeightName : saWidthName, uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) );
}
-// ============
+// ============================================================================
- double ConcreteXShapeGeometryAttributes::getLeft()
+ double ConcreteXShapeGeometryAttributes::getLeft() const
{
return m_pShapeHelper->getLeft();
}
@@ -1123,7 +1174,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
{
m_pShapeHelper->setLeft( nLeft );
}
- double ConcreteXShapeGeometryAttributes::getTop()
+ double ConcreteXShapeGeometryAttributes::getTop() const
{
return m_pShapeHelper->getTop();
}
@@ -1132,7 +1183,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
m_pShapeHelper->setTop( nTop );
}
- double ConcreteXShapeGeometryAttributes::getHeight()
+ double ConcreteXShapeGeometryAttributes::getHeight() const
{
return m_pShapeHelper->getHeight();
}
@@ -1140,7 +1191,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
{
m_pShapeHelper->setHeight( nHeight );
}
- double ConcreteXShapeGeometryAttributes::getWidth()
+ double ConcreteXShapeGeometryAttributes::getWidth() const
{
return m_pShapeHelper->getWidth();
}
@@ -1156,7 +1207,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() );
}
- double ShapeHelper::getHeight()
+ double ShapeHelper::getHeight() const
{
return Millimeter::getInPoints(xShape->getSize().Height);
}
@@ -1177,7 +1228,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getWidth()
+ double ShapeHelper::getWidth() const
{
return Millimeter::getInPoints(xShape->getSize().Width);
}
@@ -1197,7 +1248,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getLeft()
+ double ShapeHelper::getLeft() const
{
return Millimeter::getInPoints(xShape->getPosition().X);
}
@@ -1211,7 +1262,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getTop()
+ double ShapeHelper::getTop() const
{
return Millimeter::getInPoints(xShape->getPosition().Y);
}
@@ -1279,38 +1330,50 @@ void UserFormGeometryHelper::setHeight( double nHeight )
return points;
}
- uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell )
- {
- uno::Reference< uno::XInterface > xIf;
- if ( pShell )
- {
- rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") );
- BasicManager* pBasMgr = pShell->GetBasicManager();
- if ( pBasMgr && pBasMgr->GetName().Len() )
- sProj = pShell->GetBasicManager()->GetName();
- StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj );
- if ( pBasic )
- {
- SbModule* pMod = pBasic->FindModule( aModName );
- if ( pMod )
- xIf = pMod->GetUnoModule();
- }
- }
- return xIf;
- }
+uno::Reference< XHelperInterface > getVBADocument( const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< XHelperInterface > xIf;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xDocProps( xModel, uno::UNO_QUERY_THROW );
+ ::rtl::OUString aCodeName;
+ xDocProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ) >>= aCodeName;
+ xIf = getUnoDocModule( aCodeName, getSfxObjShell( xModel ) );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return xIf;
+}
- SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
- {
- SfxObjectShell* pFoundShell = NULL;
- if ( xModel.is() )
- {
- uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW );
- pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
- }
- if ( !pFoundShell )
- throw uno::RuntimeException();
- return pFoundShell;
- }
+uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell )
+{
+ uno::Reference< XHelperInterface > xIf;
+ if ( pShell )
+ {
+ rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+ BasicManager* pBasMgr = pShell->GetBasicManager();
+ if ( pBasMgr && pBasMgr->GetName().Len() )
+ sProj = pBasMgr->GetName();
+ if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) )
+ if( SbModule* pMod = pBasic->FindModule( aModName ) )
+ xIf.set( pMod->GetUnoModule(), uno::UNO_QUERY );
+ }
+ return xIf;
+}
+
+SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ SfxObjectShell* pFoundShell = NULL;
+ if ( xModel.is() )
+ {
+ uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW );
+ pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
+ }
+ if ( !pFoundShell )
+ throw uno::RuntimeException();
+ return pFoundShell;
+}
} // openoffice
} //org
diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx
index 54546a394690..132caef8b5e1 100644
--- a/vbahelper/source/vbahelper/vbawindowbase.cxx
+++ b/vbahelper/source/vbahelper/vbawindowbase.cxx
@@ -24,137 +24,113 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <vbahelper/helperdecl.hxx>
-#include <vbahelper/vbawindowbase.hxx>
-#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/awt/XWindow2.hpp>
+
+#include "vbahelper/vbawindowbase.hxx"
+#include "vbahelper/helperdecl.hxx"
#include <com/sun/star/awt/PosSize.hpp>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
-VbaWindowBase::VbaWindowBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowBaseImpl_BASE( xParent, xContext ), m_xModel( xModel )
+VbaWindowBase::VbaWindowBase(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) :
+ WindowBaseImpl_BASE( xParent, xContext ),
+ m_xModel( xModel, uno::UNO_SET_THROW )
{
+ construct( xController );
}
-VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext )
- : WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ),
- m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) )
+VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args,
+ uno::Reference< uno::XComponentContext > const & xContext ) throw (uno::RuntimeException) :
+ WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ),
+ m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) )
{
+ construct( getXSomethingFromArgs< frame::XController >( args, 2 ) );
}
sal_Bool SAL_CALL
VbaWindowBase::getVisible() throw (uno::RuntimeException)
{
- sal_Bool bVisible = sal_True;
- uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow2 > xWindow2 (xWindow, uno::UNO_QUERY_THROW );
- if( xWindow2.is() )
- {
- bVisible = xWindow2->isVisible();
- }
- return bVisible;
+ return getWindow2()->isVisible();
}
void SAL_CALL
-VbaWindowBase::setVisible(sal_Bool _visible) throw (uno::RuntimeException)
-{
- uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
- {
- xWindow->setVisible( _visible );
- }
-}
-
-css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel )
+VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect;
- uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
- {
- aRect = xWindow->getPosSize();
- }
- return aRect;
+ getWindow2()->setVisible( _visible );
}
-void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, sal_uInt16 nFlag )
+void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 nFlag )
{
- uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
+ css::awt::Rectangle aRect = xWindow->getPosSize();
+ switch( nFlag )
{
- css::awt::Rectangle aRect = xWindow->getPosSize();
- switch( nFlag )
- {
- case css::awt::PosSize::X:
- xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X );
- break;
- case css::awt::PosSize::Y:
- xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y );
- break;
- case css::awt::PosSize::WIDTH:
- xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH );
- break;
- case css::awt::PosSize::HEIGHT:
- xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT );
- break;
- default:
- break;
- }
+ case css::awt::PosSize::X:
+ xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X );
+ break;
+ case css::awt::PosSize::Y:
+ xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y );
+ break;
+ case css::awt::PosSize::WIDTH:
+ xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH );
+ break;
+ case css::awt::PosSize::HEIGHT:
+ xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT );
+ break;
+ default:
+ break;
}
}
sal_Int32 SAL_CALL
VbaWindowBase::getHeight() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Height;
+ return getWindow()->getPosSize().Height;
}
void SAL_CALL
VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT);
+ setPosSize( getWindow(), _height, css::awt::PosSize::HEIGHT );
}
sal_Int32 SAL_CALL
VbaWindowBase::getLeft() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.X;
+ return getWindow()->getPosSize().X;
}
void SAL_CALL
VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _left, css::awt::PosSize::X);
+ setPosSize( getWindow(), _left, css::awt::PosSize::X );
}
+
sal_Int32 SAL_CALL
VbaWindowBase::getTop() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Y;
+ return getWindow()->getPosSize().Y;
}
void SAL_CALL
VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _top, css::awt::PosSize::Y);
+ setPosSize( getWindow(), _top, css::awt::PosSize::Y );
}
+
sal_Int32 SAL_CALL
VbaWindowBase::getWidth() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Width;
+ return getWindow()->getPosSize().Width;
}
void SAL_CALL
VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH);
+ setPosSize( getWindow(), _width, css::awt::PosSize::WIDTH );
}
rtl::OUString&
@@ -175,3 +151,27 @@ VbaWindowBase::getServiceNames()
}
return aServiceNames;
}
+
+uno::Reference< frame::XController > VbaWindowBase::getController() throw (css::uno::RuntimeException)
+{
+ return uno::Reference< frame::XController >( m_xController, uno::UNO_SET_THROW );
+}
+
+uno::Reference< awt::XWindow > VbaWindowBase::getWindow() throw (uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow >( m_xWindow, uno::UNO_SET_THROW );
+}
+
+uno::Reference< awt::XWindow2 > VbaWindowBase::getWindow2() throw (uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow2 >( getWindow(), uno::UNO_QUERY_THROW );
+}
+
+void VbaWindowBase::construct( const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException)
+{
+ if( !xController.is() ) throw uno::RuntimeException();
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ m_xController = xController;
+ m_xWindow = xWindow;
+}