ooo-build r15339 - in trunk: . patches/dev300 patches/scsolver patches/vba



Author: noelpwer
Date: Mon Feb 16 15:21:31 2009
New Revision: 15339
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15339&view=rev

Log:
2009-02-16  Noel Power <noel power novell com>

        * patches/dev300/apply: add initial word support work ( and import
        of vba project name )
        * patches/vba/vba-word-support.diff:
        * patches/scsolver/scsolver-sc-build-lst.diff:



Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply
   trunk/patches/scsolver/scsolver-sc-build-lst.diff
   trunk/patches/vba/vba-word-support.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Mon Feb 16 15:21:31 2009
@@ -1729,6 +1729,7 @@
 # filter to read custom toolbars ( and other customization data ) from writer
 word-read-custom-toolbar-filter.diff, noelpwer
 
+vba-word-support.diff
 [ VBAUntested ]
 SectionOwner => noelpwer
 vba-basic-null.diff i#85349, jjiao

Modified: trunk/patches/scsolver/scsolver-sc-build-lst.diff
==============================================================================
--- trunk/patches/scsolver/scsolver-sc-build-lst.diff	(original)
+++ trunk/patches/scsolver/scsolver-sc-build-lst.diff	Mon Feb 16 15:21:31 2009
@@ -3,8 +3,8 @@
 --- sc/prj/build.lst
 +++ sc/prj/build.lst
 @@ -1,4 +1,4 @@
--sc	sc	:	oovbaapi svx stoc uui BOOST:boost formula oox NULL
-+sc	sc	:	SCSOLVER:scsolver oovbaapi svx stoc uui BOOST:boost formula oox NULL
+-sc	sc	:	vbahelper oovbaapi svx stoc uui BOOST:boost formula oox NULL
++sc	sc	:	SCSOLVER:scsolver vbahelper oovbaapi svx stoc uui BOOST:boost formula oox NULL
  sc	sc										usr1	-	all	sc_mkout NULL
  sc	sc\inc									nmake	-	all	sc_inc NULL
  sc	sc\uiconfig\layout									nmake	-	all	sc_layout NULL

Modified: trunk/patches/vba/vba-word-support.diff
==============================================================================
--- trunk/patches/vba/vba-word-support.diff	(original)
+++ trunk/patches/vba/vba-word-support.diff	Mon Feb 16 15:21:31 2009
@@ -1,5 +1,18 @@
+diff --git basic/inc/basic/basmgr.hxx basic/inc/basic/basmgr.hxx
+index 2674c59..4000169 100644
+--- basic/inc/basic/basmgr.hxx
++++ basic/inc/basic/basmgr.hxx
+@@ -231,6 +231,8 @@ public:
+     ::com::sun::star::uno::Any
+                     SetGlobalUNOConstant( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rValue );
+ 
++    /** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */
++                    bool GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut );
+     /** determines whether there are password-protected modules whose size exceedes the
+         legacy module size
+         @param _out_rModuleNames
 diff --git basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
-index 3c7e149..a62b1fb 100644
+index 3c7e149..5f2d594 100644
 --- basic/inc/basic/sbstar.hxx
 +++ basic/inc/basic/sbstar.hxx
 @@ -75,6 +75,10 @@ class StarBASIC : public SbxObject
@@ -7,8 +20,8 @@
  	BasicLibInfo*	pLibInfo;			// Infoblock fuer Basic-Manager
  	SbLanguageMode	eLanguageMode;		// LanguageMode des Basic-Objekts
 +
-+	SbxArrayRef pVBAGlobals; 
-+	SbxArray* getVBAGlobals( );
++	SbxObjectRef pVBAGlobals; 
++	SbxObject* getVBAGlobals( );
 +
  protected:
  	BOOL 			CError( SbError, const String&, xub_StrLen, xub_StrLen, xub_StrLen );
@@ -22,7 +35,7 @@
  
  #ifndef __SB_SBSTARBASICREF_HXX
 diff --git basic/prj/d.lst basic/prj/d.lst
-index d920102..fc5f94c 100644
+index d2a083e..7256aa1 100644
 --- basic/prj/d.lst
 +++ basic/prj/d.lst
 @@ -7,6 +7,8 @@ mkdir: %COMMON_DEST%\res%_EXT%
@@ -34,7 +47,7 @@
  ..\%__SRC%\srs\classes.srs %_DEST%\res%_EXT%\basic.srs
  ..\%COMMON_OUTDIR%\srs\classes_srs.hid %COMMON_DEST%\res%_EXT%\basic_srs.hid
  ..\%__SRC%\bin\sb?????.dll %_DEST%\bin%_EXT%\sb?????.dll
-@@ -57,4 +59,8 @@ mkdir: %_DEST%\inc%_EXT%\basic
+@@ -56,4 +58,8 @@ mkdir: %_DEST%\inc%_EXT%\basic
  ..\inc\basic\sbxmstrm.hxx %_DEST%\inc%_EXT%\basic\sbxmstrm.hxx
  
  ..\inc\basic\basicmanagerrepository.hxx %_DEST%\inc%_EXT%\basic\basicmanagerrepository.hxx
@@ -43,51 +56,47 @@
 +..\inc\basic\helperdecl.hxx %_DEST%\inc%_EXT%\basic\helperdecl.hxx
 +..\inc\basic\vbahelperinterface.hxx %_DEST%\inc%_EXT%\basic\vbahelperinterface.hxx
  ..\inc\modsizeexceeded.hxx %_DEST%\inc%_EXT%\basic\modsizeexceeded.hxx
-diff --git basic/source/app/brkpnts.cxx basic/source/app/brkpnts.cxx
-index 79f702b..66cf563 100644
---- basic/source/app/brkpnts.cxx
-+++ basic/source/app/brkpnts.cxx
-@@ -111,7 +111,7 @@ void BreakpointWindow::SetBPsInModule()
- 	{
- 		pModule->SetBP( (USHORT)pBrk->nLine );
- #if OSL_DEBUG_LEVEL > 1
--		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" )
-+		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" );
- #endif
- 		pBrk = Next();
- 	}
-@@ -152,7 +152,7 @@ void BreakpointWindow::InsertBreakpoint( USHORT nLine )
- 	if ( pModule->SetBP( nLine ) )
- 	{
- #if OSL_DEBUG_LEVEL > 1
--		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" )
-+		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" );
- #endif
- 		if ( StarBASIC::IsRunning() )
- 		{
-@@ -165,7 +165,7 @@ void BreakpointWindow::InsertBreakpoint( USHORT nLine )
- 		}
- 	}
- #if OSL_DEBUG_LEVEL > 1
--	DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" )
-+	DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" );
- #endif
+diff --git basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
+index 1c8962c..63c4376 100644
+--- basic/source/basmgr/basmgr.cxx
++++ basic/source/basmgr/basmgr.cxx
+@@ -48,6 +48,7 @@
+ 
+ #include <basic/sbuno.hxx>
+ #include <basic/basmgr.hxx>
++#include <sbunoobj.hxx>
+ #include "basrid.hxx"
+ #include "sbintern.hxx"
+ #include <sb.hrc>
+@@ -1833,6 +1834,23 @@ BasicError* BasicManager::GetNextError()
+ 	DBG_CHKTHIS( BasicManager, 0 );
+ 	return pErrorMgr->GetNextError();
  }
++bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut )
++{
++    bool bRes = false;
++    StarBASIC* pStandardLib = GetStdLib();
++    OSL_PRECOND( pStandardLib, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" );
++    if ( pStandardLib )
++    {
++        ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
++        SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( pStandardLib->Find( sVarName, SbxCLASS_DONTCARE ) );
++        if ( pGlobs )
++        {
++            aOut = pGlobs->getUnoAny(); 
++            bRes = true;
++        } 
++    }
++    return bRes;
++}
  
-@@ -282,7 +282,7 @@ void BreakpointWindow::Paint( const Rectangle& )
- 	while ( pBrk )
- 	{
- #if OSL_DEBUG_LEVEL > 1
--		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" )
-+		DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" );
- #endif
- 		ULONG nLine = pBrk->nLine-1;
- 		ULONG nY = nLine*nLineHeight - nCurYOffset;
+ Any BasicManager::SetGlobalUNOConstant( const sal_Char* _pAsciiName, const Any& _rValue )
+ {
 diff --git basic/source/classes/sb.cxx basic/source/classes/sb.cxx
-index 349c2cc..b149e96 100644
+index c237096..6425913 100644
 --- basic/source/classes/sb.cxx
 +++ basic/source/classes/sb.cxx
-@@ -70,7 +70,50 @@ SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
+@@ -70,7 +70,29 @@ SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
  TYPEINIT1(StarBASIC,SbxObject)
  
  #define RTLNAME "@SBRTL"
@@ -96,19 +105,10 @@
 +const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") );
 +const static String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) );
 +
-+SbxArray* StarBASIC::getVBAGlobals( )
++SbxObject* StarBASIC::getVBAGlobals( )
 +{
 +	if ( !pVBAGlobals )
-+	{
-+		SbUnoObject* pGlobs = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE );
-+		if ( pGlobs )
-+		{ 
-+			SbxVariable *vba = pGlobs->Find( String( RTL_CONSTASCII_USTRINGPARAM("getGlobals") ) , SbxCLASS_DONTCARE );
-+	
-+			if ( vba )
-+				pVBAGlobals = static_cast<SbxArray *>(vba->GetObject());
-+		}
-+	}
++		pVBAGlobals = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE );
 +	return pVBAGlobals;
 +}
 +
@@ -118,27 +118,15 @@
 +	if( rName == aThisComponent )
 +		return NULL;
 +	// rename to init globals
-+	getVBAGlobals( );
-+
-+	for (USHORT i = 0; pVBAGlobals && i < pVBAGlobals->Count(); i++)
-+	{
-+		SbxVariable *pElem = pVBAGlobals->Get( i );
-+		if (!pElem || !pElem->IsObject())
-+			continue;
-+		SbxObject *pVba = static_cast<SbxObject *>(pElem->GetObject());
-+		SbxVariable *pVbaVar = pVba ? pVba->Find( rName, t ) : NULL;
-+		if( pVbaVar )
-+		{
-+			return pVbaVar;
-+		}
-+	}
++	if ( getVBAGlobals( ) )
++		return pVBAGlobals->Find( rName, t );
 +	return NULL;
 +
 +}
  
  //========================================================================
  // Array zur Umrechnung SFX <-> VB-Fehlercodes anlegen
-@@ -609,6 +652,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic  )
+@@ -609,6 +631,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic  )
  	pRtl = new SbiStdObject( String( RTL_CONSTASCII_USTRINGPARAM(RTLNAME) ), this );
  	// Suche ueber StarBASIC ist immer global
  	SetFlag( SBX_GBLSEARCH );
@@ -146,6 +134,42 @@
  }
  
  // #51727 SetModified ueberladen, damit der Modified-
+diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
+index f9d0303..cf5b5a5 100644
+--- basic/source/classes/sbxmod.cxx
++++ basic/source/classes/sbxmod.cxx
+@@ -1781,13 +1781,20 @@ void SbUserFormModule::InitObject()
+     try
+     {
+ 
+-        if ( m_xModel.is() )
++        String aHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) );
++        SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE ); 
++        if ( m_xModel.is() && pGlobs )
+         {
++            
++            uno::Reference< lang::XMultiServiceFactory > xVBAFactory( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW );
+             uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
+             uno::Sequence< uno::Any > aArgs(1);
+             aArgs[ 0 ] <<= m_xModel;
+             rtl::OUString sDialogUrl( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:" ) );
+-            sDialogUrl = sDialogUrl.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) ); 
++            rtl::OUString sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") );
++            if ( this->GetParent()->GetName().Len() )
++                sProjectName = this->GetParent()->GetName(); 
++            sDialogUrl = sDialogUrl.concat( sProjectName ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) ); 
+ 
+             uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DialogProvider")), aArgs  ), uno::UNO_QUERY_THROW );
+             m_xDialog = xProvider->createDialog( sDialogUrl );
+@@ -1797,7 +1804,7 @@ void SbUserFormModule::InitObject()
+             aArgs[ 0 ] = uno::Any();
+             aArgs[ 1 ] <<= m_xDialog;
+             aArgs[ 2 ] <<= m_xModel;
+-            pDocObject = new SbUnoObject( GetName(), uno::makeAny( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm")), aArgs  ) ) );
++            pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs  ) ) );
+             uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW );
+             // remove old listener if it exists
+             FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() );
 diff --git basic/source/inc/runtime.hxx basic/source/inc/runtime.hxx
 index 93cc5f6..5a1bff2 100644
 --- basic/source/inc/runtime.hxx
@@ -158,6 +182,50 @@
  public:
  	SbiRuntime*  pRun;        		// Call-Stack
  	SbiInstance* pNext;             // Instanzen-Chain
+diff --git basic/source/runtime/methods.cxx basic/source/runtime/methods.cxx
+index 0a7a30e..72219ee 100644
+--- basic/source/runtime/methods.cxx
++++ basic/source/runtime/methods.cxx
+@@ -844,6 +844,15 @@ RTLFUNC(SendKeys) // JSM
+ 	StarBASIC::Error(SbERR_NOT_IMPLEMENTED);
+ }
+ 
++// Stub, basic already yields by default
++RTLFUNC(DoEvents)
++{
++    (void)pBasic;
++    (void)bWrite;
++
++	rPar.Get(0)->PutInteger( 0 );
++}
++
+ RTLFUNC(Exp)
+ {
+     (void)pBasic;
+diff --git basic/source/runtime/rtlproto.hxx basic/source/runtime/rtlproto.hxx
+index afba8c4..3564a46 100644
+--- basic/source/runtime/rtlproto.hxx
++++ basic/source/runtime/rtlproto.hxx
+@@ -167,6 +167,7 @@ extern RTLFUNC(Kill); // JSM
+ extern RTLFUNC(MkDir); // JSM
+ extern RTLFUNC(RmDir); // JSM
+ extern RTLFUNC(SendKeys); // JSM
++extern RTLFUNC(DoEvents);
+ extern RTLFUNC(DimArray);
+ extern RTLFUNC(Dir);
+ extern RTLFUNC(Exp);
+diff --git basic/source/runtime/stdobj.cxx basic/source/runtime/stdobj.cxx
+index 7d417a2..a6bfaf8 100644
+--- basic/source/runtime/stdobj.cxx
++++ basic/source/runtime/stdobj.cxx
+@@ -478,6 +478,7 @@ static Methods aMethods[] = {
+ { "SendKeys",       SbxNULL,      2 | _FUNCTION, RTLNAME(SendKeys),0        },
+   { "String",       SbxSTRING, 0,NULL,0 },
+   { "Wait",         SbxBOOL,          _OPT, NULL,0 },
++{ "DoEvents",       SbxINTEGER,      0 | _FUNCTION, RTLNAME(DoEvents),0        },
+ { "SetAttr",        SbxNULL,      2 | _FUNCTION, RTLNAME(SetAttr),0         },
+   { "File"  ,       SbxSTRING, 0,NULL,0 },
+   { "Attributes",   SbxINTEGER, 0,NULL,0 },
 diff --git basic/source/runtime/step2.cxx basic/source/runtime/step2.cxx
 index a9ea4b1..38e794d 100644
 --- basic/source/runtime/step2.cxx
@@ -260,6 +328,73 @@
  					rtl::OUString sCodeName;	
  					sCodeName = xNameQuery->getCodeNameForObject( xIf );
  					Reference< XPropertySet > xProps( xIf, UNO_QUERY );
+diff --git offapi/com/sun/star/document/XCompatWriterDocProperties.idl offapi/com/sun/star/document/XCompatWriterDocProperties.idl
+new file mode 100644
+index 0000000..435ffb3
+--- /dev/null
++++ offapi/com/sun/star/document/XCompatWriterDocProperties.idl
+@@ -0,0 +1,49 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XDocumentProperties.idl,v $
++ * $Revision: 1.5 $
++ *
++ * 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 __com_sun_star_document_XCompatWriterDocProperties_idl__
++#define __com_sun_star_document_XCompatWriterDocProperties_idl__
++
++#ifndef __com_sun_star_document_XDocumentProperties_idl__
++#include <com/sun/star/document/XDocumentProperties.idl>
++#endif
++//=============================================================================
++
++module com {   module sun {   module star {   module document {
++interface XCompatWriterDocProperties
++{
++//    interface ::com::sun::star::document::XDocumentProperties;
++    [attribute] string Manager;
++    [attribute] string Category;
++    [attribute] string Company;
++
++
++}; }; }; };
++};
++#endif
+diff --git offapi/com/sun/star/document/makefile.mk offapi/com/sun/star/document/makefile.mk
+index 342ea99..9ab674c 100644
+--- offapi/com/sun/star/document/makefile.mk
++++ offapi/com/sun/star/document/makefile.mk
+@@ -118,6 +118,7 @@ IDLFILES=\
+     XDocumentLanguages.idl \
+     XCodeNameQuery.idl \
+     XDocumentEventCompatibleHelper.idl \
++    XCompatWriterDocProperties.idl \
+     VbaEventId.idl \
+     XVbaEventsHelper.idl \
+     VbaEventsHelper.idl \
 diff --git oovbaapi/ooo/vba/ControlProvider.idl oovbaapi/ooo/vba/ControlProvider.idl
 new file mode 100644
 index 0000000..4db6ce8
@@ -320,6 +455,127 @@
 +
 +#endif
 +
+diff --git oovbaapi/ooo/vba/Globals.idl oovbaapi/ooo/vba/Globals.idl
+deleted file mode 100644
+index 21863c3..0000000
+--- oovbaapi/ooo/vba/Globals.idl
++++ /dev/null
+@@ -1,48 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: Globals.idl,v $
+- * $Revision: 1.3 $
+- *
+- * 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_Globals_idl__
+-#define __ooo_vba_Globals_idl__
+-
+-#ifndef __ooo_vba_XGlobals_idl__
+-#include <ooo/vba/XGlobals.idl>
+-#endif
+-
+-#include <com/sun/star/uno/XComponentContext.idl>
+-#include <com/sun/star/table/XCellRange.idl>
+-
+-module ooo {  module vba {
+-service Globals : XGlobals
+-{
+-};
+-
+-}; };
+-
+-#endif
+diff --git oovbaapi/ooo/vba/XApplicationBase.idl oovbaapi/ooo/vba/XApplicationBase.idl
+new file mode 100644
+index 0000000..bd2fa27
+--- /dev/null
++++ oovbaapi/ooo/vba/XApplicationBase.idl
+@@ -0,0 +1,61 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __ooo_vba_XApplicationBase_idl__
++#define __ooo_vba_XApplicationBase_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++module ooo {  module vba { 
++//=============================================================================
++
++interface XApplicationBase
++{
++	interface ::ooo::vba::XHelperInterface;
++
++	[attribute] boolean ScreenUpdating;
++	[attribute] boolean DisplayStatusBar;
++
++    any CommandBars( [in] any aIndex );
++};
++
++}; };
++
++#endif
 diff --git oovbaapi/ooo/vba/XControlProvider.idl oovbaapi/ooo/vba/XControlProvider.idl
 new file mode 100644
 index 0000000..cd0c68d
@@ -390,56 +646,48 @@
 +
 +#endif
 +
-diff --git oovbaapi/ooo/vba/makefile.mk oovbaapi/ooo/vba/makefile.mk
-index 11188d5..1a500d8 100644
---- oovbaapi/ooo/vba/makefile.mk
-+++ oovbaapi/ooo/vba/makefile.mk
-@@ -55,6 +55,8 @@ IDLFILES=\
- 	XCommandBarPopup.idl\
- 	XCommandBarButton.idl\
- 	Globals.idl\
-+	XControlProvider.idl\
-+	ControlProvider.idl\
- 
- # ------------------------------------------------------------------
- 
-diff --git oovbaapi/ooo/vba/word/XApplication.idl oovbaapi/ooo/vba/word/XApplication.idl
+diff --git oovbaapi/ooo/vba/XDocumentBase.idl oovbaapi/ooo/vba/XDocumentBase.idl
 new file mode 100644
-index 0000000..292399b
+index 0000000..aab3c8e
 --- /dev/null
-+++ oovbaapi/ooo/vba/word/XApplication.idl
-@@ -0,0 +1,57 @@
++++ oovbaapi/ooo/vba/XDocumentBase.idl
+@@ -0,0 +1,67 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: XApplication.idl,v $
-+ * $Revision: 1.4 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef __ooo_vba_word_XApplication_idl__
-+#define __ooo_vba_word_XApplication_idl__
++#ifndef __ooo_vba_XDocumentBase_idl__
++#define __ooo_vba_XDocumentBase_idl__
 +
 +#ifndef __com_sun_star_uno_XInterface_idl__
 +#include <com/sun/star/uno/XInterface.idl>
@@ -449,29 +697,34 @@
 +#include <ooo/vba/XHelperInterface.idl>
 +#endif
 +
++module ooo {  module vba { 
++//=============================================================================
 +
-+module ooo {  module vba {  module word { 
-+
-+interface XApplication
++interface XDocumentBase
 +{
-+
 +	interface ::ooo::vba::XHelperInterface;
 +
-+	[attribute, readonly] string Name;
-+	void DoEvents();
++	[attribute, readonly] string  Name;
++	[attribute, readonly] string  Path;
++	[attribute, readonly] string  FullName;
++	[attribute] boolean Saved;
++
++	void Close([in] any SaveChanges, [in] any FileName, [in] any RouteWorkBook);
++	void Save();
++	void Activate();
++	void Protect( [in] any Password );
++	void Unprotect( [in] any Password );
 +};
 +
-+}; }; };
++}; };
 +
 +#endif
-+
-+
-diff --git oovbaapi/ooo/vba/word/XGlobals.idl oovbaapi/ooo/vba/word/XGlobals.idl
+diff --git oovbaapi/ooo/vba/XDocumentProperties.idl oovbaapi/ooo/vba/XDocumentProperties.idl
 new file mode 100644
-index 0000000..3c144a6
+index 0000000..2bf926c
 --- /dev/null
-+++ oovbaapi/ooo/vba/word/XGlobals.idl
-@@ -0,0 +1,54 @@
++++ oovbaapi/ooo/vba/XDocumentProperties.idl
+@@ -0,0 +1,71 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -480,7 +733,7 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: XGlobals.idl,v $
++ * $RCSfile: XDocument.idl,v $
 + * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
@@ -501,499 +754,239 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef __ooo_vba_word_XGlobals_idl__
-+#define __ooo_vba_word_XGlobals_idl__
 +
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
++#ifndef __ooo_vba_XDocumentProperties_idl__
++#define __ooo_vba_XDocumentProperties_idl__
++
++#ifndef __com_sun_star_script_BasicErrorException_idl__
++#include <com/sun/star/script/BasicErrorException.idl>
 +#endif
-+#ifndef __ooo_vba_word_XApplication_idl__
-+#include <ooo/vba/word/XApplication.idl>
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++#ifndef __ooo_vba_XCollection_idl__
++#include <ooo/vba/XCollection.idl>
 +#endif
 +
-+module ooo {  module vba {  module word { 
-+
-+interface XGlobals: com::sun::star::uno::XInterface
-+{
-+        // FIXME, need better way to expose globals
-+	sequence< any > getGlobals();
-+
-+	[attribute, readonly] ooo::vba::word::XApplication Application;
++module ooo { module vba { 
++interface XDocumentProperty;
++interface XDocumentProperties
++{
++    interface XCollection;
++    /** Creates a new custom document property.
++     * You can only add a new document property to the custom DocumentProperties collection. Depending on value of
++     * boolean LinkSource, either (False) Value or (True) LinkSource must be provided.
++     * @param Name (Required String. The name of the property.
++     * @param LinkToContent Specifies whether the property is linked to the contents of the container document. If this argument is True, the LinkSource argument is required; if it's False, the value argument is required.
++     * @param Type The data type of the property. Can be one of the following MsoDocProperties constants:
++     * msoPropertyTypeBoolean, msoPropertyTypeDate, msoPropertyTypeFloat, msoPropertyTypeNumber, or msoPropertyTypeString.
++     * @param Value The value of the property, if it's not linked to the contents of the container document.
++     * The value is converted to match the data type specified by the type argument, if it can't be converted, an error occurs.
++     * If LinkToContent is True, the Value argument is ignored and the new document property is assigned a default value
++     * until the linked property values are updated by the container application (usually when the document is saved).
++     * @param LinkSource Ignored if LinkToContent is False. The source of the linked property. The container application determines
++     * what types of source linking you can use.
++     */
++    XDocumentProperty Add([in] string Name, [in] boolean LinkToContent, [in] /* MsoDocProperties */ byte Type, [in] any Value, 
++        [in] /*optional*/ any LinkSource)
++        raises (com::sun::star::script::BasicErrorException);
 +};
 +
-+}; }; };
++}; };
 +
 +#endif
 +
-+
-diff --git oovbaapi/ooo/vba/word/makefile.mk oovbaapi/ooo/vba/word/makefile.mk
+diff --git oovbaapi/ooo/vba/XDocumentProperty.idl oovbaapi/ooo/vba/XDocumentProperty.idl
 new file mode 100644
-index 0000000..27f6b68
+index 0000000..1357b1e
 --- /dev/null
-+++ oovbaapi/ooo/vba/word/makefile.mk
-@@ -0,0 +1,50 @@
-+#*************************************************************************
-+#
-+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+# 
-+# Copyright 2008 by Sun Microsystems, Inc.
-+#
-+# OpenOffice.org - a multi-platform office productivity suite
-+#
-+# $RCSfile: makefile.mk,v $
-+#
-+# $Revision: 1.4 $
-+#
-+# 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.
-+#
-+#*************************************************************************
-+PRJ=..$/..$/..
++++ oovbaapi/ooo/vba/XDocumentProperty.idl
+@@ -0,0 +1,106 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XDocument.idl,v $
++ * $Revision: 1.4 $
++ *
++ * 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.
++ *
++ ************************************************************************/
 +
-+PRJNAME=oovapi
++#ifndef __ooo_vba_XDocumentProperty_idl__
++#define __ooo_vba_XDocumentProperty_idl__
 +
-+TARGET=word
-+PACKAGE=ooo$/vba$/Word
++#ifndef __com_sun_star_script_BasicErrorException_idl__
++#include <com/sun/star/script/BasicErrorException.idl>
++#endif
++#ifndef __com_sun_star_script_XDefaultProperty_idl__
++#include <com/sun/star/script/XDefaultProperty.idl>
++#endif
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
 +
-+# --- Settings -----------------------------------------------------
-+.INCLUDE :  $(PRJ)$/util$/makefile.pmk
++module ooo { module vba { 
 +
-+# ------------------------------------------------------------------------
++/**
++ * Specific built-in document property. Use CustomDocumentProperties(index),
++ * where index is the name or index number of the custom document property,
++ * to return a DocumentProperty object that represents a specific custom document property.
++ */
++interface XDocumentProperty 
++{
++   
++    interface com::sun::star::script::XDefaultProperty;
++    interface ooo::vba::XHelperInterface;
 +
++    void Delete()
++        raises (com::sun::star::script::BasicErrorException);
 +
-+IDLFILES= XGlobals.idl\
-+	XApplication.idl \
++    /** Required String. The name of the property.
++     */
++    string getName()
++        raises (com::sun::star::script::BasicErrorException);
++
++    void setName([in] string Name)
++        raises (com::sun::star::script::BasicErrorException);
++
++    /** The data type of the property.
++     * Can be one of the following MsoDocProperties constants:
++     * msoPropertyTypeBoolean, msoPropertyTypeDate, msoPropertyTypeFloat,
++     * msoPropertyTypeNumber, or msoPropertyTypeString.
++     */
++    byte getType()
++        raises (com::sun::star::script::BasicErrorException);
++
++    void setType([in] byte Type)
++        raises (com::sun::star::script::BasicErrorException);
++
++    /** If true, then LinkSource has a valid value. */
++    boolean getLinkToContent()
++        raises (com::sun::star::script::BasicErrorException);
++
++    void setLinkToContent([in] boolean LinkToContent)
++        raises (com::sun::star::script::BasicErrorException);
++
++    /** If LinkToContent is false, then this contains the value of the property
++     * The data type of the value will match the Type property.
++     */
++    any getValue()
++        raises (com::sun::star::script::BasicErrorException);
++
++    void setValue([in] any Value)
++        raises (com::sun::star::script::BasicErrorException);
++
++    /** If LinkToContent is false, then this contains the value of the property */
++    string getLinkSource()
++        raises (com::sun::star::script::BasicErrorException);
 +
-+# ------------------------------------------------------------------
++    void setLinkSource([in] string LinkSource)
++        raises (com::sun::star::script::BasicErrorException);
++};
 +
-+.INCLUDE :  target.mk
++}; };
 +
-diff --git oovbaapi/prj/build.lst oovbaapi/prj/build.lst
-index 04060dd..937c864 100644
---- oovbaapi/prj/build.lst
-+++ oovbaapi/prj/build.lst
-@@ -4,5 +4,6 @@ ovba	oovbaapi\genconstidl         nmake	-	all	ovba_genconstidl NULL
- ovba	oovbaapi\ooo\vba\constants          nmake	-	all	ovba_constants  ovba_genconstidl NULL
- ovba	oovbaapi\ooo\vba                    nmake	-	all	ovba_vba NULL
- ovba	oovbaapi\ooo\vba\excel              nmake	-	all	ovba_excel NULL
-+ovba	oovbaapi\ooo\vba\word               nmake	-	all	ovba_word NULL
- ovba	oovbaapi\ooo\vba\msforms            nmake	-	all	ovba_msforms NULL
--ovba   oovbaapi\util                             nmake   -   all ovba_util ovba_vba ovba_excel ovba_msforms ovba_constants ovba_genconstidl NULL
-+ovba   oovbaapi\util                             nmake   -   all ovba_util ovba_vba ovba_excel ovba_word ovba_msforms ovba_constants ovba_genconstidl NULL
-diff --git oovbaapi/util/makefile.mk oovbaapi/util/makefile.mk
-index 4b98130..a0f4982 100644
---- oovbaapi/util/makefile.mk
-+++ oovbaapi/util/makefile.mk
-@@ -44,6 +44,7 @@ TARGET=oovbaapi_db
- UNOIDLDBFILES= \
- 	$(UCR)$/vba.db \
- 	$(UCR)$/excel.db \
-+	$(UCR)$/word.db \
- 	$(UCR)$/msforms.db \
- 	$(UCR)$/constants.db
- 
-diff --git sc/inc/docuno.hxx sc/inc/docuno.hxx
-index f036a23..58ebb35 100644
---- sc/inc/docuno.hxx
-+++ sc/inc/docuno.hxx
-@@ -74,8 +74,6 @@ class ScTableSheetObj;
- class SvxFmDrawPage;
- class SvxDrawPage;
- 
--#include <com/sun/star/document/XCodeNameQuery.hpp>
++#endif
++
+diff --git oovbaapi/ooo/vba/XGlobals.idl oovbaapi/ooo/vba/XGlobals.idl
+deleted file mode 100644
+index 75273c9..0000000
+--- oovbaapi/ooo/vba/XGlobals.idl
++++ /dev/null
+@@ -1,67 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: XGlobals.idl,v $
+- * $Revision: 1.4 $
+- *
+- * 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_XGlobals_idl__
+-#define __ooo_vba_XGlobals_idl__
 -
- class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
- 					public com::sun::star::sheet::XSpreadsheetDocument,
- 					public com::sun::star::document::XActionLockable,
-@@ -89,7 +87,6 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
- 					public com::sun::star::view::XRenderable,
- 					public com::sun::star::document::XLinkTargetSupplier,
- 					public com::sun::star::beans::XPropertySet,
--					public com::sun::star::document::XCodeNameQuery,
-                     public com::sun::star::document::XDocumentEventCompatibleHelper,
- 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
-                     public com::sun::star::lang::XServiceInfo
-@@ -300,8 +297,6 @@ public:
- 								throw(::com::sun::star::uno::RuntimeException);
- 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
- 								throw(::com::sun::star::uno::RuntimeException);
-- 	virtual rtl::OUString SAL_CALL getCodeNameForObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObj )
--								throw(::com::sun::star::uno::RuntimeException);
-                             // XVbaEventHelper
-     virtual sal_Bool SAL_CALL processCompatibleEvent( sal_Int16 nEventId ) throw (::com::sun::star::uno::RuntimeException);
- };
-diff --git sc/inc/servuno.hxx sc/inc/servuno.hxx
-index 3beb852..13950f1 100644
---- sc/inc/servuno.hxx
-+++ sc/inc/servuno.hxx
-@@ -94,7 +94,8 @@ class ScDocShell;
- #define SC_SERVICE_FORMULAPARS  38
- #define SC_SERVICE_OPCODEMAPPER 39
- #define SC_SERVICE_VBAOBJECTPROVIDER   40
--#define SC_SERVICE_COUNT        41
-+#define SC_SERVICE_VBACODENAMEPROVIDER   41
-+#define SC_SERVICE_COUNT        42
- #define SC_SERVICE_INVALID		USHRT_MAX
- 
- 
-diff --git sc/prj/build.lst sc/prj/build.lst
-index 9fa0b02..7ca5f1e 100644
---- sc/prj/build.lst
-+++ sc/prj/build.lst
-@@ -1,4 +1,4 @@
--sc	sc	:	SCSOLVER:scsolver oovbaapi svx stoc uui BOOST:boost NULL
-+sc	sc	:	SCSOLVER:scsolver vbahelper oovbaapi svx stoc uui BOOST:boost NULL
- sc	sc										usr1	-	all	sc_mkout NULL
- sc	sc\inc									nmake	-	all	sc_inc NULL
- sc	sc\prj									get		-	all	sc_prj NULL
-diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
-index 033cb76..b712eb9 100644
---- sc/source/filter/excel/excimp8.cxx
-+++ sc/source/filter/excel/excimp8.cxx
-@@ -103,8 +103,11 @@
- #include <com/sun/star/document/XDocumentProperties.hpp>
- #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
- #include <com/sun/star/script/ModuleInfo.hpp>
-+#include <basic/basmgr.hxx>
-+#include <cppuhelper/component_context.hxx>
- 
+-#ifndef __com_sun_star_uno_XInterface_idl__
+-#include <com/sun/star/uno/XInterface.idl>
+-#endif
+-#ifndef __ooo_vba_excel_XApplication_idl__
+-#include <ooo/vba/excel/XApplication.idl>
+-#endif
+-#ifndef __ooo_vba_excel_XWorkbook_idl__
+-#include <ooo/vba/excel/XWorkbook.idl>
+-#endif
+-#ifndef __ooo_vba_excel_XWorksheet_idl__
+-#include <ooo/vba/excel/XWorksheet.idl>
+-#endif
 -
-+#include <com/sun/star/container/XNameContainer.hpp>
-+ 
- using namespace com::sun::star;
- 
- 
-@@ -280,6 +283,32 @@ void ImportExcel8::ReadBasic( void )
-         bool bLoadStrg = pFilterOpt->IsLoadExcelBasicStorage();
-         if( bLoadCode || bLoadStrg )
-         {
-+            // Create and insert Excel vba Globals
-+            uno::Reference < uno::XComponentContext > xCtx;
-+            uno::Reference < beans::XPropertySet > xProps(
-+            ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+            xCtx.set( xProps->getPropertyValue( rtl::OUString(
-+                RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))),
-+                uno::UNO_QUERY_THROW );
-+            // Create context with 'excel' initially (null) application
-+            ::cppu::ContextEntry_Init aHandlerContextInfo[] =
-+            {
-+                ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Application" ) ), uno::Any() ) 
-+            };
-+
-+            // Create Application with new context
-+
-+            uno::Reference< uno::XComponentContext > xHandlerContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), xCtx );
-+
-+            OSL_TRACE("***** Before creating application");
-+
-+            uno::Any aApplication( xCtx->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Application" ) ), xHandlerContext ) );
-+            uno::Reference< container::XNameContainer > xNameContainer( xHandlerContext, uno::UNO_QUERY_THROW );
-+            xNameContainer->replaceByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application") ), aApplication );
-+            OSL_TRACE("***** After creating application");
-+
-+            uno::Any aGlobs = uno::makeAny( xHandlerContext->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/ooo.vba.theGlobals") ) );
-+            pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
-             SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg );
- 			bool bAsComment = !bLoadExecutable || !lcl_hasVBAEnabled();
-             aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment );
-diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index bd1a653..87556ed 100644
---- sc/source/ui/docshell/docsh.cxx
-+++ sc/source/ui/docshell/docsh.cxx
-@@ -131,7 +131,8 @@
- #include "cellsuno.hxx"
- #include <com/sun/star/document/XVbaEventsHelper.hpp>
- #include <com/sun/star/document/VbaEventId.hpp>
+-module ooo {  module vba { 
 -
-+#include <basic/sbstar.hxx>
-+#include <basic/basmgr.hxx>
- using namespace com::sun::star;
- using namespace com::sun::star::document::VbaEventId;
- 
-@@ -286,6 +287,7 @@ void ScDocShell::BeforeXMLLoading()
-     if ( xEvt.is() )
-        xEvt->setIgnoreEvents( sal_True );
-     
-+// if VBA enabled then we need to  
-     // prevent unnecessary broadcasts and updates
-     DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
- 	pModificator = new ScDocShellModificator( *this );
-@@ -369,7 +371,19 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
-     }
-     else
- 		aDocument.SetInsertingFromOtherDoc( FALSE );
+-interface XGlobals: com::sun::star::uno::XInterface
+-{
+-        // FIXME, need better way to expose globals
+-	sequence< any > getGlobals();
 -
-+	// add vba globals ( if they are availabl )
-+	SfxObjectShell* pShell = aDocument.GetDocumentShell();
-+	if ( pShell )
-+	{
-+		uno::Reference < uno::XComponentContext > xCtx;
-+		uno::Reference < beans::XPropertySet > xProps(
-+			::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+		xCtx.set( xProps->getPropertyValue( rtl::OUString(
-+			RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))),
-+				uno::UNO_QUERY_THROW );
-+		uno::Any aGlobs = uno::makeAny( xCtx->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/ooo.vba.theGlobals") ) );
-+		pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
-+	}
-         // suppress VBA events when loading the xml
-         uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
-         if ( xEvt.is() )
-diff --git sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
-index a340ff2..fd91983 100644
---- sc/source/ui/unoobj/docuno.cxx
-+++ sc/source/ui/unoobj/docuno.cxx
-@@ -107,7 +107,6 @@ using namespace com::sun::star::document::VbaEventId;
- //	alles ohne Which-ID, Map nur fuer PropertySetInfo
- 
- //!	umbenennen, sind nicht mehr nur Options
--#include <com/sun/star/script/ScriptEventDescriptor.hpp>
- const SfxItemPropertyMap* lcl_GetDocOptPropertyMap()
- {
- 	static SfxItemPropertyMap aDocOptPropertyMap_Impl[] =
-@@ -314,7 +313,6 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
- 	SC_QUERYINTERFACE( view::XRenderable )
- 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
- 	SC_QUERYINTERFACE( beans::XPropertySet )
--	SC_QUERYINTERFACE( document::XCodeNameQuery )
- 	SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper)
- 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
- 	SC_QUERYINTERFACE( lang::XServiceInfo )
-@@ -1720,49 +1718,7 @@ uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getAvailableServiceNames()
- 
- 	return concatServiceNames( aMyServices, aDrawServices );
- }
--// XCodeNameQuery
--rtl::OUString SAL_CALL 
--ScModelObj::getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
--{
--    rtl::OUString sCodeName;
--    if ( pDocShell )
--    {
--        OSL_TRACE( "*** In ScModelObj::getCodeNameForObject");
--        // need to find the page ( and index )  for this control
--        uno::Reference< drawing::XDrawPagesSupplier > xSupplier( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
--        uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
--        sal_Int32 nLen = xIndex->getCount();
--        bool bMatched = false;
--        uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
--        for ( sal_Int32 index = 0; index < nLen; ++index )
--        {
--            try
--            {
--                uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
--                uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
--                // get the www-standard container
--                uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
--                sal_Int32 nCntrls = xFormControls->getCount();
--                for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
--                {
--                    uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
--                    bMatched = ( xControl == xIf );
--                    if ( bMatched )
--                    {
--                        String sName;
--                        pDocShell->GetDocument()->GetCodeName( index, sName );
--                        sCodeName = sName;
--                    }
--                }
--            }
--            catch( uno::Exception& ) {}
--            if ( bMatched )
--                break;
--        }
--    }
--    // Probably should throw here ( if !bMatched )
--     return sCodeName;
--}
-+
- // XVbaEventHelper
- // For Vba Event
- sal_Bool SAL_CALL
-diff --git sc/source/ui/unoobj/servuno.cxx sc/source/ui/unoobj/servuno.cxx
-index 83db312..398e00a 100644
---- sc/source/ui/unoobj/servuno.cxx
-+++ sc/source/ui/unoobj/servuno.cxx
-@@ -63,6 +63,12 @@
- #include <svx/xmlgrhlp.hxx>
- 
- #include <comphelper/processfactory.hxx>
-+#include <com/sun/star/document/XCodeNameQuery.hpp>
-+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
-+#include <com/sun/star/form/XFormsSupplier.hpp>
-+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
-+#include <comphelper/componentcontext.hxx>
-+#include <cppuhelper/component_context.hxx>
- 
- using namespace ::com::sun::star;
- 
-@@ -70,24 +76,40 @@ class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container
- {
-     uno::Any maWorkbook;
-     uno::Any maCachedObject;
--    uno::Reference<lang::XMultiServiceFactory> mxSF;
-+    uno::Reference< uno::XComponentContext > mxContext;
-     ScDocShell* mpDocShell;
- public:
-     ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
-     {
--        mxSF.set(comphelper::getProcessServiceFactory());
--        uno::Reference<beans::XPropertySet> xProps(mxSF, uno::UNO_QUERY);
--        if( xProps.is() )
-+        // #FIXME 
-+        // This is copy and paste from excimp8.cxx where we set up a custom
-+        // context. We can't do this ( especially if we want to share a single
-+        // Application object ) we need another way to ensure the vba objects
-+        // are created with the appropriate context.
-+        // idea: add a GetGlobalUnoConstant to basmgr.hxx
-+        //       make XGlobals also support a multiservicefactory, this will
-+        //       provide a single point of contact for creating objects 
-+        //       with the *correct* context
-+        ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
-+        // Create context with 'excel' initially (null) application
-+        ::cppu::ContextEntry_Init aHandlerContextInfo[] =
-         {
--            ScDocument* pDoc = mpDocShell->GetDocument();
--            if ( !pDoc )
--                throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
+-	[attribute, readonly] ooo::vba::excel::XApplication Application;
+-	[attribute, readonly] ooo::vba::excel::XWorkbook ActiveWorkbook;
+-	[attribute, readonly] ooo::vba::excel::XWorksheet ActiveSheet;
+-	any WorkSheets( [in] any aIndex );
+-	any WorkBooks( [in] any aIndex );
+-	any Sheets( [in] any aIndex );
+-	any Range( [in] any Cell1, [in] any Cell2 );
+-	any Names( [in] any Index );
+-};
 -
--            uno::Sequence< uno::Any > aArgs(2);
--            aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
--            aArgs[1] = uno::Any( mpDocShell->GetModel() );
--            maWorkbook <<= mxSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook") ), aArgs );
--        }
-+            ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Application" ) ), uno::Any() ) 
-+        };
-+        mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), aContext.getUNOContext() );
-+
-+       uno::Any aApplication( aContext.getUNOContext()->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Application" ) ), mxContext ) );
-+       uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY_THROW );
-+       xNameContainer->replaceByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application") ), aApplication );
-+
-+        ScDocument* pDoc = mpDocShell->GetDocument();
-+        if ( !pDoc )
-+            throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
-+
-+        uno::Sequence< uno::Any > aArgs(2);
-+        aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
-+        aArgs[1] = uno::Any( mpDocShell->GetModel() );
-+        maWorkbook <<= aContext.getUNOContext()->getServiceManager()->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook") ), aArgs, mxContext );
-     }
- 
-     virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
-@@ -120,7 +142,8 @@ public:
-                         aArgs[0] = maWorkbook;
-                         aArgs[1] = uno::Any( xModel );
-                         aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
--                        maCachedObject <<= mxSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet") ), aArgs );
-+                        ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
-+                        maCachedObject <<= aContext.getUNOContext()->getServiceManager()->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet") ), aArgs, mxContext );
-                         break;
-                     }
-                 }
-@@ -160,6 +183,56 @@ public:
- 
- };
- 
-+class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
-+{
-+ScDocShell* mpDocShell;
-+public:
-+    ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
-+    // XCodeNameQuery
-+    rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
-+    {
-+        rtl::OUString sCodeName;
-+        if ( mpDocShell )
-+        {
-+            OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
-+            // need to find the page ( and index )  for this control
-+            uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
-+            uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
-+            sal_Int32 nLen = xIndex->getCount();
-+            bool bMatched = false;
-+            uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
-+            for ( sal_Int32 index = 0; index < nLen; ++index )
-+            {
-+                try
-+                {
-+                    uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
-+                    uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
-+                    // get the www-standard container
-+                    uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
-+                    sal_Int32 nCntrls = xFormControls->getCount();
-+                    for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
-+                    {
-+                        uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
-+                        bMatched = ( xControl == xIf );
-+                        if ( bMatched )
-+                        {
-+                            String sName;
-+                            mpDocShell->GetDocument()->GetCodeName( index, sName );
-+                            sCodeName = sName;
-+                        }
-+                    }
-+                }
-+                catch( uno::Exception& ) {}
-+                if ( bMatched )
-+                    break;
-+            }
-+        }
-+        // Probably should throw here ( if !bMatched )
-+         return sCodeName;
-+    }
-+
-+};
-+
- //------------------------------------------------------------------------
- 
- static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
-@@ -210,6 +283,7 @@ static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
-         SC_SERVICENAME_FORMULAPARS,                 // SC_SERVICE_FORMULAPARS
-         SC_SERVICENAME_OPCODEMAPPER,                 // SC_SERVICE_OPCODEMAPPER
- "ooo.vba.VBAObjectModuleObjectProvider",// SC_SERVICE_VBAOBJECTPROVIDER
-+"ooo.vba.VBACodeNameProvider",// SC_SERVICE_VBACODENAMEPROVIDER
- 	};
- 
- //
-@@ -263,6 +337,7 @@ static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] =
-         "",                                         // SC_SERVICE_FORMULAPARS
-         "",                                         // SC_SERVICE_OPCODEMAPPER
-         "",                                         // SC_SERVICE_VBAOBJECTPROVIDER
-+        "",                                         // SC_SERVICE_VBACODENAMEPROVIDER
- 	};
- 
- 
-@@ -458,6 +533,9 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
-         case SC_SERVICE_VBAOBJECTPROVIDER:
-             xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
-             break;
-+        case SC_SERVICE_VBACODENAMEPROVIDER:
-+            xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
-+            break;
- 	}
- 	return xRet;
- }
-diff --git sc/source/ui/vba/excelvbahelper.cxx sc/source/ui/vba/excelvbahelper.cxx
+-}; };
+-
+-#endif
+-
+-
+diff --git oovbaapi/ooo/vba/XGlobalsBase.idl oovbaapi/ooo/vba/XGlobalsBase.idl
 new file mode 100644
-index 0000000..1be67f7
+index 0000000..08dfd09
 --- /dev/null
-+++ sc/source/ui/vba/excelvbahelper.cxx
-@@ -0,0 +1,208 @@
++++ oovbaapi/ooo/vba/XGlobalsBase.idl
+@@ -0,0 +1,53 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1002,8 +995,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbahelper.cxx,v $
-+ * $Revision: 1.5.32.1 $
++ * $RCSfile: XGlobals.idl,v $
++ * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -1023,191 +1016,212 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include <docuno.hxx>
-+#include "excelvbahelper.hxx"
-+#include "tabvwsh.hxx"
-+#include "transobj.hxx"
-+#include "scmod.hxx"
-+#include <comphelper/processfactory.hxx>
++#ifndef __ooo_vba_XGlobalsBase_idl__
++#define __ooo_vba_XGlobalsBase_idl__
 +
-+using namespace ::com::sun::star;
-+using namespace ::ooo::vba;
-+
-+namespace ooo
-+{
-+namespace vba
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++#ifndef __com_sun_star_lang_XMultiServiceFactory
++#include <com/sun/star/lang/XMultiServiceFactory.idl>
++#endif
++module ooo {  module vba {
++interface XGlobalsBase
 +{
++	interface ::ooo::vba::XHelperInterface;
++	interface ::com::sun::star::lang::XMultiServiceFactory;
++};
 +
-+bool isInPrintPreview( SfxViewFrame* pView )
-+{
-+	sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
-+	if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() >
-+nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
-+	{
-+		SfxViewFactory &rViewFactory =
-+			pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
-+		if (  pView->GetCurViewId() == rViewFactory.GetOrdinal() )
-+			return true;
-+	}
-+	return false;
-+}
++}; };
 +
-+const ::rtl::OUString REPLACE_CELLS_WARNING(  RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning"));
++#endif
 +
-+class PasteCellsWarningReseter
-+{
-+private:
-+	bool bInitialWarningState;
-+	static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
-+	{
-+		static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+		static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
-+		static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
-+				xContext->getServiceManager(), uno::UNO_QUERY_THROW );
-+		static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
-+		return xProps;
-+	}
 +
-+	bool getReplaceCellsWarning() throw ( uno::RuntimeException )
-+	{
-+		sal_Bool res = sal_False;
-+		getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res;
-+		return ( res == sal_True );
-+	}
+diff --git oovbaapi/ooo/vba/XWindowBase.idl oovbaapi/ooo/vba/XWindowBase.idl
+new file mode 100644
+index 0000000..a6eab8d
+--- /dev/null
++++ oovbaapi/ooo/vba/XWindowBase.idl
+@@ -0,0 +1,62 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __ooo_vba_XHelperWindow_idl__
++#define __ooo_vba_XHelperWindow_idl__
 +
-+	void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException )
-+	{
-+		getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) );
-+	}
-+public:
-+	PasteCellsWarningReseter() throw ( uno::RuntimeException )
-+	{
-+		bInitialWarningState = getReplaceCellsWarning();
-+		if ( bInitialWarningState )
-+			setReplaceCellsWarning( false );
-+	}
-+	~PasteCellsWarningReseter()
-+	{
-+		if ( bInitialWarningState )
-+		{
-+			// don't allow dtor to throw
-+			try
-+			{
-+				setReplaceCellsWarning( true );
-+			}
-+			catch ( uno::Exception& /*e*/ ){}
-+		}
-+	}
-+};
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
 +
-+void
-+implnPaste()
-+{
-+	PasteCellsWarningReseter resetWarningBox;
-+	ScTabViewShell* pViewShell = getCurrentBestViewShell();
-+	if ( pViewShell )
-+	{
-+		pViewShell->PasteFromSystem();
-+		pViewShell->CellContentChanged();
-+	}
-+}
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
 +
++module ooo {  module vba { 
++//=============================================================================
 +
-+void
-+implnCopy()
++interface XWindowBase
 +{
-+	ScTabViewShell* pViewShell = getCurrentBestViewShell();
-+	if ( pViewShell )
-+		pViewShell->CopyToClip(NULL,false,false,true);
-+}
++	interface ::ooo::vba::XHelperInterface;
 +
-+void 
-+implnCut()
-+{
-+	ScTabViewShell* pViewShell =  getCurrentBestViewShell();
-+	if ( pViewShell )
-+		pViewShell->CutToClip( NULL, TRUE );
-+}
++	[attribute] long Height; 
++	[attribute] long Left; 
++	[attribute] long Top; 
++	[attribute] boolean Visible;
++	[attribute] long Width; 
++};
 +
-+void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose)
-+{
-+	PasteCellsWarningReseter resetWarningBox;
-+	sal_Bool bAsLink(sal_False), bOtherDoc(sal_False);
-+	InsCellCmd eMoveMode = INS_NONE;
++}; };
 +
-+	ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell();
-+	if ( !pTabViewShell ) 
-+		// none active, try next best
-+		pTabViewShell = getCurrentBestViewShell();
-+	if ( pTabViewShell )
-+	{
-+		ScViewData* pView = pTabViewShell->GetViewData();	
-+		Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL;
-+		if ( pView && pWin )
-+		{
-+			if ( bAsLink && bOtherDoc )
-+				pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK
-+			else 
-+			{
-+				ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
-+				ScDocument* pDoc = NULL; 
-+				if ( pOwnClip )
-+					pDoc = pOwnClip->GetDocument();	
-+				pTabViewShell->PasteFromClip( nFlags, pDoc,
-+					nFunction, bSkipEmpty, bTranspose, bAsLink,
-+					eMoveMode, IDF_NONE, TRUE );
-+				pTabViewShell->CellContentChanged();
-+			}
-+		}
-+	}
++#endif
+diff --git oovbaapi/ooo/vba/excel/Globals.idl oovbaapi/ooo/vba/excel/Globals.idl
+new file mode 100644
+index 0000000..f06be2b
+--- /dev/null
++++ oovbaapi/ooo/vba/excel/Globals.idl
+@@ -0,0 +1,48 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: Globals.idl,v $
++ * $Revision: 1.3 $
++ *
++ * 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_excel_Globals_idl__
++#define __ooo_vba_excel_Globals_idl__
 +
-+ScDocShell* 
-+getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) 
-+{
-+	uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
-+	ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() );
-+	ScDocShell* pDocShell = NULL;
-+	if ( pModel )
-+		pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
-+	return pDocShell;
++#ifndef __ooo_vba_excel_XGlobals_idl__
++#include <ooo/vba/excel/XGlobals.idl>
++#endif
 +
-+}
++#include <com/sun/star/uno/XComponentContext.idl>
++#include <com/sun/star/table/XCellRange.idl>
 +
-+ScTabViewShell* 
-+getBestViewShell(  css::uno::Reference< css::frame::XModel>& xModel )
++module ooo {  module vba { module excel {
++service Globals : XGlobals
 +{
-+	ScDocShell* pDocShell = getDocShell( xModel );
-+	if ( pDocShell )
-+		return pDocShell->GetBestViewShell();
-+	return NULL;
-+}
-+
-+ScTabViewShell* 
-+getCurrentBestViewShell()
-+{ 
-+	uno::Reference< frame::XModel > xModel = getCurrentDocument();
-+	return getBestViewShell( xModel );
-+}
++};
 +
-+SfxViewFrame* 
-+getCurrentViewFrame()
-+{
-+	ScTabViewShell* pViewShell = getCurrentBestViewShell();	
-+	if ( pViewShell )
-+		return pViewShell->GetViewFrame();
-+	return NULL;
-+}
++}; }; };
 +
-+} // openoffice
-+} //org
-diff --git sc/source/ui/vba/excelvbahelper.hxx sc/source/ui/vba/excelvbahelper.hxx
++#endif
+diff --git oovbaapi/ooo/vba/excel/XApplication.idl oovbaapi/ooo/vba/excel/XApplication.idl
+index 82533a5..35c4852 100644
+--- oovbaapi/ooo/vba/excel/XApplication.idl
++++ oovbaapi/ooo/vba/excel/XApplication.idl
+@@ -42,10 +42,6 @@
+ #include <ooo/vba/XAssistant.idl>
+ #endif
+ 
+-#ifndef __ooo_vba_XCommandBars_idl__
+-#include <ooo/vba/XCommandBars.idl>
+-#endif
+-
+ module ooo {  module vba {  module excel { 
+ 
+ interface XRange;
+@@ -56,10 +52,10 @@ interface XWorksheetFunction;
+ interface XWindow;
+ interface XWorksheet;
+ 
+-interface XApplication
++interface XApplication : com::sun::star::uno::XInterface
+ {
+ 
+-	interface ::ooo::vba::XHelperInterface;
++//	interface ::ooo::vba::XHelperInterface;
+ 
+ 	[attribute, readonly] any Selection;
+ 	[attribute, readonly] XWorkbook ActiveWorkbook;
+@@ -74,8 +70,6 @@ interface XApplication
+ 	// to determine this
+ 	[attribute, readonly] XWorkbook ThisWorkbook;
+ 	[attribute, readonly] string Name;
+-	[attribute] boolean ScreenUpdating;
+-	[attribute] boolean DisplayStatusBar;
+ 	[attribute] boolean DisplayAlerts;
+ 	[attribute] boolean DisplayFormulaBar;
+ 	[attribute] any CutCopyMode;
+@@ -90,7 +84,7 @@ interface XApplication
+ 	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 aIndex );
++    //any CommandBars( [in] any aIndex );
+ 	any Workbooks( [in] any aIndex );
+ 	any Worksheets( [in] any aIndex );
+ 	any Windows( [in] any aIndex );
+@@ -109,7 +103,6 @@ interface XApplication
+ 	XRange Union([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
+         raises(com::sun::star::script::BasicErrorException);
+ 	void Volatile([in] any Volatile);
+-	void DoEvents();
+ 	any Caller( [in] any aIndex );
+ };
+ 
+diff --git oovbaapi/ooo/vba/excel/XGlobals.idl oovbaapi/ooo/vba/excel/XGlobals.idl
 new file mode 100644
-index 0000000..e35b1db
+index 0000000..b21e902
 --- /dev/null
-+++ sc/source/ui/vba/excelvbahelper.hxx
-@@ -0,0 +1,52 @@
++++ oovbaapi/ooo/vba/excel/XGlobals.idl
+@@ -0,0 +1,86 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1216,8 +1230,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbahelper.hxx,v $
-+ * $Revision: 1.5.32.1 $
++ * $RCSfile: XGlobals.idl,v $
++ * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -1237,448 +1251,4094 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SC_EXCEL_VBA_HELPER_HXX
-+#define SC_EXCEL_VBA_HELPER_HXX
++#ifndef __ooo_vba_excel_XGlobals_idl__
++#define __ooo_vba_excel_XGlobals_idl__
 +
-+#include<vbahelper/vbahelper.hxx>
-+#include <docsh.hxx>
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++#ifndef __com_sun_star_script_BasicErrorException_idl__
++#include <com/sun/star/script/BasicErrorException.idl>
++#endif
++#ifndef __ooo_vba_excel_XWorkbook_idl__
++#include <ooo/vba/excel/XWorkbook.idl>
++#endif
++#ifndef __ooo_vba_excel_XWorksheet_idl__
++#include <ooo/vba/excel/XWorksheet.idl>
++#endif
++#ifndef __ooo_vba_XAssistant_idl__
++#include <ooo/vba/XAssistant.idl>
++#endif
 +
-+namespace ooo 
++module ooo {  module vba {  module excel {
++interface XRange;
++interface XWindow;
++interface XGlobals: com::sun::star::uno::XInterface
 +{
-+	namespace vba 
-+	{
-+		void implnCopy();
-+		void implnPaste();
-+		void implnCut();
-+		void implnPasteSpecial(sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
-+		css::uno::Reference< css::frame::XModel >
-+			getCurrentDocument() throw (css::uno::RuntimeException);
-+		ScTabViewShell* getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel ) ;
-+		ScDocShell* getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) ;
-+		ScTabViewShell* getCurrentBestViewShell();
-+		SfxViewFrame* getCurrentViewFrame();
-+};
++	[attribute, readonly] ooo::vba::excel::XWorkbook ActiveWorkbook;
++	[attribute, readonly] ooo::vba::excel::XWorksheet ActiveSheet;
++	[attribute, readonly] ooo::vba::excel::XWindow ActiveWindow;
++	[attribute, readonly] ooo::vba::excel::XRange ActiveCell;
++	[attribute, readonly] ooo::vba::XAssistant Assistant;
++	[attribute, readonly] any Selection;
++	[attribute, readonly] XWorkbook ThisWorkbook;
++
++	void Calculate() raises(com::sun::star::script::BasicErrorException);
++	XRange Cells([in] any RowIndex, [in] any ColumnIndex);
++	XRange Columns([in] any aIndex);
++	any CommandBars( [in] any aIndex );
++	any Evaluate( [in] string Name );
++XRange Intersect([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
++        raises(com::sun::star::script::BasicErrorException);
++	any WorkSheets( [in] any aIndex );
++	any WorkBooks( [in] any aIndex );
++	any WorksheetFunction();
++	any Windows( [in] any aIndex );
++	any Sheets( [in] any aIndex );
++	any Range( [in] any Cell1, [in] any Cell2 );
++	XRange Rows([in] any aIndex);
++	any Names( [in] any Index );
++	XRange Union([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
++        raises(com::sun::star::script::BasicErrorException);
++
 +};
++
++}; }; };
++
 +#endif
-diff --git sc/source/ui/vba/makefile.mk sc/source/ui/vba/makefile.mk
-index 4eaad61..a29a128 100644
---- sc/source/ui/vba/makefile.mk
-+++ sc/source/ui/vba/makefile.mk
-@@ -63,7 +63,7 @@ SLOFILES= \
- 		$(SLO)$/vbaworksheet.obj \
- 		$(SLO)$/vbaoutline.obj \
- 		$(SLO)$/vbafont.obj\
--		$(SLO)$/vbahelper.obj\
-+		$(SLO)$/excelvbahelper.obj\
- 		$(SLO)$/vbainterior.obj\
- 		$(SLO)$/vbawsfunction.obj\
- 		$(SLO)$/vbawindow.obj\
-@@ -80,20 +80,10 @@ SLOFILES= \
- 		$(SLO)$/vbapalette.obj \
- 		$(SLO)$/vbaborders.obj \
- 		$(SLO)$/vbacharacters.obj \
--		$(SLO)$/vbacombobox.obj \
- 		$(SLO)$/vbavalidation.obj \
--                $(SLO)$/vbacontrol.obj \
--                $(SLO)$/vbacontrols.obj \
-                 $(SLO)$/vbaoleobject.obj \
-                 $(SLO)$/vbaoleobjects.obj \
--                $(SLO)$/vbabutton.obj \
--                $(SLO)$/vbalabel.obj \
--                $(SLO)$/vbatextbox.obj \
-                 $(SLO)$/vbatextboxshape.obj \
--                $(SLO)$/vbaradiobutton.obj \
--                $(SLO)$/vbalistbox.obj \
--		$(SLO)$/vbalistcontrolhelper.obj \
--                $(SLO)$/vbapropvalue.obj \
-                 $(SLO)$/vbapane.obj \
-                 $(SLO)$/vbashape.obj \
-                 $(SLO)$/vbacolorformat.obj \
-@@ -115,14 +105,6 @@ SLOFILES= \
-                 $(SLO)$/vbastyle.obj \
-                 $(SLO)$/vbastyles.obj \
-                 $(SLO)$/vbaassistant.obj \
--                $(SLO)$/vbauserform.obj \
--                $(SLO)$/vbacheckbox.obj \
--                $(SLO)$/vbatogglebutton.obj \
--                $(SLO)$/vbaframe.obj \
--                $(SLO)$/vbascrollbar.obj \
--                $(SLO)$/vbaprogressbar.obj \
--				$(SLO)$/vbamultipage.obj \
--				$(SLO)$/vbapages.obj \
-                 $(SLO)$/vbacommandbarcontrol.obj \
-                 $(SLO)$/vbacommandbarcontrols.obj \
-                 $(SLO)$/vbacommandbar.obj \
-@@ -131,8 +113,6 @@ SLOFILES= \
-         		$(SLO)$/vbapagesetup.obj \
- 		        $(SLO)$/vbapagebreak.obj \
-         		$(SLO)$/vbapagebreaks.obj \
--		        $(SLO)$/vbaspinbutton.obj \
--		        $(SLO)$/vbaimage.obj \
- 				$(SLO)$/service.obj \
-         $(SLO)$/vbaeventshelper.obj \
-  
-diff --git sc/source/ui/vba/service.cxx sc/source/ui/vba/service.cxx
-index 03ea759..bf4d4c4 100644
---- sc/source/ui/vba/service.cxx
-+++ sc/source/ui/vba/service.cxx
-@@ -61,11 +61,11 @@ namespace globals
- {
- extern sdecl::ServiceDecl const serviceDecl;
- }
--namespace  userform
-+namespace hyperlink 
- {
- extern sdecl::ServiceDecl const serviceDecl;
- }
--namespace hyperlink 
-+namespace application 
++
++
+diff --git oovbaapi/ooo/vba/excel/XWindow.idl oovbaapi/ooo/vba/excel/XWindow.idl
+index 2526826..6c840a7 100644
+--- oovbaapi/ooo/vba/excel/XWindow.idl
++++ oovbaapi/ooo/vba/excel/XWindow.idl
+@@ -46,10 +46,8 @@ module ooo {  module vba {  module excel {
+ interface XRange;
+ interface XWorksheet;
+ interface XPane;
+-interface XWindow
++interface XWindow : com::sun::star::uno::XInterface
  {
- extern sdecl::ServiceDecl const serviceDecl;
- }
-@@ -90,7 +90,7 @@ extern "C"
- 
- 	// Component registration
-         if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
--		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
-+		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
- 		{
- 			// Singleton registration
- 			try
-@@ -118,7 +118,7 @@ extern "C"
-     {
- 		OSL_TRACE("In component_getFactory for %s", pImplName );
- 	void* pRet =  component_getFactoryHelper(
--        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl );
-+        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl );
-     if( !pRet )
-         pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl );
- 	OSL_TRACE("Ret is 0x%x", pRet);
-diff --git sc/source/ui/vba/vbaapplication.cxx sc/source/ui/vba/vbaapplication.cxx
-index 332d6b1..163ad9f 100644
---- sc/source/ui/vba/vbaapplication.cxx
-+++ sc/source/ui/vba/vbaapplication.cxx
-@@ -87,6 +87,7 @@
- #include "miscuno.hxx"
- #include "unonames.hxx"
- #include "docsh.hxx"
-+#include <vbahelper/helperdecl.hxx>
- 
- using namespace ::ooo::vba;
- using namespace ::com::sun::star;
-@@ -123,7 +124,7 @@ public:
- 	ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook(  xParent, xContext ){}
- };
+-	interface ::ooo::vba::XHelperInterface;
+-
+ 	[attribute] any Caption;
+ 	[attribute] boolean DisplayGridlines; 
+ 	[attribute] boolean DisplayHeadings; 
+@@ -58,8 +56,6 @@ interface XWindow
+ 	[attribute] boolean DisplayVerticalScrollBar; 
+ 	[attribute] boolean DisplayWorkbookTabs; 
+ 	[attribute] boolean FreezePanes; 
+-	[attribute] long Height; 
+-	[attribute] long Left; 
+ 	[attribute] boolean Split; 
+ 	[attribute] long SplitColumn;
+ 	[attribute] double SplitHorizontal;
+@@ -67,10 +63,7 @@ interface XWindow
+ 	[attribute] double SplitVertical;
+ 	[attribute] any ScrollColumn;
+ 	[attribute] any ScrollRow;
+-	[attribute] long Top; 
+ 	[attribute] any View;
+-	[attribute] boolean Visible;
+-	[attribute] long Width; 
+ 	[attribute] any WindowState;
+ 	[attribute] any Zoom;
+ 	any SelectedSheets( [in] any aIndex );
+diff --git oovbaapi/ooo/vba/excel/XWorkbook.idl oovbaapi/ooo/vba/excel/XWorkbook.idl
+index 1a06729..66a6380 100644
+--- oovbaapi/ooo/vba/excel/XWorkbook.idl
++++ oovbaapi/ooo/vba/excel/XWorkbook.idl
+@@ -48,31 +48,19 @@ interface XWorksheet;
+ interface XWorksheets;
+ interface XStyles;
  
--ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
-+ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
+-interface XWorkbook
++interface XWorkbook : com::sun::star::uno::XInterface
  {
- }
- 
-@@ -1344,3 +1345,13 @@ ScVbaApplication::getServiceNames()
- 	}
- 	return aServiceNames;
- }
-+
-+namespace application
-+{
-+namespace sdecl = comphelper::service_decl;
-+sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > serviceImpl;
-+extern sdecl::ServiceDecl const serviceDecl(
-+    serviceImpl,
-+    "ScVbaApplication",
-+    "ooo.vba.excel.Application" );
-+}
-diff --git sc/source/ui/vba/vbaapplication.hxx sc/source/ui/vba/vbaapplication.hxx
-index 754885e..dccb6b7 100644
---- sc/source/ui/vba/vbaapplication.hxx
-+++ sc/source/ui/vba/vbaapplication.hxx
-@@ -35,7 +35,7 @@
- #include <ooo/vba/excel/XApplication.hpp>
- #include <com/sun/star/uno/XComponentContext.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- 
- typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE;
- 
-@@ -45,7 +45,7 @@ private:
- 	sal_Int32 m_xCalculation;
- 	rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException );
- public:
--	ScVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext );
-+	ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext );
- 	virtual ~ScVbaApplication();
- 
- 	// XHelperInterface ( parent is itself )
-diff --git sc/source/ui/vba/vbaassistant.hxx sc/source/ui/vba/vbaassistant.hxx
-index d3c5ff4..060538d 100644
---- sc/source/ui/vba/vbaassistant.hxx
-+++ sc/source/ui/vba/vbaassistant.hxx
-@@ -40,8 +40,8 @@
- 
- #include <sfx2/sfxhelp.hxx>
+-	interface ::ooo::vba::XHelperInterface;
+-
+-	[attribute, readonly] string  Name;
+-	[attribute, readonly] string  Path;
+-	[attribute, readonly] string  FullName;
+ 	[attribute, readonly] boolean ProtectStructure; 
+ 	[attribute, readonly] XWorksheet ActiveSheet;
+-	[attribute] boolean Saved;
+ 	[attribute, readonly] string  CodeName;
+ 
+ 	any  Worksheets([in] any sheet);
+ 	any  Styles([in] any Index );
+ 	any  Sheets([in] any sheet);
+ 	any  Windows([in] any index );
+-	void Close([in] any SaveChanges, [in] any FileName, [in] any RouteWorkBook);
+-	void Protect( [in] any Password );
+-	void Unprotect( [in] any Password );
+-	void Save();
+-	void Activate();
+ 	void ResetColors() raises (com::sun::star::script::BasicErrorException);
+-
++	void Activate();
+ 	any Names( [in] any Index );
+-
+ 	any Colors([in] any Index) raises (com::sun::star::script::BasicErrorException);
+ 	long FileFormat() raises (com::sun::star::script::BasicErrorException);
+ 	void SaveCopyAs( [in] string Filename );
+diff --git oovbaapi/ooo/vba/excel/makefile.mk oovbaapi/ooo/vba/excel/makefile.mk
+index 2170810..8ef4294 100644
+--- oovbaapi/ooo/vba/excel/makefile.mk
++++ oovbaapi/ooo/vba/excel/makefile.mk
+@@ -41,7 +41,9 @@ PACKAGE=ooo$/vba$/Excel
+ # ------------------------------------------------------------------------
  
--#include "vbahelper.hxx"
--#include "vbahelperinterface.hxx"
-+#include "excelvbahelper.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
  
- typedef ::cppu::WeakImplHelper1< ov::XAssistant > Assistant;
- typedef InheritedHelperInterfaceImpl< Assistant > ScVbaAssistantImpl_BASE;
-diff --git sc/source/ui/vba/vbaaxes.hxx sc/source/ui/vba/vbaaxes.hxx
-index 1117d27..3ef05ec 100644
---- sc/source/ui/vba/vbaaxes.hxx
-+++ sc/source/ui/vba/vbaaxes.hxx
-@@ -32,7 +32,7 @@
- #include <ooo/vba/excel/XAxes.hpp>
- #include <ooo/vba/excel/XAxis.hpp>
- #include <ooo/vba/excel/XChart.hpp>
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
+-IDLFILES= XApplication.idl\
++IDLFILES= XGlobals.idl\
++	Globals.idl\
++	XApplication.idl\
+ 	XComment.idl\
+ 	XComments.idl\
+ 	XRange.idl\
+diff --git oovbaapi/ooo/vba/makefile.mk oovbaapi/ooo/vba/makefile.mk
+index 11188d5..2dcc035 100644
+--- oovbaapi/ooo/vba/makefile.mk
++++ oovbaapi/ooo/vba/makefile.mk
+@@ -42,7 +42,6 @@ PACKAGE=ooo$/vba
  
- typedef CollTestImplHelper< ov::excel::XAxes > ScVbaAxes_BASE;
- class ScVbaAxes : public ScVbaAxes_BASE
-diff --git sc/source/ui/vba/vbaaxis.hxx sc/source/ui/vba/vbaaxis.hxx
-index 71ec1c1..f51bac5 100644
---- sc/source/ui/vba/vbaaxis.hxx
-+++ sc/source/ui/vba/vbaaxis.hxx
-@@ -32,8 +32,8 @@
- #include <com/sun/star/beans/XPropertySet.hpp>
- #include <ooo/vba/excel/XAxis.hpp>
- #include <ooo/vba/excel/XChart.hpp>
--#include "vbahelperinterface.hxx"
--
-+#include <vbahelper/vbahelperinterface.hxx>
-+#include <memory>
- typedef InheritedHelperInterfaceImpl1< ov::excel::XAxis >  ScVbaAxis_BASE;
- class ScVbaChart;
- class ScVbaAxis : public ScVbaAxis_BASE
-diff --git sc/source/ui/vba/vbaborders.hxx sc/source/ui/vba/vbaborders.hxx
-index 9ad8c50..642e32b 100644
---- sc/source/ui/vba/vbaborders.hxx
-+++ sc/source/ui/vba/vbaborders.hxx
-@@ -38,7 +38,7 @@
- #include <com/sun/star/beans/XPropertySet.hpp>
+ IDLFILES=\
+ 	XErrObject.idl \
+-	XGlobals.idl \
+ 	XCollection.idl\
+ 	XVBAToOOEventDescGen.idl\
+ 	XPropValue.idl\
+@@ -54,7 +53,14 @@ IDLFILES=\
+ 	XCommandBars.idl\
+ 	XCommandBarPopup.idl\
+ 	XCommandBarButton.idl\
+-	Globals.idl\
++	XControlProvider.idl\
++	ControlProvider.idl\
++	XApplicationBase.idl\
++	XWindowBase.idl\
++	XDocumentBase.idl\
++	XGlobalsBase.idl\
++	XDocumentProperty.idl\
++	XDocumentProperties.idl\
  
-  
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
+ # ------------------------------------------------------------------
  
- typedef CollTestImplHelper< ov::excel::XBorders > ScVbaBorders_BASE;
- class ScVbaPalette;
-diff --git sc/source/ui/vba/vbabutton.cxx sc/source/ui/vba/vbabutton.cxx
-deleted file mode 100644
-index 0e4d749..0000000
---- sc/source/ui/vba/vbabutton.cxx
-+++ /dev/null
-@@ -1,74 +0,0 @@
--/*************************************************************************
-- *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
-- *
-- * OpenOffice.org - a multi-platform office productivity suite
-- *
-- * $RCSfile: vbabutton.cxx,v $
-- * $Revision: 1.3 $
-- *
-- * 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 "vbabutton.hxx"
--#include <vector>
--
--using namespace com::sun::star;
--using namespace ooo::vba;
--
--
--const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
--ScVbaButton::ScVbaButton( 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 ) : ButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
--{
--}
--
--// Attributes
--rtl::OUString SAL_CALL 
--ScVbaButton::getCaption() throw (css::uno::RuntimeException)
--{
--    rtl::OUString Label;
--    m_xProps->getPropertyValue( LABEL ) >>= Label;
--    return Label;
--}
--
--void SAL_CALL 
--ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
--{
--    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
--}
--
--rtl::OUString& 
--ScVbaButton::getServiceImplName()
--{
+diff --git oovbaapi/ooo/vba/word/XApplication.idl oovbaapi/ooo/vba/word/XApplication.idl
+new file mode 100644
+index 0000000..ae1835b
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XApplication.idl
+@@ -0,0 +1,63 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XApplication.idl,v $
++ * $Revision: 1.4 $
++ *
++ * 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_word_XApplication_idl__
++#define __ooo_vba_word_XApplication_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XDocument;
++interface XWindow;
++interface XSystem;
++interface XOptions;
++interface XSelection;
++interface XApplication : com::sun::star::uno::XInterface
++{
++	[attribute, readonly] XDocument ActiveDocument;
++	[attribute, readonly] XWindow ActiveWindow;
++	[attribute, readonly] string Name;
++	[attribute, readonly] ooo::vba::word::XSystem System;
++	[attribute, readonly] ooo::vba::word::XOptions Options;
++	[attribute, readonly] ooo::vba::word::XSelection Selection;
++    any CommandBars( [in] any aIndex );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XBookmark.idl oovbaapi/ooo/vba/word/XBookmark.idl
+new file mode 100644
+index 0000000..da6a489
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XBookmark.idl
+@@ -0,0 +1,61 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XBookmark_idl__
++#define __ooo_vba_word_XBookmark_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++#ifndef __com_sun_star_container_XNamed_idl__
++#include <com/sun/star/container/XNamed.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XBookmark
++{
++    interface ooo::vba::XHelperInterface;
++	interface ::com::sun::star::container::XNamed;
++
++    void Delete();
++    void Select();
++    any Range();
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XBookmarks.idl oovbaapi/ooo/vba/word/XBookmarks.idl
+new file mode 100644
+index 0000000..4f1f89e
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XBookmarks.idl
+@@ -0,0 +1,61 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XBookmarks_idl__
++#define __ooo_vba_word_XBookmarks_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XCollection_idl__
++#include <ooo/vba/XCollection.idl>
++#endif
++
++
++//=============================================================================
++
++module ooo {  module vba {  module word { 
++
++//=============================================================================
++
++interface XBookmarks 
++{
++	interface ::ooo::vba::XCollection;
++
++    [attribute] long DefaultSorting;
++    [attribute] boolean ShowHidden;
++
++	any Add( [in] string Name, [in] any Range );
++    boolean Exists( [in] string Name );
++};
++
++}; }; };
++
++#endif
+diff --git oovbaapi/ooo/vba/word/XDocument.idl oovbaapi/ooo/vba/word/XDocument.idl
+new file mode 100644
+index 0000000..32cf6d8
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XDocument.idl
+@@ -0,0 +1,62 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XDocument.idl,v $
++ * $Revision: 1.4 $
++ *
++ * 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_word_XDocument_idl__
++#define __ooo_vba_word_XDocument_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++#ifndef __ooo_vba_word_XRange_idl__
++#include <ooo/vba/word/XRange.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XDocument : com::sun::star::uno::XInterface
++{
++    [attribute, readonly] XRange Content;
++
++    XRange Range( [in] any Start, [in] any End );
++    any BuiltInDocumentProperties( [in] any index );
++    any CustomDocumentProperties( [in] any index );
++    any Bookmarks( [in] any aIndex );
++    any Variables( [in] any aIndex );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XGlobals.idl oovbaapi/ooo/vba/word/XGlobals.idl
+new file mode 100644
+index 0000000..3305e93
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XGlobals.idl
+@@ -0,0 +1,58 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XGlobals.idl,v $
++ * $Revision: 1.4 $
++ *
++ * 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_word_XGlobals_idl__
++#define __ooo_vba_word_XGlobals_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++interface XDocument;
++interface XWindow;
++interface XSystem;
++interface XOptions;
++interface XSelection;
++interface XGlobals : com::sun::star::uno::XInterface
++{
++	[attribute, readonly] XDocument ActiveDocument;
++	[attribute, readonly] XWindow ActiveWindow;
++	[attribute, readonly] string Name;
++	[attribute, readonly] ooo::vba::word::XSystem System;
++	[attribute, readonly] ooo::vba::word::XOptions Options;
++	[attribute, readonly] ooo::vba::word::XSelection Selection;
++    any CommandBars( [in] any aIndex );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XOptions.idl oovbaapi/ooo/vba/word/XOptions.idl
+new file mode 100644
+index 0000000..75b1064
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XOptions.idl
+@@ -0,0 +1,54 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XOptions_idl__
++#define __ooo_vba_word_XOptions_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XOptions
++{
++    interface ooo::vba::XHelperInterface;
++
++    any DefaultFilePath( [in] long Path );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XPane.idl oovbaapi/ooo/vba/word/XPane.idl
+new file mode 100644
+index 0000000..db506dd
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XPane.idl
+@@ -0,0 +1,55 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XPane_idl__
++#define __ooo_vba_word_XPane_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XPane
++{
++    interface ooo::vba::XHelperInterface;
++
++    any View();
++    void Close();
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XPanes.idl oovbaapi/ooo/vba/word/XPanes.idl
+new file mode 100644
+index 0000000..be3411f
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XPanes.idl
+@@ -0,0 +1,55 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XPanes_idl__
++#define __ooo_vba_word_XPanes_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XCollection_idl__
++#include <ooo/vba/XCollection.idl>
++#endif
++
++
++//=============================================================================
++
++module ooo {  module vba {  module word { 
++
++//=============================================================================
++
++interface XPanes 
++{
++	interface ::ooo::vba::XCollection;
++};
++
++}; }; };
++
++#endif
+diff --git oovbaapi/ooo/vba/word/XRange.idl oovbaapi/ooo/vba/word/XRange.idl
+new file mode 100644
+index 0000000..4ce9b79
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XRange.idl
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XRange_idl__
++#define __ooo_vba_word_XRange_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++
++module ooo {  module vba {  module word { 
++
++interface XRange
++{
++    interface ooo::vba::XHelperInterface;
++
++    [attribute] string Text;
++
++    void InsertBreak( [in] any Type );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XSelection.idl oovbaapi/ooo/vba/word/XSelection.idl
+new file mode 100644
+index 0000000..2142fb4
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XSelection.idl
+@@ -0,0 +1,55 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XSelection_idl__
++#define __ooo_vba_word_XSelection_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++
++module ooo {  module vba {  module word { 
++
++interface XSelection
++{
++    interface ooo::vba::XHelperInterface;
++
++    [attribute] string Text;
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XSystem.idl oovbaapi/ooo/vba/word/XSystem.idl
+new file mode 100644
+index 0000000..5a23f56
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XSystem.idl
+@@ -0,0 +1,56 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XSystem_idl__
++#define __ooo_vba_word_XSystem_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++
++module ooo {  module vba {  module word { 
++
++interface XSystem
++{
++    interface ooo::vba::XHelperInterface;
++
++    [attribute] long Cursor;
++    any PrivateProfileString( [in] string Filename, [in] string Section, [in] string Key );
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XVariable.idl oovbaapi/ooo/vba/word/XVariable.idl
+new file mode 100644
+index 0000000..eb1706b
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XVariable.idl
+@@ -0,0 +1,60 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XVariable_idl__
++#define __ooo_vba_word_XVariable_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++#ifndef __com_sun_star_container_XNamed_idl__
++#include <com/sun/star/container/XNamed.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XVariable
++{
++    interface ooo::vba::XHelperInterface;
++	interface ::com::sun::star::container::XNamed;
++
++    [attribute] any Value;
++    [attribute, readonly] long Index;
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XVariables.idl oovbaapi/ooo/vba/word/XVariables.idl
+new file mode 100644
+index 0000000..49af69c
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XVariables.idl
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XVariables_idl__
++#define __ooo_vba_word_XVariables_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XCollection_idl__
++#include <ooo/vba/XCollection.idl>
++#endif
++
++
++//=============================================================================
++
++module ooo {  module vba {  module word { 
++
++//=============================================================================
++
++interface XVariables 
++{
++	interface ::ooo::vba::XCollection;
++
++	any Add( [in] string Name, [in] any Value );
++};
++
++}; }; };
++
++#endif
+diff --git oovbaapi/ooo/vba/word/XView.idl oovbaapi/ooo/vba/word/XView.idl
+new file mode 100644
+index 0000000..1800d68
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XView.idl
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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_word_XView_idl__
++#define __ooo_vba_word_XView_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++module ooo {  module vba {  module word { 
++
++interface XView
++{
++    interface ooo::vba::XHelperInterface;
++
++    [attribute] long SeekView;
++    [attribute] long SplitSpecial;
++    [attribute] boolean TableGridLines;
++    [attribute] long Type;
++};
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/XWindow.idl oovbaapi/ooo/vba/word/XWindow.idl
+new file mode 100644
+index 0000000..9235335
+--- /dev/null
++++ oovbaapi/ooo/vba/word/XWindow.idl
+@@ -0,0 +1,62 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XWindow.idl,v $
++ * $Revision: 1.4 $
++ *
++ * 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_word_XWindow_idl__
++#define __ooo_vba_word_XWindow_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __ooo_vba_XHelperInterface_idl__
++#include <ooo/vba/XHelperInterface.idl>
++#endif
++
++//=============================================================================
++
++module ooo {  module vba {  module word { 
++
++//=============================================================================
++//interface XPane;
++interface XWindow : com::sun::star::uno::XInterface
++{
++    [attribute] any View;
++	void Activate();
++    void Close([in] any SaveChanges, [in] any RouteDocument);
++	any Panes( [in] any aIndex ); // this is a fake api for it seems not support in Write
++	any ActivePane(); // this is a fake api for it seems not support in Write
++};
++
++//=============================================================================
++
++}; }; };
++
++#endif
++
++
+diff --git oovbaapi/ooo/vba/word/makefile.mk oovbaapi/ooo/vba/word/makefile.mk
+new file mode 100644
+index 0000000..646e623
+--- /dev/null
++++ oovbaapi/ooo/vba/word/makefile.mk
+@@ -0,0 +1,63 @@
++#*************************************************************************
++#
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++# 
++# Copyright 2008 by Sun Microsystems, Inc.
++#
++# OpenOffice.org - a multi-platform office productivity suite
++#
++# $RCSfile: makefile.mk,v $
++#
++# $Revision: 1.4 $
++#
++# 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.
++#
++#*************************************************************************
++PRJ=..$/..$/..
++
++PRJNAME=oovapi
++
++TARGET=word
++PACKAGE=ooo$/vba$/Word
++
++# --- Settings -----------------------------------------------------
++.INCLUDE :  $(PRJ)$/util$/makefile.pmk
++
++# ------------------------------------------------------------------------
++
++
++IDLFILES= XGlobals.idl\
++	XApplication.idl \
++	XDocument.idl \
++	XWindow.idl \
++	XSystem.idl \
++	XRange.idl \
++	XBookmark.idl \
++	XBookmarks.idl \
++	XVariable.idl \
++	XVariables.idl \
++	XView.idl \
++	XPane.idl \
++	XPanes.idl \
++	XOptions.idl \
++	XSelection.idl \
++
++# ------------------------------------------------------------------
++
++.INCLUDE :  target.mk
++
+diff --git oovbaapi/prj/build.lst oovbaapi/prj/build.lst
+index bc34a4f..e6d23a3 100644
+--- oovbaapi/prj/build.lst
++++ oovbaapi/prj/build.lst
+@@ -4,5 +4,6 @@ ovba	oovbaapi\genconstidl                nmake	-	all	ovba_genconstidl NULL
+ ovba	oovbaapi\ooo\vba\constants          nmake	-	all	ovba_constants  ovba_genconstidl NULL
+ ovba	oovbaapi\ooo\vba                    nmake	-	all	ovba_vba NULL
+ ovba	oovbaapi\ooo\vba\excel              nmake	-	all	ovba_excel NULL
++ovba	oovbaapi\ooo\vba\word               nmake	-	all	ovba_word NULL
+ ovba	oovbaapi\ooo\vba\msforms            nmake	-	all	ovba_msforms NULL
+-ovba    oovbaapi\util                       nmake       -       all     ovba_util ovba_vba ovba_excel ovba_msforms ovba_constants ovba_genconstidl NULL
++ovba   oovbaapi\util                             nmake   -   all ovba_util ovba_vba ovba_excel ovba_word ovba_msforms ovba_constants ovba_genconstidl NULL
+diff --git oovbaapi/util/makefile.mk oovbaapi/util/makefile.mk
+index 4b98130..a0f4982 100644
+--- oovbaapi/util/makefile.mk
++++ oovbaapi/util/makefile.mk
+@@ -44,6 +44,7 @@ TARGET=oovbaapi_db
+ UNOIDLDBFILES= \
+ 	$(UCR)$/vba.db \
+ 	$(UCR)$/excel.db \
++	$(UCR)$/word.db \
+ 	$(UCR)$/msforms.db \
+ 	$(UCR)$/constants.db
+ 
+diff --git sc/inc/cellsuno.hxx sc/inc/cellsuno.hxx
+index 17b226d..da70b18 100644
+--- sc/inc/cellsuno.hxx
++++ sc/inc/cellsuno.hxx
+@@ -175,7 +175,9 @@ class SC_DLLPUBLIC ScCellRangesBase : public com::sun::star::beans::XPropertySet
+ {
+ 	friend class ScTabViewObj;		// fuer select()
+ 	friend class ScTableSheetObj;	// fuer createCursorByRange()
+- 	friend class ooo::vba::ScVbaCellRangeAccess;
++	friend class NumFormatHelper;	// VBA helper Class that helps manipulate format data
++	friend class ScVbaRange;	//Main VBA helper class for Range
++	friend class ScVbaFont;	//Main VBA helper class for Font
+ 
+ private:
+ 	SfxItemPropertySet		aPropSet;
+diff --git sc/inc/docuno.hxx sc/inc/docuno.hxx
+index f036a23..58ebb35 100644
+--- sc/inc/docuno.hxx
++++ sc/inc/docuno.hxx
+@@ -74,8 +74,6 @@ class ScTableSheetObj;
+ class SvxFmDrawPage;
+ class SvxDrawPage;
+ 
+-#include <com/sun/star/document/XCodeNameQuery.hpp>
+-
+ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
+ 					public com::sun::star::sheet::XSpreadsheetDocument,
+ 					public com::sun::star::document::XActionLockable,
+@@ -89,7 +87,6 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
+ 					public com::sun::star::view::XRenderable,
+ 					public com::sun::star::document::XLinkTargetSupplier,
+ 					public com::sun::star::beans::XPropertySet,
+-					public com::sun::star::document::XCodeNameQuery,
+                     public com::sun::star::document::XDocumentEventCompatibleHelper,
+ 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
+                     public com::sun::star::lang::XServiceInfo
+@@ -300,8 +297,6 @@ public:
+ 								throw(::com::sun::star::uno::RuntimeException);
+ 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ 								throw(::com::sun::star::uno::RuntimeException);
+- 	virtual rtl::OUString SAL_CALL getCodeNameForObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObj )
+-								throw(::com::sun::star::uno::RuntimeException);
+                             // XVbaEventHelper
+     virtual sal_Bool SAL_CALL processCompatibleEvent( sal_Int16 nEventId ) throw (::com::sun::star::uno::RuntimeException);
+ };
+diff --git sc/inc/servuno.hxx sc/inc/servuno.hxx
+index 3beb852..13950f1 100644
+--- sc/inc/servuno.hxx
++++ sc/inc/servuno.hxx
+@@ -94,7 +94,8 @@ class ScDocShell;
+ #define SC_SERVICE_FORMULAPARS  38
+ #define SC_SERVICE_OPCODEMAPPER 39
+ #define SC_SERVICE_VBAOBJECTPROVIDER   40
+-#define SC_SERVICE_COUNT        41
++#define SC_SERVICE_VBACODENAMEPROVIDER   41
++#define SC_SERVICE_COUNT        42
+ #define SC_SERVICE_INVALID		USHRT_MAX
+ 
+ 
+diff --git sc/prj/build.lst sc/prj/build.lst
+index 1d2f4a8..a3e52c9 100644
+--- sc/prj/build.lst
++++ sc/prj/build.lst
+@@ -1,4 +1,4 @@
+-sc     sc      :       oovbaapi svx stoc uui BOOST:boost formula oox NULL
++sc     sc      :       vbahelper oovbaapi svx stoc uui BOOST:boost formula oox NULL
+ sc	sc										usr1	-	all	sc_mkout NULL
+ sc	sc\inc									nmake	-	all	sc_inc NULL
+ sc	sc\uiconfig\layout									nmake	-	all	sc_layout NULL
+diff --git sc/source/core/tool/interpr4.cxx sc/source/core/tool/interpr4.cxx
+index a5c7de8..baa5152 100644
+--- sc/source/core/tool/interpr4.cxx
++++ sc/source/core/tool/interpr4.cxx
+@@ -77,6 +77,7 @@
+ #include <map>
+ #include <algorithm>
+ #include <functional>
++#include <vbahelper/vbahelper.hxx>
+ 
+ using namespace com::sun::star;
+ using namespace formula;
+@@ -2696,18 +2697,11 @@ lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPar )
+ 	try
+ 	{
+ 		uno::Reference< uno::XInterface > xVBARange;
+-		uno::Reference< lang::XMultiComponentFactory > xSMgr( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+-		uno::Reference< beans::XPropertySet > xProps( xSMgr, uno::UNO_QUERY_THROW );
+-		uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ 		uno::Reference<table::XCellRange> xCellRange = ScCellRangeObj::CreateRangeFromDoc( pDok, aRange );
+-		// hmm probably better not to have to include the vba generated headers
+-		// here, but... if they ever become always available certainly the
+-		// line below is more coder friendly
+-		//xRange = ooo::vba::excel::Range::createRangeFromXCellRange( xCtx , uno::Reference< ooo::vba::XHelperInterface >(), xCellRange );	
+ 		uno::Sequence< uno::Any > aArgs(2);
+ 		aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
+ 		aArgs[1] = uno::Any( xCellRange );
+-		xVBARange = xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Range") ), aArgs, xCtx  );
++		xVBARange = ov::createVBAUnoAPIServiceWithArgs( pDok->GetDocumentShell(), "ooo.vba.excel.Range", aArgs );
+ 		if ( xVBARange.is() )
+ 		{
+ 			String sDummy(RTL_CONSTASCII_USTRINGPARAM("A-Range") );
+diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+index 033cb76..60c2f6d 100644
+--- sc/source/filter/excel/excimp8.cxx
++++ sc/source/filter/excel/excimp8.cxx
+@@ -103,8 +103,11 @@
+ #include <com/sun/star/document/XDocumentProperties.hpp>
+ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+ #include <com/sun/star/script/ModuleInfo.hpp>
++#include <basic/basmgr.hxx>
++#include <cppuhelper/component_context.hxx>
+ 
+-
++#include <com/sun/star/container/XNameContainer.hpp>
++ 
+ using namespace com::sun::star;
+ 
+ 
+@@ -255,16 +258,6 @@ void ImportExcel8::SheetProtection( void )
+     GetSheetProtectBuffer().ReadOptions( aIn, GetCurrScTab() );
+ }
+ 
+-bool lcl_hasVBAEnabled()
+-{
+-	uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY);
+-		// test if vba service is present
+-	uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY );
+-	uno::Reference< uno::XInterface > xGlobals( xCtx->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/ooo.vba.theGlobals") ), uno::UNO_QUERY );
+-
+-	return xGlobals.is();
+-}
+-
+ void ImportExcel8::ReadBasic( void )
+ {
+     //bHasBasic = TRUE;
+@@ -280,8 +273,11 @@ void ImportExcel8::ReadBasic( void )
+         bool bLoadStrg = pFilterOpt->IsLoadExcelBasicStorage();
+         if( bLoadCode || bLoadStrg )
+         {
++            uno::Any aGlobs;
++            aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString::createFromAscii( "ooo.vba.excel.Globals") );
++            pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
+             SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg );
+-			bool bAsComment = !bLoadExecutable || !lcl_hasVBAEnabled();
++	    bool bAsComment = !bLoadExecutable || !aGlobs.hasValue();
+             aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment );
+             GetObjectManager().SetOleNameOverrideInfo( aBasicImport.ControlNameForObjectId() );
+         }
+diff --git sc/source/filter/excel/xlescher.cxx sc/source/filter/excel/xlescher.cxx
+index af9f995..2109a0a 100644
+--- sc/source/filter/excel/xlescher.cxx
++++ sc/source/filter/excel/xlescher.cxx
+@@ -44,6 +44,7 @@
+ #include <basic/sbstar.hxx>
+ #include <basic/sbmod.hxx>
+ #include <basic/sbmeth.hxx>
++#include <basic/basmgr.hxx>
+ 
+ using ::rtl::OUString;
+ using ::com::sun::star::uno::Reference;
+@@ -305,6 +306,7 @@ Reference< XControlModel > XclControlHelper::GetControlModel( Reference< XShape
+ }
+ 
+ #define EXC_MACRONAME_PRE "vnd.sun.star.script:Standard."
++#define EXC_MACRO_SCHEME "vnd.sun.star.script:"
+ #define EXC_MACRONAME_SUF "?language=Basic&location=document"
+ 
+ OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjectShell* pDocShell )
+@@ -312,9 +314,14 @@ OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjec
+     String sTmp( rXclMacroName );
+     if( rXclMacroName.Len() > 0 )
+     {
++        String sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") );
++
++        if ( pDocShell && pDocShell->GetBasicManager()->GetName().Len() > 0 )
++            sProjectName = pDocShell->GetBasicManager()->GetName();
++
+         if ( ( sTmp.Search( '.' ) == STRING_NOTFOUND) && pDocShell )
+         {
+-            if( StarBASIC* pBasic = pDocShell->GetBasic() )
++            if( StarBASIC* pBasic = pDocShell->GetBasicManager()->GetLib( sProjectName ) )
+             {
+                 if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sTmp, SbxCLASS_METHOD ) ) )
+                 {
+@@ -325,7 +332,9 @@ OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjec
+                 }
+             }
+         }
+-        return CREATE_OUSTRING( EXC_MACRONAME_PRE ) + sTmp + CREATE_OUSTRING( EXC_MACRONAME_SUF );
++        sProjectName.Append( '.' ); 
++        sTmp.Insert( sProjectName, 0 );
++        return CREATE_OUSTRING( EXC_MACRO_SCHEME ) + sTmp + CREATE_OUSTRING( EXC_MACRONAME_SUF );
+     }
+     return OUString();
+ }
+diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
+index 735d64e..c924be4 100644
+--- sc/source/ui/docshell/docsh.cxx
++++ sc/source/ui/docshell/docsh.cxx
+@@ -131,7 +131,8 @@
+ #include "cellsuno.hxx"
+ #include <com/sun/star/document/XVbaEventsHelper.hpp>
+ #include <com/sun/star/document/VbaEventId.hpp>
+-
++#include <basic/sbstar.hxx>
++#include <basic/basmgr.hxx>
+ using namespace com::sun::star;
+ using namespace com::sun::star::document::VbaEventId;
+ 
+@@ -288,6 +289,7 @@ void ScDocShell::BeforeXMLLoading()
+     if ( xEvt.is() )
+        xEvt->setIgnoreEvents( sal_True );
+     
++// if VBA enabled then we need to  
+     // prevent unnecessary broadcasts and updates
+     DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
+ 	pModificator = new ScDocShellModificator( *this );
+@@ -371,7 +373,14 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
+     }
+     else
+ 		aDocument.SetInsertingFromOtherDoc( FALSE );
+-
++	// add vba globals ( if they are availabl )
++	SfxObjectShell* pShell = aDocument.GetDocumentShell();
++	if ( pShell )
++	{
++		uno::Any aGlobs;
++		aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ) );
++		pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
++	}
+         // suppress VBA events when loading the xml
+         uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
+         if ( xEvt.is() )
+diff --git sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
+index 75b5d6e..58540df 100644
+--- sc/source/ui/unoobj/docuno.cxx
++++ sc/source/ui/unoobj/docuno.cxx
+@@ -107,7 +107,6 @@ using namespace com::sun::star::document::VbaEventId;
+ //	alles ohne Which-ID, Map nur fuer PropertySetInfo
+ 
+ //!	umbenennen, sind nicht mehr nur Options
+-#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+ const SfxItemPropertyMap* lcl_GetDocOptPropertyMap()
+ {
+ 	static SfxItemPropertyMap aDocOptPropertyMap_Impl[] =
+@@ -314,7 +313,6 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
+ 	SC_QUERYINTERFACE( view::XRenderable )
+ 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
+ 	SC_QUERYINTERFACE( beans::XPropertySet )
+-	SC_QUERYINTERFACE( document::XCodeNameQuery )
+ 	SC_QUERYINTERFACE( document::XDocumentEventCompatibleHelper)
+ 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
+ 	SC_QUERYINTERFACE( lang::XServiceInfo )
+@@ -1720,49 +1718,7 @@ uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getAvailableServiceNames()
+ 
+ 	return concatServiceNames( aMyServices, aDrawServices );
+ }
+-// XCodeNameQuery
+-rtl::OUString SAL_CALL 
+-ScModelObj::getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+-{
+-    rtl::OUString sCodeName;
+-    if ( pDocShell )
+-    {
+-        OSL_TRACE( "*** In ScModelObj::getCodeNameForObject");
+-        // need to find the page ( and index )  for this control
+-        uno::Reference< drawing::XDrawPagesSupplier > xSupplier( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
+-        uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+-        sal_Int32 nLen = xIndex->getCount();
+-        bool bMatched = false;
+-        uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
+-        for ( sal_Int32 index = 0; index < nLen; ++index )
+-        {
+-            try
+-            {
+-                uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+-                uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+-                // get the www-standard container
+-                uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+-                sal_Int32 nCntrls = xFormControls->getCount();
+-                for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+-                {
+-                    uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
+-                    bMatched = ( xControl == xIf );
+-                    if ( bMatched )
+-                    {
+-                        String sName;
+-                        pDocShell->GetDocument()->GetCodeName( index, sName );
+-                        sCodeName = sName;
+-                    }
+-                }
+-            }
+-            catch( uno::Exception& ) {}
+-            if ( bMatched )
+-                break;
+-        }
+-    }
+-    // Probably should throw here ( if !bMatched )
+-     return sCodeName;
+-}
++
+ // XVbaEventHelper
+ // For Vba Event
+ sal_Bool SAL_CALL
+diff --git sc/source/ui/unoobj/servuno.cxx sc/source/ui/unoobj/servuno.cxx
+index 46d6864..ed2775d 100644
+--- sc/source/ui/unoobj/servuno.cxx
++++ sc/source/ui/unoobj/servuno.cxx
+@@ -63,31 +63,31 @@
+ #include <svx/xmlgrhlp.hxx>
+ 
+ #include <comphelper/processfactory.hxx>
+-
++#include <com/sun/star/document/XCodeNameQuery.hpp>
++#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
++#include <com/sun/star/form/XFormsSupplier.hpp>
++#include <com/sun/star/script/ScriptEventDescriptor.hpp>
++#include <comphelper/componentcontext.hxx>
++#include <cppuhelper/component_context.hxx>
++#include <vbahelper/vbahelper.hxx>
+ using namespace ::com::sun::star;
+ 
+ class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
+ {
+     uno::Any maWorkbook;
+     uno::Any maCachedObject;
+-    uno::Reference<lang::XMultiServiceFactory> mxSF;
+     ScDocShell* mpDocShell;
+ public:
+     ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
+     {
+-        mxSF.set(comphelper::getProcessServiceFactory());
+-        uno::Reference<beans::XPropertySet> xProps(mxSF, uno::UNO_QUERY);
+-        if( xProps.is() )
+-        {
+-            ScDocument* pDoc = mpDocShell->GetDocument();
+-            if ( !pDoc )
+-                throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
+-
+-            uno::Sequence< uno::Any > aArgs(2);
+-            aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
+-            aArgs[1] = uno::Any( mpDocShell->GetModel() );
+-            maWorkbook <<= mxSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook") ), aArgs );
+-        }
++        ScDocument* pDoc = mpDocShell->GetDocument();
++        if ( !pDoc )
++            throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
++
++        uno::Sequence< uno::Any > aArgs(2);
++        aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++        aArgs[1] = uno::Any( mpDocShell->GetModel() );
++        maWorkbook <<= ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs );
+     }
+ 
+     virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
+@@ -120,7 +120,7 @@ public:
+                         aArgs[0] = maWorkbook;
+                         aArgs[1] = uno::Any( xModel );
+                         aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
+-                        maCachedObject <<= mxSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet") ), aArgs );
++                        maCachedObject <<= ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs );
+                         break;
+                     }
+                 }
+@@ -160,6 +160,56 @@ public:
+ 
+ };
+ 
++class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
++{
++ScDocShell* mpDocShell;
++public:
++    ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
++    // XCodeNameQuery
++    rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
++    {
++        rtl::OUString sCodeName;
++        if ( mpDocShell )
++        {
++            OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
++            // need to find the page ( and index )  for this control
++            uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
++            uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
++            sal_Int32 nLen = xIndex->getCount();
++            bool bMatched = false;
++            uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
++            for ( sal_Int32 index = 0; index < nLen; ++index )
++            {
++                try
++                {
++                    uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
++                    uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
++                    // get the www-standard container
++                    uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
++                    sal_Int32 nCntrls = xFormControls->getCount();
++                    for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
++                    {
++                        uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
++                        bMatched = ( xControl == xIf );
++                        if ( bMatched )
++                        {
++                            String sName;
++                            mpDocShell->GetDocument()->GetCodeName( index, sName );
++                            sCodeName = sName;
++                        }
++                    }
++                }
++                catch( uno::Exception& ) {}
++                if ( bMatched )
++                    break;
++            }
++        }
++        // Probably should throw here ( if !bMatched )
++         return sCodeName;
++    }
++
++};
++
+ //------------------------------------------------------------------------
+ 
+ static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
+@@ -210,6 +260,7 @@ static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
+         SC_SERVICENAME_FORMULAPARS,                 // SC_SERVICE_FORMULAPARS
+         SC_SERVICENAME_OPCODEMAPPER,                 // SC_SERVICE_OPCODEMAPPER
+ "ooo.vba.VBAObjectModuleObjectProvider",// SC_SERVICE_VBAOBJECTPROVIDER
++"ooo.vba.VBACodeNameProvider",// SC_SERVICE_VBACODENAMEPROVIDER
+ 	};
+ 
+ //
+@@ -263,6 +314,7 @@ static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] =
+         "",                                         // SC_SERVICE_FORMULAPARS
+         "",                                         // SC_SERVICE_OPCODEMAPPER
+         "",                                         // SC_SERVICE_VBAOBJECTPROVIDER
++        "",                                         // SC_SERVICE_VBACODENAMEPROVIDER
+ 	};
+ 
+ 
+@@ -464,6 +516,9 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
+         case SC_SERVICE_VBAOBJECTPROVIDER:
+             xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
+             break;
++        case SC_SERVICE_VBACODENAMEPROVIDER:
++            xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
++            break;
+ 	}
+ 	return xRet;
+ }
+diff --git sc/source/ui/vba/excelvbahelper.cxx sc/source/ui/vba/excelvbahelper.cxx
+new file mode 100644
+index 0000000..f2d1f5e
+--- /dev/null
++++ sc/source/ui/vba/excelvbahelper.cxx
+@@ -0,0 +1,210 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelper.cxx,v $
++ * $Revision: 1.5.32.1 $
++ *
++ * 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 <docuno.hxx>
++#include "excelvbahelper.hxx"
++#include "tabvwsh.hxx"
++#include "transobj.hxx"
++#include "scmod.hxx"
++#include <comphelper/processfactory.hxx>
++
++using namespace ::com::sun::star;
++using namespace ::ooo::vba;
++
++namespace ooo
++{
++namespace vba
++{
++namespace excel
++{
++bool isInPrintPreview( SfxViewFrame* pView )
++{
++	sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
++	if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() >
++nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
++	{
++		SfxViewFactory &rViewFactory =
++			pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
++		if (  pView->GetCurViewId() == rViewFactory.GetOrdinal() )
++			return true;
++	}
++	return false;
++}
++
++const ::rtl::OUString REPLACE_CELLS_WARNING(  RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning"));
++
++class PasteCellsWarningReseter
++{
++private:
++	bool bInitialWarningState;
++	static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
++	{
++		static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++		static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
++		static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
++				xContext->getServiceManager(), uno::UNO_QUERY_THROW );
++		static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
++		return xProps;
++	}
++
++	bool getReplaceCellsWarning() throw ( uno::RuntimeException )
++	{
++		sal_Bool res = sal_False;
++		getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res;
++		return ( res == sal_True );
++	}
++
++	void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException )
++	{
++		getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) );
++	}
++public:
++	PasteCellsWarningReseter() throw ( uno::RuntimeException )
++	{
++		bInitialWarningState = getReplaceCellsWarning();
++		if ( bInitialWarningState )
++			setReplaceCellsWarning( false );
++	}
++	~PasteCellsWarningReseter()
++	{
++		if ( bInitialWarningState )
++		{
++			// don't allow dtor to throw
++			try
++			{
++				setReplaceCellsWarning( true );
++			}
++			catch ( uno::Exception& /*e*/ ){}
++		}
++	}
++};
++
++void
++implnPaste()
++{
++	PasteCellsWarningReseter resetWarningBox;
++	ScTabViewShell* pViewShell = getCurrentBestViewShell();
++	if ( pViewShell )
++	{
++		pViewShell->PasteFromSystem();
++		pViewShell->CellContentChanged();
++	}
++}
++
++
++void
++implnCopy()
++{
++	ScTabViewShell* pViewShell = getCurrentBestViewShell();
++	if ( pViewShell )
++		pViewShell->CopyToClip(NULL,false,false,true);
++}
++
++void 
++implnCut()
++{
++	ScTabViewShell* pViewShell =  getCurrentBestViewShell();
++	if ( pViewShell )
++		pViewShell->CutToClip( NULL, TRUE );
++}
++
++void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose)
++{
++	PasteCellsWarningReseter resetWarningBox;
++	sal_Bool bAsLink(sal_False), bOtherDoc(sal_False);
++	InsCellCmd eMoveMode = INS_NONE;
++
++	ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell();
++	if ( !pTabViewShell ) 
++		// none active, try next best
++		pTabViewShell = getCurrentBestViewShell();
++	if ( pTabViewShell )
++	{
++		ScViewData* pView = pTabViewShell->GetViewData();	
++		Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL;
++		if ( pView && pWin )
++		{
++			if ( bAsLink && bOtherDoc )
++				pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK
++			else 
++			{
++				ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
++				ScDocument* pDoc = NULL; 
++				if ( pOwnClip )
++					pDoc = pOwnClip->GetDocument();	
++				pTabViewShell->PasteFromClip( nFlags, pDoc,
++					nFunction, bSkipEmpty, bTranspose, bAsLink,
++					eMoveMode, IDF_NONE, TRUE );
++				pTabViewShell->CellContentChanged();
++			}
++		}
++	}
++
++}
++
++ScDocShell* 
++getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) 
++{
++	uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
++	ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() );
++	ScDocShell* pDocShell = NULL;
++	if ( pModel )
++		pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
++	return pDocShell;
++
++}
++
++ScTabViewShell* 
++getBestViewShell(  css::uno::Reference< css::frame::XModel>& xModel )
++{
++	ScDocShell* pDocShell = getDocShell( xModel );
++	if ( pDocShell )
++		return pDocShell->GetBestViewShell();
++	return NULL;
++}
++
++ScTabViewShell* 
++getCurrentBestViewShell()
++{ 
++	uno::Reference< frame::XModel > xModel = getCurrentDocument();
++	return getBestViewShell( xModel );
++}
++
++SfxViewFrame* 
++getCurrentViewFrame()
++{
++	ScTabViewShell* pViewShell = getCurrentBestViewShell();	
++	if ( pViewShell )
++		return pViewShell->GetViewFrame();
++	return NULL;
++}
++
++} //excel
++} //vba 
++} //ooo 
+diff --git sc/source/ui/vba/excelvbahelper.hxx sc/source/ui/vba/excelvbahelper.hxx
+new file mode 100644
+index 0000000..e9e321a
+--- /dev/null
++++ sc/source/ui/vba/excelvbahelper.hxx
+@@ -0,0 +1,53 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelper.hxx,v $
++ * $Revision: 1.5.32.1 $
++ *
++ * 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 SC_EXCEL_VBA_HELPER_HXX
++#define SC_EXCEL_VBA_HELPER_HXX
++
++#include<vbahelper/vbahelper.hxx>
++#include <docsh.hxx>
++
++namespace ooo 
++{
++	namespace vba 
++	{
++	namespace excel
++        { 
++		void implnCopy();
++		void implnPaste();
++		void implnCut();
++		void implnPasteSpecial(sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
++		ScTabViewShell* getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel ) ;
++		ScDocShell* getDocShell( css::uno::Reference< css::frame::XModel>& xModel ) ;
++		ScTabViewShell* getCurrentBestViewShell();
++		SfxViewFrame* getCurrentViewFrame();
++};
++};
++};
++#endif
+diff --git sc/source/ui/vba/makefile.mk sc/source/ui/vba/makefile.mk
+index 46af202..3bba959 100644
+--- sc/source/ui/vba/makefile.mk
++++ sc/source/ui/vba/makefile.mk
+@@ -64,7 +64,7 @@ SLOFILES= \
+ 		$(SLO)$/vbaworksheet.obj \
+ 		$(SLO)$/vbaoutline.obj \
+ 		$(SLO)$/vbafont.obj\
+-		$(SLO)$/vbahelper.obj\
++		$(SLO)$/excelvbahelper.obj\
+ 		$(SLO)$/vbainterior.obj\
+ 		$(SLO)$/vbawsfunction.obj\
+ 		$(SLO)$/vbawindow.obj\
+@@ -81,20 +81,10 @@ SLOFILES= \
+ 		$(SLO)$/vbapalette.obj \
+ 		$(SLO)$/vbaborders.obj \
+ 		$(SLO)$/vbacharacters.obj \
+-		$(SLO)$/vbacombobox.obj \
+ 		$(SLO)$/vbavalidation.obj \
+-                $(SLO)$/vbacontrol.obj \
+-                $(SLO)$/vbacontrols.obj \
+                 $(SLO)$/vbaoleobject.obj \
+                 $(SLO)$/vbaoleobjects.obj \
+-                $(SLO)$/vbabutton.obj \
+-                $(SLO)$/vbalabel.obj \
+-                $(SLO)$/vbatextbox.obj \
+                 $(SLO)$/vbatextboxshape.obj \
+-                $(SLO)$/vbaradiobutton.obj \
+-                $(SLO)$/vbalistbox.obj \
+-		$(SLO)$/vbalistcontrolhelper.obj \
+-                $(SLO)$/vbapropvalue.obj \
+                 $(SLO)$/vbapane.obj \
+                 $(SLO)$/vbashape.obj \
+                 $(SLO)$/vbacolorformat.obj \
+@@ -116,24 +106,10 @@ SLOFILES= \
+                 $(SLO)$/vbastyle.obj \
+                 $(SLO)$/vbastyles.obj \
+                 $(SLO)$/vbaassistant.obj \
+-                $(SLO)$/vbauserform.obj \
+-                $(SLO)$/vbacheckbox.obj \
+-                $(SLO)$/vbatogglebutton.obj \
+-                $(SLO)$/vbaframe.obj \
+-                $(SLO)$/vbascrollbar.obj \
+-                $(SLO)$/vbaprogressbar.obj \
+-				$(SLO)$/vbamultipage.obj \
+-				$(SLO)$/vbapages.obj \
+-                $(SLO)$/vbacommandbarcontrol.obj \
+-                $(SLO)$/vbacommandbarcontrols.obj \
+-                $(SLO)$/vbacommandbar.obj \
+-                $(SLO)$/vbacommandbars.obj \
+ 		        $(SLO)$/vbahyperlink.obj \
+         		$(SLO)$/vbapagesetup.obj \
+ 		        $(SLO)$/vbapagebreak.obj \
+         		$(SLO)$/vbapagebreaks.obj \
+-		        $(SLO)$/vbaspinbutton.obj \
+-		        $(SLO)$/vbaimage.obj \
+ 				$(SLO)$/service.obj \
+         $(SLO)$/vbaeventshelper.obj \
+ 
+diff --git sc/source/ui/vba/service.cxx sc/source/ui/vba/service.cxx
+index 4d59f50..06629e7 100644
+--- sc/source/ui/vba/service.cxx
++++ sc/source/ui/vba/service.cxx
+@@ -61,11 +61,11 @@ namespace globals
+ {
+ extern sdecl::ServiceDecl const serviceDecl;
+ }
+-namespace  userform
++namespace hyperlink 
+ {
+ extern sdecl::ServiceDecl const serviceDecl;
+ }
+-namespace hyperlink 
++namespace application 
+ {
+ extern sdecl::ServiceDecl const serviceDecl;
+ }
+@@ -87,10 +87,10 @@ extern "C"
+         lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
+     {
+ 		OSL_TRACE("In component_writeInfo");
+-
++#if 0
+ 	// Component registration
+         if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
+-		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
++		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
+ 		{
+ 			// Singleton registration
+ 			try
+@@ -110,6 +110,12 @@ extern "C"
+ 			}
+ 		}
+ 		return sal_False;
++#else
++	// Component registration
++        return component_writeInfoHelper( pServiceManager, pRegistryKey, 
++		range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl );
++#endif
++	
+     }
+ 
+     SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( 
+@@ -118,7 +124,7 @@ extern "C"
+     {
+ 		OSL_TRACE("In component_getFactory for %s", pImplName );
+ 	void* pRet =  component_getFactoryHelper(
+-        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl, window::serviceDecl, hyperlink::serviceDecl );
++        	pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl );
+     if( !pRet )
+         pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl );
+ 	OSL_TRACE("Ret is 0x%x", pRet);
+diff --git sc/source/ui/vba/vbaapplication.cxx sc/source/ui/vba/vbaapplication.cxx
+index 122cfcd..69121a0 100644
+--- sc/source/ui/vba/vbaapplication.cxx
++++ sc/source/ui/vba/vbaapplication.cxx
+@@ -60,7 +60,6 @@
+ #include "vbashape.hxx"
+ #include "vbatextboxshape.hxx"
+ #include "vbaassistant.hxx"
+-#include "vbacommandbars.hxx"
+ #include "sc.hrc"
+ 
+ #include <osl/file.hxx>
+@@ -87,6 +86,7 @@
+ #include "miscuno.hxx"
+ #include "unonames.hxx"
+ #include "docsh.hxx"
++#include <vbahelper/helperdecl.hxx>
+ 
+ using namespace ::ooo::vba;
+ using namespace ::com::sun::star;
+@@ -123,7 +123,7 @@ public:
+ 	ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook(  xParent, xContext ){}
+ };
+ 
+-ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
++ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
+ {
+ }
+ 
+@@ -151,15 +151,6 @@ ScVbaApplication::getAssistant() throw (uno::RuntimeException)
+ }
+ 
+ uno::Any SAL_CALL
+-ScVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+-{
+-    uno::Reference< XCommandBars > xCommandBars( new ScVbaCommandBars( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
+-    if( aIndex.hasValue() )
+-        return uno::makeAny( xCommandBars->Item( aIndex, uno::Any() ) );
+-    return uno::makeAny( xCommandBars );
+-}
+-
+-uno::Any SAL_CALL
+ ScVbaApplication::getSelection() throw (uno::RuntimeException)
+ {
+     OSL_TRACE("** ScVbaApplication::getSelection() ** ");
+@@ -227,7 +218,7 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
+ {
+ 	uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW );
+ 	uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW);
+-	ScTabViewShell* pViewShell = getCurrentBestViewShell();
++	ScTabViewShell* pViewShell = excel::getCurrentBestViewShell();
+ 	if ( !pViewShell )
+ 		throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
+ 	ScViewData* pTabView = pViewShell->GetViewData();
+@@ -240,65 +231,6 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
+ 	return  new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
+ }
+ 
+-sal_Bool
+-ScVbaApplication::getScreenUpdating() throw (uno::RuntimeException)
+-{
+-	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-	return !xModel->hasControllersLocked();
+-}
+-
+-void
+-ScVbaApplication::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException)
+-{
+-	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-	if (bUpdate)
+-		xModel->unlockControllers();
+-	else
+-		xModel->lockControllers();
+-}
+-
+-sal_Bool
+-ScVbaApplication::getDisplayStatusBar() throw (uno::RuntimeException)
+-{
+-	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-    uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+-    uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
+-
+-    if( xProps.is() ){
+-        uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
+-        rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
+-        if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){
+-            return sal_True;
+-        }
+-    }
+-    return sal_False;
+-}
+-
+-void
+-ScVbaApplication::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException)
+-{
+-	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-    uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+-    uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
+-
+-    if( xProps.is() ){
+-        uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
+-        rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
+-        if( xLayoutManager.is() ){
+-            if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){
+-                if( !xLayoutManager->showElement( url ) )
+-                    xLayoutManager->createElement( url );
+-                return;
+-            }
+-            else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){
+-                xLayoutManager->hideElement( url ); 
+-                return;
+-            }
+-        }
+-    }
+-    return;
+-}
+-
+ uno::Any SAL_CALL
+ ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+ {
+@@ -347,7 +279,7 @@ ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeExc
+ uno::Any 
+ ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException)
+ {
+-	uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext ) );
++	uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< XHelperInterface >( this ), mxContext ) );
+ 	if( !aIndex.hasValue() )
+ 		return uno::Any( xDialogs );
+ 	return uno::Any( xDialogs->Item( aIndex ) );
+@@ -460,7 +392,7 @@ ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::Runtime
+ uno::Any SAL_CALL 
+ ScVbaApplication::Windows( const uno::Any& aIndex  ) throw (uno::RuntimeException)
+ {
+-	uno::Reference< XCollection >  xWindows = ScVbaWindows::Windows( mxContext );
++	uno::Reference< excel::XWindows >  xWindows( new ScVbaWindows( this, mxContext ) );
+ 	if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ 		return uno::Any( xWindows );
+ 	return uno::Any( xWindows->Item( aIndex, uno::Any() ) );	
+@@ -571,11 +503,11 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro
+                 xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+         uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet();
+ 
+-        ScTabViewShell* pShell = getCurrentBestViewShell();
++        ScTabViewShell* pShell = excel::getCurrentBestViewShell();
+         ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); 
+         try
+         {
+-            uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
++            uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
+ ;
+             if( bScroll )
+             {
+@@ -613,7 +545,7 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro
+     if( Reference >>= xRange )
+     {
+         uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY );
+-        ScTabViewShell* pShell = getCurrentBestViewShell();
++        ScTabViewShell* pShell = excel::getCurrentBestViewShell();
+         ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); 
+         if ( xVbaRange.is() )
+         {
+@@ -643,38 +575,10 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro
+             uno::Reference< uno::XInterface >() );
+ }
+ 
+-namespace
+-{
+-    static uno::Reference< frame::XController > lcl_getCurrentController()
+-    {
+-        const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+-        uno::Reference< frame::XController > xController;
+-        if ( xWorkingDoc.is() )
+-            xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW );
+-        else
+-            xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
+-        return xController;
+-    }
+-}
+-
+ sal_Int32 SAL_CALL
+ ScVbaApplication::getCursor() throw (uno::RuntimeException)
+ {
+-    sal_Int32 nPointerStyle( POINTER_ARROW );
+-    try
+-    {
+-        const uno::Reference< frame::XController > xController( lcl_getCurrentController(),     uno::UNO_SET_THROW );
+-        const uno::Reference< frame::XFrame >      xFrame     ( xController->getFrame(),        uno::UNO_SET_THROW );
+-        const uno::Reference< awt::XWindow >       xWindow    ( xFrame->getContainerWindow(),   uno::UNO_SET_THROW );
+-        // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only?
+-        const Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+-        if ( pWindow )
+-            nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle();
+-    }
+-    catch( const uno::Exception& )
+-    {
+-    	DBG_UNHANDLED_EXCEPTION();
+-    }
++    sal_Int32 nPointerStyle =  getPointerStyle();
+ 
+     switch( nPointerStyle )
+     {
+@@ -696,82 +600,34 @@ ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
+ {
+     try
+     {
+-        ::std::vector< uno::Reference< frame::XController > > aControllers;
+-
+-        const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+-        if ( xModel2.is() )
++        switch( _cursor )
+         {
+-            const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW );
+-            while ( xEnumControllers->hasMoreElements() )
++            case excel::XlMousePointer::xlNorthwestArrow:
+             {
+-                const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW );
+-                aControllers.push_back( xController );
++                const Pointer& rPointer( POINTER_ARROW );
++                setCursorHelper( rPointer, sal_False );
++                break;
+             }
+-        }
+-        else
+-        {
+-            const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
+-            if ( xModel.is() )
++            case excel::XlMousePointer::xlWait:
++            case excel::XlMousePointer::xlIBeam:
+             {
+-                const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
+-                aControllers.push_back( xController );
++                const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) );
++                //It will set the edit window, toobar and statusbar's mouse pointer.
++                setCursorHelper( rPointer, sal_True );
++                break;
+             }
+-            else
++            case excel::XlMousePointer::xlDefault:
+             {
+-                const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
+-                aControllers.push_back( xController );
++                const Pointer& rPointer( POINTER_NULL );
++                setCursorHelper( rPointer, sal_False );
++                break;
+             }
+-        }
+-
+-        for (   ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin();
+-                controller != aControllers.end();
+-                ++controller
+-            )
+-        {
+-            const uno::Reference< frame::XFrame >      xFrame     ( (*controller)->getFrame(),       uno::UNO_SET_THROW   );
+-            const uno::Reference< awt::XWindow >       xWindow    ( xFrame->getContainerWindow(),    uno::UNO_SET_THROW   );
+-
+-            Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+-            OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" );
+-            if ( !pWindow )
+-                continue;
+-
+-            switch( _cursor )
+-            {
+-                case excel::XlMousePointer::xlNorthwestArrow:
+-                {
+-                    const Pointer& rPointer( POINTER_ARROW );
+-                    pWindow->GetSystemWindow()->SetPointer( rPointer );
+-                    pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
+-                    break;
+-                }
+-                case excel::XlMousePointer::xlWait:
+-                case excel::XlMousePointer::xlIBeam:
+-                {
+-                    const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) );
+-                    //It will set the edit window, toobar and statusbar's mouse pointer.
+-                    pWindow->GetSystemWindow()->SetPointer( rPointer );
+-                    pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_True );
+-                    //It only set the edit window's mouse pointer
+-                    //pWindow->.SetPointer( rPointer );
+-                    //pWindow->.EnableChildPointerOverwrite( sal_True );
+-                    //printf("\nset Cursor...%d\n", pWindow->.GetType());
+-                    break;
+-                }
+-                case excel::XlMousePointer::xlDefault:
+-                {
+-                    const Pointer& rPointer( POINTER_NULL );
+-                    pWindow->GetSystemWindow()->SetPointer( rPointer );
+-                    pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
+-                    break;
+-                }
+-                default:
+-                    throw uno::RuntimeException( rtl::OUString( 
+-                            RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
+-                    // TODO: isn't this a flaw in the API? It should be allowed to throw an
+-                    // IllegalArgumentException, or so
+-            }
+-        }
++            default:
++                throw uno::RuntimeException( rtl::OUString( 
++                        RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
++                // TODO: isn't this a flaw in the API? It should be allowed to throw an
++                // IllegalArgumentException, or so
++        }        
+     }
+     catch( const uno::Exception& )
+     {
+@@ -1145,7 +1001,7 @@ ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const
+ 	}
+ 
+ 	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-	ScDocShell* pDocShell = getDocShell( xModel );
++	ScDocShell* pDocShell = excel::getDocShell( xModel );
+ 	if ( aCellRanges.Count() == 1 )
+ 	{
+ 		xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) );
+@@ -1234,7 +1090,7 @@ ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno:
+ 		aCellRanges.Append( *it );
+ 
+ 	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-    ScDocShell* pDocShell = getDocShell( xModel ); 
++    ScDocShell* pDocShell = excel::getDocShell( xModel ); 
+ 	if ( aCellRanges.Count() == 1 ) 
+ 	{
+ 	// normal range
+@@ -1269,16 +1125,11 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile )  throw ( uno::RuntimeExc
+ */
+ }
+ 
+-void SAL_CALL
+-ScVbaApplication::DoEvents() throw ( uno::RuntimeException )
+-{
+-}
+-
+ ::sal_Bool SAL_CALL 
+ ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
+ {
+ 	sal_Bool bRes = sal_False;
+-	ScTabViewShell* pViewShell = getCurrentBestViewShell();
++	ScTabViewShell* pViewShell = excel::getCurrentBestViewShell();
+ 	if ( pViewShell )
+ 	{
+ 		SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE);
+@@ -1296,7 +1147,7 @@ ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
+ void SAL_CALL 
+ ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException )
+ {
+-	ScTabViewShell* pViewShell = getCurrentBestViewShell();
++	ScTabViewShell* pViewShell = excel::getCurrentBestViewShell();
+ 	if ( pViewShell && ( _displayformulabar !=  getDisplayFormulaBar() ) )
+ 	{
+ 		SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar);
+@@ -1343,3 +1194,13 @@ ScVbaApplication::getServiceNames()
+ 	}
+ 	return aServiceNames;
+ }
++
++namespace application
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "ScVbaApplication",
++    "ooo.vba.excel.Application" );
++}
+diff --git sc/source/ui/vba/vbaapplication.hxx sc/source/ui/vba/vbaapplication.hxx
+index 754885e..9435282 100644
+--- sc/source/ui/vba/vbaapplication.hxx
++++ sc/source/ui/vba/vbaapplication.hxx
+@@ -35,9 +35,12 @@
+ #include <ooo/vba/excel/XApplication.hpp>
+ #include <com/sun/star/uno/XComponentContext.hpp>
+ 
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbaapplicationbase.hxx>
++#include <cppuhelper/implbase1.hxx>
+ 
+-typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE;
++//typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE;
++typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE;
+ 
+ class ScVbaApplication : public ScVbaApplication_BASE
+ {
+@@ -45,12 +48,9 @@ private:
+ 	sal_Int32 m_xCalculation;
+ 	rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException );
+ public:
+-	ScVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext );
++	ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext );
+ 	virtual ~ScVbaApplication();
+ 
+-	// XHelperInterface ( parent is itself )
+-	virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return this; }
+-
+ 	// XApplication
+ 	virtual ::rtl::OUString SAL_CALL PathSeparator(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ 	virtual void SAL_CALL setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+@@ -68,15 +68,10 @@ public:
+ 	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw ( css::uno::RuntimeException);
+  virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
+  virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
+-	virtual sal_Bool SAL_CALL getScreenUpdating() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException);
+-	virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException);
+ 	virtual ::sal_Bool SAL_CALL getDisplayFormulaBar() throw ( css::uno::RuntimeException );
+ 	virtual void SAL_CALL setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException );
+ 
+     virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
+-    virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+@@ -102,7 +97,6 @@ public:
+ 	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorEx
 ception, css::uno::RuntimeException);
+ 	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorExcept
 ion, css::uno::RuntimeException);
+ 	virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException );
+-	virtual void SAL_CALL DoEvents() throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	// XHelperInterface
+ 	virtual rtl::OUString& getServiceImplName();
+diff --git sc/source/ui/vba/vbaassistant.hxx sc/source/ui/vba/vbaassistant.hxx
+index d3c5ff4..060538d 100644
+--- sc/source/ui/vba/vbaassistant.hxx
++++ sc/source/ui/vba/vbaassistant.hxx
+@@ -40,8 +40,8 @@
+ 
+ #include <sfx2/sfxhelp.hxx>
+ 
+-#include "vbahelper.hxx"
+-#include "vbahelperinterface.hxx"
++#include "excelvbahelper.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ 
+ typedef ::cppu::WeakImplHelper1< ov::XAssistant > Assistant;
+ typedef InheritedHelperInterfaceImpl< Assistant > ScVbaAssistantImpl_BASE;
+diff --git sc/source/ui/vba/vbaaxes.hxx sc/source/ui/vba/vbaaxes.hxx
+index 1117d27..3ef05ec 100644
+--- sc/source/ui/vba/vbaaxes.hxx
++++ sc/source/ui/vba/vbaaxes.hxx
+@@ -32,7 +32,7 @@
+ #include <ooo/vba/excel/XAxes.hpp>
+ #include <ooo/vba/excel/XAxis.hpp>
+ #include <ooo/vba/excel/XChart.hpp>
+-#include "vbacollectionimpl.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
+ 
+ typedef CollTestImplHelper< ov::excel::XAxes > ScVbaAxes_BASE;
+ class ScVbaAxes : public ScVbaAxes_BASE
+diff --git sc/source/ui/vba/vbaaxis.hxx sc/source/ui/vba/vbaaxis.hxx
+index 71ec1c1..f51bac5 100644
+--- sc/source/ui/vba/vbaaxis.hxx
++++ sc/source/ui/vba/vbaaxis.hxx
+@@ -32,8 +32,8 @@
+ #include <com/sun/star/beans/XPropertySet.hpp>
+ #include <ooo/vba/excel/XAxis.hpp>
+ #include <ooo/vba/excel/XChart.hpp>
+-#include "vbahelperinterface.hxx"
+-
++#include <vbahelper/vbahelperinterface.hxx>
++#include <memory>
+ typedef InheritedHelperInterfaceImpl1< ov::excel::XAxis >  ScVbaAxis_BASE;
+ class ScVbaChart;
+ class ScVbaAxis : public ScVbaAxis_BASE
+diff --git sc/source/ui/vba/vbaborders.hxx sc/source/ui/vba/vbaborders.hxx
+index 9ad8c50..642e32b 100644
+--- sc/source/ui/vba/vbaborders.hxx
++++ sc/source/ui/vba/vbaborders.hxx
+@@ -38,7 +38,7 @@
+ #include <com/sun/star/beans/XPropertySet.hpp>
+ 
+  
+-#include "vbacollectionimpl.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
+ 
+ typedef CollTestImplHelper< ov::excel::XBorders > ScVbaBorders_BASE;
+ class ScVbaPalette;
+diff --git sc/source/ui/vba/vbabutton.cxx sc/source/ui/vba/vbabutton.cxx
+deleted file mode 100644
+index 0e4d749..0000000
+--- sc/source/ui/vba/vbabutton.cxx
++++ /dev/null
+@@ -1,74 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbabutton.cxx,v $
+- * $Revision: 1.3 $
+- *
+- * 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 "vbabutton.hxx"
+-#include <vector>
+-
+-using namespace com::sun::star;
+-using namespace ooo::vba;
+-
+-
+-const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
+-ScVbaButton::ScVbaButton( 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 ) : ButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+-{
+-}
+-
+-// Attributes
+-rtl::OUString SAL_CALL 
+-ScVbaButton::getCaption() throw (css::uno::RuntimeException)
+-{
+-    rtl::OUString Label;
+-    m_xProps->getPropertyValue( LABEL ) >>= Label;
+-    return Label;
+-}
+-
+-void SAL_CALL 
+-ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+-{
+-    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
+-}
+-
+-rtl::OUString& 
+-ScVbaButton::getServiceImplName()
+-{
 -	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaButton") );
 -	return sImplName;
 -}
 -
--uno::Sequence< rtl::OUString > 
--ScVbaButton::getServiceNames()
+-uno::Sequence< rtl::OUString > 
+-ScVbaButton::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Button" ) );
+-	}
+-	return aServiceNames;
+-}
+diff --git sc/source/ui/vba/vbabutton.hxx sc/source/ui/vba/vbabutton.hxx
+deleted file mode 100644
+index 2a98ad6..0000000
+--- sc/source/ui/vba/vbabutton.hxx
++++ /dev/null
+@@ -1,51 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbabutton.hxx,v $
+- * $Revision: 1.3 $
+- *
+- * 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 SC_VBA_BUTTON_HXX
+-#define SC_VBA_BUTTON_HXX
+-#include <cppuhelper/implbase1.hxx>
+-#include <ooo/vba/msforms/XButton.hpp>
+-
+-#include "vbacontrol.hxx"
+-#include "vbahelper.hxx"
+-
+-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
+-
+-class ScVbaButton : public ButtonImpl_BASE
+-{
+-public:
+-    ScVbaButton( 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 rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+-    //XHelperInterface
+-    virtual rtl::OUString& getServiceImplName();
+-    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-#endif //SC_VBA_BUTTON_HXX
+diff --git sc/source/ui/vba/vbacharacters.hxx sc/source/ui/vba/vbacharacters.hxx
+index 1ea523f..f69b6d2 100644
+--- sc/source/ui/vba/vbacharacters.hxx
++++ sc/source/ui/vba/vbacharacters.hxx
+@@ -36,7 +36,7 @@
+ #include <com/sun/star/uno/XComponentContext.hpp>
+ #include <com/sun/star/text/XSimpleText.hpp>
+ 
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ #include "vbapalette.hxx"
+ typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaCharacters_BASE;
+ 
+diff --git sc/source/ui/vba/vbachart.hxx sc/source/ui/vba/vbachart.hxx
+index cd20e06..b7fab46 100644
+--- sc/source/ui/vba/vbachart.hxx
++++ sc/source/ui/vba/vbachart.hxx
+@@ -41,7 +41,7 @@
+ #include <ooo/vba/excel/XChart.hpp>
+ #include <ooo/vba/excel/XDataLabels.hpp>
+ #include <ooo/vba/excel/XSeries.hpp>
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ 
+ typedef InheritedHelperInterfaceImpl1<ov::excel::XChart > ChartImpl_BASE;
+ 
+diff --git sc/source/ui/vba/vbachartobject.hxx sc/source/ui/vba/vbachartobject.hxx
+index e36f157..45b5c17 100644
+--- sc/source/ui/vba/vbachartobject.hxx
++++ sc/source/ui/vba/vbachartobject.hxx
+@@ -36,7 +36,7 @@
+ #include <com/sun/star/container/XNamed.hpp>
+ #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+ #include <ooo/vba/excel/XChartObject.hpp>
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ #include <memory>
+ 
+ typedef InheritedHelperInterfaceImpl1<ov::excel::XChartObject > ChartObjectImpl_BASE;
+diff --git sc/source/ui/vba/vbachartobjects.hxx sc/source/ui/vba/vbachartobjects.hxx
+index 3b18f51..bc87157 100644
+--- sc/source/ui/vba/vbachartobjects.hxx
++++ sc/source/ui/vba/vbachartobjects.hxx
+@@ -36,8 +36,8 @@
+ #include <com/sun/star/table/XTableCharts.hpp>
+ #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+ #include <com/sun/star/container/XEnumerationAccess.hpp>
+-#include"vbacollectionimpl.hxx"
+-#include "vbahelper.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
++#include "excelvbahelper.hxx"
+ #include <hash_map>
+ 
+ typedef CollTestImplHelper< ov::excel::XChartObjects > ChartObjects_BASE;
+diff --git sc/source/ui/vba/vbacharts.hxx sc/source/ui/vba/vbacharts.hxx
+index d9d0f8e..cedfeaa 100644
+--- sc/source/ui/vba/vbacharts.hxx
++++ sc/source/ui/vba/vbacharts.hxx
+@@ -31,8 +31,8 @@
+ #define SC_VBA_CHARTS_HXX
+ #include <ooo/vba/excel/XCharts.hpp>
+ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+-#include"vbacollectionimpl.hxx"
+-#include "vbahelper.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
++#include "excelvbahelper.hxx"
+ #include <hash_map>
+ 
+ typedef CollTestImplHelper< ov::excel::XCharts > Charts_BASE;
+diff --git sc/source/ui/vba/vbacheckbox.cxx sc/source/ui/vba/vbacheckbox.cxx
+deleted file mode 100644
+index 958e375..0000000
+--- sc/source/ui/vba/vbacheckbox.cxx
++++ /dev/null
+@@ -1,110 +0,0 @@
+-/*************************************************************************
+- *
+- *  OpenOffice.org - a multi-platform office productivity suite
+- *
+- *  $RCSfile$
+- *
+- *  $Revision$
+- *
+- *  last change: $Author$ $Date$
+- *
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
+- *
+- *
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#include "vbacheckbox.hxx"
+-#include <vector>
+-
+-using namespace com::sun::star;
+-using namespace ooo::vba;
+-
+-
+-const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
+-const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
+-ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+-{
+-}
+-
+-// Attributes
+-rtl::OUString SAL_CALL 
+-ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
+-{
+-    rtl::OUString Label;
+-    m_xProps->getPropertyValue( LABEL ) >>= Label;
+-    return Label;
+-}
+-
+-void SAL_CALL 
+-ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+-{
+-    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
+-{
+-    sal_Int16 nValue = -1;
+-    m_xProps->getPropertyValue( STATE ) >>= nValue;
+-    if( nValue != 0 )
+-        nValue = -1;
+-//    return uno::makeAny( nValue ); 
+-// I must be missing something MSO says value should be -1 if selected, 0 if not
+-// selected
+-    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
+-}
+-
+-void SAL_CALL 
+-ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
+-{
+-    sal_Int16 nValue = 0;
+-    sal_Bool bValue = false;
+-    if( _value >>= nValue )
+-    {
+-        if( nValue == -1)
+-            nValue = 1;
+-    }
+-    else if ( _value >>= bValue )
+-    {
+-        if ( bValue )
+-            nValue = 1;
+-    }
+-    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
+-}
+-rtl::OUString& 
+-ScVbaCheckbox::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
+-	return sImplName;
+-}
+-
+-uno::Sequence< rtl::OUString > 
+-ScVbaCheckbox::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
+-	}
+-	return aServiceNames;
+-}
+diff --git sc/source/ui/vba/vbacheckbox.hxx sc/source/ui/vba/vbacheckbox.hxx
+deleted file mode 100644
+index 58805c6..0000000
+--- sc/source/ui/vba/vbacheckbox.hxx
++++ /dev/null
+@@ -1,60 +0,0 @@
+-/*************************************************************************
+- *
+- *  OpenOffice.org - a multi-platform office productivity suite
+- *
+- *  $RCSfile$
+- *
+- *  $Revision$
+- *
+- *  last change: $Author$ $Date$
+- *
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
+- *
+- *
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#ifndef SC_VBA_CHECKBOX_HXX
+-#define SC_VBA_CHECKBOX_HXX
+-#include <cppuhelper/implbase2.hxx>
+-#include <ooo/vba/msforms/XRadioButton.hpp>
+-
+-#include "vbacontrol.hxx"
+-#include "vbahelper.hxx"
+-
+-typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
+-
+-class ScVbaCheckbox : public CheckBoxImpl_BASE
+-{
+-public:
+-    ScVbaCheckbox(  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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+-    // XDefaultProperty
+-    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
+-    //XHelperInterface
+-    virtual rtl::OUString& getServiceImplName();
+-    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-#endif //SC_VBA_CHECKBOX_HXX
+diff --git sc/source/ui/vba/vbacollectionimpl.cxx sc/source/ui/vba/vbacollectionimpl.cxx
+deleted file mode 100644
+index 5a9ae13..0000000
+--- sc/source/ui/vba/vbacollectionimpl.cxx
++++ /dev/null
+@@ -1,136 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbacollectionimpl.cxx,v $
+- * $Revision: 1.3 $
+- *
+- * 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 <vbacollectionimpl.hxx>
+-#include "vbaglobals.hxx"
+-using namespace ::com::sun::star;
+-using namespace ::ooo::vba;
+-
+-
+-ScVbaCollectionBaseImpl::ScVbaCollectionBaseImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ) throw (uno::RuntimeException) : m_xContext( xContext ), m_xIndexAccess( xIndexAccess )
+-{
+-	m_xNameAccess.set( xIndexAccess, uno::UNO_QUERY );
+-}
+-
+-uno::Any
+-ScVbaCollectionBaseImpl::getItemByStringIndex( const rtl::OUString& sIndex ) throw (::uno::RuntimeException)
+-{
+-	if ( !m_xNameAccess.is() )
+-		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBaseImpl string index access not supported by this object") ), uno::Reference< uno::XInterface >() );
+-
+-	return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
+-}
+-
+-uno::Any 
+-ScVbaCollectionBaseImpl::getItemByIntIndex( const sal_Int32 nIndex ) throw (uno::RuntimeException)
+-{
+-	if ( !m_xIndexAccess.is() )
+-		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBaseImpl numeric index access not supported by this object") ), uno::Reference< uno::XInterface >() );
+-	if ( nIndex <= 0 )
+-	{
+-		throw  lang::IndexOutOfBoundsException( 
+-			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
+-			"index is 0 or negative" ) ), 
+-			uno::Reference< uno::XInterface >() );
+-	}
+-	// need to adjust for vba index ( for which first element is 1 )
+-	return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );	
+-}
+-
+-::sal_Int32 SAL_CALL 
+-ScVbaCollectionBaseImpl::getCount() throw (uno::RuntimeException)
+-{
+-	return m_xIndexAccess->getCount();
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaCollectionBaseImpl::getParent() throw (uno::RuntimeException)
+-{
+-	// #TODO #FIXME investigate whether this makes sense
+-	uno::Reference< excel::XApplication > xApplication =
+-		ScVbaGlobals::getGlobalsImpl( m_xContext )->getApplication();
+-	uno::Reference< excel::XWorkbook > xWorkbook;
+-	if ( xApplication.is() )
+-	{
+-		xWorkbook = xApplication->getActiveWorkbook();
+-	}
+-	return uno::Any( xWorkbook );
+-}
+-
+-::sal_Int32 SAL_CALL ScVbaCollectionBaseImpl::getCreator() throw (uno::RuntimeException)
+-{
+-	// #TODO #FIXE some sort of implementation
+-	//SC_VBA_STUB();
+-	return 0;
+-}
+-uno::Reference< excel::XApplication > SAL_CALL ScVbaCollectionBaseImpl::getApplication() throw (uno::RuntimeException)
+-{
+-	// #TODO #FIXME investigate whether this makes sense
+-	uno::Reference< excel::XApplication > xApplication =
+-		ScVbaGlobals::getGlobalsImpl( m_xContext )->getApplication();
+-	return  xApplication;
+-}
+-
+-uno::Any SAL_CALL ScVbaCollectionBaseImpl::Item( const uno::Any& aIndex ) throw (uno::RuntimeException)
+-{
+-	if ( aIndex.getValueTypeClass() != uno::TypeClass_STRING )
+-	{
+-		sal_Int32 nIndex = 0;
+-
+-		if ( ( aIndex >>= nIndex ) != sal_True )
+-		{
+-			rtl::OUString message;
+-			message = rtl::OUString::createFromAscii(
+-				"Couldn't convert index to Int32");
+-			throw  lang::IndexOutOfBoundsException( message,
+-				uno::Reference< uno::XInterface >() );
+-		}
+-		return 	getItemByIntIndex( nIndex );
+-	}
+-	rtl::OUString aStringSheet;
+-
+-	aIndex >>= aStringSheet;
+-	return getItemByStringIndex( aStringSheet );	
+-}
+-
+-::rtl::OUString SAL_CALL 
+-ScVbaCollectionBaseImpl::getDefaultMethodName(  ) throw (css::uno::RuntimeException)
+-{
+-	const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
+-	return sName;
+-}
+-
+-	// XElementAccess
+-
+-::sal_Bool SAL_CALL ScVbaCollectionBaseImpl::hasElements() throw (uno::RuntimeException)
+-{
+-	return ( m_xIndexAccess->getCount() > 0 );
+-}
+-
+-
+diff --git sc/source/ui/vba/vbacollectionimpl.hxx sc/source/ui/vba/vbacollectionimpl.hxx
+deleted file mode 100644
+index 80371a3..0000000
+--- sc/source/ui/vba/vbacollectionimpl.hxx
++++ /dev/null
+@@ -1,259 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbacollectionimpl.hxx,v $
+- * $Revision: 1.5 $
+- *
+- * 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 SC_VBA_COLLECTION_IMPL_HXX
+-#define SC_VBA_COLLECTION_IMPL_HXX
+-
+-#include <ooo/vba/XCollection.hpp>
+-//#include <ooo/vba/XCollectionTest.hpp>
+-#include <com/sun/star/container/XEnumerationAccess.hpp>
+-#include <com/sun/star/uno/XComponentContext.hpp>
+-#include <com/sun/star/script/XDefaultMethod.hpp>
+-#include <com/sun/star/container/XIndexAccess.hpp>
+-#include <com/sun/star/container/XNameAccess.hpp>
+-#include <com/sun/star/container/XNamed.hpp>
+-
+-#include <cppuhelper/implbase3.hxx>
+-#include <cppuhelper/implbase2.hxx>
+-#include <cppuhelper/implbase1.hxx>
+-
+-#include "vbahelper.hxx"
+-#include "vbahelperinterface.hxx"
+-#include "vbaglobals.hxx"
+-
+-#include <vector>
+-
+-typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE;
+-
+-class EnumerationHelperImpl : public EnumerationHelper_BASE
+-{
+-protected:
+-	css::uno::Reference< css::uno::XComponentContext > m_xContext;
+-	css::uno::Reference< css::container::XEnumeration > m_xEnumeration;
+-public:
+-
+-	EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ),  m_xEnumeration( xEnumeration ) { }
+-	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); }
+-};
+-
+-// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces 
+-// only requirement is the object needs to implement XName
+-
+-
+-
+-typedef ::cppu::WeakImplHelper3< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess > XNamedCollectionHelper_BASE;
+-
+-template< typename Ifc1 >
+-class XNamedObjectCollectionHelper : public XNamedCollectionHelper_BASE
+-{
+-public:
+-typedef std::vector< css::uno::Reference< Ifc1 > >  XNamedVec;
+-private:
+-
+-	class XNamedEnumerationHelper : public EnumerationHelper_BASE
+-	{
+-		XNamedVec mXNamedVec;
+-		typename XNamedVec::iterator mIt;
+-	public:
+-	        XNamedEnumerationHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), mIt( mXNamedVec.begin() ) {}
+-	
+-	        virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException)
+-	        {
+-			return ( mIt != mXNamedVec.end() );
+-	        }
+-	
+-	        virtual css::uno::Any SAL_CALL nextElement(  ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+-	        {
+-	                if ( hasMoreElements() )
+-				return css::uno::makeAny( *mIt++ );
+-	                throw css::container::NoSuchElementException();
+-	        }
+-	};
+-
+-protected:
+-	XNamedVec mXNamedVec;
+-	typename XNamedVec::iterator cachePos;
+-public:
+-	XNamedObjectCollectionHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), cachePos(mXNamedVec.begin()) {}
+-	// XElementAccess
+-	virtual css::uno::Type SAL_CALL getElementType(  ) throw (css::uno::RuntimeException) { return  Ifc1::static_type(0); }
+-	virtual ::sal_Bool SAL_CALL hasElements(  ) throw (css::uno::RuntimeException) { return ( mXNamedVec.size() > 0 ); }
+-	// XNameAcess 
+-	virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+-	{
+-		if ( !hasByName(aName) )
+-			throw css::container::NoSuchElementException();
+-		return css::uno::makeAny( *cachePos );
+-	}
+-	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (css::uno::RuntimeException)
+-	{
+-		css::uno::Sequence< rtl::OUString > sNames( mXNamedVec.size() );
+-		rtl::OUString* pString = sNames.getArray();
+-		typename XNamedVec::iterator it = mXNamedVec.begin();
+-		typename XNamedVec::iterator it_end = mXNamedVec.end();
+-
+-		for ( ; it != it_end; ++it, ++pString )
+-		{
+-			css::uno::Reference< css::container::XNamed > xName( *it, css::uno::UNO_QUERY_THROW );	
+-			*pString = xName->getName();
+-		}
+-		return sNames;
+-	}
+-	virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
+-	{
+-		cachePos = mXNamedVec.begin();
+-		typename XNamedVec::iterator it_end = mXNamedVec.end();
+-		for ( ; cachePos != it_end; ++cachePos )
+-		{
+-			css::uno::Reference< css::container::XNamed > xName( *cachePos, css::uno::UNO_QUERY_THROW );	
+-			if ( aName.equals( xName->getName() ) )
+-				break;
+-		}
+-		return ( cachePos != it_end );
+-	}
+-
+-	// XElementAccess
+-	virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException) { return mXNamedVec.size(); }	
+-	virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException )
+-	{
+-		if ( Index < 0 || Index >= getCount() )
+-			throw css::lang::IndexOutOfBoundsException();
+-	
+-		return css::uno::makeAny( mXNamedVec[ Index ] );
+-
+-	}
+-	// XEnumerationAccess
+-	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (css::uno::RuntimeException)
+-	{
+-		return new XNamedEnumerationHelper( mXNamedVec );
+-	}
+-};
+-
+-// including a HelperInterface implementation
+-template< typename Ifc1 >
+-class ScVbaCollectionBase : public InheritedHelperInterfaceImpl< Ifc1 >
+-{
+-typedef InheritedHelperInterfaceImpl< Ifc1 > BaseColBase;
+-protected:
+-	css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess;
+-	css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
+-
+-	virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException)
+-	{
+-		if ( !m_xNameAccess.is() )
+-			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase string index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
+-	
+-		return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
+-	}		
+-
+-	virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException)
+-	{
+-		if ( !m_xIndexAccess.is() )
+-			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase numeric index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
+-		if ( nIndex <= 0 )
+-		{
+-			throw  css::lang::IndexOutOfBoundsException( 
+-				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
+-				"index is 0 or negative" ) ), 
+-				css::uno::Reference< css::uno::XInterface >() );
+-		}
+-		// need to adjust for vba index ( for which first element is 1 )
+-		return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );		
+-	}
+-public:
+-	ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent,   const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); }
+-	//XCollection
+-	virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException)
+-	{
+-		return m_xIndexAccess->getCount();
+-	}
+-
+-	virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw (css::uno::RuntimeException)
+-	{
+-		if ( Index1.getValueTypeClass() != css::uno::TypeClass_STRING )
+-		{
+-			sal_Int32 nIndex = 0;
+-	
+-			if ( ( Index1 >>= nIndex ) != sal_True )
+-			{
+-				rtl::OUString message;
+-				message = rtl::OUString::createFromAscii(
+-					"Couldn't convert index to Int32");
+-				throw  css::lang::IndexOutOfBoundsException( message,
+-					css::uno::Reference< css::uno::XInterface >() );
+-			}
+-			return 	getItemByIntIndex( nIndex );
+-		}
+-		rtl::OUString aStringSheet;
+-
+-		Index1 >>= aStringSheet;
+-		return getItemByStringIndex( aStringSheet );	
+-	}
+-	// XDefaultMethod
+-	::rtl::OUString SAL_CALL getDefaultMethodName(  ) throw (css::uno::RuntimeException)
+-	{
+-		const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
+-		return sName;
+-	}
+-	// XEnumerationAccess
+-	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0;	
+-
+-	// XElementAccess
+-	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0;
+-	// XElementAccess
+-	virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException)
+-	{
+-		return ( m_xIndexAccess->getCount() > 0 );
+-	}
+-	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0;
+-	
+-};
+-
+-typedef ::cppu::WeakImplHelper1<ov::XCollection> XCollection_InterfacesBASE;
+-
+-typedef ScVbaCollectionBase< XCollection_InterfacesBASE > CollImplBase1;
+-// compatible with the old collections ( pre XHelperInterface base class ) ( some internal objects still use this )
+-class ScVbaCollectionBaseImpl : public CollImplBase1
+-{
+-public:
+-	ScVbaCollectionBaseImpl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : CollImplBase1( xParent, xContext, xIndexAccess){}
+-
+-};
+-
+-template <typename Ifc> // where Ifc must implement XCollectionTest
+-class CollTestImplHelper :  public ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > >
+-{
+-typedef ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc >  > ImplBase1;
+-
+-public:
+-	CollTestImplHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,  const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : ImplBase1( xParent, xContext, xIndexAccess ) {}
+-};
+-
+-
+-#endif //SC_VBA_COLLECTION_IMPL_HXX
+diff --git sc/source/ui/vba/vbacolorformat.hxx sc/source/ui/vba/vbacolorformat.hxx
+index a5104d8..a45d5d8 100644
+--- sc/source/ui/vba/vbacolorformat.hxx
++++ sc/source/ui/vba/vbacolorformat.hxx
+@@ -33,7 +33,7 @@
+ #include <com/sun/star/drawing/XShape.hpp>
+ #include <ooo/vba/msforms/XColorFormat.hpp>
+ #include <ooo/vba/msforms/XFillFormat.hpp>
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ #include "vbafillformat.hxx"
+ 
+ typedef InheritedHelperInterfaceImpl1< ov::msforms::XColorFormat > ScVbaColorFormat_BASE;
+diff --git sc/source/ui/vba/vbacombobox.cxx sc/source/ui/vba/vbacombobox.cxx
+deleted file mode 100644
+index f1ea440..0000000
+--- sc/source/ui/vba/vbacombobox.cxx
++++ /dev/null
+@@ -1,175 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbacombobox.cxx,v $
+- * $Revision: 1.4 $
+- *
+- * 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 "vbacombobox.hxx"
+-#include <vector>
+-
+-using namespace com::sun::star;
+-using namespace ooo::vba;
+-
+-
+-//SelectedItems list of integer indexes
+-//StringItemList list of items
+-
+-const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
+-const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
+-const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
+-const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataFieldProperty") );
+-
+-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;
+-}
+-
+-// Attributes
+-
+-
+-// Value, [read] e.g. getValue returns the value of ooo Text propery e.g. the value in
+-// the drop down
+-uno::Any SAL_CALL 
+-ScVbaComboBox::getValue() throw (uno::RuntimeException)
+-{
+-	return m_xProps->getPropertyValue( sSourceName );
+-}
+-
+-void SAL_CALL 
+-ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
+-{
+-    uno::Sequence< sal_Int16 > sSelection(1);
+-    _value >>= sSelection[ 0 ];
+-    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( sSelection ) );
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
+-{
+-	uno::Sequence< rtl::OUString > sItems;
+-	m_xProps->getPropertyValue( ITEMS ) >>= sItems;
+-	// should really return the item that has focus regardless of
+-	// it been selected
+-	if ( sItems.getLength() > 0 )
+-	{
+-		rtl::OUString sText = getText();
+-		sal_Int32 nLen = sItems.getLength();
+-		for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index )
+-		{
+-			if ( sItems[ index ].equals( sText ) )
+-			{
+-				OSL_TRACE("getListIndex returning %d", index );
+-				return uno::makeAny( index );
+-			}
+-				
+-		} 
+- 	} 
+-	OSL_TRACE("getListIndex returning %d", -1 );
+-	return uno::makeAny( sal_Int32( -1 ) );
+-}
+-
+-// Value, [write]e.g. setValue sets the value in the drop down, and if the value is one
+-// of the values in the list then the selection is also set
+-void SAL_CALL 
+-ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
+-{
+-	m_xProps->setPropertyValue( sSourceName, _value );
+-}
+-
+-// see Value
+-
+-::rtl::OUString SAL_CALL 
+-ScVbaComboBox::getText() throw (uno::RuntimeException)
+-{
+-	rtl::OUString result;
+-	getValue() >>= result;
+-	return result;
+-}
+-
+-void SAL_CALL 
+-ScVbaComboBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
+-{
+-	setValue( uno::makeAny( _text ) ); // seems the same
+-}
+-
+-// Methods
+-void SAL_CALL 
+-ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
+-{
+-	mpListHelper->AddItem( pvargItem, 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)
+-{
+-	return mpListHelper->getListCount();
+-}
+-		
+-uno::Any SAL_CALL 
+-ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
+-{
+-	return mpListHelper->List( pvargIndex, pvarColumn );
+-	}
+-
+-rtl::OUString& 
+-ScVbaComboBox::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
+-	return sImplName;
+-}
+-
+-uno::Sequence< rtl::OUString > 
+-ScVbaComboBox::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ComboBox" ) );
+-	}
+-	return aServiceNames;
+-}
+diff --git sc/source/ui/vba/vbacombobox.hxx sc/source/ui/vba/vbacombobox.hxx
+deleted file mode 100644
+index ae7d1ae..0000000
+--- sc/source/ui/vba/vbacombobox.hxx
++++ /dev/null
+@@ -1,80 +0,0 @@
+-/*************************************************************************
+- *
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- * 
+- * Copyright 2008 by Sun Microsystems, Inc.
+- *
+- * OpenOffice.org - a multi-platform office productivity suite
+- *
+- * $RCSfile: vbacombobox.hxx,v $
+- * $Revision: 1.4 $
+- *
+- * 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 SC_VBA_COMBOBOX_HXX
+-#define SC_VBA_COMBOBOX_HXX
+-#include <cppuhelper/implbase2.hxx>
+-#include <com/sun/star/uno/XComponentContext.hpp>
+-#include <com/sun/star/beans/XPropertySet.hpp>
+-#include <com/sun/star/script/XDefaultProperty.hpp>
+-#include <ooo/vba/msforms/XComboBox.hpp>
+-#include <comphelper/proparrhlp.hxx>
+-#include <comphelper/propertycontainer.hxx>
+-#include <com/sun/star/beans/PropertyAttribute.hpp>
+-
+-#include "vbacontrol.hxx"
+-#include "vbalistcontrolhelper.hxx"
+-#include "vbahelper.hxx"
+-
+-typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE;
+-class ScVbaComboBox : public ComboBoxImpl_BASE
+-{		
+-	std::auto_ptr< ListControlHelper > mpListHelper;
+-	rtl::OUString sSourceName; 
+-	rtl::OUString msDftPropName;
+-	bool mbDialogType;
+-	
+-public:
+-	ScVbaComboBox( 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, bool bDialogType = false );
+-
+-	// Attributes
+-	virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException);
+-	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) 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 ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+-
+-	// Methods
+-	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);
+-	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
+-	// XControl
+-    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
+-
+-	// XDefaultProperty
+-        ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
+-	//XHelperInterface
+-	virtual rtl::OUString& getServiceImplName();
+-	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-
+-#endif //
+diff --git sc/source/ui/vba/vbacommandbar.cxx sc/source/ui/vba/vbacommandbar.cxx
+deleted file mode 100644
+index 24e5189..0000000
+--- sc/source/ui/vba/vbacommandbar.cxx
++++ /dev/null
+@@ -1,347 +0,0 @@
+-/*************************************************************************
+- *
+- *  OpenOffice.org - a multi-platform office productivity suite
+- *
+- *  $RCSfile$
+- *
+- *  $Revision$
+- *
+- *  last change: $Author$ $Date$
+- *
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
+- *
+- *
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+-#include <com/sun/star/frame/XFrame.hpp>
+-#include <com/sun/star/frame/XDesktop.hpp>
+-#include <com/sun/star/frame/XLayoutManager.hpp>
+-#include <com/sun/star/beans/XPropertySet.hpp>
+-#include <ooo/vba/office/MsoBarType.hpp>
+-
+-#include "vbacommandbar.hxx"
+-#include "vbacommandbarcontrols.hxx"
+-#include "vbahelper.hxx"
+-
+-
+-using namespace com::sun::star;
+-using namespace ooo::vba;
+-
+-ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw (uno::RuntimeException) : CommandBar_BASE( xParent, xContext )
+-{
+-    // it's a menu bar
+-    // only supporting factory menus ( no custom menus )
+-    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
+-    initCommandBar();
+-    switch( nModuleType )
+-    {
+-        case 0:
+-            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" );
+-            break;
+-        case 1:
+-            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
+-            break;
+-        default:
+-            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
+-    }
+-    getMenuSettings();
+-    m_bIsMenu = sal_True;
+-    m_bCustom = sal_False;
+-}
+-ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw (uno::RuntimeException) :  CommandBar_BASE( xParent, xContext )
+-{
+-    // it's a tool bar
+-    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
+-    initCommandBar();
+-    m_bTemporary = bTemporary;
+-    m_bCreate = bCreate;
+-    // get OOo ToolBarName
+-    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
+-    if( iter != mCommandBarNameMap.end() )
+-    {
+-        m_sToolBarName = iter->second;
+-    }
+-    else
+-    {
+-        m_sToolBarName = sToolBarName;
+-    }
+-    m_sUIName = m_sToolBarName;
+-    m_bIsMenu = sal_False;
+-    getToolBarSettings( m_sToolBarName );
+-}
+-void
+-ScVbaCommandBar::initCommandBar() throw (uno::RuntimeException)
+-{
+-    m_pScVbaCommandBars = dynamic_cast< ScVbaCommandBars* >( m_xParentHardRef.get() );
+-    if ( !m_pScVbaCommandBars )
+-        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBars"), uno::Reference< uno::XInterface >() );
+-    m_bIsMenu = sal_False;
+-    m_bCustom = sal_False;
+-    m_bTemporary = sal_True;
+-    m_sToolBarName = rtl::OUString::createFromAscii("");
+-    m_sUIName = rtl::OUString::createFromAscii("");
+-    m_sMenuModuleName = m_pScVbaCommandBars->GetModuleName();
+-}
+-void
+-ScVbaCommandBar::getToolBarSettings( rtl::OUString sToolBarName ) throw( uno::RuntimeException )
+-{
+-    rtl::OUString sFactoryToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/") + sToolBarName.toAsciiLowerCase();
+-    rtl::OUString sCustomToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/custom_toolbar_") + sToolBarName;
+-    uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+-    uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
+-    m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_pScVbaCommandBars->GetModuleName() ), uno::UNO_QUERY_THROW );
+-    m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
+-    if( m_xUICfgManager->hasSettings( sFactoryToolBar ) )
+-    {
+-        // exsiting standard ToolBar
+-        m_xBarSettings.set( m_xUICfgManager->getSettings( sFactoryToolBar, sal_True ), uno::UNO_QUERY_THROW );
+-        m_sToolBarName = sFactoryToolBar;
+-    }
+-    else if( m_xUICfgManager->hasSettings( sCustomToolBar ) )
+-    {
+-        // exisiting custom ToolBar
+-        m_xBarSettings.set( m_xUICfgManager->getSettings( sCustomToolBar, sal_True ), uno::UNO_QUERY_THROW );
+-        m_sToolBarName = sCustomToolBar;
+-        m_bCustom = sal_True;
+-    }
+-    else if( m_bCreate )
+-    {
+-        // new custom ToolBar
+-        m_xBarSettings.set( m_xUICfgManager->createSettings(), uno::UNO_QUERY_THROW );
+-        m_sToolBarName = sCustomToolBar;
+-        m_bCustom = sal_True;
+-        addCustomBar();
+-    }
+-    else
+-        throw uno::RuntimeException( rtl::OUString::createFromAscii("ToolBar do not exist"), uno::Reference< uno::XInterface >() );
+-    if( m_pScVbaCommandBars->GetWindows()->hasByName( m_sToolBarName ) )
+-    {
+-        uno::Any aToolBar = m_pScVbaCommandBars->GetWindows()->getByName( m_sToolBarName );
+-        aToolBar >>= m_aToolBar; 
+-    }
+-}
+-void
+-ScVbaCommandBar::addCustomBar()
+-{
+-    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    xPropertySet->setPropertyValue(rtl::OUString::createFromAscii("UIName"), uno::makeAny( m_sUIName ));
+-
+-    if( m_xUICfgManager->hasSettings(m_sToolBarName) )
+-    {
+-        m_xUICfgManager->replaceSettings( m_sToolBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    else
+-    {
+-        m_xUICfgManager->insertSettings( m_sToolBarName,  uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    if( !m_bTemporary )
+-    {
+-        m_xUICfgPers->store();
+-    }
+-}
+-void 
+-ScVbaCommandBar::getMenuSettings()
+-{
+-    try
+-    {
+-        rtl::OUString sMenuBar = rtl::OUString::createFromAscii( "private:resource/menubar/menubar" );
+-        uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+-        uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
+-        m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_sMenuModuleName ), uno::UNO_QUERY_THROW );
+-        m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
+-        m_xBarSettings.set( m_xUICfgManager->getSettings( sMenuBar, sal_True ), uno::UNO_QUERY_THROW );
+-    } 
+-    catch ( uno::Exception e)
+-    {
+-        OSL_TRACE( "getMenuSetting got a error\n" );
+-    }
+-}
+-::rtl::OUString SAL_CALL
+-ScVbaCommandBar::getName() throw ( uno::RuntimeException )
+-{
+-    // This will get a "NULL length string" when Name is not set. 
+-    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") );
+-    rtl::OUString sName;
+-    aName >>= sName;
+-    if( sName.getLength() < 1 && !m_bIsMenu )
+-    {
+-        uno::Reference< container::XNameAccess > xNameAccess( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
+-        if( xNameAccess->hasByName( m_sToolBarName ) )
+-        {
+-            beans::PropertyValues aToolBar; 
+-            xNameAccess->getByName( m_sToolBarName ) >>= aToolBar;
+-            sal_Int32 nCount = aToolBar.getLength();
+-            beans::PropertyValue aPropertyValue;
+-            for( sal_Int32 i = 0; i < nCount; i++ )
+-            {
+-                aPropertyValue = aToolBar[i];
+-                if( aPropertyValue.Name.equals( rtl::OUString::createFromAscii("UIName") ) )
+-                {
+-                    aPropertyValue.Value >>= sName;
+-                    return sName;
+-                }
+-            }
+-        }
+-    }
+-    return sName;
+-}
+-void SAL_CALL 
+-ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException)
+-{
+-    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
+-    uno::Reference< container::XIndexAccess > xIndexAccess( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    
+-    if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
+-    {
+-        m_xUICfgManager->replaceSettings( m_sToolBarName, xIndexAccess );
+-    }
+-    else
+-    {
+-        // toolbar not found
+-    }
+-    if( !m_bTemporary )
+-    {
+-        m_xUICfgPers->store();
+-    }
+-}
+-::sal_Bool SAL_CALL 
+-ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
+-{
+-    sal_Bool bVisible = sal_False;
+-    try
+-    {
+-        sal_Int32 i = 0;
+-        while( !m_aToolBar[i].Name.equals( rtl::OUString::createFromAscii( "Visible" ) ) )
+-        {
+-            i++;
+-        }
+-        m_aToolBar[i].Value >>= bVisible;
+-    }
+-    catch ( uno::Exception e )
+-    {
+-    }
+-    return bVisible;
+-}
+-void SAL_CALL 
+-ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
+-{
+-    try
+-    {
+-        uno::Reference< frame::XFrame > xFrame( getCurrentDocument()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); 
+-        uno::Reference< beans::XPropertySet > xPropertySet( xFrame, uno::UNO_QUERY_THROW );
+-        uno::Reference< frame::XLayoutManager > xLayoutManager( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LayoutManager") ), uno::UNO_QUERY_THROW );
+-        if( _visible )
+-        {
+-            xLayoutManager->createElement( m_sToolBarName );
+-            xLayoutManager->showElement( m_sToolBarName );
+-        }
+-        else
+-        {
+-            xLayoutManager->hideElement( m_sToolBarName );
+-            xLayoutManager->destroyElement( m_sToolBarName );
+-        }
+-    }
+-    catch( uno::Exception e )
+-    {
+-        OSL_TRACE( "SetVisible get an exception\n" );
+-    }
+-}
+-void SAL_CALL 
+-ScVbaCommandBar::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+-{
+-    if( m_bCustom )
+-    {
+-        if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
+-        {
+-            m_xUICfgManager->removeSettings(m_sToolBarName);
+-            // make it permanent
+-            if( !m_bTemporary )
+-            {
+-                m_xUICfgPers->store();
+-            }
+-        }
+-        else
+-        {
+-            // toolbar not found
+-            // TODO throw Error
+-        }
+-        uno::Reference< container::XNameContainer > xNameContainer( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
+-        if( xNameContainer->hasByName( m_sToolBarName ) )
+-        {
+-            xNameContainer->removeByName( m_sToolBarName );
+-        }
+-    }
+-}
+-uno::Any SAL_CALL 
+-ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+-{
+-    sal_Int32 nIndex;
+-    uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
+-    if( aIndex.hasValue() )
+-    {
+-        if( aIndex >>= nIndex )
+-        {
+-            uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+-            return uno::makeAny( xCommandBarControl );
+-        }
+-        else
+-            throw uno::RuntimeException( rtl::OUString::createFromAscii(  "invalid index" ), uno::Reference< uno::XInterface >() );
+-    }
+-    return uno::makeAny( xCommandBarControls );
+-}
+-
+-sal_Int32 SAL_CALL
+-ScVbaCommandBar::Type() throw (script::BasicErrorException, uno::RuntimeException)
+-{
+-    // #FIXME support msoBarTypePopup
+-    sal_Int32 nType = office::MsoBarType::msoBarTypePopup;
+-    nType = m_bIsMenu? office::MsoBarType::msoBarTypeNormal : office::MsoBarType::msoBarTypeMenuBar;
+-    return nType;
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaCommandBar::FindControl( const uno::Any& /*aType*/, const uno::Any& /*aId*/, const uno::Any& /*aTag*/, const uno::Any& /*aVisible*/, const uno::Any& /*aRecursive*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+-{
+-    // alwayse fail to find control
+-    return uno::makeAny( uno::Reference< XCommandBarControl > () );
+-}
+-
+-rtl::OUString& 
+-ScVbaCommandBar::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBar") );
+-	return sImplName;
+-}
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBar::getServiceNames()
 -{
 -	static uno::Sequence< rtl::OUString > aServiceNames;
 -	if ( aServiceNames.getLength() == 0 )
 -	{
 -		aServiceNames.realloc( 1 );
--		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Button" ) );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBar" ) );
 -	}
 -	return aServiceNames;
 -}
-diff --git sc/source/ui/vba/vbabutton.hxx sc/source/ui/vba/vbabutton.hxx
+diff --git sc/source/ui/vba/vbacommandbar.hxx sc/source/ui/vba/vbacommandbar.hxx
 deleted file mode 100644
-index 2a98ad6..0000000
---- sc/source/ui/vba/vbabutton.hxx
+index bbeda7c..0000000
+--- sc/source/ui/vba/vbacommandbar.hxx
 +++ /dev/null
-@@ -1,51 +0,0 @@
+@@ -1,107 +0,0 @@
 -/*************************************************************************
 - *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
+- *  OpenOffice.org - a multi-platform office productivity suite
 - *
-- * OpenOffice.org - a multi-platform office productivity suite
+- *  $RCSfile$
 - *
-- * $RCSfile: vbabutton.hxx,v $
-- * $Revision: 1.3 $
+- *  $Revision$
 - *
-- * This file is part of OpenOffice.org.
+- *  last change: $Author$ $Date$
 - *
-- * 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.
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
 - *
-- * 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.
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
 - *
-- ************************************************************************/
--#ifndef SC_VBA_BUTTON_HXX
--#define SC_VBA_BUTTON_HXX
--#include <cppuhelper/implbase1.hxx>
--#include <ooo/vba/msforms/XButton.hpp>
--
--#include "vbacontrol.hxx"
--#include "vbahelper.hxx"
--
--typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
--
--class ScVbaButton : public ButtonImpl_BASE
--{
--public:
--    ScVbaButton( 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 rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
--    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
--    //XHelperInterface
--    virtual rtl::OUString& getServiceImplName();
--    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
--};
--#endif //SC_VBA_BUTTON_HXX
-diff --git sc/source/ui/vba/vbacharacters.hxx sc/source/ui/vba/vbacharacters.hxx
-index 1ea523f..f69b6d2 100644
---- sc/source/ui/vba/vbacharacters.hxx
-+++ sc/source/ui/vba/vbacharacters.hxx
-@@ -36,7 +36,7 @@
- #include <com/sun/star/uno/XComponentContext.hpp>
- #include <com/sun/star/text/XSimpleText.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include "vbapalette.hxx"
- typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaCharacters_BASE;
- 
-diff --git sc/source/ui/vba/vbachart.hxx sc/source/ui/vba/vbachart.hxx
-index cd20e06..b7fab46 100644
---- sc/source/ui/vba/vbachart.hxx
-+++ sc/source/ui/vba/vbachart.hxx
-@@ -41,7 +41,7 @@
- #include <ooo/vba/excel/XChart.hpp>
- #include <ooo/vba/excel/XDataLabels.hpp>
- #include <ooo/vba/excel/XSeries.hpp>
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- 
- typedef InheritedHelperInterfaceImpl1<ov::excel::XChart > ChartImpl_BASE;
- 
-diff --git sc/source/ui/vba/vbachartobject.hxx sc/source/ui/vba/vbachartobject.hxx
-index e36f157..45b5c17 100644
---- sc/source/ui/vba/vbachartobject.hxx
-+++ sc/source/ui/vba/vbachartobject.hxx
-@@ -36,7 +36,7 @@
- #include <com/sun/star/container/XNamed.hpp>
- #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
- #include <ooo/vba/excel/XChartObject.hpp>
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#ifndef SC_VBA_COMMANDBAR_HXX
+-#define SC_VBA_COMMANDBAR_HXX
+-
+-#include <ooo/vba/XCommandBar.hpp>
+-#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+-#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
+-#include <com/sun/star/container/XIndexContainer.hpp>
+-#include <com/sun/star/beans/PropertyValues.hpp>
+-
 -#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include <memory>
- 
- typedef InheritedHelperInterfaceImpl1<ov::excel::XChartObject > ChartObjectImpl_BASE;
-diff --git sc/source/ui/vba/vbachartobjects.hxx sc/source/ui/vba/vbachartobjects.hxx
-index 3b18f51..bc87157 100644
---- sc/source/ui/vba/vbachartobjects.hxx
-+++ sc/source/ui/vba/vbachartobjects.hxx
-@@ -36,8 +36,8 @@
- #include <com/sun/star/table/XTableCharts.hpp>
- #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
- #include <com/sun/star/container/XEnumerationAccess.hpp>
--#include"vbacollectionimpl.hxx"
--#include "vbahelper.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
-+#include "excelvbahelper.hxx"
- #include <hash_map>
- 
- typedef CollTestImplHelper< ov::excel::XChartObjects > ChartObjects_BASE;
-diff --git sc/source/ui/vba/vbacharts.hxx sc/source/ui/vba/vbacharts.hxx
-index d9d0f8e..cedfeaa 100644
---- sc/source/ui/vba/vbacharts.hxx
-+++ sc/source/ui/vba/vbacharts.hxx
-@@ -31,8 +31,8 @@
- #define SC_VBA_CHARTS_HXX
- #include <ooo/vba/excel/XCharts.hpp>
- #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
--#include"vbacollectionimpl.hxx"
--#include "vbahelper.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
-+#include "excelvbahelper.hxx"
- #include <hash_map>
- 
- typedef CollTestImplHelper< ov::excel::XCharts > Charts_BASE;
-diff --git sc/source/ui/vba/vbacheckbox.cxx sc/source/ui/vba/vbacheckbox.cxx
+-#include "vbacommandbars.hxx"
+-
+-#include <map>
+-typedef std::map< const rtl::OUString, rtl::OUString > CommandBarNameMap;
+-typedef std::pair< const rtl::OUString, rtl::OUString > CommandBarNamePair;
+-const CommandBarNamePair namePair[] = { 
+-    CommandBarNamePair(  rtl::OUString::createFromAscii("standard"), rtl::OUString::createFromAscii("standardbar") ),
+-    CommandBarNamePair(  rtl::OUString::createFromAscii("formatting"), rtl::OUString::createFromAscii("formatobjectbar") ),
+-};
+-static const CommandBarNameMap mCommandBarNameMap( namePair, ( namePair + sizeof(namePair) / sizeof(namePair[0]) ) );
+-
+-
+-typedef InheritedHelperInterfaceImpl1< ov::XCommandBar > CommandBar_BASE;
+-
+-class ScVbaCommandBar : public CommandBar_BASE
+-{
+-private:
+-    rtl::OUString       m_sToolBarName;
+-    rtl::OUString       m_sMenuModuleName;
+-    rtl::OUString       m_sUIName;
+-    sal_Bool            m_bTemporary;
+-    sal_Bool            m_bIsMenu;
+-    sal_Bool            m_bCustom;
+-    sal_Bool            m_bCreate;
+-    ScVbaCommandBars*   m_pScVbaCommandBars;
+-    css::beans::PropertyValues  m_aToolBar;
+-    // hard reference for parent
+-    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
+-    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
+-    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
+-    void initCommandBar() throw( css::uno::RuntimeException );
+-protected:
+-    void getToolBarSettings( rtl::OUString sToolBarName ) throw( css::uno::RuntimeException );
+-    void getMenuSettings();
+-    void addCustomBar();
+-public:
+-    ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw( css::uno::RuntimeException );
+-    ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw( css::uno::RuntimeException );
+-    
+-    sal_Bool IsMenu() { return m_bIsMenu; };
+-    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
+-    css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
+-    rtl::OUString GetToolBarName() { return m_sToolBarName; };
+-
+-    // Attributes
+-    virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setName( const ::rtl::OUString& _name ) throw (css::uno::RuntimeException);
+-    virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
+-
+-    // Methods
+-    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    virtual sal_Int32 SAL_CALL Type(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    virtual css::uno::Any SAL_CALL FindControl( const css::uno::Any& aType, const css::uno::Any& aId, const css::uno::Any& aTag, const css::uno::Any& aVisible, const css::uno::Any& aRecursive ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-
+-	// XHelperInterface
+-	virtual rtl::OUString& getServiceImplName();
+-	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-#endif//SC_VBA_COMMANDBAR_HXX
+diff --git sc/source/ui/vba/vbacommandbarcontrol.cxx sc/source/ui/vba/vbacommandbarcontrol.cxx
 deleted file mode 100644
-index 958e375..0000000
---- sc/source/ui/vba/vbacheckbox.cxx
+index 8a39074..0000000
+--- sc/source/ui/vba/vbacommandbarcontrol.cxx
 +++ /dev/null
-@@ -1,110 +0,0 @@
+@@ -1,443 +0,0 @@
 -/*************************************************************************
 - *
 - *  OpenOffice.org - a multi-platform office productivity suite
@@ -1713,88 +5373,421 @@
 - *    MA  02111-1307  USA
 - *
 - ************************************************************************/
--#include "vbacheckbox.hxx"
--#include <vector>
+-#include "vbacommandbarcontrol.hxx"
+-#include <basic/sbstar.hxx>
+-#include <basic/sbmod.hxx>
 -
 -using namespace com::sun::star;
 -using namespace ooo::vba;
 -
+-uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName )
+-{
+-    sal_Int32 nCount = aPropertyValues.getLength();
+-    for( sal_Int32 i = 0; i < nCount; i++ )
+-    {
+-        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
+-        {
+-            return aPropertyValues[i].Value;
+-        }
+-    }
+-    return uno::Any();
+-}
 -
--const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
--const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
--ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+-beans::PropertyValues lcl_repalcePropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName, uno::Any aValue )
 -{
+-    sal_Int32 nCount = aPropertyValues.getLength();
+-    for( sal_Int32 i = 0; i < nCount; i++ )
+-    {
+-        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
+-        {
+-            aPropertyValues[i].Value = aValue;
+-            return aPropertyValues;
+-        }
+-    }
+-    return aPropertyValues;
 -}
 -
--// Attributes
--rtl::OUString SAL_CALL 
--ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
+-ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Int32 nType ) throw (uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), m_sName( sName ), m_nPosition( nPosition ), m_nType( nType )
 -{
--    rtl::OUString Label;
--    m_xProps->getPropertyValue( LABEL ) >>= Label;
--    return Label;
+-    // exsiting CommandBarBarControl
+-    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
+-    initObjects();
+-    if( m_xBarSettings->hasElements() )
+-    {
+-        ScVbaCommandBarControl* pParentCommandBarControl = m_pCommandBarControls->GetParentCommandBarControl();
+-        if( pParentCommandBarControl )
+-        {
+-            beans::PropertyValues aPropertyValues;
+-            pParentCommandBarControl->GetCurrentSettings()->getByIndex( pParentCommandBarControl->GetPosition() ) >>= aPropertyValues;
+-            pParentCommandBarControl->SetPropertyValues( aPropertyValues );
+-            m_xCurrentSettings.set( lcl_getPropertyValue( pParentCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY_THROW );
+-        }
+-        if( !m_xCurrentSettings.is() )
+-        {
+-            m_xCurrentSettings.set( m_xUICfgManager->getSettings( m_pCommandBarControls->GetParentToolBarName(), sal_True ), uno::UNO_QUERY_THROW );
+-        }
+-    }
+-    if( m_bIsMenu )
+-    {
+-        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
+-    }
+-    else
+-    {
+-        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
+-    }
+-    m_bTemporary = sal_True;
+-}
+-ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType) throw (uno::RuntimeException) :  CommandBarControl_BASE( xParent, xContext ), m_nPosition( nPosition ), m_bTemporary( bTemporary ), m_nType( nType )
+-{
+-    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
+-    initObjects();
+-    if( sName.getLength() > 0 )
+-    {
+-        m_sName = sName;
+-    }
+-    m_sCommand = rtl::OUString::createFromAscii("vnd.openoffice.org:") + sName;
+-    if( m_bIsMenu )
+-    {
+-        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
+-        createNewMenuBarControl();
+-    }
+-    else
+-    {
+-        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
+-        createNewToolBarControl();
+-    }
 -}
 -
--void SAL_CALL 
--ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+-void
+-ScVbaCommandBarControl::initObjects() throw (uno::RuntimeException)
 -{
--    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
+-    m_pCommandBarControls = dynamic_cast< ScVbaCommandBarControls* >( m_xParentHardRef.get() );
+-    if( !m_pCommandBarControls )
+-        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBarControls"), uno::Reference< uno::XInterface >() );
+-    m_xUICfgManager.set( m_pCommandBarControls->GetUICfgManager(), uno::UNO_QUERY_THROW );
+-    m_xUICfgPers.set( m_pCommandBarControls->GetUICfgPers(), uno::UNO_QUERY_THROW );
+-    m_xBarSettings.set( m_pCommandBarControls->GetBarSettings(), uno::UNO_QUERY_THROW );
+-    m_bIsMenu = m_pCommandBarControls->IsMenu();
+-    m_sName = rtl::OUString::createFromAscii( "Custom" );
 -}
 -
--uno::Any SAL_CALL 
--ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
+-void
+-ScVbaCommandBarControl::createNewMenuBarControl()
 -{
--    sal_Int16 nValue = -1;
--    m_xProps->getPropertyValue( STATE ) >>= nValue;
--    if( nValue != 0 )
--        nValue = -1;
--//    return uno::makeAny( nValue ); 
--// I must be missing something MSO says value should be -1 if selected, 0 if not
--// selected
--    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
+-    uno::Reference< lang::XSingleComponentFactory > xMenuMSF( m_xBarSettings, uno::UNO_QUERY_THROW );
+-
+-    uno::Sequence< beans::PropertyValue > aPropertys;
+-    if( m_nType == office::MsoControlType::msoControlPopup )
+-        aPropertys = uno::Sequence< beans::PropertyValue >( 4 );
+-    else
+-        aPropertys = uno::Sequence< beans::PropertyValue >( 3 );
+-
+-    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
+-    aPropertys[0].Value <<= m_sCommand; 
+-    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
+-    aPropertys[1].Value <<= m_sName; 
+-    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
+-    aPropertys[2].Value <<= sal_Int32(0); 
+-
+-    if( m_nType == office::MsoControlType::msoControlPopup )
+-    {
+-        aPropertys[3].Name = rtl::OUString::createFromAscii("ItemDescriptorContainer");
+-        aPropertys[3].Value <<= xMenuMSF->createInstanceWithContext( mxContext );
+-    }    
+-
+-    if( m_pCommandBarControls->GetParentCommandBar() != NULL )
+-    {
+-        // create a new menu
+-        m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
+-        m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    }
+-    else if( m_pCommandBarControls->GetParentCommandBarControl() != NULL )
+-    {
+-        // create a new menu entry
+-        ScVbaCommandBarControl* pPc = m_pCommandBarControls->GetParentCommandBarControl();
+-        beans::PropertyValues aPropertyValues;
+-        pPc->GetCurrentSettings()->getByIndex( pPc->GetPosition() ) >>= aPropertyValues;
+-        pPc->SetPropertyValues( aPropertyValues );
+-        
+-        // has the property already been set?
+-        if( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ).hasValue() )
+-        {
+-            lcl_repalcePropertyValue(  pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer"), uno::makeAny( xMenuMSF->createInstanceWithContext( mxContext ) ) );
+-            pPc->GetCurrentSettings()->replaceByIndex( pPc->GetPosition(), uno::makeAny( pPc->GetPropertyValues() ) );
+-        }
+-        m_xCurrentSettings.set( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY_THROW );
+-        m_xCurrentSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
+-    }
+-    if( m_xUICfgManager->hasSettings( m_sBarName ) )
+-    {
+-        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    else
+-    {
+-        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    if( !m_bTemporary )
+-    {
+-        m_xUICfgPers->store();
+-    }
+-}
+-
+-void
+-ScVbaCommandBarControl::createNewToolBarControl()
+-{
+-    uno::Sequence< beans::PropertyValue > aPropertys(4);
+-    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
+-    aPropertys[0].Value <<= m_sCommand; 
+-    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
+-    aPropertys[1].Value <<= m_sName; 
+-    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
+-    aPropertys[2].Value <<= sal_Int32(0); 
+-    aPropertys[3].Name = rtl::OUString::createFromAscii("IsVisible");
+-    aPropertys[3].Value <<= sal_True; 
+-
+-    m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
+-    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    rtl::OUString sUIName;
+-    xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") ) >>= sUIName;
+-
+-    m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
+-    if( m_xUICfgManager->hasSettings( m_sBarName ) )
+-    {
+-        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    else
+-    {
+-        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-    }
+-    if( !m_bTemporary )
+-    {
+-        m_xUICfgPers->store();
+-    }
 -}
 -
+-::rtl::OUString SAL_CALL
+-ScVbaCommandBarControl::getCaption() throw ( uno::RuntimeException )
+-{
+-    // "Label" always empty
+-    rtl::OUString sCaption;
+-    beans::PropertyValues aPropertyValues;
+-    if( m_xCurrentSettings.is() )
+-    {
+-        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
+-        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
+-    }
+-    else if( m_xBarSettings.is() )
+-    {
+-        m_xBarSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
+-        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
+-    }
+-    return sCaption;
+-}
 -void SAL_CALL 
--ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
+-ScVbaCommandBarControl::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
 -{
--    sal_Int16 nValue = 0;
--    sal_Bool bValue = false;
--    if( _value >>= nValue )
+-    if( m_xCurrentSettings.is() )
 -    {
--        if( nValue == -1)
--            nValue = 1;
+-        beans::PropertyValues aPropertyValues;
+-        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
+-        beans::PropertyValues aNewPropertyValues;
+-        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label"), uno::makeAny( _caption ) );
+-        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
+-        if( m_xUICfgManager->hasSettings( m_sBarName ) )
+-        {
+-            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        else
+-        {
+-            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        // make it permanent
+-        if( !m_bTemporary )
+-        {
+-            m_xUICfgPers->store();
+-        }
 -    }
--    else if ( _value >>= bValue )
+-}
+-::rtl::OUString SAL_CALL 
+-ScVbaCommandBarControl::getOnAction() throw (uno::RuntimeException)
+-{
+-    if( m_xCurrentSettings.is() )
 -    {
--        if ( bValue )
--            nValue = 1;
+-        beans::PropertyValues aPropertyValues;
+-        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
+-        rtl::OUString sCommandURL;
+-        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
+-        return sCommandURL;
 -    }
--    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
+-    return ::rtl::OUString();
+-}
+-void SAL_CALL 
+-ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
+-{
+-    if( m_xCurrentSettings.is() )
+-    {
+-        // convert the comand url into something like vnd.sun.star.script:Standard.testMacro.Macro1?language=Basic&location=document
+-        rtl::OUString aCommandURL;
+-        rtl::OUString sUrlPart = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
+-        SbModule* pModule = StarBASIC::GetActiveModule();
+-        if( pModule && ( _onaction.indexOf( sUrlPart ) == -1 ) )
+-        {
+-            rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "?language=Basic&location=document");
+-            aCommandURL = sUrlPart.concat( pModule->GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( _onaction ).concat( sUrlPart1 );
+-        }
+-        else
+-        {
+-            aCommandURL = _onaction;
+-        }
+-		OSL_TRACE(" ScVbaCommandBarControl::setOnAction: %s", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+-
+-        beans::PropertyValues aPropertyValues;
+-        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
+-        beans::PropertyValues aNewPropertyValues;
+-        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURL ) );
+-        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
+-        if( m_xUICfgManager->hasSettings( m_sBarName ) )
+-        {
+-            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        else
+-        {
+-            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        // make it permanent
+-        if( !m_bTemporary )
+-        {
+-            m_xUICfgPers->store();
+-        }
+-    }
+-}
+-::sal_Bool SAL_CALL 
+-ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
+-{
+-    // not possible in UNO?
+-    return sal_True;
+-}
+-void SAL_CALL 
+-ScVbaCommandBarControl::setVisible( ::sal_Bool /*_visible*/ ) throw (uno::RuntimeException)
+-{
+-    // "IsVisilbe"
+-}
+-void SAL_CALL 
+-ScVbaCommandBarControl::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+-{
+-    if( m_xCurrentSettings.is() )
+-    {
+-        m_xCurrentSettings->removeByIndex( m_nPosition );
+-
+-        if( m_xUICfgManager->hasSettings( m_sBarName ) )
+-        {
+-            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        else
+-        {
+-            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+-        }
+-        // make it permanent
+-        if( !m_bTemporary )
+-        {
+-            m_xUICfgPers->store();
+-        }
+-    }
+-}
+-uno::Any SAL_CALL 
+-ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+-{
+-    sal_Int32 nIndex;
+-    uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
+-    if( aIndex.hasValue() )
+-    {
+-        if( aIndex >>= nIndex )
+-        {
+-            uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+-            return uno::makeAny( xCommandBarControl );
+-        }
+-        else
+-            throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid index" ), uno::Reference< uno::XInterface >() );
+-    }
+-    return uno::makeAny( xCommandBarControls );
+-}
+-rtl::OUString& 
+-ScVbaCommandBarControl::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControl") );
+-	return sImplName;
+-}
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBarControl::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControl" ) );
+-	}
+-	return aServiceNames;
+-}
+-
+-//////////// ScVbaCommandBarPopup //////////////////////////////
+-ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlPopup )
+-{
+-}
+-
+-ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlPopup) 
+-{
+-}
+-
+-rtl::OUString& 
+-ScVbaCommandBarPopup::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarPopup") );
+-	return sImplName;
+-}
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBarPopup::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarPopup" ) );
+-	}
+-	return aServiceNames;
+-}
+-
+-//////////// ScVbaCommandBarButton //////////////////////////////
+-ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlButton )
+-{
 -}
+-
+-ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlButton) 
+-{
+-}
+-
 -rtl::OUString& 
--ScVbaCheckbox::getServiceImplName()
+-ScVbaCommandBarButton::getServiceImplName()
 -{
--	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarButton") );
 -	return sImplName;
 -}
--
--uno::Sequence< rtl::OUString > 
--ScVbaCheckbox::getServiceNames()
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBarButton::getServiceNames()
 -{
 -	static uno::Sequence< rtl::OUString > aServiceNames;
 -	if ( aServiceNames.getLength() == 0 )
 -	{
 -		aServiceNames.realloc( 1 );
--		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarButton" ) );
 -	}
 -	return aServiceNames;
 -}
-diff --git sc/source/ui/vba/vbacheckbox.hxx sc/source/ui/vba/vbacheckbox.hxx
+diff --git sc/source/ui/vba/vbacommandbarcontrol.hxx sc/source/ui/vba/vbacommandbarcontrol.hxx
 deleted file mode 100644
-index 58805c6..0000000
---- sc/source/ui/vba/vbacheckbox.hxx
+index 1c406a5..0000000
+--- sc/source/ui/vba/vbacommandbarcontrol.hxx
 +++ /dev/null
-@@ -1,60 +0,0 @@
+@@ -1,120 +0,0 @@
 -/*************************************************************************
 - *
 - *  OpenOffice.org - a multi-platform office productivity suite
@@ -1829,801 +5822,896 @@
 - *    MA  02111-1307  USA
 - *
 - ************************************************************************/
--#ifndef SC_VBA_CHECKBOX_HXX
--#define SC_VBA_CHECKBOX_HXX
--#include <cppuhelper/implbase2.hxx>
--#include <ooo/vba/msforms/XRadioButton.hpp>
--
--#include "vbacontrol.hxx"
--#include "vbahelper.hxx"
--
--typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
--
--class ScVbaCheckbox : public CheckBoxImpl_BASE
--{
--public:
--    ScVbaCheckbox(  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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
--    virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
--    // XDefaultProperty
--    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
--    //XHelperInterface
--    virtual rtl::OUString& getServiceImplName();
--    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
--};
--#endif //SC_VBA_CHECKBOX_HXX
-diff --git sc/source/ui/vba/vbacollectionimpl.cxx sc/source/ui/vba/vbacollectionimpl.cxx
-deleted file mode 100644
-index 5a9ae13..0000000
---- sc/source/ui/vba/vbacollectionimpl.cxx
-+++ /dev/null
-@@ -1,136 +0,0 @@
--/*************************************************************************
-- *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
-- *
-- * OpenOffice.org - a multi-platform office productivity suite
-- *
-- * $RCSfile: vbacollectionimpl.cxx,v $
-- * $Revision: 1.3 $
-- *
-- * 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 <vbacollectionimpl.hxx>
--#include "vbaglobals.hxx"
--using namespace ::com::sun::star;
--using namespace ::ooo::vba;
--
--
--ScVbaCollectionBaseImpl::ScVbaCollectionBaseImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ) throw (uno::RuntimeException) : m_xContext( xContext ), m_xIndexAccess( xIndexAccess )
--{
--	m_xNameAccess.set( xIndexAccess, uno::UNO_QUERY );
--}
--
--uno::Any
--ScVbaCollectionBaseImpl::getItemByStringIndex( const rtl::OUString& sIndex ) throw (::uno::RuntimeException)
--{
--	if ( !m_xNameAccess.is() )
--		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBaseImpl string index access not supported by this object") ), uno::Reference< uno::XInterface >() );
--
--	return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
--}
+-#ifndef SC_VBA_COMMANDBARCONTROL_HXX
+-#define SC_VBA_COMMANDBARCONTROL_HXX
 -
--uno::Any 
--ScVbaCollectionBaseImpl::getItemByIntIndex( const sal_Int32 nIndex ) throw (uno::RuntimeException)
--{
--	if ( !m_xIndexAccess.is() )
--		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBaseImpl numeric index access not supported by this object") ), uno::Reference< uno::XInterface >() );
--	if ( nIndex <= 0 )
--	{
--		throw  lang::IndexOutOfBoundsException( 
--			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
--			"index is 0 or negative" ) ), 
--			uno::Reference< uno::XInterface >() );
--	}
--	// need to adjust for vba index ( for which first element is 1 )
--	return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );	
--}
--
--::sal_Int32 SAL_CALL 
--ScVbaCollectionBaseImpl::getCount() throw (uno::RuntimeException)
--{
--	return m_xIndexAccess->getCount();
--}
+-#include <ooo/vba/XCommandBarControl.hpp>
+-#include <ooo/vba/XCommandBarPopup.hpp>
+-#include <ooo/vba/XCommandBarButton.hpp>
+-#include <ooo/vba/office/MsoControlType.hpp>
 -
--uno::Any SAL_CALL 
--ScVbaCollectionBaseImpl::getParent() throw (uno::RuntimeException)
--{
--	// #TODO #FIXME investigate whether this makes sense
--	uno::Reference< excel::XApplication > xApplication =
--		ScVbaGlobals::getGlobalsImpl( m_xContext )->getApplication();
--	uno::Reference< excel::XWorkbook > xWorkbook;
--	if ( xApplication.is() )
--	{
--		xWorkbook = xApplication->getActiveWorkbook();
--	}
--	return uno::Any( xWorkbook );
--}
+-#include "vbahelperinterface.hxx"
+-#include "vbacommandbarcontrols.hxx"
 -
--::sal_Int32 SAL_CALL ScVbaCollectionBaseImpl::getCreator() throw (uno::RuntimeException)
--{
--	// #TODO #FIXE some sort of implementation
--	//SC_VBA_STUB();
--	return 0;
--}
--uno::Reference< excel::XApplication > SAL_CALL ScVbaCollectionBaseImpl::getApplication() throw (uno::RuntimeException)
--{
--	// #TODO #FIXME investigate whether this makes sense
--	uno::Reference< excel::XApplication > xApplication =
--		ScVbaGlobals::getGlobalsImpl( m_xContext )->getApplication();
--	return  xApplication;
--}
+-typedef InheritedHelperInterfaceImpl1< ov::XCommandBarControl > CommandBarControl_BASE;
 -
--uno::Any SAL_CALL ScVbaCollectionBaseImpl::Item( const uno::Any& aIndex ) throw (uno::RuntimeException)
+-class ScVbaCommandBarControl : public CommandBarControl_BASE
 -{
--	if ( aIndex.getValueTypeClass() != uno::TypeClass_STRING )
--	{
--		sal_Int32 nIndex = 0;
--
--		if ( ( aIndex >>= nIndex ) != sal_True )
--		{
--			rtl::OUString message;
--			message = rtl::OUString::createFromAscii(
--				"Couldn't convert index to Int32");
--			throw  lang::IndexOutOfBoundsException( message,
--				uno::Reference< uno::XInterface >() );
--		}
--		return 	getItemByIntIndex( nIndex );
--	}
--	rtl::OUString aStringSheet;
+-private:
+-    rtl::OUString       m_sName;
+-    rtl::OUString       m_sBarName;
+-    rtl::OUString       m_sCommand;
+-    sal_Int32           m_nType;
+-    sal_Int32           m_nPosition;
+-    sal_Bool            m_bTemporary;
+-    sal_Bool            m_bIsMenu;
+-    ScVbaCommandBarControls*        m_pCommandBarControls;
+-    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
+-    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
+-    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
+-    css::uno::Reference< css::container::XIndexContainer >          m_xCurrentSettings;
+-    css::beans::PropertyValues                                      m_aPropertyValues;
+-    
+-    void initObjects() throw (css::uno::RuntimeException);
+-    void createNewMenuBarControl();
+-    void createNewToolBarControl();
+-public:
+-    ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
+-    ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
+-    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
+-    css::uno::Reference< css::container::XIndexContainer >  GetBarSettings() { return m_xBarSettings; };
+-    sal_Bool IsMenu() { return m_bIsMenu; };
+-    sal_Int32 GetPosition() { return m_nPosition; };
+-    css::uno::Reference< css::container::XIndexContainer > GetCurrentSettings() { return m_xCurrentSettings; };
+-    css::beans::PropertyValues GetPropertyValues() { return m_aPropertyValues; };
+-    void SetPropertyValues( css::beans::PropertyValues aPropertyValues ) { m_aPropertyValues = aPropertyValues; };
+-    
+-    // 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 ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
+-    virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
+-
+-    // Methods
+-    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
 -
--	aIndex >>= aStringSheet;
--	return getItemByStringIndex( aStringSheet );	
--}
+-	// XHelperInterface
+-	virtual rtl::OUString& getServiceImplName();
+-	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
 -
--::rtl::OUString SAL_CALL 
--ScVbaCollectionBaseImpl::getDefaultMethodName(  ) throw (css::uno::RuntimeException)
+-typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPopup > CommandBarPopup_BASE;
+-class ScVbaCommandBarPopup : public CommandBarPopup_BASE
 -{
--	const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
--	return sName;
--}
--
--	// XElementAccess
+-public:
+-    ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
+-    ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
+-	// XHelperInterface
+-	virtual rtl::OUString& getServiceImplName();
+-	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
 -
--::sal_Bool SAL_CALL ScVbaCollectionBaseImpl::hasElements() throw (uno::RuntimeException)
+-typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarButton > CommandBarButton_BASE;
+-class ScVbaCommandBarButton : public CommandBarButton_BASE
 -{
--	return ( m_xIndexAccess->getCount() > 0 );
--}
--
+-public:
+-    ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
+-    ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
+-	// XHelperInterface
+-	virtual rtl::OUString& getServiceImplName();
+-	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
 -
-diff --git sc/source/ui/vba/vbacollectionimpl.hxx sc/source/ui/vba/vbacollectionimpl.hxx
+-#endif//SC_VBA_COMMANDBARCONTROL_HXX
+diff --git sc/source/ui/vba/vbacommandbarcontrols.cxx sc/source/ui/vba/vbacommandbarcontrols.cxx
 deleted file mode 100644
-index 80371a3..0000000
---- sc/source/ui/vba/vbacollectionimpl.hxx
+index 2b79cff..0000000
+--- sc/source/ui/vba/vbacommandbarcontrols.cxx
 +++ /dev/null
-@@ -1,259 +0,0 @@
+@@ -1,349 +0,0 @@
 -/*************************************************************************
 - *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
+- *  OpenOffice.org - a multi-platform office productivity suite
 - *
-- * OpenOffice.org - a multi-platform office productivity suite
+- *  $RCSfile$
 - *
-- * $RCSfile: vbacollectionimpl.hxx,v $
-- * $Revision: 1.5 $
+- *  $Revision$
 - *
-- * This file is part of OpenOffice.org.
+- *  last change: $Author$ $Date$
 - *
-- * 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.
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
 - *
-- * 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.
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
 - *
-- ************************************************************************/
--#ifndef SC_VBA_COLLECTION_IMPL_HXX
--#define SC_VBA_COLLECTION_IMPL_HXX
--
--#include <ooo/vba/XCollection.hpp>
--//#include <ooo/vba/XCollectionTest.hpp>
--#include <com/sun/star/container/XEnumerationAccess.hpp>
--#include <com/sun/star/uno/XComponentContext.hpp>
--#include <com/sun/star/script/XDefaultMethod.hpp>
--#include <com/sun/star/container/XIndexAccess.hpp>
--#include <com/sun/star/container/XNameAccess.hpp>
--#include <com/sun/star/container/XNamed.hpp>
--
--#include <cppuhelper/implbase3.hxx>
--#include <cppuhelper/implbase2.hxx>
--#include <cppuhelper/implbase1.hxx>
--
--#include "vbahelper.hxx"
--#include "vbahelperinterface.hxx"
--#include "vbaglobals.hxx"
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#include "vbacommandbarcontrols.hxx"
+-#include "vbacommandbarcontrol.hxx"
 -
--#include <vector>
+-using namespace com::sun::star;
+-using namespace ooo::vba;
 -
--typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE;
+-uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName );
 -
--class EnumerationHelperImpl : public EnumerationHelper_BASE
+-typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarControlEnumeration_BASE;
+-class CommandBarControlEnumeration : public CommandBarControlEnumeration_BASE
 -{
--protected:
--	css::uno::Reference< css::uno::XComponentContext > m_xContext;
--	css::uno::Reference< css::container::XEnumeration > m_xEnumeration;
+-    //uno::Reference< uno::XComponentContext > m_xContext;
+-    ScVbaCommandBarControls* m_pCommandBarControls;
+-    sal_Int32 m_nCurrentPosition;
 -public:
--
--	EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ),  m_xEnumeration( xEnumeration ) { }
--	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); }
+-    CommandBarControlEnumeration( ScVbaCommandBarControls* pCommandBarControls ) : m_pCommandBarControls( pCommandBarControls ), m_nCurrentPosition( 0 ) {}
+-    virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+-    {
+-        if( m_nCurrentPosition < m_pCommandBarControls->getCount() )
+-            return sal_True;
+-        return sal_False;
+-    }
+-    virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+-    {
+-        if( hasMoreElements() )
+-        {
+-            rtl::OUString sName = m_pCommandBarControls->GetControlNameByIndex( m_nCurrentPosition );
+-            m_nCurrentPosition = m_nCurrentPosition + 1;
+-            if( sName.getLength() > 0 )
+-                return m_pCommandBarControls->createCollectionObject( uno::makeAny( sName ) );
+-            else
+-                return nextElement();
+-        }
+-        else
+-            throw container::NoSuchElementException();
+-        return uno::Any();
+-    }
 -};
 -
--// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces 
--// only requirement is the object needs to implement XName
--
--
--
--typedef ::cppu::WeakImplHelper3< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess > XNamedCollectionHelper_BASE;
--
--template< typename Ifc1 >
--class XNamedObjectCollectionHelper : public XNamedCollectionHelper_BASE
+-ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess> xIndexAccess ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess )
 -{
--public:
--typedef std::vector< css::uno::Reference< Ifc1 > >  XNamedVec;
--private:
+-    m_bIsMenu = sal_False;
+-    m_bHasElements = sal_False;
+-    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
+-    m_pCommandBar = dynamic_cast< ScVbaCommandBar* >( m_xParentHardRef.get() );
+-    m_pCommandBarControl = dynamic_cast< ScVbaCommandBarControl* >( m_xParentHardRef.get() );
+-    if( m_pCommandBar )
+-    {
+-        m_xUICfgManager.set( m_pCommandBar->GetUICfgManager(), uno::UNO_QUERY_THROW );
+-        m_xUICfgPers.set( m_pCommandBar->GetUICfgPers(), uno::UNO_QUERY_THROW );
+-        m_xBarSettings.set( m_pCommandBar->GetBarSettings(), uno::UNO_QUERY_THROW );
+-        m_bIsMenu = m_pCommandBar->IsMenu();
+-        if( m_xBarSettings->hasElements() )
+-        {
+-            m_bHasElements = sal_True;
+-        }
+-    }
+-    else if( m_pCommandBarControl )
+-    {
+-        m_xUICfgManager.set( m_pCommandBarControl->GetUICfgManager(), uno::UNO_QUERY_THROW );
+-        m_xUICfgPers.set( m_pCommandBarControl->GetUICfgPers(), uno::UNO_QUERY_THROW );
+-        beans::PropertyValues aPropertyValues;
+-        m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
+-        m_pCommandBarControl->SetPropertyValues( aPropertyValues );
+-        m_xBarSettings.set( m_pCommandBarControl->GetCurrentSettings(), uno::UNO_QUERY_THROW );
 -
--	class XNamedEnumerationHelper : public EnumerationHelper_BASE
--	{
--		XNamedVec mXNamedVec;
--		typename XNamedVec::iterator mIt;
--	public:
--	        XNamedEnumerationHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), mIt( mXNamedVec.begin() ) {}
--	
--	        virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException)
--	        {
--			return ( mIt != mXNamedVec.end() );
--	        }
--	
--	        virtual css::uno::Any SAL_CALL nextElement(  ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
--	        {
--	                if ( hasMoreElements() )
--				return css::uno::makeAny( *mIt++ );
--	                throw css::container::NoSuchElementException();
--	        }
--	};
+-        uno::Any aValue = lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") );
+-        if( aValue.hasValue() )
+-        {
+-            m_xCurrentSettings = m_pCommandBarControl->GetCurrentSettings();
+-            m_bHasElements = sal_True;
+-        }
+-        else
+-        {
+-            m_bHasElements = sal_False;
+-        }
+-        m_bIsMenu = m_pCommandBarControl->IsMenu();
+-    }
+-    else
+-    {
+-        throw uno::RuntimeException( rtl::OUString::createFromAscii("Parent needs to be a ScVbaCommandBar or a ScVbaCommandBarControl"), uno::Reference< uno::XInterface >() );
+-    }
+-}
+-rtl::OUString
+-ScVbaCommandBarControls::GetControlNameByIndex( const sal_Int32 nIndex ) throw ( uno::RuntimeException )
+-{
+-    sal_Int32 nCount = 0;
+-    if( m_bHasElements )
+-    {
+-        sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
+-        for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
+-        {
+-            beans::PropertyValues aMenuValues;
+-            m_xBarSettings->getByIndex( i ) >>= aMenuValues;
+-            for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
+-            {
+-                if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
+-                {
+-                    nCount++;
+-                    if( nIndex == nCount )
+-                    {
+-                        rtl::OUString sCommandURL;
+-                        aMenuValues[j].Value >>= sCommandURL;
+-                        sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
+-                        if( ( nLastIndex != -1 ) && ( ( nLastIndex +1 ) < sCommandURL.getLength() ) )
+-                        {
+-                            sCommandURL = sCommandURL.copy( nLastIndex + 1 );
+-                            return sCommandURL;
+-                        }
+-                    }
+-                }
+-            }
+-        } 
+-    }
+-    else
+-        throw  uno::RuntimeException( rtl::OUString::createFromAscii( "Out of bound" ), uno::Reference< uno::XInterface >() );
+-    return rtl::OUString();
+-}
 -
--protected:
--	XNamedVec mXNamedVec;
--	typename XNamedVec::iterator cachePos;
--public:
--	XNamedObjectCollectionHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), cachePos(mXNamedVec.begin()) {}
--	// XElementAccess
--	virtual css::uno::Type SAL_CALL getElementType(  ) throw (css::uno::RuntimeException) { return  Ifc1::static_type(0); }
--	virtual ::sal_Bool SAL_CALL hasElements(  ) throw (css::uno::RuntimeException) { return ( mXNamedVec.size() > 0 ); }
--	// XNameAcess 
--	virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
--	{
--		if ( !hasByName(aName) )
--			throw css::container::NoSuchElementException();
--		return css::uno::makeAny( *cachePos );
--	}
--	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (css::uno::RuntimeException)
--	{
--		css::uno::Sequence< rtl::OUString > sNames( mXNamedVec.size() );
--		rtl::OUString* pString = sNames.getArray();
--		typename XNamedVec::iterator it = mXNamedVec.begin();
--		typename XNamedVec::iterator it_end = mXNamedVec.end();
+-// Attributes
+-sal_Int32 SAL_CALL 
+-ScVbaCommandBarControls::getCount() throw (uno::RuntimeException)
+-{
+-    sal_Int32 nCount = 0;
+-    if( m_bHasElements )
+-    {
+-        sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
+-        for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
+-        {
+-            beans::PropertyValues aMenuValues;
+-            m_xBarSettings->getByIndex( i ) >>= aMenuValues;
+-            for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
+-            {
+-                if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
+-                {
+-                    nCount++;
+-                }
+-            }
+-        } 
+-    }
+-    return nCount;
+-}
+-// XEnumerationAccess
+-uno::Type SAL_CALL
+-ScVbaCommandBarControls::getElementType() throw ( uno::RuntimeException )
+-{
+-    return XCommandBarControls::static_type( 0 );
+-}
+-uno::Reference< container::XEnumeration >
+-ScVbaCommandBarControls::createEnumeration() throw ( uno::RuntimeException )
+-{
+-    return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) );
+-}
+-uno::Any
+-ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
+-{
+-    // only surport the aSource as a name string, because this class is a API wrapper
+-    rtl::OUString sName;
+-    if( aSource >>= sName )
+-    {
+-        uno::Reference< container::XIndexContainer > xCurrentSettings;
+-        beans::PropertyValues aPropertyValues;
+-        if( m_pCommandBarControl )
+-        {
+-            m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
+-            xCurrentSettings.set( lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY );
+-            if( !xCurrentSettings.is() )
+-            {
+-                xCurrentSettings.set( m_xUICfgManager->getSettings( GetParentToolBarName(), sal_True ), uno::UNO_QUERY );
+-            }
+-        }
 -
--		for ( ; it != it_end; ++it, ++pString )
--		{
--			css::uno::Reference< css::container::XNamed > xName( *it, css::uno::UNO_QUERY_THROW );	
--			*pString = xName->getName();
--		}
--		return sNames;
--	}
--	virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
--	{
--		cachePos = mXNamedVec.begin();
--		typename XNamedVec::iterator it_end = mXNamedVec.end();
--		for ( ; cachePos != it_end; ++cachePos )
--		{
--			css::uno::Reference< css::container::XNamed > xName( *cachePos, css::uno::UNO_QUERY_THROW );	
--			if ( aName.equals( xName->getName() ) )
--				break;
--		}
--		return ( cachePos != it_end );
--	}
+-        sal_Int32 nPosition = -1;
+-        for( sal_Int32 i = 0; i < xCurrentSettings->getCount(); i++ )
+-        {
+-            xCurrentSettings->getByIndex( i ) >>= aPropertyValues;
+-            // Label always empty in OOo
+-            rtl::OUString sLabel;
+-            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel;
+-            if( sLabel.equalsIgnoreAsciiCase( sName ) )
+-            {
+-                nPosition = i;
+-                break;
+-            }
+-            // using CammandURL to find
+-            rtl::OUString sCommandURL;
+-            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
+-            sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
+-            if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sCommandURL.getLength() ) )
+-            {
+-                sCommandURL = sCommandURL.copy( nLastIndex + 1 );
+-            }
+-            if( sCommandURL.equalsIgnoreAsciiCase( sName ) )
+-            {
+-                nPosition = i;
+-                break;
+-            }
+-        }
 -
--	// XElementAccess
--	virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException) { return mXNamedVec.size(); }	
--	virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException )
--	{
--		if ( Index < 0 || Index >= getCount() )
--			throw css::lang::IndexOutOfBoundsException();
--	
--		return css::uno::makeAny( mXNamedVec[ Index ] );
+-        if( nPosition  != -1 )
+-        {
+-            uno::Reference< container::XIndexContainer > xSubMenu;
+-            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ) >>= xSubMenu;
+-            ScVbaCommandBarControl* pNewCommandBarControl = NULL;
+-            if( xSubMenu.is() )
+-                pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sName, nPosition );
+-            else
+-                pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sName, nPosition );
 -
--	}
--	// XEnumerationAccess
--	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (css::uno::RuntimeException)
--	{
--		return new XNamedEnumerationHelper( mXNamedVec );
--	}
--};
+-            return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
+-        }
+-        else
+-            throw uno::RuntimeException( rtl::OUString::createFromAscii("The CommandBarControl do not exist"), uno::Reference< uno::XInterface >() );
+-        
+-    }
+-    return uno::Any();
+-}
 -
--// including a HelperInterface implementation
--template< typename Ifc1 >
--class ScVbaCollectionBase : public InheritedHelperInterfaceImpl< Ifc1 >
+-// Methods
+-uno::Any SAL_CALL 
+-ScVbaCommandBarControls::Item( const uno::Any& aIndex, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException)
 -{
--typedef InheritedHelperInterfaceImpl< Ifc1 > BaseColBase;
--protected:
--	css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess;
--	css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
--
--	virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException)
--	{
--		if ( !m_xNameAccess.is() )
--			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase string index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
--	
--		return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
--	}		
--
--	virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException)
--	{
--		if ( !m_xIndexAccess.is() )
--			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase numeric index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
--		if ( nIndex <= 0 )
--		{
--			throw  css::lang::IndexOutOfBoundsException( 
--				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
--				"index is 0 or negative" ) ), 
--				css::uno::Reference< css::uno::XInterface >() );
--		}
--		// need to adjust for vba index ( for which first element is 1 )
--		return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );		
--	}
--public:
--	ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent,   const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); }
--	//XCollection
--	virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException)
--	{
--		return m_xIndexAccess->getCount();
--	}
--
--	virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw (css::uno::RuntimeException)
--	{
--		if ( Index1.getValueTypeClass() != css::uno::TypeClass_STRING )
--		{
--			sal_Int32 nIndex = 0;
--	
--			if ( ( Index1 >>= nIndex ) != sal_True )
--			{
--				rtl::OUString message;
--				message = rtl::OUString::createFromAscii(
--					"Couldn't convert index to Int32");
--				throw  css::lang::IndexOutOfBoundsException( message,
--					css::uno::Reference< css::uno::XInterface >() );
--			}
--			return 	getItemByIntIndex( nIndex );
--		}
--		rtl::OUString aStringSheet;
+-    if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
+-    {
+-        return createCollectionObject( aIndex );
+-    } 
+-    sal_Int32 nIndex = 0;
+-    if( aIndex >>= nIndex )
+-    {
+-        return createCollectionObject( uno::makeAny( GetControlNameByIndex( nIndex ) ) );
+-    }
+-    
+-    return uno::Any();
+-}
+-uno::Reference< XCommandBarControl > SAL_CALL 
+-ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& /*Parameter*/, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
+-{
+-    // Parameter is not supported
+-    // the following name needs to be individually created;
+-    rtl::OUString sCaption( rtl::OUString::createFromAscii("custom Control") );
+-    rtl::OUString sCommand( rtl::OUString::createFromAscii("macro:///Standard.Module1.Test()") );
+-    sal_Int32 nType =0;
+-    sal_Int32 nPosition = 0;
+-    sal_Int32 nId;
+-    sal_Bool bTemporary = sal_True;
+-    
+-    if( Type.hasValue() )
+-        if( Type >>= nType )
+-        {
+-            // evalute the type of the new control
+-        }
+-    if( Id.hasValue() )
+-        if( Id >>= nId )
+-        {
+-            // evalute the action of the new control
+-        }
+-    if( Before.hasValue() )
+-        Before >>= nPosition;
+-    else
+-    {
+-        // if Before is ignore, the new control should be placed at the end of the commandbars;
+-        if( m_pCommandBar )
+-            nPosition = getCount();
+-        else if ( m_pCommandBarControl )
+-        {
+-            css::uno::Reference< css::container::XIndexContainer > xCurrentSettings;
+-            xCurrentSettings.set( lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY );
+-            if( xCurrentSettings.is() )
+-            {
+-                nPosition = xCurrentSettings->getCount();
+-            }
+-        }
+-    }
+-    if( Temporary.hasValue() )
+-        if( Temporary >>= bTemporary )
+-        {
+-            // evalute the temporary of the new Control
+-        }
+-    
+-    ScVbaCommandBarControl* pNewCommandBarControl = NULL;
+-    if( nType == office::MsoControlType::msoControlButton )
+-    {
+-        pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sCaption, nPosition, bTemporary );
+-    }
+-    else if ( nType == office::MsoControlType::msoControlPopup )
+-    {
+-        pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sCaption, nPosition, bTemporary );
+-    }
+-    else
+-    {
+-        pNewCommandBarControl = new ScVbaCommandBarControl( this, mxContext, sCaption, nPosition, bTemporary );
+-    }
 -
--		Index1 >>= aStringSheet;
--		return getItemByStringIndex( aStringSheet );	
--	}
--	// XDefaultMethod
--	::rtl::OUString SAL_CALL getDefaultMethodName(  ) throw (css::uno::RuntimeException)
--	{
--		const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
--		return sName;
--	}
--	// XEnumerationAccess
--	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0;	
+-    return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
+-}
+-   
+-// XHelperInterface
+-rtl::OUString& 
+-ScVbaCommandBarControls::getServiceImplName()
+-{
+-    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControls") );
+-    return sImplName;
+-}
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBarControls::getServiceNames()
+-{
+-    static uno::Sequence< rtl::OUString > aServiceNames;
+-    if ( aServiceNames.getLength() == 0 )
+-    {
+-        aServiceNames.realloc( 1 );
+-        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControls" ) );
+-    }
+-    return aServiceNames;
+-}
 -
--	// XElementAccess
--	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0;
--	// XElementAccess
--	virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException)
--	{
--		return ( m_xIndexAccess->getCount() > 0 );
--	}
--	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0;
--	
--};
+diff --git sc/source/ui/vba/vbacommandbarcontrols.hxx sc/source/ui/vba/vbacommandbarcontrols.hxx
+deleted file mode 100644
+index 8e7d1e1..0000000
+--- sc/source/ui/vba/vbacommandbarcontrols.hxx
++++ /dev/null
+@@ -1,91 +0,0 @@
+-/*************************************************************************
+- *
+- *  OpenOffice.org - a multi-platform office productivity suite
+- *
+- *  $RCSfile$
+- *
+- *  $Revision$
+- *
+- *  last change: $Author$ $Date$
+- *
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
+- *
+- *
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#ifndef SC_VBA_COMMANDBARCONTROLS_HXX
+-#define SC_VBA_COMMANDBARCONTROLS_HXX
 -
--typedef ::cppu::WeakImplHelper1<ov::XCollection> XCollection_InterfacesBASE;
+-#include <ooo/vba/XCommandBarControls.hpp>
 -
--typedef ScVbaCollectionBase< XCollection_InterfacesBASE > CollImplBase1;
--// compatible with the old collections ( pre XHelperInterface base class ) ( some internal objects still use this )
--class ScVbaCollectionBaseImpl : public CollImplBase1
--{
--public:
--	ScVbaCollectionBaseImpl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : CollImplBase1( xParent, xContext, xIndexAccess){}
+-#include "vbahelperinterface.hxx"
+-#include "vbacommandbar.hxx"
+-#include "vbacollectionimpl.hxx"
 -
--};
+-class ScVbaCommandBarControl;
 -
--template <typename Ifc> // where Ifc must implement XCollectionTest
--class CollTestImplHelper :  public ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > >
+-typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
+-
+-class ScVbaCommandBarControls : public CommandBarControls_BASE
 -{
--typedef ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc >  > ImplBase1;
+-private:
+-    sal_Bool                    m_bIsMenu;
+-    sal_Bool                    m_bHasElements;
+-    ScVbaCommandBar*            m_pCommandBar; 
+-    ScVbaCommandBarControl*     m_pCommandBarControl; 
+-    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
+-    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
+-    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
+-    css::uno::Reference< css::container::XIndexContainer >          m_xCurrentSettings;
 -
 -public:
--	CollTestImplHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,  const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : ImplBase1( xParent, xContext, xIndexAccess ) {}
--};
+-    ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess ) throw( css::uno::RuntimeException );
+-    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
+-    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
+-    css::uno::Reference< css::container::XIndexContainer >  GetBarSettings() { return m_xBarSettings; };
+-    sal_Bool IsMenu() { return m_bIsMenu; };
+-    ScVbaCommandBar* GetParentCommandBar() { return m_pCommandBar; };
+-    ScVbaCommandBarControl* GetParentCommandBarControl() { return m_pCommandBarControl; };
+-    rtl::OUString GetParentToolBarName() 
+-    { 
+-        if( m_pCommandBar ) return m_pCommandBar->GetToolBarName();
+-        else return rtl::OUString();
+-    }
+-    rtl::OUString GetControlNameByIndex( const sal_Int32 nIndex ) throw ( css::uno::RuntimeException );
 -
+-    // Attributes
+-    virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+-    // XEnumerationAccess
+-    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+-    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+-    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
 -
--#endif //SC_VBA_COLLECTION_IMPL_HXX
-diff --git sc/source/ui/vba/vbacolorformat.hxx sc/source/ui/vba/vbacolorformat.hxx
-index a5104d8..a45d5d8 100644
---- sc/source/ui/vba/vbacolorformat.hxx
-+++ sc/source/ui/vba/vbacolorformat.hxx
-@@ -33,7 +33,7 @@
- #include <com/sun/star/drawing/XShape.hpp>
- #include <ooo/vba/msforms/XColorFormat.hpp>
- #include <ooo/vba/msforms/XFillFormat.hpp>
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include "vbafillformat.hxx"
- 
- typedef InheritedHelperInterfaceImpl1< ov::msforms::XColorFormat > ScVbaColorFormat_BASE;
-diff --git sc/source/ui/vba/vbacombobox.cxx sc/source/ui/vba/vbacombobox.cxx
+-    // Methods     
+-    virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException); 
+-    virtual css::uno::Reference< ov::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    // XHelperInterface
+-    virtual rtl::OUString& getServiceImplName();
+-    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-
+-#endif//SC_VBA_COMMANDBARCONTROLS_HXX
+diff --git sc/source/ui/vba/vbacommandbars.cxx sc/source/ui/vba/vbacommandbars.cxx
 deleted file mode 100644
-index 8f1e0fb..0000000
---- sc/source/ui/vba/vbacombobox.cxx
+index 66a1652..0000000
+--- sc/source/ui/vba/vbacommandbars.cxx
 +++ /dev/null
-@@ -1,175 +0,0 @@
+@@ -1,261 +0,0 @@
 -/*************************************************************************
 - *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
+- *  OpenOffice.org - a multi-platform office productivity suite
 - *
-- * OpenOffice.org - a multi-platform office productivity suite
+- *  $RCSfile$
 - *
-- * $RCSfile: vbacombobox.cxx,v $
-- * $Revision: 1.4 $
+- *  $Revision$
 - *
-- * This file is part of OpenOffice.org.
+- *  last change: $Author$ $Date$
 - *
-- * 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.
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
 - *
-- * 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.
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
 - *
 - ************************************************************************/
--#include "vbacombobox.hxx"
--#include <vector>
+-#include <com/sun/star/lang/XServiceInfo.hpp>
+-#include <com/sun/star/frame/XDesktop.hpp>
+-#include <com/sun/star/container/XNameAccess.hpp>
+-
+-#include "vbacommandbars.hxx"
+-#include "vbacommandbar.hxx"
 -
 -using namespace com::sun::star;
 -using namespace ooo::vba;
 -
+-typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarEnumeration_BASE;
 -
--//SelectedItems list of integer indexes
--//StringItemList list of items
--
--const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
--const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
--const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
--const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataFieldProperty") );
--
--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;
--}
--
--// Attributes
--
--
--// Value, [read] e.g. getValue returns the value of ooo Text propery e.g. the value in
--// the drop down
--uno::Any SAL_CALL 
--ScVbaComboBox::getValue() throw (uno::RuntimeException)
--{
--	return m_xProps->getPropertyValue( sSourceName );
--}
--
--void SAL_CALL 
--ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
--{
--    uno::Sequence< sal_Int16 > sSelection(1);
--    _value >>= sSelection[ 0 ];
--    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( sSelection ) );
--}
+-static rtl::OUString sSpreadsheetDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" ) );
+-static rtl::OUString sTextDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" ) );
+-static rtl::OUString sWindowStateConfUrl( rtl::OUString::createFromAscii( "com.sun.star.ui.WindowStateConfiguration" ) );
+-
+-class CommandBarEnumeration : public CommandBarEnumeration_BASE
+-{
+-    uno::Reference< uno::XComponentContext > m_xContext;
+-    uno::Reference< XCommandBars > m_xCommandBars;
+-    uno::Sequence< rtl::OUString > m_sNames;
+-    sal_Int32 m_nCurrentPosition;
+-public:
+-    CommandBarEnumeration( const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBars > xCommandBars, const uno::Sequence< rtl::OUString > sNames ) : m_xContext( xContext ), m_xCommandBars( xCommandBars ), m_sNames( sNames ), m_nCurrentPosition( 0 )
+-    {
+-    }
+-    virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+-    {
+-        if( m_nCurrentPosition < m_sNames.getLength() )
+-            return sal_True;
+-        return sal_False;
+-    }
+-    virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+-    {
+-        if( hasMoreElements() )
+-        {
+-            rtl::OUString sName( m_sNames[ m_nCurrentPosition ] );
+-            m_nCurrentPosition = m_nCurrentPosition + 1;
+-            if( sName.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 ) 
+-            {
+-                sal_Int32 nLastIndex = sName.lastIndexOf( rtl::OUString::createFromAscii( "/" ) );
+-                if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sName.getLength() ) )
+-                {
+-                   sName = sName.copy( nLastIndex + 1);
+-                   if( sName.getLength() > 0 )
+-                   {
+-                        uno::Reference< XHelperInterface > xHelperInterface( m_xCommandBars, uno::UNO_QUERY_THROW );
+-                        uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( xHelperInterface, m_xContext, sName, sal_True, sal_False ) );
+-                        if( xCommandBar.is() )
+-                            return uno::makeAny( xCommandBar );
+-                        else
+-                            return nextElement();
+-                    }
+-                    else
+-                        return nextElement();
+-                    }
+-             }
+-             else
+-                return nextElement();
+-        }
+-        else
+-            throw container::NoSuchElementException();
+-        return uno::Any();
+-    }
+-};
 -
--uno::Any SAL_CALL 
--ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
--{
--	uno::Sequence< rtl::OUString > sItems;
--	m_xProps->getPropertyValue( ITEMS ) >>= sItems;
--	// should really return the item that has focus regardless of
--	// it been selected
--	if ( sItems.getLength() > 0 )
--	{
--		rtl::OUString sText = getText();
--		sal_Int32 nLen = sItems.getLength();
--		for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index )
--		{
--			if ( sItems[ index ].equals( sText ) )
--			{
--				OSL_TRACE("getListIndex returning %d", index );
--				return uno::makeAny( index );
--			}
--				
--		} 
-- 	} 
--	OSL_TRACE("getListIndex returning %d", -1 );
--	return uno::makeAny( sal_Int32( -1 ) );
--}
 -
--// Value, [write]e.g. setValue sets the value in the drop down, and if the value is one
--// of the values in the list then the selection is also set
--void SAL_CALL 
--ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
+-ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess > xIndexAccess ) : CommandBars_BASE( xParent, xContext, xIndexAccess )
 -{
--	m_xProps->setPropertyValue( sSourceName, _value );
+-    retrieveObjects();
 -}
--
--// see Value
--
--::rtl::OUString SAL_CALL 
--ScVbaComboBox::getText() throw (uno::RuntimeException)
+-void
+-ScVbaCommandBars::retrieveObjects() throw ( uno::RuntimeException )
 -{
--	rtl::OUString result;
--	getValue() >>= result;
--	return result;
+-    uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument(), uno::UNO_QUERY_THROW );
+-    if( xServiceInfo->supportsService( sSpreadsheetDocumentUrl ) )
+-    {
+-        m_sModuleName = sSpreadsheetDocumentUrl;
+-    }
+-    else if( xServiceInfo->supportsService( sTextDocumentUrl ) )
+-    {
+-        m_sModuleName = sTextDocumentUrl;
+-    }
+-    else
+-        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Unsupported Document" ), uno::Reference< uno::XInterface >() );
+-    
+-    uno::Reference < lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+-    uno::Reference < container::XNameAccess > xNameAccess( xMSF->createInstance( sWindowStateConfUrl ), uno::UNO_QUERY_THROW );
+-    m_xNameAccess.set( xNameAccess->getByName( m_sModuleName ), uno::UNO_QUERY_THROW );
 -}
 -
--void SAL_CALL 
--ScVbaComboBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
+-// XEnumerationAccess
+-uno::Type SAL_CALL 
+-ScVbaCommandBars::getElementType() throw ( uno::RuntimeException )
 -{
--	setValue( uno::makeAny( _text ) ); // seems the same
+-    return XCommandBars::static_type( 0 );
 -}
--
--// Methods
--void SAL_CALL 
--ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
+-uno::Reference< container::XEnumeration >
+-ScVbaCommandBars::createEnumeration() throw ( uno::RuntimeException )
 -{
--	mpListHelper->AddItem( pvargItem, pvargIndex );
+-    return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( mxContext, this, m_xNameAccess->getElementNames() ) );
 -}
 -
--void SAL_CALL 
--ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
--	{
--	mpListHelper->removeItem( index );
+-uno::Any
+-ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
+-{
+-    // aSource should be a name at this time, because of the class is API wrapper.
+-    rtl::OUString sToolBarName;
+-    if( aSource >>= sToolBarName )
+-    {
+-        sToolBarName = sToolBarName.toAsciiLowerCase();
+-        if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") ) )
+-        {
+-            return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, 0 ) ) );
+-        }
+-        else if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
+-        {
+-            return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, 1 ) ) );
+-        }
+-        else if( checkToolBarExist( sToolBarName ) )
+-        {
+-            return uno::makeAny( uno::Reference< XCommandBar > (new ScVbaCommandBar( this, mxContext, sToolBarName, sal_True, sal_False ) ) );
+-        }
+-    }
+-    return uno::Any();
 -}
 -
--void SAL_CALL 
--ScVbaComboBox::Clear(  ) throw (uno::RuntimeException)
--		{
--	mpListHelper->Clear();
--		}
+-// XCommandBars
+-uno::Reference< XCommandBar > SAL_CALL 
+-ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Position*/, const css::uno::Any& /*MenuBar*/, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+-{
+-    // Position - MsoBar MenuBar - sal_Bool
+-    // Currently only the Name is supported.
+-    rtl::OUString sName;
+-    if( !( Name >>= sName ) )
+-    {
+-        sName = rtl::OUString::createFromAscii("Custom1");
+-    }
+-    sal_Bool bTemporary = false;
+-    if( !( Temporary >>= bTemporary ) )
+-    {
+-        bTemporary = sal_True;
+-    }
+-    return uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, sName.toAsciiLowerCase(), bTemporary, sal_True ) );
+-}
+-sal_Int32 SAL_CALL 
+-ScVbaCommandBars::getCount() throw(css::uno::RuntimeException)
+-{
+-    // Filter out all toolbars from the window collection
+-    sal_Int32 nCount = 0;
+-    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
+-    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
+-    {
+-        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
+-        {
+-            nCount++;
+-        }
+-    }
+-    return nCount;
+-}
 -
--void SAL_CALL
--ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException)
+-// ScVbaCollectionBaseImpl
+-uno::Any SAL_CALL
+-ScVbaCommandBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
 -{
--	ScVbaControl::setRowSource( _rowsource );
--	mpListHelper->setRowSource( _rowsource );
--		}
+-    if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
+-    {
+-        return createCollectionObject( aIndex );    
+-    }
 -
--sal_Int32 SAL_CALL
--ScVbaComboBox::getListCount() throw (uno::RuntimeException)
--		{
--	return mpListHelper->getListCount();
--		}
--		
--uno::Any SAL_CALL 
--ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
--		{
--	return mpListHelper->List( pvargIndex, pvarColumn );
--		}
+-    // hardcode if "aIndex = 1" that would return "main menu".
+-    sal_Int16 nIndex = 0;
+-    aIndex >>= nIndex;
+-    if( nIndex == 1 )
+-    {
+-        uno::Any aSource;
+-        if( m_sModuleName.equalsIgnoreAsciiCase( sSpreadsheetDocumentUrl ) )
+-            aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" );
+-        else if( m_sModuleName.equalsIgnoreAsciiCase( sTextDocumentUrl ) )
+-            aSource <<= rtl::OUString::createFromAscii( "Menu Bar" );
+-        if( aSource.hasValue() )    
+-            return createCollectionObject( aSource );
+-    }
+-    return uno::Any();
+-}
 -
--rtl::OUString& 
--ScVbaComboBox::getServiceImplName()
+-sal_Bool
+-ScVbaCommandBars::checkToolBarExist( rtl::OUString sToolBarName )
 -{
--	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
--	return sImplName;
--	}
--
--uno::Sequence< rtl::OUString > 
--ScVbaComboBox::getServiceNames()
+-    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
+-    if( iter != mCommandBarNameMap.end() )
+-    {
+-        return sal_True;
+-    }    
+-    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
+-    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
+-    {
+-        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
+-        {
+-            if( allNames[i].indexOf( sToolBarName ) != -1 )
+-            {
+-                return sal_True;
+-            }
+-        }
+-    }
+-    return sal_False;
+-}
+-    
+-// XHelperInterface
+-rtl::OUString& 
+-ScVbaCommandBars::getServiceImplName()
 -{
--	static uno::Sequence< rtl::OUString > aServiceNames;
--	if ( aServiceNames.getLength() == 0 )
--	{
--		aServiceNames.realloc( 1 );
--		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ComboBox" ) );
+-    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBars") );
+-    return sImplName;
 -}
--	return aServiceNames;
+-uno::Sequence<rtl::OUString> 
+-ScVbaCommandBars::getServiceNames()
+-{
+-    static uno::Sequence< rtl::OUString > aServiceNames;
+-    if ( aServiceNames.getLength() == 0 )
+-    {
+-        aServiceNames.realloc( 1 );
+-        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBars" ) );
+-    }
+-    return aServiceNames;
 -}
-diff --git sc/source/ui/vba/vbacombobox.hxx sc/source/ui/vba/vbacombobox.hxx
+-
+diff --git sc/source/ui/vba/vbacommandbars.hxx sc/source/ui/vba/vbacommandbars.hxx
 deleted file mode 100644
-index 45996e2..0000000
---- sc/source/ui/vba/vbacombobox.hxx
+index a05e22b..0000000
+--- sc/source/ui/vba/vbacommandbars.hxx
 +++ /dev/null
-@@ -1,80 +0,0 @@
+@@ -1,79 +0,0 @@
 -/*************************************************************************
 - *
-- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-- * 
-- * Copyright 2008 by Sun Microsystems, Inc.
+- *  OpenOffice.org - a multi-platform office productivity suite
 - *
-- * OpenOffice.org - a multi-platform office productivity suite
+- *  $RCSfile$
 - *
-- * $RCSfile: vbacombobox.hxx,v $
-- * $Revision: 1.4 $
+- *  $Revision$
 - *
-- * This file is part of OpenOffice.org.
+- *  last change: $Author$ $Date$
 - *
-- * 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.
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
 - *
-- * 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.
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
 - *
 - ************************************************************************/
--#ifndef SC_VBA_COMBOBOX_HXX
--#define SC_VBA_COMBOBOX_HXX
--#include <cppuhelper/implbase2.hxx>
--#include <com/sun/star/uno/XComponentContext.hpp>
--#include <com/sun/star/beans/XPropertySet.hpp>
--#include <com/sun/star/script/XDefaultProperty.hpp>
--#include <ooo/vba/msforms/XComboBox.hpp>
--#include <comphelper/proparrhlp.hxx>
--#include <comphelper/propertycontainer.hxx>
--#include <com/sun/star/beans/PropertyAttribute.hpp>
+-#ifndef SC_VBA_COMMANDBARS_HXX
+-#define SC_VBA_COMMANDBARS_HXX
 -
--#include "vbacontrol.hxx"
--#include "vbalistcontrolhelper.hxx"
--#include "vbahelper.hxx"
+-#include <ooo/vba/XCommandBar.hpp>
+-#include <ooo/vba/XCommandBars.hpp>
+-#include <com/sun/star/container/XNameAccess.hpp>
 -
--typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE;
--class ScVbaComboBox : public ComboBoxImpl_BASE
--{		
--	std::auto_ptr< ListControlHelper > mpListHelper;
--	rtl::OUString sSourceName; 
--	rtl::OUString msDftPropName;
--	bool mbDialogType;
+-#include <cppuhelper/implbase1.hxx>
 -
--public:
--	ScVbaComboBox( 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, bool bDialogType = false );
+-#include "vbahelperinterface.hxx"
+-#include "vbacollectionimpl.hxx"
 -
--	// Attributes
--	virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException);
--	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
--	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) 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 ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
--	virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+-typedef CollTestImplHelper< ov::XCommandBars > CommandBars_BASE;
 -
--	// Methods
--	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);
--	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
--	// XControl
--    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
+-class ScVbaCommandBars : public CommandBars_BASE
+-{
+-private:
+-    css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
+-    rtl::OUString m_sModuleName;
+-    void retrieveObjects() throw( css::uno::RuntimeException );
+-public:
+-    ScVbaCommandBars( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess );
 -
--	// XDefaultProperty
--        ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
--	//XHelperInterface
--	virtual rtl::OUString& getServiceImplName();
--	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-    sal_Bool checkToolBarExist( rtl::OUString sToolBarName );
+-    rtl::OUString GetModuleName(){ return m_sModuleName; };
+-    css::uno::Reference< css::container::XNameAccess > GetWindows() 
+-    { 
+-        retrieveObjects();
+-        return m_xNameAccess; 
+-    };
+-    // XCommandBars
+-    virtual css::uno::Reference< ov::XCommandBar > SAL_CALL Add( const css::uno::Any& Name, const css::uno::Any& Position, const css::uno::Any& MenuBar, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+-    // XEnumerationAccess
+-    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+-    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+-    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+-
+-    virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+-    virtual css::uno::Any SAL_CALL Item( const css::uno::Any& aIndex, const css::uno::Any& /*aIndex2*/ ) throw( css::uno::RuntimeException);
+-    // XHelperInterface
+-    virtual rtl::OUString& getServiceImplName();
+-    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 -};
 -
--#endif //
-diff --git sc/source/ui/vba/vbacommandbar.cxx sc/source/ui/vba/vbacommandbar.cxx
-index 24e5189..b5c283d 100644
---- sc/source/ui/vba/vbacommandbar.cxx
-+++ sc/source/ui/vba/vbacommandbar.cxx
-@@ -41,7 +41,7 @@
- 
- #include "vbacommandbar.hxx"
- #include "vbacommandbarcontrols.hxx"
--#include "vbahelper.hxx"
-+#include "excelvbahelper.hxx"
- 
- 
- using namespace com::sun::star;
-diff --git sc/source/ui/vba/vbacommandbar.hxx sc/source/ui/vba/vbacommandbar.hxx
-index bbeda7c..0b830b2 100644
---- sc/source/ui/vba/vbacommandbar.hxx
-+++ sc/source/ui/vba/vbacommandbar.hxx
-@@ -41,7 +41,7 @@
- #include <com/sun/star/container/XIndexContainer.hpp>
- #include <com/sun/star/beans/PropertyValues.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include "vbacommandbars.hxx"
- 
- #include <map>
-diff --git sc/source/ui/vba/vbacommandbarcontrol.hxx sc/source/ui/vba/vbacommandbarcontrol.hxx
-index 1c406a5..4d7d133 100644
---- sc/source/ui/vba/vbacommandbarcontrol.hxx
-+++ sc/source/ui/vba/vbacommandbarcontrol.hxx
-@@ -40,7 +40,7 @@
- #include <ooo/vba/XCommandBarButton.hpp>
- #include <ooo/vba/office/MsoControlType.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include "vbacommandbarcontrols.hxx"
- 
- typedef InheritedHelperInterfaceImpl1< ov::XCommandBarControl > CommandBarControl_BASE;
-diff --git sc/source/ui/vba/vbacommandbarcontrols.hxx sc/source/ui/vba/vbacommandbarcontrols.hxx
-index 8e7d1e1..ff00609 100644
---- sc/source/ui/vba/vbacommandbarcontrols.hxx
-+++ sc/source/ui/vba/vbacommandbarcontrols.hxx
-@@ -37,9 +37,9 @@
- 
- #include <ooo/vba/XCommandBarControls.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
- #include "vbacommandbar.hxx"
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
- 
- class ScVbaCommandBarControl;
- 
-diff --git sc/source/ui/vba/vbacommandbars.cxx sc/source/ui/vba/vbacommandbars.cxx
-index a111609..7913000 100644
---- sc/source/ui/vba/vbacommandbars.cxx
-+++ sc/source/ui/vba/vbacommandbars.cxx
-@@ -38,6 +38,7 @@
- 
- #include "vbacommandbars.hxx"
- #include "vbacommandbar.hxx"
-+#include "vbaglobals.hxx"
- 
- using namespace com::sun::star;
- using namespace ooo::vba;
-diff --git sc/source/ui/vba/vbacommandbars.hxx sc/source/ui/vba/vbacommandbars.hxx
-index a05e22b..7442002 100644
---- sc/source/ui/vba/vbacommandbars.hxx
-+++ sc/source/ui/vba/vbacommandbars.hxx
-@@ -41,8 +41,8 @@
- 
- #include <cppuhelper/implbase1.hxx>
- 
--#include "vbahelperinterface.hxx"
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
-+#include <vbahelper/vbacollectionimpl.hxx>
- 
- typedef CollTestImplHelper< ov::XCommandBars > CommandBars_BASE;
- 
+-#endif//SC_VBA_COMMANDBARS_HXX
 diff --git sc/source/ui/vba/vbacomment.hxx sc/source/ui/vba/vbacomment.hxx
 index 8baae1c..4911586 100644
 --- sc/source/ui/vba/vbacomment.hxx
@@ -2667,7 +6755,7 @@
  template< typename Ifc1 >
 diff --git sc/source/ui/vba/vbacontrol.cxx sc/source/ui/vba/vbacontrol.cxx
 deleted file mode 100644
-index a84703c..0000000
+index 0eb4255..0000000
 --- sc/source/ui/vba/vbacontrol.cxx
 +++ /dev/null
 @@ -1,467 +0,0 @@
@@ -2818,10 +6906,10 @@
 -ScVbaControl::~ScVbaControl()
 -{
 -    if( m_xControl.is() )
--    {
+-{
 -        uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
--        xComponent->removeEventListener( m_xEventListener );
--    }
+-    xComponent->removeEventListener( m_xEventListener );
+-}
 -}
 -
 -void 
@@ -2943,7 +7031,7 @@
 -			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BoundCell") ) ) >>= aAddress;
 -			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address") ), uno::makeAny( aAddress ) );
 -                	xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sControlSource;
--}
+-		}
 -		catch( uno::Exception& )
 -		{
 -		}	
@@ -2967,7 +7055,7 @@
 -
 -rtl::OUString SAL_CALL 
 -ScVbaControl::getRowSource() throw (uno::RuntimeException)
--    {
+-{
 -#ifdef VBA_OOBUILD_HACK
 -	rtl::OUString sRowSource;
 -	uno::Reference< form::binding::XListEntrySink > xListSink( m_xProps, uno::UNO_QUERY );
@@ -2983,10 +7071,10 @@
 -			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellRange") ) ) >>= aAddress;
 -			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address")), uno::makeAny( aAddress ) );
 -			xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sRowSource;
--    }
+-		}
 -		catch( uno::Exception& )
 -		{
--}
+-		}	
 -	}
 -	return sRowSource;
 -#else
@@ -3257,7 +7345,7 @@
 -#endif//SC_VBA_CONTROL_HXX
 diff --git sc/source/ui/vba/vbacontrols.cxx sc/source/ui/vba/vbacontrols.cxx
 deleted file mode 100644
-index e27e46a..0000000
+index e9dc0a7..0000000
 --- sc/source/ui/vba/vbacontrols.cxx
 +++ /dev/null
 @@ -1,227 +0,0 @@
@@ -3347,7 +7435,7 @@
 -    
 -    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException) 
 -    {
--        return mControls.size();
+-        return ( mControls.size() > 0 );
 -    }
 -    
 -    // XNameAcess 
@@ -3570,10 +7658,14 @@
  #include "vbaglobals.hxx"
  
 diff --git sc/source/ui/vba/vbadialog.hxx sc/source/ui/vba/vbadialog.hxx
-index 94d8114..162e19c 100644
+index 94d8114..583969e 100644
 --- sc/source/ui/vba/vbadialog.hxx
 +++ sc/source/ui/vba/vbadialog.hxx
-@@ -37,7 +37,7 @@
+@@ -33,11 +33,10 @@
+ #include <cppuhelper/implbase1.hxx>
+ 
+ #include <com/sun/star/uno/XComponentContext.hpp>
+-#include <ooo/vba/XGlobals.hpp>
  #include <ooo/vba/excel/XApplication.hpp>
  #include <ooo/vba/excel/XDialog.hpp>
   
@@ -3583,7 +7675,7 @@
  
  typedef InheritedHelperInterfaceImpl1< ov::excel::XDialog > ScVbaDialog_BASE;
 diff --git sc/source/ui/vba/vbadialogs.cxx sc/source/ui/vba/vbadialogs.cxx
-index e25cf7c..c798be9 100644
+index e25cf7c..c76a0b5 100644
 --- sc/source/ui/vba/vbadialogs.cxx
 +++ sc/source/ui/vba/vbadialogs.cxx
 @@ -36,7 +36,7 @@
@@ -3595,6 +7687,15 @@
  #include "vbadialogs.hxx"
  #include "vbaglobals.hxx"
  #include "vbadialog.hxx"
+@@ -62,7 +62,7 @@ ScVbaDialogs::Item( const uno::Any &aItem ) throw (uno::RuntimeException)
+ {
+ 	sal_Int32 nIndex = 0;
+ 	aItem >>= nIndex;
+-	uno::Reference< excel::XDialog > aDialog( new ScVbaDialog( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), nIndex, mxContext ) );
++	uno::Reference< excel::XDialog > aDialog( new ScVbaDialog( uno::Reference< XHelperInterface >( Application(),uno::UNO_QUERY_THROW ), nIndex, mxContext ) );
+ 	return uno::Any( aDialog );
+ }
+ rtl::OUString& 
 diff --git sc/source/ui/vba/vbadialogs.hxx sc/source/ui/vba/vbadialogs.hxx
 index fe9a32c..a0b2b24 100644
 --- sc/source/ui/vba/vbadialogs.hxx
@@ -3609,20 +7710,153 @@
  class ScModelObj;
  
 diff --git sc/source/ui/vba/vbaeventshelper.cxx sc/source/ui/vba/vbaeventshelper.cxx
-index c83406f..52ba287 100644
+index c83406f..8248d48 100644
 --- sc/source/ui/vba/vbaeventshelper.cxx
 +++ sc/source/ui/vba/vbaeventshelper.cxx
-@@ -33,7 +33,7 @@
+@@ -33,12 +33,8 @@
   *
   ************************************************************************/
  #include "vbaeventshelper.hxx"
 -#include "helperdecl.hxx"
 +#include <vbahelper/helperdecl.hxx>
  #include <sfx2/objsh.hxx> 
- #include <basic/basmgr.hxx>
- #include <basic/sbmod.hxx>
+-#include <basic/basmgr.hxx>
+-#include <basic/sbmod.hxx>
+-#include <basic/sbmeth.hxx>
+-#include <basic/sbx.hxx>
+ #include "scextopt.hxx"
+ #include <sfx2/evntconf.hxx>
+ #include <sfx2/event.hxx>
+@@ -69,8 +65,6 @@ using namespace com::sun::star;
+ using namespace ooo::vba;
+ using namespace com::sun::star::document::VbaEventId;
+ 
+-const static String sLibrary( RTL_CONSTASCII_USTRINGPARAM("Standard"));
+-
+ const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
+ const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
+ const static rtl::OUString sUrlPart2 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); 
+@@ -400,7 +394,7 @@ ScVbaEventsHelper::ScVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArg
+     : m_xContext( xContext ), mpVbaEventsListener( NULL ), mbOpened( sal_False ), mbIgnoreEvents( sal_False )
+ {
+     uno::Reference< frame::XModel > xModel ( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ), uno::UNO_QUERY );
+-    ScDocShell* pDocShell = getDocShell( xModel );
++    ScDocShell* pDocShell = excel::getDocShell( xModel );
+     pDoc = pDocShell->GetDocument();
+ }
+ 
+@@ -452,55 +446,6 @@ sal_Bool ScVbaEventsHelper::executeMacro( SfxObjectShell* pShell, const String&
+ 	}
+ 	return sal_True;
+ }
+-String ScVbaEventsHelper::workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro )
+-{
+-	String sFullName;	
+-	// would use the script provider to see if the macro exists but
+-	// called at this stage tdoc content handler stuff is not set up
+-	// so it fails
+-
+-	BasicManager* pBasicMgr = pShell-> GetBasicManager();
+-	if ( pBasicMgr )
+-	{
+-		StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary );
+-		if ( !pBasic )
+-		{
+-			USHORT nId = pBasicMgr->GetLibId( sLibrary );
+-			pBasicMgr->LoadLib( nId );
+-			pBasic = pBasicMgr->GetLib( sLibrary );
+-		}
+-		if ( pBasic )
+-		{
+-			if ( sMod.Len() ) // we wish to find the macro is a specific module
+-			{
+-				SbModule* pModule = pBasic->FindModule( sMod );
+-				if ( pModule )
+-				{
+-					SbxArray* pMethods = pModule->GetMethods();
+-					if ( pMethods )
+-					{
+-						SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) );
+-						if ( pMethod )
+-						{
+-							sFullName = sMacro;
+-							sFullName.Insert( '.', 0 ).Insert( sMod, 0 ).Insert( '.', 0 ).Insert( sLibrary, 0 );
+-						}
+-					}
+-				}
+-			}
+-			else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) )
+-			{
+-					if( SbModule* pModule = pMethod->GetModule() )
+-					{
+-						sFullName = sMacro;
+-						sFullName.Insert( '.', 0 ).Insert( pModule->GetName(), 0).Insert( '.', 0 ).Insert( sLibrary, 0 );
+-					}
+-			}		
+-				
+-		}
+-	}
+-	return sFullName;
+-}
+ 
+ uno::Any ScVbaEventsHelper::createWorkSheet( SfxObjectShell* pShell, SCTAB nTab )
+ {
+@@ -517,7 +462,7 @@ uno::Any ScVbaEventsHelper::createWorkSheet( SfxObjectShell* pShell, SCTAB nTab
+ 		uno::Sequence< uno::Any > aArgs(2);
+ 		aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
+ 		aArgs[1] = uno::Any( pShell->GetModel() );
+-		uno::Reference< uno::XInterface > xWorkbook( xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook") ), aArgs, xCtx ), uno::UNO_QUERY );
++		uno::Reference< uno::XInterface > xWorkbook( ov::createVBAUnoAPIServiceWithArgs( pShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_QUERY );
+ 
+ 		// create WorkSheet
+ 		String sSheetName;
+@@ -526,7 +471,7 @@ uno::Any ScVbaEventsHelper::createWorkSheet( SfxObjectShell* pShell, SCTAB nTab
+ 		aArgs[ 0 ] <<= xWorkbook;
+ 		aArgs[ 1 ] <<= pShell->GetModel();
+ 		aArgs[ 2 ] = uno::makeAny( rtl::OUString( sSheetName ) );
+-		aRet <<= xSMgr->createInstanceWithArgumentsAndContext(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet") ), aArgs, xCtx );
++		aRet <<= ov::createVBAUnoAPIServiceWithArgs( pShell, "ooo.vba.excel.Worksheet", aArgs );
+ 	}
+ 	catch( uno::Exception& e )
+ 	{
+@@ -560,7 +505,7 @@ uno::Any ScVbaEventsHelper::createRange( const uno::Any& aRange )
+ 			{
+ 				throw uno::RuntimeException(); // 
+ 			}
+-			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Range") ), aArgs, xCtx  );	
++			aRet <<= ov::createVBAUnoAPIServiceWithArgs( pDoc->GetDocumentShell(), "ooo.vba.excel.Range", aArgs );	
+ 		}
+ 	}
+ 	catch( uno::Exception& e ) 
+@@ -584,7 +529,7 @@ uno::Any ScVbaEventsHelper::createHyperlink( const uno::Any& rCell )
+ 			aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); // dummy parent
+ 			aArgs[1] <<= rCell;
+ 			
+-			aRet <<= xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Hyperlink") ), aArgs, xCtx  );	
++			aRet <<= ov::createVBAUnoAPIServiceWithArgs( pDoc->GetDocumentShell(), "ooo.vba.excel.Hyperlink", aArgs );	
+ 		}
+ 		else
+ 		{
+@@ -647,7 +592,7 @@ ScVbaEventsHelper::getMacroPath( const sal_Int32 nEventId, const SCTAB nTab )
+     	case VBAEVENT_WORKSHEET_SELECTIONCHANGE               :
+         {
+             rtl::OUString  aSheetModuleName = getSheetModuleName( nTab );
+-            sMacroPath = workbookMacroExists( pShell, aSheetModuleName, sMacroName );
++            sMacroPath = docMacroExists( pShell, aSheetModuleName, sMacroName );
+             break;
+         }
+         // Workbook
+@@ -681,7 +626,7 @@ ScVbaEventsHelper::getMacroPath( const sal_Int32 nEventId, const SCTAB nTab )
+                 sWorkbookModuleName = aExtDocSettings.maGlobCodeName;
+             }
+            
+-            sMacroPath = workbookMacroExists( pShell, sWorkbookModuleName, sMacroName );
++            sMacroPath = docMacroExists( pShell, sWorkbookModuleName, sMacroName );
+             break;
+         }
+         default:
 diff --git sc/source/ui/vba/vbaeventshelper.hxx sc/source/ui/vba/vbaeventshelper.hxx
-index df56886..fd0dc12 100644
+index df56886..e8c41d3 100644
 --- sc/source/ui/vba/vbaeventshelper.hxx
 +++ sc/source/ui/vba/vbaeventshelper.hxx
 @@ -40,7 +40,7 @@
@@ -3634,6 +7868,14 @@
  
  #define INVALID_TAB -1
  
+@@ -57,7 +57,6 @@ private:
+     sal_Bool mbIgnoreEvents;
+ 
+ 	String getSheetModuleName( SCTAB nTab );
+-	String workbookMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro );
+ 	css::uno::Any createWorkSheet( SfxObjectShell* pShell, SCTAB nTab );
+ 	css::uno::Any createRange( const css::uno::Any& aRange );
+ 	css::uno::Any createHyperlink( const css::uno::Any& rCell );
 diff --git sc/source/ui/vba/vbafillformat.hxx sc/source/ui/vba/vbafillformat.hxx
 index 88fcfc0..047af92 100644
 --- sc/source/ui/vba/vbafillformat.hxx
@@ -3647,6 +7889,19 @@
  
  typedef InheritedHelperInterfaceImpl1< ov::msforms::XFillFormat > ScVbaFillFormat_BASE;
  
+diff --git sc/source/ui/vba/vbafont.cxx sc/source/ui/vba/vbafont.cxx
+index f1bfeaa..091c734 100644
+--- sc/source/ui/vba/vbafont.cxx
++++ sc/source/ui/vba/vbafont.cxx
+@@ -76,7 +76,7 @@ ScVbaFont::ScVbaFont( const uno::Reference< XHelperInterface >& xParent, const u
+ SfxItemSet*  
+ ScVbaFont::GetDataSet()
+ {
+-    SfxItemSet* pDataSet = ScVbaCellRangeAccess::GetDataSet( mpRangeObj );
++    SfxItemSet* pDataSet = mpRangeObj ? mpRangeObj->GetCurrentDataSet( true ) : NULL ;
+     return pDataSet;
+ }
+ 
 diff --git sc/source/ui/vba/vbafont.hxx sc/source/ui/vba/vbafont.hxx
 index f73d729..efca63c 100644
 --- sc/source/ui/vba/vbafont.hxx
@@ -3661,7 +7916,7 @@
  
  class ScTableSheetsObj;
 diff --git sc/source/ui/vba/vbaformat.cxx sc/source/ui/vba/vbaformat.cxx
-index 16cbf3a..9a13b94 100644
+index 16cbf3a..264f02c 100644
 --- sc/source/ui/vba/vbaformat.cxx
 +++ sc/source/ui/vba/vbaformat.cxx
 @@ -33,6 +33,7 @@
@@ -3672,6 +7927,24 @@
  #include <com/sun/star/table/CellVertJustify.hpp>
  #include <com/sun/star/table/CellHoriJustify.hpp>
  #include <com/sun/star/table/CellOrientation.hpp>
+@@ -341,7 +342,7 @@ template< typename Ifc1 >
+ uno::Any SAL_CALL 
+ ScVbaFormat<Ifc1>::Borders( const uno::Any& Index ) throw (script::BasicErrorException, uno::RuntimeException )
+ {
+-	ScVbaPalette aPalette( getDocShell( mxModel ) );	
++	ScVbaPalette aPalette( excel::getDocShell( mxModel ) );	
+ 	uno::Reference< XCollection > xColl =  new ScVbaBorders( thisHelperIface(), ScVbaFormat_BASE::mxContext, uno::Reference< table::XCellRange >( mxPropertySet, uno::UNO_QUERY_THROW ), aPalette );
+ 
+ 	if ( Index.hasValue() )
+@@ -355,7 +356,7 @@ template< typename Ifc1 >
+ uno::Reference< excel::XFont > SAL_CALL 
+ ScVbaFormat<Ifc1>::Font(  ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+-	ScVbaPalette aPalette( getDocShell( mxModel ) );
++	ScVbaPalette aPalette( excel::getDocShell( mxModel ) );
+ 	return new ScVbaFont( thisHelperIface(), ScVbaFormat_BASE::mxContext, aPalette, mxPropertySet );
+ }
+ 
 diff --git sc/source/ui/vba/vbaformat.hxx sc/source/ui/vba/vbaformat.hxx
 index a88687d..7c01ea4 100644
 --- sc/source/ui/vba/vbaformat.hxx
@@ -3686,7 +7959,7 @@
  template< typename Ifc1 >
  class ScVbaFormat : public InheritedHelperInterfaceImpl1< Ifc1 >
 diff --git sc/source/ui/vba/vbaformatconditions.cxx sc/source/ui/vba/vbaformatconditions.cxx
-index 26d8b67..827503e 100644
+index 26d8b67..7cce546 100644
 --- sc/source/ui/vba/vbaformatconditions.cxx
 +++ sc/source/ui/vba/vbaformatconditions.cxx
 @@ -36,6 +36,7 @@
@@ -3697,6 +7970,15 @@
  using namespace ::ooo::vba;
  using namespace ::com::sun::star;
  
+@@ -50,7 +51,7 @@ static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFo
+ ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& xModel ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries )
+ {
+ 	mxRangeParent.set( xParent, uno::UNO_QUERY_THROW );
+-	uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook(  uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext, xModel );
++	uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook(  uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), xContext, xModel );
+ 	mxStyles.set( xWorkbook->Styles( uno::Any() ), uno::UNO_QUERY_THROW );
+ 	uno::Reference< sheet::XCellRangeAddressable > xCellRange( mxRangeParent->getCellRange(), uno::UNO_QUERY_THROW );
+ 	mxParentRangePropertySet.set( xCellRange, uno::UNO_QUERY_THROW );
 diff --git sc/source/ui/vba/vbaformatconditions.hxx sc/source/ui/vba/vbaformatconditions.hxx
 index efdfce5..cac54da 100644
 --- sc/source/ui/vba/vbaformatconditions.hxx
@@ -3874,10 +8156,10 @@
 -};
 -#endif //SC_VBA_LABEL_HXX
 diff --git sc/source/ui/vba/vbaglobals.cxx sc/source/ui/vba/vbaglobals.cxx
-index bfc291f..7c829bf 100644
+index bfc291f..d32eb78 100644
 --- sc/source/ui/vba/vbaglobals.cxx
 +++ sc/source/ui/vba/vbaglobals.cxx
-@@ -27,7 +27,7 @@
+@@ -27,13 +27,14 @@
   * for a copy of the LGPLv3 License.
   *
   ************************************************************************/
@@ -3886,25 +8168,358 @@
  #include "vbaglobals.hxx"
  
  #include <comphelper/unwrapargs.hxx>
+ 
+ #include <com/sun/star/lang/XMultiComponentFactory.hpp>
+ #include <com/sun/star/beans/XPropertySet.hpp>
++#include <cppuhelper/component_context.hxx>
+ 
+ #include "vbaapplication.hxx"
+ #include "vbaworksheet.hxx"
+@@ -49,11 +50,10 @@ using namespace ::ooo::vba;
+ // ScVbaGlobals
+ // =============================================================================
+ 
+-ScVbaGlobals::ScVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext )
+-        :m_xContext( rxContext )
++ScVbaGlobals::ScVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
+ {
+ 	OSL_TRACE("ScVbaGlobals::ScVbaGlobals()");
+-	mxApplication = uno::Reference< excel::XApplication > ( new ScVbaApplication( m_xContext) );
++        init( rxContext, uno::Any( getApplication() ) );
+ }
+ 
+ ScVbaGlobals::~ScVbaGlobals()
+@@ -61,23 +61,6 @@ ScVbaGlobals::~ScVbaGlobals()
+ 	OSL_TRACE("ScVbaGlobals::~ScVbaGlobals");
+ }
+ 
+-// Will throw if singleton can't be accessed 
+-uno::Reference< XGlobals >
+-ScVbaGlobals::getGlobalsImpl( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException )
+-{
+-	uno::Reference< XGlobals > xGlobals( 
+-		xContext->getValueByName( ::rtl::OUString::createFromAscii( 
+-			"/singletons/ooo.vba.theGlobals") ), uno::UNO_QUERY);
+-
+-	if ( !xGlobals.is() )
+-	{
+-		throw uno::RuntimeException(
+-                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": Couldn't access Globals" ) ),
+-                    uno::Reference< XInterface >() );
+-	}
+-	return xGlobals;
+-}
+-
+ // =============================================================================
+ // XGlobals
+ // =============================================================================
+@@ -85,14 +68,15 @@ uno::Reference<excel::XApplication >
+ ScVbaGlobals::getApplication() throw (uno::RuntimeException)
+ {
+ //	OSL_TRACE("In ScVbaGlobals::getApplication");	
+-    return mxApplication;
++	static  uno::Reference< excel::XApplication > ExcelApplication( new ScVbaApplication( mxContext) );
++   	return ExcelApplication; 
+ }
+ 
+ uno::Reference< excel::XWorkbook > SAL_CALL 
+ ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
+ {
+ //	OSL_TRACE("In ScVbaGlobals::getActiveWorkbook");	
+-    uno::Reference< excel::XWorkbook > xWorkbook( mxApplication->getActiveWorkbook(), uno::UNO_QUERY);
++    uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_QUERY);
+     if ( xWorkbook.is() )
+     {
+         return xWorkbook;    
+@@ -103,22 +87,28 @@ ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
+ }
+ 
+ 
++uno::Reference< excel::XWindow > SAL_CALL 
++ScVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
++{
++    return getApplication()->getActiveWindow();
++}
++
+ uno::Reference< excel::XWorksheet > SAL_CALL 
+ ScVbaGlobals::getActiveSheet() throw (uno::RuntimeException)
+ {
+-    return mxApplication->getActiveSheet();
++    return getApplication()->getActiveSheet();
+ }
+ 
+ uno::Any SAL_CALL 
+ ScVbaGlobals::WorkBooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+ {
+-	return uno::Any( mxApplication->Workbooks(aIndex) );
++	return uno::Any( getApplication()->Workbooks(aIndex) );
+ }
+ 
+ uno::Any SAL_CALL
+ ScVbaGlobals::WorkSheets(const uno::Any& aIndex) throw (uno::RuntimeException)
+ {
+-	return mxApplication->Worksheets( aIndex );
++	return getApplication()->Worksheets( aIndex );
+ }
+ uno::Any SAL_CALL
+ ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+@@ -126,26 +116,6 @@ ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+ 	return WorkSheets( aIndex );
+ }
+ 
+-::uno::Sequence< ::uno::Any > SAL_CALL
+-ScVbaGlobals::getGlobals(  ) throw (::uno::RuntimeException)
+-{
+-	sal_uInt32 nMax = 0;
+-	uno::Sequence< uno::Any > maGlobals(4);
+-	maGlobals[ nMax++ ] <<= ScVbaGlobals::getGlobalsImpl(m_xContext);
+-	maGlobals[ nMax++ ] <<= mxApplication;
+-
+-	uno::Reference< excel::XWorkbook > xWorkbook = mxApplication->getActiveWorkbook();
+-	if( xWorkbook.is() )
+-	{
+-		maGlobals[ nMax++ ] <<= xWorkbook;
+-		uno::Reference< excel::XWorksheet > xWorksheet = xWorkbook->getActiveSheet();
+-		if( xWorksheet.is() )
+-			maGlobals[ nMax++ ] <<= xWorksheet;
+-	}
+-	maGlobals.realloc( nMax );
+-	return maGlobals;
+-}
+-
+ uno::Any SAL_CALL 
+ ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
+ {
+@@ -158,13 +128,140 @@ ScVbaGlobals::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException
+ 	return getApplication()->Names( aIndex );
+ }
+ 
++uno::Reference< excel::XRange > SAL_CALL 
++ScVbaGlobals::getActiveCell() throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveCell();
++}
++
++uno::Reference< XAssistant > SAL_CALL 
++ScVbaGlobals::getAssistant() throw (uno::RuntimeException)
++{
++	return getApplication()->getAssistant();
++}
++
++uno::Any SAL_CALL 
++ScVbaGlobals::getSelection() throw (uno::RuntimeException)
++{
++	return getApplication()->getSelection();
++}
++
++uno::Reference< excel::XWorkbook > SAL_CALL 
++ScVbaGlobals::getThisWorkbook() throw (uno::RuntimeException)
++{
++	return getApplication()->getThisWorkbook();
++}
++void SAL_CALL 
++ScVbaGlobals::Calculate()  throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
++{
++	return getApplication()->Calculate();
++}
++
++uno::Reference< excel::XRange > SAL_CALL 
++ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex ) throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
++}
++uno::Reference< excel::XRange > SAL_CALL 
++ScVbaGlobals::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveSheet()->Columns( aIndex );
++}
++
++uno::Any SAL_CALL 
++ScVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++	uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
++	return xBase->CommandBars( aIndex );
++}
++
++css::uno::Reference< ov::excel::XRange > SAL_CALL 
++ScVbaGlobals::Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++	return getApplication()->Union(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
++}
++css::uno::Reference< ov::excel::XRange > SAL_CALL 
++ScVbaGlobals::Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++	return getApplication()->Intersect(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
++}
++
++uno::Any SAL_CALL 
++ScVbaGlobals::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
++{
++	return getApplication()->Evaluate( Name );
++}
++
++css::uno::Any SAL_CALL 
++ScVbaGlobals::WorksheetFunction(  ) throw (css::uno::RuntimeException)
++{
++	return getApplication()->WorksheetFunction();
++}
++
++uno::Any SAL_CALL 
++ScVbaGlobals::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++	return getApplication()->Windows( aIndex );
++}
++
++uno::Reference< excel::XRange > SAL_CALL 
++ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveSheet()->Rows( aIndex );
++	
++}
++
++uno::Sequence< ::rtl::OUString > SAL_CALL 
++ScVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
++{
++    static bool bInit = false;
++    static uno::Sequence< rtl::OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() );
++    if ( !bInit )
++    {
++         rtl::OUString names[] = { 
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Range" ) ),
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Workbook" ) ),
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Window" ) ),
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ),
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ),
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ),
++          };
++        sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) );
++        sal_Int32 startIndex = serviceNames.getLength();
++        serviceNames.realloc( serviceNames.getLength() + nExcelServices );
++        for ( sal_Int32 index = 0; index < nExcelServices; ++index )
++             serviceNames[ startIndex + index ] = names[ index ];
++        bInit = true;
++    }
++    return serviceNames;
++}
++
++rtl::OUString&
++ScVbaGlobals::getServiceImplName()
++{
++        static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaGlobals") );
++        return sImplName;
++}
++
++uno::Sequence< rtl::OUString >
++ScVbaGlobals::getServiceNames()
++{
++        static uno::Sequence< rtl::OUString > aServiceNames;
++        if ( aServiceNames.getLength() == 0 )
++        {
++                aServiceNames.realloc( 1 );
++                aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Globals" ) );
++        }
++        return aServiceNames;
++}
++
+ namespace globals
+ {
+ namespace sdecl = comphelper::service_decl;
+-sdecl::class_<ScVbaGlobals, sdecl::with_args<false> > serviceImpl;
++sdecl::vba_service_class_<ScVbaGlobals, sdecl::with_args<false> > serviceImpl;
+ extern sdecl::ServiceDecl const serviceDecl(
+     serviceImpl,
+     "ScVbaGlobals",
+-    "ooo.vba.Globals" );
++    "ooo.vba.excel.Globals" );
+ }
+ 
 diff --git sc/source/ui/vba/vbaglobals.hxx sc/source/ui/vba/vbaglobals.hxx
-index 0e9e3a5..ee33026 100644
+index 0e9e3a5..89861ee 100644
 --- sc/source/ui/vba/vbaglobals.hxx
 +++ sc/source/ui/vba/vbaglobals.hxx
-@@ -36,7 +36,7 @@
- #include <ooo/vba/XGlobals.hpp>
+@@ -33,43 +33,62 @@
+ #include <com/sun/star/lang/XServiceInfo.hpp>
+ #include <com/sun/star/lang/XInitialization.hpp>
+ #include <com/sun/star/uno/XComponentContext.hpp>
+-#include <ooo/vba/XGlobals.hpp>
++#include <ooo/vba/excel/XGlobals.hpp>
++#include <ooo/vba/excel/XApplication.hpp>
  
  #include <cppuhelper/implbase1.hxx>
 -#include "vbahelper.hxx"
 +#include "excelvbahelper.hxx"
  
++#include <vbahelper/vbaglobalbase.hxx>
      // =============================================================================
      // class ScVbaGlobals
+     // =============================================================================
+ 
+-    typedef ::cppu::WeakImplHelper1<    
+- ov::XGlobals > ScVbaGlobals_BASE;
+-
++typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > ScVbaGlobals_BASE;
+ 
+     class ScVbaGlobals : public ScVbaGlobals_BASE
+     {
+-    private:
+-            css::uno::Reference< css::uno::XComponentContext > m_xContext;
+-            css::uno::Reference< ov::excel::XApplication > mxApplication;
++        virtual css::uno::Reference<
++ ov::excel::XApplication > SAL_CALL getApplication()
++                        throw (css::uno::RuntimeException);
+     public:
+ 	
+         ScVbaGlobals(
+             css::uno::Reference< css::uno::XComponentContext >const& rxContext );
+         virtual ~ScVbaGlobals();
+ 
+-		static 	css::uno::Reference< ov::XGlobals > getGlobalsImpl(const css::uno::Reference< css::uno::XComponentContext >& ) throw (css::uno::RuntimeException);
+-
+         // XGlobals
+-        virtual css::uno::Reference<
+- ov::excel::XApplication > SAL_CALL getApplication()
+-                        throw (css::uno::RuntimeException);
+         virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getActiveWorkbook() throw (css::uno::RuntimeException);
++        virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
+         virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Calculate(  ) throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException);
++
++	virtual css::uno::Any SAL_CALL getSelection() throw (css::uno::RuntimeException);
++        virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any& RowIndex, const css::uno::Any& ColumnIndex ) throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
++	virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
++	virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name ) throw (css::uno::RuntimeException);
++
+         virtual css::uno::Any SAL_CALL WorkSheets(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+         virtual css::uno::Any SAL_CALL WorkBooks(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
++	virtual css::uno::Any SAL_CALL WorksheetFunction(  ) throw (css::uno::RuntimeException);
++	virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+-	virtual css::uno::Sequence< css::uno::Any > SAL_CALL getGlobals(  ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< ::ooo::vba::excel::XRange > SAL_CALL Rows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException );
++	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorEx
 ception, css::uno::RuntimeException);
++	virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorExcept
 ion, css::uno::RuntimeException);
++
++
++
++    // XMultiServiceFactory
++    virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames(  ) throw (css::uno::RuntimeException);
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+     };
+ #endif // 
 diff --git sc/source/ui/vba/vbahelper.cxx sc/source/ui/vba/vbahelper.cxx
 deleted file mode 100644
-index 5e5f6e6..0000000
+index c26a515..0000000
 --- sc/source/ui/vba/vbahelper.cxx
 +++ /dev/null
-@@ -1,818 +0,0 @@
+@@ -1,828 +0,0 @@
 -/*************************************************************************
 - *
 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -3967,6 +8582,7 @@
 -#include "scmod.hxx"
 -#include "vbashape.hxx"
 -#include "unonames.hxx"
+-#include "cellsuno.hxx"
 -using namespace ::com::sun::star;
 -using namespace ::ooo::vba;
 -
@@ -4721,14 +9337,23 @@
 -    {
 -	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	SC_UNONAME_CELLWID ) ), uno::makeAny(  Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
 -    }
+-
+-SfxItemSet*
+-ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj )
+-{
+-	SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ;
+-	return pDataSet;
+-	
+-}
+-
 -} // openoffice
 -} //org
 diff --git sc/source/ui/vba/vbahelper.hxx sc/source/ui/vba/vbahelper.hxx
 deleted file mode 100644
-index 6ba5f16..0000000
+index 9dbda9b..0000000
 --- sc/source/ui/vba/vbahelper.hxx
 +++ /dev/null
-@@ -1,344 +0,0 @@
+@@ -1,352 +0,0 @@
 -/*************************************************************************
 - *
 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -4774,6 +9399,7 @@
 -#include <docsh.hxx>
 -#include <sfx2/dispatch.hxx>
 -#include <ooo/vba/msforms/XShape.hpp>
+-#include "cellsuno.hxx"
 -
 -namespace css = ::com::sun::star;
 -
@@ -4824,6 +9450,13 @@
 -	double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
 -	double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
 -
+-
+-class ScVbaCellRangeAccess
+-{
+-public:
+-    static SfxItemSet* GetDataSet( ScCellRangeObj* pRangeObj );
+-};
+-
 -class Millimeter
 -{
 -//Factor to translate between points and hundredths of millimeters:
@@ -5527,10 +10160,10 @@
  
 diff --git sc/source/ui/vba/vbalistbox.cxx sc/source/ui/vba/vbalistbox.cxx
 deleted file mode 100644
-index a0fd7ce..0000000
+index e624409..0000000
 --- sc/source/ui/vba/vbalistbox.cxx
 +++ /dev/null
-@@ -1,287 +0,0 @@
+@@ -1,289 +0,0 @@
 -/*************************************************************************
 - *
 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -5683,11 +10316,13 @@
 -    uno::Sequence< rtl::OUString > sList;
 -    m_xProps->getPropertyValue( ITEMS ) >>= sList;
 -    sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
--    sal_Int16 nIndex( index );
+-    // no choice but to do a horror cast as internally
+-    // the indices are but sal_Int16 
+-    sal_Int16 nIndex = static_cast< sal_Int16 >( index );
 -    if( nIndex < 0 || nIndex >= nLength )
 -        throw uno::RuntimeException( rtl::OUString::createFromAscii(
 -                    "Error Number." ), uno::Reference< uno::XInterface >() );
--    m_nIndex = static_cast< sal_Int16 >( index );
+-    m_nIndex = nIndex;
 -    return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
 -}
 -
@@ -5700,9 +10335,9 @@
 -
 -void SAL_CALL 
 -ScVbaListBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
--		{
+-{
 -	mpListHelper->removeItem( index );
--		}
+-}
 -
 -void SAL_CALL 
 -ScVbaListBox::Clear(  ) throw (uno::RuntimeException)
@@ -6067,7 +10702,7 @@
 -}
 diff --git sc/source/ui/vba/vbalistcontrolhelper.hxx sc/source/ui/vba/vbalistcontrolhelper.hxx
 deleted file mode 100644
-index 5e4684c..0000000
+index 34d42ce..0000000
 --- sc/source/ui/vba/vbalistcontrolhelper.hxx
 +++ /dev/null
 @@ -1,20 +0,0 @@
@@ -6082,7 +10717,7 @@
 -
 -public:
 -	ListControlHelper( const css::uno::Reference< css::beans::XPropertySet >& rxControl ) : m_xProps( rxControl ){}
--
+-	virtual ~ListControlHelper() {}
 -	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 setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
@@ -6231,7 +10866,7 @@
 -}
 diff --git sc/source/ui/vba/vbamultipage.hxx sc/source/ui/vba/vbamultipage.hxx
 deleted file mode 100644
-index 3c83d6c..0000000
+index 03db35d..0000000
 --- sc/source/ui/vba/vbamultipage.hxx
 +++ /dev/null
 @@ -1,65 +0,0 @@
@@ -6290,7 +10925,7 @@
 -    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 );
 -   // Attributes
 -    virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException);
--    virtual void SAL_CALL setValue( const sal_Int32 _value ) throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException);
 -    virtual css::uno::Any SAL_CALL Pages( const css::uno::Any& index ) throw (css::uno::RuntimeException);
 -
 -    //XHelperInterface
@@ -6301,7 +10936,7 @@
 -};
 -#endif //SC_VBA_LABEL_HXX
 diff --git sc/source/ui/vba/vbaname.cxx sc/source/ui/vba/vbaname.cxx
-index 3fdc003..3e7b713 100644
+index 3fbee5e..177e414 100644
 --- sc/source/ui/vba/vbaname.cxx
 +++ sc/source/ui/vba/vbaname.cxx
 @@ -27,7 +27,7 @@
@@ -6313,6 +10948,25 @@
  
  #include <com/sun/star/table/XCellRange.hpp>
  #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+@@ -64,7 +64,8 @@ ScVbaName::~ScVbaName()
+ css::uno::Reference< ov::excel::XWorksheet >
+ ScVbaName::getWorkSheet() throw (css::uno::RuntimeException)
+ {
+-	return ScVbaGlobals::getGlobalsImpl( mxContext )->getActiveSheet();
++	uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++	return xApplication->getActiveSheet();
+ }
+ 
+ ::rtl::OUString
+@@ -234,7 +235,7 @@ ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css:
+ css::uno::Reference< ov::excel::XRange >
+ ScVbaName::getRefersToRange() throw (css::uno::RuntimeException)
+ {
+-    uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( mxContext, mxNamedRange->getName(), getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
++    uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
+ 	return xRange;
+ }
+ 
 diff --git sc/source/ui/vba/vbaname.hxx sc/source/ui/vba/vbaname.hxx
 index fcd1a7d..6370d64 100644
 --- sc/source/ui/vba/vbaname.hxx
@@ -6329,7 +10983,7 @@
  typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE;
  
 diff --git sc/source/ui/vba/vbanames.cxx sc/source/ui/vba/vbanames.cxx
-index 1e40d55..c69d29b 100644
+index 1e40d55..e11d9ad 100644
 --- sc/source/ui/vba/vbanames.cxx
 +++ sc/source/ui/vba/vbanames.cxx
 @@ -27,7 +27,7 @@
@@ -6341,6 +10995,15 @@
  
  #include <com/sun/star/table/XCellRange.hpp>
  #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+@@ -81,7 +81,7 @@ ScDocument *
+ ScVbaNames::getScDocument()
+ {
+ 	uno::Reference< frame::XModel > xModel( getModel() , uno::UNO_QUERY_THROW );
+-	ScTabViewShell * pTabViewShell = getBestViewShell( xModel );
++	ScTabViewShell * pTabViewShell = excel::getBestViewShell( xModel );
+ 	if ( !pTabViewShell )
+ 		throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
+ 	ScViewData* pViewData = pTabViewShell->GetViewData();
 diff --git sc/source/ui/vba/vbanames.hxx sc/source/ui/vba/vbanames.hxx
 index 5b53ab0..5f93b7b 100644
 --- sc/source/ui/vba/vbanames.hxx
@@ -6399,10 +11062,10 @@
  typedef InheritedHelperInterfaceImpl1< ov::excel::XOutline > ScVbaOutline_BASE;
  
 diff --git sc/source/ui/vba/vbapagebreak.hxx sc/source/ui/vba/vbapagebreak.hxx
-index a07cfda..a353edb 100644
+index 04c8702..6150aa6 100644
 --- sc/source/ui/vba/vbapagebreak.hxx
 +++ sc/source/ui/vba/vbapagebreak.hxx
-@@ -38,7 +38,7 @@
+@@ -39,7 +39,7 @@
  #include <com/sun/star/script/BasicErrorException.hpp>
  #include <com/sun/star/sheet/TablePageBreakData.hpp>
  #include <com/sun/star/beans/XPropertySet.hpp>
@@ -6412,10 +11075,10 @@
  template< typename Ifc1 >
  class ScVbaPageBreak : public InheritedHelperInterfaceImpl1< Ifc1 >
 diff --git sc/source/ui/vba/vbapagebreaks.hxx sc/source/ui/vba/vbapagebreaks.hxx
-index 530d82a..ac99ddf 100644
+index cc2a642..a435ddc 100644
 --- sc/source/ui/vba/vbapagebreaks.hxx
 +++ sc/source/ui/vba/vbapagebreaks.hxx
-@@ -41,8 +41,8 @@
+@@ -43,8 +43,8 @@
  #include <com/sun/star/beans/XPropertySet.hpp>
  #include <com/sun/star/container/XIndexAccess.hpp>
  #include <com/sun/star/table/XColumnRowRange.hpp>
@@ -6584,7 +11247,7 @@
 -};
 -#endif//SC_VBA_SHAPE_HXX
 diff --git sc/source/ui/vba/vbapagesetup.cxx sc/source/ui/vba/vbapagesetup.cxx
-index 33d3128..c8974a6 100644
+index 5bd66d1..a859e74 100644
 --- sc/source/ui/vba/vbapagesetup.cxx
 +++ sc/source/ui/vba/vbapagesetup.cxx
 @@ -31,6 +31,7 @@
@@ -6595,6 +11258,24 @@
  #include <com/sun/star/sheet/XPrintAreas.hpp>
  #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
  #include <com/sun/star/text/XText.hpp>
+@@ -85,7 +86,7 @@ rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeEx
+ 			ScUnoConversion::FillScRange( aRange, aSeq[i] );
+ 			aRangeList.Append( aRange );
+ 		}
+-		ScDocument* pDoc = getDocShell( mxModel )->GetDocument();
++		ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument();
+ 		aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ','  );
+     }
+     
+@@ -106,7 +107,7 @@ void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw
+     {
+ 		ScRangeList aCellRanges;
+ 		ScRange aRange;
+-		if( getScRangeListForAddress( rAreas, getDocShell( mxModel ) , aRange, aCellRanges ) ) 
++		if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) ) 
+ 		{
+ 			uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.Count() );
+ 			USHORT i=0;
 diff --git sc/source/ui/vba/vbapagesetup.hxx sc/source/ui/vba/vbapagesetup.hxx
 index e60fc07..0026197 100644
 --- sc/source/ui/vba/vbapagesetup.hxx
@@ -7029,7 +11710,7 @@
 -};
 -#endif //SC_VBA_RADIOBUTTON_HXX
 diff --git sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbarange.cxx
-index 6b510ff..e243410 100644
+index a052262..eab272a 100644
 --- sc/source/ui/vba/vbarange.cxx
 +++ sc/source/ui/vba/vbarange.cxx
 @@ -27,7 +27,7 @@
@@ -7039,28 +11720,151 @@
 -#include "helperdecl.hxx"
 +#include <vbahelper/helperdecl.hxx>
  
- #include <comphelper/unwrapargs.hxx>
- #include <comphelper/processfactory.hxx>
-@@ -159,7 +159,7 @@
- #include "vbaglobals.hxx"
- #include "vbastyle.hxx"
- #include <vector>
--#include <vbacollectionimpl.hxx>
-+#include <vbahelper/vbacollectionimpl.hxx>
- // begin test includes
- #include <com/sun/star/sheet/FunctionArgument.hpp>
- // end test includes
-@@ -4708,7 +4708,7 @@ ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any&
+ #include <comphelper/unwrapargs.hxx>
+ #include <comphelper/processfactory.hxx>
+@@ -146,7 +146,6 @@
+ #include "rangelst.hxx"
+ #include "convuno.hxx"
+ #include "compiler.hxx"
+-#include "formula/grammar.hxx"
+ #include "attrib.hxx"
+ #include "undodat.hxx"
+ #include "dbdocfun.hxx"
+@@ -159,7 +158,7 @@
+ #include "vbaglobals.hxx"
+ #include "vbastyle.hxx"
+ #include <vector>
+-#include <vbacollectionimpl.hxx>
++#include <vbahelper/vbacollectionimpl.hxx>
+ // begin test includes
+ #include <com/sun/star/sheet/FunctionArgument.hpp>
+ // end test includes
+@@ -253,7 +252,8 @@ ScCellRangeObj*  ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException )
+ SfxItemSet*  ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException )
+ {
+ 	ScCellRangeObj* pUnoCellRange = getCellRangeObj();
+-	SfxItemSet* pDataSet = ScVbaCellRangeAccess::GetDataSet( pUnoCellRange );
++	SfxItemSet* pDataSet = 	pUnoCellRange ? pUnoCellRange->GetCurrentDataSet( true ) : NULL ;
++
+ 	if ( !pDataSet )
+ 		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for range" ) ), uno::Reference< uno::XInterface >() );
+ 	return pDataSet;	
+@@ -470,7 +470,7 @@ public:
+ 		if ( pUnoCellRange )
+ 		{
+ 			
+-			SfxItemSet* pDataSet = 	ScVbaCellRangeAccess::GetDataSet( pUnoCellRange );
++			SfxItemSet* pDataSet = 	pUnoCellRange->GetCurrentDataSet( true );
+ 			SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, TRUE, NULL);
+ 			// one of the cells in the range is not like the other ;-)
+ 			// so return a zero length format to indicate that
+@@ -1999,7 +1999,7 @@ bool cellInRange( const table::CellRangeAddress& rAddr, const sal_Int32& nCol, c
+ 
+ void setCursor(  const SCCOL& nCol, const SCROW& nRow, bool bInSel = true )
+ {
+-	ScTabViewShell* pShell = getCurrentBestViewShell();
++	ScTabViewShell* pShell = excel::getCurrentBestViewShell();
+ 	if ( pShell )
+ 	{
+ 		if ( bInSel )
+@@ -2210,7 +2210,7 @@ ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException)
+ 	else
+ 	{
+ 		Select();
+-		implnCopy();
++		excel::implnCopy();
+ 	}
+ }
+ 
+@@ -2234,7 +2234,7 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
+ 	}
+ 	{
+ 		Select();
+-		implnCut();
++		excel::implnCut();
+ 	}
+ }
+                                                                                                                              
+@@ -2564,7 +2564,7 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons
+ 
+ 	USHORT nFlags = getPasteFlags(nPaste);
+ 	USHORT nFormulaBits = getPasteFormulaBits(nOperation);
+-	implnPasteSpecial(nFlags,nFormulaBits,bSkipBlanks,bTranspose);
++	excel::implnPasteSpecial(nFlags,nFormulaBits,bSkipBlanks,bTranspose);
+ 	// restore selection
+ 	xSelection->select( uno::makeAny( xSel ) );
+ }
+@@ -3233,13 +3233,13 @@ ScVbaRange::End( ::sal_Int32 Direction )  throw (uno::RuntimeException)
+ 	
+ 	// Save ActiveCell pos ( to restore later )
+ 	uno::Any aDft;
+-	rtl::OUString sActiveCell =	ScVbaGlobals::getGlobalsImpl(
+-                       mxContext )->getApplication()->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
++	uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++	rtl::OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
+ 
+ 	// position current cell upper left of this range
+ 	Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select();
+ 
+-	SfxViewFrame* pViewFrame = getCurrentViewFrame();
++	SfxViewFrame* pViewFrame = excel::getCurrentViewFrame();
+ 	if ( pViewFrame )
+ 	{
+ 		SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+@@ -3275,18 +3275,17 @@ ScVbaRange::End( ::sal_Int32 Direction )  throw (uno::RuntimeException)
+ 	}
+ 
+ 	// result is the ActiveCell		
+-	rtl::OUString sMoved =	ScVbaGlobals::getGlobalsImpl(
+-                       mxContext )->getApplication()->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
++	rtl::OUString sMoved =	xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
+ 
+ 	// restore old ActiveCell		
+ 	uno::Any aVoid;
+-	uno::Reference< excel::XRange > xOldActiveCell( ScVbaGlobals::getGlobalsImpl(
+-		mxContext )->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW );
++
++	uno::Reference< excel::XRange > xOldActiveCell( xApplication->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW );
+ 	xOldActiveCell->Select();
+ 
+ 	uno::Reference< excel::XRange > resultCell;
+-	resultCell.set( ScVbaGlobals::getGlobalsImpl(
+-		mxContext )->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
++	
++	resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
+ 
+ 	// return result
+ 	
+@@ -3749,7 +3748,7 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti
+ 		uno::Reference< frame::XModel > xModel = pShell->GetModel();
+ 		if ( xModel.is() )
+ 		{
+-			ScTabViewShell* pViewShell = getBestViewShell( xModel );
++			ScTabViewShell* pViewShell = excel::getBestViewShell( xModel );
+ 			if ( nPageBreak == excel::XlPageBreak::xlPageBreakManual )
+ 			    pViewShell->InsertPageBreak( bColumn, TRUE, &aAddr);
+ 			else if ( nPageBreak == excel::XlPageBreak::xlPageBreakNone )
+@@ -4711,7 +4710,7 @@ ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any&
  		{
  			xPrintAreas->setPrintAreas( printAreas );
  			uno::Reference< frame::XModel > xModel = pShell->GetModel();
 -			PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, xModel, sal_True );
-+			PrintOutHelper( getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
++			PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
  		}
  	}
  }
+@@ -5362,7 +5361,8 @@ sal_Bool SAL_CALL
+ ScVbaRange::hasError() throw (uno::RuntimeException)
+ {
+     double dResult = sal_False;
+-    uno::Reference< script::XInvocation > xInvoc( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication()->WorksheetFunction(), uno::UNO_QUERY_THROW );
++    uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++    uno::Reference< script::XInvocation > xInvoc( xApplication->WorksheetFunction(), uno::UNO_QUERY_THROW );
+ 
+     static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("IsError" ) );
+     uno::Sequence< uno::Any > Params(1);
 diff --git sc/source/ui/vba/vbarange.hxx sc/source/ui/vba/vbarange.hxx
-index f9e4186..57fda33 100644
+index 0df668c..4bbf3fe 100644
 --- sc/source/ui/vba/vbarange.hxx
 +++ sc/source/ui/vba/vbarange.hxx
 @@ -53,12 +53,15 @@
@@ -7070,13 +11874,13 @@
 -//#include "vbahelperinterface.hxx"
 +//#include <vbahelper/vbahelperinterface.hxx>
  #include "vbaformat.hxx"
-+#include "address.hxx"
-+#include "grammar.hxx"
++#include <formula/grammar.hxx>
  
  class ScTableSheetsObj;
  class ScCellRangesBase;
  class ScCellRangeObj;
 +class ScDocShell;
++class ScDocument;
  
  //typedef InheritedHelperInterfaceImpl1< ov::excel::XRange >  ScVbaRange_BASE;
  typedef ScVbaFormat< ov::excel::XRange > ScVbaRange_BASE;
@@ -7793,6 +12597,19 @@
 -    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 -};
 -#endif //SC_VBA_TEXTBOX_HXX
+diff --git sc/source/ui/vba/vbatextboxshape.cxx sc/source/ui/vba/vbatextboxshape.cxx
+index 83981c8..49600d3 100644
+--- sc/source/ui/vba/vbatextboxshape.cxx
++++ sc/source/ui/vba/vbatextboxshape.cxx
+@@ -62,7 +62,7 @@ ScVbaTextBoxShape::setText( const rtl::OUString& _text ) throw (css::uno::Runtim
+ uno::Reference< excel::XCharacters > SAL_CALL 
+ ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException)
+ {
+-    ScDocShell* pDocShell = getDocShell( m_xModel );
++    ScDocShell* pDocShell = excel::getDocShell( m_xModel );
+     ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+ 
+     if ( !pDoc )
 diff --git sc/source/ui/vba/vbatextboxshape.hxx sc/source/ui/vba/vbatextboxshape.hxx
 index 8a3b62b..c923329 100644
 --- sc/source/ui/vba/vbatextboxshape.hxx
@@ -7820,10 +12637,10 @@
  
  typedef InheritedHelperInterfaceImpl1< ov::excel::XTextFrame > ScVbaTextFrame_BASE;
 diff --git sc/source/ui/vba/vbatitle.hxx sc/source/ui/vba/vbatitle.hxx
-index fb35d8e..1553199 100644
+index fb35d8e..f73b16a 100644
 --- sc/source/ui/vba/vbatitle.hxx
 +++ sc/source/ui/vba/vbatitle.hxx
-@@ -30,8 +30,8 @@
+@@ -30,14 +30,15 @@
  #ifndef SC_VBA_TITLE_HXX
  #define SC_VBA_TITLE_HXX
  
@@ -7834,6 +12651,13 @@
  #include "vbainterior.hxx"
  #include "vbafont.hxx"
  #include "vbapalette.hxx"
+ #include <com/sun/star/drawing/XShape.hpp>
+ #include <com/sun/star/beans/XPropertySet.hpp>
+ #include <ooo/vba/excel/XTitle.hpp>
++#include <ooo/vba/excel/XCharacters.hpp>
+ #include <basic/sberrors.hxx>
+ #include <memory>
+ 
 diff --git sc/source/ui/vba/vbatogglebutton.cxx sc/source/ui/vba/vbatogglebutton.cxx
 deleted file mode 100644
 index f938ad1..0000000
@@ -8058,892 +12882,9850 @@
 - *
 - ************************************************************************/
 -#include "helperdecl.hxx"
--#include "vbauserform.hxx"
--#include <com/sun/star/awt/XControl.hpp>
--#include <com/sun/star/awt/XControlContainer.hpp>
--#include <com/sun/star/beans/PropertyConcept.hpp>
--#include <basic/sbx.hxx>
--#include <basic/sbstar.hxx>
--#include <basic/sbmeth.hxx>
--#include "unonames.hxx"
--#include "vbacontrols.hxx"
+-#include "vbauserform.hxx"
+-#include <com/sun/star/awt/XControl.hpp>
+-#include <com/sun/star/awt/XControlContainer.hpp>
+-#include <com/sun/star/beans/PropertyConcept.hpp>
+-#include <basic/sbx.hxx>
+-#include <basic/sbstar.hxx>
+-#include <basic/sbmeth.hxx>
+-#include "unonames.hxx"
+-#include "vbacontrols.hxx"
+-
+-using namespace ::ooo::vba;
+-using namespace ::com::sun::star;
+-
+-// some little notes
+-// XDialog implementation has the following interesting bits
+-// a Controls property ( which is an array of the container controls )
+-//   each item in the controls array is a XControl, where the model is 
+-//   basically a property bag
+-// additionally the XDialog instance has itself a model
+-//     this model has a ControlModels ( array of models ) property
+-//     the models in ControlModels can be accessed by name
+-// also the XDialog is a XControl ( to access the model above
+-
+-ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) :  ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), static_cast< ooo::vba::AbstractGeometryAttributes* >(0) ), m_pDocShell( 0 ), mbDispose( true )
+-{
+-    m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW );
+-    uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
+-    m_pDocShell = getDocShell( m_xModel );
+-    m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
+-    setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) );
+-}
+-
+-ScVbaUserForm::~ScVbaUserForm()
+-{
+-}
+-
+-void SAL_CALL 
+-ScVbaUserForm::Show(  ) throw (uno::RuntimeException)
+-{
+-	OSL_TRACE("ScVbaUserForm::Show(  )");
+-	short aRet = 0;
+-	if ( m_xDialog.is() )
+-		aRet = m_xDialog->execute();
+-	OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
+-	if ( mbDispose )
+-	{
+-		try
+-		{
+-			uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
+-			m_xDialog = NULL;
+-			xComp->dispose();
+-			mbDispose = false; 
+-		}
+-		catch( uno::Exception& )
+-		{
+-		}
+-	}
+-}
+-
+-rtl::OUString SAL_CALL 
+-ScVbaUserForm::getCaption() throw (::com::sun::star::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)
+-{
+-    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
+-}
+-
+-void SAL_CALL 
+-ScVbaUserForm::Hide(  ) throw (uno::RuntimeException)
+-{
+-	mbDispose = false;  // hide not dispose
+-	if ( m_xDialog.is() )
+-		m_xDialog->endExecute();
+-}
+-
+-void SAL_CALL 
+-ScVbaUserForm::RePaint(  ) throw (uno::RuntimeException)
+-{
+-	// do nothing
+-}
+-
+-void SAL_CALL 
+-ScVbaUserForm::UnloadObject(  ) throw (uno::RuntimeException)
+-{
+-	mbDispose = true;
+-	if ( m_xDialog.is() )
+-		m_xDialog->endExecute();
+-}
+-
+-rtl::OUString& 
+-ScVbaUserForm::getServiceImplName()
+-{
+-	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
+-	return sImplName;
+-}
+-
+-uno::Sequence< rtl::OUString > 
+-ScVbaUserForm::getServiceNames()
+-{
+-	static uno::Sequence< rtl::OUString > aServiceNames;
+-	if ( aServiceNames.getLength() == 0 )
+-	{
+-		aServiceNames.realloc( 1 );
+-		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm" ) );
+-	}
+-	return aServiceNames;
+-}
+-
+-uno::Reference< beans::XIntrospectionAccess > SAL_CALL 
+-ScVbaUserForm::getIntrospection(  ) throw (uno::RuntimeException)
+-{
+-	return uno::Reference< beans::XIntrospectionAccess >();
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+-{
+-	throw uno::RuntimeException(); // unsupported operation
+-}
+-
+-void SAL_CALL 
+-ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+-{
+-	uno::Any aObject = getValue( aPropertyName );
+-	// The Object *must* support XDefaultProperty here because getValue will
+-	// only return properties that are Objects ( e.g. controls )
+-	// e.g. Userform1.aControl = something
+-	// 'aControl' has to support XDefaultProperty to make sense here
+-	uno::Reference< script::XDefaultProperty > xDfltProp( aObject, uno::UNO_QUERY_THROW );
+-	rtl::OUString aDfltPropName = xDfltProp->getDefaultPropertyName();
+-	uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) );
+-	uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY_THROW );
+-	xPropSet->setPropertyValue( aDfltPropName, aValue );
+-}
+-
+-uno::Any SAL_CALL 
+-ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+-{
+-	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
+-	uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
+-	uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
+-	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 ) );
+-	return uno::makeAny( xVBAControl );
+-}
+-
+-::sal_Bool SAL_CALL 
+-ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
+-{
+-	return sal_False;
+-}
+-uno::Any SAL_CALL 
+-ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
+-{
+-	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
+-	uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
+-	if ( index.hasValue() )
+-		return uno::makeAny( xControls->Item( index, uno::Any() ) );
+-	return uno::makeAny( xControls );
+-}
+-
+-::sal_Bool SAL_CALL 
+-ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+-{
+-	uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
+-	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() );
+-	if ( xControl.is() )
+-	{
+-		uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );	
+-		sal_Bool bRes =  xNameAccess->hasByName( aName );
+-	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes );
+-		return bRes;
+-	}
+-	return sal_False;
+-}
+-
+-namespace userform
+-{
+-namespace sdecl = comphelper::service_decl;
+-sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl;
+-extern sdecl::ServiceDecl const serviceDecl(
+-    serviceImpl,
+-    "ScVbaUserForm",
+-    "ooo.vba.excel.UserForm" );
+-}
+-
+diff --git sc/source/ui/vba/vbauserform.hxx sc/source/ui/vba/vbauserform.hxx
+deleted file mode 100644
+index 2c8a1b7..0000000
+--- sc/source/ui/vba/vbauserform.hxx
++++ /dev/null
+@@ -1,78 +0,0 @@
+-/*************************************************************************
+- *
+- *  OpenOffice.org - a multi-platform office productivity suite
+- *
+- *  $RCSfile$
+- *
+- *  $Revision$
+- *
+- *  last change: $Author$ $Date$
+- *
+- *  The Contents of this file are made available subject to
+- *  the terms of GNU Lesser General Public License Version 2.1.
+- *
+- *
+- *    GNU Lesser General Public License Version 2.1
+- *    =============================================
+- *    Copyright 2005 by Sun Microsystems, Inc.
+- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+- *
+- *    This library is free software; you can redistribute it and/or
+- *    modify it under the terms of the GNU Lesser General Public
+- *    License version 2.1, as published by the Free Software Foundation.
+- *
+- *    This library 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 for more details.
+- *
+- *    You should have received a copy of the GNU Lesser General Public
+- *    License along with this library; if not, write to the Free Software
+- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+- *    MA  02111-1307  USA
+- *
+- ************************************************************************/
+-#ifndef SC_VBA_USERFORM_HXX
+-#define SC_VBA_USERFORM_HXX
+-
+-#include <cppuhelper/implbase1.hxx>
+-#include <ooo/vba/msforms/XUserForm.hpp>
+-#include <com/sun/star/awt/XDialog.hpp>
+-#include <com/sun/star/frame/XModel.hpp>
+-
+-#include "vbahelperinterface.hxx"
+-#include "vbacontrol.hxx"
+-
+-//typedef InheritedHelperInterfaceImpl1< ov::msforms::XUserForm > ScVbaUserForm_BASE;
+-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE;
+-
+-class ScVbaUserForm : public ScVbaUserForm_BASE
+-{
+-private:
+-    css::uno::Reference< css::awt::XDialog > m_xDialog;
+-    ScDocShell* m_pDocShell;
+-    bool mbDispose;
+-protected:
+-public:
+-    ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
+-    virtual ~ScVbaUserForm();
+-    // 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 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);
+-    //XHelperInterface
+-    virtual rtl::OUString& getServiceImplName();
+-    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+-};
+-#endif
+diff --git sc/source/ui/vba/vbavalidation.hxx sc/source/ui/vba/vbavalidation.hxx
+index fff6b8a..445a249 100644
+--- sc/source/ui/vba/vbavalidation.hxx
++++ sc/source/ui/vba/vbavalidation.hxx
+@@ -33,7 +33,7 @@
+ #include <com/sun/star/uno/XComponentContext.hpp>
+ #include <ooo/vba/excel/XValidation.hpp>
+ #include <com/sun/star/table/XCellRange.hpp>
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
+ 
+ typedef InheritedHelperInterfaceImpl1<ov::excel::XValidation > ValidationImpl_BASE;
+ 
+diff --git sc/source/ui/vba/vbawindow.cxx sc/source/ui/vba/vbawindow.cxx
+index ea4fe9a..c64e156 100644
+--- sc/source/ui/vba/vbawindow.cxx
++++ sc/source/ui/vba/vbawindow.cxx
+@@ -27,10 +27,11 @@
+  * for a copy of the LGPLv3 License.
+  *
+  ************************************************************************/
+-#include "helperdecl.hxx"
++#include <vbahelper/helperdecl.hxx>
+ #include "vbawindow.hxx"
+ #include "vbaworksheets.hxx"
+ #include "vbaworksheet.hxx"
++#include "vbaglobals.hxx"
+ #include "vbapane.hxx"
+ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+ #include <com/sun/star/sheet/XSpreadsheet.hpp>
+@@ -118,7 +119,7 @@ public:
+ 		ScDocShell* pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
+ 		if ( !pDocShell )
+ 			throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain docshell" ) ), uno::Reference< uno::XInterface >() );
+-		ScTabViewShell* pViewShell = getBestViewShell( m_xModel );
++		ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ 		if ( !pViewShell )
+ 			throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() );
+ 			
+@@ -202,14 +203,13 @@ public:
+ 
+ };
+ 
+-ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext ), m_xModel( xModel ) 
++ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext, xModel )
+ {
+     init();
+ }
+ 
+ ScVbaWindow::ScVbaWindow( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext )  
+-        : WindowImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ),
+-          m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) )
++        : WindowImpl_BASE( args, xContext )
+ {
+     init();
+ }
+@@ -306,8 +306,7 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException)
+ 		if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() )
+ 		{
+ 			sTitle = sTitle.copy( 0, nCrudIndex );
+-            uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5
+-			ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
++			ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+ 			rtl::OUString sName = workbook.getName();
+ 			// rather bizare hack to make sure the name behavior
+ 			// is like XL
+@@ -343,7 +342,7 @@ uno::Any SAL_CALL
+ ScVbaWindow::getScrollRow() throw (uno::RuntimeException)
+ {	
+     sal_Int32 nValue = 0;
+-    ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++    ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+ 	if ( pViewShell )
+ 	{
+ 	    ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+@@ -356,7 +355,7 @@ ScVbaWindow::getScrollRow() throw (uno::RuntimeException)
+ void SAL_CALL 
+ ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException)
+ {
+-	ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++	ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+ 	if ( pViewShell )
+ 	{
+ 		sal_Int32 scrollRow = 0;	
+@@ -371,7 +370,7 @@ uno::Any SAL_CALL
+ ScVbaWindow::getScrollColumn() throw (uno::RuntimeException)
+ {	
+     sal_Int32 nValue = 0;
+-    ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++    ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+ 	if ( pViewShell )
+ 	{
+ 	    ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+@@ -384,7 +383,7 @@ ScVbaWindow::getScrollColumn() throw (uno::RuntimeException)
+ void SAL_CALL 
+ ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException)
+ {
+-	ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++	ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+ 	if ( pViewShell )
+ 	{
+ 		sal_Int32 scrollColumn = 0;	
+@@ -399,7 +398,7 @@ uno::Any SAL_CALL
+ ScVbaWindow::getWindowState() throw (uno::RuntimeException)
+ {	
+     sal_Int32 nwindowState = xlNormal;
+-    ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++    ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+     SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
+ 	SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
+ 	if ( pTop )
+@@ -421,7 +420,7 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE
+ {
+ 	sal_Int32 nwindowState = xlMaximized;
+ 	_windowstate >>= nwindowState;
+-	ScTabViewShell* pViewShell = getBestViewShell( m_xModel );	
++	ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );	
+ 	SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
+ 	SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
+ 	if ( pTop )
+@@ -444,8 +443,7 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE
+ void
+ ScVbaWindow::Activate() throw (css::uno::RuntimeException)
+ {
+-    uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5
+-	ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
++	ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+ 
+ 	workbook.Activate();
+ }
+@@ -453,8 +451,7 @@ ScVbaWindow::Activate() throw (css::uno::RuntimeException)
+ void
+ ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException)
+ {
+-    uno::Reference< ov::XGlobals > xTemp( ScVbaGlobals::getGlobalsImpl( mxContext )); // temporary needed for g++ 3.3.5
+-	ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( xTemp->getApplication(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
++	ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+ 	workbook.Close(SaveChanges, FileName, RouteWorkBook );
+ }
+ 
+@@ -467,13 +464,15 @@ ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeExcept
+ uno::Reference< excel::XRange > SAL_CALL 
+ ScVbaWindow::ActiveCell(  ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+-	return ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication()->getActiveCell();
++	uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++	return xApplication->getActiveCell();
+ }
+ 
+ uno::Any SAL_CALL 
+ ScVbaWindow::Selection(  ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+-	return ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication()->getSelection();
++	uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++	return xApplication->getSelection();
+ }
+ 
+ ::sal_Bool SAL_CALL 
+@@ -759,7 +758,8 @@ ScVbaWindow::setZoom( const uno::Any& _zoom ) throw (uno::RuntimeException)
+ uno::Reference< excel::XWorksheet > SAL_CALL 
+ ScVbaWindow::ActiveSheet(  ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+-	return ScVbaGlobals::getGlobalsImpl(mxContext)->getApplication()->getActiveSheet();
++	uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++	return xApplication->getActiveSheet();
+ }
+ 
+ uno::Any SAL_CALL
+@@ -787,121 +787,9 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException)
+ 		default:
+ 			DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ 	}
+-	dispatchExecute( m_xModel, nSlot );
+-}
 -
--using namespace ::ooo::vba;
--using namespace ::com::sun::star;
+-sal_Bool SAL_CALL
+-ScVbaWindow::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;
+-}
 -
--// some little notes
--// XDialog implementation has the following interesting bits
--// a Controls property ( which is an array of the container controls )
--//   each item in the controls array is a XControl, where the model is 
--//   basically a property bag
--// additionally the XDialog instance has itself a model
--//     this model has a ControlModels ( array of models ) property
--//     the models in ControlModels can be accessed by name
--// also the XDialog is a XControl ( to access the model above
+-void SAL_CALL
+-ScVbaWindow::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 );	
+-	}
+-}
 -
--ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) :  ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), static_cast< ooo::vba::AbstractGeometryAttributes* >(0) ), m_pDocShell( 0 ), mbDispose( true )
+-css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel )
+-{
+-	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;
+-}
+-
+-void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, USHORT 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 )
+-		{
+-			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 
+-ScVbaWindow::getHeight() throw (uno::RuntimeException)
+-{
+-	css::awt::Rectangle aRect = getPosSize(m_xModel);
+-	return aRect.Height;
+-}
+-
+-void SAL_CALL 
+-ScVbaWindow::setHeight( sal_Int32 _height ) throw (uno::RuntimeException)
+-{
+-	setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT);
+-}
+-
+-sal_Int32 SAL_CALL 
+-ScVbaWindow::getLeft() throw (uno::RuntimeException)
+-{
+-	css::awt::Rectangle aRect = getPosSize(m_xModel);
+-	return aRect.X;
+-}
+-
+-void SAL_CALL 
+-ScVbaWindow::setLeft( sal_Int32 _left ) throw (uno::RuntimeException)
+-{
+-	setPosSize(m_xModel, _left, css::awt::PosSize::X);
+-}
+-sal_Int32 SAL_CALL 
+-ScVbaWindow::getTop() throw (uno::RuntimeException)
+-{
+-	css::awt::Rectangle aRect = getPosSize(m_xModel);
+-	return aRect.Y;
+-}
+-
+-void SAL_CALL 
+-ScVbaWindow::setTop( sal_Int32 _top ) throw (uno::RuntimeException)
+-{
+-	setPosSize(m_xModel, _top, css::awt::PosSize::Y);
+-}
+-sal_Int32 SAL_CALL 
+-ScVbaWindow::getWidth() throw (uno::RuntimeException)
+-{
+-	css::awt::Rectangle aRect = getPosSize(m_xModel);
+-	return aRect.Width;
+-}
+-
+-void SAL_CALL 
+-ScVbaWindow::setWidth( sal_Int32 _width ) throw (uno::RuntimeException)
+-{
+-	setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH);
++	ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
++	if ( pViewShell )
++		dispatchExecute( pViewShell, nSlot );
+ }
+ 
+ sal_Int32 SAL_CALL 
+@@ -924,14 +812,14 @@ void SAL_CALL
+ ScVbaWindow::PrintOut( 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 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ 	// need test, print current active sheet	
+-	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, m_xModel, sal_True );
++	PrintOutHelper( excel::getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
+ }
+ 
+ void SAL_CALL 
+ ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ 	// need test, print preview current active sheet	
+-	PrintPreviewHelper( EnableChanges, m_xModel );	
++	PrintPreviewHelper( EnableChanges, excel::getBestViewShell( m_xModel ) );	
+ }
+ 
+ rtl::OUString& 
+diff --git sc/source/ui/vba/vbawindow.hxx sc/source/ui/vba/vbawindow.hxx
+index ee4f5c8..ce34de5 100644
+--- sc/source/ui/vba/vbawindow.hxx
++++ sc/source/ui/vba/vbawindow.hxx
+@@ -39,15 +39,16 @@
+ #include <ooo/vba/excel/XPane.hpp>
+ #include <com/sun/star/awt/XDevice.hpp>
+ 
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbawindowbase.hxx>
+ #include "vbaworkbook.hxx"
+ 
+-typedef InheritedHelperInterfaceImpl1<ov::excel::XWindow > WindowImpl_BASE;
++//typedef InheritedHelperInterfaceImpl1<ov::excel::XWindow > WindowImpl_BASE;
++typedef cppu::ImplInheritanceHelper1< VbaWindowBase, ov::excel::XWindow > WindowImpl_BASE;
+ 
+ class ScVbaWindow : public WindowImpl_BASE
+ {		
+ private:		
+-	css::uno::Reference< css::frame::XModel > m_xModel;
+ 	css::uno::Reference< css::sheet::XViewPane > m_xViewPane;
+ 	css::uno::Reference< css::sheet::XViewFreezable > m_xViewFreezable;
+ 	css::uno::Reference< css::sheet::XViewSplitable > m_xViewSplitable;
+@@ -82,10 +83,6 @@ public:
+ 	virtual void SAL_CALL setDisplayWorkbookTabs( ::sal_Bool _bDisplayWorkbookTabs ) throw (css::uno::RuntimeException);
+ 	virtual ::sal_Bool SAL_CALL getFreezePanes() throw (css::uno::RuntimeException);
+ 	virtual void SAL_CALL setFreezePanes( ::sal_Bool _bFreezePanes ) throw (css::uno::RuntimeException);
+-    virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ;
+-    virtual void SAL_CALL setHeight( sal_Int32 _height ) throw (css::uno::RuntimeException) ;
+-    virtual sal_Int32 SAL_CALL getLeft() throw (css::uno::RuntimeException) ;
+-    virtual void SAL_CALL setLeft( sal_Int32 _left ) throw (css::uno::RuntimeException) ;
+ 	virtual ::sal_Bool SAL_CALL getSplit() throw (css::uno::RuntimeException);
+ 	virtual void SAL_CALL setSplit( ::sal_Bool _bSplit ) throw (css::uno::RuntimeException);
+     virtual sal_Int32 SAL_CALL getSplitColumn() throw (css::uno::RuntimeException) ;
+@@ -100,14 +97,8 @@ public:
+     virtual void SAL_CALL setScrollRow( const css::uno::Any& _scrollrow ) throw (css::uno::RuntimeException) ;
+     virtual css::uno::Any SAL_CALL getScrollColumn() throw (css::uno::RuntimeException) ;
+     virtual void SAL_CALL setScrollColumn( const css::uno::Any& _scrollcolumn ) throw (css::uno::RuntimeException) ;
+-    virtual sal_Int32 SAL_CALL getTop() throw (css::uno::RuntimeException) ;
+-    virtual void SAL_CALL setTop( sal_Int32 _top ) throw (css::uno::RuntimeException) ;
+     virtual css::uno::Any SAL_CALL getView() throw (css::uno::RuntimeException);
+     virtual void SAL_CALL setView( const css::uno::Any& _view ) throw (css::uno::RuntimeException);
+-    virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
+-    virtual sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException) ;
+-    virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException) ;
+     virtual css::uno::Any SAL_CALL getWindowState() throw (css::uno::RuntimeException);
+     virtual void SAL_CALL setWindowState( const css::uno::Any& _windowstate ) throw (css::uno::RuntimeException);
+     virtual css::uno::Any SAL_CALL getZoom() throw (css::uno::RuntimeException);
+diff --git sc/source/ui/vba/vbawindows.cxx sc/source/ui/vba/vbawindows.cxx
+index 517f9fd..349bad4 100644
+--- sc/source/ui/vba/vbawindows.cxx
++++ sc/source/ui/vba/vbawindows.cxx
+@@ -37,6 +37,7 @@
+ 
+ #include <tools/urlobj.hxx>
+ #include "vbawindow.hxx"
++#include "vbaglobals.hxx"
+ //#include "vbaworkbook.hxx"
+ 
+ using namespace ::com::sun::star;
+@@ -47,15 +48,15 @@ sal_Int32, ::rtl::OUStringHash,
+ ::std::equal_to< ::rtl::OUString > > NameIndexHash;
+ 
+ 
+-uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext )
++uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication )
+ {
+-	return new ScVbaWorkbook( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext,  xModel );
++	return new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext,  xModel );
+ }
+ 
+-uno::Any ComponentToWindow( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext )
++uno::Any ComponentToWindow( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Any& aApplication )
+ {
+ 	uno::Reference< frame::XModel > xModel( aSource, uno::UNO_QUERY_THROW );
+-	uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext ), xContext,xModel ) );
++	uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext, aApplication ), xContext,xModel ) );
+ 	return uno::makeAny( xWin );
+ }
+ 
+@@ -108,12 +109,13 @@ public:
+ 
+ class WindowEnumImpl : public  WindowComponentEnumImpl
+ {
++	uno::Any m_aApplication;
+ public:
+-	WindowEnumImpl(const uno::Reference< uno::XComponentContext >& xContext, const Components& components ):WindowComponentEnumImpl( xContext, components ) {}
+-	WindowEnumImpl( const uno::Reference< uno::XComponentContext >& xContext ): WindowComponentEnumImpl( xContext ) {}
++	WindowEnumImpl(const uno::Reference< uno::XComponentContext >& xContext, const Components& components, const uno::Any& aApplication ):WindowComponentEnumImpl( xContext, components ), m_aApplication( aApplication ){}
++	WindowEnumImpl( const uno::Reference< uno::XComponentContext >& xContext,  const uno::Any& aApplication ): WindowComponentEnumImpl( xContext ), m_aApplication( aApplication ) {}
+ 	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ 	{
+-		return ComponentToWindow( WindowComponentEnumImpl::nextElement(), m_xContext );
++		return ComponentToWindow( WindowComponentEnumImpl::nextElement(), m_xContext, m_aApplication );
+ 	}
+ };
+ 
+@@ -212,16 +214,19 @@ ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParen
+ {
+ }
+ 
++ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWindows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess > ( new WindowsAccessImpl( xContext ) ) )
++{
++}
+ uno::Reference< container::XEnumeration >
+ ScVbaWindows::createEnumeration() throw (uno::RuntimeException)
+ {
+-	return new WindowEnumImpl( mxContext );
++	return new WindowEnumImpl( mxContext, Application() );
+ }
+ 
+ uno::Any
+ ScVbaWindows::createCollectionObject( const css::uno::Any& aSource )
+ {
+-	return ComponentToWindow( aSource,  mxContext );
++	return ComponentToWindow( aSource,  mxContext, Application() );
+ }
+ 
+ uno::Type 
+@@ -230,12 +235,6 @@ ScVbaWindows::getElementType() throw (uno::RuntimeException)
+ 	return excel::XWindows::static_type(0);
+ }
+ 
+-uno::Reference< XCollection >
+-ScVbaWindows::Windows( const css::uno::Reference< css::uno::XComponentContext >& xContext )
 -{
--    m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW );
--    uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
--    m_pDocShell = getDocShell( m_xModel );
--    m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
--    setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) );
+-	uno::Reference< container::XIndexAccess > xIndex( new WindowsAccessImpl( xContext ) );
+-	return  new ScVbaWindows( uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext , xIndex );	
 -}
--
--ScVbaUserForm::~ScVbaUserForm()
+ 
+ void SAL_CALL 
+ ScVbaWindows::Arrange( ::sal_Int32 /*ArrangeStyle*/, const uno::Any& /*ActiveWorkbook*/, const uno::Any& /*SyncHorizontal*/, const uno::Any& /*SyncVertical*/ ) throw (uno::RuntimeException)
+diff --git sc/source/ui/vba/vbawindows.hxx sc/source/ui/vba/vbawindows.hxx
+index 67bda22..d0940a8 100644
+--- sc/source/ui/vba/vbawindows.hxx
++++ sc/source/ui/vba/vbawindows.hxx
+@@ -35,8 +35,8 @@
+ 
+ #include <com/sun/star/uno/XComponentContext.hpp>
+  
+-#include "vbahelper.hxx"
+-#include "vbacollectionimpl.hxx"
++#include "excelvbahelper.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
+ 
+ 
+ typedef CollTestImplHelper< ov::excel::XWindows > ScVbaWindows_BASE;
+@@ -45,6 +45,7 @@ class ScVbaWindows : public ScVbaWindows_BASE
+ {
+ public:
+ 	ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
++	ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext );
+ 	virtual ~ScVbaWindows() {}
+ 
+ 	// XEnumerationAccess
+@@ -57,8 +58,6 @@ public:
+ 	// ScVbaCollectionBaseImpl	
+ 	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); 
+ 
+-	static css::uno::Reference< ov::XCollection > Windows(  const css::uno::Reference< css::uno::XComponentContext >& xContext );
+-
+ 	// XHelperInterface
+ 	virtual rtl::OUString& getServiceImplName();
+ 	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+diff --git sc/source/ui/vba/vbaworkbook.cxx sc/source/ui/vba/vbaworkbook.cxx
+index e0521dd..ded6aad 100644
+--- sc/source/ui/vba/vbaworkbook.cxx
++++ sc/source/ui/vba/vbaworkbook.cxx
+@@ -27,7 +27,7 @@
+  * for a copy of the LGPLv3 License.
+  *
+  ************************************************************************/
+-#include "helperdecl.hxx"
++#include <vbahelper/helperdecl.hxx>
+ #include <tools/urlobj.hxx>
+ #include <comphelper/unwrapargs.hxx>
+ 
+@@ -46,7 +46,7 @@
+ #include "vbaworkbook.hxx"
+ #include "vbawindows.hxx"
+ #include "vbastyles.hxx"
+-#include "vbahelper.hxx"
++#include "excelvbahelper.hxx"
+ #include "vbapalette.hxx"
+ #include <osl/file.hxx>
+ #include <stdio.h>
+@@ -192,7 +192,7 @@ ScVbaWorkbook::init()
+ 	if ( !ColorData.getLength() )
+ 		ResetColors();
+ }
+-ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext ), mxModel(NULL)
++ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext )
+ {
+ 	//#FIXME this persists the color data per office instance and
+ 	// not per workbook instance, need to hook the data into XModel
+@@ -203,54 +203,18 @@ ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >
+ 	init();
+ }
+ 
+-ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext ),  mxModel( xModel ) 
++ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )
+ { 
+ 	init();
+ }
+ 
+ ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
+-    uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ),  mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) 
++    uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
+ 
+ {
+ 	init();
+ }
+ 
+-::rtl::OUString
+-ScVbaWorkbook::getName() throw (uno::RuntimeException)
 -{
--}
+-	rtl::OUString sName = getModel()->getURL();
+-	if ( sName.getLength() )
+-	{
 -
--void SAL_CALL 
--ScVbaUserForm::Show(  ) throw (uno::RuntimeException)
--{
--	OSL_TRACE("ScVbaUserForm::Show(  )");
--	short aRet = 0;
--	if ( m_xDialog.is() )
--		aRet = m_xDialog->execute();
--	OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
--	if ( mbDispose )
+-		INetURLObject aURL( getModel()->getURL() );
+-		::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
+-	}
+-	else
 -	{
--		try
--		{
--			uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
--			m_xDialog = NULL;
--			xComp->dispose();
--			mbDispose = false; 
--		}
--		catch( uno::Exception& )
--		{
--		}
+-		const static rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM("Title" ) );
+-		// process "UntitledX - $(PRODUCTNAME)"
+-		uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+-		uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
+-		xProps->getPropertyValue(sTitle ) >>= sName;
+-		sal_Int32 pos = 0;
+-		sName = sName.getToken(0,' ',pos);	
 -	}
+-	return sName;
 -}
--
--rtl::OUString SAL_CALL 
--ScVbaUserForm::getCaption() throw (::com::sun::star::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)
+-::rtl::OUString
+-ScVbaWorkbook::getPath() throw (uno::RuntimeException)
 -{
--    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
+-	INetURLObject aURL( getModel()->getURL() );
+-	aURL.CutLastName();
+-	return aURL.GetURLPath();
 -}
 -
--void SAL_CALL 
--ScVbaUserForm::Hide(  ) throw (uno::RuntimeException)
+-::rtl::OUString
+-ScVbaWorkbook::getFullName() throw (uno::RuntimeException)
 -{
--	mbDispose = false;  // hide not dispose
--	if ( m_xDialog.is() )
--		m_xDialog->endExecute();
+-	INetURLObject aURL( getModel()->getURL() );
+-	return aURL.GetURLPath();
 -}
--
--void SAL_CALL 
--ScVbaUserForm::RePaint(  ) throw (uno::RuntimeException)
+ uno::Reference< excel::XWorksheet >
+ ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException)
+ {
+@@ -281,91 +245,19 @@ ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException
+ uno::Any SAL_CALL
+ ScVbaWorkbook::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+ {
+-	uno::Reference< XCollection >  xWindows = ScVbaWindows::Windows( mxContext );
++
++	uno::Reference< excel::XWindows >  xWindows( new ScVbaWindows( getParent(), mxContext ) );
+ 	if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ 		return uno::Any( xWindows );
+ 	return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
+ }
+-void
+-ScVbaWorkbook::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg,
+-					  const uno::Any &rRouteArg ) throw (uno::RuntimeException)
 -{
--	// do nothing
--}
+-	sal_Bool bSaveChanges = sal_False;
+-	rtl::OUString aFileName;
+-	sal_Bool bRouteWorkbook = sal_True;
+-
+-	rSaveArg >>= bSaveChanges;
+-	sal_Bool bFileName =  ( rFileArg >>= aFileName );
+-	rRouteArg >>= bRouteWorkbook;
+-	uno::Reference< frame::XStorable > xStorable( getModel(), uno::UNO_QUERY_THROW );
+-	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
+-
+-	if( bSaveChanges )
+-	{
+-		if( xStorable->isReadonly() )
+-		{	
+-			throw uno::RuntimeException(::rtl::OUString( 
+-				RTL_CONSTASCII_USTRINGPARAM( "Unable to save to a read only file ") ),
+-                        	uno::Reference< XInterface >() );
+-		}
+-		if( bFileName )
+-			xStorable->storeAsURL( aFileName, uno::Sequence< beans::PropertyValue >(0) ); 
+-		else
+-			xStorable->store();
+-	}	
+-	else
+-		xModifiable->setModified( false );		
 -
--void SAL_CALL 
--ScVbaUserForm::UnloadObject(  ) throw (uno::RuntimeException)
--{
--	mbDispose = true;
--	if ( m_xDialog.is() )
--		m_xDialog->endExecute();
--}
+-	uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY );
 -
--rtl::OUString& 
--ScVbaUserForm::getServiceImplName()
--{
--	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
--	return sImplName;
+-	if( xCloseable.is() )
+-		// use close(boolean DeliverOwnership)
+-	
+-		// The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
+-		// assume ownership if they object the closure by throwing a CloseVetoException
+-		// Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
+-		xCloseable->close(sal_True);
+-	// If close is not supported by this model - try to dispose it.
+-	// But if the model disagree with a reset request for the modify state
+-	// we shouldn't do so. Otherwhise some strange things can happen.
+-	else
+-	{
+-		uno::Reference< lang::XComponent > xDisposable ( getCurrentDocument(), uno::UNO_QUERY );
+-		if ( xDisposable.is() )
+-			xDisposable->dispose();
+-	}
 -}
--
--uno::Sequence< rtl::OUString > 
--ScVbaUserForm::getServiceNames()
+ 
+-void
+-ScVbaWorkbook::Protect( const uno::Any &aPassword ) throw (uno::RuntimeException)
++void SAL_CALL
++ScVbaWorkbook::Activate() throw (uno::RuntimeException)
+ {
+-	rtl::OUString rPassword;
+-	uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
+-	SC_VBA_FIXME(("Workbook::Protect stub"));
+-	if(  aPassword >>= rPassword )
+-		xProt->protect( rPassword );
+-	else
+-		xProt->protect( rtl::OUString() );
++    VbaDocumentBase::Activate();
+ }
+ 
+-void 
+-ScVbaWorkbook::Unprotect( const uno::Any &aPassword ) throw (uno::RuntimeException)
 -{
--	static uno::Sequence< rtl::OUString > aServiceNames;
--	if ( aServiceNames.getLength() == 0 )
+-	rtl::OUString rPassword;
+-	uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
+-	if( !getProtectStructure() )
+-		throw uno::RuntimeException(::rtl::OUString(
+-			RTL_CONSTASCII_USTRINGPARAM( "File is already unprotected" ) ),
+-			uno::Reference< XInterface >() );
+-	else
 -	{
--		aServiceNames.realloc( 1 );
--		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm" ) );
+-		if( aPassword >>= rPassword )
+-			xProt->unprotect( rPassword );
+-		else
+-			xProt->unprotect( rtl::OUString() );
 -	}
--	return aServiceNames;
 -}
--
--uno::Reference< beans::XIntrospectionAccess > SAL_CALL 
--ScVbaUserForm::getIntrospection(  ) throw (uno::RuntimeException)
+-		
+ ::sal_Bool
+ ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException)
+ {
+@@ -373,28 +265,6 @@ ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException)
+ 	return xProt->isProtected();
+ }
+ 
+-void 
+-ScVbaWorkbook::setSaved( sal_Bool bSave ) throw (uno::RuntimeException)
 -{
--	return uno::Reference< beans::XIntrospectionAccess >();
+-	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
+-	xModifiable->setModified( bSave );
 -}
 -
--uno::Any SAL_CALL 
--ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+-sal_Bool
+-ScVbaWorkbook::getSaved() throw (uno::RuntimeException)
 -{
--	throw uno::RuntimeException(); // unsupported operation
+-	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
+-	return xModifiable->isModified();
 -}
 -
--void SAL_CALL 
--ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+-void
+-ScVbaWorkbook::Save() throw (uno::RuntimeException)
 -{
--	uno::Any aObject = getValue( aPropertyName );
--	// The Object *must* support XDefaultProperty here because getValue will
--	// only return properties that are Objects ( e.g. controls )
--	// e.g. Userform1.aControl = something
--	// 'aControl' has to support XDefaultProperty to make sense here
--	uno::Reference< script::XDefaultProperty > xDfltProp( aObject, uno::UNO_QUERY_THROW );
--	rtl::OUString aDfltPropName = xDfltProp->getDefaultPropertyName();
--	uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) );
--	uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY_THROW );
--	xPropSet->setPropertyValue( aDfltPropName, aValue );
+-	rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Save"));
+-	uno::Reference< frame::XModel > xModel = getModel();
+-	dispatchRequests(xModel,url);
 -}
 -
--uno::Any SAL_CALL 
--ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+ void
+ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::RuntimeException)
+ {
+@@ -407,13 +277,6 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime
+ 	xStor->storeToURL( aURL, storeProps );
+ }
+ 
+-void 
+-ScVbaWorkbook::Activate() throw (uno::RuntimeException)
 -{
--	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
--	uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
--	uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
--	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 ) );
--	return uno::makeAny( xVBAControl );
--}
+-	uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+-	xFrame->activate();
+-}	
+-
+ css::uno::Any SAL_CALL 
+ ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException)
+ {
+@@ -465,7 +328,7 @@ ScVbaWorkbook::getCodeName() throw (css::uno::RuntimeException)
+ {
+ #ifdef VBA_OOBUILD_HACK 
+     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+-    ScDocument* pDoc = getDocShell( xModel )->GetDocument();
++    ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+     ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
+     ScExtDocSettings pExtSettings = pExtOptions->GetDocSettings();
+     ::rtl::OUString sGlobCodeName = pExtSettings.maGlobCodeName;
+@@ -479,7 +342,7 @@ void SAL_CALL
+ ScVbaWorkbook::setCodeName( const ::rtl::OUString& sGlobCodeName ) throw (css::uno::RuntimeException)
+ {
+     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+-    ScDocument* pDoc = getDocShell( xModel )->GetDocument();
++    ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+     ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
+     ScExtDocSettings pExtSettings = pExtOptions->GetDocSettings();
+     pExtSettings.maGlobCodeName = sGlobCodeName;
+diff --git sc/source/ui/vba/vbaworkbook.hxx sc/source/ui/vba/vbaworkbook.hxx
+index b84d84e..1ce5de5 100644
+--- sc/source/ui/vba/vbaworkbook.hxx
++++ sc/source/ui/vba/vbaworkbook.hxx
+@@ -32,21 +32,20 @@
+ 
+ #include <com/sun/star/frame/XModel.hpp>
+ #include <ooo/vba/excel/XWorkbook.hpp>
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbadocumentbase.hxx>
+ 
+ class ScModelObj;
+ 
+-typedef InheritedHelperInterfaceImpl1< ov::excel::XWorkbook > ScVbaWorkbook_BASE;
++typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ov::excel::XWorkbook > ScVbaWorkbook_BASE;
+ 
+ class ScVbaWorkbook : public ScVbaWorkbook_BASE
+ {
+-	css::uno::Reference< css::frame::XModel > mxModel;
+ 	static css::uno::Sequence< sal_Int32 > ColorData;
+ 	void initColorData( const css::uno::Sequence< sal_Int32 >& sColors );
+ 	void init();
+ protected:
+ 
+-	virtual css::uno::Reference< css::frame::XModel >  getModel() { return mxModel; }
+ 	ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ public:
+ 	ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+@@ -55,25 +54,14 @@ public:
+ 	virtual ~ScVbaWorkbook() {}
+ 
+     // Attributes
+-	virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+-	virtual ::rtl::OUString SAL_CALL getPath() throw (css::uno::RuntimeException);
+-	virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException);
+ 	virtual ::sal_Bool SAL_CALL getProtectStructure() throw (css::uno::RuntimeException);
+ 	virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
+-	virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException);
+ 
+ 	// Methods
+ 	virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges,
+-								 const css::uno::Any &aFileName,
+-								 const css::uno::Any &bRouteWorkbook ) throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL Unprotect( const css::uno::Any &aPassword ) throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL Save() throw (css::uno::RuntimeException);
+-	virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+     // Amelia Wang
+     virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 
+diff --git sc/source/ui/vba/vbaworkbooks.cxx sc/source/ui/vba/vbaworkbooks.cxx
+index 6bb17b5..acb9cfc 100644
+--- sc/source/ui/vba/vbaworkbooks.cxx
++++ sc/source/ui/vba/vbaworkbooks.cxx
+@@ -56,7 +56,7 @@
+ #include "vbaglobals.hxx"
+ #include "vbaworkbook.hxx"
+ #include "vbaworkbooks.hxx"
+-#include "vbahelper.hxx"
++#include <vbahelper/vbahelper.hxx>
+ 
+ #include <hash_map>
+ #include <osl/file.hxx>
+@@ -74,14 +74,14 @@ typedef std::vector < uno::Reference< sheet::XSpreadsheetDocument > > WorkBooks;
+ typedef ::cppu::WeakImplHelper1< container::XEnumeration > SpreadSheetDocEnumImpl_BASE;
+ 
+ static uno::Any
+-getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc )
++getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Any& aApplication )
+ {
+ 	// FIXME: fine as long as ScVbaWorkbook is stateless ...
+ 	uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
+ 	if( !xModel.is() )
+ 		return uno::Any();
+ 	
+-	ScVbaWorkbook *pWb = new ScVbaWorkbook(  uno::Reference< XHelperInterface >( ScVbaGlobals::getGlobalsImpl( xContext )->getApplication(), uno::UNO_QUERY_THROW ), xContext, xModel );
++	ScVbaWorkbook *pWb = new ScVbaWorkbook(  uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel );
+ 	return uno::Any( uno::Reference< excel::XWorkbook > (pWb) );
+ }
+ 
+@@ -134,13 +134,14 @@ public:
+ 
+ class WorkBookEnumImpl : public EnumerationHelperImpl
+ {
++	uno::Any m_aApplication;
+ public:
+-	WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ){}
++	WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_aApplication( aApplication ) {}
+ 
+ 	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 
+ 	{ 
+ 		uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+-		return getWorkbook( m_xContext, xDoc );
++		return getWorkbook( m_xContext, xDoc, m_aApplication );
+ 	}
+ 
+ };
+@@ -254,14 +255,14 @@ ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException)
+ 	// the state of this object ( although it should ) would be 
+ 	// safer to create an enumeration based on this objects state
+ 	// rather than one effectively based of the desktop component
+-	return new WorkBookEnumImpl( mxContext, uno::Reference< container::XEnumeration >( new SpreadSheetDocEnumImpl(mxContext) ) );
++	return new WorkBookEnumImpl( mxContext, uno::Reference< container::XEnumeration >( new SpreadSheetDocEnumImpl(mxContext) ), Application() );
+ }
+ 
+ uno::Any
+ ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource )
+ {
+ 	uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY );
+-	return getWorkbook( mxContext, xDoc );
++	return getWorkbook( mxContext, xDoc, Application() );
+ }
+ 
+ 
+@@ -282,7 +283,7 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException)
+     uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW );
+                                                                                                                              
+     if( xSpreadDoc.is() )
+-        return getWorkbook( mxContext, xSpreadDoc );
++        return getWorkbook( mxContext, xSpreadDoc, Application() );
+     return uno::Any();
+ }
+ 
+@@ -438,7 +439,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi
+ 		frame::FrameSearchFlag::CREATE,
+ 		sProps);
+ 	uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW );
+-	uno::Any aRet = getWorkbook( mxContext, xSpreadDoc );
++	uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, Application() );
+ 	uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY );
+ 	if ( xWBook.is() )
+ 		xWBook->Activate();
+diff --git sc/source/ui/vba/vbaworkbooks.hxx sc/source/ui/vba/vbaworkbooks.hxx
+index 7c5b421..b66d294 100644
+--- sc/source/ui/vba/vbaworkbooks.hxx
++++ sc/source/ui/vba/vbaworkbooks.hxx
+@@ -31,11 +31,10 @@
+ #define SC_VBA_WORKBOOKS_HXX
+ 
+ 
+-#include "vbacollectionimpl.hxx"
+-#include <ooo/vba/XGlobals.hpp>
++#include <vbahelper/vbacollectionimpl.hxx>
+ #include <ooo/vba/excel/XWorkbooks.hpp>
+ #include <com/sun/star/container/XEnumerationAccess.hpp>
+-#include "vbahelper.hxx"
++#include "excelvbahelper.hxx"
+ 
+ 
+ class ScModelObj;
+@@ -45,7 +44,6 @@ typedef CollTestImplHelper< ov::excel::XWorkbooks > ScVbaWorkbooks_BASE;
+ class ScVbaWorkbooks : public ScVbaWorkbooks_BASE
+ {
+ private:
+-	css::uno::Reference< ov::XGlobals > getGlobals() throw (css::uno::RuntimeException);
+ 	rtl::OUString 	getFileFilterType( const rtl::OUString& rString );
+ 	bool 	isTextFile( const rtl::OUString& rString );
+ 	bool 	isSpreadSheetFile( const rtl::OUString& rString );
+diff --git sc/source/ui/vba/vbaworksheet.cxx sc/source/ui/vba/vbaworksheet.cxx
+index 17618d1..310f81e 100644
+--- sc/source/ui/vba/vbaworksheet.cxx
++++ sc/source/ui/vba/vbaworksheet.cxx
+@@ -27,7 +27,7 @@
+  * for a copy of the LGPLv3 License.
+  *
+  ************************************************************************/
+-#include "helperdecl.hxx"
++#include <vbahelper/helperdecl.hxx>
+ #include <cppuhelper/queryinterface.hxx>
+ 
+ #include <com/sun/star/beans/XPropertySet.hpp>
+@@ -59,6 +59,7 @@
+ #include <com/sun/star/form/FormComponentType.hpp>
+ #include <com/sun/star/form/XFormsSupplier.hpp>
+ #include <ooo/vba/excel/XlEnableSelection.hpp>
++#include <ooo/vba/XControlProvider.hpp>
+ 
+ #include <comphelper/processfactory.hxx>
+ 
+@@ -83,7 +84,6 @@
+ #include "vbaworksheet.hxx"
+ #include "vbachartobjects.hxx"
+ #include "vbapivottables.hxx"
+-#include "vbacombobox.hxx"
+ #include "vbaoleobject.hxx"
+ #include "vbaoleobjects.hxx"
+ #include "vbashapes.hxx"
+@@ -268,7 +268,7 @@ ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException)
+     if ( bSheetExists )
+     {
+         uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+-        ScDocument* pDoc = getDocShell( xModel )->GetDocument();
++        ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+         ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ 		sal_Bool bLockedCells = sal_False;
+ 		sal_Bool bUnlockedCells = sal_False;
+@@ -308,7 +308,7 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx
+     if ( bSheetExists )
+     {
+         uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+-        ScDocument* pDoc = getDocShell( xModel )->GetDocument();
++        ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+         ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+         // default is xlNoSelection
+         sal_Bool bLockedCells = sal_False;
+@@ -441,11 +441,11 @@ ScVbaWorksheet::Move( const uno::Any& Before, const uno::Any& After ) throw (uno
+ 		uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, mxContext, xRange1);
+ 		if (xRange.is())
+ 			xRange->Select();
+-		implnCopy();
++		excel::implnCopy();
+ 		uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
+ 		if (xModel.is()) 
+ 		{
+-			implnPaste();
++			excel::implnPaste();
+ 			Delete();
+ 		}
+ 		return ;
+@@ -479,11 +479,11 @@ ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno
+ 		uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, mxContext, xRange1);
+ 		if (xRange.is())
+ 			xRange->Select();
+-		implnCopy();
++		excel::implnCopy();
+ 		uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
+ 		if (xModel.is())
+ 		{
+-			implnPaste();
++			excel::implnPaste();
+ 		}
+ 		return;
+ 	}
+@@ -512,7 +512,7 @@ ScVbaWorksheet::Paste( const uno::Any& Destination, const uno::Any& /*Link*/ ) t
+ 	uno::Reference<excel::XRange> xRange( Destination, uno::UNO_QUERY );
+ 	if ( xRange.is() )
+ 		xRange->Select();
+-	implnPaste();
++	excel::implnPaste();
+ }
+ 
+ void 
+@@ -723,7 +723,7 @@ ScVbaWorksheet::ShowDataForm( ) throw (uno::RuntimeException)
+ {
+ #ifdef VBA_OOBUILD_HACK 
+ 	uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+-	ScTabViewShell* pTabViewShell = getBestViewShell( xModel );
++	ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel );
+ 
+ 	ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ 	DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
+@@ -772,9 +772,11 @@ uno::Any SAL_CALL
+ ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+ {
+     uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW );
+-    ScVbaControlFactory controlFactory( mxContext, xControlShape, getModel() );
+-    uno::Reference< msforms::XControl > xControl( controlFactory.createControl( getModel() ) );
+-	return uno::makeAny( xControl );
++    
++    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 > xControl( xControlProvider->createControl(  xControlShape, getModel() ) );
++    return uno::makeAny( xControl );
+ }
+ 
+ ::sal_Bool SAL_CALL 
+@@ -957,10 +959,9 @@ ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::A
+ 		bSelection = sal_True;
+ 
+     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );  
+-	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, xModel, bSelection );
++	PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
+ }
+ 
 -
--::sal_Bool SAL_CALL 
--ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
--{
--	return sal_False;
--}
--uno::Any SAL_CALL 
--ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
--{
--	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
--	uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
--	if ( index.hasValue() )
--		return uno::makeAny( xControls->Item( index, uno::Any() ) );
--	return uno::makeAny( xControls );
--}
+ namespace worksheet
+ {
+ namespace sdecl = comphelper::service_decl;
+diff --git sc/source/ui/vba/vbaworksheet.hxx sc/source/ui/vba/vbaworksheet.hxx
+index b275960..953d653 100644
+--- sc/source/ui/vba/vbaworksheet.hxx
++++ sc/source/ui/vba/vbaworksheet.hxx
+@@ -48,7 +48,8 @@
+ #include <ooo/vba/excel/XChartObjects.hpp>
+ #include <com/sun/star/container/XNamed.hpp>
+ 
+-#include "vbahelperinterface.hxx"
++#include <vbahelper/vbahelperinterface.hxx>
++#include "address.hxx"
+ 
+ typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheet >  WorksheetImpl_BASE;
+ 
+diff --git sc/source/ui/vba/vbaworksheets.cxx sc/source/ui/vba/vbaworksheets.cxx
+index cfc156f..f2c0312 100644
+--- sc/source/ui/vba/vbaworksheets.cxx
++++ sc/source/ui/vba/vbaworksheets.cxx
+@@ -217,8 +217,8 @@ ScVbaWorksheets::Add( const uno::Any& Before, const uno::Any& After,
+ 	}
+ 	if (!aStringSheet.getLength())
+ 	{
+-		aStringSheet = ScVbaGlobals::getGlobalsImpl( 
+-			mxContext )->getApplication()->getActiveWorkbook()->getActiveSheet()->getName();
++		uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
++		aStringSheet = xApplication->getActiveWorkbook()->getActiveSheet()->getName();
+ 		bBefore = sal_True;
+ 	}
+ 		nCount = static_cast< SCTAB >( m_xIndexAccess->getCount() );
+@@ -295,7 +295,7 @@ ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno::
+ 		if ( isSelectedSheets() )
+ 			bSelection = sal_True;
+ 
+-	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, mxModel, bSelection );
++	PrintOutHelper( excel::getBestViewShell( mxModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
+ }
+ 
+ uno::Any SAL_CALL 
+@@ -336,7 +336,7 @@ ScVbaWorksheets::setVisible( const uno::Any& _visible ) throw (uno::RuntimeExcep
+ void SAL_CALL 
+ ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException)
+ {
+-	ScTabViewShell* pViewShell = getBestViewShell( mxModel );
++	ScTabViewShell* pViewShell = excel::getBestViewShell( mxModel );
+ 	if ( !pViewShell )
+ 		throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() );
+ 			
+diff --git sc/source/ui/vba/vbaworksheets.hxx sc/source/ui/vba/vbaworksheets.hxx
+index a57a86a..46679a1 100644
+--- sc/source/ui/vba/vbaworksheets.hxx
++++ sc/source/ui/vba/vbaworksheets.hxx
+@@ -36,9 +36,8 @@
+ #include <com/sun/star/sheet/XSpreadsheets.hpp>
+ #include <com/sun/star/container/XEnumerationAccess.hpp>
+ #include <com/sun/star/uno/XComponentContext.hpp>
+-#include <ooo/vba/XGlobals.hpp>
+  
+-#include "vbacollectionimpl.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
+ 
+ class ScModelObj;
+ 
+diff --git sc/util/makefile.mk sc/util/makefile.mk
+index 564882f..dd6c36d 100644
+--- sc/util/makefile.mk
++++ sc/util/makefile.mk
+@@ -78,6 +78,7 @@ SHL1IMPLIB= sci
+ 
+ # dynamic libraries
+ SHL1STDLIBS=       \
++		$(VBAHELPERLIB) \
+ 	$(BASICLIB)	\
+ 	$(SFXLIB)		\
+ 	$(SVTOOLLIB)	\
+@@ -304,6 +305,7 @@ SHL9RPATH=OOO
+ .ENDIF
+ 
+ SHL9STDLIBS= \
++		$(VBAHELPERLIB) \
+ 		$(CPPUHELPERLIB) \
+ 		$(VCLLIB) \
+ 		$(CPPULIB) \
+diff --git scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
+index 0a94c57..d4a0643 100644
+--- scp2/source/ooo/file_library_ooo.scp
++++ scp2/source/ooo/file_library_ooo.scp
+@@ -406,7 +406,42 @@ File gid_File_Lib_Vbaobj
+   #endif
+ End
+ 
++File gid_File_Lib_Vbaswobj
++    TXT_FILE_BODY;
++    Styles = (PACKED,UNO_COMPONENT);
++    RegistryID = gid_Starregistry_Services_Rdb;
++    Dir = gid_Dir_Program;
++  #ifdef UNX
++    Name = STRING(CONCAT4(libvbaswobj,DLLPOSTFIX,.uno,UNXSUFFIX));
++  #else
++    Name = STRING(CONCAT4(vbaswobj,DLLPOSTFIX,.uno,.dll));
++  #endif
++End
++
++File gid_File_Lib_Vbamsforms
++    TXT_FILE_BODY;
++    Styles = (PACKED,UNO_COMPONENT);
++    RegistryID = gid_Starregistry_Services_Rdb;
++    Dir = gid_Dir_Program;
++  #ifdef UNX
++    Name = STRING(CONCAT4(libmsforms,DLLPOSTFIX,.uno,UNXSUFFIX));
++  #else
++    Name = STRING(CONCAT4(msforms,DLLPOSTFIX,.uno,.dll));
++  #endif
++End
++
+ #endif // VBA_EXTENSION
++File gid_File_Lib_Vbahelper
++    TXT_FILE_BODY;
++    Styles = (PACKED);
++    RegistryID = gid_Starregistry_Services_Rdb;
++    Dir = gid_Dir_Program;
++  #ifdef UNX
++    Name = STRING(CONCAT3(libvbahelper,DLLPOSTFIX,UNXSUFFIX));
++  #else
++    Name = STRING(CONCAT3(vbahelper,DLLPOSTFIX,.dll));
++  #endif
++End
+ #endif // ENABLE_VBA
+ 
+ 
+diff --git scripting/source/vbaevents/eventhelper.cxx scripting/source/vbaevents/eventhelper.cxx
+index 9242cb5..5433c7e 100644
+--- scripting/source/vbaevents/eventhelper.cxx
++++ scripting/source/vbaevents/eventhelper.cxx
+@@ -768,10 +768,27 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* /*pRet*/ ) throw(Runtime
+         std::list< TranslateInfo >::const_iterator txInfo =
+             eventInfo_it->second.begin();
+         std::list< TranslateInfo >::const_iterator txInfo_end = eventInfo_it->second.end();
+-        rtl::OUString sMacroLoc = rtl::OUString::createFromAscii("Standard.").concat( evt.ScriptCode ).concat( rtl::OUString::createFromAscii(".") );
+        
+         StarBASIC* pBasic = mpShell->GetBasic();
++        BasicManager* pBasicManager = mpShell->GetBasicManager();
++        //'Project' is a better default but I want to force failures
++        //rtl::OUString sMacroLoc = rtl::OUString::createFromAscii("Project");
++        rtl::OUString sProject = rtl::OUString::createFromAscii("Standard");
++
++        if ( pBasicManager->GetName().Len() > 0 )
++            sProject =  pBasicManager->GetName();
++
++        rtl::OUString sMacroLoc = sProject;
++        sMacroLoc = sMacroLoc.concat(  rtl::OUString::createFromAscii(".") );
++        sMacroLoc = sMacroLoc.concat( evt.ScriptCode ).concat( rtl::OUString::createFromAscii(".") );
++        
++        OSL_TRACE("sMacroLoc is %s", rtl::OUStringToOString( sMacroLoc, RTL_TEXTENCODING_UTF8 ).getStr() );
++
++        // find library
++        pBasic = pBasicManager->GetLib( sProject );
++        
+         SbModule* pModule = pBasic->FindModule( evt.ScriptCode );
++
+         for ( ; pModule && txInfo != txInfo_end; ++txInfo )
+         {
+             // see if we have a match for the handlerextension
+diff --git sfx2/inc/sfx2/sfx.hrc sfx2/inc/sfx2/sfx.hrc
+index 436189d..888a67a 100644
+--- sfx2/inc/sfx2/sfx.hrc
++++ sfx2/inc/sfx2/sfx.hrc
+@@ -402,8 +402,10 @@
+ #define MID_DOCINFO_ENCRYPTED				 0x2c
+ #define MID_DOCINFO_STATISTIC				 0x33
+ #define MID_DOCINFO_CHARLOCALE				 0x34
+-
+-#define MID_LAST_USED_PROPID                 MID_DOCINFO_CHARLOCALE
++#define MID_CATEGORY                                     0x35
++#define MID_COMPANY                                      0x36
++#define MID_MANAGER                                      0x37
++#define MID_LAST_USED_PROPID              MID_MANAGER   
+ 
+ // Config-Ids -----------------------------------------------------------
+ 
+diff --git sfx2/inc/sfx2/sfxbasemodel.hxx sfx2/inc/sfx2/sfxbasemodel.hxx
+index 9e407e8..b73914c 100644
+--- sfx2/inc/sfx2/sfxbasemodel.hxx
++++ sfx2/inc/sfx2/sfxbasemodel.hxx
+@@ -1379,6 +1379,7 @@ protected:
+     /* returns true if the document signatures are valid, otherwise false */
+     sal_Bool hasValidSignatures() const;
+ 
++    void setDocumentProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties >& );
+ //________________________________________________________________________________________________________
+ //	private methods
+ //________________________________________________________________________________________________________
+diff --git sfx2/source/appl/appuno.cxx sfx2/source/appl/appuno.cxx
+index 0d2fc0c..46460bf 100644
+--- sfx2/source/appl/appuno.cxx
++++ sfx2/source/appl/appuno.cxx
+@@ -2257,6 +2257,16 @@ SFX2_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo(
+     xNewKey = xKey->createKey( aTempStr );
+     xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.DocumentProperties") );
+ 
++
++    // writer compatable document properties
++    aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
++    aImpl += comp_CompatWriterDocProps::_getImplementationName();
++
++    aTempStr = aImpl;
++    aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
++    xNewKey = xKey->createKey( aTempStr );
++    xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.writer.DocumentProperties") );
++
+ 	return sal_True;
+ }
+ 
+@@ -2314,6 +2324,16 @@ SFX2_DLLPUBLIC void* SAL_CALL component_getFactory(
+ 			::comp_SfxDocumentMetaData::_getImplementationName(),
+ 			::comp_SfxDocumentMetaData::_getSupportedServiceNames());
+         }
++        if ( ::comp_CompatWriterDocProps::_getImplementationName().equals(
++                 ::rtl::OUString::createFromAscii( pImplementationName ) ) )
++        {
++            xFactory = ::cppu::createSingleComponentFactory(
++			::comp_CompatWriterDocProps::_create,
++			::comp_CompatWriterDocProps::_getImplementationName(),
++			::comp_CompatWriterDocProps::_getSupportedServiceNames());
++        }
++
++        // Factory is valid - service was found.
+ 
+         // Factory is valid - service was found.
+ 		if ( xFactory.is() )
+diff --git sfx2/source/doc/SfxDocumentMetaData.cxx sfx2/source/doc/SfxDocumentMetaData.cxx
+index d1d0b45..b8c9f5d 100644
+--- sfx2/source/doc/SfxDocumentMetaData.cxx
++++ sfx2/source/doc/SfxDocumentMetaData.cxx
+@@ -89,6 +89,10 @@
+ #include <cstring>
+ #include <limits>
+ 
++
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/document/XCompatWriterDocProperties.hpp>
++
+ /**
+  * This file contains the implementation of the service
+  * com.sun.star.document.DocumentProperties.
+@@ -298,12 +302,12 @@ public:
+         const css::uno::Sequence< css::beans::StringPair >& i_rNamespaces)
+         throw (css::uno::RuntimeException, css::xml::sax::SAXException);
+ 
+-private:
++protected:
+     SfxDocumentMetaData(SfxDocumentMetaData &); // not defined
+     SfxDocumentMetaData& operator =(SfxDocumentMetaData &); // not defined
+ 
+     virtual ~SfxDocumentMetaData() {}
 -
--::sal_Bool SAL_CALL 
--ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
--{
--	uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
--	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() );
--	if ( xControl.is() )
--	{
--		uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );	
--		sal_Bool bRes =  xNameAccess->hasByName( aName );
--	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes );
--		return bRes;
--	}
--	return sal_False;
--}
++    virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new SfxDocumentMetaData( context ); };
+     const css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ 
+     /// for notification
+@@ -377,6 +381,54 @@ private:
+     // throw (css::uno::RuntimeException);
+ };
+ 
++typedef ::cppu::ImplInheritanceHelper1< SfxDocumentMetaData, css::document::XCompatWriterDocProperties > CompatWriterDocPropsImpl_BASE;
++
++class CompatWriterDocPropsImpl : public CompatWriterDocPropsImpl_BASE
++{
++    rtl::OUString msManager;
++    rtl::OUString msCategory;
++    rtl::OUString msCompany;
++protected:
++    virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new CompatWriterDocPropsImpl( context ); };
++public:
++    CompatWriterDocPropsImpl( css::uno::Reference< css::uno::XComponentContext > const & context) : CompatWriterDocPropsImpl_BASE( context ) {}
++// XCompatWriterDocPropsImpl
++    virtual ::rtl::OUString SAL_CALL getManager() throw (::com::sun::star::uno::RuntimeException) { return msManager; }
++    virtual void SAL_CALL setManager( const ::rtl::OUString& _manager ) throw (::com::sun::star::uno::RuntimeException) { msManager = _manager; }
++    virtual ::rtl::OUString SAL_CALL getCategory() throw (::com::sun::star::uno::RuntimeException){ return msCategory; }
++    virtual void SAL_CALL setCategory( const ::rtl::OUString& _category ) throw (::com::sun::star::uno::RuntimeException){ msCategory = _category; }
++    virtual ::rtl::OUString SAL_CALL getCompany() throw (::com::sun::star::uno::RuntimeException){ return msCompany; }
++    virtual void SAL_CALL setCompany( const ::rtl::OUString& _company ) throw (::com::sun::star::uno::RuntimeException){ msCompany = _company; }
++
++// XServiceInfo
++    virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)
++    {
++        return comp_CompatWriterDocProps::_getImplementationName();
++    }
++
++    virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException)
++    { 
++        css::uno::Sequence< rtl::OUString > sServiceNames= getSupportedServiceNames();
++        sal_Int32 nLen = sServiceNames.getLength();
++        rtl::OUString* pIt = sServiceNames.getArray();
++        rtl::OUString* pEnd = ( pIt + nLen );
++        sal_Bool bRes = sal_False;
++        for ( ; pIt != pEnd; ++pIt )
++        {
++            if ( pIt->equals( ServiceName ) )
++            {
++                bRes = sal_True;
++                break;
++            }
++        }
++        return bRes;
++    }
++
++    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException)
++    {
++        return comp_CompatWriterDocProps::_getSupportedServiceNames();
++    }
++};
+ ////////////////////////////////////////////////////////////////////////////
+ 
+ bool operator== (const css::util::DateTime &i_rLeft,
+@@ -2149,7 +2201,7 @@ SfxDocumentMetaData::createClone()
+     ::osl::MutexGuard g(m_aMutex);
+     checkInit();
+ 
+-    SfxDocumentMetaData *pNew = new SfxDocumentMetaData(m_xContext);
++    SfxDocumentMetaData *pNew = createMe(m_xContext);
+ 
+     // NB: do not copy the modification listeners, only DOM
+     css::uno::Reference<css::xml::dom::XDocument> xDoc = createDOM();
+@@ -2266,6 +2318,32 @@ void SAL_CALL SfxDocumentMetaData::serialize(
+ 
+ 
+ // component helper namespace
++namespace comp_CompatWriterDocProps {
++
++    ::rtl::OUString SAL_CALL _getImplementationName() {
++        return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
++            "CompatWriterDocPropsImpl"));
++}
++
++   css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames()
++   {
++        static css::uno::Sequence< rtl::OUString > aServiceNames;
++        if ( aServiceNames.getLength() == 0 )
++        {
++            aServiceNames.realloc( 1 );
++            aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.writer.DocumentProperties" ) ); 
++        }
++        return aServiceNames;
++   } 
++    css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
++        const css::uno::Reference< css::uno::XComponentContext > & context)
++            SAL_THROW((css::uno::Exception))
++    {
++        return static_cast< ::cppu::OWeakObject * >
++                    (new CompatWriterDocPropsImpl(context));
++    }
++
++}
+ namespace comp_SfxDocumentMetaData {
+ 
+ ::rtl::OUString SAL_CALL _getImplementationName() {
+diff --git sfx2/source/doc/docinf.cxx sfx2/source/doc/docinf.cxx
+index 508fcf2..2b1043e 100644
+--- sfx2/source/doc/docinf.cxx
++++ sfx2/source/doc/docinf.cxx
+@@ -37,6 +37,7 @@
+ #include <com/sun/star/beans/XPropertySet.hpp>
+ #include <com/sun/star/beans/XPropertyContainer.hpp>
+ #include <com/sun/star/document/XDocumentProperties.hpp>
++#include <com/sun/star/document/XCompatWriterDocProperties.hpp>
+ #include <com/sun/star/uno/Exception.hpp>
+ 
+ #include <rtl/ustring.hxx>
+@@ -46,7 +47,6 @@
+ #include <vcl/gdimtf.hxx>
+ 
+ #include "oleprops.hxx"
 -
--namespace userform
--{
--namespace sdecl = comphelper::service_decl;
--sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl;
--extern sdecl::ServiceDecl const serviceDecl(
--    serviceImpl,
--    "ScVbaUserForm",
--    "ooo.vba.excel.UserForm" );
--}
+ // ============================================================================
+ 
+ // stream names
+@@ -175,6 +175,28 @@ sal_uInt32 SFX2_DLLPUBLIC LoadOlePropertySet(
+         }
+     }
+ 
++    uno::Reference< document::XCompatWriterDocProperties > xWriterProps( i_xDocProps, uno::UNO_QUERY );
++    if ( xWriterProps.is() )
++    {
++        SfxOleSectionRef xBuiltin = aDocSet.GetSection( SECTION_BUILTIN );
++        if ( xBuiltin.get() )
++        {
++            try
++            {
++                String aStrValue;
++                if ( xBuiltin->GetStringValue( aStrValue, PROPID_MANAGER ) )
++                    xWriterProps->setManager( aStrValue );
++                if ( xBuiltin->GetStringValue( aStrValue, PROPID_CATEGORY ) )
++                    xWriterProps->setCategory( aStrValue );
++                if ( xBuiltin->GetStringValue( aStrValue, PROPID_COMPANY ) )
++                    xWriterProps->setCompany( aStrValue );
++            }
++            catch ( uno::Exception& )
++            {
++            }
++        }
++    }
++
+     // return code
+     return (nGlobError != ERRCODE_NONE) ? nGlobError : nDocError;
+ }
+diff --git sfx2/source/doc/objuno.cxx sfx2/source/doc/objuno.cxx
+index be13e93..dd3e7c7 100644
+--- sfx2/source/doc/objuno.cxx
++++ sfx2/source/doc/objuno.cxx
+@@ -48,6 +48,7 @@
+ #include <com/sun/star/lang/Locale.hpp>
+ #include <com/sun/star/util/XModifiable.hpp>
+ #include <com/sun/star/document/XDocumentProperties.hpp>
++#include <com/sun/star/document/XCompatWriterDocProperties.hpp>
+ 
+ #include <unotools/configmgr.hxx>
+ #include <tools/inetdef.hxx>
+@@ -105,6 +106,9 @@ SfxItemPropertyMap aDocInfoPropertyMap_Impl[] =
+ 	{ "AutoloadEnabled"	, 15, MID_DOCINFO_AUTOLOADENABLED, &::getBooleanCppuType(),   PROPERTY_UNBOUND, 0 },
+     { "AutoloadSecs"    , 12, MID_DOCINFO_AUTOLOADSECS, &::getCppuType((const sal_Int32*)0),     PROPERTY_UNBOUND, 0 },
+ 	{ "AutoloadURL"		, 11, MID_DOCINFO_AUTOLOADURL, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
++	{ "Category"			, 8	, MID_CATEGORY,           &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
++	{ "Company"			, 7	, MID_COMPANY,           &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
++	{ "Manager"			, 7	, MID_MANAGER,           &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
+     { "CreationDate"    , 12, WID_DATE_CREATED,   &::getCppuType((const ::com::sun::star::util::DateTime*)0),PROPERTY_MAYBEVOID, 0 },
+ 	{ "DefaultTarget"	, 13, MID_DOCINFO_DEFAULTTARGET, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
+ 	{ "Description"		, 11, MID_DOCINFO_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 },
+@@ -822,6 +826,22 @@ void SAL_CALL  SfxDocumentInfoObject::setFastPropertyValue(sal_Int32 nHandle, co
+                     _pImp->m_xDocProps->setDefaultTarget(sTemp);
+ 				break;
+ //            case WID_CONTENT_TYPE : // this is readonly!
++               case MID_CATEGORY:
++               case MID_MANAGER:
++               case MID_COMPANY:
++                   {
++                       uno::Reference< document::XCompatWriterDocProperties > xWriterProps( _pImp->m_xDocProps, uno::UNO_QUERY  );
++                       if ( xWriterProps.is() ) 
++                       {
++                           if ( nHandle ==  MID_CATEGORY )
++                               xWriterProps->setCategory( sTemp );
++                           else if ( nHandle ==  MID_MANAGER )
++                               xWriterProps->setManager( sTemp );
++                           else
++                               xWriterProps->setCompany( sTemp );
++                           break;
++                       }
++                   }
+ 			default:
+ 				break;
+ 		}
+@@ -1039,6 +1059,23 @@ void SAL_CALL  SfxDocumentInfoObject::setFastPropertyValue(sal_Int32 nHandle, co
+         case MID_DOCINFO_CHARLOCALE:
+             aValue <<= _pImp->m_xDocProps->getLanguage();
+             break;
++        case MID_CATEGORY:
++        case MID_MANAGER:
++        case MID_COMPANY:
++            {
++                uno::Reference< document::XCompatWriterDocProperties > xWriterProps( _pImp->m_xDocProps, uno::UNO_QUERY  );
++                if ( xWriterProps.is() ) 
++                {
++                    if ( nHandle ==  MID_CATEGORY )
++                        aValue <<= xWriterProps->getCategory();
++                    else if ( nHandle ==  MID_MANAGER )
++                        aValue <<= xWriterProps->getManager();
++                    else
++                        aValue <<= xWriterProps->getCompany();
++                        break;
++               }
++           }
++	
+         default:
+             aValue <<= ::rtl::OUString();
+             break;
+diff --git sfx2/source/doc/oleprops.hxx sfx2/source/doc/oleprops.hxx
+index 7ed7655..924e131 100755
+--- sfx2/source/doc/oleprops.hxx
++++ sfx2/source/doc/oleprops.hxx
+@@ -83,6 +83,10 @@ const sal_Int32 PROPID_CREATED          = 12;
+ const sal_Int32 PROPID_LASTSAVED        = 13;
+ const sal_Int32 PROPID_THUMBNAIL        = 17;
+ 
++// some Builtin properties
++const sal_Int32 PROPID_CATEGORY         = 0x2;
++const sal_Int32 PROPID_COMPANY          = 0xf;
++const sal_Int32 PROPID_MANAGER          = 0xe;
+ // predefined codepages
+ const sal_uInt16 CODEPAGE_UNKNOWN       = 0;
+ const sal_uInt16 CODEPAGE_UNICODE       = 1200;
+diff --git sfx2/source/doc/sfxbasemodel.cxx sfx2/source/doc/sfxbasemodel.cxx
+index f5fd341..2915d43 100644
+--- sfx2/source/doc/sfxbasemodel.cxx
++++ sfx2/source/doc/sfxbasemodel.cxx
+@@ -784,7 +784,15 @@ uno::Reference< document::XDocumentInfo > SAL_CALL SfxBaseModel::getDocumentInfo
+ 
+ 	return m_pData->m_xDocumentInfo;
+ }
 -
-diff --git sc/source/ui/vba/vbauserform.hxx sc/source/ui/vba/vbauserform.hxx
-deleted file mode 100644
-index 2c8a1b7..0000000
---- sc/source/ui/vba/vbauserform.hxx
-+++ /dev/null
-@@ -1,78 +0,0 @@
--/*************************************************************************
-- *
-- *  OpenOffice.org - a multi-platform office productivity suite
-- *
-- *  $RCSfile$
-- *
-- *  $Revision$
-- *
-- *  last change: $Author$ $Date$
-- *
-- *  The Contents of this file are made available subject to
-- *  the terms of GNU Lesser General Public License Version 2.1.
-- *
-- *
-- *    GNU Lesser General Public License Version 2.1
-- *    =============================================
-- *    Copyright 2005 by Sun Microsystems, Inc.
-- *    901 San Antonio Road, Palo Alto, CA 94303, USA
-- *
-- *    This library is free software; you can redistribute it and/or
-- *    modify it under the terms of the GNU Lesser General Public
-- *    License version 2.1, as published by the Free Software Foundation.
-- *
-- *    This library 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 for more details.
-- *
-- *    You should have received a copy of the GNU Lesser General Public
-- *    License along with this library; if not, write to the Free Software
-- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-- *    MA  02111-1307  USA
-- *
-- ************************************************************************/
--#ifndef SC_VBA_USERFORM_HXX
--#define SC_VBA_USERFORM_HXX
++void 
++SfxBaseModel::setDocumentProperties( const uno::Reference< document::XDocumentProperties >& rxNewDocProps )
++{
++	// object already disposed?
++    ::vos::OGuard aGuard( Application::GetSolarMutex() );
++    if ( impl_isDisposed() )
++        throw lang::DisposedException();
++    m_pData->m_xDocumentProperties.set(rxNewDocProps, uno::UNO_QUERY_THROW);
++}
+ // document::XDocumentPropertiesSupplier:
+ uno::Reference< document::XDocumentProperties > SAL_CALL
+ SfxBaseModel::getDocumentProperties()
+diff --git sfx2/source/inc/SfxDocumentMetaData.hxx sfx2/source/inc/SfxDocumentMetaData.hxx
+index 35b0984..0167d18 100644
+--- sfx2/source/inc/SfxDocumentMetaData.hxx
++++ sfx2/source/inc/SfxDocumentMetaData.hxx
+@@ -48,5 +48,16 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
+ 
+ } // closing component helper namespace
+ 
++namespace comp_CompatWriterDocProps {
++
++namespace css = ::com::sun::star;
++
++// component and service helper functions:
++::rtl::OUString SAL_CALL _getImplementationName();
++css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
++css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
++        css::uno::Reference< css::uno::XComponentContext > const & context );
++
++}
+ #endif
+ 
+diff --git solenv/inc/libs.mk solenv/inc/libs.mk
+index a26cdb1..71c3103 100644
+--- solenv/inc/libs.mk
++++ solenv/inc/libs.mk
+@@ -195,6 +195,7 @@ SAXLIB=-lsax$(DLLPOSTFIX)
+ MAILLIB=-lmail
+ DOCMGRLIB=-ldmg$(DLLPOSTFIX)
+ BASICLIB=-lsb$(DLLPOSTFIX)
++VBAHELPERLIB=-lvbahelper$(DLLPOSTFIX)
+ DBTOOLSLIB=-ldbtools$(DLLPOSTFIX)
+ HM2LIBSH=-lhmwrpdll
+ HM2LIBST=-lhmwrap
+@@ -437,6 +438,7 @@ SAXLIB=isax.lib
+ MAILLIB=mail.lib
+ DOCMGRLIB=docmgr.lib
+ BASICLIB=basic.lib
++VBAHELPERLIB=vbahelper.lib
+ TKTLIB=tkt.lib
+ SJLIB=sj.lib
+ SVXLIB=isvx.lib
+diff --git svx/inc/svx/mstoolbar.hxx svx/inc/svx/mstoolbar.hxx
+index d78a90d..1e28ded 100644
+--- svx/inc/svx/mstoolbar.hxx
++++ svx/inc/svx/mstoolbar.hxx
+@@ -27,6 +27,7 @@ public:
+     virtual rtl::OUString MSOTCIDToOOCommand( sal_Int16 msoTCID ) = 0; 
+ };
+ 
++class SfxObjectShell;
+ 
+ class SVX_DLLPUBLIC CustomToolBarImportHelper
+ {
+@@ -39,16 +40,16 @@ class SVX_DLLPUBLIC CustomToolBarImportHelper
+     std::auto_ptr< MSOCommandConvertor > pMSOCmdConvertor;
+     css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp;
+     css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
 -
--#include <cppuhelper/implbase1.hxx>
--#include <ooo/vba/msforms/XUserForm.hpp>
--#include <com/sun/star/awt/XDialog.hpp>
--#include <com/sun/star/frame/XModel.hpp>
++    SfxObjectShell& mrDocSh;
+ public:
+-    CustomToolBarImportHelper( const css::uno::Reference< css::frame::XModel >& rxModel, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
++    CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
+ 
+     void setMSOCommandMap( MSOCommandConvertor* pCnvtr ) { pMSOCmdConvertor.reset( pCnvtr ); }
+     css::uno::Reference< css::ui::XUIConfigurationManager > getCfgManager();
+     css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager();
+ 
+ 
+-    static css::uno::Any createCommandFromMacro( const rtl::OUString& sCmd );
++    css::uno::Any createCommandFromMacro( const rtl::OUString& sCmd );
+ 
+     void addIcon( const css::uno::Reference< css::graphic::XGraphic >& xImage, const rtl::OUString& sString );
+     void applyIcons();
+@@ -131,7 +132,7 @@ public:
+     ~TBCGeneralInfo() {}
+     bool Read(SvStream *pS);
+     void Print( FILE* );
+-    bool ImportToolBarControlData( std::vector< css::beans::PropertyValue >& );
++    bool ImportToolBarControlData( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
+ };
+ 
+ class SVX_DLLPUBLIC TBCBitMap : public TBBase
+diff --git svx/inc/svxmsbas.hxx svx/inc/svxmsbas.hxx
+index 5e87fe6..74c89f9 100644
+--- svx/inc/svxmsbas.hxx
++++ svx/inc/svxmsbas.hxx
+@@ -102,6 +102,7 @@ private:
+ 		const String &rSubStorageName, BOOL bVBAMode );
+ 	SVX_DLLPRIVATE BOOL CopyStorage_Impl( const String& rStorageName,
+ 						   const String &rSubStorageName);
++        rtl::OUString msProjectName;
+ };
+ 
+ #endif
+diff --git svx/source/msfilter/mstoolbar.cxx svx/source/msfilter/mstoolbar.cxx
+index cb1c4bf..2b8a906 100644
+--- svx/source/msfilter/mstoolbar.cxx
++++ svx/source/msfilter/mstoolbar.cxx
+@@ -8,6 +8,8 @@
+ #include <vcl/graph.hxx>
+ #include <vcl/bitmapex.hxx>
+ #include <map>
++#include <sfx2/objsh.hxx>
++#include <basic/basmgr.hxx>
+ 
+ int TBBase::nIndent = 0;
+ 
+@@ -36,9 +38,9 @@ void CustomToolBarImportHelper::addIcon( const uno::Reference< graphic::XGraphic
+     iconcommands.push_back( item );
+ }
+ 
+-CustomToolBarImportHelper::CustomToolBarImportHelper( const uno::Reference< frame::XModel >& rxModel,  const css::uno::Reference< css::ui::XUIConfigurationManager>& rxAppCfgMgr )
++CustomToolBarImportHelper::CustomToolBarImportHelper( SfxObjectShell& rDocShell,  const css::uno::Reference< css::ui::XUIConfigurationManager>& rxAppCfgMgr ) : mrDocSh( rDocShell ) 
+ {
+-    m_xCfgSupp.set( rxModel, uno::UNO_QUERY_THROW );
++    m_xCfgSupp.set( mrDocSh.GetModel(), uno::UNO_QUERY_THROW );
+     m_xAppCfgMgr.set( rxAppCfgMgr, uno::UNO_QUERY_THROW );
+ }
+ 
+@@ -58,10 +60,18 @@ uno::Any
+ CustomToolBarImportHelper::createCommandFromMacro( const rtl::OUString& sCmd )
+ {
+ //"vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"    
+-    static rtl::OUString part1 = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
++    static rtl::OUString scheme = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
+     static rtl::OUString part2 = rtl::OUString::createFromAscii("?language=Basic&location=document");
++    rtl::OUString sProject( RTL_CONSTASCII_USTRINGPARAM("Standard") );
++    if ( mrDocSh.GetBasicManager()->GetName().Len() )
++        sProject = mrDocSh.GetBasicManager()->GetName();
++    sProject += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") );
++
++    // #TODO #FIXME a script can also be loosly defined ( e.g. with no module 
++    // spec )
++
+     // create script url
+-    rtl::OUString scriptURL = part1 + sCmd + part2;
++    rtl::OUString scriptURL = scheme + sProject + sCmd + part2;
+     return uno::makeAny( scriptURL );
+ }
+ 
+@@ -197,7 +207,7 @@ bool TBCData::Read(SvStream *pS)
+ 
+ bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& /*toolbarcontainer*/, CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props )
+ {
+-    controlGeneralInfo.ImportToolBarControlData( props );
++    controlGeneralInfo.ImportToolBarControlData( helper, props );
+     beans::PropertyValue aProp;
+     aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Visible") ) ;
+     aProp.Value = uno::makeAny( rHeader.isVisible() ); // where is the visible attribute stored
+@@ -356,7 +366,7 @@ TBCGeneralInfo::Print( FILE* fp )
+ }
+ 
+ bool 
+-TBCGeneralInfo::ImportToolBarControlData( std::vector< beans::PropertyValue >& sControlData )
++TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std::vector< beans::PropertyValue >& sControlData )
+ {
+     if ( ( bFlags & 0x5 ) )
+     {
+@@ -366,7 +376,7 @@ TBCGeneralInfo::ImportToolBarControlData( std::vector< beans::PropertyValue >& s
+         if ( extraInfo.getOnAction().getLength() )
+         {
+             aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") );
+-            aProp.Value = CustomToolBarImportHelper::createCommandFromMacro( extraInfo.getOnAction() );
++            aProp.Value = helper.createCommandFromMacro( extraInfo.getOnAction() );
+             sControlData.push_back( aProp );
+         }
+ 
+@@ -379,7 +389,7 @@ TBCGeneralInfo::ImportToolBarControlData( std::vector< beans::PropertyValue >& s
+         sControlData.push_back( aProp );
+ 
+         aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") );
+-        aProp.Value = uno::makeAny( CustomToolBarImportHelper::createCommandFromMacro( tooltip.getString() ) ); 
++        aProp.Value = uno::makeAny( helper.createCommandFromMacro( tooltip.getString() ) ); 
+         sControlData.push_back( aProp );
+ 
+         // #TODO find out what is the property for tooltip?
+diff --git svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
+index 2eff354..a8aac8a 100644
+--- svx/source/msfilter/msvbasic.cxx
++++ svx/source/msfilter/msvbasic.cxx
+@@ -40,9 +40,929 @@
+ #include <osl/endian.h>
+ #include <rtl/tencinfo.h>   //rtl_getTextEncodingFromWindowsCodePage
+ #include "msvbasic.hxx"
++#include <fstream>
++#include <memory>
++#include <rtl/ustrbuf.hxx>
+ 
+ using namespace ::com::sun::star::script;
+ 
++// #FIXME this routine is stolen from msocximex ( needs to be somewhere central )
++
++const sal_uInt32 SVX_MSOCX_SIZEMASK     = 0x7FFFFFFF;   /// Mask for character buffer size.
++const sal_uInt32 SVX_MSOCX_COMPRESSED   = 0x80000000; 
++
++inline bool lclIsCompressed( sal_uInt32 nLenFld )
++{
++    return (nLenFld & SVX_MSOCX_COMPRESSED) != 0;
++}
++
++
++/** Extracts and returns the memory size of the character buffer.
++    @return  Character buffer size (may differ from resulting string length!).
++ */
++inline sal_uInt32 lclGetBufferSize( sal_uInt32 nLenFld )
++{
++    return nLenFld & SVX_MSOCX_SIZEMASK;
++}
++/** Creates an OUString from a character array created with lclReadCharArray().
++
++    The passed parameters must match, that means the length field must be the
++    same used to create the passed character array.
++
++    @param pcCharArr
++        The character array returned by lclReadCharArray(). May be compressed
++        or uncompressed, next parameter nLenFld will specify this.
++
++    @param nLenFld
++        MUST be the same string length field that has been passed to
++        lclReadCharArray() to create the character array in previous parameter
++        pcCharArr.
++
++    @return
++        An OUString containing the decoded string data. Will be empty if
++        pcCharArr is 0.
++ */
++rtl::OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
++{
++    rtl::OUStringBuffer aBuffer;
++    sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
++    if( lclIsCompressed( nLenFld ) )
++    {
++        // buffer contains compressed Unicode, not encoded bytestring
++        sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize );
++        aBuffer.setLength( nStrLen );
++        const char* pcCurrChar = pcCharArr;
++        for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar, ++pcCurrChar )
++            /*  *pcCurrChar may contain negative values and therefore MUST be
++                casted to unsigned char, before assigned to a sal_Unicode. */
++            aBuffer.setCharAt( nChar, static_cast< unsigned char >( *pcCurrChar ) );
++    }
++    else
++    {
++        // buffer contains Little-Endian Unicode
++        sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize ) / 2;
++        aBuffer.setLength( nStrLen );
++        const char* pcCurrChar = pcCharArr;
++        for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar )
++        {
++            /*  *pcCurrChar may contain negative values and therefore MUST be
++                casted to unsigned char, before assigned to a sal_Unicode. */
++            sal_Unicode cChar = static_cast< unsigned char >( *pcCurrChar++ );
++            cChar |= (static_cast< unsigned char >( *pcCurrChar++ ) << 8);
++            aBuffer.setCharAt( nChar, cChar );
++        }
++    }
++    return aBuffer.makeStringAndClear();
++}
++
++
++namespace MSLZSS {
++
++static unsigned int getShift( sal_uInt32 nPos )
++{
++    if (nPos <= 0x80) {
++        if (nPos <= 0x20)
++            return (nPos <= 0x10) ? 12 : 11;
++        else
++            return (nPos <= 0x40) ? 10 : 9;
++    } else {
++    if (nPos <= 0x200)
++        return (nPos <= 0x100) ? 8 : 7;
++    else if (nPos <= 0x800)
++        return (nPos <= 0x400) ? 6 : 5;
++    else
++        return 4;
++    }
++}
++
++SvMemoryStream *decompressAsStream( SvStream *pStream, sal_uInt32 nOffset, sal_uInt32 *pCompressedLength = NULL, sal_uInt32 *pLength = NULL )
++{
++    SvMemoryStream *pResult;
++    const sal_Int32 nWINDOWLEN = 4096;
++    pResult = new SvMemoryStream();
++
++    sal_uInt8 nLeadbyte;
++    unsigned int nPos = 0;
++    int nLen, nDistance, nShift, nClean=1;
++    sal_uInt8 aHistory[ nWINDOWLEN ];
++
++    pStream->Seek( nOffset + 3 );
++
++    while( pStream->Read( &nLeadbyte, 1 ) )
++    {
++        for(int nMask=0x01; nMask < 0x100; nMask = nMask<<1)
++        {
++            // we see if the leadbyte has flagged this location as a dataunit
++            // which is actually a token which must be looked up in the history
++            if( nLeadbyte & nMask )
++            {
++                sal_uInt16 nToken;
++            
++                *pStream >> nToken;
++    
++                if (nClean == 0)
++                    nClean=1;
++    
++                //For some reason the division of the token into the length
++                //field of the data to be inserted, and the distance back into
++                //the history differs depending on how full the history is
++                nShift = getShift( nPos % nWINDOWLEN );
++        
++                nLen = (nToken & ((1<<nShift) - 1)) + 3;
++                nDistance = nToken >> nShift;
++        
++                //read the len of data from the history, wrapping around the
++                //nWINDOWLEN boundary if necessary data read from the history
++                //is also copied into the recent part of the history as well.
++                for (int i = 0; i < nLen; i++)
++                {
++                    unsigned char c;
++                    c = aHistory[(nPos-nDistance-1) % nWINDOWLEN];
++                    aHistory[nPos % nWINDOWLEN] = c;
++                    nPos++;
++                }
++            }
++            else
++            {
++                // special boundary case code, not guarantueed to be correct
++                // seems to work though, there is something wrong with the
++                // compression scheme (or maybe a feature) where when the data
++                // ends on a nWINDOWLEN boundary and the excess bytes in the 8
++                // dataunit list are discarded, and not interpreted as tokens
++                // or normal data.
++                if ((nPos != 0) && ((nPos % nWINDOWLEN) == 0) && (nClean))
++                {
++                    pStream->SeekRel(2);
++                    nClean=0;
++                    pResult->Write( aHistory, nWINDOWLEN );
++                    break;
++                }
++                //This is the normal case for when the data unit is not a
++                //token to be looked up, but instead some normal data which
++                //can be output, and placed in the history.
++                if (pStream->Read(&aHistory[nPos % nWINDOWLEN],1))
++                    nPos++;
++                    
++                if (nClean == 0)
++                    nClean=1;
++            }
++        }
++    }
++    if (nPos % nWINDOWLEN)
++        pResult->Write( aHistory, nPos % nWINDOWLEN );
++    pResult->Flush();
++
++    if( pCompressedLength )
++        *pCompressedLength = nPos;
++    
++    if( pLength )
++        *pLength = pResult->Tell();
++
++    pResult->Seek( 0 );
++
++    return pResult;
++} 
++
++} //MSZSS
++
++// also _VBA_PROJECT_VDPI can be used to create a usable 
++// ( and much smaller ) "_VBA_PROJECT" stream
++
++// _VBA_PROJECT Stream Version Dependant Project Information
++// _VBA_PROJECT Stream Version Dependant Project Information
++
++class _VBA_PROJECT_VDPI
++{
++public:
++sal_Int16 Reserved1;
++sal_Int16 Version;
++sal_Int8 Reserved2;
++sal_Int16 Reserved3;
++sal_uInt8* PerformanceCache;
++sal_Int32 PerformanceCacheSize;
++_VBA_PROJECT_VDPI(): Reserved1( 0x61CC), Version( 0xFFFF ), Reserved2(0x0), Reserved3(0x0), PerformanceCache(0),  PerformanceCacheSize(0) {}
++~_VBA_PROJECT_VDPI()
++{
++    if (  PerformanceCache )
++       delete [] PerformanceCache;
++    PerformanceCache = 0;
++    PerformanceCacheSize = 0;
++}
++void read(){}
++void write( SvStream* pStream )
++{
++    *pStream << Reserved1 << Version << Reserved2 << Reserved3;
++    for( sal_Int32 i = 0; PerformanceCache && i < PerformanceCacheSize; ++i )
++    {
++        *pStream >> PerformanceCache[ i ];
++    }
++}
++};
++
++class ProjectSysKindRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 Size;
++sal_Int32 SysKind;
++ProjectSysKindRecord(): Id(0x1), Size(0x4), SysKind( 0x1 ) {}
++void read( SvStream* pStream )
++{
++    *pStream >> Id >> Size >> SysKind;
++}
++};
++
++class ProjectLcidRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 Size;
++sal_Int32 Lcid;
++
++ProjectLcidRecord() : Id( 0x2 ), Size( 0x4 ), Lcid( 0x409 ) {}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectLcidRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> Size >> Lcid;
++}
++};
++
++class ProjectLcidInvokeRecord
++{
++sal_Int16 Id;
++sal_Int32 Size;
++sal_Int32 LcidInvoke;
++public:
++ProjectLcidInvokeRecord() : Id( 0x14 ), Size( 0x4 ), LcidInvoke( 0x409 ) {}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectLcidInvokeRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> Size >> LcidInvoke;
++}
++};
++
++class ProjectCodePageRecord
++{
++sal_Int16 Id;
++sal_Int32 Size;
++sal_Int16 CodePage;
++public:
++// #FIXME get a better default for the CodePage
++ProjectCodePageRecord() : Id( 0x03 ), Size( 0x2 ), CodePage( 0x0 ) {}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectCodePageRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> Size >> CodePage;
++}
++};
++class ProjectNameRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 SizeOfProjectName;
++sal_uInt8* ProjectName;
++rtl::OUString msProjectName;
++ProjectNameRecord() : Id( 0x04 ), SizeOfProjectName( 0x0 ), ProjectName(0) {}
++~ProjectNameRecord()
++{
++    delete [] ProjectName;
++    ProjectName = 0;
++}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectNameRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> SizeOfProjectName;
++    if ( ProjectName )
++        delete [] ProjectName;
++
++    if ( SizeOfProjectName ) 
++    {
++        ProjectName = new sal_uInt8[ SizeOfProjectName ];
++        OSL_TRACE("ProjectNameRecord about to read name from [0x%x], size %d", pStream->Tell(), SizeOfProjectName );
++        pStream->Read( ProjectName, SizeOfProjectName );
++        msProjectName = lclCreateOUString( reinterpret_cast< const char* >( ProjectName ), ( SVX_MSOCX_COMPRESSED |  SizeOfProjectName ) );
++    }
++}
++};
++
++class ProjectDocStringRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 SizeOfDocString;
++sal_uInt8* DocString;
++sal_Int16 Reserved;
++sal_Int32 SizeOfDocStringUnicode;
++sal_uInt8* DocStringUnicode;
++
++ProjectDocStringRecord() : Id( 0x5 ), SizeOfDocString( 0x0 ), DocString( 0 ), Reserved( 0x0 ), SizeOfDocStringUnicode( 0 ), DocStringUnicode( 0 ) {}
++
++~ProjectDocStringRecord()
++{
++    delete [] DocString;
++    delete [] DocStringUnicode;
++    DocString = 0;
++    DocStringUnicode = 0;
++}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectDocStringRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> SizeOfDocString;
++
++    if ( DocString )
++        delete [] DocString;
++
++    DocString = new sal_uInt8[ SizeOfDocString ];
++    pStream->Read( DocString, SizeOfDocString );
++
++    if ( SizeOfDocStringUnicode )
++        delete [] DocStringUnicode;
++
++    *pStream >> Reserved >> SizeOfDocStringUnicode;
++
++    if ( DocStringUnicode )
++        delete [] DocStringUnicode;
++
++    DocStringUnicode =  new sal_uInt8[ SizeOfDocStringUnicode ];
++
++    pStream->Read( DocStringUnicode, SizeOfDocStringUnicode );
++}
++
++};
++
++class ProjectHelpFilePath
++{
++public:
++sal_Int16 Id;
++sal_Int32 SizeOfHelpFile1;
++sal_uInt8* HelpFile1;
++sal_Int16 Reserved;
++sal_Int32 SizeOfHelpFile2;
++sal_uInt8* HelpFile2;
++
++ProjectHelpFilePath() : Id( 0x06 ), SizeOfHelpFile1(0), HelpFile1(0), Reserved(0x0), SizeOfHelpFile2(0), HelpFile2(0) {}
++~ProjectHelpFilePath()
++{
++    if ( HelpFile1 )
++        delete [] HelpFile1;
++    if ( HelpFile2 )
++        delete [] HelpFile2;
++    HelpFile1 = 0;
++    HelpFile2 = 0;
++}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectHelpFilePath [0x%x]", pStream->Tell() );
++    *pStream >> Id >> SizeOfHelpFile1;
++
++    if ( HelpFile1 )
++        delete HelpFile1;
++
++    HelpFile1 = new sal_uInt8[ SizeOfHelpFile1 ];
++    pStream->Read( HelpFile1, SizeOfHelpFile1 );
++
++    *pStream >> Reserved >> SizeOfHelpFile2;
++
++    if ( HelpFile2 )
++        delete HelpFile2;
++
++    HelpFile2 = new sal_uInt8[ SizeOfHelpFile2 ];
++    pStream->Read( HelpFile2, SizeOfHelpFile2 );
++  
++}
++};
++
++class ProjectHelpContextRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 Size;    
++sal_Int32 HelpContext;    
++
++ProjectHelpContextRecord() : Id( 0x7 ), Size( 0x4 ), HelpContext( 0 ) {}
++void read( SvStream* pStream )
++{
++    
++   OSL_TRACE("ProjectHelpContextRecord [0x%x]", pStream->Tell() );
++   *pStream >> Id >> Size >> HelpContext;
++}
++
++};
++
++class ProjectLibFlagsRecord
++{
++sal_Int16 Id;
++sal_Int32 Size;
++sal_Int32 ProjectLibFlags;
++
++public:
++ProjectLibFlagsRecord() : Id( 0x8 ), Size( 0x4 ), ProjectLibFlags( 0x0 ) {}
++void read( SvStream* pStream ) 
++{
++    OSL_TRACE("ProjectLibFlagsRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> Size >> ProjectLibFlags;
++}
++};
++
++class ProjectVersionRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 Reserved;
++sal_Int32 VersionMajor;
++sal_Int16 VersionMinor;
++ProjectVersionRecord() : Id( 0x9 ), Reserved( 0x4 ), VersionMajor( 0x1 ), VersionMinor( 0 ) {}
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectVersionRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> Reserved >> VersionMajor >> VersionMinor;
++}
++};
++
++class ProjectConstantsRecord
++{
++sal_Int16 Id;
++sal_Int32 SizeOfConstants;
++sal_uInt8* Constants;
++sal_Int16 Reserved;
++sal_Int32 SizeOfConstantsUnicode;
++sal_uInt8* ConstantsUnicode;
++public:
++ProjectConstantsRecord() : Id( 0xC ), SizeOfConstants( 0 ), Constants( 0 ), Reserved( 0x3C ), SizeOfConstantsUnicode( 0 ), ConstantsUnicode(0) {}
++
++~ProjectConstantsRecord()
++{
++    delete [] Constants;
++    Constants = 0;
++    delete [] ConstantsUnicode;
++    ConstantsUnicode = 0;
++}
++
++void read( SvStream* pStream )
++{
++    OSL_TRACE("ProjectConstantsRecord [0x%x]", pStream->Tell() );
++   *pStream >> Id >> SizeOfConstants;
++    if ( Constants )
++        delete [] Constants;
++    Constants = new sal_uInt8[ SizeOfConstants ];
++
++    pStream->Read( Constants, SizeOfConstants );
++
++    *pStream >> Reserved;
++
++    if ( ConstantsUnicode )
++        delete [] ConstantsUnicode;
++
++    *pStream >> SizeOfConstantsUnicode;
++
++    ConstantsUnicode = new sal_uInt8[ SizeOfConstantsUnicode ];
++    pStream->Read( ConstantsUnicode, SizeOfConstantsUnicode );
++}
++
++};
++
++class ReferenceNameRecord
++{
++public:
++sal_Int16 Id;
++sal_Int32 SizeOfName;
++sal_uInt8* Name;
++sal_Int16 Reserved;
++sal_Int32 SizeOfNameUnicode;
++sal_uInt8* NameUnicode;
++
++ReferenceNameRecord() : Id( 0x16 ), SizeOfName( 0 ), Name( 0 ), Reserved( 0x3E ), SizeOfNameUnicode( 0 ), NameUnicode( 0 ) {}
++~ReferenceNameRecord()
++{
++    delete [] Name;
++    Name = 0;
++    delete [] NameUnicode;
++    NameUnicode = 0;
++}
++
++void read( SvStream* pStream )
++{
++    OSL_TRACE("NameRecord [0x%x]", pStream->Tell() );
++    *pStream >> Id >> SizeOfName;
++ 
++    if ( Name )
++        delete [] Name;
++
++    Name = new sal_uInt8[ SizeOfName ];
++
++    pStream->Read( Name, SizeOfName );
++
++    *pStream >> Reserved >> SizeOfNameUnicode;
++
++    if ( NameUnicode )
++        delete [] Name;
++
++    NameUnicode = new sal_uInt8[ SizeOfNameUnicode ];
++    pStream->Read( NameUnicode, SizeOfNameUnicode );
++}
++
++};
++
++// Baseclass for ReferenceControlRecord, ReferenceRegisteredRecord, ReferenceProjectRecord
++class DirDumper; 
++
++class BaseReferenceRecord 
++{
++public:
++virtual ~BaseReferenceRecord(){}
++virtual bool read( SvStream* pStream ) = 0;
++virtual void import( VBA_Impl& ){}
++};
++
++
++class ReferenceProjectRecord : public BaseReferenceRecord
++{
++public:
++    sal_uInt16 Id;
++    sal_uInt32 Size;
++    sal_uInt32 SizeOfLibidAbsolute;
++    sal_uInt8* pLibidAbsolute;
++    sal_uInt32 SizeOfLibidRelative; 
++    sal_uInt8* pLibidRelative;
++    sal_uInt32 MajorVersion;
++    sal_uInt16 MinorVersion;
++    rtl::OUString msAbsoluteLibid; 
++    rtl::OUString msRelativeLibid; 
++
++    virtual bool read( SvStream* pStream );
++    virtual void import( VBA_Impl& rDir );
++    ReferenceProjectRecord();
++    ~ReferenceProjectRecord();
++};
++
++ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), pLibidAbsolute( NULL ), SizeOfLibidRelative( 0 ), pLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
++{
++}
++
++ReferenceProjectRecord::~ReferenceProjectRecord()
++{
++    if ( pLibidAbsolute )
++        delete[] pLibidAbsolute;
++    if ( pLibidRelative )
++        delete[] pLibidRelative;
++}
++
++bool ReferenceProjectRecord::read( SvStream* pStream )
++{
++    OSL_TRACE("ReferenceProjectRecord [0x%x]", pStream->Tell() ); 
++    *pStream >> Id >> Size >> SizeOfLibidAbsolute;
++
++    if ( SizeOfLibidAbsolute )
++    {
++        pLibidAbsolute = new sal_uInt8[ SizeOfLibidAbsolute ];
++        OSL_TRACE("ReferenceProjectRecord about to read LibidAbsolute at [0x%x]", pStream->Tell() );
++        pStream->Read( pLibidAbsolute, SizeOfLibidAbsolute );
++    }
++
++    *pStream >> SizeOfLibidRelative; 
++
++    if ( SizeOfLibidRelative )
++    {
++        pLibidRelative = new sal_uInt8[ SizeOfLibidRelative ];
++        OSL_TRACE("ReferenceProjectRecord about to read LibidRelative at [0x%x]", pStream->Tell() );
++        pStream->Read( pLibidRelative, SizeOfLibidRelative );
++    }
++
++    *pStream >> MajorVersion >> MinorVersion;
++
++    // array size is ORed with SVX_MSOCX_COMPRESSED to force processing of ascii bytes ( and not 
++    // 16 bit unicode )
++    // the offset of 3 is needed to skip the ProjectReference "*\" and project kind ( 0x4[1-4] ) info.
++
++    msAbsoluteLibid = lclCreateOUString( reinterpret_cast< const char* >( pLibidAbsolute + 3 ), ( SVX_MSOCX_COMPRESSED | (SizeOfLibidAbsolute - 3 )));
++    msRelativeLibid = lclCreateOUString( reinterpret_cast< const char* >( pLibidRelative + 3 ), ( SVX_MSOCX_COMPRESSED | ( SizeOfLibidRelative -3 )));
++
++    OSL_TRACE("ReferenceProjectRecord - absolute path %s", rtl::OUStringToOString( msAbsoluteLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
++    OSL_TRACE("ReferenceProjectRecord - relative path %s", rtl::OUStringToOString( msRelativeLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
++    return true;
++}
++
++void ReferenceProjectRecord::import( VBA_Impl& rDir )
++{
++    rDir.AddProjectReference( msAbsoluteLibid );
++}
++
++class ReferenceRegisteredRecord : public BaseReferenceRecord
++{
++public:
++    sal_uInt16 Id;
++    sal_uInt32 Size;
++    sal_uInt32 SizeOfLibid;
++    sal_uInt8* pLibid;
++    sal_Int32 Reserved1;
++    sal_Int16 Reserved2;
++
++    ReferenceRegisteredRecord();
++    ~ReferenceRegisteredRecord();
++    bool read( SvStream* pStream );
++};
++
++ReferenceRegisteredRecord::ReferenceRegisteredRecord() : Id( 0x000D ), Size( 0 ), SizeOfLibid( 0 ), pLibid( NULL ), Reserved1( 0 ), Reserved2( 0 )
++{
++}
++
++ReferenceRegisteredRecord::~ReferenceRegisteredRecord()
++{
++    if ( pLibid )
++    {
++        delete[] pLibid;
++    }
++}
++
++bool 
++ReferenceRegisteredRecord::read( SvStream* pStream )
++{
++    OSL_TRACE("ReferenceRegisteredRecord [0x%x]", pStream->Tell() ); 
++    *pStream >> Id >> Size >> SizeOfLibid;
++    if ( SizeOfLibid )
++    {
++        pLibid = new sal_uInt8[ SizeOfLibid ];
++        OSL_TRACE("ReferenceRegisteredRecord about to read Libid [0x%x]", pStream->Tell() ); 
++        pStream->Read( pLibid, SizeOfLibid );
++    }
++    *pStream >> Reserved1 >> Reserved2;
++    return true;
++}
++
++class ReferenceOriginalRecord
++{
++public:
++    sal_uInt16 Id;
++    sal_uInt32 SizeOfLibOriginal;
++    sal_uInt8* pLibidOriginal;
++
++
++ReferenceOriginalRecord() : Id( 0x033 ), SizeOfLibOriginal( 0 ), pLibidOriginal( NULL )
++{
++}
++
++~ReferenceOriginalRecord()
++{
++    if ( pLibidOriginal )
++        delete[] pLibidOriginal;
++}
++
++void read( SvStream* pStream )
++{
++    *pStream >> Id >> SizeOfLibOriginal;
++    if ( SizeOfLibOriginal )
++    {
++        pLibidOriginal = new sal_uInt8[ SizeOfLibOriginal ];
++        pStream->Read( pLibidOriginal, SizeOfLibOriginal );
++    }
++}
++
++};
++
++class ReferenceControlRecord : public BaseReferenceRecord
++{
++public:
++ReferenceOriginalRecord OriginalRecord;
++sal_Int16 Id;
++sal_uInt32 SizeTwiddled;
++sal_uInt32 SizeOfLibidTwiddled;
++sal_uInt8* LibidTwiddled;
++sal_uInt32 Reserved1;
++sal_uInt16 Reserved2;
++ReferenceNameRecord* NameRecordExtended;// Optional
++sal_uInt16 Reserved3;
++sal_uInt32 SizeExtended;
++sal_uInt32 SizeOfLibidExtended;
++sal_uInt8* LibidExtended;
++sal_uInt32 Reserved4;
++sal_uInt16 Reserved5;
++sal_uInt8  OriginalTypeLib[ 16 ];
++sal_uInt32 Cookie;
++
++ReferenceControlRecord() : Id( 0x2F ), SizeTwiddled( 0 ), SizeOfLibidTwiddled( 0 ), LibidTwiddled( 0 ), Reserved1( 0 ), Reserved2( 0 ), NameRecordExtended( 0 ), Reserved3( 0x30 ), SizeExtended( 0 ), SizeOfLibidExtended( 0 ), LibidExtended( 0 ), Reserved4( 0 ), Reserved5( 0 ), Cookie( 0 )
++{
++    for( int i = 0; i < 16; ++i )
++        OriginalTypeLib[ i ] = 0;
++}
++
++~ReferenceControlRecord()
++{
++    delete LibidTwiddled;
++    delete NameRecordExtended;
++    delete [] LibidExtended;
++    LibidTwiddled = 0;
++    NameRecordExtended = 0;
++    LibidExtended = 0;
++}
++
++bool read( SvStream* pStream )
++{
++    OSL_TRACE("ReferenceControlRecord [0x%x]", pStream->Tell() ); 
++    OriginalRecord.read( pStream );
++    *pStream >> Id >> SizeTwiddled >> SizeOfLibidTwiddled;
++
++    if ( SizeOfLibidTwiddled )
++    {
++        LibidTwiddled = new sal_uInt8[ SizeOfLibidTwiddled ];
++        pStream->Read( LibidTwiddled,  SizeOfLibidTwiddled );
++    }
++
++    *pStream >> Reserved1 >> Reserved2;
++
++    long nPos = pStream->Tell();
++    // peek at the id for optional NameRecord
++    sal_Int16 nTmpId;
++    *pStream >> nTmpId;
++    if ( nTmpId == 0x30 )
++    {
++        Reserved3 = 0x30;
++    }
++    else
++    {
++        pStream->Seek( nPos );
++        NameRecordExtended = new ReferenceNameRecord();
++        NameRecordExtended->read( pStream );
++        *pStream >> Reserved3;
++    }
++    *pStream >> SizeExtended >> SizeOfLibidExtended;
++
++    if ( SizeExtended )
++    {
++        LibidExtended = new sal_uInt8[ SizeOfLibidExtended ]; 
++        pStream->Read( LibidExtended, SizeOfLibidExtended );
++    } 
++
++    *pStream >> Reserved4;
++    *pStream >> Reserved5;
++
++    pStream->Read( OriginalTypeLib, sizeof( OriginalTypeLib ) );
++    *pStream >> Cookie;
++    return true;
++}
++
++};
++
++class ReferenceRecord : public BaseReferenceRecord
++{
++public:
++// NameRecord is Optional
++ReferenceNameRecord* NameRecord;
++BaseReferenceRecord*  aReferenceRecord;
++ReferenceRecord(): NameRecord(0), aReferenceRecord(0) {}
++~ReferenceRecord()
++{
++    if ( NameRecord )
++        delete NameRecord;       
++    if ( aReferenceRecord )
++        delete aReferenceRecord;       
++}
++
++// false return would mean failed to read Record e.g. end of array encountered
++// Note: this read routine will make sure the stream is pointing to where it was the 
++// method was called ) 
++
++bool read( SvStream* pStream )
++{
++    OSL_TRACE("ReferenceRecord [0x%x]", pStream->Tell() );
++    bool bRead = true;
++    long nStart = pStream->Tell();
++    long nPos = nStart;
++    // Peek at the ID 
++    sal_Int16 Id;
++    *pStream >> Id;
++    pStream->Seek( nPos ); // place back before Id
++    if ( Id == 0x16 ) // Optional NameRecord
++    {
++        NameRecord = new ReferenceNameRecord();
++        NameRecord->read( pStream ); 
++    }
++    else if ( Id == 0x0f )
++    {
++        pStream->Seek( nStart );
++        bRead = false;
++        return bRead; // start of module, terminate read
++    }
++
++    nPos = pStream->Tell(); // mark position, peek at next Id
++    *pStream >> Id;
++    pStream->Seek( nPos ); // place back before Id
++
++    switch( Id )
++    {
++        case 0x0D:
++            aReferenceRecord = new ReferenceRegisteredRecord();
++            break; 
++        case 0x0E:
++            aReferenceRecord = new ReferenceProjectRecord();
++            break; 
++        case 0x2F:
++        case 0x33:
++            aReferenceRecord = new ReferenceControlRecord();
++            break; 
++        default:
++            bRead = false;
++            OSL_TRACE("Big fat error, unknown ID 0x%x", Id);
++            break;
++    } 
++    if ( bRead )
++        aReferenceRecord->read( pStream );
++    return bRead;
++}
++
++void import( VBA_Impl& rVBA )
++{
++    if ( aReferenceRecord )
++        aReferenceRecord->import( rVBA );
++}
++
++};
++
++class DirDumper
++{
++public:
++ProjectSysKindRecord mSysKindRec;
++ProjectLcidRecord mLcidRec;
++ProjectLcidInvokeRecord mLcidInvokeRec;
++ProjectCodePageRecord mCodePageRec;
++ProjectNameRecord mProjectNameRec;
++ProjectDocStringRecord mDocStringRec;
++ProjectHelpFilePath mHelpFileRec;
++ProjectHelpContextRecord mHelpContextRec;
++ProjectLibFlagsRecord mLibFlagsRec;
++ProjectVersionRecord mVersionRec;
++ProjectConstantsRecord mConstantsRecord;
++std::vector< ReferenceRecord* > ReferenceArray;
++
++DirDumper() {}
++~DirDumper() 
++{
++    for ( std::vector< ReferenceRecord* >::iterator it = ReferenceArray.begin(); it != ReferenceArray.end(); ++it )
++        delete *it;
++    
++}
++
++void read( SvStream* pStream )
++{
++    sal_Int32 nPos = pStream->Tell();
++    std::ofstream aDump("dir.dump");
++    while ( !pStream->IsEof() ) 
++    {
++        sal_Int8 aByte;
++        *pStream >> aByte;
++        aDump << aByte;
++    }
++    aDump.flush();
++    pStream->Seek( nPos );
++    readProjectInformation( pStream );
++    readProjectReferenceInformation( pStream );
++}
++
++void readProjectReferenceInformation( SvStream* pStream )
++{
++    bool bKeepReading = true;
++    while( bKeepReading )
++    {
++        ReferenceRecord* pRef = new ReferenceRecord();
++        bKeepReading = pRef->read( pStream );
++        if ( bKeepReading ) 
++            ReferenceArray.push_back( pRef );
++    }
++}
++
++void readProjectInformation( SvStream* pStream )
++{
++    mSysKindRec.read( pStream );
++    mLcidRec.read( pStream ); 
++    mLcidInvokeRec.read( pStream );
++    mCodePageRec.read( pStream );
++    mProjectNameRec.read( pStream );
++    mDocStringRec.read( pStream );
++    mHelpFileRec.read( pStream );
++    mHelpContextRec.read( pStream );
++    mLibFlagsRec.read( pStream );
++    mVersionRec.read( pStream ); 
++    sal_Int32 nPos = pStream->Tell();
++    sal_uInt16 nTmp;
++    *pStream >> nTmp;
++    if ( nTmp == 0x0C )
++    {
++        pStream->Seek( nPos );
++        mConstantsRecord.read( pStream );
++    }
++    OSL_TRACE("After Information pos is 0x%x", pStream->Tell() );
++}
++
++void import( VBA_Impl& rVBA )
++{
++    // get project references
++    for ( std::vector< ReferenceRecord* >::iterator it = ReferenceArray.begin(); it != ReferenceArray.end(); ++it )
++        (*it)->import( rVBA );
++    rVBA.SetProjectName( mProjectNameRec.msProjectName );
++    
++}
++};
++
++
+ /*
+ A few urls which may in the future be of some use
+ http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf
+@@ -155,7 +1075,17 @@ int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage)
+     xVBAProject = rxVBAStorage->OpenSotStream(
+                     String( RTL_CONSTASCII_USTRINGPARAM( "_VBA_PROJECT" ) ),
+ 					STREAM_STD_READ | STREAM_NOCREATE );
+-
++    // read Dir stream
++    SvStorageStreamRef xDir = rxVBAStorage->OpenSotStream(
++                    String( RTL_CONSTASCII_USTRINGPARAM( "dir" ) ),
++					STREAM_STD_READ | STREAM_NOCREATE );
++    // decompress the stream
++    std::auto_ptr< SvMemoryStream > xCmpDir;
++    xCmpDir.reset( MSLZSS::decompressAsStream( xDir, 0 ) );
++    // try to parse the dir stream
++    DirDumper dDump;
++    dDump.read( xCmpDir.get() );
++    dDump.import( *this );
+ 	if( !xVBAProject.Is() || SVSTREAM_OK != xVBAProject->GetError() )
+ 	{
+ 		DBG_WARNING("Not able to find vba project, cannot find macros");
+@@ -478,6 +1408,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+          * ( value ) is either a Class Module, Form Module or a plain VB Module.        */
+         SvStorageStreamRef xProject = xMacros->OpenSotStream(
+             String( RTL_CONSTASCII_USTRINGPARAM( "PROJECT" ) ) );
++
+         SvStorageStream* pStp = xProject;
+         UniString tmp;
+         static const String sThisDoc(   RTL_CONSTASCII_USTRINGPARAM( "ThisDocument" ) );
+diff --git svx/source/msfilter/msvbasic.hxx svx/source/msfilter/msvbasic.hxx
+index a0536ae..9a21fbe 100644
+--- svx/source/msfilter/msvbasic.hxx
++++ svx/source/msfilter/msvbasic.hxx
+@@ -97,9 +97,12 @@ public:
+     //
+     // #117718# member map of module names to types of module
+     ModType GetModuleType( const UniString& rModuleName );
+-
+-    std::vector<String> maReferences;
++    rtl::OUString& ProjectName() { return msProjectName; }
++    void SetProjectName( const rtl::OUString& rPName ) { msProjectName = rPName; }
++    const std::vector<rtl::OUString> ProjectReferences() { return maReferences; }
++    void AddProjectReference( const rtl::OUString& rProject ) { maReferences.push_back( rProject); }
+ private:
++    std::vector<rtl::OUString> maReferences;
+     struct VBAOffset_Impl
+     {
+         String sName;
+@@ -125,6 +128,7 @@ private:
+     int ReadVBAProject(const SvStorageRef &rxVBAStorage);
+     int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
+     sal_uInt8 ReadPString(SvStorageStreamRef &xVBAProject, bool bIsUnicode);
++    rtl::OUString msProjectName;
+ };
+ 
+ #endif
+diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
+index 843491f..7d0e701 100644
+--- svx/source/msfilter/svxmsbas.cxx
++++ svx/source/msfilter/svxmsbas.cxx
+@@ -83,6 +83,7 @@ int SvxImportMSVBasic::Import( const String& rStorageName,
+ 								const String &rSubStorageName,
+ 								BOOL bAsComment, BOOL bStripped )
+ {
++        msProjectName = rtl::OUString();
+ 	int nRet = 0;
+ 	if( bImport && ImportCode_Impl( rStorageName, rSubStorageName,
+ 									bAsComment, bStripped ))
+@@ -133,6 +134,11 @@ bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
+         DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
+ 
+         String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++        if ( msProjectName.getLength() )
++        {
++            aLibName = msProjectName;
++            rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
++        }
+         Reference<XNameContainer> xLib;
+         if (xLibContainer.is())
+         {
+@@ -262,6 +268,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+ 	VBA_Impl aVBA( *xRoot, bAsComment );
+ 	if( aVBA.Open(rStorageName,rSubStorageName) )
+ 	{
++                msProjectName = aVBA.ProjectName();
+ 		SFX_APP()->EnterBasicCall();
+         Reference<XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer();
+ 		DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
+@@ -271,6 +278,9 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+         if( xLibContainer.is() && nStreamCount )
+         {
+             String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++            if ( msProjectName.getLength() )
++                aLibName = msProjectName;
++                rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
+ 		    if( !xLibContainer->hasByName( aLibName ) )
+ 			    xLibContainer->createLibrary( aLibName );
+ 
+@@ -282,7 +292,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+             Reference< container::XNameAccess > xVBAObjectForCodeName;
+ 			if ( !bAsComment )
+             {
+-                rDocSh.GetBasic()->SetVBAEnabled( true );
++                rDocSh.GetBasicManager()->GetLib( msProjectName )->SetVBAEnabled( true );
+                 Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
+                 if ( xSF.is() )
+                 {
+diff --git sw/inc/unocoll.hxx sw/inc/unocoll.hxx
+index 7b4632d..06fe329 100644
+--- sw/inc/unocoll.hxx
++++ sw/inc/unocoll.hxx
+@@ -194,8 +194,10 @@ class SwUnoCollection
+ #define SW_SERVICE_CHART2_DATA_PROVIDER                 106
+ #define SW_SERVICE_TYPE_FIELDMARK                       107
+ #define SW_SERVICE_TYPE_FORMFIELDMARK                   108
++#define SW_SERVICE_VBAOBJECTPROVIDER                    109
++#define SW_SERVICE_VBACODENAMEPROVIDER                  110
+ 
+-#define SW_SERVICE_LAST                 SW_SERVICE_TYPE_FORMFIELDMARK
++#define SW_SERVICE_LAST                 SW_SERVICE_VBACODENAMEPROVIDER
+ 
+ #define SW_SERVICE_INVALID			USHRT_MAX
+ 
+diff --git sw/prj/build.lst sw/prj/build.lst
+index 1a799f7..428fc91 100644
+--- sw/prj/build.lst
++++ sw/prj/build.lst
+@@ -1,4 +1,4 @@
+-sw	sw	:	connectivity OOo:writerperfect OOo:lotuswordpro svx stoc uui NULL
++sw	sw	:	connectivity OOo:writerperfect OOo:lotuswordpro svx stoc uui vbahelper NULL
+ sw	sw										usr1	-	all	sw_mkout NULL
+ sw	sw\inc									nmake		-	all	sw_inc NULL
+ sw	sw\uiconfig\layout									nmake	-	all	sw_layout NULL
+@@ -33,6 +33,7 @@ sw      sw\source\ui\smartmenu                                          nmake
+ sw      sw\source\ui\table                                              nmake   -       all     sw_table sw_inc NULL
+ sw	sw\source\ui\uiview						nmake	-	all	sw_uivw sw_sdi sw_inc NULL
+ sw	sw\source\ui\uno						nmake	-	all	sw_uiuno sw_sdi sw_inc NULL
++sw	sw\source\ui\vba						nmake	-	all	sw_vba sw_inc NULL
+ sw	sw\source\ui\utlui						nmake	-	all	sw_utlui sw_inc NULL
+ sw	sw\source\ui\web						nmake	-	all	sw_web sw_uinc sw_sdi sw_inc NULL
+ sw	sw\source\ui\wrtsh						nmake	-	all	sw_wrtsh sw_inc NULL
+diff --git sw/prj/d.lst sw/prj/d.lst
+index 09c417c..958771d 100644
+--- sw/prj/d.lst
++++ sw/prj/d.lst
+@@ -63,6 +63,7 @@ mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\swreport\statusbar
+ ..\%__SRC%\bin\swd?????.dll %_DEST%\bin%_EXT%\swd?????.dll
+ ..\%__SRC%\bin\swui?????.dll %_DEST%\bin%_EXT%\swui?????.dll
+ ..\%__SRC%\bin\msword?????.dll %_DEST%\bin%_EXT%\msword?????.dll
++..\%__SRC%\bin\vbaswobj*.dll %_DEST%\bin%_EXT%\vbaswobj*.dll
+ ..\%__SRC%\bin\sw*.res %_DEST%\bin%_EXT%\sw*.res
+ ..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.*
+ 
+diff --git sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocoll.cxx
+index 8ff51f9..54797da 100644
+--- sw/source/core/unocore/unocoll.cxx
++++ sw/source/core/unocore/unocoll.cxx
+@@ -73,7 +73,14 @@
+ #include <unochart.hxx>
+ 
+ #include "docsh.hxx"
 -
--#include "vbahelperinterface.hxx"
--#include "vbacontrol.hxx"
++#include <com/sun/star/document/XCodeNameQuery.hpp>
++#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
++#include <com/sun/star/form/XFormsSupplier.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/ScriptEventDescriptor.hpp>
++#include <vbahelper/vbahelper.hxx>
++#include <basic/basmgr.hxx>
+ using ::rtl::OUString;
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::document;
+@@ -82,6 +89,119 @@ using namespace ::com::sun::star::text;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ 
++class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
++{
++    SwDocShell* mpDocShell;
++    rtl::OUString msThisDocumentCodeName;
++public:
++    SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
++        // XCodeNameQuery
++    rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
++    {
++        // Initialise the code name
++        if ( msThisDocumentCodeName.getLength() == 0 )
++        {
++            try
++            {
++                uno::Reference< beans::XPropertySet > xProps( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
++                uno::Reference< container::XNameAccess > xLibContainer( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW );
++		rtl::OUString sProjectName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) );
++                if ( mpDocShell->GetBasicManager()->GetName().Len() )
++                    sProjectName =  mpDocShell->GetBasicManager()->GetName();
++    
++                uno::Reference< container::XNameAccess > xStandard( xLibContainer->getByName( sProjectName ), uno::UNO_QUERY_THROW );
++                uno::Sequence< rtl::OUString > sModuleNames = xStandard->getElementNames();
++                for ( sal_Int32 i=0; i < sModuleNames.getLength(); ++i )
++                {
++                    script::ModuleInfo mInfo;
++                    if ( xStandard->getByName( sModuleNames[ i ] ) >>= mInfo )
++                    {
++                        if ( mInfo.ModuleType == script::ModuleType::Document )
++                        {
++                            msThisDocumentCodeName = sModuleNames[ i ];
++                            break;
++                        }
++                    } 
++                }
++            }
++            catch( uno::Exception& )
++            {
++            }
++        }
++        rtl::OUString sCodeName;
++        if ( mpDocShell )
++        {
++            OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
++            // need to find the page ( and index )  for this control
++            uno::Reference< drawing::XDrawPageSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
++            uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
++            sal_Int32 nLen = xIndex->getCount();
++            bool bMatched = false;
++            uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
++                try
++                {
++                    uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex, uno::UNO_QUERY_THROW );
++                    uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
++                    // get the www-standard container
++                    uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
++                    sal_Int32 nCntrls = xFormControls->getCount();
++                    for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
++                    {
++                        uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
++                        bMatched = ( xControl == xIf );
++                        if ( bMatched )
++                        {
++                            sCodeName = msThisDocumentCodeName;
++                            break;
++                        }
++                    }
++                }
++                catch( uno::Exception& ) {}
++        }
++        // Probably should throw here ( if !bMatched )
++        return sCodeName;
++    }
++};
++
++class SwVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
++{
++    SwDocShell* mpDocShell;
++public:
++    SwVbaObjectForCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell )
++    {
++        // #FIXME #TODO is the code name for ThisDocument read anywhere?
++    }
++
++    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
++    {
++        // #FIXME #TODO we really need to be checking against the codename for 
++        // ThisDocument 
++        if ( aName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisDocument" ) ) ) )
++            return sal_True;
++        return sal_False;
++    }
++    ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
++    {
++        if ( !hasByName( aName ) )
++             throw container::NoSuchElementException();
++	uno::Sequence< uno::Any > aArgs( 2 );
++        aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++        aArgs[1] = uno::Any( mpDocShell->GetModel() );
++        uno::Reference< uno::XInterface > xDocObj = ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.word.Document" , aArgs );
++        OSL_TRACE("Creating Object ( ooo.vba.word.Document ) 0x%x", xDocObj.get() );
++        return  uno::makeAny( xDocObj );
++    }
++    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException)
++    {
++        uno::Sequence< rtl::OUString > aNames;
++        return aNames;
++    }
++    // XElemenAccess
++    virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
++    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; }
++
++};
++
+ /******************************************************************************
+  *
+  ******************************************************************************/
+@@ -203,6 +323,8 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
+     { "com.sun.star.text.Fieldmark",                          SW_SERVICE_TYPE_FIELDMARK },
+     { "com.sun.star.text.FormFieldmark",                      SW_SERVICE_TYPE_FORMFIELDMARK },
+     { "com.sun.star.chart2.data.DataProvider",                SW_SERVICE_CHART2_DATA_PROVIDER },
++    { "ooo.vba.VBAObjectModuleObjectProvider",                SW_SERVICE_VBAOBJECTPROVIDER },
++    { "ooo.vba.VBACodeNameProvider",                          SW_SERVICE_VBACODENAMEPROVIDER },
+ 
+     // case-correct versions of the service names (see #i67811)
+     { CSS_TEXT_TEXTFIELD_DATE_TIME,                   SW_SERVICE_FIELDTYPE_DATETIME },
+@@ -383,6 +505,18 @@ uno::Reference< uno::XInterface >   SwXServiceProvider::MakeInstance(sal_uInt16
+             xRet =  (cppu::OWeakObject*)pFieldmark;
+         }
+         break;
++		case  SW_SERVICE_VBAOBJECTPROVIDER :
++		{
++			SwVbaObjectForCodeNameProvider* pObjProv = new SwVbaObjectForCodeNameProvider( pDoc->GetDocShell() );
++			xRet =  (cppu::OWeakObject*)pObjProv;
++		}
++		break;
++		case  SW_SERVICE_VBACODENAMEPROVIDER :
++		{
++			SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() );
++			xRet =  (cppu::OWeakObject*)pObjProv;
++		}
++		break;
+         case  SW_SERVICE_TYPE_FOOTNOTE :
+             xRet =  (cppu::OWeakObject*)new SwXFootnote(sal_False);
+         break;
+diff --git sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.cxx
+index 290ffda..a0dd778 100644
+--- sw/source/filter/ww8/ww8par.cxx
++++ sw/source/filter/ww8/ww8par.cxx
+@@ -132,6 +132,9 @@
+ #include <svtools/itemiter.hxx>  //SfxItemIter
+ 
+ #include <stdio.h>
++#include <comphelper/processfactory.hxx>
++#include <basic/basmgr.hxx>
++
+ #include "ww8toolbar.hxx"
+ #ifdef DEBUG
+ #include <iostream>
+@@ -146,6 +149,76 @@ using namespace sw::util;
+ using namespace sw::types;
+ using namespace nsHdFtFlags;
+ 
++#include <vbahelper/vbahelper.hxx>
++#include <com/sun/star/document/XEventsSupplier.hpp>
++#include <com/sun/star/container/XNameReplace.hpp>
++#include <com/sun/star/frame/XModel.hpp>
++const static String sModule( RTL_CONSTASCII_USTRINGPARAM("ThisDocument"));
++
++const static rtl::OUString sUrlPart0 = rtl::OUString::createFromAscii( "vnd.sun.star.script:");
++const static rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
++const static rtl::OUString sUrlPart2 = rtl::OUString::createFromAscii( "?language=Basic&location=document"); 
++
++struct DocEventNameTable
++{
++    const sal_Char* sEventName;
++    const sal_Char* sMacroName;
++};
++
++const DocEventNameTable aEventNameTable[] = 
++{
++    {"OnNew", "Document_New"},
++    {"OnLoad", "Document_Open"},
++    {"OnPrepareUnload", "Document_Close"},
++    {NULL, NULL}
++};
++
++bool registerDocEvent( SfxObjectShell* pShell )
++{
++	bool result = false;
++	const static rtl::OUString sEvtType( RTL_CONSTASCII_USTRINGPARAM("EventType") );
++	const static rtl::OUString sScript( RTL_CONSTASCII_USTRINGPARAM("Script") );
++    uno::Reference< document::XEventsSupplier > xEvtSupplier( pShell->GetModel(), uno::UNO_QUERY );
++    if( !xEvtSupplier.is() )
++        return result;
++    uno::Reference< container::XNameReplace > xEvts( xEvtSupplier->getEvents(), uno::UNO_QUERY );     
++	if ( xEvts.is() )
++	{
++        for( const DocEventNameTable* pTable = aEventNameTable; pTable->sEventName != NULL; pTable++ )
++        {
++            rtl::OUString sEvt = rtl::OUString::createFromAscii( pTable->sEventName );
++            rtl::OUString sMacroName = rtl::OUString::createFromAscii( pTable->sMacroName );
++            // fail to search the macro if the module is not specified.
++            String sFullPath = ooo::vba::docMacroExists( pShell, sModule, sMacroName );
++            if( sFullPath.Len() == 0 )
++                continue;
++
++		    uno::Sequence< beans::PropertyValue > aEvents;
++		    xEvts->getByName( sEvt ) >>= aEvents;
++		    uno::Sequence< beans::PropertyValue > aOpenEvt( 2 );
++		    aOpenEvt[ 0 ].Name = sEvtType;
++		    aOpenEvt[ 0 ].Value = uno::makeAny(sScript);
++		    aOpenEvt[ 1 ].Name = sScript;
++            rtl::OUString sUrl = sUrlPart0.concat( sFullPath ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( sUrlPart2 );
++    		aOpenEvt[ 1 ].Value = uno::makeAny(sUrl);
++	    	sal_Int32 nPos = aEvents.getLength();
++
++		    sal_Int32 nNewSize = aEvents.getLength() + aOpenEvt.getLength();
++		    if ( nNewSize > aEvents.getLength() )
++			    aEvents.realloc( nNewSize );
++
++	    	for ( sal_Int32 nIndex = nPos, nCpyIndex = 0; nIndex<nNewSize; nIndex++, nCpyIndex++ )
++		    	aEvents[ nIndex ] = aOpenEvt[ nCpyIndex ];	
++			
++		    uno::Any aParam = uno::makeAny( aEvents );
++
++		    xEvts->replaceByName( sEvt, aParam ); 
++		    result = true;
++        }    
++	}
++	return result;
++}
++
+ 
+ SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr )
+     : SvxMSDffManager(*rRdr.pTableStream, rRdr.GetBaseURL(), rRdr.pWwFib->fcDggInfo,
+@@ -3912,7 +3985,48 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
+     }
+     else //ordinary case
+     {
++        if (mbNewDoc && pStg && !pGloss) /*meaningless for a glossary, cmc*/
++        {
++            const SvtFilterOptions* pVBAFlags = SvtFilterOptions::Get();
++            maTracer.EnterEnvironment(sw::log::eMacros);
++            // Create and insert Excel vba Globals
++            uno::Any aGlobs;
++            aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString::createFromAscii( "ooo.vba.word.Globals") );
++            mpDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
++            
++            SvxImportMSVBasic aVBasic(*mpDocShell, *pStg,
++                            pVBAFlags->IsLoadWordBasicCode(),
++                            pVBAFlags->IsLoadWordBasicStorage() );
++            String s1(CREATE_CONST_ASC("Macros"));
++            String s2(CREATE_CONST_ASC("VBA"));
++            int nRet = aVBasic.Import( s1, s2, ! pVBAFlags->IsLoadWordBasicCode() );
++            // Read custom toolbars 
++            if ( pWwFib->lcbCmds )
++            {
++                // there is a tgc255 structure
++                long nCur = pTableStream->Tell();
++                Tcg aTCG;
++                pTableStream->Seek( pWwFib->fcCmds ); // point at tgc record
++                if (!aTCG.Read( pTableStream ) )
++                    OSL_TRACE("** Read of Customization data failed!!!! ");
++                pTableStream->Seek( nCur ); // return to previous position, is that necessary?
++#if DEBUG
++                aTCG.Print( stderr );
++#endif
++                aTCG.ImportCustomToolBar( *mpDocShell );
++            }
++            if( 2 & nRet )
++            {
++                maTracer.Log(sw::log::eContainsVisualBasic);
++                rDoc.SetContainsMSVBasic(true);
++            }
++
++            StoreMacroCmds();
++
++            maTracer.LeaveEnvironment(sw::log::eMacros);
++        }
+         ReadText(0, pWwFib->ccpText, MAN_MAINTEXT);
++
+     }
+ 
+     ::SetProgressState(nProgress, mpDocShell);    // Update
+@@ -3986,41 +4100,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
+             eMode |= nsRedlineMode_t::REDLINE_ON;
+         if( pWDop->fRMView )
+             eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
+-        if (pStg && !pGloss) /*meaningless for a glossary, cmc*/
+-        {
+-            // Read custom toolbars 
+-            if ( pWwFib->lcbCmds )
+-            {
+-                // there is a tgc255 structure
+-                long nCur = pTableStream->Tell();
+-                Tcg aTCG;
+-                pTableStream->Seek( pWwFib->fcCmds ); // point at tgc record
+-                if (!aTCG.Read( pTableStream ) )
+-                    OSL_TRACE("** Read of Customization data failed!!!! ");
+-                pTableStream->Seek( nCur ); // return to previous position, is that necessary?
+-#if DEBUG
+-                aTCG.Print( stderr );
+-#endif
+-                aTCG.ImportCustomToolBar( mpDocShell->GetModel() );
+-            }
+-            const SvtFilterOptions* pVBAFlags = SvtFilterOptions::Get();
+-            maTracer.EnterEnvironment(sw::log::eMacros);
+-            SvxImportMSVBasic aVBasic(*mpDocShell, *pStg,
+-                            pVBAFlags->IsLoadWordBasicCode(),
+-                            pVBAFlags->IsLoadWordBasicStorage() );
+-            String s1(CREATE_CONST_ASC("Macros"));
+-            String s2(CREATE_CONST_ASC("VBA"));
+-            int nRet = aVBasic.Import( s1, s2 );
+-            if( 2 & nRet )
+-            {
+-                maTracer.Log(sw::log::eContainsVisualBasic);
+-                rDoc.SetContainsMSVBasic(true);
+-            }
 -
--//typedef InheritedHelperInterfaceImpl1< ov::msforms::XUserForm > ScVbaUserForm_BASE;
--typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE;
+-            StoreMacroCmds();
 -
--class ScVbaUserForm : public ScVbaUserForm_BASE
--{
--private:
--    css::uno::Reference< css::awt::XDialog > m_xDialog;
--    ScDocShell* m_pDocShell;
--    bool mbDispose;
--protected:
--public:
--    ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
--    virtual ~ScVbaUserForm();
--    // 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 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);
--    //XHelperInterface
--    virtual rtl::OUString& getServiceImplName();
--    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
--};
--#endif
-diff --git sc/source/ui/vba/vbavalidation.hxx sc/source/ui/vba/vbavalidation.hxx
-index fff6b8a..445a249 100644
---- sc/source/ui/vba/vbavalidation.hxx
-+++ sc/source/ui/vba/vbavalidation.hxx
-@@ -33,7 +33,7 @@
- #include <com/sun/star/uno/XComponentContext.hpp>
- #include <ooo/vba/excel/XValidation.hpp>
- #include <com/sun/star/table/XCellRange.hpp>
--#include "vbahelperinterface.hxx"
+-            maTracer.LeaveEnvironment(sw::log::eMacros);
+-        }
+     }
+ 
+     maInsertedTables.DelAndMakeTblFrms();
+diff --git sw/source/filter/ww8/ww8toolbar.cxx sw/source/filter/ww8/ww8toolbar.cxx
+index ac10d7a..facc7a9 100644
+--- sw/source/filter/ww8/ww8toolbar.cxx
++++ sw/source/filter/ww8/ww8toolbar.cxx
+@@ -154,14 +154,14 @@ void CTBWrapper::Print( FILE* fp )
+     }
+ }
+ 
+-bool CTBWrapper::ImportCustomToolBar( const uno::Reference< css::frame::XModel >& rxModel )
++bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
+ {
+     
+     for ( std::vector< Customization >::iterator it = rCustomizations.begin(); it != rCustomizations.end(); ++it )
+     {
+         uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+         uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW ); 
+-        CustomToolBarImportHelper helper( rxModel, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) ) );
++        CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) ) );
+         helper.setMSOCommandMap( new  MSOWordCommandConvertor() );
+         if ( !(*it).ImportCustomToolBar( helper ) )
+             return false;
+@@ -538,9 +538,9 @@ void Tcg::Print( FILE* fp )
+     tcg->Print( fp );
+ }
+ 
+-bool Tcg::ImportCustomToolBar( const uno::Reference< frame::XModel >& rxModel )
++bool Tcg::ImportCustomToolBar( SfxObjectShell& rDocSh )
+ {
+-    return tcg->ImportCustomToolBar( rxModel );
++    return tcg->ImportCustomToolBar( rDocSh );
+ }
+ 
+ Tcg255::Tcg255()
+@@ -601,7 +601,7 @@ bool Tcg255::processSubStruct( sal_uInt8 nId, SvStream *pS )
+     return true;
+ }
+ 
+-bool Tcg255::ImportCustomToolBar( const uno::Reference< css::frame::XModel >& rxModel )
++bool Tcg255::ImportCustomToolBar( SfxObjectShell& rDocSh )
+ {
+     // Find the CTBWrapper
+     for ( std::vector< Tcg255SubStruct* >::const_iterator it = rgtcgData.begin(); it != rgtcgData.end(); ++it )
+@@ -612,7 +612,7 @@ bool Tcg255::ImportCustomToolBar( const uno::Reference< css::frame::XModel >& rx
+             CTBWrapper* pCTBWrapper =  dynamic_cast< CTBWrapper* > ( *it );
+             if ( pCTBWrapper )
+             {
+-                if ( !pCTBWrapper->ImportCustomToolBar( rxModel ) )
++                if ( !pCTBWrapper->ImportCustomToolBar( rDocSh ) )
+                     return false;
+             }
+         }
+diff --git sw/source/filter/ww8/ww8toolbar.hxx sw/source/filter/ww8/ww8toolbar.hxx
+index 188213c..675a16e 100644
+--- sw/source/filter/ww8/ww8toolbar.hxx
++++ sw/source/filter/ww8/ww8toolbar.hxx
+@@ -117,6 +117,8 @@ public:
+     void Print( FILE* );
+ };
+ 
++class SfxObjectShell; 
++
+ class CTBWrapper : public Tcg255SubStruct
+ {
+     // reserved1 is the ch field of Tcg255SubStruct
+@@ -139,7 +141,7 @@ public:
+     CTBWrapper( bool bReadId = true );
+     ~CTBWrapper();
+     bool Read(SvStream *pS);
+-    bool ImportCustomToolBar( const css::uno::Reference< css::frame::XModel >& rxModel );
++    bool ImportCustomToolBar( SfxObjectShell& rDocSh );
+     void Print( FILE* );
+ };
+ 
+@@ -320,7 +322,7 @@ public:
+     ~Tcg255();
+     bool Read(SvStream *pS);
+     void Print( FILE* );
+-    bool ImportCustomToolBar( const css::uno::Reference< css::frame::XModel >& rxModel );
++    bool ImportCustomToolBar( SfxObjectShell& rDocSh );
+ };
+ 
+ class Tcg: public TBBase
+@@ -333,7 +335,7 @@ public:
+     Tcg();
+     ~Tcg(){}
+     bool Read(SvStream *pS);
+-    bool ImportCustomToolBar( const css::uno::Reference< css::frame::XModel >& rxModel );
++    bool ImportCustomToolBar( SfxObjectShell& rDocSh );
+     void Print( FILE* );
+ };
+ 
+diff --git sw/source/ui/uno/unotxdoc.cxx sw/source/ui/uno/unotxdoc.cxx
+index 401c270..fc3b8b9 100644
+--- sw/source/ui/uno/unotxdoc.cxx
++++ sw/source/ui/uno/unotxdoc.cxx
+@@ -170,6 +170,7 @@ using ::osl::FileBase;
+ #define SW_CREATE_MARKER_TABLE          0x06
+ #define SW_CREATE_DRAW_DEFAULTS         0x07
+ 
++#include <comphelper/processfactory.hxx> 
+ 
+ /******************************************************************************
+  *
+@@ -362,6 +363,9 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
+     pxXRedlines(0),
+     m_pHiddenViewFrame(0)
+ {
++    uno::Reference< document::XDocumentProperties > xWriterProps( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.writer.DocumentProperties") ), uno::UNO_QUERY_THROW);
++
++    SfxBaseModel::setDocumentProperties( xWriterProps );
+ }
+ /*-- 18.12.98 11:53:00---------------------------------------------------
+ 
+@@ -2873,6 +2877,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
+ {
+ 	::vos::OGuard aGuard(Application::GetSolarMutex());
+ 
++
+     // possible canonical values for nScriptTypes
+     // any bit wise combination is allowed
+     const sal_Int16 nLatin   = 0x001;
+diff --git sw/source/ui/vba/makefile.mk sw/source/ui/vba/makefile.mk
+new file mode 100644
+index 0000000..e789fde
+--- /dev/null
++++ sw/source/ui/vba/makefile.mk
+@@ -0,0 +1,85 @@
++#*************************************************************************
++#
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++# 
++# Copyright 2008 by Sun Microsystems, Inc.
++#
++# OpenOffice.org - a multi-platform office productivity suite
++#
++# $RCSfile: makefile.mk,v $
++#
++# $Revision: 1.6 $
++#
++# 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.
++#
++#*************************************************************************
++
++PRJ=..$/..$/..
++
++PRJNAME=sw
++TARGET=vbaswobj
++ENABLE_EXCEPTIONS=TRUE
++
++# --- Settings -----------------------------------------------------
++
++.INCLUDE :  settings.mk
++DLLPRE =
++
++.IF "$(ENABLE_VBA)"!="YES"
++dummy:
++        @echo "not building vba..."
++.ENDIF
++ 
++INCPRE=$(INCCOM)$/$(TARGET)
++CDEFS+=-DVBA_OOBUILD_HACK
++# ------------------------------------------------------------------
++
++SLOFILES= \
++		$(SLO)$/vbaglobals.obj \
++		$(SLO)$/vbaapplication.obj \
++		$(SLO)$/vbadocument.obj \
++		$(SLO)$/vbawindow.obj \
++		$(SLO)$/vbasystem.obj \
++		$(SLO)$/vbarangehelper.obj \
++		$(SLO)$/vbarange.obj \
++		$(SLO)$/vbabookmark.obj \
++		$(SLO)$/vbabookmarks.obj \
++		$(SLO)$/vbavariable.obj \
++		$(SLO)$/vbavariables.obj \
++		$(SLO)$/vbaview.obj \
++		$(SLO)$/wordvbahelper.obj \
++				$(SLO)$/service.obj \
++				$(SLO)$/vbadocumentproperties.obj \
++				$(SLO)$/vbapane.obj \
++				$(SLO)$/vbapanes.obj \
++				$(SLO)$/vbaoptions.obj \
++				$(SLO)$/vbaselection.obj \
++
++# --- Targets ------------------------------------------------------
++
++.INCLUDE :	target.mk
++
++ALLTAR : \
++        $(MISC)$/$(TARGET).don \
++
++$(SLOFILES) : $(MISC)$/$(TARGET).don
++
++$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
++        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
++        echo $@
++
+diff --git sw/source/ui/vba/service.cxx sw/source/ui/vba/service.cxx
+new file mode 100644
+index 0000000..009f440
+--- /dev/null
++++ sw/source/ui/vba/service.cxx
+@@ -0,0 +1,82 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: service.cxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 "cppuhelper/implementationentry.hxx"
++#include "com/sun/star/lang/XMultiServiceFactory.hpp"
++#include "com/sun/star/registry/XRegistryKey.hpp"
++#include "comphelper/servicedecl.hxx"
++
++// =============================================================================
++// component exports
++// =============================================================================
++using namespace ::com::sun::star;
++using namespace ::com::sun::star::uno;
++
++namespace sdecl = comphelper::service_decl;
++
++namespace globals
++{
++extern sdecl::ServiceDecl const serviceDecl;
++}
++
++namespace document
++{
++extern sdecl::ServiceDecl const serviceDecl;
++}
++
++extern "C"
++{
++    void SAL_CALL component_getImplementationEnvironment( 
++        const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
++    {
++		OSL_TRACE("In component_getImplementationEnv");
++        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
++    }
++
++    sal_Bool SAL_CALL component_writeInfo( 
++        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
++    {
++		OSL_TRACE("In component_writeInfo");
++
++	// Component registration
++        return component_writeInfoHelper( pServiceManager, pRegistryKey, 
++		globals::serviceDecl, document::serviceDecl ); 
++    }
++
++    void * SAL_CALL component_getFactory( 
++        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
++        registry::XRegistryKey * pRegistryKey )
++    {
++		OSL_TRACE("In component_getFactory for %s", pImplName );
++	void* pRet =  component_getFactoryHelper(
++        	pImplName, pServiceManager, pRegistryKey, globals::serviceDecl, document::serviceDecl );
++	OSL_TRACE("Ret is 0x%x", pRet);
++	return pRet;
++    }
++}
+diff --git sw/source/ui/vba/vbaapplication.cxx sw/source/ui/vba/vbaapplication.cxx
+new file mode 100644
+index 0000000..0d580e3
+--- /dev/null
++++ sw/source/ui/vba/vbaapplication.cxx
+@@ -0,0 +1,135 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaapplication.cxx,v $
++ * $Revision: 1.7 $
++ *
++ * 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 <stdio.h>
++#include "vbaapplication.hxx"
++#include "vbadocument.hxx"
++#include <osl/file.hxx>
++#include <vbahelper/vbahelper.hxx>
++#include "vbawindow.hxx"
++#include "vbasystem.hxx"
++#include "vbaoptions.hxx"
++#include "vbaselection.hxx"
++
++using namespace ::ooo;
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++using ::com::sun::star::uno::Reference;
++using ::com::sun::star::uno::UNO_QUERY_THROW;
++using ::com::sun::star::uno::UNO_QUERY;
++using ::rtl::OUString;
++
++// Enable our own join detection for Intersection and Union
++// should be more efficient than using ScRangeList::Join ( because
++// we already are testing the same things )
++
++#define OWN_JOIN 1
++
++// #TODO is this defined somewhere else?
++#if ( defined UNX ) || ( defined OS2 ) //unix
++#define FILE_PATH_SEPERATOR "/"
++#else // windows
++#define FILE_PATH_SEPERATOR "\\"
++#endif 
++
++#define EXCELVERSION "11.0"
++
++uno::Any sbxToUnoValue( SbxVariable* pVar );
++
++SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( xContext )
++{
++}
++
++SwVbaApplication::~SwVbaApplication()
++{
++}
++
++rtl::OUString SAL_CALL
++SwVbaApplication::getName() throw (uno::RuntimeException)
++{
++    static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) );
++    return appName;
++}
++
++uno::Reference< word::XDocument > SAL_CALL
++SwVbaApplication::getActiveDocument() throw (uno::RuntimeException)
++{
++    return new SwVbaDocument( this, mxContext, getCurrentDocument() );
++}
++
++uno::Reference< word::XWindow > SAL_CALL 
++SwVbaApplication::getActiveWindow() throw (uno::RuntimeException)
++{
++	// #FIXME sofar can't determine Parent
++	return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, getCurrentDocument() );
++}
++
++uno::Reference<word::XSystem > SAL_CALL
++SwVbaApplication::getSystem() throw (uno::RuntimeException)
++{
++    return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) );
++}
++
++uno::Reference<word::XOptions > SAL_CALL
++SwVbaApplication::getOptions() throw (uno::RuntimeException)
++{
++    return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) );
++}
++
++uno::Any SAL_CALL
++SwVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    return VbaApplicationBase::CommandBars( aIndex );
++}
++
++uno::Reference< word::XSelection > SAL_CALL
++SwVbaApplication::getSelection() throw (uno::RuntimeException)
++{
++    return new SwVbaSelection( this, mxContext, getCurrentDocument() );
++}
++
++rtl::OUString& 
++SwVbaApplication::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaApplication::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) );
++	}
++	return aServiceNames;
++}
+diff --git sw/source/ui/vba/vbaapplication.hxx sw/source/ui/vba/vbaapplication.hxx
+new file mode 100644
+index 0000000..fbb7221
+--- /dev/null
++++ sw/source/ui/vba/vbaapplication.hxx
+@@ -0,0 +1,64 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaapplication.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_APPLICATION_HXX
++#define SW_VBA_APPLICATION_HXX
++
++#include <ooo/vba/word/XApplication.hpp>
++#include <ooo/vba/word/XDocument.hpp>
++#include <ooo/vba/word/XWindow.hpp>
++#include <ooo/vba/word/XSystem.hpp>
++#include <ooo/vba/word/XOptions.hpp>
++#include <ooo/vba/word/XSelection.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbaapplicationbase.hxx>
++#include <cppuhelper/implbase1.hxx>
++
++//typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XApplication > SwVbaApplication_BASE;
++typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ooo::vba::word::XApplication > SwVbaApplication_BASE;
++
++class SwVbaApplication : public SwVbaApplication_BASE
++{
++public:
++	SwVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext );
++	virtual ~SwVbaApplication();
++
++	// XApplication
++    virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);  
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_APPLICATION_HXX */
+diff --git sw/source/ui/vba/vbabookmark.cxx sw/source/ui/vba/vbabookmark.cxx
+new file mode 100644
+index 0000000..e05476e
+--- /dev/null
++++ sw/source/ui/vba/vbabookmark.cxx
+@@ -0,0 +1,111 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbabookmark.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++#include <com/sun/star/text/XTextDocument.hpp>
++#include <com/sun/star/text/XTextContent.hpp>
++#include <com/sun/star/text/XTextViewCursor.hpp>
++#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
++#include "vbarange.hxx"
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaBookmark::SwVbaBookmark( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++    const css::uno::Reference< frame::XModel >& rModel, const rtl::OUString& rName ) throw ( css::uno::RuntimeException ) :
++    SwVbaBookmark_BASE( rParent, rContext ), mxModel( rModel ), maName( rName ), mbValid( sal_True )
++{
++    uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( mxModel, uno::UNO_QUERY_THROW );
++    mxBookmark.set( xBookmarksSupplier->getBookmarks()->getByName( maName ), uno::UNO_QUERY_THROW );
++}
++
++SwVbaBookmark::~SwVbaBookmark()
++{
++}
++
++void SwVbaBookmark::checkVality() throw ( uno::RuntimeException )
++{
++    if( !mbValid )
++        throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("The bookmark is not valid" ) ), uno::Reference< uno::XInterface >() );
++}
++
++void SAL_CALL SwVbaBookmark::Delete() throw ( uno::RuntimeException )
++{
++    checkVality();
++    uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
++    xTextDocument->getText()->removeTextContent( mxBookmark );
++    mbValid = sal_False;
++}
++
++void SAL_CALL SwVbaBookmark::Select() throw ( uno::RuntimeException )
++{
++    checkVality();
++    uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
++    xViewCursorSupplier->getViewCursor()->gotoRange( mxBookmark->getAnchor(),sal_False );
++}
++
++rtl::OUString SAL_CALL SwVbaBookmark::getName() throw ( uno::RuntimeException )
++{
++    return maName;
++}
++
++void SAL_CALL SwVbaBookmark::setName( const rtl::OUString& _name ) throw ( uno::RuntimeException )
++{
++    uno::Reference< container::XNamed > xNamed( mxBookmark, uno::UNO_QUERY_THROW );
++    xNamed->setName( _name );
++}
++
++uno::Any SAL_CALL SwVbaBookmark::Range() throw ( uno::RuntimeException )
++{
++    uno::Reference< text::XTextContent > xTextContent( mxBookmark, uno::UNO_QUERY_THROW );
++    uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
++    return uno::makeAny( uno::Reference< word::XRange>(  new SwVbaRange( this, mxContext, xTextDocument, xTextContent->getAnchor()->getStart(), xTextContent->getAnchor()->getEnd() ) ) );
++}
++
++rtl::OUString& 
++SwVbaBookmark::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBookmark") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaBookmark::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Bookmark" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbabookmark.hxx sw/source/ui/vba/vbabookmark.hxx
+new file mode 100644
+index 0000000..9d240e7
+--- /dev/null
++++ sw/source/ui/vba/vbabookmark.hxx
+@@ -0,0 +1,68 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_BOOKMARK_HXX
++#define SW_VBA_BOOKMARK_HXX
++
++#include <ooo/vba/word/XBookmark.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/text/XBookmarksSupplier.hpp>
++#include <com/sun/star/text/XTextContent.hpp>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XBookmark > SwVbaBookmark_BASE;
++
++class SwVbaBookmark : public SwVbaBookmark_BASE
++{
++private:
++    css::uno::Reference< css::frame::XModel > mxModel;
++    css::uno::Reference< css::text::XTextContent > mxBookmark;
++    rtl::OUString maName;
++    sal_Bool mbValid;
++
++private:
++    void checkVality() throw ( css::uno::RuntimeException );
++
++public:
++	SwVbaBookmark( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, 
++        const css::uno::Reference< css::frame::XModel >& rModel, const rtl::OUString& rName ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaBookmark();
++
++   // Methods
++    virtual rtl::OUString SAL_CALL getName() throw ( css::uno::RuntimeException );
++    virtual void SAL_CALL setName( const rtl::OUString& ) throw ( css::uno::RuntimeException );
++    virtual void SAL_CALL Delete() throw ( css::uno::RuntimeException );
++    virtual void SAL_CALL Select() throw ( css::uno::RuntimeException );
++    virtual css::uno::Any SAL_CALL Range() throw ( css::uno::RuntimeException );
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_BOOKMARK_HXX */
+diff --git sw/source/ui/vba/vbabookmarks.cxx sw/source/ui/vba/vbabookmarks.cxx
+new file mode 100644
+index 0000000..3ff2bf3
+--- /dev/null
++++ sw/source/ui/vba/vbabookmarks.cxx
+@@ -0,0 +1,193 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbabookmarks.hxx"
++#include "vbabookmark.hxx"
++#include <com/sun/star/container/XNamed.hpp>
++#include <com/sun/star/text/XTextDocument.hpp>
++#include <com/sun/star/text/XTextViewCursor.hpp>
++#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
++#include <ooo/vba/word/WdBookmarkSortBy.hpp>
++#include "vbarange.hxx"
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++class BookmarksEnumeration : public EnumerationHelperImpl
++{
++	uno::Reference< frame::XModel > mxModel;
++	uno::WeakReference< XHelperInterface > mxParent;
++public:
++	BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration,  const uno::Reference< frame::XModel >& xModel  ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), mxModel( xModel ), mxParent( xParent ) {}
++
++	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 
++	{ 
++		uno::Reference< container::XNamed > xNamed( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
++        rtl::OUString aName = xNamed->getName();
++		return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( mxParent, m_xContext, mxModel, aName ) ) );
++	}
++
++};
++
++SwVbaBookmarks::SwVbaBookmarks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xBookmarks, const uno::Reference< frame::XModel >& xModel ): SwVbaBookmarks_BASE( xParent, xContext, xBookmarks ), mxModel( xModel ) 
++{
++    mxBookmarksSupplier.set( mxModel, uno::UNO_QUERY_THROW );
++    uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
++    mxText = xDocument->getText();
++    
++    // FIXME: fail to rename the bookmark
++    // word doesn't distinguish cases, so set all bookmarknames to Lowercase
++    //renameAllBookmarksToLowercase();
++}
++// XEnumerationAccess
++uno::Type
++SwVbaBookmarks::getElementType() throw (uno::RuntimeException)
++{
++	return word::XBookmark::static_type(0);
++}
++uno::Reference< container::XEnumeration >
++SwVbaBookmarks::createEnumeration() throw (uno::RuntimeException)
++{
++    uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
++	return new BookmarksEnumeration( getParent(), mxContext,xEnumAccess->createEnumeration(), mxModel );
++}
++
++uno::Any
++SwVbaBookmarks::createCollectionObject( const css::uno::Any& aSource )
++{
++	uno::Reference< container::XNamed > xNamed( aSource, uno::UNO_QUERY_THROW );
++    rtl::OUString aName = xNamed->getName();
++    return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( getParent(), mxContext, mxModel, aName ) ) );
++}
++
++void SwVbaBookmarks::removeBookmarkByName( const rtl::OUString& rName ) throw (uno::RuntimeException)
++{
++    uno::Reference< text::XTextContent > xBookmark( mxBookmarksSupplier->getBookmarks()->getByName( rName ), uno::UNO_QUERY_THROW );
++    mxText->removeTextContent( xBookmark );
++}
++
++void SwVbaBookmarks::addBookmarkByName( const rtl::OUString& rName, const uno::Reference< text::XTextRange >& rTextRange ) throw (uno::RuntimeException)
++{
++    uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxModel, uno::UNO_QUERY_THROW );
++    uno::Reference< text::XTextContent > xBookmark( xDocMSF->createInstance(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Bookmark")) ), uno::UNO_QUERY_THROW );
++    uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
++    xNamed->setName( rName );
++    mxText->insertTextContent( rTextRange, xBookmark, sal_False );
++}
++
++void SwVbaBookmarks::renameAllBookmarksToLowercase() throw (uno::RuntimeException)
++{
++    uno::Reference< container::XIndexAccess > xBookmarks( mxBookmarksSupplier->getBookmarks(),uno::UNO_QUERY_THROW );
++    for( sal_Int32 nIndex = 0; nIndex < xBookmarks->getCount(); nIndex++ )
++    {
++        uno::Reference< container::XNamed > xNamed( xBookmarks->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
++        rtl::OUString aName = xNamed->getName();
++        rtl::OUString aNameLowerCase = aName.toAsciiLowerCase();
++        if( !aName.equals( aNameLowerCase ) );
++            xNamed->setName( aNameLowerCase );
++    }
++}
++
++uno::Any SAL_CALL
++SwVbaBookmarks::Add( const rtl::OUString& rName, const uno::Any& rRange ) throw (uno::RuntimeException)
++{
++    uno::Reference< text::XTextRange > xTextRange;
++    uno::Reference< word::XRange > xRange;
++    if( rRange >>= xRange )
++    {
++        SwVbaRange* pRange = dynamic_cast< SwVbaRange* >( xRange.get() );
++        if( pRange )
++            xTextRange = pRange->getXTextRange();
++    }
++    else
++    {
++        // FIXME: insert the bookmark into current view cursor
++        uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
++        xTextRange.set( xViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW );
++    }
++
++    // remove the exist bookmark
++    rtl::OUString aName = rName.toAsciiLowerCase();
++    if( mxBookmarksSupplier->getBookmarks()->hasByName( aName ) )
++        removeBookmarkByName( aName );
++    
++    addBookmarkByName( aName, xTextRange );
++
++    return uno::makeAny( uno::Reference< word::XBookmark >( new SwVbaBookmark( getParent(), mxContext, mxModel, aName ) ) );
++}
++
++sal_Int32 SAL_CALL 
++SwVbaBookmarks::getDefaultSorting() throw (css::uno::RuntimeException)
++{
++    return word::WdBookmarkSortBy::wdSortByName;
++}
++
++void SAL_CALL 
++SwVbaBookmarks::setDefaultSorting( sal_Int32/* _type*/ ) throw (css::uno::RuntimeException)
++{
++    // not support in Writer
++}
++
++sal_Bool SAL_CALL 
++SwVbaBookmarks::getShowHidden() throw (css::uno::RuntimeException)
++{
++    return sal_True;
++}
++
++void SAL_CALL 
++SwVbaBookmarks::setShowHidden( sal_Bool /*_hidden*/ ) throw (css::uno::RuntimeException)
++{
++    // not support in Writer
++}
++
++sal_Bool SAL_CALL 
++SwVbaBookmarks::Exists( const rtl::OUString& rName ) throw (css::uno::RuntimeException)
++{
++    sal_Bool bExist = mxBookmarksSupplier->getBookmarks()->hasByName( rName.toAsciiLowerCase() );
++    return bExist;
++}
++
++rtl::OUString& 
++SwVbaBookmarks::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBookmarks") );
++	return sImplName;
++}
++
++css::uno::Sequence<rtl::OUString> 
++SwVbaBookmarks::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > sNames;
++	if ( sNames.getLength() == 0 )
++	{
++		sNames.realloc( 1 );
++		sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Bookmarks") );
++	}
++	return sNames;
++}
+diff --git sw/source/ui/vba/vbabookmarks.hxx sw/source/ui/vba/vbabookmarks.hxx
+new file mode 100644
+index 0000000..7fe5ffe
+--- /dev/null
++++ sw/source/ui/vba/vbabookmarks.hxx
+@@ -0,0 +1,79 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_BOOKMARKS_HXX
++#define SW_VBA_BOOKMARKS_HXX
++
++#include <vbahelper/vbacollectionimpl.hxx>
++#include <ooo/vba/word/XBookmarks.hpp>
++#include <com/sun/star/container/XEnumerationAccess.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <com/sun/star/text/XBookmarksSupplier.hpp>
++#include <com/sun/star/text/XTextRange.hpp>
++#include <com/sun/star/text/XText.hpp>
++
++typedef CollTestImplHelper< ooo::vba::word::XBookmarks > SwVbaBookmarks_BASE;
++
++class SwVbaBookmarks : public SwVbaBookmarks_BASE
++{
++private:
++	css::uno::Reference< css::frame::XModel > mxModel;
++    css::uno::Reference< css::text::XBookmarksSupplier > mxBookmarksSupplier;
++    css::uno::Reference< css::text::XText > mxText;
++
++private:
++    void removeBookmarkByName( const rtl::OUString& rName ) throw (css::uno::RuntimeException);
++    void addBookmarkByName( const rtl::OUString& rName, const css::uno::Reference< css::text::XTextRange >& rTextRange ) throw (css::uno::RuntimeException);
++    void renameAllBookmarksToLowercase() throw (css::uno::RuntimeException);
++
++public:
++	SwVbaBookmarks( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xBookmarks, const css::uno::Reference< css::frame::XModel >& xModel );
++	virtual ~SwVbaBookmarks() {}
++
++	// XEnumerationAccess
++	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++
++	// SwVbaBookmarks_BASE
++	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); 
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++
++	// XBookmarks
++    virtual sal_Int32 SAL_CALL getDefaultSorting() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setDefaultSorting( sal_Int32 _type ) throw (css::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL getShowHidden() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setShowHidden( sal_Bool _hidden ) throw (css::uno::RuntimeException);
++
++	virtual css::uno::Any SAL_CALL Add( const rtl::OUString& rName, const css::uno::Any& rRange ) throw (css::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL Exists( const rtl::OUString& rName ) throw (css::uno::RuntimeException);
++};    
++
++#endif /* SW_VBA_BOOKMARKS_HXX */
+diff --git sw/source/ui/vba/vbadocument.cxx sw/source/ui/vba/vbadocument.cxx
+new file mode 100644
+index 0000000..c6b1c25
+--- /dev/null
++++ sw/source/ui/vba/vbadocument.cxx
+@@ -0,0 +1,186 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbadocument.cxx,v $
++ * $Revision: 1.7 $
++ *
++ * 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 "vbadocument.hxx"
++#include "vbarange.hxx"
++#include "vbarangehelper.hxx"
++#include "vbadocumentproperties.hxx"
++#include "vbabookmarks.hxx"
++#include "vbavariables.hxx"
++#include <com/sun/star/text/XBookmarksSupplier.hpp>
++#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
++#include <com/sun/star/document/XDocumentProperties.hpp>
++#include <vbahelper/helperdecl.hxx>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaDocument::SwVbaDocument( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > xModel ): SwVbaDocument_BASE( xParent, xContext, xModel )
++{
++    Initialize();
++}
++SwVbaDocument::SwVbaDocument( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) : SwVbaDocument_BASE( aArgs, xContext )
++{
++    Initialize();
++} 
++
++SwVbaDocument::~SwVbaDocument()
++{
++}
++
++void SwVbaDocument::Initialize()
++{
++    mxTextDocument.set( getModel(), uno::UNO_QUERY_THROW );    
++}
++
++uno::Reference< word::XRange > SAL_CALL 
++SwVbaDocument::getContent() throw ( uno::RuntimeException )
++{
++    uno::Reference< text::XTextRange > xStart = mxTextDocument->getText()->getStart();
++    uno::Reference< text::XTextRange > xEnd;
++    return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, xStart, xEnd, sal_True ) );
++}
++
++uno::Reference< word::XRange > SAL_CALL 
++SwVbaDocument::Range( const uno::Any& rStart, const uno::Any& rEnd ) throw ( uno::RuntimeException )
++{
++    if( !rStart.hasValue() && !rEnd.hasValue() )
++        return getContent();
++    
++    sal_Int32 nStart = 0;
++    sal_Int32 nEnd = 0;
++    rStart >>= nStart;
++    rEnd >>= nEnd;
++    nStart--;
++    nEnd--;
++
++    uno::Reference< text::XTextRange > xStart;
++    uno::Reference< text::XTextRange > xEnd;
++    if( nStart != -1 || nEnd != -1 )
++    {
++        if( nStart == -1 )
++            xStart = mxTextDocument->getText()->getStart();
++        else
++            xStart = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nStart );
++
++        if( nEnd == -1 )
++            xEnd = mxTextDocument->getText()->getEnd();
++        else
++            xEnd = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nEnd );
++    }
++
++    if( !xStart.is() && !xEnd.is() )
++    {
++        try
++        {
++            // FIXME
++            xStart = mxTextDocument->getText()->getStart();
++            xEnd = mxTextDocument->getText()->getEnd();
++        }
++        catch( uno::Exception )
++        {
++            DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
++        }    
++    }
++    return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, xStart, xEnd ) );
++}
++
++uno::Any SAL_CALL
++SwVbaDocument::BuiltInDocumentProperties( const uno::Any& index ) throw (uno::RuntimeException)
++{
++    uno::Reference< XCollection > xCol( new SwVbaBuiltinDocumentProperties( mxParent, mxContext, getModel() ) );
++    if ( index.hasValue() )
++        return xCol->Item( index, uno::Any() );
++    return uno::makeAny( xCol );
++}
++
++uno::Any SAL_CALL
++SwVbaDocument::CustomDocumentProperties( const uno::Any& index ) throw (uno::RuntimeException)
++{
++    uno::Reference< XCollection > xCol( new SwVbaCustomDocumentProperties( mxParent, mxContext, getModel() ) );
++    if ( index.hasValue() )
++        return xCol->Item( index, uno::Any() );
++    return uno::makeAny( xCol );
++}
++
++uno::Any SAL_CALL 
++SwVbaDocument::Bookmarks( const uno::Any& rIndex ) throw ( uno::RuntimeException )
++{
++    uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( getModel(),uno::UNO_QUERY_THROW );
++    uno::Reference<container::XIndexAccess > xBookmarks( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW );
++    uno::Reference< XCollection > xBookmarksVba( new SwVbaBookmarks( this, mxContext, xBookmarks, getModel() ) );
++    if (  rIndex.getValueTypeClass() == uno::TypeClass_VOID )
++        return uno::makeAny( xBookmarksVba );
++    
++    return uno::Any( xBookmarksVba->Item( rIndex, uno::Any() ) );
++}
++
++uno::Any SAL_CALL 
++SwVbaDocument::Variables( const uno::Any& rIndex ) throw ( uno::RuntimeException )
++{
++    uno::Reference< document::XDocumentPropertiesSupplier > xDocumentPropertiesSupplier( getModel(),uno::UNO_QUERY_THROW );
++    uno::Reference< document::XDocumentProperties > xDocumentProperties =  xDocumentPropertiesSupplier->getDocumentProperties();
++    uno::Reference< beans::XPropertyAccess > xUserDefined( xDocumentProperties->getUserDefinedProperties(), uno::UNO_QUERY_THROW );
++
++    uno::Reference< XCollection > xVariables( new SwVbaVariables( this, mxContext, xUserDefined ) );
++    if (  rIndex.getValueTypeClass() == uno::TypeClass_VOID )
++        return uno::makeAny( xVariables );
++    
++    return uno::Any( xVariables->Item( rIndex, uno::Any() ) );
++}
++
++rtl::OUString& 
++SwVbaDocument::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaDocument") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaDocument::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Document" ) );
++	}
++	return aServiceNames;
++}
++
++namespace document
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::vba_service_class_<SwVbaDocument, sdecl::with_args<true> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "SwVbaDocument",
++    "ooo.vba.word.Document" );
++}
++
+diff --git sw/source/ui/vba/vbadocument.hxx sw/source/ui/vba/vbadocument.hxx
+new file mode 100644
+index 0000000..0f696ce
+--- /dev/null
++++ sw/source/ui/vba/vbadocument.hxx
+@@ -0,0 +1,63 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbadocument.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_DOCUMENT_HXX
++#define SW_VBA_DOCUMENT_HXX
++
++#include <ooo/vba/word/XDocument.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbadocumentbase.hxx>
++#include <com/sun/star/text/XTextDocument.hpp>
++
++typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ooo::vba::word::XDocument > SwVbaDocument_BASE;
++
++class SwVbaDocument : public SwVbaDocument_BASE
++{
++private:
++    css::uno::Reference< css::text::XTextDocument > mxTextDocument;
++
++    void Initialize();
++public:
++	SwVbaDocument( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& m_xContext, css::uno::Reference< css::frame::XModel > xModel );
++	SwVbaDocument(  css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
++	virtual ~SwVbaDocument();
++
++    // XDocument
++    virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL getContent() throw ( css::uno::RuntimeException );
++    virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL Range( const css::uno::Any& rStart, const css::uno::Any& rEnd ) throw ( css::uno::RuntimeException );
++    virtual css::uno::Any SAL_CALL BuiltInDocumentProperties( const css::uno::Any& index ) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL CustomDocumentProperties( const css::uno::Any& index ) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Bookmarks( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException );
++    virtual css::uno::Any SAL_CALL Variables( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException );
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_DOCUMENT_HXX */
+diff --git sw/source/ui/vba/vbadocumentproperties.cxx sw/source/ui/vba/vbadocumentproperties.cxx
+new file mode 100644
+index 0000000..74470f9
+--- /dev/null
++++ sw/source/ui/vba/vbadocumentproperties.cxx
+@@ -0,0 +1,798 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbadocument.cxx,v $
++ * $Revision: 1.7 $
++ *
++ * 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 "vbadocumentproperties.hxx"
++#include <cppuhelper/implbase1.hxx>
++#include <cppuhelper/implbase3.hxx>
++#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
++#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
++#include <com/sun/star/beans/NamedValue.hpp>
++#include <com/sun/star/beans/XPropertyContainer.hpp>
++#include <ooo/vba/word/WdBuiltInProperty.hpp>
++#include <ooo/vba/office/MsoDocProperties.hpp>
++#include <memory>
++#include <boost/shared_ptr.hpp>
++#include "wordvbahelper.hxx"
++#include "fesh.hxx"
++#include "docsh.hxx"
++using namespace ::ooo::vba;
++using namespace css;
++
++sal_Int8 lcl_toMSOPropType( const uno::Type& aType ) throw ( lang::IllegalArgumentException )
++{
++    sal_Int16 msoType = office::MsoDocProperties::msoPropertyTypeString;
++
++    switch ( aType.getTypeClass() )
++    {
++        case uno::TypeClass_BOOLEAN:       
++            msoType =  office::MsoDocProperties::msoPropertyTypeBoolean;
++            break;
++        case uno::TypeClass_FLOAT:
++            msoType =  office::MsoDocProperties::msoPropertyTypeFloat;
++            break;
++        case uno::TypeClass_STRUCT: // Assume date
++            msoType =  office::MsoDocProperties::msoPropertyTypeDate;
++            break;
++        case  uno::TypeClass_BYTE:
++        case  uno::TypeClass_SHORT:
++        case  uno::TypeClass_LONG:
++        case  uno::TypeClass_HYPER:
++            msoType =  office::MsoDocProperties::msoPropertyTypeNumber;
++            break;
++        default:
++            throw lang::IllegalArgumentException();
++    }
++    return msoType;
++}
++
++class PropertGetSetHelper
++{
++protected:
++    uno::Reference< frame::XModel > m_xModel;
++    uno::Reference< beans::XPropertySet > mxProps;
++public:
++    PropertGetSetHelper( const uno::Reference< frame::XModel >& xModel ):m_xModel( xModel ) 
++    {
++        uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW );
++        mxProps.set( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW );
++    }
++    virtual ~PropertGetSetHelper() {}
++    virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) = 0;
++    virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) = 0;
++    virtual uno::Reference< beans::XPropertySet > getUnoProperties() { return mxProps; }
++
++};
++
++class BuiltinPropertyGetSetHelper : public PropertGetSetHelper
++{
++public:
++    BuiltinPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) 
++    {
++    }
++    virtual uno::Any getPropertyValue( const rtl::OUString& rPropName )
++    {
++        if ( rPropName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("EditingDuration" ) ) ) )
++        {
++            sal_Int32 nSecs = 0;
++            mxProps->getPropertyValue( rPropName ) >>= nSecs;
++            return uno::makeAny( nSecs/60 ); // minutes
++        }
++        return mxProps->getPropertyValue( rPropName );
++    }
++    virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue )
++    {
++        mxProps->setPropertyValue( rPropName, aValue );
++    }
++};
++
++class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper
++{
++public:
++    CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel )
++    {
++        uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( mxProps, uno::UNO_QUERY_THROW );
++        uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );  
++        mxProps.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW );
++    }
++};
++class StatisticPropertyGetSetHelper : public PropertGetSetHelper
++{
++    SwDocShell* mpDocShell;
++    uno::Reference< beans::XPropertySet > mxModelProps;
++public:
++    StatisticPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( NULL )
++    {
++            mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW );
++            mpDocShell = word::getDocShell( xModel );
++    }
++    virtual uno::Any getPropertyValue( const rtl::OUString& rPropName )
++    {
++        uno::Sequence< beans::NamedValue > stats;
++        try 
++        {
++            // Characters, ParagraphCount & WordCount are available from
++            // the model ( and addtionally these also update the statics object )
++            //return mxProps->getPropertyValue( rPropName );
++            return mxModelProps->getPropertyValue( rPropName );
++        }
++        catch( uno::Exception& )
++        {
++            OSL_TRACE("Got exception");
++        }
++        uno::Any aReturn;
++        if ( rPropName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount")) ) ) // special processing needed
++        {
++            if ( mpDocShell )
++            {
++                SwFEShell* pFEShell = mpDocShell->GetFEShell();
++                if(pFEShell)
++                {
++                    aReturn <<= pFEShell->GetLineCount(FALSE);
++                }
++            }
++        }
++        else
++        {
++            mxModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphCount") ) ) >>= stats;
++            mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats;
++  
++            sal_Int32 nLen = stats.getLength();
++            bool bFound = false;
++            for ( sal_Int32 index = 0; index < nLen && !bFound ; ++index )
++            {
++                if ( rPropName.equals( stats[ index ].Name ) )
++                {
++                    aReturn = stats[ index ].Value;
++                    bFound = true;
++                }  
++            }     
++            if ( !bFound )
++                throw uno::RuntimeException(); // bad Property
++        }
++        return aReturn;
++    }
++
++    virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue )
++    {
++
++        uno::Sequence< beans::NamedValue > stats;
++        mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats;
++  
++        sal_Int32 nLen = stats.getLength();
++        for ( sal_Int32 index = 0; index < nLen; ++index )
++        {
++            if ( rPropName.equals( stats[ index ].Name ) )
++            {
++                stats[ index ].Value = aValue;
++                mxProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ), uno::makeAny( stats ) );
++                break;
++            }  
++        }     
++    }
++};
++
++class DocPropInfo
++{
++public:
++    rtl::OUString msMSODesc;
++    rtl::OUString msOOOPropName;
++    boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
++    
++    static DocPropInfo createDocPropInfo( const rtl::OUString& sDesc, const rtl::OUString& sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
++    {
++        return createDocPropInfo( rtl::OUStringToOString( sDesc, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sPropName, RTL_TEXTENCODING_UTF8 ).getStr(), rHelper );
++    }
++
++    static DocPropInfo createDocPropInfo( const sal_Char* sDesc, const sal_Char* sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
++    {
++        DocPropInfo aItem;
++        aItem.msMSODesc = rtl::OUString::createFromAscii( sDesc );
++        aItem.msOOOPropName = rtl::OUString::createFromAscii( sPropName );
++        aItem.mpPropGetSetHelper = rHelper;
++        return aItem;
++    }
++    uno::Any getValue() 
++    {
++        if ( mpPropGetSetHelper.get() )
++            return mpPropGetSetHelper->getPropertyValue( msOOOPropName ); 
++        return uno::Any();
++    }
++    void setValue( const uno::Any& rValue ) 
++    {
++        if ( mpPropGetSetHelper.get() )
++            mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue ); 
++    }
++    uno::Reference< beans::XPropertySet > getUnoProperties() 
++    { 
++        
++        uno::Reference< beans::XPropertySet > xProps;
++        if ( mpPropGetSetHelper.get() )
++            return mpPropGetSetHelper->getUnoProperties(); 
++        return xProps; 
++    }
++};
++
++
++typedef std::hash_map< sal_Int32, DocPropInfo > MSOIndexToOODocPropInfo;
++
++class BuiltInIndexHelper
++{
++    MSOIndexToOODocPropInfo m_docPropInfoMap;
++    BuiltInIndexHelper();
++public:
++    BuiltInIndexHelper( const uno::Reference< frame::XModel >& xModel )
++    {
++        boost::shared_ptr< PropertGetSetHelper > aStandardHelper( new BuiltinPropertyGetSetHelper( xModel ) );
++        boost::shared_ptr< PropertGetSetHelper > aUsingStatsHelper( new StatisticPropertyGetSetHelper( xModel ) );
++/*
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo( "Title", "Title", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo( "Subject", "Subject", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo( "Author", "Author", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo( "Keywords", "Keywords", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo( "Comments", "Description", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo( "Template", "Template", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo( "Last author", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo( "Revision number", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo( "Application name", "Generator", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo( "Last print date", "PrintDate", office::MsoDocProperties::msoPropertyTypeDate, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo( "Creation date", "CreationDate", office::MsoDocProperties::msoPropertyTypeDate, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo( "Last save time", "ModifyDate", office::MsoDocProperties::msoPropertyTypeDate, aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo( "Total editing time", "EditingDuration", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // Not sure if this is correct 
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo( "Number of pages", "PageCount", office::MsoDocProperties::msoPropertyTypeNumber, aUsingStatsHelper ); // special handling required
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo( "Number of words", "WordCount", office::MsoDocProperties::msoPropertyTypeNumber, aUsingStatsHelper ); // special handling required
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo( "Number of characters", "CharacterCount", office::MsoDocProperties::msoPropertyTypeNumber, aUsingStatsHelper ); // special handling required
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo( "Security", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo( "Category", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo( "Format", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo( "Manager", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo( "Company", "", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo( "Number of bytes", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to exist - size on disk exists ( for an already saved document ) perhaps it will do ( or we need something else )
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo( "Number of lines", "LineCount", office::MsoDocProperties::msoPropertyTypeNumber, aUsingStatsHelper ); // special handling
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo( "Number of paragraphs", "", office::MsoDocProperties::msoPropertyTypeNumber, aUsingStatsHelper ); // special handling
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo( "Number of slides", "" , office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo( "Number of notes", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo("Number of hidden Slides", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper  ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo( "Number of multimedia clips", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo( "Hyperlink base", "AutoloadURL", office::MsoDocProperties::msoPropertyTypeString, aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo( "Number of characters (with spaces)", "", office::MsoDocProperties::msoPropertyTypeNumber, aStandardHelper ); // doesn't seem to be supported
++*/
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo( "Title", "Title", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo( "Subject", "Subject", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo( "Author", "Author", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo( "Keywords", "Keywords", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo( "Comments", "Description", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo( "Template", "Template", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo( "Last author", "ModifiedBy", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo( "Revision number", "EditingCycles", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo( "Application name", "Generator", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo( "Last print date", "PrintDate", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo( "Creation date", "CreationDate", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo( "Last save time", "ModifyDate", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo( "Total editing time", "EditingDuration", aStandardHelper ); // Not sure if this is correct 
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo( "Number of pages", "PageCount", aUsingStatsHelper ); // special handling required ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo( "Number of words", "WordCount", aUsingStatsHelper ); // special handling require ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo( "Number of characters", "CharacterCount", aUsingStatsHelper ); // special handling required ?
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo( "Security", "", aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo( "Category", "Category", aStandardHelper ); // hacked in
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo( "Format", "", aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo( "Manager", "Manager", aStandardHelper ); // hacked in
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo( "Company", "Company", aStandardHelper ); // hacked in
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo( "Number of bytes", "", aStandardHelper ); // doesn't seem to exist - size on disk exists ( for an already saved document ) perhaps it will do ( or we need something else )
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo( "Number of lines", "LineCount", aUsingStatsHelper ); // special handling
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo( "Number of paragraphs", "ParagraphCount", aUsingStatsHelper ); // special handling
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo( "Number of slides", "" , aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo( "Number of notes", "", aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo("Number of hidden Slides", "", aStandardHelper  ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo( "Number of multimedia clips", "", aStandardHelper ); // doesn't seem to exist
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo( "Hyperlink base", "AutoloadURL", aStandardHelper );
++        m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo( "Number of characters (with spaces)", "", aStandardHelper ); // doesn't seem to be supported
++    }
++
++    MSOIndexToOODocPropInfo& getDocPropInfoMap() { return m_docPropInfoMap; }
++};
++
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentProperty > SwVbaDocumentProperty_BASE;
++
++class SwVbaBuiltInDocumentProperty : public SwVbaDocumentProperty_BASE
++{
++protected:
++    DocPropInfo mPropInfo;
++public:
++    SwVbaBuiltInDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
++    // XDocumentProperty
++    virtual void SAL_CALL Delete(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual ::rtl::OUString SAL_CALL getName(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual ::sal_Int8 SAL_CALL getType(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual ::sal_Bool SAL_CALL getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setLinkToContent( ::sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual uno::Any SAL_CALL getValue(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual rtl::OUString SAL_CALL getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setLinkSource( const rtl::OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException);
++    //XDefaultProperty
++    virtual ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (uno::RuntimeException) { return rtl::OUString::createFromAscii("Value"); }
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++class SwVbaCustomDocumentProperty : public SwVbaBuiltInDocumentProperty
++{
++public:
++
++    SwVbaCustomDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
++
++    virtual ::sal_Bool SAL_CALL getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setLinkToContent( ::sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException);
++
++    virtual rtl::OUString SAL_CALL getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setLinkSource( const rtl::OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL Delete(  ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException);
++    virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException);
++
++};
++
++
++SwVbaCustomDocumentProperty::SwVbaCustomDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaBuiltInDocumentProperty( xParent, xContext, rInfo )
++{
++}
++
++sal_Bool
++SwVbaCustomDocumentProperty::getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // #FIXME we need to store the link content somewhere
++    return sal_False;
++}
++
++void
++SwVbaCustomDocumentProperty::setLinkToContent( sal_Bool /*bLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++}
++
++rtl::OUString
++SwVbaCustomDocumentProperty::getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // #FIXME we need to store the link content somewhere
++    return rtl::OUString();;
++}
++
++void
++SwVbaCustomDocumentProperty::setLinkSource( const rtl::OUString& /*rsLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // #FIXME we need to store the link source somewhere
++}
++
++void SAL_CALL 
++SwVbaCustomDocumentProperty::setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // setName on existing property ? 
++    // #FIXME 
++    // do we need to delete existing property and create a new one?
++}
++
++void SAL_CALL 
++SwVbaCustomDocumentProperty::setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // setType, do we need to do a conversion?
++    // #FIXME the underlying value needs to be changed to the new type
++}
++
++void SAL_CALL 
++SwVbaCustomDocumentProperty::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    uno::Reference< beans::XPropertyContainer > xContainer( mPropInfo.getUnoProperties(), uno::UNO_QUERY_THROW );
++    xContainer->removeProperty( getName() );
++}
++
++SwVbaBuiltInDocumentProperty::SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaDocumentProperty_BASE( xParent, xContext ), mPropInfo( rInfo )
++{
++} 
++
++void SAL_CALL 
++SwVbaBuiltInDocumentProperty::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++ 
++::rtl::OUString SAL_CALL 
++SwVbaBuiltInDocumentProperty::getName(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    return mPropInfo.msMSODesc;
++}
++
++void SAL_CALL
++SwVbaBuiltInDocumentProperty::setName( const rtl::OUString& ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++
++::sal_Int8 SAL_CALL 
++SwVbaBuiltInDocumentProperty::getType(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    return lcl_toMSOPropType( getValue().getValueType() );
++}
++
++void SAL_CALL 
++SwVbaBuiltInDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++
++::sal_Bool SAL_CALL 
++SwVbaBuiltInDocumentProperty::getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    return sal_False; // built-in always false
++}
++
++void SAL_CALL 
++SwVbaBuiltInDocumentProperty::setLinkToContent( ::sal_Bool /*LinkToContent*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++
++uno::Any SAL_CALL 
++SwVbaBuiltInDocumentProperty::getValue(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    uno::Any aRet = mPropInfo.getValue();
++    if ( !aRet.hasValue() )
++        throw uno::RuntimeException();
++    return aRet;
++}
++
++void SAL_CALL 
++SwVbaBuiltInDocumentProperty::setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    mPropInfo.setValue( Value );
++}
++
++rtl::OUString SAL_CALL 
++SwVbaBuiltInDocumentProperty::getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++
++void SAL_CALL 
++SwVbaBuiltInDocumentProperty::setLinkSource( const rtl::OUString& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // not valid for Builtin
++    throw uno::RuntimeException();
++}
++
++rtl::OUString& 
++SwVbaBuiltInDocumentProperty::getServiceImplName()
++{
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBuiltinDocumentProperty") );
++    return sImplName;    
++}
++
++uno::Sequence<rtl::OUString> 
++SwVbaBuiltInDocumentProperty::getServiceNames()
++{
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.DocumentProperty" ) );
++    }
++    return aServiceNames;
++}
++typedef ::cppu::WeakImplHelper3< com::sun::star::container::XIndexAccess
++        ,com::sun::star::container::XNameAccess
++        ,com::sun::star::container::XEnumerationAccess
++        > PropertiesImpl_BASE;
++
++typedef std::hash_map< sal_Int32, uno::Reference< XDocumentProperty > > DocProps;
++
++typedef ::cppu::WeakImplHelper1< com::sun::star::container::XEnumeration > DocPropEnumeration_BASE;
++class DocPropEnumeration : public DocPropEnumeration_BASE
++{
++    DocProps mDocProps;
++    DocProps::iterator mIt;
++public:
++    
++    DocPropEnumeration( const DocProps& rProps ) : mDocProps( rProps ), mIt( mDocProps.begin() ) {}
++    virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
++    {
++        return mIt != mDocProps.end();
++    }
++    virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
++    {
++        if ( !hasMoreElements() )
++            throw container::NoSuchElementException();
++        return uno::makeAny( mIt++->second );
++    }
++};
++
++typedef std::hash_map< rtl::OUString, uno::Reference< XDocumentProperty >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > DocPropsByName;
++
++class BuiltInPropertiesImpl : public PropertiesImpl_BASE
++{
++protected:
++
++    uno::Reference< XHelperInterface > m_xParent;
++    uno::Reference< uno::XComponentContext > m_xContext;
++    uno::Reference< frame::XModel > m_xModel;
++    uno::Reference< document::XDocumentInfo > m_xOOOBuiltIns;
++ 
++    DocProps mDocProps;
++    DocPropsByName mNamedDocProps;
++      
++    public:
++    BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
++    {
++    	BuiltInIndexHelper builtIns( m_xModel );
++        for ( sal_Int32 index = word::WdBuiltInProperty::wdPropertyTitle; index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++index )
++        {
++            mDocProps[ index ] = new SwVbaBuiltInDocumentProperty( xParent, xContext, builtIns.getDocPropInfoMap()[ index ] );
++            mNamedDocProps[ mDocProps[ index ]->getName() ] = mDocProps[ index ];
++        } 
++    }
++// XIndexAccess
++    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException)
++    {
++        return mDocProps.size();
++    }
++    virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException )
++    {
++        // correct the correct by the base class for 1 based indices
++        DocProps::iterator it = mDocProps.find( ++Index );
++        if ( it == mDocProps.end() )
++            throw lang::IndexOutOfBoundsException();
++        return uno::makeAny( it->second  );
++    }
++    virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
++    {
++        if ( !hasByName( aName ) )
++		throw container::NoSuchElementException();
++        DocPropsByName::iterator it = mNamedDocProps.find( aName );
++        return uno::Any( it->second );
++        
++    }
++    virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
++    {
++        uno::Sequence< rtl::OUString > aNames( getCount() );
++        rtl::OUString* pName = aNames.getArray();
++        DocPropsByName::iterator it_end = mNamedDocProps.end();
++        for(  DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName )
++           *pName = it->first;
++        return aNames; 
++    }
++
++    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++    {
++        DocPropsByName::iterator it = mNamedDocProps.find( aName );
++        if ( it == mNamedDocProps.end() )
++            return sal_False;
++        return sal_True;
++    }
++// XElementAccess
++    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException) 
++    {
++        return  XDocumentProperty::static_type(0); 
++    }
++    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException)
++    {
++        return mDocProps.size() > 0;
++    }
++    virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException)
++    {
++        return new DocPropEnumeration( mDocProps );
++    }
++};
++
++SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaDocumentproperties_BASE( xParent, xContext,  uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) ), m_xModel( xModel )
++{
++} 
++
++uno::Reference< XDocumentProperty > SAL_CALL 
++SwVbaBuiltinDocumentProperties::Add( const ::rtl::OUString& /*Name*/, ::sal_Bool /*LinkToContent*/, ::sal_Int8 /*Type*/, const uno::Any& value, const uno::Any& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    throw uno::RuntimeException(
++        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("not supported for Builtin properties") ), uno::Reference< uno::XInterface >() );
++}
++
++// XEnumerationAccess
++uno::Type SAL_CALL 
++SwVbaBuiltinDocumentProperties::getElementType() throw (uno::RuntimeException)
++{
++    return  XDocumentProperty::static_type(0); 
++}
++
++uno::Reference< container::XEnumeration > SAL_CALL 
++SwVbaBuiltinDocumentProperties::createEnumeration() throw (uno::RuntimeException)
++{
++    uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
++    return xEnumAccess->createEnumeration();
++}
++
++// ScVbaCollectionBaseImpl      
++uno::Any 
++SwVbaBuiltinDocumentProperties::createCollectionObject( const uno::Any& aSource )
++{
++    // pass through
++    return aSource;
++}
++
++// XHelperInterface
++rtl::OUString& 
++SwVbaBuiltinDocumentProperties::getServiceImplName()
++{
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBuiltinDocumentProperties") );
++    return sImplName;    
++}
++
++uno::Sequence<rtl::OUString> 
++SwVbaBuiltinDocumentProperties::getServiceNames()
++{
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.DocumentProperties" ) );
++    }
++    return aServiceNames;
++}
++
++class CustomPropertiesImpl : public PropertiesImpl_BASE
++{
++    uno::Reference< XHelperInterface > m_xParent;
++    uno::Reference< uno::XComponentContext > m_xContext;
++    uno::Reference< frame::XModel > m_xModel;
++    uno::Reference< beans::XPropertySet > mxUserDefinedProp;
++    boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
++public:
++    CustomPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
++    {
++        // suck in the document( custom ) properties
++        uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW );
++        uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW );     
++        uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );     
++        mxUserDefinedProp.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW );     
++        mpPropGetSetHelper.reset( new CustomPropertyGetSetHelper( m_xModel ) );
++    }; 
++    // XIndexAccess
++    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException)
++    {
++        return mxUserDefinedProp->getPropertySetInfo()->getProperties().getLength();
++    }
++
++    virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException )
++    {
++        uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
++        if ( Index >= aProps.getLength() )
++            throw lang::IndexOutOfBoundsException();
++        // How to determine type e.g Date? ( com.sun.star.util.DateTime )
++        DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aProps[ Index ].Name, aProps[ Index ].Name, mpPropGetSetHelper );
++        return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
++    }
++
++    virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
++    {
++        if ( !hasByName( aName ) )
++            throw container::NoSuchElementException();
++
++        DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aName, aName, mpPropGetSetHelper );
++        return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
++    }
++
++    virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
++    {
++        uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
++        uno::Sequence< rtl::OUString > aNames( aProps.getLength() );
++        rtl::OUString* pString = aNames.getArray();
++        rtl::OUString* pEnd = ( pString + aNames.getLength() );
++        beans::Property* pProp = aProps.getArray();
++        for ( ; pString != pEnd; ++pString, ++pProp )
++            *pString = pProp->Name;
++        return aNames;
++    }
++
++    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++    {
++        OSL_TRACE("hasByName(%s) returns %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ) );
++        return mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName );
++    }
++
++    // XElementAccess
++    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException) 
++    {
++        return  XDocumentProperty::static_type(0); 
++    }
++
++    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException)
++    {
++        return getCount() > 0;
++    }
++
++    virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException)
++    {
++        // create a map of properties ( the key doesn't matter )
++        OSL_TRACE("Creating an enumeration");
++        sal_Int32 key = 0;
++        sal_Int32 nElem =  getCount();
++        DocProps simpleDocPropSnapShot;
++        for ( ; key < nElem; ++key )
++             simpleDocPropSnapShot[ key ].set( getByIndex( key ), uno::UNO_QUERY_THROW );
++        OSL_TRACE("After creating the enumeration");
++        return  new DocPropEnumeration( simpleDocPropSnapShot );
++    }
++
++    void addProp( const ::rtl::OUString& Name, ::sal_Int8 Type, const uno::Any& Value )
++    {
++        sal_Int16 attributes = 128;
++        uno::Reference< beans::XPropertyContainer > xContainer( mxUserDefinedProp, uno::UNO_QUERY_THROW );
++        // TODO fixme, perform the necessary Type Value conversions
++        xContainer->addProperty( Name, attributes, Value );
++    }
++
++};
++
++
++SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel )
++{
++    // replace the m_xIndexAccess implementation ( we need a virtual init )
++    m_xIndexAccess.set( new CustomPropertiesImpl( xParent, xContext, xModel ) );
++    m_xNameAccess.set( m_xIndexAccess, uno::UNO_QUERY_THROW );
++}
++
++uno::Reference< XDocumentProperty > SAL_CALL 
++SwVbaCustomDocumentProperties::Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const uno::Any& Value, const uno::Any& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    CustomPropertiesImpl* pCustomProps = dynamic_cast< CustomPropertiesImpl* > ( m_xIndexAccess.get() );
++    uno::Reference< XDocumentProperty > xDocProp;
++    if ( pCustomProps )
++    {
++        rtl::OUString sLinkSource;
++        pCustomProps->addProp( Name, Type, Value );
++
++        xDocProp.set( m_xNameAccess->getByName( Name ), uno::UNO_QUERY_THROW );
++        xDocProp->setLinkToContent( LinkToContent );
++
++        if ( LinkSource >>= sLinkSource )
++           xDocProp->setLinkSource( sLinkSource );
++    }
++    return xDocProp;
++}
++
++// XHelperInterface
++rtl::OUString& 
++SwVbaCustomDocumentProperties::getServiceImplName()
++{
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCustomDocumentProperties") );
++    return sImplName;    
++}
+diff --git sw/source/ui/vba/vbadocumentproperties.hxx sw/source/ui/vba/vbadocumentproperties.hxx
+new file mode 100644
+index 0000000..a75c6a6
+--- /dev/null
++++ sw/source/ui/vba/vbadocumentproperties.hxx
+@@ -0,0 +1,70 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbadocument.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_DOCUMENTPROPERTIES_HXX
++#define SW_VBA_DOCUMENTPROPERTIES_HXX
++
++#include <ooo/vba/XDocumentProperties.hpp>
++#include <com/sun/star/frame/XModel.hpp>
++#include <vbahelper/vbacollectionimpl.hxx>
++#include <hash_map>
++
++typedef CollTestImplHelper< ov::XDocumentProperties > SwVbaDocumentproperties_BASE;
++
++class SwVbaBuiltinDocumentProperties : public SwVbaDocumentproperties_BASE
++{
++protected:
++    css::uno::Reference< css::frame::XModel > m_xModel;
++public:
++    SwVbaBuiltinDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument );
++
++    // XDocumentProperties
++    virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    // XEnumerationAccess
++    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++    // ScVbaCollectionBaseImpl      
++    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
++
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++class SwVbaCustomDocumentProperties : public SwVbaBuiltinDocumentProperties
++{
++public:
++    SwVbaCustomDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument );
++// XDocumentProperties
++    virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++};
++
++#endif /* SW_VBA_DOCUMENTPROPERTY_HXX */
+diff --git sw/source/ui/vba/vbaglobals.cxx sw/source/ui/vba/vbaglobals.cxx
+new file mode 100644
+index 0000000..38818fa
+--- /dev/null
++++ sw/source/ui/vba/vbaglobals.cxx
+@@ -0,0 +1,164 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaglobals.cxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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/helperdecl.hxx>
++#include "vbaglobals.hxx"
++
++#include <comphelper/unwrapargs.hxx>
++
++#include <com/sun/star/lang/XMultiComponentFactory.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/container/XNameContainer.hpp>
++#include <cppuhelper/bootstrap.hxx>
++#include "vbaapplication.hxx"
++using namespace ::com::sun::star;
++using namespace ::com::sun::star::uno;
++using namespace ::ooo::vba;
++
++
++
++// =============================================================================
++// SwVbaGlobals
++// =============================================================================
++
++SwVbaGlobals::SwVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
++{
++	OSL_TRACE("SwVbaGlobals::SwVbaGlobals()");
++	init( rxContext, uno::makeAny( getApplication() ) );
++}
++
++SwVbaGlobals::~SwVbaGlobals()
++{
++	OSL_TRACE("SwVbaGlobals::~SwVbaGlobals");
++}
++
++// =============================================================================
++// XGlobals
++// =============================================================================
++uno::Reference<word::XApplication >
++SwVbaGlobals::getApplication() throw (uno::RuntimeException)
++{
++	OSL_TRACE("In SwVbaGlobals::getApplication");	
++	static  uno::Reference< word::XApplication > WordApplication( new SwVbaApplication( mxContext) );
++   	return WordApplication; 
++}
++
++uno::Reference<word::XSystem > SAL_CALL
++SwVbaGlobals::getSystem() throw (uno::RuntimeException)
++{
++	return getApplication()->getSystem();	
++}
++
++uno::Reference< word::XDocument > SAL_CALL 
++SwVbaGlobals::getActiveDocument() throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveDocument();	
++}
++
++uno::Reference< word::XWindow > SAL_CALL 
++SwVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
++{
++	return getApplication()->getActiveWindow();
++}
++
++rtl::OUString SAL_CALL 
++SwVbaGlobals::getName() throw (uno::RuntimeException)
++{
++	return getApplication()->getName();
++}
++
++uno::Reference<word::XOptions > SAL_CALL
++SwVbaGlobals::getOptions() throw (uno::RuntimeException)
++{
++	return getApplication()->getOptions();
++}
++
++uno::Any SAL_CALL
++SwVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    return getApplication()->CommandBars( aIndex );
++}
++
++uno::Reference<word::XSelection > SAL_CALL
++SwVbaGlobals::getSelection() throw (uno::RuntimeException)
++{
++	return getApplication()->getSelection();
++}
++
++rtl::OUString&
++SwVbaGlobals::getServiceImplName()
++{
++        static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaGlobals") );
++        return sImplName;
++}
++
++uno::Sequence< rtl::OUString >
++SwVbaGlobals::getServiceNames()
++{
++        static uno::Sequence< rtl::OUString > aServiceNames;
++        if ( aServiceNames.getLength() == 0 )
++        {
++                aServiceNames.realloc( 1 );
++                aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Globals" ) );
++        }
++        return aServiceNames;
++}
++
++uno::Sequence< rtl::OUString >
++SwVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
++{
++    static bool bInit = false;
++    static uno::Sequence< rtl::OUString > serviceNames( SwVbaGlobals_BASE::getAvailableServiceNames() );
++    if ( !bInit )
++    {
++         rtl::OUString names[] = { 
++            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Document" ) ),
++//            #FIXME #TODO make Application a proper service
++//            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Application" ) ),
++        };
++        sal_Int32 nWordServices = ( sizeof( names )/ sizeof( names[0] ) );
++        sal_Int32 startIndex = serviceNames.getLength();
++        serviceNames.realloc( serviceNames.getLength() + nWordServices );
++        for ( sal_Int32 index = 0; index < nWordServices; ++index )
++             serviceNames[ startIndex + index ] = names[ index ];
++        bInit = true;
++    }
++    return serviceNames;
++}
++
++namespace globals
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::vba_service_class_<SwVbaGlobals, sdecl::with_args<false> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "SwVbaGlobals",
++    "ooo.vba.word.Globals" );
++}
++
+diff --git sw/source/ui/vba/vbaglobals.hxx sw/source/ui/vba/vbaglobals.hxx
+new file mode 100644
+index 0000000..5c216b1
+--- /dev/null
++++ sw/source/ui/vba/vbaglobals.hxx
+@@ -0,0 +1,80 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaglobals.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_GLOBALS_HXX
++#define SW_VBA_GLOBALS_HXX
++
++#include <com/sun/star/lang/XServiceInfo.hpp>
++#include <com/sun/star/lang/XInitialization.hpp>
++#include <com/sun/star/uno/XComponentContext.hpp>
++#include <ooo/vba/word/XGlobals.hpp>
++#include <ooo/vba/word/XApplication.hpp>
++#include <ooo/vba/word/XSystem.hpp>
++#include <ooo/vba/word/XOptions.hpp>
++#include <ooo/vba/word/XSelection.hpp>
++
++#include <cppuhelper/implbase1.hxx>
++#include <vbahelper/vbahelper.hxx>
++#include <vbahelper/vbaglobalbase.hxx>
++
++// =============================================================================
++// class SwVbaGlobals
++// =============================================================================
++
++
++typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::word::XGlobals > SwVbaGlobals_BASE;
++
++class SwVbaGlobals : public SwVbaGlobals_BASE 
++{
++private:
++    css::uno::Reference< ooo::vba::word::XApplication > mxApplication;
++
++    virtual css::uno::Reference< ooo::vba::word::XApplication > getApplication() throw (css::uno::RuntimeException);
++
++public:
++	
++    SwVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext );
++    virtual ~SwVbaGlobals();
++
++    // XGlobals
++    virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);  
++    // XMultiServiceFactory
++    virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames(  ) throw (css::uno::RuntimeException);
++
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_GLOBALS_HXX */ 
+diff --git sw/source/ui/vba/vbaoptions.cxx sw/source/ui/vba/vbaoptions.cxx
+new file mode 100644
+index 0000000..9066a76
+--- /dev/null
++++ sw/source/ui/vba/vbaoptions.cxx
+@@ -0,0 +1,148 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microoptionss, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbaoptions.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <ooo/vba/word/WdDefaultFilePath.hpp>
++#include <com/sun/star/util/XStringSubstitution.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <osl/file.hxx>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext )
++{
++    mxFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++}
++
++SwVbaOptions::~SwVbaOptions()
++{
++}
++
++uno::Any SAL_CALL 
++SwVbaOptions::DefaultFilePath( sal_Int32 _path ) throw ( uno::RuntimeException )
++{
++    switch( _path )
++    {
++        case word::WdDefaultFilePath::wdDocumentsPath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work") );
++            break;
++        }
++        case word::WdDefaultFilePath::wdPicturesPath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Gallery") );
++            break;
++        }
++        case word::WdDefaultFilePath::wdUserTemplatesPath:
++        case word::WdDefaultFilePath::wdWorkgroupTemplatesPath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template") );
++            break;
++        }
++        case word::WdDefaultFilePath::wdUserOptionsPath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserConfig") );
++            break;
++        }
++        case word::WdDefaultFilePath::wdToolsPath:
++        case word::WdDefaultFilePath::wdProgramPath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Module") );
++            break;
++        }
++        case word::WdDefaultFilePath::wdTempFilePath:
++        {
++            msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Temp") );
++            break;
++        }
++        default:
++        {
++            DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); 
++            break;
++        }
++    }
++    return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
++}
++
++void SwVbaOptions::setValueEvent( const uno::Any& value )
++{
++    rtl::OUString sNewPath;
++    value >>= sNewPath;
++    rtl::OUString sNewPathUrl;
++    ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl );
++    uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW );
++    rtl::OUString sOldPathUrl;
++    xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl;
++    // path could be a multipath, Microsoft doesn't support this feature in Word currently
++    // only the last path is from interest.
++    sal_Int32 nIndex = sOldPathUrl.lastIndexOf( sal_Unicode(';') );
++    if( nIndex != -1 )
++    {
++        sNewPathUrl = sOldPathUrl.copy( 0, nIndex + 1 ).concat( sNewPathUrl );
++    }
++    xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) );
++}
++
++uno::Any SwVbaOptions::getValueEvent()
++{
++    uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.PathSettings") ), uno::UNO_QUERY_THROW );
++    rtl::OUString sPathUrl;
++    xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl;
++    // path could be a multipath, Microsoft doesn't support this feature in Word currently
++    // only the last path is from interest.
++    sal_Int32 nIndex = sPathUrl.lastIndexOf( sal_Unicode(';') );
++    if( nIndex != -1 )
++    {
++        sPathUrl = sPathUrl.copy( nIndex + 1 );
++    }
++    rtl::OUString sPath;
++    ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath );
++    return uno::makeAny( sPath );
++}
++
++rtl::OUString& 
++SwVbaOptions::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaOptions") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaOptions::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Options" ) );
++	}
++	return aServiceNames;
++}
+diff --git sw/source/ui/vba/vbaoptions.hxx sw/source/ui/vba/vbaoptions.hxx
+new file mode 100644
+index 0000000..a03b581
+--- /dev/null
++++ sw/source/ui/vba/vbaoptions.hxx
+@@ -0,0 +1,62 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbasystem.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_OPTIONS_HXX
++#define SW_VBA_OPTIONS_HXX
++
++#include <ooo/vba/word/XOptions.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <vbahelper/vbapropvalue.hxx>
++#include <comphelper/processfactory.hxx>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XOptions > SwVbaOptions_BASE;
++
++class SwVbaOptions : public SwVbaOptions_BASE, 
++                    public PropListener
++{
++private:
++    rtl::OUString msDefaultFilePath;
++    css::uno::Reference< css::lang::XMultiServiceFactory > mxFactory;
++public:
++	SwVbaOptions( css::uno::Reference< css::uno::XComponentContext >& m_xContext ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaOptions();
++
++	// XOptions
++    virtual css::uno::Any SAL_CALL DefaultFilePath( sal_Int32 _path ) throw ( css::uno::RuntimeException );
++
++    //PropListener
++    virtual void setValueEvent( const css::uno::Any& value );
++    virtual css::uno::Any getValueEvent();
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_OPTIONS_HXX */
+diff --git sw/source/ui/vba/vbapane.cxx sw/source/ui/vba/vbapane.cxx
+new file mode 100644
+index 0000000..cdb5bac
+--- /dev/null
++++ sw/source/ui/vba/vbapane.cxx
+@@ -0,0 +1,79 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbapane.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++#include "vbaview.hxx"
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaPane::SwVbaPane( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++    const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :
++    SwVbaPane_BASE( rParent, rContext ), mxModel( xModel )
++{
++}
++
++SwVbaPane::~SwVbaPane()
++{
++}
++
++uno::Any SAL_CALL
++SwVbaPane::View() throw ( css::uno::RuntimeException )
++{
++    return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this,  mxContext, mxModel ) ) );    
++}
++
++void SAL_CALL
++SwVbaPane::Close( ) throw ( css::uno::RuntimeException )
++{
++    rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseWin"));
++    dispatchRequests( mxModel,url );
++}
++
++rtl::OUString& 
++SwVbaPane::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPane") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaPane::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Pane" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbapane.hxx sw/source/ui/vba/vbapane.hxx
+new file mode 100644
+index 0000000..cfb139d
+--- /dev/null
++++ sw/source/ui/vba/vbapane.hxx
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_PANE_HXX
++#define SW_VBA_PANE_HXX
++
++#include <ooo/vba/word/XPane.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XPane > SwVbaPane_BASE;
++
++class SwVbaPane : public SwVbaPane_BASE
++{
++private:
++    css::uno::Reference< css::frame::XModel > mxModel;
++
++public:
++	SwVbaPane( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, 
++        const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaPane();
++
++    // Methods
++    virtual css::uno::Any SAL_CALL View(  ) throw (css::uno::RuntimeException);
++    virtual void SAL_CALL Close(  ) throw (css::uno::RuntimeException);
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_PANE_HXX */
+diff --git sw/source/ui/vba/vbapanes.cxx sw/source/ui/vba/vbapanes.cxx
+new file mode 100644
+index 0000000..5cd35e2
+--- /dev/null
++++ sw/source/ui/vba/vbapanes.cxx
+@@ -0,0 +1,127 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbapanes.hxx"
++#include "vbapane.hxx"
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++// I assume there is only one pane in Writer
++typedef ::cppu::WeakImplHelper1<container::XIndexAccess > PanesIndexAccess_Base;
++class PanesIndexAccess : public PanesIndexAccess_Base
++{
++private:
++    uno::Reference< XHelperInterface > mxParent;
++    uno::Reference< uno::XComponentContext > mxContext;
++    uno::Reference< frame::XModel > mxModel;
++
++public:
++    PanesIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) {}
++    ~PanesIndexAccess(){}
++
++    // XIndexAccess
++    virtual sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException)
++    {
++        return 1;
++    }
++    virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
++    {
++        if( Index != 1 )
++            throw container::NoSuchElementException();
++        return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( mxParent,  mxContext, mxModel ) ) );    
++    }
++    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException)
++    {
++        return word::XPane::static_type(0);
++    }
++    virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException)
++    {
++        return sal_True;
++    }
++};
++
++class PanesEnumWrapper : public EnumerationHelper_BASE
++{
++	uno::Reference<container::XIndexAccess > m_xIndexAccess;
++	sal_Int32 nIndex;
++public:
++	PanesEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
++	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
++	{
++		return ( nIndex < m_xIndexAccess->getCount() );
++	}
++
++	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
++	{
++		if ( nIndex < m_xIndexAccess->getCount() )
++			return m_xIndexAccess->getByIndex( nIndex++ );
++		throw container::NoSuchElementException();
++	}
++};
++
++SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) ),  mxModel( xModel )
++{
++}
++// XEnumerationAccess
++uno::Type
++SwVbaPanes::getElementType() throw (uno::RuntimeException)
++{
++	return word::XPane::static_type(0);
++}
++uno::Reference< container::XEnumeration >
++SwVbaPanes::createEnumeration() throw (uno::RuntimeException)
++{
++    return new PanesEnumWrapper( m_xIndexAccess );
++}
++
++uno::Any
++SwVbaPanes::createCollectionObject( const css::uno::Any& aSource )
++{
++    return aSource;
++}
++
++rtl::OUString& 
++SwVbaPanes::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPanes") );
++	return sImplName;
++}
++
++css::uno::Sequence<rtl::OUString> 
++SwVbaPanes::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > sNames;
++	if ( sNames.getLength() == 0 )
++	{
++		sNames.realloc( 1 );
++		sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Panes") );
++	}
++	return sNames;
++}
+diff --git sw/source/ui/vba/vbapanes.hxx sw/source/ui/vba/vbapanes.hxx
+new file mode 100644
+index 0000000..f9c9441
+--- /dev/null
++++ sw/source/ui/vba/vbapanes.hxx
+@@ -0,0 +1,60 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_PANES_HXX
++#define SW_VBA_PANES_HXX
++
++#include <vbahelper/vbacollectionimpl.hxx>
++#include <ooo/vba/word/XPanes.hpp>
++#include <com/sun/star/container/XEnumerationAccess.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++
++typedef CollTestImplHelper< ooo::vba::word::XPanes > SwVbaPanes_BASE;
++
++class SwVbaPanes : public SwVbaPanes_BASE
++{
++private:
++    css::uno::Reference< css::frame::XModel > mxModel;
++
++public:
++	SwVbaPanes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
++	virtual ~SwVbaPanes() {}
++
++	// XEnumerationAccess
++	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++
++	// SwVbaPanes_BASE
++	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); 
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};    
++
++#endif /* SW_VBA_PANES_HXX */
+diff --git sw/source/ui/vba/vbarange.cxx sw/source/ui/vba/vbarange.cxx
+new file mode 100644
+index 0000000..39c93b9
+--- /dev/null
++++ sw/source/ui/vba/vbarange.cxx
+@@ -0,0 +1,302 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbarange.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++#include "vbarangehelper.hxx"
++#include <com/sun/star/text/XTextDocument.hpp>
++#include <ooo/vba/word/WdBreakType.hpp>
++#include <com/sun/star/style/BreakType.hpp>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRange > SwVbaBaseRange_BASE;
++
++class SwVbaBaseRange : public SwVbaBaseRange_BASE
++{
++protected:
++    uno::Reference< text::XTextDocument > mxTextDocument;
++    uno::Reference< text::XTextCursor > mxTextCursor;
++    uno::Reference< text::XText > mxText;
++    sal_Bool mbMaySpanEndOfDocument;
++
++	SwVbaBaseRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext );
++    virtual ~SwVbaBaseRange();
++
++public:
++    uno::Reference< text::XTextRange > getXTextRange() throw (uno::RuntimeException);
++
++	// XRange
++    virtual rtl::OUString SAL_CALL getText() throw (uno::RuntimeException);
++    virtual void SAL_CALL setText( const rtl::OUString& rText ) throw (uno::RuntimeException);
++
++   // Methods
++   virtual void SAL_CALL InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException);
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++
++SwVbaBaseRange::SwVbaBaseRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext )
++    : SwVbaBaseRange_BASE( rParent, rContext )
++{
++}
++
++SwVbaBaseRange::~SwVbaBaseRange()
++{
++}
++
++uno::Reference< text::XTextRange >
++SwVbaBaseRange::getXTextRange() throw (uno::RuntimeException)
++{
++    uno::Reference< text::XTextRange > xTextRange( mxTextCursor, uno::UNO_QUERY_THROW );
++    return xTextRange;
++}
++
++/**
++* The complexity in this method is because we need to workaround
++* an issue that the last paragraph in a document does not have a trailing CRLF.
++* @return
++*/
++rtl::OUString SAL_CALL
++SwVbaBaseRange::getText() throw ( uno::RuntimeException )
++{
++    rtl::OUString aText = mxTextCursor->getString();
++    sal_Int32 nLen = aText.getLength();
++
++    // FIXME: should add a line separator if the range includes the last paragraph
++    if( nLen == 0 )
++    {
++        if( mxTextCursor->isCollapsed() )
++        {
++            mxTextCursor->goRight( 1, sal_True );
++            aText = mxTextCursor->getString();
++            mxTextCursor->collapseToStart();
++        }
++        else
++        {
++            uno::Reference< text::XTextRange > xStart = mxTextCursor->getStart();
++            uno::Reference< text::XTextRange > xEnd = mxTextCursor->getEnd();
++            mxTextCursor->collapseToEnd();
++            mxTextCursor->goRight( 1, sal_True );
++            mxTextCursor->gotoRange( xStart, sal_False );
++            mxTextCursor->gotoRange( xEnd, sal_True );
++        }
++    }
++
++    return aText;
++}
++
++void SAL_CALL
++SwVbaBaseRange::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException )
++{
++    if( rText.indexOf( '\n' )  != -1 )
++    {
++        mxTextCursor->setString( rtl::OUString() );
++        // process CR in strings
++        uno::Reference< text::XTextRange > xRange( mxTextCursor, uno::UNO_QUERY_THROW );
++        SwVbaRangeHelper::insertString( xRange, mxText, rText, sal_True );
++    }
++    else
++    {
++        mxTextCursor->setString( rText );
++    }
++}
++
++// FIXME: test is not pass
++void SAL_CALL SwVbaBaseRange::InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException)
++{
++    // default type is wdPageBreak;
++    sal_Int32 nBreakType = word::WdBreakType::wdPageBreak;
++    if( _breakType.hasValue() )
++        _breakType >>= nBreakType;
++
++    style::BreakType eBreakType = style::BreakType_NONE;
++    switch( nBreakType )
++    {
++        case word::WdBreakType::wdPageBreak:
++            eBreakType = style::BreakType_PAGE_AFTER;
++            break;
++        case word::WdBreakType::wdColumnBreak:
++            eBreakType = style::BreakType_COLUMN_AFTER;
++            break;
++        case word::WdBreakType::wdLineBreak:
++        case word::WdBreakType::wdLineBreakClearLeft:
++        case word::WdBreakType::wdLineBreakClearRight:
++        case word::WdBreakType::wdSectionBreakContinuous:
++        case word::WdBreakType::wdSectionBreakEvenPage:
++        case word::WdBreakType::wdSectionBreakNextPage:
++        case word::WdBreakType::wdSectionBreakOddPage:
++        case word::WdBreakType::wdTextWrappingBreak:
++            DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() );
++            break;
++        default:
++            DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
++    }
++
++    if( eBreakType != style::BreakType_NONE )
++    {
++        if( !mxTextCursor->isCollapsed() )
++        {
++            mxTextCursor->setString( rtl::OUString() );
++            mxTextCursor->collapseToStart();
++        }
++
++        uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW );
++        xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ), uno::makeAny( eBreakType ) );
++    }
++}
++
++rtl::OUString& 
++SwVbaBaseRange::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBaseRange") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaBaseRange::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.BaseRange" ) );
++	}
++	return aServiceNames;
++}
++
++
++/*
++* class SwVbaDocRange
++*/
++class SwVbaDocRange : public SwVbaBaseRange
++{
++public:
++	SwVbaDocRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++        const uno::Reference< text::XTextDocument >& rDocument, const uno::Reference< text::XTextRange >& rStart, 
++        const uno::Reference< text::XTextRange >& rEnd, const uno::Reference< text::XText >& rText, sal_Bool _bMaySpanEndOfDocument = sal_False ) 
++        throw ( uno::RuntimeException );
++    virtual ~SwVbaDocRange();
++};
++
++SwVbaDocRange::SwVbaDocRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++        const uno::Reference< text::XTextDocument >& rDocument, const uno::Reference< text::XTextRange >& rStart, 
++        const uno::Reference< text::XTextRange >& rEnd, const uno::Reference< text::XText >& rText, sal_Bool _bMaySpanEndOfDocument ) throw ( uno::RuntimeException ) : SwVbaBaseRange( rParent, rContext )
++{
++    mxTextDocument = rDocument;
++    mbMaySpanEndOfDocument = _bMaySpanEndOfDocument; 
++
++    if( rText.is() )
++        mxText = rText;
++    else
++        mxText = mxTextDocument->getText();
++    
++    mxTextCursor = SwVbaRangeHelper::initCursor( rStart, mxText );
++    mxTextCursor->collapseToStart();
++
++    if( rEnd.is() )
++        mxTextCursor->gotoRange( rEnd, sal_True );
++    else
++        mxTextCursor->gotoEnd( sal_True );
++}
++
++SwVbaDocRange::~SwVbaDocRange()
++{
++}
++
++/*
++* class SwVbaRange
++*/
++SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++    const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, sal_Bool _bMaySpanEndOfDocument ) : SwVbaRange_BASE( rParent, rContext )
++{
++    uno::Reference< text::XText > xText;
++    mxActualRange = uno::Reference< word::XRange > ( new SwVbaDocRange( rParent, rContext, rTextDocument, rStart, rEnd, xText, _bMaySpanEndOfDocument ) );
++}
++
++SwVbaRange::~SwVbaRange()
++{
++}
++
++uno::Reference< text::XTextRange >
++SwVbaRange::getXTextRange() throw (uno::RuntimeException)
++{
++    uno::Reference< text::XTextRange > xTextRange;
++    SwVbaBaseRange* pBaseRange = dynamic_cast< SwVbaBaseRange* >( mxActualRange.get() );
++    if( pBaseRange )
++        xTextRange = pBaseRange->getXTextRange();
++    return xTextRange;
++}
++
++rtl::OUString SAL_CALL
++SwVbaRange::getText() throw ( uno::RuntimeException )
++{
++    rtl::OUString aText;
++    if( mxActualRange.is() )
++        return mxActualRange->getText();
++    return aText;
++}
++
++void SAL_CALL
++SwVbaRange::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException )
++{
++    if( mxActualRange.is() )
++        mxActualRange->setText( rText );
++}
++
++void SAL_CALL SwVbaRange::InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException)
++{
++    if( mxActualRange.is() )
++        mxActualRange->InsertBreak( _breakType );
++}
++    
++rtl::OUString& 
++SwVbaRange::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRange") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaRange::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Range" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbarange.hxx sw/source/ui/vba/vbarange.hxx
+new file mode 100644
+index 0000000..f126527
+--- /dev/null
++++ sw/source/ui/vba/vbarange.hxx
+@@ -0,0 +1,65 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_RANGE_HXX
++#define SW_VBA_RANGE_HXX
++
++#include <ooo/vba/word/XRange.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/text/XTextRange.hpp>
++#include <com/sun/star/text/XTextDocument.hpp>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRange > SwVbaRange_BASE;
++
++class SwVbaRange : public SwVbaRange_BASE
++{
++private:
++    css::uno::Reference< ooo::vba::word::XRange > mxActualRange;
++
++public:
++	SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, 
++        const css::uno::Reference< css::text::XTextDocument >& rTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart, const css::uno::Reference< css::text::XTextRange >& rEnd, sal_Bool _bMaySpanEndOfDocument = sal_False );
++	virtual ~SwVbaRange();
++    
++    css::uno::Reference< css::text::XTextRange > getXTextRange() throw (css::uno::RuntimeException);
++
++	// Attribute
++    virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setText( const rtl::OUString& rText ) throw (css::uno::RuntimeException);
++
++   // Methods
++   virtual void SAL_CALL InsertBreak( const css::uno::Any& _breakType ) throw (css::uno::RuntimeException);
++
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_RANGE_HXX */
+diff --git sw/source/ui/vba/vbarangehelper.cxx sw/source/ui/vba/vbarangehelper.cxx
+new file mode 100644
+index 0000000..61ced2c
+--- /dev/null
++++ sw/source/ui/vba/vbarangehelper.cxx
+@@ -0,0 +1,143 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbarangehelper.hxx"
++#include <com/sun/star/text/ControlCharacter.hpp>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++/**
++ * get a range in a xText by creating
++ * a cursor that iterates over the text. If the iterating cursor is 
++ * equal to the desired position, the range equivalent is returned.
++ * Some special cases are tables that are inside of the text, because the
++ * position has to be adjusted.
++ * @param xText a text where a range position is searched
++ * @param position a position inside o the text
++ * @return a range for the postion; null is returned if no range can be
++ * constructed.
++ */
++uno::Reference< text::XTextRange > SwVbaRangeHelper::getRangeByPosition( const uno::Reference< text::XText >& rText, sal_Int32 _position ) throw ( uno::RuntimeException )
++{
++    uno::Reference< text::XTextRange > xRange;
++    if( rText.is() )
++    {
++        sal_Int32 nPos = 0;
++        uno::Reference< text::XTextCursor > xCursor = rText->createTextCursor();
++        xCursor->collapseToStart();
++        sal_Bool bCanGo = sal_True;
++        while( !xRange.is() && bCanGo )
++        {
++            if( _position == nPos )
++            {
++                xRange = xCursor->getStart();
++            }    
++            else
++            {
++                bCanGo = xCursor->goRight( 1, sal_False );
++                nPos++;
++            }
++        }
++    }
++    return xRange;
++}
++
++
++void SwVbaRangeHelper::insertString( uno::Reference< text::XTextRange >& rTextRange, uno::Reference< text::XText >& rText, const rtl::OUString& rStr, sal_Bool _bAbsorb ) throw ( uno::RuntimeException )
++{
++    sal_Int32 nlastIndex = 0;
++    sal_Int32 nIndex = 0;
++    uno::Reference< text::XTextRange > xRange = rTextRange;
++    
++    while(( nIndex = rStr.indexOf('\n', nlastIndex)) >= 0  )
++    {
++        xRange = xRange->getEnd();
++        if( nlastIndex < ( nIndex - 1 ) )
++        {
++            rText->insertString( xRange, rStr.copy( nlastIndex, ( nIndex - 1 - nlastIndex ) ), _bAbsorb );
++            xRange = xRange->getEnd();
++        }
++
++        rText->insertControlCharacter( xRange, text::ControlCharacter::PARAGRAPH_BREAK, _bAbsorb );
++        nlastIndex = nIndex + 1;
++    }
++
++    if( nlastIndex < rStr.getLength() )
++    {
++        xRange = xRange->getEnd();
++
++        rtl::OUString aWatt = rStr.copy( nlastIndex );
++        rText->insertString( xRange, aWatt, _bAbsorb );
++    }
++}
++
++uno::Reference< text::XTextCursor > SwVbaRangeHelper::initCursor( const uno::Reference< text::XTextRange >& rTextRange, const uno::Reference< text::XText >& rText ) throw ( uno::RuntimeException )
++{
++    uno::Reference< text::XTextCursor > xTextCursor;
++    sal_Bool bGotTextCursor = sal_False;
++
++    try
++    {
++        xTextCursor = rText->createTextCursorByRange( rTextRange );
++        bGotTextCursor = sal_True;
++    }
++    catch (uno::Exception& e)
++    {
++        DebugHelper::exception(e);
++    }
++
++    if( !bGotTextCursor )
++    {
++        try
++        {
++            uno::Reference< text::XText > xText = rTextRange->getText();
++            xTextCursor = xText->createTextCursor();
++            bGotTextCursor = sal_True;
++        }
++        catch( uno::Exception& e )
++        {
++            DebugHelper::exception(e);
++        }
++    }
++
++    if( !bGotTextCursor )
++    {
++        try
++        {
++            xTextCursor = rText->createTextCursor();
++            bGotTextCursor = sal_True;
++        }
++        catch( uno::Exception& e )
++        {
++            DebugHelper::exception(e);
++        }
++    }
++    return xTextCursor;
++}
+diff --git sw/source/ui/vba/vbarangehelper.hxx sw/source/ui/vba/vbarangehelper.hxx
+new file mode 100644
+index 0000000..3e5a281
+--- /dev/null
++++ sw/source/ui/vba/vbarangehelper.hxx
+@@ -0,0 +1,45 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_RANGEHELPER_HXX
++#define SW_VBA_RANGEHELPER_HXX
++
++#include <vbahelper/vbahelperinterface.hxx>
++#include <com/sun/star/text/XTextViewCursor.hpp>
++#include <com/sun/star/text/XText.hpp>
++
++class SwVbaRangeHelper
++{
++public:
++    static css::uno::Reference< css::text::XTextRange > getRangeByPosition( const css::uno::Reference< css::text::XText >& rText, sal_Int32 _position )throw ( css::uno::RuntimeException );
++    static void insertString( css::uno::Reference< css::text::XTextRange >& rTextRange, css::uno::Reference< css::text::XText >& rText, const rtl::OUString& rStr, sal_Bool _bAbsorb ) throw ( css::uno::RuntimeException );
++    static css::uno::Reference< css::text::XTextCursor > initCursor( const css::uno::Reference< css::text::XTextRange >& rTextRange, const css::uno::Reference< css::text::XText >& rText ) throw ( css::uno::RuntimeException );
++
++};
++#endif /* SW_VBA_RANGEHELPER_HXX */
+diff --git sw/source/ui/vba/vbaselection.cxx sw/source/ui/vba/vbaselection.cxx
+new file mode 100644
+index 0000000..ceb7bb1
+--- /dev/null
++++ sw/source/ui/vba/vbaselection.cxx
+@@ -0,0 +1,75 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbaselection.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaSelection::SwVbaSelection( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel ) throw ( css::uno::RuntimeException ) : SwVbaSelection_BASE( rParent, rContext ), mxModel( rModel )
++{
++}
++
++SwVbaSelection::~SwVbaSelection()
++{
++}
++
++rtl::OUString SAL_CALL
++SwVbaSelection::getText() throw ( uno::RuntimeException )
++{
++    rtl::OUString aText;
++    return aText;
++}
++
++void SAL_CALL
++SwVbaSelection::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException )
++{
++}
++
++rtl::OUString& 
++SwVbaSelection::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSelection") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaSelection::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Selection" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbaselection.hxx sw/source/ui/vba/vbaselection.hxx
+new file mode 100644
+index 0000000..4d48068
+--- /dev/null
++++ sw/source/ui/vba/vbaselection.hxx
+@@ -0,0 +1,56 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_SELECTION_HXX
++#define SW_VBA_SELECTION_HXX
++
++#include <ooo/vba/word/XSelection.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XSelection > SwVbaSelection_BASE;
++
++class SwVbaSelection : public SwVbaSelection_BASE
++{
++private:
++    css::uno::Reference< css::frame::XModel > mxModel;
++
++public:
++	SwVbaSelection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaSelection();
++    
++	// Attribute
++    virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setText( const rtl::OUString& rText ) throw (css::uno::RuntimeException);
++
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_SELECTION_HXX */
+diff --git sw/source/ui/vba/vbasystem.cxx sw/source/ui/vba/vbasystem.cxx
+new file mode 100644
+index 0000000..29ea2e5
+--- /dev/null
++++ sw/source/ui/vba/vbasystem.cxx
+@@ -0,0 +1,195 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbasystem.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <ooo/vba/word/WdCursorType.hpp>
++#include <tools/diagnose_ex.h>
++#include <tools/config.hxx>
++#include <tools/string.hxx>
++#include <osl/file.hxx>
++#include <tools/urlobj.hxx>
++#include <tools/string.hxx>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++PrivateProfileStringListener::PrivateProfileStringListener( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey )
++    :maFileName( rFileName ), maGroupName( rGroupName ), maKey( rKey )
++{
++}
++
++PrivateProfileStringListener::~PrivateProfileStringListener()
++{
++}
++
++void PrivateProfileStringListener::Initialize( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey )
++{
++    maFileName = rFileName;
++    maGroupName = rGroupName;
++    maKey = rKey;
++}
++
++uno::Any PrivateProfileStringListener::getValueEvent()
++{
++    // get the private profile string
++    Config aCfg( maFileName );
++    aCfg.SetGroup( maGroupName );
++    rtl::OUString sValue = rtl::OUString( String( aCfg.ReadKey( maKey ), RTL_TEXTENCODING_UTF8 ) );
++
++    return uno::makeAny( sValue );
++}
++
++void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
++{
++    // set the private profile string
++    Config aCfg( maFileName );
++    aCfg.SetGroup( maGroupName );
++
++    rtl::OUString aValue;
++    value >>= aValue;
++    aCfg.WriteKey( maKey, ByteString( aValue.getStr(), RTL_TEXTENCODING_UTF8 ) );
++}
++
++SwVbaSystem::SwVbaSystem( uno::Reference<uno::XComponentContext >& xContext ): SwVbaSystem_BASE( uno::Reference< XHelperInterface >(), xContext )
++{
++}
++
++SwVbaSystem::~SwVbaSystem()
++{
++}
++
++sal_Int32 SAL_CALL
++SwVbaSystem::getCursor() throw (uno::RuntimeException)
++{
++    sal_Int32 nPointerStyle =  getPointerStyle();
++
++    switch( nPointerStyle )
++    {
++        case POINTER_ARROW:
++            return word::WdCursorType::wdCursorNorthwestArrow;
++        case POINTER_NULL:
++            return word::WdCursorType::wdCursorNormal;
++        case POINTER_WAIT:
++            return word::WdCursorType::wdCursorWait;
++        case POINTER_TEXT:
++            return word::WdCursorType::wdCursorIBeam;
++        default:
++            return word::WdCursorType::wdCursorNormal;
++    }
++}
++
++void SAL_CALL 
++SwVbaSystem::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
++{
++    try
++    {
++        switch( _cursor )
++        {
++            case word::WdCursorType::wdCursorNorthwestArrow:
++            {
++                const Pointer& rPointer( POINTER_ARROW );
++                setCursorHelper( rPointer, sal_False );
++                break;
++            }
++            case word::WdCursorType::wdCursorWait:
++            {
++                const Pointer& rPointer( static_cast< PointerStyle >( POINTER_WAIT ) );
++                //It will set the edit window, toobar and statusbar's mouse pointer.
++                setCursorHelper( rPointer, sal_True );
++                break;
++            }
++            case word::WdCursorType::wdCursorIBeam:
++            {
++                const Pointer& rPointer( static_cast< PointerStyle >( POINTER_TEXT ) );
++                //It will set the edit window, toobar and statusbar's mouse pointer.
++                setCursorHelper( rPointer, sal_True );
++                break;
++            }
++            case word::WdCursorType::wdCursorNormal:
++            {
++                const Pointer& rPointer( POINTER_NULL );
++                setCursorHelper( rPointer, sal_False );
++                break;
++            }
++            default:
++                throw uno::RuntimeException( rtl::OUString( 
++                        RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
++                // TODO: isn't this a flaw in the API? It should be allowed to throw an
++                // IllegalArgumentException, or so
++        }        
++    }
++    catch( const uno::Exception& )
++    {
++    	DBG_UNHANDLED_EXCEPTION();
++    }
++}
++
++uno::Any SAL_CALL 
++SwVbaSystem::PrivateProfileString( const rtl::OUString& rFilename, const rtl::OUString& rSection, const rtl::OUString& rKey ) throw ( uno::RuntimeException )
++{
++    if( rFilename.getLength() == 0 )
++        throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
++
++    // FIXME: need to detect whether it is a relative file path
++    // we need to detect if this is a URL, if not then assume its a file path
++    rtl::OUString sFileUrl;
++    INetURLObject aObj;
++	aObj.SetURL( rFilename );
++	bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
++	if ( bIsURL )
++		sFileUrl = rFilename;
++	else
++		osl::FileBase::getFileURLFromSystemPath( rFilename, sFileUrl);
++
++    ByteString aGroupName = ByteString( rSection.getStr(), RTL_TEXTENCODING_UTF8);
++    ByteString aKey = ByteString( rKey.getStr(), RTL_TEXTENCODING_UTF8);
++    maPrivateProfileStringListener.Initialize( sFileUrl, aGroupName, aKey );
++
++    return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( &maPrivateProfileStringListener ) ) );
++}
++
++rtl::OUString& 
++SwVbaSystem::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSystem") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaSystem::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.System" ) );
++	}
++	return aServiceNames;
++}
+diff --git sw/source/ui/vba/vbasystem.hxx sw/source/ui/vba/vbasystem.hxx
+new file mode 100644
+index 0000000..59281b1
+--- /dev/null
++++ sw/source/ui/vba/vbasystem.hxx
+@@ -0,0 +1,75 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbasystem.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_SYSTEM_HXX
++#define SW_VBA_SYSTEM_HXX
++
++#include <ooo/vba/word/XSystem.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <vbahelper/vbapropvalue.hxx>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XSystem > SwVbaSystem_BASE;
++
++class PrivateProfileStringListener : public PropListener
++{
++private:
++    rtl::OUString maFileName;
++    ByteString maGroupName;
++    ByteString  maKey;
++public:    
++    PrivateProfileStringListener(){};
++    PrivateProfileStringListener( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey );
++    virtual ~PrivateProfileStringListener();
++    void Initialize( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey );
++
++    //PropListener
++    virtual void setValueEvent( const css::uno::Any& value );
++    virtual css::uno::Any getValueEvent();
++};
++
++class SwVbaSystem : public SwVbaSystem_BASE
++{
++private:
++    PrivateProfileStringListener maPrivateProfileStringListener;
++
++public:
++	SwVbaSystem( css::uno::Reference< css::uno::XComponentContext >& m_xContext );
++	virtual ~SwVbaSystem();
++
++	// XSystem
++	virtual sal_Int32 SAL_CALL getCursor() throw ( css::uno::RuntimeException );
++	virtual void SAL_CALL setCursor( sal_Int32 _cursor ) throw ( css::uno::RuntimeException );
++    virtual css::uno::Any SAL_CALL PrivateProfileString( const rtl::OUString& rFilename, const rtl::OUString& rSection, const rtl::OUString& rKey ) throw ( css::uno::RuntimeException );
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_SYSTEM_HXX */
+diff --git sw/source/ui/vba/vbavariable.cxx sw/source/ui/vba/vbavariable.cxx
+new file mode 100644
+index 0000000..5dc59ed
+--- /dev/null
++++ sw/source/ui/vba/vbavariable.cxx
+@@ -0,0 +1,108 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbavariable.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/beans/PropertyValue.hpp>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++SwVbaVariable::SwVbaVariable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++    const uno::Reference< beans::XPropertyAccess >& rUserDefined, const rtl::OUString& rName ) throw ( uno::RuntimeException ) :
++    SwVbaVariable_BASE( rParent, rContext ), mxUserDefined( rUserDefined ), maName( rName )
++{
++}
++
++SwVbaVariable::~SwVbaVariable()
++{
++}
++
++rtl::OUString SAL_CALL
++SwVbaVariable::getName() throw ( css::uno::RuntimeException )
++{
++    return maName;
++}
++
++void SAL_CALL
++SwVbaVariable::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException )
++{
++    throw uno::RuntimeException( rtl::OUString(
++            RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() );
++}
++
++uno::Any SAL_CALL
++SwVbaVariable::getValue() throw ( css::uno::RuntimeException )
++{
++    uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW );
++    return xProp->getPropertyValue( maName );
++}
++
++void SAL_CALL
++SwVbaVariable::setValue( const uno::Any& rValue ) throw ( css::uno::RuntimeException )
++{
++    // FIXME: fail to set the value if the new type of vaue is differenct from the original one.
++    uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW );
++    xProp->setPropertyValue( maName, rValue );
++}
++
++sal_Int32 SAL_CALL
++SwVbaVariable::getIndex() throw ( css::uno::RuntimeException )
++{
++    const uno::Sequence< beans::PropertyValue > props = mxUserDefined->getPropertyValues();
++    for (sal_Int32 i = 0; i < props.getLength(); ++i)
++    {
++        if( maName.equals( props[i].Name ) )
++            return i+1;
++    }
++
++    return 0;
++}
++
++rtl::OUString& 
++SwVbaVariable::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaVariable") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaVariable::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Variable" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbavariable.hxx sw/source/ui/vba/vbavariable.hxx
+new file mode 100644
+index 0000000..69d307d
+--- /dev/null
++++ sw/source/ui/vba/vbavariable.hxx
+@@ -0,0 +1,62 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_VARIABLE_HXX
++#define SW_VBA_VARIABLE_HXX
++
++#include <ooo/vba/word/XVariable.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/beans/XPropertyAccess.hpp>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XVariable > SwVbaVariable_BASE;
++
++class SwVbaVariable : public SwVbaVariable_BASE
++{
++private:
++    css::uno::Reference< css::beans::XPropertyAccess > mxUserDefined;
++    rtl::OUString maName;
++
++public:
++	SwVbaVariable( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, 
++        const css::uno::Reference< css::beans::XPropertyAccess >& rUserDefined, const rtl::OUString& rName ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaVariable();
++
++   // XVariable
++    virtual rtl::OUString SAL_CALL getName() throw ( css::uno::RuntimeException );
++    virtual void SAL_CALL setName( const rtl::OUString& ) throw ( css::uno::RuntimeException );
++    virtual css::uno::Any SAL_CALL getValue() throw ( css::uno::RuntimeException );
++    virtual void SAL_CALL setValue( const css::uno::Any& rValue ) throw ( css::uno::RuntimeException );
++    virtual sal_Int32 SAL_CALL getIndex() throw ( css::uno::RuntimeException );
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_VARIABLE_HXX */
+diff --git sw/source/ui/vba/vbavariables.cxx sw/source/ui/vba/vbavariables.cxx
+new file mode 100644
+index 0000000..9242fd9
+--- /dev/null
++++ sw/source/ui/vba/vbavariables.cxx
+@@ -0,0 +1,105 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbavariables.hxx"
++#include "vbavariable.hxx"
++#include <com/sun/star/beans/XPropertyContainer.hpp>
++#include <com/sun/star/beans/PropertyAttribute.hpp>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++uno::Reference< container::XIndexAccess > createVariablesAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertyAccess >& xUserDefined ) throw ( uno::RuntimeException )
++{
++    // FIXME: the performance is poor?
++    XNamedObjectCollectionHelper< word::XVariable >::XNamedVec mVariables;
++    const uno::Sequence< beans::PropertyValue > props = xUserDefined->getPropertyValues();
++    sal_Int32 nCount = props.getLength();
++    mVariables.reserve( nCount );
++    for( sal_Int32 i=0; i < nCount; i++ )
++        mVariables.push_back( uno::Reference< word::XVariable > ( new SwVbaVariable( xParent, xContext, xUserDefined, props[i].Name ) ) );
++
++    uno::Reference< container::XIndexAccess > xVariables( new XNamedObjectCollectionHelper< word::XVariable >( mVariables ) );
++    return xVariables;
++}
++
++SwVbaVariables::SwVbaVariables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertyAccess >& rUserDefined ): SwVbaVariables_BASE( xParent, xContext, createVariablesAccess( xParent, xContext, rUserDefined ) ),  mxUserDefined( rUserDefined )
++{
++}
++// XEnumerationAccess
++uno::Type
++SwVbaVariables::getElementType() throw (uno::RuntimeException)
++{
++	return word::XVariable::static_type(0);
++}
++uno::Reference< container::XEnumeration >
++SwVbaVariables::createEnumeration() throw (uno::RuntimeException)
++{
++    uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
++    return xEnumerationAccess->createEnumeration();
++}
++
++uno::Any
++SwVbaVariables::createCollectionObject( const css::uno::Any& aSource )
++{
++    return aSource;
++}
++
++uno::Any SAL_CALL
++SwVbaVariables::Add( const rtl::OUString& rName, const uno::Any& rValue ) throw (uno::RuntimeException)
++{
++    uno::Any aValue;
++    if( rValue.hasValue() )
++        aValue = rValue;
++    else
++        aValue <<= rtl::OUString();
++    uno::Reference< beans::XPropertyContainer > xPropertyContainer( mxUserDefined, uno::UNO_QUERY_THROW );
++    xPropertyContainer->addProperty( rName, beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::REMOVEABLE, aValue );
++
++    return uno::makeAny( uno::Reference< word::XVariable >( new SwVbaVariable( getParent(), mxContext, mxUserDefined, rName ) ) );
++}
++
++rtl::OUString& 
++SwVbaVariables::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaVariables") );
++	return sImplName;
++}
++
++css::uno::Sequence<rtl::OUString> 
++SwVbaVariables::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > sNames;
++	if ( sNames.getLength() == 0 )
++	{
++		sNames.realloc( 1 );
++		sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Variables") );
++	}
++	return sNames;
++}
+diff --git sw/source/ui/vba/vbavariables.hxx sw/source/ui/vba/vbavariables.hxx
+new file mode 100644
+index 0000000..4a453d1
+--- /dev/null
++++ sw/source/ui/vba/vbavariables.hxx
+@@ -0,0 +1,64 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_VARIABLES_HXX
++#define SW_VBA_VARIABLES_HXX
++
++#include <vbahelper/vbacollectionimpl.hxx>
++#include <ooo/vba/word/XVariables.hpp>
++#include <com/sun/star/container/XEnumerationAccess.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
 +#include <vbahelper/vbahelperinterface.hxx>
- 
- typedef InheritedHelperInterfaceImpl1<ov::excel::XValidation > ValidationImpl_BASE;
- 
-diff --git sc/source/ui/vba/vbawindow.cxx sc/source/ui/vba/vbawindow.cxx
-index ea4fe9a..9012ff7 100644
---- sc/source/ui/vba/vbawindow.cxx
-+++ sc/source/ui/vba/vbawindow.cxx
-@@ -27,10 +27,11 @@
-  * for a copy of the LGPLv3 License.
-  *
-  ************************************************************************/
--#include "helperdecl.hxx"
++#include <com/sun/star/beans/XPropertyAccess.hpp>
++
++typedef CollTestImplHelper< ooo::vba::word::XVariables > SwVbaVariables_BASE;
++
++class SwVbaVariables : public SwVbaVariables_BASE
++{
++private:
++    css::uno::Reference< css::beans::XPropertyAccess > mxUserDefined;
++
++public:
++	SwVbaVariables( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertyAccess >& rUserDefined );
++	virtual ~SwVbaVariables() {}
++
++	// XEnumerationAccess
++	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++
++	// SwVbaVariables_BASE
++	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); 
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++
++	// XVariables
++	virtual css::uno::Any SAL_CALL Add( const rtl::OUString& rName, const css::uno::Any& rValue ) throw (css::uno::RuntimeException);
++};    
++
++#endif /* SW_VBA_VARIABLES_HXX */
+diff --git sw/source/ui/vba/vbaview.cxx sw/source/ui/vba/vbaview.cxx
+new file mode 100644
+index 0000000..b9b52f4
+--- /dev/null
++++ sw/source/ui/vba/vbaview.cxx
+@@ -0,0 +1,384 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 "vbaview.hxx"
++#include <vbahelper/vbahelper.hxx>
++#include <tools/diagnose_ex.h>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/view/XViewSettingsSupplier.hpp>
++#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
++#include <com/sun/star/text/XText.hpp>
++#include <com/sun/star/text/XTextDocument.hpp>
++#include <com/sun/star/text/XFootnotesSupplier.hpp>
++#include <com/sun/star/text/XEndnotesSupplier.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
++#include <com/sun/star/frame/XController.hpp>
++#include <com/sun/star/lang/XServiceInfo.hpp>
++#include <ooo/vba/word/WdSpecialPane.hpp>
++#include <ooo/vba/word/WdViewType.hpp>
++#include <ooo/vba/word/WdSeekView.hpp>
++
++#include "wordvbahelper.hxx"
++#include <view.hxx>
++
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
++
++const sal_Int32 DEFAULT_BODY_DISTANCE = 500;
++
++SwVbaView::SwVbaView( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
++    const uno::Reference< frame::XModel >& rModel ) throw ( uno::RuntimeException ) :
++    SwVbaView_BASE( rParent, rContext ), mxModel( rModel )
++{
++    uno::Reference< frame::XController > xController = mxModel->getCurrentController();
++
++    uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp( xController, uno::UNO_QUERY_THROW );
++    mxViewCursor = xTextViewCursorSupp->getViewCursor();
++
++    uno::Reference< view::XViewSettingsSupplier > xViewSettingSupp( xController, uno::UNO_QUERY_THROW );
++    mxViewSettings.set( xViewSettingSupp->getViewSettings(), uno::UNO_QUERY_THROW );
++}
++
++SwVbaView::~SwVbaView()
++{
++}
++
++::sal_Int32 SAL_CALL 
++SwVbaView::getSeekView() throw (css::uno::RuntimeException)
++{
++    uno::Reference< text::XText > xCurrentText = mxViewCursor->getText();
++    uno::Reference< lang::XServiceInfo > xServiceInfo( xCurrentText, uno::UNO_QUERY_THROW );
++    rtl::OUString aImplName = xServiceInfo->getImplementationName();
++    if( aImplName.equalsAscii("SwXBodyText") )
++    {
++        return word::WdSeekView::wdSeekMainDocument;
++    }
++    else if( aImplName.equalsAscii("SwXHeadFootText") )
++    {
++        if( word::HeaderFooterHelper::isHeader( mxModel, xCurrentText ) )
++        {
++            if( word::HeaderFooterHelper::isFirstPageHeader( mxModel, xCurrentText ) )
++                return word::WdSeekView::wdSeekFirstPageHeader;
++            else if( word::HeaderFooterHelper::isEvenPagesHeader( mxModel, xCurrentText ) )
++                return word::WdSeekView::wdSeekEvenPagesHeader;
++            else
++                return word::WdSeekView::wdSeekPrimaryHeader;
++        }
++        else
++        {
++            if( word::HeaderFooterHelper::isFirstPageFooter( mxModel, xCurrentText ) )
++                return word::WdSeekView::wdSeekFirstPageFooter;
++            else if( word::HeaderFooterHelper::isEvenPagesFooter( mxModel, xCurrentText ) )
++                return word::WdSeekView::wdSeekEvenPagesFooter;
++            else
++                return word::WdSeekView::wdSeekPrimaryFooter;
++        }
++    }
++    else if( aImplName.equalsAscii("SwXFootnote") )
++    {
++        if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote") ) ) )
++            return word::WdSeekView::wdSeekEndnotes;
++        else
++            return word::WdSeekView::wdSeekFootnotes;
++    }
++
++    return word::WdSeekView::wdSeekMainDocument;
++}
++
++void SAL_CALL 
++SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeException)
++{
++    if( _seekview == getSeekView() )
++        return;
++
++    switch( _seekview )
++    {
++        case word::WdSeekView::wdSeekFirstPageFooter:
++        case word::WdSeekView::wdSeekFirstPageHeader:
++        case word::WdSeekView::wdSeekCurrentPageFooter:
++        case word::WdSeekView::wdSeekCurrentPageHeader:
++        case word::WdSeekView::wdSeekPrimaryFooter:
++        case word::WdSeekView::wdSeekPrimaryHeader:
++        case word::WdSeekView::wdSeekEvenPagesFooter:
++        case word::WdSeekView::wdSeekEvenPagesHeader:
++        {
++            // need to test
++            mxViewCursor->gotoRange( getHFTextRange( _seekview ), sal_False );
++            break;
++        }
++        case word::WdSeekView::wdSeekFootnotes:
++        {
++            uno::Reference< text::XFootnotesSupplier > xFootnotesSupp( mxModel, uno::UNO_QUERY_THROW );
++            uno::Reference< container::XIndexAccess > xFootnotes( xFootnotesSupp->getFootnotes(), uno::UNO_QUERY_THROW );
++            if( xFootnotes->getCount() > 0 )
++            {
++                uno::Reference< text::XText > xText( xFootnotes->getByIndex(0), uno::UNO_QUERY_THROW );
++                mxViewCursor->gotoRange( xText->getStart(), sal_False );
++            }
++            else
++            {
++                DebugHelper::exception( SbERR_NO_ACTIVE_OBJECT, rtl::OUString() );
++            }
++            break;
++        }
++        case word::WdSeekView::wdSeekEndnotes:
++        {
++            uno::Reference< text::XEndnotesSupplier > xEndnotesSupp( mxModel, uno::UNO_QUERY_THROW );
++            uno::Reference< container::XIndexAccess > xEndnotes( xEndnotesSupp->getEndnotes(), uno::UNO_QUERY_THROW );
++            if( xEndnotes->getCount() > 0 )
++            {
++                uno::Reference< text::XText > xText( xEndnotes->getByIndex(0), uno::UNO_QUERY_THROW );
++                mxViewCursor->gotoRange( xText->getStart(), sal_False );
++            }
++            else
++            {
++                DebugHelper::exception( SbERR_NO_ACTIVE_OBJECT, rtl::OUString() );
++            }
++            break;
++        }
++        case word::WdSeekView::wdSeekMainDocument:
++        {
++            uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
++            uno::Reference< text::XText > xText = xTextDocument->getText();
++            mxViewCursor->gotoRange( xText->getStart(), sal_False );
++            break;
++        }
++    }
++}
++
++::sal_Int32 SAL_CALL 
++SwVbaView::getSplitSpecial() throw (css::uno::RuntimeException)
++{
++    return word::WdSpecialPane::wdPaneNone;
++}
++
++void SAL_CALL 
++SwVbaView::setSplitSpecial( ::sal_Int32/* _splitspecial */) throw (css::uno::RuntimeException)
++{
++    // not support in Writer
++}
++
++::sal_Bool SAL_CALL 
++SwVbaView::getTableGridLines() throw (css::uno::RuntimeException)
++{
++    sal_Bool bShowTableGridLine = sal_False;
++    mxViewSettings->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowTableBoundaries"))) >>= bShowTableGridLine;
++    return bShowTableGridLine;
++}
++
++void SAL_CALL 
++SwVbaView::setTableGridLines( ::sal_Bool _tablegridlines ) throw (css::uno::RuntimeException)
++{
++    mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowTableBoundaries")), uno::makeAny( _tablegridlines ) );
++}
++
++::sal_Int32 SAL_CALL 
++SwVbaView::getType() throw (css::uno::RuntimeException)
++{
++    // FIXME: handle wdPrintPreview type
++    sal_Bool bOnlineLayout = sal_False;
++    mxViewSettings->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout"))) >>= bOnlineLayout;
++    return bOnlineLayout ? word::WdViewType::wdWebView : word::WdViewType::wdPrintView;
++}
++
++void SAL_CALL 
++SwVbaView::setType( ::sal_Int32 _type ) throw (css::uno::RuntimeException)
++{
++    // FIXME: handle wdPrintPreview type
++    switch( _type )
++    {
++        case word::WdViewType::wdPrintView:
++        {
++            mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout")), uno::makeAny( sal_False ) );
++            break;
++        }
++        case word::WdViewType::wdWebView:
++        {
++            mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout")), uno::makeAny( sal_True ) );
++            break;
++        }
++        case word::WdViewType::wdPrintPreview:
++        {
++            PrintPreviewHelper( uno::Any(),word::getView( mxModel ) ); 
++            break;
++        }
++        default:
++            DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() );
++            
++    }
++}
++
++uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType ) throw (uno::RuntimeException)
++{
++    mxModel->lockControllers();
++
++    rtl::OUString aPropIsOn;
++    rtl::OUString aPropIsShared;
++    rtl::OUString aPropBodyDistance;
++    rtl::OUString aPropText;
++    
++    switch( nType )
++    {
++        case word::WdSeekView::wdSeekCurrentPageFooter:
++        case word::WdSeekView::wdSeekFirstPageFooter:
++        case word::WdSeekView::wdSeekPrimaryFooter:
++        case word::WdSeekView::wdSeekEvenPagesFooter:
++        {
++            aPropIsOn = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn") );
++            aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared") );
++            aPropBodyDistance = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterBodyDistance") );
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") );
++            break;
++        }
++        case word::WdSeekView::wdSeekCurrentPageHeader:
++        case word::WdSeekView::wdSeekFirstPageHeader:
++        case word::WdSeekView::wdSeekPrimaryHeader:
++        case word::WdSeekView::wdSeekEvenPagesHeader:
++        {
++            aPropIsOn = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn") );
++            aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared") );
++            aPropBodyDistance = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderBodyDistance") );
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") );
++            break;
++        }
++    }
++
++    uno::Reference< text::XPageCursor > xPageCursor( mxViewCursor, uno::UNO_QUERY_THROW );
++    
++    if( nType == word::WdSeekView::wdSeekFirstPageFooter
++        || nType == word::WdSeekView::wdSeekFirstPageHeader )
++    {
++        xPageCursor->jumpToFirstPage();
++    }
++
++    uno::Reference< style::XStyle > xStyle;
++    uno::Reference< text::XText > xText;
++    switch( nType )
++    {
++        case word::WdSeekView::wdSeekPrimaryFooter:
++        case word::WdSeekView::wdSeekPrimaryHeader:
++        case word::WdSeekView::wdSeekEvenPagesFooter:
++        case word::WdSeekView::wdSeekEvenPagesHeader:
++        {
++            // The primary header is the first header of the section.
++            // If the header is not shared between odd and even pages
++            // the odd page's header is the primary header. If the
++            // first page's header is different from the rest of the
++            // document, it is NOT the primary header ( the next primary
++            // header would be on page 3 )
++            // The even pages' header is only available if the header is
++            // not shared and the current style is applied to a page with
++            // an even page number
++            uno::Reference< beans::XPropertySet > xCursorProps( mxViewCursor, uno::UNO_QUERY_THROW );
++            rtl::OUString aPageStyleName;
++            xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName;
++            if( aPageStyleName.equalsAscii("First Page") )
++            {
++                // go to the beginning of where the next style is used
++                sal_Bool hasNextPage = sal_False;
++                xStyle = word::getCurrentPageStyle( mxModel );
++                do
++                {
++                    hasNextPage = xPageCursor->jumpToNextPage();
++                }
++                while( hasNextPage && ( xStyle == word::getCurrentPageStyle( mxModel ) ) );
++
++                if( !hasNextPage )
++                    DebugHelper::exception( SbERR_BAD_ACTION, rtl::OUString() );
++            }
++            break;
++        }    
++        default:
++        {
++            break;
++        }
++    }    
++
++    xStyle = word::getCurrentPageStyle( mxModel );
++    uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW );
++    sal_Bool isOn = sal_False;
++    xPageProps->getPropertyValue( aPropIsOn ) >>= isOn;
++    sal_Bool isShared =  sal_False;
++    xPageProps->getPropertyValue( aPropIsShared ) >>= isShared;
++    if( !isOn )
++    {
++        xPageProps->setPropertyValue( aPropIsOn, uno::makeAny( sal_True ) );
++        xPageProps->setPropertyValue( aPropBodyDistance, uno::makeAny( DEFAULT_BODY_DISTANCE ) );
++    }
++    if( !isShared )
++    {
++        rtl::OUString aTempPropText = aPropText;
++        if( nType == word::WdSeekView::wdSeekEvenPagesFooter
++            || nType == word::WdSeekView::wdSeekEvenPagesHeader )
++        {
++            aTempPropText += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Left") );
++        }
++        else
++        {
++            aTempPropText += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Right") );
++        }
++        xText.set( xPageProps->getPropertyValue( aTempPropText), uno::UNO_QUERY_THROW );
++    }
++    else
++    {
++        if( nType == word::WdSeekView::wdSeekEvenPagesFooter
++            || nType == word::WdSeekView::wdSeekEvenPagesHeader )
++        {
++            DebugHelper::exception( SbERR_BAD_ACTION, rtl::OUString() );
++        }
++        xText.set( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
++    }
++
++    mxModel->unlockControllers();
++    if( !xText.is() )
++    {
++        DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() );
++    }
++    return xText->getStart();
++}
++
++rtl::OUString& 
++SwVbaView::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaView") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaView::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.View" ) );
++	}
++	return aServiceNames;
++}
++
+diff --git sw/source/ui/vba/vbaview.hxx sw/source/ui/vba/vbaview.hxx
+new file mode 100644
+index 0000000..4aa07a3
+--- /dev/null
++++ sw/source/ui/vba/vbaview.hxx
+@@ -0,0 +1,69 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 SW_VBA_VIEW_HXX
++#define SW_VBA_VIEW_HXX
++
++#include <ooo/vba/word/XView.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <com/sun/star/text/XTextViewCursor.hpp>
++#include <com/sun/star/text/XTextRange.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XView > SwVbaView_BASE;
++
++class SwVbaView : public SwVbaView_BASE
++{
++private:
++    css::uno::Reference< css::frame::XModel > mxModel;
++    css::uno::Reference< css::text::XTextViewCursor > mxViewCursor;
++    css::uno::Reference< css::beans::XPropertySet > mxViewSettings;
++
++    css::uno::Reference< css::text::XTextRange > getHFTextRange( sal_Int32 nType ) throw (css::uno::RuntimeException);
++
++public:
++	SwVbaView( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, 
++        const css::uno::Reference< css::frame::XModel >& rModel ) throw ( css::uno::RuntimeException );
++	virtual ~SwVbaView();
++
++   // XView
++    virtual ::sal_Int32 SAL_CALL getSeekView() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getSplitSpecial() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setSplitSpecial( ::sal_Int32 _splitspecial ) throw (css::uno::RuntimeException);
++    virtual ::sal_Bool SAL_CALL getTableGridLines() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setTableGridLines( ::sal_Bool _tablegridlines ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setType( ::sal_Int32 _type ) throw (css::uno::RuntimeException);
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif /* SW_VBA_VIEW_HXX */
+diff --git sw/source/ui/vba/vbawindow.cxx sw/source/ui/vba/vbawindow.cxx
+new file mode 100644
+index 0000000..abdf3d5
+--- /dev/null
++++ sw/source/ui/vba/vbawindow.cxx
+@@ -0,0 +1,116 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbawindow.cxx,v $
++ * $Revision: 1.5 $
++ *
++ * 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/helperdecl.hxx>
- #include "vbawindow.hxx"
- #include "vbaworksheets.hxx"
- #include "vbaworksheet.hxx"
++#include "vbawindow.hxx"
 +#include "vbaglobals.hxx"
- #include "vbapane.hxx"
- #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
- #include <com/sun/star/sheet/XSpreadsheet.hpp>
-@@ -787,7 +788,9 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException)
- 		default:
- 			DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
- 	}
--	dispatchExecute( m_xModel, nSlot );
-+	ScTabViewShell* pViewShell = getBestViewShell( m_xModel );
-+	if ( pViewShell )
-+		dispatchExecute( pViewShell, nSlot );
- }
- 
- sal_Bool SAL_CALL
-@@ -924,14 +927,14 @@ void SAL_CALL
- ScVbaWindow::PrintOut( 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 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
- {
- 	// need test, print current active sheet	
--	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, m_xModel, sal_True );
-+	PrintOutHelper( getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
- }
- 
- void SAL_CALL 
- ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
- {
- 	// need test, print preview current active sheet	
--	PrintPreviewHelper( EnableChanges, m_xModel );	
-+	PrintPreviewHelper( EnableChanges, getBestViewShell( m_xModel ) );	
- }
- 
- rtl::OUString& 
-diff --git sc/source/ui/vba/vbawindow.hxx sc/source/ui/vba/vbawindow.hxx
-index ee4f5c8..2fdd31c 100644
---- sc/source/ui/vba/vbawindow.hxx
-+++ sc/source/ui/vba/vbawindow.hxx
-@@ -39,7 +39,7 @@
- #include <ooo/vba/excel/XPane.hpp>
- #include <com/sun/star/awt/XDevice.hpp>
- 
--#include "vbahelperinterface.hxx"
++#include "vbadocument.hxx"
++#include "vbaview.hxx"
++#include "vbapanes.hxx"
++#include "vbapane.hxx"
++
++using namespace ::com::sun::star;
++using namespace ::ooo::vba;
++
++SwVbaWindow::SwVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext, xModel )
++{
++}
++
++SwVbaWindow::SwVbaWindow( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext )  
++        : WindowImpl_BASE( args, xContext )
++{
++}
++
++void
++SwVbaWindow::Activate() throw (css::uno::RuntimeException)
++{
++	SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
++
++	document.Activate();
++}
++
++void
++SwVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& RouteDocument ) throw (uno::RuntimeException)
++{
++    // FIXME: it is incorrect when there are more than 1 windows
++	SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
++    uno::Any FileName;
++	document.Close(SaveChanges, FileName, RouteDocument );
++}
++
++uno::Any SAL_CALL 
++SwVbaWindow::getView() throw (uno::RuntimeException)
++{
++    return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this,  mxContext, m_xModel ) ) );    
++}
++
++void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeException)
++{
++    sal_Int32 nType = 0;
++    if( _view >>= nType )
++    {
++        SwVbaView view( this,  mxContext, m_xModel );
++        view.setType( nType );
++    }    
++}
++
++uno::Any SAL_CALL 
++SwVbaWindow::Panes( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    uno::Reference< XCollection > xPanes( new SwVbaPanes( this,  mxContext, m_xModel ) );
++    if(  aIndex.getValueTypeClass() == uno::TypeClass_VOID )
++        return uno::makeAny( xPanes );
++
++    return uno::Any( xPanes->Item( aIndex, uno::Any() ) );    
++}
++
++uno::Any SAL_CALL 
++SwVbaWindow::ActivePane() throw (uno::RuntimeException)
++{
++    return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( this,  mxContext, m_xModel ) ) );    
++}
++
++rtl::OUString& 
++SwVbaWindow::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaWindow") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++SwVbaWindow::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Window" ) );
++	}
++	return aServiceNames;
++}
+diff --git sw/source/ui/vba/vbawindow.hxx sw/source/ui/vba/vbawindow.hxx
+new file mode 100644
+index 0000000..11a1a36
+--- /dev/null
++++ sw/source/ui/vba/vbawindow.hxx
+@@ -0,0 +1,61 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbawindow.hxx,v $
++ * $Revision: 1.4 $
++ *
++ * 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 SW_VBA_WINDOW_HXX
++#define SW_VBA_WINDOW_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/word/XWindow.hpp>
++#include <com/sun/star/uno/XComponentContext.hpp>
++
 +#include <vbahelper/vbahelperinterface.hxx>
- #include "vbaworkbook.hxx"
- 
- typedef InheritedHelperInterfaceImpl1<ov::excel::XWindow > WindowImpl_BASE;
-diff --git sc/source/ui/vba/vbawindows.cxx sc/source/ui/vba/vbawindows.cxx
-index 517f9fd..4d9284d 100644
---- sc/source/ui/vba/vbawindows.cxx
-+++ sc/source/ui/vba/vbawindows.cxx
-@@ -37,6 +37,7 @@
- 
- #include <tools/urlobj.hxx>
- #include "vbawindow.hxx"
-+#include "vbaglobals.hxx"
- //#include "vbaworkbook.hxx"
- 
- using namespace ::com::sun::star;
-diff --git sc/source/ui/vba/vbawindows.hxx sc/source/ui/vba/vbawindows.hxx
-index 67bda22..385530a 100644
---- sc/source/ui/vba/vbawindows.hxx
-+++ sc/source/ui/vba/vbawindows.hxx
-@@ -35,8 +35,8 @@
- 
- #include <com/sun/star/uno/XComponentContext.hpp>
-  
--#include "vbahelper.hxx"
--#include "vbacollectionimpl.hxx"
-+#include "excelvbahelper.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
- 
- 
- typedef CollTestImplHelper< ov::excel::XWindows > ScVbaWindows_BASE;
-diff --git sc/source/ui/vba/vbaworkbook.cxx sc/source/ui/vba/vbaworkbook.cxx
-index e0521dd..f3ad203 100644
---- sc/source/ui/vba/vbaworkbook.cxx
-+++ sc/source/ui/vba/vbaworkbook.cxx
-@@ -27,7 +27,7 @@
-  * for a copy of the LGPLv3 License.
-  *
-  ************************************************************************/
--#include "helperdecl.hxx"
-+#include <vbahelper/helperdecl.hxx>
- #include <tools/urlobj.hxx>
- #include <comphelper/unwrapargs.hxx>
- 
-@@ -46,7 +46,7 @@
- #include "vbaworkbook.hxx"
- #include "vbawindows.hxx"
- #include "vbastyles.hxx"
--#include "vbahelper.hxx"
-+#include "excelvbahelper.hxx"
- #include "vbapalette.hxx"
- #include <osl/file.hxx>
- #include <stdio.h>
-diff --git sc/source/ui/vba/vbaworkbook.hxx sc/source/ui/vba/vbaworkbook.hxx
-index b84d84e..6c8f7da 100644
---- sc/source/ui/vba/vbaworkbook.hxx
-+++ sc/source/ui/vba/vbaworkbook.hxx
-@@ -32,7 +32,7 @@
++#include <vbahelper/vbawindowbase.hxx>
++
++typedef cppu::ImplInheritanceHelper1< VbaWindowBase, ov::word::XWindow > WindowImpl_BASE;
++
++class SwVbaWindow : public WindowImpl_BASE
++{		
++public:	
++	SwVbaWindow( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel );
++    SwVbaWindow( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
++
++
++    // Attributes
++    virtual css::uno::Any SAL_CALL getView() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setView( const css::uno::Any& _view ) throw (css::uno::RuntimeException);
++	// Methods
++	virtual void SAL_CALL Activate(  ) throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Close( const css::uno::Any& SaveChanges, const css::uno::Any& RouteDocument ) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Panes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL ActivePane() throw (css::uno::RuntimeException);
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif //SW_VBA_WINDOW_HXX
+diff --git sw/source/ui/vba/wordvbahelper.cxx sw/source/ui/vba/wordvbahelper.cxx
+new file mode 100644
+index 0000000..00f40fd
+--- /dev/null
++++ sw/source/ui/vba/wordvbahelper.cxx
+@@ -0,0 +1,207 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelper.cxx,v $
++ * $Revision: 1.5.32.1 $
++ *
++ * 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 <docsh.hxx>
++#include "wordvbahelper.hxx"
++#include <comphelper/processfactory.hxx>
++#include <com/sun/star/frame/XController.hpp>
++#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
++#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
++#include <com/sun/star/lang/XUnoTunnel.hpp>
++#include <unotxdoc.hxx>
++
++using namespace ::com::sun::star;
++using namespace ::ooo::vba;
++
++#define FIRST_PAGE 1;
++
++namespace ooo
++{
++namespace vba
++{
++namespace word
++{
++
++SwDocShell* getDocShell( const uno::Reference< frame::XModel>& xModel ) 
++{
++	uno::Reference< lang::XUnoTunnel > xTunnel( xModel, uno::UNO_QUERY_THROW );
++    SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >( sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
++	return pXDoc ? pXDoc->GetDocShell() : 0;
++}
++
++SwView* getView( const uno::Reference< frame::XModel>& xModel )
++{
++    SwDocShell* pDocShell = getDocShell( xModel );
++    return pDocShell? pDocShell->GetView() : 0;
++}
++
++uno::Reference< text::XTextViewCursor > getXTextViewCursor( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
++{
++    uno::Reference< frame::XController > xController = xModel->getCurrentController();
++    uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp( xController, uno::UNO_QUERY_THROW );
++    uno::Reference< text::XTextViewCursor > xTextViewCursor = xTextViewCursorSupp->getViewCursor();
++    return xTextViewCursor;
++}
++
++uno::Reference< style::XStyle > getCurrentPageStyle( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
++{
++    uno::Reference< beans::XPropertySet > xCursorProps( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++    rtl::OUString aPageStyleName;
++    xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName;
++    uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
++    uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_QUERY_THROW );
++    uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles") ) ), uno::UNO_QUERY_THROW );
++    uno::Reference< style::XStyle > xStyle( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW );
++
++    return xStyle;
++}
++
++// Class HeaderFooterHelper 
++
++sal_Bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++    uno::Reference< beans::XPropertySet > xStyleProps( getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
++    
++    sal_Bool isOn = sal_False;
++    xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))) >>= isOn;
++    if( !isOn )
++        return sal_False;
++
++    sal_Bool isShared = sal_False;
++    xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared"))) >>= isShared;
++
++    rtl::OUString aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") );
++    if( !isShared )
++    {
++        if( 0 == xPageCursor->getPage() % 2 )
++        {
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderTextLeft") );
++        }
++        else
++        {
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderTextRight") );
++        }
++    }
++    
++    uno::Reference< text::XText > xText( xStyleProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
++    //FIXME: can not compare in this way?
++    return ( xText == xCurrentText );
++}
++
++sal_Bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    if( isHeader( xModel, xCurrentText ) )
++    {
++        uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++        // FIXME: getPage allways returns 1
++        sal_Int32 nPage = xPageCursor->getPage();
++        return nPage == FIRST_PAGE;
++    }
++    return sal_False;
++}
++
++sal_Bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    if( isHeader( xModel, xCurrentText ) )
++    {
++        uno::Reference< beans::XPropertySet > xStyleProps( getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
++        sal_Bool isShared = sal_False;
++        xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared"))) >>= isShared;
++        if( !isShared )
++        {
++            uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++            return ( 0 == xPageCursor->getPage() % 2 );
++        }    
++    }
++    return sal_False;
++}
++
++sal_Bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++    uno::Reference< beans::XPropertySet > xStyleProps( getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
++    
++    sal_Bool isOn = sal_False;
++    xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))) >>= isOn;
++    if( !isOn )
++        return sal_False;
++
++    sal_Bool isShared = sal_False;
++    xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared"))) >>= isShared;
++
++    rtl::OUString aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") );
++    if( !isShared )
++    {
++        if( 0 == xPageCursor->getPage() % 2 )
++        {
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterTextLeft") );
++        }
++        else
++        {
++            aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterTextRight") );
++        }
++    }
++    
++    uno::Reference< text::XText > xText( xStyleProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
++
++    return ( xText == xCurrentText );
++}
++
++sal_Bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    if( isFooter( xModel, xCurrentText ) )
++    {
++        uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++        sal_Int32 nPage = xPageCursor->getPage();
++        return nPage == FIRST_PAGE;
++    }
++    return sal_False;
++}
++
++sal_Bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
++{
++    if( isFooter( xModel, xCurrentText ) )
++    {
++        uno::Reference< beans::XPropertySet > xStyleProps( getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
++        sal_Bool isShared = sal_False;
++        xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared"))) >>= isShared;
++        if( !isShared )
++        {
++            uno::Reference< text::XPageCursor > xPageCursor( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
++            return ( 0 == xPageCursor->getPage() % 2 );
++        }    
++    }
++    return sal_False;
++}
++
++} // word
++} // 
++} //
+diff --git sw/source/ui/vba/wordvbahelper.hxx sw/source/ui/vba/wordvbahelper.hxx
+new file mode 100644
+index 0000000..aecae44
+--- /dev/null
++++ sw/source/ui/vba/wordvbahelper.hxx
+@@ -0,0 +1,67 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelper.hxx,v $
++ * $Revision: 1.5.32.1 $
++ *
++ * 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 SW_WORD_VBA_HELPER_HXX
++#define SW_WORD_VBA_HELPER_HXX
++
++#include <vbahelper/vbahelper.hxx>
++#include <com/sun/star/text/XText.hpp>
++#include <com/sun/star/text/XTextViewCursor.hpp>
++#include <com/sun/star/text/XPageCursor.hpp>
++#include <com/sun/star/style/XStyle.hpp>
++
++class SwDocShell;
++class SwView;
++namespace ooo 
++{
++	namespace vba 
++	{
++    namespace word
++    {
++		//css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException);
++        SwDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel );
++        SwView* getView( const css::uno::Reference< css::frame::XModel>& xModel );
++        css::uno::Reference< css::text::XTextViewCursor > getXTextViewCursor( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
++        css::uno::Reference< css::style::XStyle > getCurrentPageStyle( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
++
++class HeaderFooterHelper
++{
++public:
++    static sal_Bool isHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++    static sal_Bool isFirstPageHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++    static sal_Bool isEvenPagesHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++    static sal_Bool isFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++    static sal_Bool isFirstPageFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++    static sal_Bool isEvenPagesFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
++};
++
++}; // word
++}; // vba
++}; // ooo
++#endif
+diff --git sw/util/makefile.mk sw/util/makefile.mk
+index cb845b7..b47a0fe 100644
+--- sw/util/makefile.mk
++++ sw/util/makefile.mk
+@@ -126,6 +126,7 @@ SHL1STDLIBS+= \
+ 	$(SALHELPERLIB) \
+     $(ICUUCLIB) \
+ 	$(I18NUTILLIB)	\
++		        $(VBAHELPERLIB) \
+ 	$(AVMEDIALIB)
+ 
+ .IF "$(GUI)"=="WNT"
+@@ -338,6 +339,37 @@ SHL4STDLIBS= \
+ 	$(CPPUHELPERLIB) \
+ 	$(SALLIB) \
+ 	$(ICUUCLIB) \
++    $(VBAHELPERLIB) \
++    $(BASICLIB)     \
+ 	$(I18NUTILLIB)
  
- #include <com/sun/star/frame/XModel.hpp>
- #include <ooo/vba/excel/XWorkbook.hpp>
--#include "vbahelperinterface.hxx"
++#target vba
++TARGET_VBA=vbaswobj
++SHL5TARGET=$(TARGET_VBA)$(DLLPOSTFIX).uno
++SHL5IMPLIB=     i$(TARGET_VBA)
++
++SHL5VERSIONMAP=$(TARGET_VBA).map
++SHL5DEF=$(MISC)$/$(SHL5TARGET).def
++DEF5NAME=$(SHL5TARGET)
++SHL5STDLIBS= \
++                $(ISWLIB) \
++                $(CPPUHELPERLIB) \
++                $(VCLLIB) \
++                $(CPPULIB) \
++                $(COMPHELPERLIB) \
++                $(SVLIB) \
++                $(TOOLSLIB) \
++                $(SALLIB)\
++		        $(VBAHELPERLIB) \
++                $(BASICLIB)     \
++                $(SFXLIB)       \
++                $(SVXLIB)       \
++                $(SVTOOLLIB)    \
++                $(SVLLIB) \
++        $(VCLLIB) \
++        $(TKLIB) \
++
++SHL5DEPN=$(SHL1TARGETN)
++SHL5LIBS=$(SLB)$/$(TARGET_VBA).lib
++
+ .INCLUDE :  target.mk
+diff --git sw/util/vbaswobj.map sw/util/vbaswobj.map
+new file mode 100644
+index 0000000..832e82c
+--- /dev/null
++++ sw/util/vbaswobj.map
+@@ -0,0 +1,9 @@
++OOO_1.1 {
++	global:
++		component_getImplementationEnvironment;
++		component_getFactory;
++		component_writeInfo;
++
++	local:
++		*;
++};
+diff --git vbahelper/inc/vbahelper/helperdecl.hxx vbahelper/inc/vbahelper/helperdecl.hxx
+new file mode 100644
+index 0000000..7a0b495
+--- /dev/null
++++ vbahelper/inc/vbahelper/helperdecl.hxx
+@@ -0,0 +1,58 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: helperdecl.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 OOVBAAPI_SERV_DECL
++#define OOVBAAPI_SERV_DECL
++#include <comphelper/servicedecl.hxx>
++#include <ooo/vba/XHelperInterface.hpp>
++
++namespace comphelper {
++namespace service_decl {
++template <typename ImplT_, typename WithArgsT = with_args<false> >
++struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT >
++{
++    typedef serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > baseT;
++    /** Default ctor.  Implementation class without args, expecting
++        component context as single argument.
++    */
++    vba_service_class_() : baseT() {}
++    template <typename PostProcessFuncT>
++    /** Ctor to pass a post processing function/functor.
++        
++        @tpl PostProcessDefaultT let your compiler deduce this
++        @param postProcessFunc function/functor that gets the yet unacquired
++                               ImplT_ pointer returning a
++                               uno::Reference<uno::XInterface>
++    */
++    explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
++};
++
++} // namespace service_decl
++} // namespace comphelper
++#endif
+diff --git vbahelper/inc/vbahelper/vbaapplicationbase.hxx vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+new file mode 100644
+index 0000000..aff57d0
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+@@ -0,0 +1,59 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaapplicationbase.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 VBA_APPLICATION_BASE_HXX
++#define VBA_APPLICATION_BASE_HXX
++
++#include <ooo/vba/XHelperInterface.hpp>
++#include <ooo/vba/XApplicationBase.hpp>
++#include <vbahelper/vbahelperinterface.hxx>
++
++typedef InheritedHelperInterfaceImpl1< ov::XApplicationBase > ApplicationBase_BASE;
++
++class VbaApplicationBase : public ApplicationBase_BASE
++{
++protected:
++    VbaApplicationBase( const css::uno::Reference< css::uno::XComponentContext >& xContext );
++    virtual ~VbaApplicationBase();
++
++public:
++	// XHelperInterface ( parent is itself )
++	virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return this; }
++
++	virtual sal_Bool SAL_CALL getScreenUpdating() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setScreenUpdating(sal_Bool bUpdate) throw (css::uno::RuntimeException);
++	virtual sal_Bool SAL_CALL getDisplayStatusBar() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);  
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif
+diff --git vbahelper/inc/vbahelper/vbacollectionimpl.hxx vbahelper/inc/vbahelper/vbacollectionimpl.hxx
+new file mode 100644
+index 0000000..fec7b92
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbacollectionimpl.hxx
+@@ -0,0 +1,257 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbacollectionimpl.hxx,v $
++ * $Revision: 1.5 $
++ *
++ * 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 OOVBAAPI_VBA_COLLECTION_IMPL_HXX
++#define OOVBAAPI_VBA_COLLECTION_IMPL_HXX
++
++#include <ooo/vba/XCollection.hpp>
++#include <com/sun/star/container/XEnumerationAccess.hpp>
++#include <com/sun/star/uno/XComponentContext.hpp>
++#include <com/sun/star/script/XDefaultMethod.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
++#include <com/sun/star/container/XNamed.hpp>
++
++#include <cppuhelper/implbase3.hxx>
++#include <cppuhelper/implbase2.hxx>
++#include <cppuhelper/implbase1.hxx>
++
++#include "vbahelper/vbahelper.hxx"
++#include "vbahelper/vbahelperinterface.hxx"
++
++#include <vector>
++
++typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE;
++
++class EnumerationHelperImpl : public EnumerationHelper_BASE
++{
++protected:
++	css::uno::Reference< css::uno::XComponentContext > m_xContext;
++	css::uno::Reference< css::container::XEnumeration > m_xEnumeration;
++public:
++
++	EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ),  m_xEnumeration( xEnumeration ) { }
++	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); }
++};
++
++// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces 
++// only requirement is the object needs to implement XName
++
++
++
++typedef ::cppu::WeakImplHelper3< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess > XNamedCollectionHelper_BASE;
++
++template< typename Ifc1 >
++class XNamedObjectCollectionHelper : public XNamedCollectionHelper_BASE
++{
++public:
++typedef std::vector< css::uno::Reference< Ifc1 > >  XNamedVec;
++private:
++
++	class XNamedEnumerationHelper : public EnumerationHelper_BASE
++	{
++		XNamedVec mXNamedVec;
++		typename XNamedVec::iterator mIt;
++	public:
++	        XNamedEnumerationHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), mIt( mXNamedVec.begin() ) {}
++	
++	        virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException)
++	        {
++			return ( mIt != mXNamedVec.end() );
++	        }
++	
++	        virtual css::uno::Any SAL_CALL nextElement(  ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
++	        {
++	                if ( hasMoreElements() )
++				return css::uno::makeAny( *mIt++ );
++	                throw css::container::NoSuchElementException();
++	        }
++	};
++
++protected:
++	XNamedVec mXNamedVec;
++	typename XNamedVec::iterator cachePos;
++public:
++	XNamedObjectCollectionHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), cachePos(mXNamedVec.begin()) {}
++	// XElementAccess
++	virtual css::uno::Type SAL_CALL getElementType(  ) throw (css::uno::RuntimeException) { return  Ifc1::static_type(0); }
++	virtual ::sal_Bool SAL_CALL hasElements(  ) throw (css::uno::RuntimeException) { return ( mXNamedVec.size() > 0 ); }
++	// XNameAcess 
++	virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
++	{
++		if ( !hasByName(aName) )
++			throw css::container::NoSuchElementException();
++		return css::uno::makeAny( *cachePos );
++	}
++	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (css::uno::RuntimeException)
++	{
++		css::uno::Sequence< rtl::OUString > sNames( mXNamedVec.size() );
++		rtl::OUString* pString = sNames.getArray();
++		typename XNamedVec::iterator it = mXNamedVec.begin();
++		typename XNamedVec::iterator it_end = mXNamedVec.end();
++
++		for ( ; it != it_end; ++it, ++pString )
++		{
++			css::uno::Reference< css::container::XNamed > xName( *it, css::uno::UNO_QUERY_THROW );	
++			*pString = xName->getName();
++		}
++		return sNames;
++	}
++	virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
++	{
++		cachePos = mXNamedVec.begin();
++		typename XNamedVec::iterator it_end = mXNamedVec.end();
++		for ( ; cachePos != it_end; ++cachePos )
++		{
++			css::uno::Reference< css::container::XNamed > xName( *cachePos, css::uno::UNO_QUERY_THROW );	
++			if ( aName.equals( xName->getName() ) )
++				break;
++		}
++		return ( cachePos != it_end );
++	}
++
++	// XElementAccess
++	virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException) { return mXNamedVec.size(); }	
++	virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException )
++	{
++		if ( Index < 0 || Index >= getCount() )
++			throw css::lang::IndexOutOfBoundsException();
++	
++		return css::uno::makeAny( mXNamedVec[ Index ] );
++
++	}
++	// XEnumerationAccess
++	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (css::uno::RuntimeException)
++	{
++		return new XNamedEnumerationHelper( mXNamedVec );
++	}
++};
++
++// including a HelperInterface implementation
++template< typename Ifc1 >
++class ScVbaCollectionBase : public InheritedHelperInterfaceImpl< Ifc1 >
++{
++typedef InheritedHelperInterfaceImpl< Ifc1 > BaseColBase;
++protected:
++	css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess;
++	css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
++
++	virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException)
++	{
++		if ( !m_xNameAccess.is() )
++			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase string index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
++	
++		return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
++	}		
++
++	virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException)
++	{
++		if ( !m_xIndexAccess.is() )
++			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase numeric index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
++		if ( nIndex <= 0 )
++		{
++			throw  css::lang::IndexOutOfBoundsException( 
++				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
++				"index is 0 or negative" ) ), 
++				css::uno::Reference< css::uno::XInterface >() );
++		}
++		// need to adjust for vba index ( for which first element is 1 )
++		return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );		
++	}
++public:
++	ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent,   const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); }
++	//XCollection
++	virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException)
++	{
++		return m_xIndexAccess->getCount();
++	}
++
++	virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw (css::uno::RuntimeException)
++	{
++		if ( Index1.getValueTypeClass() != css::uno::TypeClass_STRING )
++		{
++			sal_Int32 nIndex = 0;
++	
++			if ( ( Index1 >>= nIndex ) != sal_True )
++			{
++				rtl::OUString message;
++				message = rtl::OUString::createFromAscii(
++					"Couldn't convert index to Int32");
++				throw  css::lang::IndexOutOfBoundsException( message,
++					css::uno::Reference< css::uno::XInterface >() );
++			}
++			return 	getItemByIntIndex( nIndex );
++		}
++		rtl::OUString aStringSheet;
++
++		Index1 >>= aStringSheet;
++		return getItemByStringIndex( aStringSheet );	
++	}
++	// XDefaultMethod
++	::rtl::OUString SAL_CALL getDefaultMethodName(  ) throw (css::uno::RuntimeException)
++	{
++		const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
++		return sName;
++	}
++	// XEnumerationAccess
++	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0;	
++
++	// XElementAccess
++	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0;
++	// XElementAccess
++	virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException)
++	{
++		return ( m_xIndexAccess->getCount() > 0 );
++	}
++	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0;
++	
++};
++
++typedef ::cppu::WeakImplHelper1<ov::XCollection> XCollection_InterfacesBASE;
++
++typedef ScVbaCollectionBase< XCollection_InterfacesBASE > CollImplBase1;
++// compatible with the old collections ( pre XHelperInterface base class ) ( some internal objects still use this )
++class ScVbaCollectionBaseImpl : public CollImplBase1
++{
++public:
++	ScVbaCollectionBaseImpl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : CollImplBase1( xParent, xContext, xIndexAccess){}
++
++};
++
++template <typename Ifc> // where Ifc must implement XCollectionTest
++class CollTestImplHelper :  public ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > >
++{
++typedef ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc >  > ImplBase1;
++
++public:
++	CollTestImplHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,  const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : ImplBase1( xParent, xContext, xIndexAccess ) {}
++};
++
++
++#endif //SC_VBA_COLLECTION_IMPL_HXX
+diff --git vbahelper/inc/vbahelper/vbadllapi.h vbahelper/inc/vbahelper/vbadllapi.h
+new file mode 100644
+index 0000000..8d815fc
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbadllapi.h
+@@ -0,0 +1,44 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: svldllapi.h,v $
++ * $Revision: 1.4 $
++ *
++ * 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 INCLUDED_VBADLLAPI_H
++#define INCLUDED_VBADLLAPI_H
++
++#include "sal/types.h"
++
++#if defined(VBAHELPER_DLLIMPLEMENTATION)
++#define VBAHELPER_DLLPUBLIC  SAL_DLLPUBLIC_EXPORT
++#else
++#define VBAHELPER_DLLPUBLIC  SAL_DLLPUBLIC_IMPORT
++#endif
++#define VBAHELPER_DLLPRIVATE SAL_DLLPRIVATE
++
++#endif /* INCLUDED_SVLDLLAPI_H */
++
+diff --git vbahelper/inc/vbahelper/vbadocumentbase.hxx vbahelper/inc/vbahelper/vbadocumentbase.hxx
+new file mode 100644
+index 0000000..985cd25
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbadocumentbase.hxx
+@@ -0,0 +1,73 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 VBA_DOCUMENTBASE_HXX
++#define VBA_DOCUMENTBASE_HXX
++
++#include <com/sun/star/frame/XModel.hpp>
++#include <ooo/vba/XDocumentBase.hpp>
 +#include <vbahelper/vbahelperinterface.hxx>
- 
- class ScModelObj;
- 
-diff --git sc/source/ui/vba/vbaworkbooks.cxx sc/source/ui/vba/vbaworkbooks.cxx
-index 6bb17b5..69e5693 100644
---- sc/source/ui/vba/vbaworkbooks.cxx
-+++ sc/source/ui/vba/vbaworkbooks.cxx
-@@ -56,7 +56,7 @@
- #include "vbaglobals.hxx"
- #include "vbaworkbook.hxx"
- #include "vbaworkbooks.hxx"
--#include "vbahelper.hxx"
-+#include <vbahelper/vbahelper.hxx>
- 
- #include <hash_map>
- #include <osl/file.hxx>
-diff --git sc/source/ui/vba/vbaworkbooks.hxx sc/source/ui/vba/vbaworkbooks.hxx
-index 7c5b421..a42d8a5 100644
---- sc/source/ui/vba/vbaworkbooks.hxx
-+++ sc/source/ui/vba/vbaworkbooks.hxx
-@@ -31,11 +31,11 @@
- #define SC_VBA_WORKBOOKS_HXX
- 
- 
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
- #include <ooo/vba/XGlobals.hpp>
- #include <ooo/vba/excel/XWorkbooks.hpp>
- #include <com/sun/star/container/XEnumerationAccess.hpp>
--#include "vbahelper.hxx"
-+#include "excelvbahelper.hxx"
- 
- 
- class ScModelObj;
-diff --git sc/source/ui/vba/vbaworksheet.cxx sc/source/ui/vba/vbaworksheet.cxx
-index d687610..05ed019 100644
---- sc/source/ui/vba/vbaworksheet.cxx
-+++ sc/source/ui/vba/vbaworksheet.cxx
-@@ -27,7 +27,7 @@
-  * for a copy of the LGPLv3 License.
-  *
-  ************************************************************************/
--#include "helperdecl.hxx"
-+#include <vbahelper/helperdecl.hxx>
- #include <cppuhelper/queryinterface.hxx>
- 
- #include <com/sun/star/beans/XPropertySet.hpp>
-@@ -59,6 +59,7 @@
- #include <com/sun/star/form/FormComponentType.hpp>
- #include <com/sun/star/form/XFormsSupplier.hpp>
- #include <ooo/vba/excel/XlEnableSelection.hpp>
-+#include <ooo/vba/XControlProvider.hpp>
- 
- #include <comphelper/processfactory.hxx>
- 
-@@ -83,7 +84,6 @@
- #include "vbaworksheet.hxx"
- #include "vbachartobjects.hxx"
- #include "vbapivottables.hxx"
--#include "vbacombobox.hxx"
- #include "vbaoleobject.hxx"
- #include "vbaoleobjects.hxx"
- #include "vbashapes.hxx"
-@@ -762,9 +762,11 @@ uno::Any SAL_CALL
- ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
- {
-     uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW );
--    ScVbaControlFactory controlFactory( mxContext, xControlShape, getModel() );
--    uno::Reference< msforms::XControl > xControl( controlFactory.createControl( getModel() ) );
--	return uno::makeAny( xControl );
++
++typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentBase > VbaDocumentBase_BASE;
++
++class VbaDocumentBase : public VbaDocumentBase_BASE
++{
++protected:
++	css::uno::Reference< css::frame::XModel > mxModel;
++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);
++public:
++	VbaDocumentBase( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
++			css::uno::Reference< css::frame::XModel > xModel );
++	VbaDocumentBase( 	css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
++	virtual ~VbaDocumentBase() {}
++
++    // Attributes
++	virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++	virtual ::rtl::OUString SAL_CALL getPath() throw (css::uno::RuntimeException);
++	virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException);
++	virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException);
++
++	// Methods
++	virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges,
++								 const css::uno::Any &aFileName,
++								 const css::uno::Any &bRouteWorkbook ) throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Unprotect( const css::uno::Any &aPassword ) throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Save() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
++    
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif /* VBA_DOCUMENTBASE_HXX */
+diff --git vbahelper/inc/vbahelper/vbaglobalbase.hxx vbahelper/inc/vbahelper/vbaglobalbase.hxx
+new file mode 100644
+index 0000000..43c8286
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbaglobalbase.hxx
+@@ -0,0 +1,53 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbaapplicationbase.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 VBA_GLOBAL_BASE_HXX
++#define VBA_GLOBAL_BASE_HXX
++
++#include "vbahelperinterface.hxx"
++#include <ooo/vba/XGlobalsBase.hpp>
++
++typedef InheritedHelperInterfaceImpl1< ov::XGlobalsBase > Globals_BASE;
++class VbaGlobalsBase : public Globals_BASE
++
++{
++protected:
++
++    bool hasServiceName( const rtl::OUString& serviceName );
++    void init(  const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any& aApplication );
++
++public:
++    VbaGlobalsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
++    virtual ~VbaGlobalsBase(){};
++    // XMultiServiceFactory
++    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException);
++    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException);
++    virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames(  ) throw (css::uno::RuntimeException);
++};
++#endif
+diff --git vbahelper/inc/vbahelper/vbahelper.hxx vbahelper/inc/vbahelper/vbahelper.hxx
+new file mode 100644
+index 0000000..cfc8ee0
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbahelper.hxx
+@@ -0,0 +1,224 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelper.hxx,v $
++ * $Revision: 1.5.32.1 $
++ *
++ * 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 OOVBAAPI_VBA_HELPER_HXX
++#define OOVBAAPI_VBA_HELPER_HXX
++
++#include <com/sun/star/drawing/XShape.hpp>
++#include <com/sun/star/beans/XIntrospectionAccess.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/script/BasicErrorException.hpp>
++#include <com/sun/star/script/XTypeConverter.hpp>
++#include <com/sun/star/lang/IllegalArgumentException.hpp>
++#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/awt/XDevice.hpp>
++#include <basic/sberrors.hxx>
++#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/frame/XModel.hpp>
++#include <sfx2/dispatch.hxx>
++//#include <ooo/vba/msforms/XShape.hpp>
++#include <vcl/pointr.hxx>
++#define VBAHELPER_DLLIMPLEMENTATION
++#include <vbahelper/vbadllapi.h>
++namespace css = ::com::sun::star;
++
++namespace ooo 
++{
++	namespace vba 
++	{
++		template < class T > 
++		css::uno::Reference< T > getXSomethingFromArgs( css::uno::Sequence< css::uno::Any > const & args, sal_Int32 nPos, bool bCanBeNull = true ) throw (css::lang::IllegalArgumentException)
++		{
++			if ( args.getLength() < ( nPos + 1) )
++				throw css::lang::IllegalArgumentException();
++			css::uno::Reference< T > aSomething( args[ nPos ], css::uno::UNO_QUERY );
++			if ( !bCanBeNull && !aSomething.is() )
++				throw css::lang::IllegalArgumentException();
++			return aSomething;
++		}
++        VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell,  const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException);
++        VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell,  const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException);
++        VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException);
++		VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject ) throw (css::uno::RuntimeException);
++		VBAHELPER_DLLPUBLIC css::uno::Reference< css::script::XTypeConverter > getTypeConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
++
++		VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl) ;
++		VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl, css::uno::Sequence< css::beans::PropertyValue >& sProps ) ;
++		VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, USHORT nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON );
++		VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 );
++		VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 );
++		VBAHELPER_DLLPUBLIC css::uno::Any OORGBToXLRGB( const css::uno::Any& );
++		VBAHELPER_DLLPUBLIC css::uno::Any XLRGBToOORGB( const css::uno::Any& );
++		// provide a NULL object that can be passed as variant so that 
++		// the object when passed to IsNull will return true. aNULL 
++		// contains an empty object reference
++		VBAHELPER_DLLPUBLIC const css::uno::Any& aNULL();
++		VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection  );
++		VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges,  SfxViewShell* );
++
++		VBAHELPER_DLLPUBLIC 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 fPoints, sal_Bool bVertical);
++        VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle();
++        VBAHELPER_DLLPUBLIC void setCursorHelper( const Pointer& rPointer, sal_Bool bOverWrite );
++        VBAHELPER_DLLPUBLIC String docMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro );
++
++class VBAHELPER_DLLPUBLIC Millimeter
++{
++//Factor to translate between points and hundredths of millimeters:
++private:
++	static const double factor;
 +    
-+    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 > xControl( xControlProvider->createControl(  xControlShape, getModel() ) );
-+    return uno::makeAny( xControl );
- }
- 
- ::sal_Bool SAL_CALL 
-@@ -947,10 +949,9 @@ ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::A
- 		bSelection = sal_True;
- 
-     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );  
--	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, xModel, bSelection );
-+	PrintOutHelper( getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
- }
- 
--
- namespace worksheet
- {
- namespace sdecl = comphelper::service_decl;
-diff --git sc/source/ui/vba/vbaworksheet.hxx sc/source/ui/vba/vbaworksheet.hxx
-index e70b282..d6637bb 100644
---- sc/source/ui/vba/vbaworksheet.hxx
-+++ sc/source/ui/vba/vbaworksheet.hxx
-@@ -47,7 +47,8 @@
- #include <ooo/vba/excel/XChartObjects.hpp>
- #include <com/sun/star/container/XNamed.hpp>
- 
--#include "vbahelperinterface.hxx"
-+#include <vbahelper/vbahelperinterface.hxx>
-+#include "address.hxx"
- 
- typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheet >  WorksheetImpl_BASE;
- 
-diff --git sc/source/ui/vba/vbaworksheets.cxx sc/source/ui/vba/vbaworksheets.cxx
-index cfc156f..246d21c 100644
---- sc/source/ui/vba/vbaworksheets.cxx
-+++ sc/source/ui/vba/vbaworksheets.cxx
-@@ -295,7 +295,7 @@ ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno::
- 		if ( isSelectedSheets() )
- 			bSelection = sal_True;
- 
--	PrintOutHelper( From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, mxModel, bSelection );
-+	PrintOutHelper( getBestViewShell( mxModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
- }
- 
- uno::Any SAL_CALL 
-diff --git sc/source/ui/vba/vbaworksheets.hxx sc/source/ui/vba/vbaworksheets.hxx
-index a57a86a..164196d 100644
---- sc/source/ui/vba/vbaworksheets.hxx
-+++ sc/source/ui/vba/vbaworksheets.hxx
-@@ -38,7 +38,7 @@
- #include <com/sun/star/uno/XComponentContext.hpp>
- #include <ooo/vba/XGlobals.hpp>
-  
--#include "vbacollectionimpl.hxx"
-+#include <vbahelper/vbacollectionimpl.hxx>
- 
- class ScModelObj;
- 
-diff --git sc/util/makefile.mk sc/util/makefile.mk
-index c88b4ab..13250b9 100644
---- sc/util/makefile.mk
-+++ sc/util/makefile.mk
-@@ -276,6 +276,7 @@ SHL9STDLIBS= \
- 		$(TOOLSLIB) \
- 		$(SALLIB)\
- 		$(BASICLIB)	\
-+		$(VBAHELPERLIB) \
- 		$(SFXLIB)	\
- 		$(SVXLIB)	\
- 		$(SVTOOLLIB)    \
-diff --git scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
-index 447e0e7..bf707af 100644
---- scp2/source/ooo/file_library_ooo.scp
-+++ scp2/source/ooo/file_library_ooo.scp
-@@ -406,7 +406,42 @@ File gid_File_Lib_Vbaobj
-   #endif
- End
- 
-+File gid_File_Lib_Vbaswobj
-+    TXT_FILE_BODY;
-+    Styles = (PACKED,UNO_COMPONENT);
-+    RegistryID = gid_Starregistry_Services_Rdb;
-+    Dir = gid_Dir_Program;
-+  #ifdef UNX
-+    Name = STRING(CONCAT4(libvbaswobj,DLLPOSTFIX,.uno,UNXSUFFIX));
-+  #else
-+    Name = STRING(CONCAT4(vbaswobj,DLLPOSTFIX,.uno,.dll));
-+  #endif
-+End
++	double m_nMillimeter;
++
++public:
++	Millimeter();
++    
++	Millimeter(double mm);
++    
++	void set(double mm);
++	void setInPoints(double points) ;
++	void setInHundredthsOfOneMillimeter(double hmm);
++	double get();
++	double getInHundredthsOfOneMillimeter();
++	double getInPoints();
++	static sal_Int32 getInHundredthsOfOneMillimeter(double points);
++	static double getInPoints(int _hmm);
++};
++
++class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace the ShapeHelper below
++{
++public:
++    virtual ~AbstractGeometryAttributes() {}
++    virtual double getLeft() = 0;
++    virtual void setLeft( double ) = 0;
++    virtual double getTop() = 0;
++    virtual void setTop( double ) = 0;
++    virtual double getHeight() = 0;
++    virtual void setHeight( double ) = 0;
++    virtual double getWidth() = 0;
++    virtual void setWidth( double ) = 0;
++};
++
++namespace msforms {
++    class XShape;
++}
++
++class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeometryAttributes
++{
++public:
++    css::uno::Reference< ooo::vba::msforms::XShape > m_xShape; 
++    ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape );
++    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);
++};
++#define VBA_LEFT "PositionX"
++#define VBA_TOP "PositionY"
++class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes
++{
++
++    css::uno::Reference< css::beans::XPropertySet > mxModel;
++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 ShapeHelper
++{
++protected:
++	css::uno::Reference< css::drawing::XShape > xShape;
++public:
++	ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException );
++    
++	double getHeight();
++
++    	void setHeight(double _fheight) throw ( css::script::BasicErrorException );
++    
++	double getWidth();
++
++	void setWidth(double _fWidth) throw ( css::script::BasicErrorException );
++    
++	double getLeft();
++    
++	void setLeft(double _fLeft);
++
++	double getTop();
++    
++	void setTop(double _fTop);
++};
++
++class VBAHELPER_DLLPUBLIC ContainerUtilities
++{
++
++public: 
++	static rtl::OUString getUniqueName( const css::uno::Sequence< ::rtl::OUString >&  _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator);
++	static rtl::OUString getUniqueName( const css::uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix );
++
++	static sal_Int32 FieldInList( const css::uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString );
++};
++
++// really just a a place holder to ease the porting pain
++class VBAHELPER_DLLPUBLIC DebugHelper
++{
++public:
++	static void exception( const rtl::OUString&  DetailedMessage, const css::uno::Exception& ex,  int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException );
++
++	static void exception( int err,  const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException );
++
++	static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException );
++};
++	} // openoffice
++} // org
++
++namespace ov = ooo::vba;
++
++#ifdef DEBUG
++#  define SC_VBA_FIXME(a) OSL_TRACE( a )
++#  define SC_VBA_STUB() SC_VBA_FIXME(( "%s - stubbed\n", __FUNCTION__ ))
++#else
++#  define SC_VBA_FIXME(a)
++#  define SC_VBA_STUB()
++#endif
++
++#endif
+diff --git vbahelper/inc/vbahelper/vbahelperinterface.hxx vbahelper/inc/vbahelper/vbahelperinterface.hxx
+new file mode 100644
+index 0000000..389a825
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbahelperinterface.hxx
+@@ -0,0 +1,121 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbahelperinterface.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 OOVBAAPI_VBA_HELPERINTERFACE_HXX
++#define OOVBAAPI_VBA_HELPERINTERFACE_HXX
 +
-+File gid_File_Lib_Vbamsforms
-+    TXT_FILE_BODY;
-+    Styles = (PACKED,UNO_COMPONENT);
-+    RegistryID = gid_Starregistry_Services_Rdb;
-+    Dir = gid_Dir_Program;
-+  #ifdef UNX
-+    Name = STRING(CONCAT4(libmsforms,DLLPOSTFIX,.uno,UNXSUFFIX));
-+  #else
-+    Name = STRING(CONCAT4(msforms,DLLPOSTFIX,.uno,.dll));
-+  #endif
-+End
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/XHelperInterface.hpp>
++#include <vbahelper/vbahelper.hxx>
++#include <com/sun/star/container/XNameAccess.hpp>
 +
- #endif // VBA_EXTENSION
-+File gid_File_Lib_Vbahelper
-+    TXT_FILE_BODY;
-+    Styles = (PACKED);
-+    RegistryID = gid_Starregistry_Services_Rdb;
-+    Dir = gid_Dir_Program;
-+  #ifdef UNX
-+    Name = STRING(CONCAT3(libvbahelper,DLLPOSTFIX,UNXSUFFIX));
-+  #else
-+    Name = STRING(CONCAT3(vbahelper,DLLPOSTFIX,.dll));
-+  #endif
-+End
- #endif // ENABLE_VBA
- 
- 
-diff --git solenv/inc/libs.mk solenv/inc/libs.mk
-index f686801..da2b8fc 100644
---- solenv/inc/libs.mk
-+++ solenv/inc/libs.mk
-@@ -192,6 +192,7 @@ SAXLIB=-lsax$(DLLPOSTFIX)
- MAILLIB=-lmail
- DOCMGRLIB=-ldmg$(DLLPOSTFIX)
- BASICLIB=-lsb$(DLLPOSTFIX)
-+VBAHELPERLIB=-lvbahelper$(DLLPOSTFIX)
- DBTOOLSLIB=-ldbtools$(DLLPOSTFIX)
- HM2LIBSH=-lhmwrpdll
- HM2LIBST=-lhmwrap
-@@ -434,6 +435,7 @@ SAXLIB=isax.lib
- MAILLIB=mail.lib
- DOCMGRLIB=docmgr.lib
- BASICLIB=basic.lib
-+VBAHELPERLIB=vbahelper.lib
- TKTLIB=tkt.lib
- SJLIB=sj.lib
- SVXLIB=isvx.lib
-diff --git sw/inc/unocoll.hxx sw/inc/unocoll.hxx
-index 7b4632d..06fe329 100644
---- sw/inc/unocoll.hxx
-+++ sw/inc/unocoll.hxx
-@@ -194,8 +194,10 @@ class SwUnoCollection
- #define SW_SERVICE_CHART2_DATA_PROVIDER                 106
- #define SW_SERVICE_TYPE_FIELDMARK                       107
- #define SW_SERVICE_TYPE_FORMFIELDMARK                   108
-+#define SW_SERVICE_VBAOBJECTPROVIDER                    109
-+#define SW_SERVICE_VBACODENAMEPROVIDER                  110
- 
--#define SW_SERVICE_LAST                 SW_SERVICE_TYPE_FORMFIELDMARK
-+#define SW_SERVICE_LAST                 SW_SERVICE_VBACODENAMEPROVIDER
- 
- #define SW_SERVICE_INVALID			USHRT_MAX
- 
-diff --git sw/prj/build.lst sw/prj/build.lst
-index 1a799f7..428fc91 100644
---- sw/prj/build.lst
-+++ sw/prj/build.lst
-@@ -1,4 +1,4 @@
--sw	sw	:	connectivity OOo:writerperfect OOo:lotuswordpro svx stoc uui NULL
-+sw	sw	:	connectivity OOo:writerperfect OOo:lotuswordpro svx stoc uui vbahelper NULL
- sw	sw										usr1	-	all	sw_mkout NULL
- sw	sw\inc									nmake		-	all	sw_inc NULL
- sw	sw\uiconfig\layout									nmake	-	all	sw_layout NULL
-@@ -33,6 +33,7 @@ sw      sw\source\ui\smartmenu                                          nmake
- sw      sw\source\ui\table                                              nmake   -       all     sw_table sw_inc NULL
- sw	sw\source\ui\uiview						nmake	-	all	sw_uivw sw_sdi sw_inc NULL
- sw	sw\source\ui\uno						nmake	-	all	sw_uiuno sw_sdi sw_inc NULL
-+sw	sw\source\ui\vba						nmake	-	all	sw_vba sw_inc NULL
- sw	sw\source\ui\utlui						nmake	-	all	sw_utlui sw_inc NULL
- sw	sw\source\ui\web						nmake	-	all	sw_web sw_uinc sw_sdi sw_inc NULL
- sw	sw\source\ui\wrtsh						nmake	-	all	sw_wrtsh sw_inc NULL
-diff --git sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocoll.cxx
-index 8ff51f9..c0e5e95 100644
---- sw/source/core/unocore/unocoll.cxx
-+++ sw/source/core/unocore/unocoll.cxx
-@@ -73,7 +73,12 @@
- #include <unochart.hxx>
- 
- #include "docsh.hxx"
--
-+#include <com/sun/star/document/XCodeNameQuery.hpp>
-+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
-+#include <com/sun/star/form/XFormsSupplier.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
-+#include <com/sun/star/script/ModuleType.hpp>
-+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
- using ::rtl::OUString;
- using namespace ::com::sun::star;
- using namespace ::com::sun::star::document;
-@@ -82,6 +87,104 @@ using namespace ::com::sun::star::text;
- using namespace ::com::sun::star::container;
- using namespace ::com::sun::star::lang;
- 
-+class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
++// use this class when you have an a object like
++// interface  XAnInterface which contains XHelperInterface in its inheritance hierarchy
++// interface XAnInterface
++// { 
++//     interface XHelperInterface;
++//     [attribute, string] name;
++// }
++// or
++// interface XAnInterface : XHelperInterface;
++// { 
++//     [attribute, string] name;
++// }
++//
++// then this class can provide a default implementation of XHelperInterface,
++// you can use it like this
++// typedef InheritedHelperInterfaceImpl< XAnInterface > > AnInterfaceImpl_BASE;
++// class AnInterfaceImpl : public AnInterfaceImpl_BASE
++// {
++// public:
++//     AnInterface( const Reference< HelperInterface >& xParent ) : AnInterfaceImpl_BASE( xParent ) {}
++//     // implement XAnInterface methods only, no need to implement the XHelperInterface 
++//     // methods
++//     virtual void setName( const OUString& );  
++//     virtual OUString getName();  
++// }
++//
++const ::rtl::OUString sHelperServiceName( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.HelperServiceBase" ) );
++
++template< typename Ifc1 >
++class InheritedHelperInterfaceImpl : public Ifc1
++{
++protected: 
++	css::uno::WeakReference< ov::XHelperInterface > mxParent;
++	css::uno::Reference< css::uno::XComponentContext > mxContext;
++public:
++	InheritedHelperInterfaceImpl() {}
++	InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {}
++	virtual rtl::OUString& getServiceImplName() = 0;
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames() = 0;
++
++	// XHelperInterface Methods
++	virtual ::sal_Int32 SAL_CALL getCreator() throw (css::script::BasicErrorException, css::uno::RuntimeException)
++	{
++		return 0x53756E4F;
++	}
++	virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return mxParent; }
++	
++	virtual css::uno::Any SAL_CALL Application(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { 
++            // The application could certainly be passed around in the context - seems
++            // to make sense
++            css::uno::Reference< css::container::XNameAccess > xNameAccess( mxContext, css::uno::UNO_QUERY_THROW );
++            return xNameAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application" ) ) );
++	}
++
++
++	// XServiceInfo Methods
++	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (css::uno::RuntimeException) { return getServiceImplName(); }
++	virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) 
++	{ 
++		css::uno::Sequence< rtl::OUString > sServices = getSupportedServiceNames();
++		const rtl::OUString* pStart = sServices.getConstArray();
++		const rtl::OUString* pEnd = pStart + sServices.getLength();
++		for ( ; pStart != pEnd ; ++pStart )
++			if ( (*pStart).equals( ServiceName ) )
++				return sal_True;
++		return sal_False;	
++	}
++	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (css::uno::RuntimeException) 
++	{ 
++		css::uno::Sequence< rtl::OUString > aNames = getServiceNames();;
++		return aNames;
++	}
++ };
++
++template< typename Ifc1 >
++class InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > >
++
++{
++typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base;
++public:
++	InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {}	
++
++};
++#endif
+diff --git vbahelper/inc/vbahelper/vbapropvalue.hxx vbahelper/inc/vbahelper/vbapropvalue.hxx
+new file mode 100644
+index 0000000..c782f5b
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbapropvalue.hxx
+@@ -0,0 +1,60 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbapropvalue.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 SC_VBA_PROPVALULE_HXX
++#define SC_VBA_PROPVALULE_HXX
++#include <ooo/vba/XPropValue.hpp>
++#include <cppuhelper/implbase1.hxx>
++
++#include <vbahelper/vbahelper.hxx>
++
++typedef ::cppu::WeakImplHelper1< ov::XPropValue > PropValueImpl_BASE;
++
++class PropListener 
 +{
-+    SwDocShell* mpDocShell;
-+    rtl::OUString msThisDocumentCodeName;
 +public:
-+    SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
-+        // XCodeNameQuery
-+    rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
-+    {
-+        // Initialise the code name
-+        if ( msThisDocumentCodeName.getLength() == 0 )
-+        {
-+            try
-+            {
-+                uno::Reference< beans::XPropertySet > xProps( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
-+                uno::Reference< container::XNameAccess > xLibContainer( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW );
-+                uno::Reference< container::XNameAccess > xStandard( xLibContainer->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) ), uno::UNO_QUERY_THROW );
-+                uno::Sequence< rtl::OUString > sModuleNames = xStandard->getElementNames();
-+                for ( sal_Int32 i=0; i < sModuleNames.getLength(); ++i )
-+                {
-+                    script::ModuleInfo mInfo;
-+                    if ( xStandard->getByName( sModuleNames[ i ] ) >>= mInfo )
-+                    {
-+                        if ( mInfo.ModuleType == script::ModuleType::Document )
-+                        {
-+                            msThisDocumentCodeName = sModuleNames[ i ];
-+                            break;
-+                        }
-+                    } 
-+                }
-+		
-+            }
-+            catch( uno::Exception& )
-+            {
-+            }
-+        }
-+        rtl::OUString sCodeName;
-+        if ( mpDocShell )
-+        {
-+            OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
-+            // need to find the page ( and index )  for this control
-+            uno::Reference< drawing::XDrawPageSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
-+            uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
-+            sal_Int32 nLen = xIndex->getCount();
-+            bool bMatched = false;
-+            uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
-+                try
-+                {
-+                    uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex, uno::UNO_QUERY_THROW );
-+                    uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
-+                    // get the www-standard container
-+                    uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
-+                    sal_Int32 nCntrls = xFormControls->getCount();
-+                    for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
-+                    {
-+                        uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
-+                        bMatched = ( xControl == xIf );
-+                        if ( bMatched )
-+                        {
-+                            sCodeName = msThisDocumentCodeName;
-+                            break;
-+                        }
-+                    }
-+                }
-+                catch( uno::Exception& ) {}
-+        }
-+        // Probably should throw here ( if !bMatched )
-+        return sCodeName;
-+    }
++    virtual void setValueEvent( const css::uno::Any& value ) = 0;
++    virtual css::uno::Any getValueEvent() = 0; 
 +};
 +
-+class SwVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
++
++class ScVbaPropValue : public PropValueImpl_BASE 
 +{
-+    SwDocShell* mpDocShell;
++    PropListener* m_pListener;
 +public:
-+    SwVbaObjectForCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell )
-+    {
-+    }
++    ScVbaPropValue( PropListener* pListener );
 +
-+    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
-+    {
-+        return sal_False;
-+    }
-+    ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
-+    {
-+        return uno::Any();
-+    }
-+    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException)
-+    {
-+        uno::Sequence< rtl::OUString > aNames;
-+        return aNames;
-+    }
-+    // XElemenAccess
-+    virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
-+    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; }
++    // 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);
++
++    rtl::OUString SAL_CALL getDefaultPropertyName() throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +
 +};
++#endif //SC_VBA_PROPVALULE_HXX
+diff --git vbahelper/inc/vbahelper/vbawindowbase.hxx vbahelper/inc/vbahelper/vbawindowbase.hxx
+new file mode 100644
+index 0000000..ad35a98
+--- /dev/null
++++ vbahelper/inc/vbahelper/vbawindowbase.hxx
+@@ -0,0 +1,66 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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 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>
 +
- /******************************************************************************
-  *
-  ******************************************************************************/
-@@ -203,6 +306,8 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
-     { "com.sun.star.text.Fieldmark",                          SW_SERVICE_TYPE_FIELDMARK },
-     { "com.sun.star.text.FormFieldmark",                      SW_SERVICE_TYPE_FORMFIELDMARK },
-     { "com.sun.star.chart2.data.DataProvider",                SW_SERVICE_CHART2_DATA_PROVIDER },
-+    { "ooo.vba.VBAObjectModuleObjectProvider",                SW_SERVICE_VBAOBJECTPROVIDER },
-+    { "ooo.vba.VBACodeNameProvider",                          SW_SERVICE_VBACODENAMEPROVIDER },
- 
-     // case-correct versions of the service names (see #i67811)
-     { CSS_TEXT_TEXTFIELD_DATE_TIME,                   SW_SERVICE_FIELDTYPE_DATETIME },
-@@ -383,6 +488,18 @@ uno::Reference< uno::XInterface >   SwXServiceProvider::MakeInstance(sal_uInt16
-             xRet =  (cppu::OWeakObject*)pFieldmark;
-         }
-         break;
-+		case  SW_SERVICE_VBAOBJECTPROVIDER :
-+		{
-+			SwVbaObjectForCodeNameProvider* pObjProv = new SwVbaObjectForCodeNameProvider( pDoc->GetDocShell() );
-+			xRet =  (cppu::OWeakObject*)pObjProv;
-+		}
-+		break;
-+		case  SW_SERVICE_VBACODENAMEPROVIDER :
-+		{
-+			SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() );
-+			xRet =  (cppu::OWeakObject*)pObjProv;
-+		}
-+		break;
-         case  SW_SERVICE_TYPE_FOOTNOTE :
-             xRet =  (cppu::OWeakObject*)new SwXFootnote(sal_False);
-         break;
-diff --git sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.cxx
-index c292f2b..5055206 100644
---- sw/source/filter/ww8/ww8par.cxx
-+++ sw/source/filter/ww8/ww8par.cxx
-@@ -140,6 +140,8 @@
- #include <svtools/itemiter.hxx>  //SfxItemIter
- 
- #include <stdio.h>
-+#include <comphelper/processfactory.hxx>
-+#include <basic/basmgr.hxx>
- 
- #ifdef DEBUG
- #include <iostream>
-@@ -4003,7 +4005,38 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
-     }
-     else //ordinary case
-     {
-+        if (mbNewDoc && pStg && !pGloss) /*meaningless for a glossary, cmc*/
-+        {
-+            const SvtFilterOptions* pVBAFlags = SvtFilterOptions::Get();
-+            maTracer.EnterEnvironment(sw::log::eMacros);
-+            // Create and insert Excel vba Globals
-+            uno::Reference < uno::XComponentContext > xCtx;
-+            uno::Reference < beans::XPropertySet > xProps(
-+            ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+            xCtx.set( xProps->getPropertyValue( rtl::OUString(
-+                RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))),
-+                uno::UNO_QUERY_THROW );
-+            uno::Any aGlobs = uno::makeAny( xCtx->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/ooo.vba.word.theGlobals") ) );
-+            mpDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
-+            
-+            SvxImportMSVBasic aVBasic(*mpDocShell, *pStg,
-+                            pVBAFlags->IsLoadWordBasicCode(),
-+                            pVBAFlags->IsLoadWordBasicStorage() );
-+            String s1(CREATE_CONST_ASC("Macros"));
-+            String s2(CREATE_CONST_ASC("VBA"));
-+            int nRet = aVBasic.Import( s1, s2, ! pVBAFlags->IsLoadWordBasicCode() );
-+            if( 2 & nRet )
-+            {
-+                maTracer.Log(sw::log::eContainsVisualBasic);
-+                rDoc.SetContainsMSVBasic(true);
-+            }
++#include <vbahelper/vbahelperinterface.hxx>
 +
-+            StoreMacroCmds();
++typedef InheritedHelperInterfaceImpl1<ov::XWindowBase > WindowBaseImpl_BASE;
 +
-+            maTracer.LeaveEnvironment(sw::log::eMacros);
-+        }
-         ReadText(0, pWwFib->ccpText, MAN_MAINTEXT);
++class 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 );
 +
-     }
- 
-     ::SetProgressState(nProgress, mpDocShell);    // Update
-@@ -4077,26 +4110,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
-             eMode |= nsRedlineMode_t::REDLINE_ON;
-         if( pWDop->fRMView )
-             eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
--        if (pStg && !pGloss) /*meaningless for a glossary, cmc*/
--        {
--            const SvtFilterOptions* pVBAFlags = SvtFilterOptions::Get();
--            maTracer.EnterEnvironment(sw::log::eMacros);
--            SvxImportMSVBasic aVBasic(*mpDocShell, *pStg,
--                            pVBAFlags->IsLoadWordBasicCode(),
--                            pVBAFlags->IsLoadWordBasicStorage() );
--            String s1(CREATE_CONST_ASC("Macros"));
--            String s2(CREATE_CONST_ASC("VBA"));
--            int nRet = aVBasic.Import( s1, s2 );
--            if( 2 & nRet )
--            {
--                maTracer.Log(sw::log::eContainsVisualBasic);
--                rDoc.SetContainsMSVBasic(true);
--            }
--
--            StoreMacroCmds();
--
--            maTracer.LeaveEnvironment(sw::log::eMacros);
--        }
-     }
- 
-     maInsertedTables.DelAndMakeTblFrms();
-diff --git sw/source/ui/vba/makefile.mk sw/source/ui/vba/makefile.mk
++	// XWindowBase
++    virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ;
++    virtual void SAL_CALL setHeight( sal_Int32 _height ) throw (css::uno::RuntimeException) ;
++    virtual sal_Int32 SAL_CALL getLeft() throw (css::uno::RuntimeException) ;
++    virtual void SAL_CALL setLeft( sal_Int32 _left ) throw (css::uno::RuntimeException) ;
++    virtual sal_Int32 SAL_CALL getTop() throw (css::uno::RuntimeException) ;
++    virtual void SAL_CALL setTop( sal_Int32 _top ) throw (css::uno::RuntimeException) ;
++    virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
++    virtual sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException) ;
++    virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException) ;
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif //VBA_WINDOWBASE_HXX
+diff --git vbahelper/prj/build.lst vbahelper/prj/build.lst
+new file mode 100644
+index 0000000..a38a6dc
+--- /dev/null
++++ vbahelper/prj/build.lst
+@@ -0,0 +1,6 @@
++vba	vbahelper	:	oovbaapi basic sfx2 svx cppuhelper vcl comphelper svtools tools sal NULL
++vba	vbahelper									usr1	-	all	  vba_mkout NULL
++#vba	vbahelper\inc								nmake	-	all	vba_inc NULL
++vba	vbahelper\source\vbahelper                        nmake	-	all	vba_vbahelper NULL
++vba	vbahelper\source\msforms                        nmake	-	all	vba_msforms NULL
++vba	vbahelper\util								nmake	-	all	vba_util vba_vbahelper vba_msforms NULL
+diff --git vbahelper/prj/d.lst vbahelper/prj/d.lst
 new file mode 100644
-index 0000000..96b7c8b
+index 0000000..7590625
 --- /dev/null
-+++ sw/source/ui/vba/makefile.mk
-@@ -0,0 +1,69 @@
++++ vbahelper/prj/d.lst
+@@ -0,0 +1,17 @@
++..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%
++..\%__SRC%\slb\vbahelper.lib %_DEST%\lib%_EXT%\vbahelper.lib
++..\%__SRC%\lib\vbahelp*.* %_DEST%\lib%_EXT%\vba*.*
++..\%__SRC%\bin\vbahelper*.* %_DEST%\bin%_EXT%\vbahelper*.*
++..\%__SRC%\bin\msforms*.* %_DEST%\bin%_EXT%\msforms*.*
++
++mkdir: %_DEST%\inc%_EXT%\basic
++..\inc\vbahelper\vbacollectionimpl.hxx %_DEST%\inc%_EXT%\vbahelper\vbacollectionimpl.hxx
++..\inc\vbahelper\vbahelper.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelper.hxx
++..\inc\vbahelper\helperdecl.hxx %_DEST%\inc%_EXT%\vbahelper\helperdecl.hxx
++..\inc\vbahelper\vbahelperinterface.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelperinterface.hxx
++..\inc\vbahelper\vbaapplicationbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaapplicationbase.hxx
++..\inc\vbahelper\vbadllapi.h %_DEST%\inc%_EXT%\vbahelper\vbadllapi.h
++..\inc\vbahelper\vbawindowbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbawindowbase.hxx
++..\inc\vbahelper\vbadocumentbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbadocumentbase.hxx
++..\inc\vbahelper\vbapropvalue.hxx %_DEST%\inc%_EXT%\vbahelper\vbapropvalue.hxx
++..\inc\vbahelper\vbaglobalbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaglobalbase.hxx
+diff --git vbahelper/source/msforms/makefile.mk vbahelper/source/msforms/makefile.mk
+new file mode 100644
+index 0000000..ad5e7b4
+--- /dev/null
++++ vbahelper/source/msforms/makefile.mk
+@@ -0,0 +1,78 @@
 +#*************************************************************************
 +#
 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -8954,7 +22736,7 @@
 +#
 +# $RCSfile: makefile.mk,v $
 +#
-+# $Revision: 1.6 $
++# $Revision: 1.45 $
 +#
 +# This file is part of OpenOffice.org.
 +#
@@ -8975,34 +22757,43 @@
 +#
 +#*************************************************************************
 +
-+PRJ=..$/..$/..
++PRJ=..$/..
++PRJNAME=vbahelper
++TARGET=msforms
 +
-+PRJNAME=sw
-+TARGET=vbaswobj
-+ENABLE_EXCEPTIONS=TRUE
++ENABLE_EXCEPTIONS := TRUE
 +
 +# --- Settings -----------------------------------------------------
 +
 +.INCLUDE :  settings.mk
-+DLLPRE =
 +
-+.IF "$(ENABLE_VBA)"!="YES"
-+dummy:
-+        @echo "not building vba..."
-+.ENDIF
-+ 
-+INCPRE=$(INCCOM)$/$(TARGET)
-+CDEFS+=-DVBA_OOBUILD_HACK
-+# ------------------------------------------------------------------
++SLOFILES=\
++    $(SLO)$/vbacontrol.obj \
++    $(SLO)$/vbacontrols.obj \
++    $(SLO)$/vbabutton.obj \
++    $(SLO)$/vbacombobox.obj \
++    $(SLO)$/vbalabel.obj \
++    $(SLO)$/vbatextbox.obj \
++    $(SLO)$/vbaradiobutton.obj \
++    $(SLO)$/vbalistbox.obj \
++    $(SLO)$/vbatogglebutton.obj \
++    $(SLO)$/vbacheckbox.obj \
++    $(SLO)$/vbaframe.obj \
++    $(SLO)$/vbascrollbar.obj \
++    $(SLO)$/vbaprogressbar.obj \
++    $(SLO)$/vbamultipage.obj \
++    $(SLO)$/vbalistcontrolhelper.obj \
++    $(SLO)$/vbaspinbutton.obj \
++    $(SLO)$/vbaimage.obj \
++    $(SLO)$/vbapages.obj \
++    $(SLO)$/vbauserform.obj \
++    $(SLO)$/service.obj \
 +
-+SLOFILES= \
-+		$(SLO)$/vbaglobals.obj \
-+		$(SLO)$/vbaapplication.obj \
-+				$(SLO)$/service.obj \
++# #FIXME vbapropvalue needs to move to vbahelper
 +
-+# --- Targets ------------------------------------------------------
++# --- Targets -------------------------------------------------------
 +
-+.INCLUDE :	target.mk
++.INCLUDE :  target.mk
 +
 +ALLTAR : \
 +        $(MISC)$/$(TARGET).don \
@@ -9013,12 +22804,12 @@
 +        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
 +        echo $@
 +
-diff --git sw/source/ui/vba/service.cxx sw/source/ui/vba/service.cxx
+diff --git vbahelper/source/msforms/service.cxx vbahelper/source/msforms/service.cxx
 new file mode 100644
-index 0000000..c3dc180
+index 0000000..3215944
 --- /dev/null
-+++ sw/source/ui/vba/service.cxx
-@@ -0,0 +1,96 @@
++++ vbahelper/source/msforms/service.cxx
+@@ -0,0 +1,83 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9061,236 +22852,53 @@
 +
 +namespace sdecl = comphelper::service_decl;
 +
-+namespace globals
++// reference service helper(s)
++namespace  controlprovider
 +{
 +extern sdecl::ServiceDecl const serviceDecl;
-+}
-+
-+extern "C"
-+{
-+    void SAL_CALL component_getImplementationEnvironment( 
-+        const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
-+    {
-+		OSL_TRACE("In component_getImplementationEnv");
-+        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
-+    }
-+
-+    sal_Bool SAL_CALL component_writeInfo( 
-+        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
-+    {
-+		OSL_TRACE("In component_writeInfo");
-+
-+	// Component registration
-+        if ( component_writeInfoHelper( pServiceManager, pRegistryKey, 
-+		globals::serviceDecl ) )
-+		{
-+			// Singleton registration
-+			try
-+			{
-+				registry::XRegistryKey * pKey =
-+					reinterpret_cast< registry::XRegistryKey * >(pRegistryKey);
-+
-+				Reference< registry::XRegistryKey >xKey = pKey->createKey(
-+					rtl::OUString::createFromAscii( ("ooo.vba.sw.Globals/UNO/SINGLETONS/ooo.vba.word.theGlobals") ) );
-+				xKey->setStringValue( ::rtl::OUString::createFromAscii( 
-+					("ooo.vba.word.Globals") ) );
-+				return sal_True;
-+			}
-+			catch( uno::Exception& /*e*/ )
-+			{
-+				//recomp & friends will detect false returned and fail
-+			}
-+		}
-+		return sal_False;
-+    }
-+
-+    void * SAL_CALL component_getFactory( 
-+        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
-+        registry::XRegistryKey * pRegistryKey )
-+    {
-+		OSL_TRACE("In component_getFactory for %s", pImplName );
-+	void* pRet =  component_getFactoryHelper(
-+        	pImplName, pServiceManager, pRegistryKey, globals::serviceDecl );
-+	OSL_TRACE("Ret is 0x%x", pRet);
-+	return pRet;
-+    }
-+}
-diff --git sw/source/ui/vba/vbaapplication.cxx sw/source/ui/vba/vbaapplication.cxx
-new file mode 100644
-index 0000000..3fd0635
---- /dev/null
-+++ sw/source/ui/vba/vbaapplication.cxx
-@@ -0,0 +1,100 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: vbaapplication.cxx,v $
-+ * $Revision: 1.7 $
-+ *
-+ * 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 <stdio.h>
-+
-+
-+#include "vbaapplication.hxx"
-+#include <osl/file.hxx>
-+
-+using namespace ::ooo;
-+using namespace ::com::sun::star;
-+
-+using ::com::sun::star::uno::Reference;
-+using ::com::sun::star::uno::UNO_QUERY_THROW;
-+using ::com::sun::star::uno::UNO_QUERY;
-+using ::rtl::OUString;
-+
-+// Enable our own join detection for Intersection and Union
-+// should be more efficient than using ScRangeList::Join ( because
-+// we already are testing the same things )
-+
-+#define OWN_JOIN 1
-+
-+// #TODO is this defined somewhere else?
-+#if ( defined UNX ) || ( defined OS2 ) //unix
-+#define FILE_PATH_SEPERATOR "/"
-+#else // windows
-+#define FILE_PATH_SEPERATOR "\\"
-+#endif 
-+
-+#define EXCELVERSION "11.0"
-+
-+uno::Any sbxToUnoValue( SbxVariable* pVar );
-+
-+SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( uno::Reference< vba::XHelperInterface >(), xContext )
-+{
-+    OSL_TRACE("SwVbaApplication::SwVbaApplication");
-+}
-+
-+SwVbaApplication::~SwVbaApplication()
-+{
-+}
-+	
-+
-+void SAL_CALL
-+SwVbaApplication::DoEvents() throw ( uno::RuntimeException )
-+{
-+}
-+
-+rtl::OUString& 
-+SwVbaApplication::getServiceImplName()
-+{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication") );
-+	return sImplName;
-+}
-+
-+rtl::OUString SAL_CALL
-+SwVbaApplication::getName() throw (uno::RuntimeException)
-+{
-+        static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) );
-+        return appName;
-+}
-+
-+uno::Sequence< rtl::OUString > 
-+SwVbaApplication::getServiceNames()
-+{
-+	static uno::Sequence< rtl::OUString > aServiceNames;
-+	if ( aServiceNames.getLength() == 0 )
-+	{
-+		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) );
-+	}
-+	return aServiceNames;
-+}
-diff --git sw/source/ui/vba/vbaapplication.hxx sw/source/ui/vba/vbaapplication.hxx
-new file mode 100644
-index 0000000..f553aff
---- /dev/null
-+++ sw/source/ui/vba/vbaapplication.hxx
-@@ -0,0 +1,58 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: vbaapplication.hxx,v $
-+ * $Revision: 1.4 $
-+ *
-+ * 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 SW_VBA_APPLICATION_HXX
-+#define SW_VBA_APPLICATION_HXX
-+
-+
-+#include <ooo/vba/word/XApplication.hpp>
-+
-+#include <vbahelper/vbahelperinterface.hxx>
++}
 +
-+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XApplication > SwVbaApplication_BASE;
++namespace  userform
++{
++extern sdecl::ServiceDecl const serviceDecl;
++}
 +
-+class SwVbaApplication : public SwVbaApplication_BASE
++extern "C"
 +{
-+private:
-+public:
-+	SwVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext );
-+	virtual ~SwVbaApplication();
++    void SAL_CALL component_getImplementationEnvironment( 
++        const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
++    {
++		OSL_TRACE("In component_getImplementationEnv");
++        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
++    }
 +
-+	// XHelperInterface ( parent is itself )
-+	virtual css::uno::Reference< ooo::vba::XHelperInterface > SAL_CALL getParent(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return this; }
++    sal_Bool SAL_CALL component_writeInfo( 
++        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
++    {
++		OSL_TRACE("In component_writeInfo");
 +
-+	// XApplication
-+	
-+	virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
-+	virtual void SAL_CALL DoEvents() throw (css::uno::RuntimeException);
-+	// XHelperInterface
-+	virtual rtl::OUString& getServiceImplName();
-+	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+};
-+#endif /* SW_VBA_APPLICATION_HXX */
-diff --git sw/source/ui/vba/vbaglobals.cxx sw/source/ui/vba/vbaglobals.cxx
++	// Component registration
++         return component_writeInfoHelper( pServiceManager, pRegistryKey, 
++		controlprovider::serviceDecl, userform::serviceDecl );
++    }
++
++    void * SAL_CALL component_getFactory( 
++        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
++        registry::XRegistryKey * pRegistryKey )
++    {
++		OSL_TRACE("In component_getFactory for %s", pImplName );
++	void* pRet =  component_getFactoryHelper(
++        	pImplName, pServiceManager, pRegistryKey, controlprovider::serviceDecl, userform::serviceDecl );
++	OSL_TRACE("Ret is 0x%x", pRet);
++	return pRet;
++    }
++}
+diff --git vbahelper/source/msforms/vbabutton.cxx vbahelper/source/msforms/vbabutton.cxx
 new file mode 100644
-index 0000000..df7d6d9
+index 0000000..0e4d749
 --- /dev/null
-+++ sw/source/ui/vba/vbaglobals.cxx
-@@ -0,0 +1,109 @@
++++ vbahelper/source/msforms/vbabutton.cxx
+@@ -0,0 +1,74 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9299,8 +22907,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbaglobals.cxx,v $
-+ * $Revision: 1.4 $
++ * $RCSfile: vbabutton.cxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -9320,92 +22928,57 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include <vbahelper/helperdecl.hxx>
-+#include "vbaglobals.hxx"
-+
-+#include <comphelper/unwrapargs.hxx>
-+
-+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-+#include <com/sun/star/beans/XPropertySet.hpp>
-+
-+#include <cppuhelper/bootstrap.hxx>
-+#include "vbaapplication.hxx"
-+using namespace ::com::sun::star;
-+using namespace ::com::sun::star::uno;
-+using namespace ::ooo::vba;
-+
-+
++#include "vbabutton.hxx"
++#include <vector>
 +
-+// =============================================================================
-+// SwVbaGlobals
-+// =============================================================================
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+SwVbaGlobals::SwVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext )
-+        :m_xContext( rxContext )
-+{
-+	OSL_TRACE("SwVbaGlobals::SwVbaGlobals()");
-+	mxApplication = uno::Reference< word::XApplication > ( new SwVbaApplication( m_xContext) );
-+}
 +
-+SwVbaGlobals::~SwVbaGlobals()
++const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++ScVbaButton::ScVbaButton( 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 ) : ButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
-+	OSL_TRACE("SwVbaGlobals::~SwVbaGlobals");
 +}
 +
-+// Will throw if singleton can't be accessed 
-+uno::Reference< word::XGlobals >
-+SwVbaGlobals::getGlobalsImpl( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException )
++// Attributes
++rtl::OUString SAL_CALL 
++ScVbaButton::getCaption() throw (css::uno::RuntimeException)
 +{
-+	uno::Reference< XGlobals > xGlobals( 
-+		xContext->getValueByName( ::rtl::OUString::createFromAscii( 
-+			"/singletons/ooo.vba.word.theGlobals") ), uno::UNO_QUERY);
-+
-+	if ( !xGlobals.is() )
-+	{
-+		throw uno::RuntimeException(
-+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": Couldn't access Globals" ) ),
-+                    uno::Reference< XInterface >() );
-+	}
-+	return xGlobals;
++    rtl::OUString Label;
++    m_xProps->getPropertyValue( LABEL ) >>= Label;
++    return Label;
 +}
 +
-+// =============================================================================
-+// XGlobals
-+// =============================================================================
-+uno::Reference<word::XApplication >
-+SwVbaGlobals::getApplication() throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+	OSL_TRACE("In SwVbaGlobals::getApplication");	
-+    return mxApplication;
++    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
 +}
 +
-+::uno::Sequence< ::uno::Any > SAL_CALL
-+SwVbaGlobals::getGlobals(  ) throw (::uno::RuntimeException)
++rtl::OUString& 
++ScVbaButton::getServiceImplName()
 +{
-+	sal_uInt32 nMax = 0;
-+	uno::Sequence< uno::Any > maGlobals(4);
-+	maGlobals[ nMax++ ] <<= SwVbaGlobals::getGlobalsImpl(m_xContext);
-+	maGlobals[ nMax++ ] <<= mxApplication;
-+	maGlobals.realloc( nMax );
-+	return maGlobals;
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaButton") );
++	return sImplName;
 +}
 +
-+namespace globals
++uno::Sequence< rtl::OUString > 
++ScVbaButton::getServiceNames()
 +{
-+namespace sdecl = comphelper::service_decl;
-+sdecl::class_<SwVbaGlobals, sdecl::with_args<false> > serviceImpl;
-+extern sdecl::ServiceDecl const serviceDecl(
-+    serviceImpl,
-+    "SwVbaGlobals",
-+    "ooo.vba.word.Globals" );
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Button" ) );
++	}
++	return aServiceNames;
 +}
-+
-diff --git sw/source/ui/vba/vbaglobals.hxx sw/source/ui/vba/vbaglobals.hxx
+diff --git vbahelper/source/msforms/vbabutton.hxx vbahelper/source/msforms/vbabutton.hxx
 new file mode 100644
-index 0000000..b8a2033
+index 0000000..818f245
 --- /dev/null
-+++ sw/source/ui/vba/vbaglobals.hxx
-@@ -0,0 +1,69 @@
++++ vbahelper/source/msforms/vbabutton.hxx
+@@ -0,0 +1,51 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9414,8 +22987,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbaglobals.hxx,v $
-+ * $Revision: 1.4 $
++ * $RCSfile: vbabutton.hxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -9435,170 +23008,219 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SW_VBA_GLOBALS_HXX
-+#define SW_VBA_GLOBALS_HXX
-+
-+#include <com/sun/star/lang/XServiceInfo.hpp>
-+#include <com/sun/star/lang/XInitialization.hpp>
-+#include <com/sun/star/uno/XComponentContext.hpp>
-+#include <ooo/vba/word/XGlobals.hpp>
-+#include <ooo/vba/word/XApplication.hpp>
-+
++#ifndef SC_VBA_BUTTON_HXX
++#define SC_VBA_BUTTON_HXX
 +#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XButton.hpp>
++
++#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
 +
-+    // =============================================================================
-+    // class SwVbaGlobals
-+    // =============================================================================
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
 +
-+    typedef ::cppu::WeakImplHelper1<    
-+        ooo::vba::word::XGlobals > SwVbaGlobals_BASE;
++class ScVbaButton : public ButtonImpl_BASE
++{
++public:
++    ScVbaButton( 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 rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif //SC_VBA_BUTTON_HXX
+diff --git vbahelper/source/msforms/vbacheckbox.cxx vbahelper/source/msforms/vbacheckbox.cxx
+new file mode 100644
+index 0000000..3a6c5d9
+--- /dev/null
++++ vbahelper/source/msforms/vbacheckbox.cxx
+@@ -0,0 +1,112 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "vbacheckbox.hxx"
++#include <vbahelper/helperdecl.hxx>
++#include <vector>
 +
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+    class SwVbaGlobals : public SwVbaGlobals_BASE
-+    {
-+    private:
-+            css::uno::Reference< css::uno::XComponentContext > m_xContext;
-+            css::uno::Reference< ooo::vba::word::XApplication > mxApplication;
-+    public:
-+	
-+        SwVbaGlobals(
-+            css::uno::Reference< css::uno::XComponentContext >const& rxContext );
-+        virtual ~SwVbaGlobals();
 +
-+		static 	css::uno::Reference< ooo::vba::word::XGlobals > getGlobalsImpl(const css::uno::Reference< css::uno::XComponentContext >& ) throw (css::uno::RuntimeException);
++const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
++ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++{
++}
 +
-+        // XGlobals
-+        virtual css::uno::Reference<
-+                        ooo::vba::word::XApplication > SAL_CALL getApplication()
-+                        throw (css::uno::RuntimeException);
-+	virtual css::uno::Sequence< css::uno::Any > SAL_CALL getGlobals(  ) throw (css::uno::RuntimeException);
-+    };
-+#endif /* SW_VBA_GLOBALS_HXX */ 
-diff --git sw/util/makefile.mk sw/util/makefile.mk
-index ef9b141..f3a33ba 100644
---- sw/util/makefile.mk
-+++ sw/util/makefile.mk
-@@ -296,6 +296,34 @@ LIB3OBJFILES = \
-         $(SLO)$/mmpreparemergepage.obj \
-         $(SLO)$/selectdbtabledialog.obj
- 
-+#target vba
-+TARGET_VBA=vbaswobj
-+SHL4TARGET=$(TARGET_VBA)$(DLLPOSTFIX).uno
-+SHL4IMPLIB=     i$(TARGET_VBA)
++// Attributes
++rtl::OUString SAL_CALL 
++ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
++{
++    rtl::OUString Label;
++    m_xProps->getPropertyValue( LABEL ) >>= Label;
++    return Label;
++}
 +
-+SHL4VERSIONMAP=$(TARGET_VBA).map
-+SHL4DEF=$(MISC)$/$(SHL4TARGET).def
-+DEF4NAME=$(SHL4TARGET)
-+SHL4STDLIBS= \
-+                $(CPPUHELPERLIB) \
-+                $(VCLLIB) \
-+                $(CPPULIB) \
-+                $(COMPHELPERLIB) \
-+                $(SVLIB) \
-+                $(TOOLSLIB) \
-+                $(SALLIB)\
-+                $(BASICLIB)     \
-+                $(SFXLIB)       \
-+                $(SVXLIB)       \
-+                $(SVTOOLLIB)    \
-+                $(SVLLIB) \
-+        $(VCLLIB) \
-+        $(TKLIB) \
++void SAL_CALL 
++ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++{
++    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++}
 +
-+SHL4DEPN=$(SHL1TARGETN)
-+SHL4LIBS=$(SLB)$/$(TARGET_VBA).lib
++uno::Any SAL_CALL 
++ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
++{
++    sal_Int16 nValue = -1;
++    m_xProps->getPropertyValue( STATE ) >>= nValue;
++    if( nValue != 0 )
++        nValue = -1;
++//    return uno::makeAny( nValue ); 
++// I must be missing something MSO says value should be -1 if selected, 0 if not
++// selected
++    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
++}
 +
++void SAL_CALL 
++ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
++{
++    sal_Int16 nValue = 0;
++    sal_Bool bValue = false;
++    if( _value >>= nValue )
++    {
++        if( nValue == -1)
++            nValue = 1;
++    }
++    else if ( _value >>= bValue )
++    {
++        if ( bValue )
++            nValue = 1;
++    }
++    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
++}
++rtl::OUString& 
++ScVbaCheckbox::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
++	return sImplName;
++}
 +
- .IF "$(GUI)$(COM)" == "WNTMSC"
- .IF "$(ENABLE_PCH)" != "" && ( "$(PRJNAME)"!="sw" || "$(BUILD_SPECIAL)"!="TRUE" )
- #target sw
-diff --git sw/util/vbaswobj.map sw/util/vbaswobj.map
-new file mode 100644
-index 0000000..832e82c
---- /dev/null
-+++ sw/util/vbaswobj.map
-@@ -0,0 +1,9 @@
-+OOO_1.1 {
-+	global:
-+		component_getImplementationEnvironment;
-+		component_getFactory;
-+		component_writeInfo;
++uno::Sequence< rtl::OUString > 
++ScVbaCheckbox::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
++	}
++	return aServiceNames;
++}
 +
-+	local:
-+		*;
-+};
-diff --git vbahelper/inc/vbahelper/helperdecl.hxx vbahelper/inc/vbahelper/helperdecl.hxx
+diff --git vbahelper/source/msforms/vbacheckbox.hxx vbahelper/source/msforms/vbacheckbox.hxx
 new file mode 100644
-index 0000000..7a0b495
+index 0000000..f3374db
 --- /dev/null
-+++ vbahelper/inc/vbahelper/helperdecl.hxx
-@@ -0,0 +1,58 @@
++++ vbahelper/source/msforms/vbacheckbox.hxx
+@@ -0,0 +1,61 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: helperdecl.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef OOVBAAPI_SERV_DECL
-+#define OOVBAAPI_SERV_DECL
-+#include <comphelper/servicedecl.hxx>
-+#include <ooo/vba/XHelperInterface.hpp>
++#ifndef SC_VBA_CHECKBOX_HXX
++#define SC_VBA_CHECKBOX_HXX
++#include <cppuhelper/implbase2.hxx>
++#include <ooo/vba/msforms/XRadioButton.hpp>
 +
-+namespace comphelper {
-+namespace service_decl {
-+template <typename ImplT_, typename WithArgsT = with_args<false> >
-+struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT >
++#include "vbacontrol.hxx"
++#include <vbahelper/vbahelper.hxx>
++
++typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
++
++class ScVbaCheckbox : public CheckBoxImpl_BASE
 +{
-+    typedef serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > baseT;
-+    /** Default ctor.  Implementation class without args, expecting
-+        component context as single argument.
-+    */
-+    vba_service_class_() : baseT() {}
-+    template <typename PostProcessFuncT>
-+    /** Ctor to pass a post processing function/functor.
-+        
-+        @tpl PostProcessDefaultT let your compiler deduce this
-+        @param postProcessFunc function/functor that gets the yet unacquired
-+                               ImplT_ pointer returning a
-+                               uno::Reference<uno::XInterface>
-+    */
-+    explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
++public:
++    ScVbaCheckbox(  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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
++    // XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
 +
-+} // namespace service_decl
-+} // namespace comphelper
-+#endif
-diff --git vbahelper/inc/vbahelper/vbacollectionimpl.hxx vbahelper/inc/vbahelper/vbacollectionimpl.hxx
++#endif //SC_VBA_CHECKBOX_HXX
+diff --git vbahelper/source/msforms/vbacombobox.cxx vbahelper/source/msforms/vbacombobox.cxx
 new file mode 100644
-index 0000000..fec7b92
+index 0000000..f1ea440
 --- /dev/null
-+++ vbahelper/inc/vbahelper/vbacollectionimpl.hxx
-@@ -0,0 +1,257 @@
++++ vbahelper/source/msforms/vbacombobox.cxx
+@@ -0,0 +1,175 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9607,8 +23229,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbacollectionimpl.hxx,v $
-+ * $Revision: 1.5 $
++ * $RCSfile: vbacombobox.cxx,v $
++ * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -9625,243 +23247,161 @@
 + * 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 OOVBAAPI_VBA_COLLECTION_IMPL_HXX
-+#define OOVBAAPI_VBA_COLLECTION_IMPL_HXX
-+
-+#include <ooo/vba/XCollection.hpp>
-+#include <com/sun/star/container/XEnumerationAccess.hpp>
-+#include <com/sun/star/uno/XComponentContext.hpp>
-+#include <com/sun/star/script/XDefaultMethod.hpp>
-+#include <com/sun/star/container/XIndexAccess.hpp>
-+#include <com/sun/star/container/XNameAccess.hpp>
-+#include <com/sun/star/container/XNamed.hpp>
-+
-+#include <cppuhelper/implbase3.hxx>
-+#include <cppuhelper/implbase2.hxx>
-+#include <cppuhelper/implbase1.hxx>
-+
-+#include "vbahelper/vbahelper.hxx"
-+#include "vbahelper/vbahelperinterface.hxx"
-+
-+#include <vector>
-+
-+typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumerationHelper_BASE;
-+
-+class EnumerationHelperImpl : public EnumerationHelper_BASE
-+{
-+protected:
-+	css::uno::Reference< css::uno::XComponentContext > m_xContext;
-+	css::uno::Reference< css::container::XEnumeration > m_xEnumeration;
-+public:
-+
-+	EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ),  m_xEnumeration( xEnumeration ) { }
-+	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); }
-+};
-+
-+// a wrapper class for a providing a XIndexAccess, XNameAccess, XEnumerationAccess impl based on providing a vector of interfaces 
-+// only requirement is the object needs to implement XName
-+
-+
-+
-+typedef ::cppu::WeakImplHelper3< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess > XNamedCollectionHelper_BASE;
-+
-+template< typename Ifc1 >
-+class XNamedObjectCollectionHelper : public XNamedCollectionHelper_BASE
-+{
-+public:
-+typedef std::vector< css::uno::Reference< Ifc1 > >  XNamedVec;
-+private:
-+
-+	class XNamedEnumerationHelper : public EnumerationHelper_BASE
-+	{
-+		XNamedVec mXNamedVec;
-+		typename XNamedVec::iterator mIt;
-+	public:
-+	        XNamedEnumerationHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), mIt( mXNamedVec.begin() ) {}
-+	
-+	        virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (css::uno::RuntimeException)
-+	        {
-+			return ( mIt != mXNamedVec.end() );
-+	        }
-+	
-+	        virtual css::uno::Any SAL_CALL nextElement(  ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
-+	        {
-+	                if ( hasMoreElements() )
-+				return css::uno::makeAny( *mIt++ );
-+	                throw css::container::NoSuchElementException();
-+	        }
-+	};
-+
-+protected:
-+	XNamedVec mXNamedVec;
-+	typename XNamedVec::iterator cachePos;
-+public:
-+	XNamedObjectCollectionHelper( const XNamedVec& sMap ) : mXNamedVec( sMap ), cachePos(mXNamedVec.begin()) {}
-+	// XElementAccess
-+	virtual css::uno::Type SAL_CALL getElementType(  ) throw (css::uno::RuntimeException) { return  Ifc1::static_type(0); }
-+	virtual ::sal_Bool SAL_CALL hasElements(  ) throw (css::uno::RuntimeException) { return ( mXNamedVec.size() > 0 ); }
-+	// XNameAcess 
-+	virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
-+	{
-+		if ( !hasByName(aName) )
-+			throw css::container::NoSuchElementException();
-+		return css::uno::makeAny( *cachePos );
-+	}
-+	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (css::uno::RuntimeException)
-+	{
-+		css::uno::Sequence< rtl::OUString > sNames( mXNamedVec.size() );
-+		rtl::OUString* pString = sNames.getArray();
-+		typename XNamedVec::iterator it = mXNamedVec.begin();
-+		typename XNamedVec::iterator it_end = mXNamedVec.end();
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++#include "vbacombobox.hxx"
++#include <vector>
 +
-+		for ( ; it != it_end; ++it, ++pString )
-+		{
-+			css::uno::Reference< css::container::XNamed > xName( *it, css::uno::UNO_QUERY_THROW );	
-+			*pString = xName->getName();
-+		}
-+		return sNames;
-+	}
-+	virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
-+	{
-+		cachePos = mXNamedVec.begin();
-+		typename XNamedVec::iterator it_end = mXNamedVec.end();
-+		for ( ; cachePos != it_end; ++cachePos )
-+		{
-+			css::uno::Reference< css::container::XNamed > xName( *cachePos, css::uno::UNO_QUERY_THROW );	
-+			if ( aName.equals( xName->getName() ) )
-+				break;
-+		}
-+		return ( cachePos != it_end );
-+	}
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+	// XElementAccess
-+	virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException) { return mXNamedVec.size(); }	
-+	virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException )
-+	{
-+		if ( Index < 0 || Index >= getCount() )
-+			throw css::lang::IndexOutOfBoundsException();
-+	
-+		return css::uno::makeAny( mXNamedVec[ Index ] );
 +
-+	}
-+	// XEnumerationAccess
-+	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (css::uno::RuntimeException)
-+	{
-+		return new XNamedEnumerationHelper( mXNamedVec );
-+	}
-+};
++//SelectedItems list of integer indexes
++//StringItemList list of items
 +
-+// including a HelperInterface implementation
-+template< typename Ifc1 >
-+class ScVbaCollectionBase : public InheritedHelperInterfaceImpl< Ifc1 >
++const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
++const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
++const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
++const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataFieldProperty") );
++
++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 )
 +{
-+typedef InheritedHelperInterfaceImpl< Ifc1 > BaseColBase;
-+protected:
-+	css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess;
-+	css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
++    	mpListHelper.reset( new ListControlHelper( m_xProps ) );
++	// grab the default value property name
++	m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
++}
 +
-+	virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException)
-+	{
-+		if ( !m_xNameAccess.is() )
-+			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase string index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
-+	
-+		return createCollectionObject( m_xNameAccess->getByName( sIndex ) );	
-+	}		
++// Attributes
 +
-+	virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException)
-+	{
-+		if ( !m_xIndexAccess.is() )
-+			throw css::uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScVbaCollectionBase numeric index access not supported by this object") ), css::uno::Reference< css::uno::XInterface >() );
-+		if ( nIndex <= 0 )
-+		{
-+			throw  css::lang::IndexOutOfBoundsException( 
-+				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
-+				"index is 0 or negative" ) ), 
-+				css::uno::Reference< css::uno::XInterface >() );
-+		}
-+		// need to adjust for vba index ( for which first element is 1 )
-+		return createCollectionObject( m_xIndexAccess->getByIndex( nIndex - 1 ) );		
-+	}
-+public:
-+	ScVbaCollectionBase( const css::uno::Reference< ov::XHelperInterface >& xParent,   const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) : BaseColBase( xParent, xContext ), m_xIndexAccess( xIndexAccess ){ m_xNameAccess.set(m_xIndexAccess, css::uno::UNO_QUERY); }
-+	//XCollection
-+	virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException)
-+	{
-+		return m_xIndexAccess->getCount();
-+	}
 +
-+	virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw (css::uno::RuntimeException)
++// Value, [read] e.g. getValue returns the value of ooo Text propery e.g. the value in
++// the drop down
++uno::Any SAL_CALL 
++ScVbaComboBox::getValue() throw (uno::RuntimeException)
++{
++	return m_xProps->getPropertyValue( sSourceName );
++}
++
++void SAL_CALL 
++ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
++{
++    uno::Sequence< sal_Int16 > sSelection(1);
++    _value >>= sSelection[ 0 ];
++    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( sSelection ) );
++}
++
++uno::Any SAL_CALL 
++ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
++{
++	uno::Sequence< rtl::OUString > sItems;
++	m_xProps->getPropertyValue( ITEMS ) >>= sItems;
++	// should really return the item that has focus regardless of
++	// it been selected
++	if ( sItems.getLength() > 0 )
 +	{
-+		if ( Index1.getValueTypeClass() != css::uno::TypeClass_STRING )
++		rtl::OUString sText = getText();
++		sal_Int32 nLen = sItems.getLength();
++		for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index )
 +		{
-+			sal_Int32 nIndex = 0;
-+	
-+			if ( ( Index1 >>= nIndex ) != sal_True )
++			if ( sItems[ index ].equals( sText ) )
 +			{
-+				rtl::OUString message;
-+				message = rtl::OUString::createFromAscii(
-+					"Couldn't convert index to Int32");
-+				throw  css::lang::IndexOutOfBoundsException( message,
-+					css::uno::Reference< css::uno::XInterface >() );
++				OSL_TRACE("getListIndex returning %d", index );
++				return uno::makeAny( index );
 +			}
-+			return 	getItemByIntIndex( nIndex );
-+		}
-+		rtl::OUString aStringSheet;
++				
++		} 
++ 	} 
++	OSL_TRACE("getListIndex returning %d", -1 );
++	return uno::makeAny( sal_Int32( -1 ) );
++}
 +
-+		Index1 >>= aStringSheet;
-+		return getItemByStringIndex( aStringSheet );	
-+	}
-+	// XDefaultMethod
-+	::rtl::OUString SAL_CALL getDefaultMethodName(  ) throw (css::uno::RuntimeException)
-+	{
-+		const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
-+		return sName;
-+	}
-+	// XEnumerationAccess
-+	virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException) = 0;	
++// Value, [write]e.g. setValue sets the value in the drop down, and if the value is one
++// of the values in the list then the selection is also set
++void SAL_CALL 
++ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
++{
++	m_xProps->setPropertyValue( sSourceName, _value );
++}
 +
-+	// XElementAccess
-+	virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) = 0;
-+	// XElementAccess
-+	virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException)
-+	{
-+		return ( m_xIndexAccess->getCount() > 0 );
-+	}
-+	virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0;
-+	
-+};
++// see Value
 +
-+typedef ::cppu::WeakImplHelper1<ov::XCollection> XCollection_InterfacesBASE;
++::rtl::OUString SAL_CALL 
++ScVbaComboBox::getText() throw (uno::RuntimeException)
++{
++	rtl::OUString result;
++	getValue() >>= result;
++	return result;
++}
 +
-+typedef ScVbaCollectionBase< XCollection_InterfacesBASE > CollImplBase1;
-+// compatible with the old collections ( pre XHelperInterface base class ) ( some internal objects still use this )
-+class ScVbaCollectionBaseImpl : public CollImplBase1
++void SAL_CALL 
++ScVbaComboBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
 +{
-+public:
-+	ScVbaCollectionBaseImpl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : CollImplBase1( xParent, xContext, xIndexAccess){}
++	setValue( uno::makeAny( _text ) ); // seems the same
++}
 +
-+};
++// Methods
++void SAL_CALL 
++ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
++{
++	mpListHelper->AddItem( pvargItem, pvargIndex );
++}
 +
-+template <typename Ifc> // where Ifc must implement XCollectionTest
-+class CollTestImplHelper :  public ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc > >
++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)
 +{
-+typedef ScVbaCollectionBase< ::cppu::WeakImplHelper1< Ifc >  > ImplBase1;
++	ScVbaControl::setRowSource( _rowsource );
++	mpListHelper->setRowSource( _rowsource );
++		}
 +
-+public:
-+	CollTestImplHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,  const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw( css::uno::RuntimeException ) : ImplBase1( xParent, xContext, xIndexAccess ) {}
-+};
++sal_Int32 SAL_CALL
++ScVbaComboBox::getListCount() throw (uno::RuntimeException)
++{
++	return mpListHelper->getListCount();
++}
++		
++uno::Any SAL_CALL 
++ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
++{
++	return mpListHelper->List( pvargIndex, pvarColumn );
++	}
 +
++rtl::OUString& 
++ScVbaComboBox::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
++	return sImplName;
++}
 +
-+#endif //SC_VBA_COLLECTION_IMPL_HXX
-diff --git vbahelper/inc/vbahelper/vbadllapi.h vbahelper/inc/vbahelper/vbadllapi.h
++uno::Sequence< rtl::OUString > 
++ScVbaComboBox::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ComboBox" ) );
++	}
++	return aServiceNames;
++}
+diff --git vbahelper/source/msforms/vbacombobox.hxx vbahelper/source/msforms/vbacombobox.hxx
 new file mode 100644
-index 0000000..8d815fc
+index 0000000..2b1f5ce
 --- /dev/null
-+++ vbahelper/inc/vbahelper/vbadllapi.h
-@@ -0,0 +1,44 @@
++++ vbahelper/source/msforms/vbacombobox.hxx
+@@ -0,0 +1,80 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9870,7 +23410,7 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: svldllapi.h,v $
++ * $RCSfile: vbacombobox.hxx,v $
 + * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
@@ -9891,27 +23431,63 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
++#ifndef SC_VBA_COMBOBOX_HXX
++#define SC_VBA_COMBOBOX_HXX
++#include <cppuhelper/implbase2.hxx>
++#include <com/sun/star/uno/XComponentContext.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/script/XDefaultProperty.hpp>
++#include <ooo/vba/msforms/XComboBox.hpp>
++#include <comphelper/proparrhlp.hxx>
++#include <comphelper/propertycontainer.hxx>
++#include <com/sun/star/beans/PropertyAttribute.hpp>
 +
-+#ifndef INCLUDED_VBADLLAPI_H
-+#define INCLUDED_VBADLLAPI_H
++#include "vbacontrol.hxx"
++#include "vbalistcontrolhelper.hxx"
++#include <vbahelper/vbahelper.hxx>
 +
-+#include "sal/types.h"
++typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE;
++class ScVbaComboBox : public ComboBoxImpl_BASE
++{		
++	std::auto_ptr< ListControlHelper > mpListHelper;
++	rtl::OUString sSourceName; 
++	rtl::OUString msDftPropName;
++	bool mbDialogType;
++	
++public:
++	ScVbaComboBox( 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, bool bDialogType = false );
 +
-+#if defined(VBAHELPER_DLLIMPLEMENTATION)
-+#define VBAHELPER_DLLPUBLIC  SAL_DLLPUBLIC_EXPORT
-+#else
-+#define VBAHELPER_DLLPUBLIC  SAL_DLLPUBLIC_IMPORT
-+#endif
-+#define VBAHELPER_DLLPRIVATE SAL_DLLPRIVATE
++	// Attributes
++	virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException);
++	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) 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 ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
 +
-+#endif /* INCLUDED_SVLDLLAPI_H */
++	// Methods
++	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);
++	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
++	// XControl
++    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
 +
-diff --git vbahelper/inc/vbahelper/vbahelper.hxx vbahelper/inc/vbahelper/vbahelper.hxx
++	// XDefaultProperty
++        ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++	//XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif //
+diff --git vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/msforms/vbacontrol.cxx
 new file mode 100644
-index 0000000..76b842a
+index 0000000..25502d2
 --- /dev/null
-+++ vbahelper/inc/vbahelper/vbahelper.hxx
-@@ -0,0 +1,335 @@
++++ vbahelper/source/msforms/vbacontrol.cxx
+@@ -0,0 +1,520 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -9920,8 +23496,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbahelper.hxx,v $
-+ * $Revision: 1.5.32.1 $
++ * $RCSfile: vbacontrol.cxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -9941,445 +23517,503 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef OOVBAAPI_VBA_HELPER_HXX
-+#define OOVBAAPI_VBA_HELPER_HXX
-+
++#include <com/sun/star/form/FormComponentType.hpp>
++#include <com/sun/star/awt/XControlModel.hpp>
++#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/awt/XWindow2.hpp>
++#include <com/sun/star/lang/XEventListener.hpp>
 +#include <com/sun/star/drawing/XShape.hpp>
-+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
-+#include <com/sun/star/beans/XPropertySet.hpp>
-+#include <com/sun/star/script/BasicErrorException.hpp>
-+#include <com/sun/star/script/XTypeConverter.hpp>
-+#include <com/sun/star/lang/IllegalArgumentException.hpp>
++#include <com/sun/star/drawing/XControlShape.hpp>
 +#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/awt/XDevice.hpp>
-+#include <basic/sberrors.hxx>
-+#include <cppuhelper/implbase1.hxx>
 +#include <com/sun/star/frame/XModel.hpp>
-+#include <sfx2/dispatch.hxx>
-+#include <ooo/vba/msforms/XShape.hpp>
-+#define VBAHELPER_DLLIMPLEMENTATION
-+#include <vbahelper/vbadllapi.h>
-+namespace css = ::com::sun::star;
++#include <com/sun/star/view/XControlAccess.hpp>
++#include <com/sun/star/container/XChild.hpp>
++#include <com/sun/star/form/binding/XBindableValue.hpp>
++#include <com/sun/star/form/binding/XListEntrySink.hpp>
++#include <com/sun/star/table/CellAddress.hpp>
++#include <com/sun/star/table/CellRangeAddress.hpp>
++#include <ooo/vba/XControlProvider.hpp>
++#ifdef VBA_OOBUILD_HACK
++#include <svtools/bindablecontrolhelper.hxx>
++#endif
++#include"vbacontrol.hxx"
++#include"vbacombobox.hxx"
++#include "vbabutton.hxx"
++#include "vbalabel.hxx"
++#include "vbatextbox.hxx"
++#include "vbaradiobutton.hxx"
++#include "vbalistbox.hxx"
++#include "vbatogglebutton.hxx"
++#include "vbacheckbox.hxx"
++#include "vbaframe.hxx"
++#include "vbascrollbar.hxx"
++#include "vbaprogressbar.hxx"
++#include "vbamultipage.hxx"
++#include "vbaspinbutton.hxx"
++#include "vbaimage.hxx"
++#include <vbahelper/helperdecl.hxx>
 +
-+namespace ooo 
++
++using namespace com::sun::star;
++using namespace ooo::vba;
++
++uno::Reference< css::awt::XWindowPeer > 
++ScVbaControl::getWindowPeer() throw (uno::RuntimeException)
 +{
-+	namespace vba 
-+	{
-+		template < class T > 
-+		css::uno::Reference< T > getXSomethingFromArgs( css::uno::Sequence< css::uno::Any > const & args, sal_Int32 nPos, bool bCanBeNull = true ) throw (css::lang::IllegalArgumentException)
-+		{
-+			if ( args.getLength() < ( nPos + 1) )
-+				throw css::lang::IllegalArgumentException();
-+			css::uno::Reference< T > aSomething( args[ nPos ], css::uno::UNO_QUERY );
-+			if ( !bCanBeNull && !aSomething.is() )
-+				throw css::lang::IllegalArgumentException();
-+			return aSomething;
-+		}
-+		VBAHELPER_DLLPUBLIC css::uno::Reference< css::beans::XIntrospectionAccess > getIntrospectionAccess( const css::uno::Any& aObject ) throw (css::uno::RuntimeException);
-+		VBAHELPER_DLLPUBLIC css::uno::Reference< css::script::XTypeConverter > getTypeConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
++    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
 +
-+		VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl) ;
-+		VBAHELPER_DLLPUBLIC void dispatchRequests (css::uno::Reference< css::frame::XModel>& xModel,rtl::OUString & aUrl, css::uno::Sequence< css::beans::PropertyValue >& sProps ) ;
-+		VBAHELPER_DLLPUBLIC void dispatchExecute(SfxViewShell* pView, USHORT nSlot, SfxCallMode nCall = SFX_CALLMODE_SYNCHRON );
-+		VBAHELPER_DLLPUBLIC sal_Int32 OORGBToXLRGB( sal_Int32 );
-+		VBAHELPER_DLLPUBLIC sal_Int32 XLRGBToOORGB( sal_Int32 );
-+		VBAHELPER_DLLPUBLIC css::uno::Any OORGBToXLRGB( const css::uno::Any& );
-+		VBAHELPER_DLLPUBLIC css::uno::Any XLRGBToOORGB( const css::uno::Any& );
-+		// provide a NULL object that can be passed as variant so that 
-+		// the object when passed to IsNull will return true. aNULL 
-+		// contains an empty object reference
-+		VBAHELPER_DLLPUBLIC const css::uno::Any& aNULL();
-+		VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection  );
-+		VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges,  SfxViewShell* );
++    uno::Reference< awt::XControlModel > xControlModel;
++    uno::Reference< css::awt::XWindowPeer >  xWinPeer;
++    if ( !xControlShape.is() ) 
++    { 
++        // would seem to be a Userform control
++        uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW );
++        xWinPeer =  xControl->getPeer();
++	return xWinPeer;
++    }
++    // form control
++    xControlModel.set( xControlShape->getControl(), uno::UNO_QUERY_THROW );
++
++    uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
++    try
++    {
++        uno::Reference< awt::XControl > xControl( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY );
++        xWinPeer =  xControl->getPeer();
++    }
++    catch( uno::Exception )
++    {
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ),
++                uno::Reference< uno::XInterface >() );
++    }
++    return xWinPeer;
++}
++
++//ScVbaControlListener
++class ScVbaControlListener: public cppu::WeakImplHelper1< lang::XEventListener >
++{
++private:
++    ScVbaControl *pControl;
++public:
++    ScVbaControlListener( ScVbaControl *pTmpControl );
++    virtual ~ScVbaControlListener();
++    virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) throw( uno::RuntimeException );
++};
++
++ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl )
++{
++}
++
++ScVbaControlListener::~ScVbaControlListener()
++{
++}
++
++void SAL_CALL
++ScVbaControlListener::disposing( const lang::EventObject& ) throw( uno::RuntimeException )
++{
++    if( pControl )
++    {
++        pControl->removeResouce();
++        pControl = NULL;
++    }
++}
++
++//ScVbaControl
++
++ScVbaControl::ScVbaControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl,  const css::uno::Reference< css::frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ControlImpl_BASE( xParent, xContext ),  m_xControl( xControl ), m_xModel( xModel )
++{
++    //add listener
++    m_xEventListener.set( new ScVbaControlListener( this ) );
++    setGeometryHelper( pGeomHelper );
++    uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
++    xComponent->addEventListener( m_xEventListener );
++   
++    //init m_xProps
++    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ;
++    uno::Reference< awt::XControl> xUserFormControl( m_xControl, uno::UNO_QUERY ) ;
++    if ( xControlShape.is() ) // form control
++        m_xProps.set( xControlShape->getControl(), uno::UNO_QUERY_THROW );
++    else if ( xUserFormControl.is() ) // userform control
++        m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW );
++}
++
++ScVbaControl::~ScVbaControl()
++{
++    if( m_xControl.is() )
++{
++        uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
++    xComponent->removeEventListener( m_xEventListener );
++}
++}
++
++void 
++ScVbaControl::setGeometryHelper( AbstractGeometryAttributes* pHelper )
++{
++    mpGeometryHelper.reset( pHelper );
++}
++
++void ScVbaControl::removeResouce() throw( uno::RuntimeException )
++{
++    uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
++    xComponent->removeEventListener( m_xEventListener );
++    m_xControl= NULL;
++    m_xProps = NULL;
++}
++
++//In design model has different behavior
++sal_Bool SAL_CALL ScVbaControl::getEnabled() throw (uno::RuntimeException)
++{
++    uno::Any aValue = m_xProps->getPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ) );
++    sal_Bool bRet = false;
++    aValue >>= bRet;
++    return bRet;
++}
++
++void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeException)
++{
++    uno::Any aValue( bVisible );
++    m_xProps->setPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ), aValue);
 +
-+		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 fPoints, sal_Bool bVertical);
++}
 +
-+class VBAHELPER_DLLPUBLIC Millimeter
++sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
 +{
-+//Factor to translate between points and hundredths of millimeters:
-+private:
-+	static const double factor;
-+    
-+	double m_nMillimeter;
++    uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
++    return xWindow2->isVisible();
++}
 +
-+public:
-+	Millimeter():m_nMillimeter(0) {}
-+    
-+	Millimeter(double mm):m_nMillimeter(mm) {}
-+    
-+	void set(double mm) { m_nMillimeter = mm; }
-+	void setInPoints(double points) 
-+	{ 
-+		m_nMillimeter = points * 0.352777778; 
-+		// 25.4mm / 72 
-+	}
-+      
-+	void setInHundredthsOfOneMillimeter(double hmm)
-+	{
-+		m_nMillimeter = hmm / 100;
-+	}
-+    
-+	double get()
-+	{
-+		return m_nMillimeter;
-+	}
-+	double getInHundredthsOfOneMillimeter()
-+	{
-+		return m_nMillimeter * 100;
-+	}
-+	double getInPoints()
-+	{
-+		return m_nMillimeter * 2.834645669; // 72 / 25.4mm
-+	}    
++void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException)
++{
++    uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
++    xWindow2->setVisible( bVisible );
++}
++double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException)
++{
++    return mpGeometryHelper->getHeight();
++}
++void SAL_CALL ScVbaControl::setHeight( double _height ) throw (uno::RuntimeException)
++{
++    mpGeometryHelper->setHeight( _height );
++}
 +
-+	static sal_Int32 getInHundredthsOfOneMillimeter(double points)
-+	{
-+		sal_Int32 mm = static_cast<sal_Int32>(points * factor);
-+		return mm;
-+	}
-+    
-+	static double getInPoints(int _hmm)
-+	{
-+		double points = double( static_cast<double>(_hmm) / factor);
-+		return points;
-+	}
-+};
++double SAL_CALL ScVbaControl::getWidth() throw (uno::RuntimeException)
++{
++    return mpGeometryHelper->getWidth();
++}
++void SAL_CALL ScVbaControl::setWidth( double _width ) throw (uno::RuntimeException)
++{
++    mpGeometryHelper->setWidth( _width );
++}
 +
-+class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace the ShapeHelper below
++double SAL_CALL
++ScVbaControl::getLeft() throw (uno::RuntimeException)
 +{
-+public:
-+    virtual ~AbstractGeometryAttributes() {}
-+    virtual double getLeft() = 0;
-+    virtual void setLeft( double ) = 0;
-+    virtual double getTop() = 0;
-+    virtual void setTop( double ) = 0;
-+    virtual double getHeight() = 0;
-+    virtual void setHeight( double ) = 0;
-+    virtual double getWidth() = 0;
-+    virtual void setWidth( double ) = 0;
-+};
++    return mpGeometryHelper->getLeft();
++}
 +
-+class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeometryAttributes
++void SAL_CALL
++ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException)
 +{
-+public:
-+    css::uno::Reference< ooo::vba::msforms::XShape > m_xShape; 
-+    ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape );
-+    virtual double getLeft()
-+    {
-+        return m_xShape->getLeft();
-+    }
-+    virtual void setLeft( double nLeft )
-+    {
-+        m_xShape->setLeft( nLeft );
-+    }
-+    virtual double getTop()
-+    {
-+        return m_xShape->getTop();
-+    }
-+    virtual void setTop( double nTop )
-+    {
-+        m_xShape->setTop( nTop );
-+    }
++    mpGeometryHelper->setLeft( _left );
 +
-+    virtual double getHeight()
-+    {
-+        return m_xShape->getHeight();
-+    }
-+    virtual void setHeight( double nHeight )
-+    {
-+        m_xShape->setHeight( nHeight );
-+    }
-+    virtual double getWidth()
-+    {
-+        return m_xShape->getWidth();
-+    }
-+    virtual void setWidth( double nWidth)
-+    {
-+        m_xShape->setHeight( nWidth );
-+    }
++}
 +
-+   
-+};
-+#define VBA_LEFT "PositionX"
-+#define VBA_TOP "PositionY"
-+class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes
++double SAL_CALL
++ScVbaControl::getTop() throw (uno::RuntimeException)
 +{
++    return mpGeometryHelper->getTop();
++}
 +
-+    css::uno::Reference< css::beans::XPropertySet > mxModel;
-+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);
-+};
++void SAL_CALL
++ScVbaControl::setTop( double _top ) throw (uno::RuntimeException)
++{
++    mpGeometryHelper->setTop( _top );
++}
 +
-+class VBAHELPER_DLLPUBLIC ShapeHelper
++uno::Reference< uno::XInterface > SAL_CALL
++ScVbaControl::getObject() throw (uno::RuntimeException)
 +{
-+protected:
-+	css::uno::Reference< css::drawing::XShape > xShape;
-+public:
-+	ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ) : xShape( _xShape )
-+	{ 
-+		if( !xShape.is() ) 
-+			throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() );
-+	}
-+    
-+	double getHeight()
-+	{
-+        	return  Millimeter::getInPoints(xShape->getSize().Height);
-+    	}
++	uno::Reference< msforms::XControl > xRet( this );
++	return xRet;
++}
 +
++void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) 
++{
++    uno::Reference< awt::XWindow > xWin( m_xControl, uno::UNO_QUERY_THROW );
++    xWin->setFocus();
++}
 +
-+    	void setHeight(double _fheight) throw ( css::script::BasicErrorException )
++rtl::OUString SAL_CALL 
++ScVbaControl::getControlSource() throw (uno::RuntimeException)
++{
++// #FIXME I *hate* having these upstream differences
++// but this is necessary until I manage to upstream other
++// dependant parts
++#ifdef VBA_OOBUILD_HACK
++	rtl::OUString sControlSource;
++	uno::Reference< form::binding::XBindableValue > xBindable( m_xProps, uno::UNO_QUERY );
++	if ( xBindable.is() )
 +	{
 +		try
 +		{
-+			css::awt::Size aSize = xShape->getSize();
-+			aSize.Height = Millimeter::getInHundredthsOfOneMillimeter(_fheight);
-+			xShape->setSize(aSize);
++			uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW );
++			uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellAddressConversion" ))), uno::UNO_QUERY );
++			uno::Reference< beans::XPropertySet > xProps( xBindable->getValueBinding(), uno::UNO_QUERY_THROW );
++			table::CellAddress aAddress;
++			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BoundCell") ) ) >>= aAddress;
++			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address") ), uno::makeAny( aAddress ) );
++                	xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sControlSource;
 +		}
-+		catch ( css::uno::Exception& /*e*/)
++		catch( uno::Exception& )
 +		{
-+			throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
-+    		}
++		}	
 +	}
-+    
-+    
-+	double getWidth()
-+	{ 
-+		return Millimeter::getInPoints(xShape->getSize().Width);
-+    	}
++	return sControlSource;
++#else
++	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getControlSource not supported") ), uno::Reference< uno::XInterface >()); // not supported
++#endif
++}
 +
-+	void setWidth(double _fWidth) throw ( css::script::BasicErrorException )
-+	{
++void SAL_CALL 
++ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno::RuntimeException)
++{
++#ifdef VBA_OOBUILD_HACK
++    rtl::OUString sEmpty;
++    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty );
++#else
++	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setControlSource not supported ") ).concat( _controlsource ), uno::Reference< uno::XInterface >()); // not supported
++#endif
++}
++
++rtl::OUString SAL_CALL 
++ScVbaControl::getRowSource() throw (uno::RuntimeException)
++{
++#ifdef VBA_OOBUILD_HACK
++	rtl::OUString sRowSource;
++	uno::Reference< form::binding::XListEntrySink > xListSink( m_xProps, uno::UNO_QUERY );
++	if ( xListSink.is() )
++    {
 +		try
 +		{
-+			css::awt::Size aSize = xShape->getSize();
-+			aSize.Width = Millimeter::getInHundredthsOfOneMillimeter(_fWidth);
-+			xShape->setSize(aSize);
++			uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW );
++			uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeAddressConversion" ))), uno::UNO_QUERY );
++
++			uno::Reference< beans::XPropertySet > xProps( xListSink->getListEntrySource(), uno::UNO_QUERY_THROW );
++			table::CellRangeAddress aAddress;
++			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellRange") ) ) >>= aAddress;
++			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address")), uno::makeAny( aAddress ) );
++			xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sRowSource;
 +		}
-+		catch (css::uno::Exception& /*e*/)
++		catch( uno::Exception& )
 +		{
-+			throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
-+		}
-+	}
-+    
-+    
-+	double getLeft()
-+	{
-+		return Millimeter::getInPoints(xShape->getPosition().X);
-+	}
-+
-+    
-+	void setLeft(double _fLeft)
-+	{
-+		css::awt::Point aPoint = xShape->getPosition();
-+		aPoint.X = Millimeter::getInHundredthsOfOneMillimeter(_fLeft);
-+		xShape->setPosition(aPoint);
-+	}
-+    
-+
-+	double getTop()
-+	{
-+        	return Millimeter::getInPoints(xShape->getPosition().Y);
-+	}
-+
-+    
-+	void setTop(double _fTop)
-+	{
-+		css::awt::Point aPoint = xShape->getPosition();
-+		aPoint.Y = Millimeter::getInHundredthsOfOneMillimeter(_fTop);
-+		xShape->setPosition(aPoint);
++		}	
 +	}
-+    
-+};
++	return sRowSource;
++#else
++	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getRowSource not supported") ), uno::Reference< uno::XInterface >()); // not supported
++#endif
++}
 +
-+class VBAHELPER_DLLPUBLIC ContainerUtilities
++void SAL_CALL 
++ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
 +{
++#ifdef VBA_OOBUILD_HACK
++    rtl::OUString sEmpty;
++    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, sEmpty, _rowsource );
++#else
++	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setRowSource not supported ") ).concat( _rowsource ), uno::Reference< uno::XInterface >()); // not supported
++#endif
++}
 +
-+public: 
-+	static rtl::OUString getUniqueName( const css::uno::Sequence< ::rtl::OUString >&  _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator);
-+	static rtl::OUString getUniqueName( const css::uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix );
-+
-+	static sal_Int32 FieldInList( const css::uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString );
-+};
-+
-+// really just a a place holder to ease the porting pain
-+class VBAHELPER_DLLPUBLIC DebugHelper
++rtl::OUString SAL_CALL 
++ScVbaControl::getName() throw (uno::RuntimeException)
 +{
-+public:
-+	static void exception( const rtl::OUString&  DetailedMessage, const css::uno::Exception& ex,  int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException )
-+	{
-+		// #TODO #FIXME ( do we want to support additionalArg here )
-+		throw css::script::BasicErrorException( DetailedMessage.concat( rtl::OUString::createFromAscii(" ") ).concat( ex.Message ), css::uno::Reference< css::uno::XInterface >(), err, rtl::OUString() );
-+	}
-+
-+	static void exception( int err,  const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException )
-+	{
-+		exception( rtl::OUString(), css::uno::Exception(), err, additionalArgument );
-+	}
++	rtl::OUString sName;
++	m_xProps->getPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
++	return sName;
 +
-+	static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException )
-+	{
-+		exception( rtl::OUString(), ex, SbERR_INTERNAL_ERROR, rtl::OUString() );
-+	}
-+};
-+	} // openoffice
-+} // org
++}
 +
-+namespace ov = ooo::vba;
++void SAL_CALL
++ScVbaControl::setName( const rtl::OUString& _name ) throw (uno::RuntimeException)
++{
++	m_xProps->setPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), uno::makeAny( _name ) );
++    }
++//ScVbaControlFactory
 +
-+#ifdef DEBUG
-+#  define SC_VBA_FIXME(a) OSL_TRACE( a )
-+#  define SC_VBA_STUB() SC_VBA_FIXME(( "%s - stubbed\n", __FUNCTION__ ))
-+#else
-+#  define SC_VBA_FIXME(a)
-+#  define SC_VBA_STUB()
-+#endif
++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 )
++{
++}
 +
-+#endif
-diff --git vbahelper/inc/vbahelper/vbahelperinterface.hxx vbahelper/inc/vbahelper/vbahelperinterface.hxx
-new file mode 100644
-index 0000000..389a825
---- /dev/null
-+++ vbahelper/inc/vbahelper/vbahelperinterface.hxx
-@@ -0,0 +1,121 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: vbahelperinterface.hxx,v $
-+ * $Revision: 1.3 $
-+ *
-+ * 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 OOVBAAPI_VBA_HELPERINTERFACE_HXX
-+#define OOVBAAPI_VBA_HELPERINTERFACE_HXX
++ScVbaControl* ScVbaControlFactory::createControl()  throw (uno::RuntimeException)
++{
++    return createControl( m_xModel );
++}
++ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent )  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 );
++    
++}
 +
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/XHelperInterface.hpp>
-+#include <vbahelper/vbahelper.hxx>
-+#include <com/sun/star/container/XNameAccess.hpp>
++ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape,  const uno::Reference< uno::XInterface >& /*xParent*/ )  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
++    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 ) ) );
++        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 ) ) );
++        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 ) ) );
++        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 ) ) );
++        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 ) ) );
++        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 ) ) );
++        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 ) ) );
++        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 >() );
++    }
++}
 +
-+// use this class when you have an a object like
-+// interface  XAnInterface which contains XHelperInterface in its inheritance hierarchy
-+// interface XAnInterface
-+// { 
-+//     interface XHelperInterface;
-+//     [attribute, string] name;
-+// }
-+// or
-+// interface XAnInterface : XHelperInterface;
-+// { 
-+//     [attribute, string] name;
-+// }
-+//
-+// then this class can provide a default implementation of XHelperInterface,
-+// you can use it like this
-+// typedef InheritedHelperInterfaceImpl< XAnInterface > > AnInterfaceImpl_BASE;
-+// class AnInterfaceImpl : public AnInterfaceImpl_BASE
-+// {
-+// public:
-+//     AnInterface( const Reference< HelperInterface >& xParent ) : AnInterfaceImpl_BASE( xParent ) {}
-+//     // implement XAnInterface methods only, no need to implement the XHelperInterface 
-+//     // methods
-+//     virtual void setName( const OUString& );  
-+//     virtual OUString getName();  
-+// }
-+//
-+const ::rtl::OUString sHelperServiceName( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.HelperServiceBase" ) );
++ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl,  const uno::Reference< uno::XInterface >& xParent  )  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< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
++    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 ) );	
++    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 ) );	
++    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 );
++    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 ) );
++        else
++            pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
++    }
++    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 );
++    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 ) );
++    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 ) );
++    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 ) );
++    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 ) );
++    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 ) );
++    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 ) );
++    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 );
++    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 ) );
++    else
++        throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() );
++    return pControl;
++}
 +
-+template< typename Ifc1 >
-+class InheritedHelperInterfaceImpl : public Ifc1
++rtl::OUString& 
++ScVbaControl::getServiceImplName()
 +{
-+protected: 
-+	css::uno::WeakReference< ov::XHelperInterface > mxParent;
-+	css::uno::Reference< css::uno::XComponentContext > mxContext;
-+public:
-+	InheritedHelperInterfaceImpl() {}
-+	InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {}
-+	virtual rtl::OUString& getServiceImplName() = 0;
-+	virtual css::uno::Sequence<rtl::OUString> getServiceNames() = 0;
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControl") );
++	return sImplName;
++}
 +
-+	// XHelperInterface Methods
-+	virtual ::sal_Int32 SAL_CALL getCreator() throw (css::script::BasicErrorException, css::uno::RuntimeException)
++uno::Sequence< rtl::OUString > 
++ScVbaControl::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
 +	{
-+		return 0x53756E4F;
-+	}
-+	virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { return mxParent; }
-+	
-+	virtual css::uno::Any SAL_CALL Application(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { 
-+            // The application could certainly be passed around in the context - seems
-+            // to make sense
-+            css::uno::Reference< css::container::XNameAccess > xNameAccess( mxContext, css::uno::UNO_QUERY_THROW );
-+            return xNameAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application" ) ) );
-+	}
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Control" ) );
++    }
++	return aServiceNames;
++}
 +
 +
-+	// XServiceInfo Methods
-+	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (css::uno::RuntimeException) { return getServiceImplName(); }
-+	virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) 
-+	{ 
-+		css::uno::Sequence< rtl::OUString > sServices = getSupportedServiceNames();
-+		const rtl::OUString* pStart = sServices.getConstArray();
-+		const rtl::OUString* pEnd = pStart + sServices.getLength();
-+		for ( ; pStart != pEnd ; ++pStart )
-+			if ( (*pStart).equals( ServiceName ) )
-+				return sal_True;
-+		return sal_False;	
++
++typedef cppu::WeakImplHelper1< XControlProvider > ControlProvider_BASE;
++class ControlProviderImpl : public ControlProvider_BASE
++{
++    uno::Reference< uno::XComponentContext > m_xCtx;
++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 
++ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException)
++{
++	uno::Reference< msforms::XControl > xControlToReturn;
++	if ( xControlShape.is() ) 
++	{
++		ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner );
++		xControlToReturn.set( controlFactory.createControl( xDocOwner ) );
 +	}
-+	virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (css::uno::RuntimeException) 
++	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() ) 
 +	{ 
-+		css::uno::Sequence< rtl::OUString > aNames = getServiceNames();;
-+		return aNames;
++			
++		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 ) );
 +	}
-+ };
-+
-+template< typename Ifc1 >
-+class InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > >
++	return xControlToReturn;
++}
 +
++namespace controlprovider
 +{
-+typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base;
-+public:
-+	InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {}	
++namespace sdecl = comphelper::service_decl;
++sdecl::class_<ControlProviderImpl, sdecl::with_args<false> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "ControlProviderImpl",
++    "ooo.vba.ControlProvider" );
++}
 +
-+};
-+#endif
-diff --git vbahelper/inc/vbahelper/vbapropvalue.hxx vbahelper/inc/vbahelper/vbapropvalue.hxx
++
+diff --git vbahelper/source/msforms/vbacontrol.hxx vbahelper/source/msforms/vbacontrol.hxx
 new file mode 100644
-index 0000000..c782f5b
+index 0000000..e7593e8
 --- /dev/null
-+++ vbahelper/inc/vbahelper/vbapropvalue.hxx
-@@ -0,0 +1,60 @@
++++ vbahelper/source/msforms/vbacontrol.hxx
+@@ -0,0 +1,112 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -10388,7 +24022,7 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbapropvalue.hxx,v $
++ * $RCSfile: vbacontrol.hxx,v $
 + * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
@@ -10409,154 +24043,95 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_PROPVALULE_HXX
-+#define SC_VBA_PROPVALULE_HXX
-+#include <ooo/vba/XPropValue.hpp>
++#ifndef SC_VBA_CONTROL_HXX
++#define SC_VBA_CONTROL_HXX
++
 +#include <cppuhelper/implbase1.hxx>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/uno/XComponentContext.hpp>
++#include <com/sun/star/script/XDefaultProperty.hpp>
++#include <com/sun/star/drawing/XControlShape.hpp>
++#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/awt/XWindowPeer.hpp>
++#include <ooo/vba/msforms/XControl.hpp>
 +
 +#include <vbahelper/vbahelper.hxx>
++#include <vbahelper/vbahelperinterface.hxx>
++#include <memory>
 +
-+typedef ::cppu::WeakImplHelper1< ov::XPropValue > PropValueImpl_BASE;
++//typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE;
++typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE;
 +
-+class PropListener 
++class ScVbaControl : public ControlImpl_BASE
 +{
-+public:
-+    virtual void setValueEvent( const css::uno::Any& value ) = 0;
-+    virtual css::uno::Any getValueEvent() = 0; 
-+};
-+
++private:
++    com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener;
++protected:
++    std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper;
++    css::uno::Reference< css::beans::XPropertySet > m_xProps;
++    css::uno::Reference< css::uno::XInterface > m_xControl;
++    css::uno::Reference< css::frame::XModel > m_xModel;
 +
-+class ScVbaPropValue : public PropValueImpl_BASE 
-+{
-+    PropListener* m_pListener;
++    virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
 +public:
-+    ScVbaPropValue( PropListener* pListener );
-+
-+    // Attributes
-+    virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
-+
-+    rtl::OUString SAL_CALL getDefaultPropertyName() throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
-+
-+};
-+#endif //SC_VBA_PROPVALULE_HXX
-diff --git vbahelper/prj/build.lst vbahelper/prj/build.lst
-new file mode 100644
-index 0000000..a38a6dc
---- /dev/null
-+++ vbahelper/prj/build.lst
-@@ -0,0 +1,6 @@
-+vba	vbahelper	:	oovbaapi basic sfx2 svx cppuhelper vcl comphelper svtools tools sal NULL
-+vba	vbahelper									usr1	-	all	  vba_mkout NULL
-+#vba	vbahelper\inc								nmake	-	all	vba_inc NULL
-+vba	vbahelper\source\vbahelper                        nmake	-	all	vba_vbahelper NULL
-+vba	vbahelper\source\msforms                        nmake	-	all	vba_msforms NULL
-+vba	vbahelper\util								nmake	-	all	vba_util vba_vbahelper vba_msforms NULL
-diff --git vbahelper/prj/d.lst vbahelper/prj/d.lst
-new file mode 100644
-index 0000000..bc31ac5
---- /dev/null
-+++ vbahelper/prj/d.lst
-@@ -0,0 +1,9 @@
-+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%
-+..\%__SRC%\lib\vbahelp*.* %_DEST%\lib%_EXT%\vba*.*
-+
-+mkdir: %_DEST%\inc%_EXT%\basic
-+..\inc\vbahelper\vbacollectionimpl.hxx %_DEST%\inc%_EXT%\vbahelper\vbacollectionimpl.hxx
-+..\inc\vbahelper\vbahelper.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelper.hxx
-+..\inc\vbahelper\helperdecl.hxx %_DEST%\inc%_EXT%\vbahelper\helperdecl.hxx
-+..\inc\vbahelper\vbahelperinterface.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelperinterface.hxx
-+..\inc\vbahelper\vbadllapi.h %_DEST%\inc%_EXT%\vbahelper\vbadllapi.h
-diff --git vbahelper/source/msforms/makefile.mk vbahelper/source/msforms/makefile.mk
-new file mode 100644
-index 0000000..ad5e7b4
---- /dev/null
-+++ vbahelper/source/msforms/makefile.mk
-@@ -0,0 +1,78 @@
-+#*************************************************************************
-+#
-+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+# 
-+# Copyright 2008 by Sun Microsystems, Inc.
-+#
-+# OpenOffice.org - a multi-platform office productivity suite
-+#
-+# $RCSfile: makefile.mk,v $
-+#
-+# $Revision: 1.45 $
-+#
-+# 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.
-+#
-+#*************************************************************************
-+
-+PRJ=..$/..
-+PRJNAME=vbahelper
-+TARGET=msforms
-+
-+ENABLE_EXCEPTIONS := TRUE
-+
-+# --- Settings -----------------------------------------------------
-+
-+.INCLUDE :  settings.mk
-+
-+SLOFILES=\
-+    $(SLO)$/vbacontrol.obj \
-+    $(SLO)$/vbacontrols.obj \
-+    $(SLO)$/vbabutton.obj \
-+    $(SLO)$/vbacombobox.obj \
-+    $(SLO)$/vbalabel.obj \
-+    $(SLO)$/vbatextbox.obj \
-+    $(SLO)$/vbaradiobutton.obj \
-+    $(SLO)$/vbalistbox.obj \
-+    $(SLO)$/vbatogglebutton.obj \
-+    $(SLO)$/vbacheckbox.obj \
-+    $(SLO)$/vbaframe.obj \
-+    $(SLO)$/vbascrollbar.obj \
-+    $(SLO)$/vbaprogressbar.obj \
-+    $(SLO)$/vbamultipage.obj \
-+    $(SLO)$/vbalistcontrolhelper.obj \
-+    $(SLO)$/vbaspinbutton.obj \
-+    $(SLO)$/vbaimage.obj \
-+    $(SLO)$/vbapages.obj \
-+    $(SLO)$/vbauserform.obj \
-+    $(SLO)$/service.obj \
-+
-+# #FIXME vbapropvalue needs to move to vbahelper
-+
-+# --- Targets -------------------------------------------------------
-+
-+.INCLUDE :  target.mk
++    ScVbaControl( 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* pHelper );
++    virtual ~ScVbaControl();
++    // This class will own the helper, so make sure it is allocated from 
++    // the heap
++    void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper );
++    // XControl
++    virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException);
++    virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
++    virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
++    virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
++    virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
++    virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
++    virtual void SAL_CALL SetFocus(  ) throw (css::uno::RuntimeException);
 +
-+ALLTAR : \
-+        $(MISC)$/$(TARGET).don \
++    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
++    virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource ) throw (css::uno::RuntimeException);
++    virtual rtl::OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
++    virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setName( const rtl::OUString& _name ) 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
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
 +
-+$(SLOFILES) : $(MISC)$/$(TARGET).don
 +
-+$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
-+        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
-+        echo $@
++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()  throw ( css::uno::RuntimeException );
++    ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent )  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;
++};
 +
-diff --git vbahelper/source/msforms/service.cxx vbahelper/source/msforms/service.cxx
++#endif//SC_VBA_CONTROL_HXX
+diff --git vbahelper/source/msforms/vbacontrols.cxx vbahelper/source/msforms/vbacontrols.cxx
 new file mode 100644
-index 0000000..3215944
+index 0000000..f963890
 --- /dev/null
-+++ vbahelper/source/msforms/service.cxx
-@@ -0,0 +1,83 @@
++++ vbahelper/source/msforms/vbacontrols.cxx
+@@ -0,0 +1,232 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -10565,8 +24140,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: service.cxx,v $
-+ * $Revision: 1.4 $
++ * $RCSfile$
++ * $Revision$
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -10586,146 +24161,215 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include "cppuhelper/implementationentry.hxx"
-+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
-+#include "com/sun/star/registry/XRegistryKey.hpp"
-+#include "comphelper/servicedecl.hxx"
 +
-+// =============================================================================
-+// component exports
-+// =============================================================================
-+using namespace ::com::sun::star;
-+using namespace ::com::sun::star::uno;
++#include "vbacontrols.hxx"
++#include <cppuhelper/implbase2.hxx>
++#include <com/sun/star/awt/XControlContainer.hpp>
++#include <ooo/vba//XControlProvider.hpp>
++#include <hash_map>
 +
-+namespace sdecl = comphelper::service_decl;
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+// reference service helper(s)
-+namespace  controlprovider
-+{
-+extern sdecl::ServiceDecl const serviceDecl;
-+}
 +
-+namespace  userform
-+{
-+extern sdecl::ServiceDecl const serviceDecl;
-+}
++typedef ::cppu::WeakImplHelper2< container::XNameAccess, container::XIndexAccess > ArrayWrapImpl;
 +
-+extern "C"
++typedef  std::hash_map< rtl::OUString, sal_Int32, ::rtl::OUStringHash,
++    ::std::equal_to< ::rtl::OUString >  > ControlIndexMap;
++typedef  std::vector< uno::Reference< awt::XControl > > ControlVec;
++
++class ControlArrayWrapper : public ArrayWrapImpl
 +{
-+    void SAL_CALL component_getImplementationEnvironment( 
-+        const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
++    uno::Reference< awt::XControlContainer > mxDialog;
++    uno::Sequence< ::rtl::OUString > msNames;
++    ControlVec mControls;
++    ControlIndexMap mIndices;
++
++    rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl )
 +    {
-+		OSL_TRACE("In component_getImplementationEnv");
-+        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
++        uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY );
++        rtl::OUString sName;
++        xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
++        return sName;
 +    }
 +
-+    sal_Bool SAL_CALL component_writeInfo( 
-+        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
++public:
++
++    ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog )
 +    {
-+		OSL_TRACE("In component_writeInfo");
++        mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
++        uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls();
++    
++        msNames.realloc( sXControls.getLength() );
++        for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i )
++        {
++            uno::Reference< awt::XControl > xCtrl = sXControls[ i ];
++            msNames[ i ] = getControlName( xCtrl );
++            mControls.push_back( xCtrl );
++            mIndices[ msNames[ i ] ] = i;
++        }
++    }
++    
++    // XElementAccess
++    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException)
++    {
++        return awt::XControl::static_type(0);
++    }
++    
++    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException) 
++    {
++        return ( mControls.size() > 0 );
++    }
++    
++    // XNameAcess 
++    virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
++    {
++        if ( !hasByName( aName ) )
++            throw container::NoSuchElementException();
++        return getByIndex( mIndices[ aName ] );
++    }
++    
++    virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
++    {
++        return msNames;
++    }
++    
++    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
++    {
++        ControlIndexMap::iterator it = mIndices.find( aName );
++        return it != mIndices.end();
++    }
++    
++    // XElementAccess
++    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException)
++    {
++        return mControls.size();
++    }
++    
++    virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
++    {
++        if ( Index < 0 || Index >= static_cast< sal_Int32 >( mControls.size() ) )
++            throw lang::IndexOutOfBoundsException();
++        return uno::makeAny( mControls[ Index ] );
++    }
++};
 +
-+	// Component registration
-+         return component_writeInfoHelper( pServiceManager, pRegistryKey, 
-+		controlprovider::serviceDecl, userform::serviceDecl );
++
++class ControlsEnumWrapper : public EnumerationHelper_BASE
++{
++    uno::Reference<XHelperInterface > m_xParent;
++    uno::Reference<uno::XComponentContext > m_xContext;
++    uno::Reference<container::XIndexAccess > m_xIndexAccess;
++    uno::Reference<awt::XControl > m_xDlg;
++    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 ) {}
++
++    virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
++    {
++        return ( nIndex < m_xIndexAccess->getCount() );
 +    }
 +
-+    void * SAL_CALL component_getFactory( 
-+        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
-+        registry::XRegistryKey * pRegistryKey )
++    virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
 +    {
-+		OSL_TRACE("In component_getFactory for %s", pImplName );
-+	void* pRet =  component_getFactoryHelper(
-+        	pImplName, pServiceManager, pRegistryKey, controlprovider::serviceDecl, userform::serviceDecl );
-+	OSL_TRACE("Ret is 0x%x", pRet);
-+	return pRet;
++        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 ) );
++            return uno::makeAny( xVBAControl );
++        }
++        throw container::NoSuchElementException();
 +    }
-+}
-diff --git vbahelper/source/msforms/vbabutton.cxx vbahelper/source/msforms/vbabutton.cxx
-new file mode 100644
-index 0000000..0e4d749
---- /dev/null
-+++ vbahelper/source/msforms/vbabutton.cxx
-@@ -0,0 +1,74 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: vbabutton.cxx,v $
-+ * $Revision: 1.3 $
-+ *
-+ * 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 "vbabutton.hxx"
-+#include <vector>
 +
-+using namespace com::sun::star;
-+using namespace ooo::vba;
++};
 +
 +
-+const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+ScVbaButton::ScVbaButton( 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 ) : ButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++uno::Reference<container::XIndexAccess >
++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  ) )
++{
++    mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
++}
++
++uno::Reference< container::XEnumeration >
++ScVbaControls::createEnumeration() throw (uno::RuntimeException)
 +{
++    uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) );
++    if ( !xEnum.is() )
++        throw uno::RuntimeException();
++    return xEnum;
 +}
 +
-+// Attributes
-+rtl::OUString SAL_CALL 
-+ScVbaButton::getCaption() throw (css::uno::RuntimeException)
-+{
-+    rtl::OUString Label;
-+    m_xProps->getPropertyValue( LABEL ) >>= Label;
-+    return Label;
++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 );
 +}
 +
 +void SAL_CALL 
-+ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++    uno::Reference< container::XEnumeration > xEnum( createEnumeration() );
++    while ( xEnum->hasMoreElements() )
++    {
++        uno::Reference< msforms::XControl > xControl( xEnum->nextElement(), uno::UNO_QUERY_THROW );
++        xControl->setLeft( xControl->getLeft() + cx );
++        xControl->setTop( xControl->getTop() + cy ); 
++    }
 +}
 +
++uno::Type
++ScVbaControls::getElementType() throw (uno::RuntimeException)
++{
++    return ooo::vba::msforms::XControl::static_type(0);
++}
 +rtl::OUString& 
-+ScVbaButton::getServiceImplName()
++ScVbaControls::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaButton") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaButton::getServiceNames()
++ScVbaControls::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Button" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbabutton.hxx vbahelper/source/msforms/vbabutton.hxx
+diff --git vbahelper/source/msforms/vbacontrols.hxx vbahelper/source/msforms/vbacontrols.hxx
 new file mode 100644
-index 0000000..818f245
+index 0000000..461c360
 --- /dev/null
-+++ vbahelper/source/msforms/vbabutton.hxx
-@@ -0,0 +1,51 @@
++++ vbahelper/source/msforms/vbacontrols.hxx
+@@ -0,0 +1,62 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -10734,8 +24378,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbabutton.hxx,v $
-+ * $Revision: 1.3 $
++ * $RCSfile$
++ * $Revision$
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -10755,34 +24399,45 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_BUTTON_HXX
-+#define SC_VBA_BUTTON_HXX
++#ifndef SC_VBA_CONTROLS_HXX
++#define SC_VBA_CONTROLS_HXX
++
 +#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XButton.hpp>
++#include <ooo/vba/msforms/XControls.hpp>
++#include <com/sun/star/awt/XControl.hpp>
 +
-+#include "vbacontrol.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
 +#include <vbahelper/vbahelper.hxx>
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
++typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE;
 +
-+class ScVbaButton : public ButtonImpl_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:
-+    ScVbaButton( 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 rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, 
++                    const css::uno::Reference< css::awt::XControl >& xDialog );
++    // XControls
++     virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException);
++    // XEnumerationAccess
++    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++
++    // ScVbaCollectionBaseImpl
++    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
++    
 +};
-+#endif //SC_VBA_BUTTON_HXX
-diff --git vbahelper/source/msforms/vbacheckbox.cxx vbahelper/source/msforms/vbacheckbox.cxx
++#endif //SC_VBA_OLEOBJECTS_HXX
++
+diff --git vbahelper/source/msforms/vbaframe.cxx vbahelper/source/msforms/vbaframe.cxx
 new file mode 100644
-index 0000000..3a6c5d9
+index 0000000..b2827d0
 --- /dev/null
-+++ vbahelper/source/msforms/vbacheckbox.cxx
-@@ -0,0 +1,112 @@
++++ vbahelper/source/msforms/vbaframe.cxx
+@@ -0,0 +1,93 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -10817,8 +24472,7 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbacheckbox.hxx"
-+#include <vbahelper/helperdecl.hxx>
++#include "vbaframe.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
@@ -10826,14 +24480,13 @@
 +
 +
 +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
-+ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_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 ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
 +}
 +
 +// Attributes
 +rtl::OUString SAL_CALL 
-+ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
++ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
 +{
 +    rtl::OUString Label;
 +    m_xProps->getPropertyValue( LABEL ) >>= Label;
@@ -10841,133 +24494,232 @@
 +}
 +
 +void SAL_CALL 
-+ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
 +{
 +    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
 +}
 +
 +uno::Any SAL_CALL 
-+ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
++ScVbaFrame::getValue() throw (css::uno::RuntimeException)
 +{
-+    sal_Int16 nValue = -1;
-+    m_xProps->getPropertyValue( STATE ) >>= nValue;
-+    if( nValue != 0 )
-+        nValue = -1;
-+//    return uno::makeAny( nValue ); 
-+// I must be missing something MSO says value should be -1 if selected, 0 if not
-+// selected
-+    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
++    return uno::makeAny( getCaption() );
 +}
 +
 +void SAL_CALL 
-+ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
++ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++{
++    rtl::OUString sCaption;
++    _value >>= sCaption;
++    setCaption( sCaption ); 
++}
++
++rtl::OUString& 
++ScVbaFrame::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++ScVbaFrame::getServiceNames()
++{
++	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;
++}
+diff --git vbahelper/source/msforms/vbaframe.hxx vbahelper/source/msforms/vbaframe.hxx
+new file mode 100644
+index 0000000..071b5b0
+--- /dev/null
++++ vbahelper/source/msforms/vbaframe.hxx
+@@ -0,0 +1,58 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef SC_VBA_FRAME_HXX
++#define SC_VBA_FRAME_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XLabel.hpp>
++
++#include "vbacontrol.hxx"
++#include <vbahelper/vbahelper.hxx>
++
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > 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);
++    virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif //SC_VBA_LABEL_HXX
+diff --git vbahelper/source/msforms/vbaimage.cxx vbahelper/source/msforms/vbaimage.cxx
+new file mode 100644
+index 0000000..847a08a
+--- /dev/null
++++ vbahelper/source/msforms/vbaimage.cxx
+@@ -0,0 +1,59 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile$
++ * $Revision$
++ *
++ * 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 "vbaimage.hxx"
++#include <vector>
++
++using namespace com::sun::star;
++using namespace ooo::vba;
++
++
++const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++ScVbaImage::ScVbaImage( 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 ) : ImageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
-+    sal_Int16 nValue = 0;
-+    sal_Bool bValue = false;
-+    if( _value >>= nValue )
-+    {
-+        if( nValue == -1)
-+            nValue = 1;
-+    }
-+    else if ( _value >>= bValue )
-+    {
-+        if ( bValue )
-+            nValue = 1;
-+    }
-+    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
 +}
++
 +rtl::OUString& 
-+ScVbaCheckbox::getServiceImplName()
++ScVbaImage::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaImage") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaCheckbox::getServiceNames()
++ScVbaImage::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Image" ) );
 +	}
 +	return aServiceNames;
 +}
-+
-diff --git vbahelper/source/msforms/vbacheckbox.hxx vbahelper/source/msforms/vbacheckbox.hxx
+diff --git vbahelper/source/msforms/vbaimage.hxx vbahelper/source/msforms/vbaimage.hxx
 new file mode 100644
-index 0000000..f3374db
+index 0000000..d64f1c3
 --- /dev/null
-+++ vbahelper/source/msforms/vbacheckbox.hxx
-@@ -0,0 +1,61 @@
++++ vbahelper/source/msforms/vbaimage.hxx
+@@ -0,0 +1,48 @@
 +/*************************************************************************
 + *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
 + *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
++ * OpenOffice.org - a multi-platform office productivity suite
 + *
++ * $RCSfile$
++ * $Revision$
 + *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ * This file is part of OpenOffice.org.
 + *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
++ * 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.
 + *
-+ *    This library 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 for more details.
++ * 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 along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
++ * 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 SC_VBA_CHECKBOX_HXX
-+#define SC_VBA_CHECKBOX_HXX
-+#include <cppuhelper/implbase2.hxx>
-+#include <ooo/vba/msforms/XRadioButton.hpp>
++#ifndef SC_VBA_IMAGE_HXX
++#define SC_VBA_IMAGE_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XImage.hpp>
 +
 +#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
 +
-+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XImage > ImageImpl_BASE;
 +
-+class ScVbaCheckbox : public CheckBoxImpl_BASE
++class ScVbaImage : public ImageImpl_BASE
 +{
 +public:
-+    ScVbaCheckbox(  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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
-+    // XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++    ScVbaImage( 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  );
 +    //XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+
-+#endif //SC_VBA_CHECKBOX_HXX
-diff --git vbahelper/source/msforms/vbacombobox.cxx vbahelper/source/msforms/vbacombobox.cxx
++#endif //SC_VBA_IMAGE_HXX
+diff --git vbahelper/source/msforms/vbalabel.cxx vbahelper/source/msforms/vbalabel.cxx
 new file mode 100644
-index 0000000..8f1e0fb
+index 0000000..a5fa3c1
 --- /dev/null
-+++ vbahelper/source/msforms/vbacombobox.cxx
-@@ -0,0 +1,175 @@
++++ vbahelper/source/msforms/vbalabel.cxx
+@@ -0,0 +1,88 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -10976,8 +24728,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbacombobox.cxx,v $
-+ * $Revision: 1.4 $
++ * $RCSfile: vbalabel.cxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -10997,158 +24749,71 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include "vbacombobox.hxx"
++#include "vbalabel.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
 +
-+//SelectedItems list of integer indexes
-+//StringItemList list of items
-+
-+const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
-+const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
-+const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
-+const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataFieldProperty") );
-+
-+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 )
++const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++ScVbaLabel::ScVbaLabel(  const css::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 ) : LabelImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
-+    	mpListHelper.reset( new ListControlHelper( m_xProps ) );
-+	// grab the default value property name
-+	m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
 +}
 +
 +// Attributes
-+
-+
-+// Value, [read] e.g. getValue returns the value of ooo Text propery e.g. the value in
-+// the drop down
-+uno::Any SAL_CALL 
-+ScVbaComboBox::getValue() throw (uno::RuntimeException)
++rtl::OUString SAL_CALL 
++ScVbaLabel::getCaption() throw (css::uno::RuntimeException)
 +{
-+	return m_xProps->getPropertyValue( sSourceName );
++    rtl::OUString Label;
++    m_xProps->getPropertyValue( LABEL ) >>= Label;
++    return Label;
 +}
 +
 +void SAL_CALL 
-+ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
++ScVbaLabel::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+    uno::Sequence< sal_Int16 > sSelection(1);
-+    _value >>= sSelection[ 0 ];
-+    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( sSelection ) );
++    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
 +}
-+
 +uno::Any SAL_CALL 
-+ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
-+{
-+	uno::Sequence< rtl::OUString > sItems;
-+	m_xProps->getPropertyValue( ITEMS ) >>= sItems;
-+	// should really return the item that has focus regardless of
-+	// it been selected
-+	if ( sItems.getLength() > 0 )
-+	{
-+		rtl::OUString sText = getText();
-+		sal_Int32 nLen = sItems.getLength();
-+		for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index )
-+		{
-+			if ( sItems[ index ].equals( sText ) )
-+			{
-+				OSL_TRACE("getListIndex returning %d", index );
-+				return uno::makeAny( index );
-+			}
-+				
-+		} 
-+ 	} 
-+	OSL_TRACE("getListIndex returning %d", -1 );
-+	return uno::makeAny( sal_Int32( -1 ) );
-+}
-+
-+// Value, [write]e.g. setValue sets the value in the drop down, and if the value is one
-+// of the values in the list then the selection is also set
-+void SAL_CALL 
-+ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
-+{
-+	m_xProps->setPropertyValue( sSourceName, _value );
-+}
-+
-+// see Value
-+
-+::rtl::OUString SAL_CALL 
-+ScVbaComboBox::getText() throw (uno::RuntimeException)
-+{
-+	rtl::OUString result;
-+	getValue() >>= result;
-+	return result;
-+}
-+
-+void SAL_CALL 
-+ScVbaComboBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
++ScVbaLabel::getValue() throw (css::uno::RuntimeException)
 +{
-+	setValue( uno::makeAny( _text ) ); // seems the same
++    return uno::makeAny( getCaption() );
 +}
 +
-+// Methods
 +void SAL_CALL 
-+ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
++ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+	mpListHelper->AddItem( pvargItem, pvargIndex );
-+}
-+
-+void SAL_CALL 
-+ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
-+	{
-+	mpListHelper->removeItem( index );
++    rtl::OUString sCaption;
++    _value >>= sCaption;
++    setCaption( sCaption ); 
 +}
 +
-+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)
-+		{
-+	return mpListHelper->getListCount();
-+		}
-+		
-+uno::Any SAL_CALL 
-+ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
-+		{
-+	return mpListHelper->List( pvargIndex, pvarColumn );
-+		}
 +
 +rtl::OUString& 
-+ScVbaComboBox::getServiceImplName()
++ScVbaLabel::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaLabel") );
 +	return sImplName;
-+	}
++}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaComboBox::getServiceNames()
++ScVbaLabel::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ComboBox" ) );
-+}
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) );
++	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbacombobox.hxx vbahelper/source/msforms/vbacombobox.hxx
+diff --git vbahelper/source/msforms/vbalabel.hxx vbahelper/source/msforms/vbalabel.hxx
 new file mode 100644
-index 0000000..d14a19f
+index 0000000..3afd652
 --- /dev/null
-+++ vbahelper/source/msforms/vbacombobox.hxx
-@@ -0,0 +1,80 @@
++++ vbahelper/source/msforms/vbalabel.hxx
+@@ -0,0 +1,56 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -11157,8 +24822,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbacombobox.hxx,v $
-+ * $Revision: 1.4 $
++ * $RCSfile: vbalabel.hxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -11178,63 +24843,39 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_COMBOBOX_HXX
-+#define SC_VBA_COMBOBOX_HXX
-+#include <cppuhelper/implbase2.hxx>
-+#include <com/sun/star/uno/XComponentContext.hpp>
-+#include <com/sun/star/beans/XPropertySet.hpp>
-+#include <com/sun/star/script/XDefaultProperty.hpp>
-+#include <ooo/vba/msforms/XComboBox.hpp>
-+#include <comphelper/proparrhlp.hxx>
-+#include <comphelper/propertycontainer.hxx>
-+#include <com/sun/star/beans/PropertyAttribute.hpp>
++#ifndef SC_VBA_LABEL_HXX
++#define SC_VBA_LABEL_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XLabel.hpp>
 +
 +#include "vbacontrol.hxx"
-+#include "vbalistcontrolhelper.hxx"
 +#include <vbahelper/vbahelper.hxx>
++#include <cppuhelper/implbase2.hxx>
 +
-+typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE;
-+class ScVbaComboBox : public ComboBoxImpl_BASE
-+{		
-+	std::auto_ptr< ListControlHelper > mpListHelper;
-+	rtl::OUString sSourceName; 
-+	rtl::OUString msDftPropName;
-+	bool mbDialogType;
++typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XLabel, css::script::XDefaultProperty  > LabelImpl_BASE;
 +
++class ScVbaLabel : public LabelImpl_BASE
++{
 +public:
-+	ScVbaComboBox( 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, bool bDialogType = false );
-+
-+	// Attributes
-+	virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException);
-+	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
-+	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) 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 ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
-+	virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
-+
-+	// Methods
-+	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);
-+	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
-+	// XControl
-+    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
-+
-+	// XDefaultProperty
-+        ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
-+	//XHelperInterface
-+	virtual rtl::OUString& getServiceImplName();
-+	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    ScVbaLabel( 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);
++    virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    // XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
-+
-+#endif //
-diff --git vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/msforms/vbacontrol.cxx
++#endif //SC_VBA_LABEL_HXX
+diff --git vbahelper/source/msforms/vbalistbox.cxx vbahelper/source/msforms/vbalistbox.cxx
 new file mode 100644
-index 0000000..e005ab5
+index 0000000..39eb251
 --- /dev/null
-+++ vbahelper/source/msforms/vbacontrol.cxx
-@@ -0,0 +1,520 @@
++++ vbahelper/source/msforms/vbalistbox.cxx
+@@ -0,0 +1,288 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -11243,8 +24884,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile: vbacontrol.cxx,v $
-+ * $Revision: 1.3 $
++ * $RCSfile: vbalistbox.cxx,v $
++ * $Revision: 1.4 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -11264,927 +24905,910 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include <com/sun/star/form/FormComponentType.hpp>
-+#include <com/sun/star/awt/XControlModel.hpp>
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/awt/XWindow2.hpp>
-+#include <com/sun/star/lang/XEventListener.hpp>
-+#include <com/sun/star/drawing/XShape.hpp>
-+#include <com/sun/star/drawing/XControlShape.hpp>
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/frame/XModel.hpp>
-+#include <com/sun/star/view/XControlAccess.hpp>
-+#include <com/sun/star/container/XChild.hpp>
-+#include <com/sun/star/form/binding/XBindableValue.hpp>
-+#include <com/sun/star/form/binding/XListEntrySink.hpp>
-+#include <com/sun/star/table/CellAddress.hpp>
-+#include <com/sun/star/table/CellRangeAddress.hpp>
-+#include <ooo/vba/XControlProvider.hpp>
-+#ifdef VBA_OOBUILD_HACK
-+#include <svtools/bindablecontrolhelper.hxx>
-+#endif
-+#include"vbacontrol.hxx"
-+#include"vbacombobox.hxx"
-+#include "vbabutton.hxx"
-+#include "vbalabel.hxx"
-+#include "vbatextbox.hxx"
-+#include "vbaradiobutton.hxx"
-+#include "vbalistbox.hxx"
-+#include "vbatogglebutton.hxx"
-+#include "vbacheckbox.hxx"
-+#include "vbaframe.hxx"
-+#include "vbascrollbar.hxx"
-+#include "vbaprogressbar.hxx"
-+#include "vbamultipage.hxx"
-+#include "vbaspinbutton.hxx"
-+#include "vbaimage.hxx"
-+#include <vbahelper/helperdecl.hxx>
++#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
 +
++#include "vbalistbox.hxx"
++#include <vector>
++#include <comphelper/anytostring.hxx>
++#include <com/sun/star/script/ArrayWrapper.hpp>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+uno::Reference< css::awt::XWindowPeer > 
-+ScVbaControl::getWindowPeer() throw (uno::RuntimeException)
-+{
-+    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
-+
-+    uno::Reference< awt::XControlModel > xControlModel;
-+    uno::Reference< css::awt::XWindowPeer >  xWinPeer;
-+    if ( !xControlShape.is() ) 
-+    { 
-+        // would seem to be a Userform control
-+        uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW );
-+        xWinPeer =  xControl->getPeer();
-+	return xWinPeer;
-+    }
-+    // form control
-+    xControlModel.set( xControlShape->getControl(), uno::UNO_QUERY_THROW );
-+
-+    uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
-+    try
-+    {
-+        uno::Reference< awt::XControl > xControl( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY );
-+        xWinPeer =  xControl->getPeer();
-+    }
-+    catch( uno::Exception )
-+    {
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ),
-+                uno::Reference< uno::XInterface >() );
-+    }
-+    return xWinPeer;
-+}
++const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
++const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
++const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
 +
-+//ScVbaControlListener
-+class ScVbaControlListener: public cppu::WeakImplHelper1< lang::XEventListener >
-+{
-+private:
-+    ScVbaControl *pControl;
-+public:
-+    ScVbaControlListener( ScVbaControl *pTmpControl );
-+    virtual ~ScVbaControlListener();
-+    virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) throw( uno::RuntimeException );
-+};
 +
-+ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl )
++ScVbaListBox::ScVbaListBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ListBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
++    mpListHelper.reset( new ListControlHelper( m_xProps ) );
 +}
 +
-+ScVbaControlListener::~ScVbaControlListener()
++// Attributes
++void SAL_CALL 
++ScVbaListBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
 +{
++    sal_Int32 nIndex = 0;
++    _value >>= nIndex;
++    Selected( nIndex );
 +}
 +
-+void SAL_CALL
-+ScVbaControlListener::disposing( const lang::EventObject& ) throw( uno::RuntimeException )
++uno::Any SAL_CALL 
++ScVbaListBox::getListIndex() throw (uno::RuntimeException)
 +{
-+    if( pControl )
-+    {
-+        pControl->removeResouce();
-+        pControl = NULL;
-+    }
++    uno::Sequence< sal_Int16 > sSelection;
++    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection;
++    if ( sSelection.getLength() == 0 )
++        return uno::Any( sal_Int32( -1 ) );
++    return uno::Any( sSelection[ 0 ] );
 +}
 +
-+//ScVbaControl
-+
-+ScVbaControl::ScVbaControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl,  const css::uno::Reference< css::frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ControlImpl_BASE( xParent, xContext ),  m_xControl( xControl ), m_xModel( xModel )
++uno::Any SAL_CALL 
++ScVbaListBox::getValue() throw (uno::RuntimeException)
 +{
-+    //add listener
-+    m_xEventListener.set( new ScVbaControlListener( this ) );
-+    setGeometryHelper( pGeomHelper );
-+    uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
-+    xComponent->addEventListener( m_xEventListener );
-+   
-+    //init m_xProps
-+    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ;
-+    uno::Reference< awt::XControl> xUserFormControl( m_xControl, uno::UNO_QUERY ) ;
-+    if ( xControlShape.is() ) // form control
-+        m_xProps.set( xControlShape->getControl(), uno::UNO_QUERY_THROW );
-+    else if ( xUserFormControl.is() ) // userform control
-+        m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW );
++    uno::Sequence< sal_Int16 > sSelection;
++    uno::Sequence< rtl::OUString > sItems;
++    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection;
++    m_xProps->getPropertyValue( ITEMS ) >>= sItems;
++    if( getMultiSelect() )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
++    uno::Any aRet;
++    if ( sSelection.getLength() )
++        aRet = uno::makeAny( sItems[ sSelection[ 0 ] ] ); 
++    return aRet;
 +}
 +
-+ScVbaControl::~ScVbaControl()
++void SAL_CALL 
++ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
 +{
-+    if( m_xControl.is() )
++    if( getMultiSelect() )
++    {	
++        throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
++    }
++    rtl::OUString sValue = getAnyAsString( _value );
++    uno::Sequence< rtl::OUString > sList;
++    m_xProps->getPropertyValue( ITEMS ) >>= sList;
++    uno::Sequence< sal_Int16 > nList;
++    sal_Int16 nLength = static_cast<sal_Int16>( sList.getLength() );
++    sal_Int16 nValue = -1;
++    sal_Int16 i = 0;
++    for( i = 0; i < nLength; i++ )
 +    {
-+        uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
-+        xComponent->removeEventListener( m_xEventListener );
++        if( sList[i].equals( sValue ) )
++        {
++            nValue = i; 
++            break;
++        }
 +    }
-+}
-+
-+void 
-+ScVbaControl::setGeometryHelper( AbstractGeometryAttributes* pHelper )
-+{
-+    mpGeometryHelper.reset( pHelper );
-+}
-+
-+void ScVbaControl::removeResouce() throw( uno::RuntimeException )
-+{
-+    uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
-+    xComponent->removeEventListener( m_xEventListener );
-+    m_xControl= NULL;
-+    m_xProps = NULL;
-+}
++    if( nValue == -1 )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
 +
-+//In design model has different behavior
-+sal_Bool SAL_CALL ScVbaControl::getEnabled() throw (uno::RuntimeException)
-+{
-+    uno::Any aValue = m_xProps->getPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ) );
-+    sal_Bool bRet = false;
-+    aValue >>= bRet;
-+    return bRet;
++    uno::Sequence< sal_Int16 > nSelectedIndices(1);
++    nSelectedIndices[ 0 ] = nValue;
++    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); 
++    m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); 
 +}
 +
-+void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeException)
++::rtl::OUString SAL_CALL 
++ScVbaListBox::getText() throw (uno::RuntimeException)
 +{
-+    uno::Any aValue( bVisible );
-+    m_xProps->setPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ), aValue);
-+
++	rtl::OUString result;
++	getValue() >>= result;
++	return result;
 +}
 +
-+sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaListBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
 +{
-+    uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
-+    return xWindow2->isVisible();
++	setValue( uno::makeAny( _text ) ); // seems the same
 +}
 +
-+void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException)
++sal_Bool SAL_CALL 
++ScVbaListBox::getMultiSelect() throw (css::uno::RuntimeException)
 +{
-+    uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
-+    xWindow2->setVisible( bVisible );
++    sal_Bool bMultiSelect = sal_False;
++    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ) ) >>= bMultiSelect;
++    return bMultiSelect;
 +}
-+double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException)
++
++void SAL_CALL 
++ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException)
 +{
-+    return mpGeometryHelper->getHeight();
++    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( _multiselect ) );
 +}
-+void SAL_CALL ScVbaControl::setHeight( double _height ) throw (uno::RuntimeException)
++
++css::uno::Any SAL_CALL 
++ScVbaListBox::Selected( sal_Int32 index ) throw (css::uno::RuntimeException)
 +{
-+    mpGeometryHelper->setHeight( _height );
++    uno::Sequence< rtl::OUString > sList;
++    m_xProps->getPropertyValue( ITEMS ) >>= sList;
++    sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
++    // no choice but to do a horror cast as internally
++    // the indices are but sal_Int16 
++    sal_Int16 nIndex = static_cast< sal_Int16 >( index );
++    if( nIndex < 0 || nIndex >= nLength )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Error Number." ), uno::Reference< uno::XInterface >() );
++    m_nIndex = nIndex;
++    return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
 +}
 +
-+double SAL_CALL ScVbaControl::getWidth() throw (uno::RuntimeException)
++// Methods
++void SAL_CALL 
++ScVbaListBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
 +{
-+    return mpGeometryHelper->getWidth();
++	mpListHelper->AddItem( pvargItem, pvargIndex );
++		}
++
++void SAL_CALL 
++ScVbaListBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
++{
++	mpListHelper->removeItem( index );
 +}
-+void SAL_CALL ScVbaControl::setWidth( double _width ) throw (uno::RuntimeException)
++
++void SAL_CALL 
++ScVbaListBox::Clear(  ) throw (uno::RuntimeException)
 +{
-+    mpGeometryHelper->setWidth( _width );
++	mpListHelper->Clear();
 +}
 +
-+double SAL_CALL
-+ScVbaControl::getLeft() throw (uno::RuntimeException)
++// this is called when something like the following vba code is used
++// to set the selected state of particular entries in the Listbox
++// ListBox1.Selected( 3 ) = false
++//PropListener
++void 
++ScVbaListBox::setValueEvent( const uno::Any& value )
 +{
-+    return mpGeometryHelper->getLeft();
++    sal_Bool bValue = sal_False;
++    if( !(value >>= bValue) )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Invalid type\n. need boolean." ), uno::Reference< uno::XInterface >() );
++    uno::Sequence< sal_Int16 > nList;
++    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= nList;
++    sal_Int16 nLength = static_cast<sal_Int16>( nList.getLength() );
++    sal_Int16 nIndex = m_nIndex;
++    for( sal_Int16 i = 0; i < nLength; i++ )
++    {
++        if( nList[i] == nIndex )
++        {
++            if( bValue )
++                return;
++            else
++            {
++                for( ; i < nLength - 1; i++ )
++                {
++                    nList[i] = nList[i + 1];
++                }
++                nList.realloc( nLength - 1 );
++                //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
++		m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) );
++                return;
++            }
++        }
++    }
++    if( bValue )
++    {
++        if( getMultiSelect() )
++        {
++            nList.realloc( nLength + 1 );
++            nList[nLength] = nIndex;
++        }
++        else
++        {
++            nList.realloc( 1 );
++            nList[0] = nIndex;
++        }
++        m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
++    }
 +}
 +
-+void SAL_CALL
-+ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException)
++// this is called when something like the following vba code is used
++// to determine the selected state of particular entries in the Listbox
++// msgbox ListBox1.Selected( 3 )
++
++css::uno::Any 
++ScVbaListBox::getValueEvent()
 +{
-+    mpGeometryHelper->setLeft( _left );
++    uno::Sequence< sal_Int16 > nList;
++    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedItems" ) ) ) >>= nList;
++    sal_Int32 nLength = nList.getLength();
++    sal_Int32 nIndex = m_nIndex;
++    
++    for( sal_Int32 i = 0; i < nLength; i++ )
++    {
++        if( nList[i] == nIndex )
++            return uno::makeAny( sal_True );
++    }
 +
++    return uno::makeAny( sal_False );
 +}
 +
-+double SAL_CALL
-+ScVbaControl::getTop() throw (uno::RuntimeException)
++void SAL_CALL
++ScVbaListBox::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
 +{
-+    return mpGeometryHelper->getTop();
++	ScVbaControl::setRowSource( _rowsource );
++	mpListHelper->setRowSource( _rowsource );
 +}
 +
-+void SAL_CALL
-+ScVbaControl::setTop( double _top ) throw (uno::RuntimeException)
++sal_Int32 SAL_CALL
++ScVbaListBox::getListCount() throw (uno::RuntimeException)
 +{
-+    mpGeometryHelper->setTop( _top );
++	return mpListHelper->getListCount();
 +}
 +
-+uno::Reference< uno::XInterface > SAL_CALL
-+ScVbaControl::getObject() throw (uno::RuntimeException)
++uno::Any SAL_CALL 
++ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
 +{
-+	uno::Reference< msforms::XControl > xRet( this );
-+	return xRet;
++	return mpListHelper->List( pvargIndex, pvarColumn );
 +}
 +
-+void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) 
++rtl::OUString& 
++ScVbaListBox::getServiceImplName()
 +{
-+    uno::Reference< awt::XWindow > xWin( m_xControl, uno::UNO_QUERY_THROW );
-+    xWin->setFocus();
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaListBox") );
++	return sImplName;
 +}
 +
-+rtl::OUString SAL_CALL 
-+ScVbaControl::getControlSource() throw (uno::RuntimeException)
++uno::Sequence< rtl::OUString > 
++ScVbaListBox::getServiceNames()
 +{
-+// #FIXME I *hate* having these upstream differences
-+// but this is necessary until I manage to upstream other
-+// dependant parts
-+#ifdef VBA_OOBUILD_HACK
-+	rtl::OUString sControlSource;
-+	uno::Reference< form::binding::XBindableValue > xBindable( m_xProps, uno::UNO_QUERY );
-+	if ( xBindable.is() )
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
 +	{
-+		try
-+		{
-+			uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW );
-+			uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellAddressConversion" ))), uno::UNO_QUERY );
-+			uno::Reference< beans::XPropertySet > xProps( xBindable->getValueBinding(), uno::UNO_QUERY_THROW );
-+			table::CellAddress aAddress;
-+			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BoundCell") ) ) >>= aAddress;
-+			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address") ), uno::makeAny( aAddress ) );
-+                	xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sControlSource;
-+}
-+		catch( uno::Exception& )
-+		{
-+		}	
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ScVbaListBox" ) );
 +	}
-+	return sControlSource;
-+#else
-+	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getControlSource not supported") ), uno::Reference< uno::XInterface >()); // not supported
-+#endif
++	return aServiceNames;
 +}
+diff --git vbahelper/source/msforms/vbalistbox.hxx vbahelper/source/msforms/vbalistbox.hxx
+new file mode 100644
+index 0000000..93e80a3
+--- /dev/null
++++ vbahelper/source/msforms/vbalistbox.hxx
+@@ -0,0 +1,90 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbalistbox.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 SC_VBA_LISTBOX_HXX
++#define SC_VBA_LISTBOX_HXX
++#include <cppuhelper/implbase2.hxx>
++#include <com/sun/star/uno/XComponentContext.hpp>
++#include <com/sun/star/script/XDefaultProperty.hpp>
++#include <ooo/vba/msforms/XListBox.hpp>
++#include <com/sun/star/beans/PropertyAttribute.hpp>
++
++#include "vbacontrol.hxx"
++#include <vbahelper/vbapropvalue.hxx>
++#include "vbalistcontrolhelper.hxx"
++#include <vbahelper/vbahelper.hxx>
++
++typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XListBox, css::script::XDefaultProperty > ListBoxImpl_BASE;
++class ScVbaListBox : public ListBoxImpl_BASE
++    ,public PropListener
++{		
++	std::auto_ptr< ListControlHelper > mpListHelper;
++	rtl::OUString sSourceName; 
++	rtl::OUString msDftPropName;
++
++    sal_Int16 m_nIndex;
++	
++public:
++	ScVbaListBox( 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 getListIndex() throw (css::uno::RuntimeException);
++	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
++	virtual ::sal_Int32 SAL_CALL getListCount() 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 rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
++	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);
++
++	// Methods
++	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);
++	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
++	// XControl
++    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
 +
-+void SAL_CALL 
-+ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno::RuntimeException)
-+{
-+#ifdef VBA_OOBUILD_HACK
-+    rtl::OUString sEmpty;
-+    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty );
-+#else
-+	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setControlSource not supported ") ).concat( _controlsource ), uno::Reference< uno::XInterface >()); // not supported
-+#endif
-+}
++	// XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++    
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();    
 +
-+rtl::OUString SAL_CALL 
-+ScVbaControl::getRowSource() throw (uno::RuntimeException)
-+    {
-+#ifdef VBA_OOBUILD_HACK
-+	rtl::OUString sRowSource;
-+	uno::Reference< form::binding::XListEntrySink > xListSink( m_xProps, uno::UNO_QUERY );
-+	if ( xListSink.is() )
-+    {
-+		try
-+		{
-+			uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW );
-+			uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeAddressConversion" ))), uno::UNO_QUERY );
++    //PropListener
++    virtual void setValueEvent( const css::uno::Any& value );
++    virtual css::uno::Any getValueEvent();
 +
-+			uno::Reference< beans::XPropertySet > xProps( xListSink->getListEntrySource(), uno::UNO_QUERY_THROW );
-+			table::CellRangeAddress aAddress;
-+			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellRange") ) ) >>= aAddress;
-+			xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address")), uno::makeAny( aAddress ) );
-+			xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sRowSource;
-+    }
-+		catch( uno::Exception& )
-+		{
-+}
-+	}
-+	return sRowSource;
-+#else
-+	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getRowSource not supported") ), uno::Reference< uno::XInterface >()); // not supported
-+#endif
-+}
++
++};
++
++#endif //
+diff --git vbahelper/source/msforms/vbalistcontrolhelper.cxx vbahelper/source/msforms/vbalistcontrolhelper.cxx
+new file mode 100644
+index 0000000..8582821
+--- /dev/null
++++ vbahelper/source/msforms/vbalistcontrolhelper.cxx
+@@ -0,0 +1,146 @@
++#include <vbalistcontrolhelper.hxx>
++#include <vector>
++
++using namespace com::sun::star;
++using namespace ooo::vba;
++
++const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
 +
 +void SAL_CALL 
-+ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
++ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
 +{
-+#ifdef VBA_OOBUILD_HACK
-+    rtl::OUString sEmpty;
-+    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, sEmpty, _rowsource );
-+#else
-+	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setRowSource not supported ") ).concat( _rowsource ), uno::Reference< uno::XInterface >()); // not supported
-+#endif
-+}
++	if ( pvargItem.hasValue()  )
++	{
++		uno::Sequence< rtl::OUString > sList;
++		m_xProps->getPropertyValue( ITEMS ) >>= sList;
 +
-+rtl::OUString SAL_CALL 
-+ScVbaControl::getName() throw (uno::RuntimeException)
-+{
-+	rtl::OUString sName;
-+	m_xProps->getPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
-+	return sName;
++		sal_Int32 nIndex = sList.getLength();
 +
-+}
++		if ( pvargIndex.hasValue() )
++			pvargIndex >>= nIndex;
 +
-+void SAL_CALL
-+ScVbaControl::setName( const rtl::OUString& _name ) throw (uno::RuntimeException)
-+{
-+	m_xProps->setPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), uno::makeAny( _name ) );
-+    }
-+//ScVbaControlFactory
++		rtl::OUString sString = getAnyAsString( pvargItem );
 +
-+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 )
-+{
-+}
++		// if no index specified or item is to be appended to end of 
++		// list just realloc the array and set the last item
++		if ( nIndex  == sList.getLength() )
++		{
++			sal_Int32 nOldSize = sList.getLength();
++			sList.realloc( nOldSize + 1 );
++			sList[ nOldSize ] = sString; 
++		}
++		else
++		{
++			// just copy those elements above the one to be inserted
++			std::vector< rtl::OUString > sVec;
++			// reserve just the amount we need to copy
++			sVec.reserve( sList.getLength() - nIndex );
 +
-+ScVbaControl* ScVbaControlFactory::createControl()  throw (uno::RuntimeException)
-+{
-+    return createControl( m_xModel );
-+}
-+ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent )  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 );
-+    
-+}
++			// point at first element to copy
++			rtl::OUString* pString = sList.getArray() + nIndex;
++			const rtl::OUString* pEndString = sList.getArray() + sList.getLength();
++			// insert the new element
++			sVec.push_back( sString );
++			// copy elements	
++			for ( ; pString != pEndString; ++pString )
++				sVec.push_back( *pString );
++		
++			sList.realloc(  sList.getLength() + 1 );
 +
-+ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape,  const uno::Reference< uno::XInterface >& /*xParent*/ )  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
-+    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 ) ) );
-+        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 ) ) );
-+        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 ) ) );
-+        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 ) ) );
-+        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 ) ) );
-+        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 ) ) );
-+        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 ) ) );
-+        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 >() );
-+    }
-+}
++			// point at first element to be overwritten
++			pString = sList.getArray() + nIndex;
++			pEndString = sList.getArray() + sList.getLength();
++			std::vector< rtl::OUString >::iterator it = sVec.begin();
++			for ( ; pString != pEndString; ++pString, ++it)
++				*pString = *it;	
++			//
++		}
 +
-+ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl,  const uno::Reference< uno::XInterface >& xParent  )  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< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
-+    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 ) );	
-+    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 ) );	
-+    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 );
-+    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 ) );
-+        else
-+            pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
-+    }
-+    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 );
-+    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 ) );
-+    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 ) );
-+    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 ) );
-+    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 ) );
-+    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 ) );
-+    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 ) );
-+    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 );
-+    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 ) );
-+    else
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() );
-+    return pControl;
++		m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) );
++		
++	}
 +}
 +
-+rtl::OUString& 
-+ScVbaControl::getServiceImplName()
++void SAL_CALL 
++ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControl") );
-+	return sImplName;
++    sal_Int32 nIndex = 0;
++    // for int index
++	if ( index >>= nIndex  )
++	{
++		uno::Sequence< rtl::OUString > sList;
++		m_xProps->getPropertyValue( ITEMS ) >>= sList;
++        if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) )
++            throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid index" ), uno::Reference< uno::XInterface > () );
++        if( sList.hasElements() )
++        {
++            if( sList.getLength() == 1 )
++            {
++                Clear();
++                return;
++            }
++            for( sal_Int32 i = nIndex; i < ( sList.getLength()-1 ); i++ )
++            {
++                sList[i] = sList[i+1];
++            }
++			sList.realloc(  sList.getLength() - 1 );
++		}
++
++		m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) );
++	}
 +}
 +
-+uno::Sequence< rtl::OUString > 
-+ScVbaControl::getServiceNames()
++void SAL_CALL 
++ListControlHelper::Clear(  ) 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.excel.Control" ) );
-+    }
-+	return aServiceNames;
++	// urk, setValue doesn't seem to work !!
++	//setValue( uno::makeAny( sal_Int16() ) );
++	m_xProps->setPropertyValue( ITEMS, uno::makeAny( uno::Sequence< rtl::OUString >() ) );
 +}
 +
-+
-+
-+typedef cppu::WeakImplHelper1< XControlProvider > ControlProvider_BASE;
-+class ControlProviderImpl : public ControlProvider_BASE
-+{
-+    uno::Reference< uno::XComponentContext > m_xCtx;
-+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 
-+ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException)
++void SAL_CALL
++ListControlHelper::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
 +{
-+	uno::Reference< msforms::XControl > xControlToReturn;
-+	if ( xControlShape.is() ) 
-+	{
-+		ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner );
-+		xControlToReturn.set( controlFactory.createControl( xDocOwner ) );
-+	}
-+	return xControlToReturn;
-+		
++	if ( _rowsource.getLength() == 0 )
++		Clear();
 +}
-+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)
++
++sal_Int32 SAL_CALL
++ListControlHelper::getListCount() 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;
++    uno::Sequence< rtl::OUString > sList;
++    m_xProps->getPropertyValue( ITEMS ) >>= sList;
++    return sList.getLength();
 +}
 +
-+namespace controlprovider
++uno::Any SAL_CALL 
++ListControlHelper::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
 +{
-+namespace sdecl = comphelper::service_decl;
-+sdecl::class_<ControlProviderImpl, sdecl::with_args<false> > serviceImpl;
-+extern sdecl::ServiceDecl const serviceDecl(
-+    serviceImpl,
-+    "ControlProviderImpl",
-+    "ooo.vba.ControlProvider" );
++    uno::Sequence< rtl::OUString > sList;
++    m_xProps->getPropertyValue( ITEMS ) >>= sList;
++    sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
++    uno::Any aRet;
++    if ( pvargIndex.hasValue() )
++    {
++        sal_Int16 nIndex = -1;
++        pvargIndex >>= nIndex;
++        if( nIndex < 0 || nIndex >= nLength )
++            throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Bad row Index" ), uno::Reference< uno::XInterface >() );       
++        aRet <<= sList[ nIndex ];
++    }
++    else if ( pvarColumn.hasValue() ) // pvarColumn on its own would be bad
++            throw uno::RuntimeException( rtl::OUString::createFromAscii(
++                    "Bad column Index" ), uno::Reference< uno::XInterface >() );       
++    else // List() ( e.g. no args )
++    {
++        uno::Sequence< uno::Sequence< rtl::OUString > > sReturnArray( nLength );
++        for ( sal_Int32 i = 0; i < nLength; ++i )
++        {
++            sReturnArray[ i ].realloc( 10 );
++            sReturnArray[ i ][ 0 ] = sList[ i ];
++        }        
++        aRet = uno::makeAny( sReturnArray );
++    }
++    return aRet;
 +}
+diff --git vbahelper/source/msforms/vbalistcontrolhelper.hxx vbahelper/source/msforms/vbalistcontrolhelper.hxx
+new file mode 100644
+index 0000000..8bdee82
+--- /dev/null
++++ vbahelper/source/msforms/vbalistcontrolhelper.hxx
+@@ -0,0 +1,20 @@
++#ifndef SC_VBA_LISTCONTROLHELPER
++#define SC_VBA_LISTCONTROLHELPER
 +
++#include <vbahelper/vbahelper.hxx>
 +
-diff --git vbahelper/source/msforms/vbacontrol.hxx vbahelper/source/msforms/vbacontrol.hxx
++class ListControlHelper
++{
++	css::uno::Reference< css::beans::XPropertySet > m_xProps;
++
++public:
++	ListControlHelper( const css::uno::Reference< css::beans::XPropertySet >& rxControl ) : m_xProps( rxControl ){}
++	virtual ~ListControlHelper() {}
++	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 setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
++	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
++	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
++	virtual void SAL_CALL Clear(  ) throw (css::uno::RuntimeException);
++};
++#endif
+diff --git vbahelper/source/msforms/vbamultipage.cxx vbahelper/source/msforms/vbamultipage.cxx
 new file mode 100644
-index 0000000..e7593e8
+index 0000000..118e005
 --- /dev/null
-+++ vbahelper/source/msforms/vbacontrol.hxx
-@@ -0,0 +1,112 @@
++++ vbahelper/source/msforms/vbamultipage.cxx
+@@ -0,0 +1,132 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbacontrol.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_CONTROL_HXX
-+#define SC_VBA_CONTROL_HXX
-+
-+#include <cppuhelper/implbase1.hxx>
-+#include <com/sun/star/beans/XPropertySet.hpp>
-+#include <com/sun/star/uno/XComponentContext.hpp>
-+#include <com/sun/star/script/XDefaultProperty.hpp>
-+#include <com/sun/star/drawing/XControlShape.hpp>
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/awt/XWindowPeer.hpp>
-+#include <ooo/vba/msforms/XControl.hpp>
++#include "vbamultipage.hxx"
++#include <ooo/vba/XCollection.hpp>
++#include "vbapages.hxx"
++#include <vector>
 +
-+#include <vbahelper/vbahelper.hxx>
-+#include <vbahelper/vbahelperinterface.hxx>
-+#include <memory>
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+//typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE;
-+typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE;
++// uno servicename com.sun.star.awt.UnoControlProgressBarMode
++const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
++const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") );
++const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") );
 +
-+class ScVbaControl : public ControlImpl_BASE
++typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base;
++class PagesImpl : public PagesImpl_Base
 +{
-+private:
-+    com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener;
-+protected:
-+    std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper;
-+    css::uno::Reference< css::beans::XPropertySet > m_xProps;
-+    css::uno::Reference< css::uno::XInterface > m_xControl;
-+    css::uno::Reference< css::frame::XModel > m_xModel;
-+
-+    virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
++	sal_Int32 mnPages;
 +public:
-+    ScVbaControl( 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* pHelper );
-+    virtual ~ScVbaControl();
-+    // This class will own the helper, so make sure it is allocated from 
-+    // the heap
-+    void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper );
-+    // XControl
-+    virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException);
-+    virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
-+    virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
-+    virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
-+    virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
-+    virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL SetFocus(  ) throw (css::uno::RuntimeException);
-+
-+    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
-+    virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource ) throw (css::uno::RuntimeException);
-+    virtual rtl::OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
-+    virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setName( const rtl::OUString& _name ) 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
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++	PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {}
++	virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) { return mnPages; }
++	virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, ::uno::RuntimeException)
++	{
++		if ( Index < 0 || Index > mnPages )
++			throw lang::IndexOutOfBoundsException();
++		return uno::makeAny( uno::Reference< uno::XInterface >() );
++	}
++	// XElementAccess
++	virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
++	{
++		// no Pages object yet #FIXME
++		//return msforms::XPage::static_type(0);
++		return uno::XInterface::static_type(0);
++	}
++	virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
++	{
++		return ( mnPages > 0 );
++	}
 +};
++uno::Reference< container::XIndexAccess > 
++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 )
++{
++    mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
++    // set dialog step to value of multipage pseudo model
++    setValue(getValue());
++}
 +
-+class ScVbaControlFactory
++// Attributes
++sal_Int32 SAL_CALL 
++ScVbaMultiPage::getValue() throw (css::uno::RuntimeException)
 +{
-+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()  throw ( css::uno::RuntimeException );
-+    ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent )  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;
-+};
++    sal_Int32 nValue = 0;
++    m_xProps->getPropertyValue( SVALUE ) >>= nValue;
++    return nValue;
++}
 +
-+#endif//SC_VBA_CONTROL_HXX
-diff --git vbahelper/source/msforms/vbacontrols.cxx vbahelper/source/msforms/vbacontrols.cxx
++void SAL_CALL 
++ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException)
++{
++    // track change in dialog ( dialog value is 1 based, 0 is a special value )
++    m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) );
++    mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) );
++}
++
++
++rtl::OUString& 
++ScVbaMultiPage::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMultiPage") );
++	return sImplName;
++}
++
++uno::Any SAL_CALL 
++ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException)
++{
++	sal_Int32 nValue = 0;
++	m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue;
++	uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) );
++	if ( !index.hasValue() )
++		return uno::makeAny( xColl );
++	return xColl->Item( uno::makeAny( index ), uno::Any() );
++}
++
++uno::Sequence< rtl::OUString > 
++ScVbaMultiPage::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.MultiPage" ) );
++	}
++	return aServiceNames;
++}
+diff --git vbahelper/source/msforms/vbamultipage.hxx vbahelper/source/msforms/vbamultipage.hxx
 new file mode 100644
-index 0000000..82fdfc0
+index 0000000..b0214f6
 --- /dev/null
-+++ vbahelper/source/msforms/vbacontrols.cxx
-@@ -0,0 +1,232 @@
++++ vbahelper/source/msforms/vbamultipage.hxx
+@@ -0,0 +1,65 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile$
-+ * $Revision$
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
++#ifndef SC_VBA_MULTIPAGE_HXX
++#define SC_VBA_MULTIPAGE_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XMultiPage.hpp>
++#include <com/sun/star/container/XIndexAccess.hpp>
 +
-+#include "vbacontrols.hxx"
-+#include <cppuhelper/implbase2.hxx>
-+#include <com/sun/star/awt/XControlContainer.hpp>
-+#include <ooo/vba//XControlProvider.hpp>
-+#include <hash_map>
-+
-+using namespace com::sun::star;
-+using namespace ooo::vba;
-+
-+
-+typedef ::cppu::WeakImplHelper2< container::XNameAccess, container::XIndexAccess > ArrayWrapImpl;
-+
-+typedef  std::hash_map< rtl::OUString, sal_Int32, ::rtl::OUStringHash,
-+    ::std::equal_to< ::rtl::OUString >  > ControlIndexMap;
-+typedef  std::vector< uno::Reference< awt::XControl > > ControlVec;
-+
-+class ControlArrayWrapper : public ArrayWrapImpl
-+{
-+    uno::Reference< awt::XControlContainer > mxDialog;
-+    uno::Sequence< ::rtl::OUString > msNames;
-+    ControlVec mControls;
-+    ControlIndexMap mIndices;
-+
-+    rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl )
-+    {
-+        uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY );
-+        rtl::OUString sName;
-+        xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
-+        return sName;
-+    }
-+
-+public:
-+
-+    ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog )
-+    {
-+        mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
-+        uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls();
-+    
-+        msNames.realloc( sXControls.getLength() );
-+        for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i )
-+        {
-+            uno::Reference< awt::XControl > xCtrl = sXControls[ i ];
-+            msNames[ i ] = getControlName( xCtrl );
-+            mControls.push_back( xCtrl );
-+            mIndices[ msNames[ i ] ] = i;
-+        }
-+    }
-+    
-+    // XElementAccess
-+    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException)
-+    {
-+        return awt::XControl::static_type(0);
-+    }
-+    
-+    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException) 
-+    {
-+        return mControls.size();
-+    }
-+    
-+    // XNameAcess 
-+    virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
-+    {
-+        if ( !hasByName( aName ) )
-+            throw container::NoSuchElementException();
-+        return getByIndex( mIndices[ aName ] );
-+    }
-+    
-+    virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
-+    {
-+        return msNames;
-+    }
-+    
-+    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
-+    {
-+        ControlIndexMap::iterator it = mIndices.find( aName );
-+        return it != mIndices.end();
-+    }
-+    
-+    // XElementAccess
-+    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException)
-+    {
-+        return mControls.size();
-+    }
-+    
-+    virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
-+    {
-+        if ( Index < 0 || Index >= static_cast< sal_Int32 >( mControls.size() ) )
-+            throw lang::IndexOutOfBoundsException();
-+        return uno::makeAny( mControls[ Index ] );
-+    }
-+};
++#include "vbacontrol.hxx"
++#include <vbahelper/vbahelper.hxx>
++//#include <cppuhelper/implbase2.hxx>
++#include <cppuhelper/implbase1.hxx>
 +
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XMultiPage > MultiPageImpl_BASE;
 +
-+class ControlsEnumWrapper : public EnumerationHelper_BASE
++class ScVbaMultiPage : public MultiPageImpl_BASE
 +{
-+    uno::Reference<XHelperInterface > m_xParent;
-+    uno::Reference<uno::XComponentContext > m_xContext;
-+    uno::Reference<container::XIndexAccess > m_xIndexAccess;
-+    uno::Reference<awt::XControl > m_xDlg;
-+    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 ) {}
-+
-+    virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
-+    {
-+        return ( nIndex < m_xIndexAccess->getCount() );
-+    }
-+
-+    virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
-+    {
-+        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 ) );
-+            return uno::makeAny( xVBAControl );
-+        }
-+        throw container::NoSuchElementException();
-+    }
++    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 );
++   // Attributes
++    virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Pages( const css::uno::Any& index ) throw (css::uno::RuntimeException);
 +
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    // XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
++#endif //SC_VBA_LABEL_HXX
+diff --git vbahelper/source/msforms/vbapages.cxx vbahelper/source/msforms/vbapages.cxx
+new file mode 100644
+index 0000000..db28086
+--- /dev/null
++++ vbahelper/source/msforms/vbapages.cxx
+@@ -0,0 +1,80 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "vbapages.hxx"
 +
++using namespace ::ooo::vba;
++using namespace ::com::sun::star;
 +
-+uno::Reference<container::XIndexAccess >
-+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  ) )
++ScVbaPages::ScVbaPages( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPages ) throw( lang::IllegalArgumentException ) : ScVbaPages_BASE( xParent, xContext, xPages )
 +{
-+    mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
 +}
 +
-+uno::Reference< container::XEnumeration >
-+ScVbaControls::createEnumeration() throw (uno::RuntimeException)
++uno::Type SAL_CALL 
++ScVbaPages::getElementType() throw (uno::RuntimeException)
 +{
-+    uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) );
-+    if ( !xEnum.is() )
-+        throw uno::RuntimeException();
-+    return xEnum;
++	// return msforms::XPage::static_type(0); 
++	return uno::XInterface::static_type(0); 
 +}
 +
-+uno::Any
-+ScVbaControls::createCollectionObject( const css::uno::Any& aSource )
++uno::Any 
++ScVbaPages::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 );
++	return aSource;
 +}
 +
-+void SAL_CALL 
-+ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException)
++rtl::OUString& 
++ScVbaPages::getServiceImplName()
 +{
-+    uno::Reference< container::XEnumeration > xEnum( createEnumeration() );
-+    while ( xEnum->hasMoreElements() )
-+    {
-+        uno::Reference< msforms::XControl > xControl( xEnum->nextElement(), uno::UNO_QUERY_THROW );
-+        xControl->setLeft( xControl->getLeft() + cx );
-+        xControl->setTop( xControl->getTop() + cy ); 
-+    }
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPages") );
++	return sImplName;
 +}
 +
-+uno::Type
-+ScVbaControls::getElementType() throw (uno::RuntimeException)
-+{
-+    return ooo::vba::msforms::XControl::static_type(0);
-+}
-+rtl::OUString& 
-+ScVbaControls::getServiceImplName()
++uno::Reference< container::XEnumeration > SAL_CALL 
++ScVbaPages::createEnumeration() throw (uno::RuntimeException)
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") );
-+	return sImplName;
++	return uno::Reference< container::XEnumeration >();
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaControls::getServiceNames()
++ScVbaPages::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" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msform.Pages" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbacontrols.hxx vbahelper/source/msforms/vbacontrols.hxx
+diff --git vbahelper/source/msforms/vbapages.hxx vbahelper/source/msforms/vbapages.hxx
 new file mode 100644
-index 0000000..461c360
+index 0000000..c1755f5
 --- /dev/null
-+++ vbahelper/source/msforms/vbacontrols.hxx
-@@ -0,0 +1,62 @@
++++ vbahelper/source/msforms/vbapages.hxx
+@@ -0,0 +1,64 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile$
-+ * $Revision$
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_CONTROLS_HXX
-+#define SC_VBA_CONTROLS_HXX
++#ifndef SC_VBA_PAGES_HXX
++#define SC_VBA_PAGES_HXX
 +
++#include <ooo/vba/office/MsoShapeType.hpp>
++#include <com/sun/star/lang/XEventListener.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <ooo/vba/msforms/XPages.hpp>
++#include <cppuhelper/implbase2.hxx>
 +#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XControls.hpp>
-+#include <com/sun/star/awt/XControl.hpp>
 +
 +#include <vbahelper/vbacollectionimpl.hxx>
-+#include <vbahelper/vbahelper.hxx>
-+
-+typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE;
++typedef CollTestImplHelper< 
++ov::msforms::XPages > ScVbaPages_BASE;
 +
-+class ScVbaControls : public ControlsImpl_BASE
++class ScVbaPages : public ScVbaPages_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 );
-+    // XControls
-+     virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException);
-+    // XEnumerationAccess
++    ScVbaPages( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPages ) throw ( css::lang::IllegalArgumentException );
++    virtual ~ScVbaPages() {}
++        // XEnumerationAccess
 +    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
 +    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++     // ScVbaPages_BASE
++     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
 +
-+    // ScVbaCollectionBaseImpl
-+    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
-+    
 +};
-+#endif //SC_VBA_OLEOBJECTS_HXX
-+
-diff --git vbahelper/source/msforms/vbaframe.cxx vbahelper/source/msforms/vbaframe.cxx
++#endif//SC_VBA_SHAPE_HXX
+diff --git vbahelper/source/msforms/vbaprogressbar.cxx vbahelper/source/msforms/vbaprogressbar.cxx
 new file mode 100644
-index 0000000..b2827d0
+index 0000000..77f3eca
 --- /dev/null
-+++ vbahelper/source/msforms/vbaframe.cxx
-@@ -0,0 +1,93 @@
++++ vbahelper/source/msforms/vbaprogressbar.cxx
+@@ -0,0 +1,78 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -12219,71 +25843,56 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbaframe.hxx"
++#include "vbaprogressbar.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
++// uno servicename com.sun.star.awt.UnoControlProgressBarMode
++const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
 +
-+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 )
++ScVbaProgressBar::ScVbaProgressBar( 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 ) : ProgressBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
 +}
 +
 +// 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)
-+{
-+    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
-+}
-+
 +uno::Any SAL_CALL 
-+ScVbaFrame::getValue() throw (css::uno::RuntimeException)
++ScVbaProgressBar::getValue() throw (css::uno::RuntimeException)
 +{
-+    return uno::makeAny( getCaption() );
++    return m_xProps->getPropertyValue( SVALUE );
 +}
 +
 +void SAL_CALL 
-+ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaProgressBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+    rtl::OUString sCaption;
-+    _value >>= sCaption;
-+    setCaption( sCaption ); 
++    m_xProps->setPropertyValue( SVALUE,  _value );
 +}
 +
 +rtl::OUString& 
-+ScVbaFrame::getServiceImplName()
++ScVbaProgressBar::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaProgressBar") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaFrame::getServiceNames()
++ScVbaProgressBar::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbaframe.hxx vbahelper/source/msforms/vbaframe.hxx
+diff --git vbahelper/source/msforms/vbaprogressbar.hxx vbahelper/source/msforms/vbaprogressbar.hxx
 new file mode 100644
-index 0000000..071b5b0
+index 0000000..86cbae4
 --- /dev/null
-+++ vbahelper/source/msforms/vbaframe.hxx
-@@ -0,0 +1,58 @@
++++ vbahelper/source/msforms/vbaprogressbar.hxx
+@@ -0,0 +1,59 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -12318,36 +25927,37 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_FRAME_HXX
-+#define SC_VBA_FRAME_HXX
++#ifndef SC_VBA_PROGRESSBAR_HXX
++#define SC_VBA_PROGRESSBAR_HXX
 +#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XLabel.hpp>
++#include <ooo/vba/msforms/XProgressBar.hpp>
 +
 +#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
++#include <cppuhelper/implbase2.hxx>
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE;
++typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XProgressBar, css::script::XDefaultProperty  > ProgressBarImpl_BASE;
 +
-+class ScVbaFrame : public FrameImpl_BASE
++class ScVbaProgressBar : public ProgressBarImpl_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 );
++    ScVbaProgressBar( 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);
-+    virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
 +    //XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    // XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
 +#endif //SC_VBA_LABEL_HXX
-diff --git vbahelper/source/msforms/vbaimage.cxx vbahelper/source/msforms/vbaimage.cxx
+diff --git vbahelper/source/msforms/vbaradiobutton.cxx vbahelper/source/msforms/vbaradiobutton.cxx
 new file mode 100644
-index 0000000..847a08a
+index 0000000..5aa9d20
 --- /dev/null
-+++ vbahelper/source/msforms/vbaimage.cxx
-@@ -0,0 +1,59 @@
++++ vbahelper/source/msforms/vbaradiobutton.cxx
+@@ -0,0 +1,107 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -12356,8 +25966,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile$
-+ * $Revision$
++ * $RCSfile: vbaradiobutton.cxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -12377,7 +25987,7 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#include "vbaimage.hxx"
++#include "vbaradiobutton.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
@@ -12385,34 +25995,82 @@
 +
 +
 +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+ScVbaImage::ScVbaImage( 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 ) : ImageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
++ScVbaRadioButton::ScVbaRadioButton( 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 ) : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++{
++}
++
++// Attributes
++rtl::OUString SAL_CALL 
++ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException)
++{
++    rtl::OUString Label;
++    m_xProps->getPropertyValue( LABEL ) >>= Label;
++    return Label;
++}
++
++void SAL_CALL 
++ScVbaRadioButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++{
++    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++}
++
++uno::Any SAL_CALL 
++ScVbaRadioButton::getValue() throw (css::uno::RuntimeException)
++{
++    sal_Int16 nValue = -1;
++    m_xProps->getPropertyValue( STATE ) >>= nValue;
++    if( nValue != 0 )
++        nValue = -1;
++//    return uno::makeAny( nValue ); 
++// I must be missing something MSO says value should be -1 if selected, 0 if not
++// selected
++    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
++
++}
++
++void SAL_CALL 
++ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
 +{
++    sal_Int16 nValue = 0;
++    sal_Bool bValue = sal_False;
++    if( _value >>= nValue )
++    {
++        if( nValue == -1)
++        nValue = 1;
++    }
++    else if ( _value >>= bValue )
++    {
++        if ( bValue )
++            nValue = 1;
++    }
++    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
 +}
 +
 +rtl::OUString& 
-+ScVbaImage::getServiceImplName()
++ScVbaRadioButton::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaImage") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRadioButton") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaImage::getServiceNames()
++ScVbaRadioButton::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Image" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.RadioButton" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbaimage.hxx vbahelper/source/msforms/vbaimage.hxx
+diff --git vbahelper/source/msforms/vbaradiobutton.hxx vbahelper/source/msforms/vbaradiobutton.hxx
 new file mode 100644
-index 0000000..d64f1c3
+index 0000000..9a09dff
 --- /dev/null
-+++ vbahelper/source/msforms/vbaimage.hxx
-@@ -0,0 +1,48 @@
++++ vbahelper/source/msforms/vbaradiobutton.hxx
+@@ -0,0 +1,55 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -12421,8 +26079,8 @@
 + *
 + * OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * $RCSfile$
-+ * $Revision$
++ * $RCSfile: vbaradiobutton.hxx,v $
++ * $Revision: 1.3 $
 + *
 + * This file is part of OpenOffice.org.
 + *
@@ -12442,753 +26100,643 @@
 + * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_IMAGE_HXX
-+#define SC_VBA_IMAGE_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XImage.hpp>
-+
++#ifndef SC_VBA_RADIOBUTTON_HXX
++#define SC_VBA_RADIOBUTTON_HXX
++#include <ooo/vba/msforms/XRadioButton.hpp>
 +#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
++#include <cppuhelper/implbase2.hxx>
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XImage > ImageImpl_BASE;
++typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > RadioButtonImpl_BASE;
 +
-+class ScVbaImage : public ImageImpl_BASE
++class ScVbaRadioButton : public RadioButtonImpl_BASE
 +{
 +public:
-+    ScVbaImage( 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  );
++    ScVbaRadioButton( 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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException);
 +    //XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++    // XDefaultProperty
++    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++
 +};
-+#endif //SC_VBA_IMAGE_HXX
-diff --git vbahelper/source/msforms/vbalabel.cxx vbahelper/source/msforms/vbalabel.cxx
++#endif //SC_VBA_RADIOBUTTON_HXX
+diff --git vbahelper/source/msforms/vbascrollbar.cxx vbahelper/source/msforms/vbascrollbar.cxx
 new file mode 100644
-index 0000000..a5fa3c1
+index 0000000..e754903
 --- /dev/null
-+++ vbahelper/source/msforms/vbalabel.cxx
-@@ -0,0 +1,88 @@
++++ vbahelper/source/msforms/vbascrollbar.cxx
+@@ -0,0 +1,139 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbalabel.cxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbalabel.hxx"
++#include "vbascrollbar.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
 +
-+const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+ScVbaLabel::ScVbaLabel(  const css::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 ) : LabelImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++const static rtl::OUString LARGECHANGE( RTL_CONSTASCII_USTRINGPARAM("BlockIncrement") );
++const static rtl::OUString SMALLCHANGE( RTL_CONSTASCII_USTRINGPARAM("LineIncrement") );
++const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") );
++const static rtl::OUString SCROLLVALUE( RTL_CONSTASCII_USTRINGPARAM("ScrollValue") );
++const static rtl::OUString SCROLLMAX( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMax") );
++const static rtl::OUString SCROLLMIN( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMin") );
++
++ScVbaScrollBar::ScVbaScrollBar(  const css::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 ) : ScrollBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
 +}
 +
 +// Attributes
-+rtl::OUString SAL_CALL 
-+ScVbaLabel::getCaption() throw (css::uno::RuntimeException)
++uno::Any SAL_CALL 
++ScVbaScrollBar::getValue() throw (css::uno::RuntimeException)
 +{
-+    rtl::OUString Label;
-+    m_xProps->getPropertyValue( LABEL ) >>= Label;
-+    return Label;
++    return  m_xProps->getPropertyValue( SCROLLVALUE );
 +}
 +
 +void SAL_CALL 
-+ScVbaLabel::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaScrollBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++    m_xProps->setPropertyValue( SCROLLVALUE, _value );
 +}
-+uno::Any SAL_CALL 
-+ScVbaLabel::getValue() throw (css::uno::RuntimeException)
++
++::sal_Int32 SAL_CALL 
++ScVbaScrollBar::getMax() throw (uno::RuntimeException)
 +{
-+    return uno::makeAny( getCaption() );
++    sal_Int32 nMax = 0;
++    m_xProps->getPropertyValue( SCROLLMAX ) >>= nMax;
++    return nMax;
 +}
 +
 +void SAL_CALL 
-+ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaScrollBar::setMax( sal_Int32 nVal ) throw (uno::RuntimeException)
 +{
-+    rtl::OUString sCaption;
-+    _value >>= sCaption;
-+    setCaption( sCaption ); 
++    m_xProps->setPropertyValue( SCROLLMAX, uno::makeAny( nVal ) ); 
++}
++
++::sal_Int32 SAL_CALL 
++ScVbaScrollBar::getMin() throw (uno::RuntimeException)
++{
++    sal_Int32 nVal = 0;
++    m_xProps->getPropertyValue( SCROLLMIN ) >>= nVal;
++    return nVal;
++}
++
++void SAL_CALL 
++ScVbaScrollBar::setMin( sal_Int32 nVal ) throw (uno::RuntimeException)
++{
++    m_xProps->setPropertyValue( SCROLLMIN, uno::makeAny( nVal ) ); 
++}
++
++void SAL_CALL 
++ScVbaScrollBar::setLargeChange( ::sal_Int32 _largechange ) throw (uno::RuntimeException)
++{
++    m_xProps->setPropertyValue( LARGECHANGE, uno::makeAny( _largechange ) );
++}
++
++::sal_Int32 SAL_CALL 
++ScVbaScrollBar::getLargeChange() throw (uno::RuntimeException)
++{
++    sal_Int32 nVal = 0;
++    m_xProps->getPropertyValue( LARGECHANGE ) >>= nVal;
++    return nVal;
++}
++
++::sal_Int32 SAL_CALL 
++ScVbaScrollBar::getSmallChange() throw (uno::RuntimeException)
++{
++    sal_Int32 nSmallChange = 0;
++    m_xProps->getPropertyValue( SMALLCHANGE ) >>= nSmallChange;
++    return nSmallChange;
 +}
 +
++void SAL_CALL 
++ScVbaScrollBar::setSmallChange( ::sal_Int32 _smallchange ) throw (uno::RuntimeException)
++{
++    m_xProps->setPropertyValue( SMALLCHANGE, uno::makeAny( _smallchange ) );
++}
 +
 +rtl::OUString& 
-+ScVbaLabel::getServiceImplName()
++ScVbaScrollBar::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaLabel") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaScrollBar") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaLabel::getServiceNames()
++ScVbaScrollBar::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbalabel.hxx vbahelper/source/msforms/vbalabel.hxx
+diff --git vbahelper/source/msforms/vbascrollbar.hxx vbahelper/source/msforms/vbascrollbar.hxx
 new file mode 100644
-index 0000000..3afd652
+index 0000000..459f610
 --- /dev/null
-+++ vbahelper/source/msforms/vbalabel.hxx
-@@ -0,0 +1,56 @@
++++ vbahelper/source/msforms/vbascrollbar.hxx
+@@ -0,0 +1,66 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbalabel.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_LABEL_HXX
-+#define SC_VBA_LABEL_HXX
++#ifndef SC_VBA_SCROLLBAR_HXX
++#define SC_VBA_SCROLLBAR_HXX
 +#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XLabel.hpp>
++#include <ooo/vba/msforms/XScrollBar.hpp>
 +
 +#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
-+#include <cppuhelper/implbase2.hxx>
 +
-+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XLabel, css::script::XDefaultProperty  > LabelImpl_BASE;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XScrollBar > ScrollBarImpl_BASE;
 +
-+class ScVbaLabel : public LabelImpl_BASE
++class ScVbaScrollBar : public ScrollBarImpl_BASE
 +{
 +public:
-+    ScVbaLabel( 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  );
++    ScVbaScrollBar( 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);
-+    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 getMax() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getLargeChange() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setLargeChange( ::sal_Int32 _largechange ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getSmallChange() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setSmallChange( ::sal_Int32 _smallchange ) throw (css::uno::RuntimeException);
++
++
 +    //XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+    // XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
 +#endif //SC_VBA_LABEL_HXX
-diff --git vbahelper/source/msforms/vbalistbox.cxx vbahelper/source/msforms/vbalistbox.cxx
+diff --git vbahelper/source/msforms/vbaspinbutton.cxx vbahelper/source/msforms/vbaspinbutton.cxx
 new file mode 100644
-index 0000000..f425069
+index 0000000..05b6777
 --- /dev/null
-+++ vbahelper/source/msforms/vbalistbox.cxx
-@@ -0,0 +1,286 @@
++++ vbahelper/source/msforms/vbaspinbutton.cxx
+@@ -0,0 +1,109 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbalistbox.cxx,v $
-+ * $Revision: 1.4 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
-+
-+#include "vbalistbox.hxx"
-+#include <vector>
-+#include <comphelper/anytostring.hxx>
-+#include <com/sun/star/script/ArrayWrapper.hpp>
-+
-+using namespace com::sun::star;
-+using namespace ooo::vba;
-+
-+const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") );
-+const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") );
-+const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
-+
-+
-+ScVbaListBox::ScVbaListBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ListBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
-+{
-+    mpListHelper.reset( new ListControlHelper( m_xProps ) );
-+}
-+
-+// Attributes
-+void SAL_CALL 
-+ScVbaListBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException)
-+{
-+    sal_Int32 nIndex = 0;
-+    _value >>= nIndex;
-+    Selected( nIndex );
-+}
-+
-+uno::Any SAL_CALL 
-+ScVbaListBox::getListIndex() throw (uno::RuntimeException)
-+{
-+    uno::Sequence< sal_Int16 > sSelection;
-+    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection;
-+    if ( sSelection.getLength() == 0 )
-+        return uno::Any( sal_Int32( -1 ) );
-+    return uno::Any( sSelection[ 0 ] );
-+}
-+
-+uno::Any SAL_CALL 
-+ScVbaListBox::getValue() throw (uno::RuntimeException)
-+{
-+    uno::Sequence< sal_Int16 > sSelection;
-+    uno::Sequence< rtl::OUString > sItems;
-+    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection;
-+    m_xProps->getPropertyValue( ITEMS ) >>= sItems;
-+    if( getMultiSelect() )
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
-+    uno::Any aRet;
-+    if ( sSelection.getLength() )
-+        aRet = uno::makeAny( sItems[ sSelection[ 0 ] ] ); 
-+    return aRet;
-+}
-+
-+void SAL_CALL 
-+ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
-+{
-+    if( getMultiSelect() )
-+    {	
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
-+    }
-+    rtl::OUString sValue = getAnyAsString( _value );
-+    uno::Sequence< rtl::OUString > sList;
-+    m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+    uno::Sequence< sal_Int16 > nList;
-+    sal_Int16 nLength = static_cast<sal_Int16>( sList.getLength() );
-+    sal_Int16 nValue = -1;
-+    sal_Int16 i = 0;
-+    for( i = 0; i < nLength; i++ )
-+    {
-+        if( sList[i].equals( sValue ) )
-+        {
-+            nValue = i; 
-+            break;
-+        }
-+    }
-+    if( nValue == -1 )
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Attribute use invalid." ), uno::Reference< uno::XInterface >() );
-+
-+    uno::Sequence< sal_Int16 > nSelectedIndices(1);
-+    nSelectedIndices[ 0 ] = nValue;
-+    m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); 
-+    m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); 
-+}
-+
-+::rtl::OUString SAL_CALL 
-+ScVbaListBox::getText() throw (uno::RuntimeException)
-+{
-+	rtl::OUString result;
-+	getValue() >>= result;
-+	return result;
-+}
-+
-+void SAL_CALL 
-+ScVbaListBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException)
-+{
-+	setValue( uno::makeAny( _text ) ); // seems the same
-+}
-+
-+sal_Bool SAL_CALL 
-+ScVbaListBox::getMultiSelect() throw (css::uno::RuntimeException)
-+{
-+    sal_Bool bMultiSelect = sal_False;
-+    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ) ) >>= bMultiSelect;
-+    return bMultiSelect;
-+}
-+
-+void SAL_CALL 
-+ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException)
-+{
-+    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( _multiselect ) );
-+}
++#include "vbaspinbutton.hxx"
++#include <vector>
 +
-+css::uno::Any SAL_CALL 
-+ScVbaListBox::Selected( sal_Int32 index ) throw (css::uno::RuntimeException)
-+{
-+    uno::Sequence< rtl::OUString > sList;
-+    m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+    sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
-+    sal_Int16 nIndex( index );
-+    if( nIndex < 0 || nIndex >= nLength )
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Error Number." ), uno::Reference< uno::XInterface >() );
-+    m_nIndex = static_cast< sal_Int16 >( index );
-+    return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
-+}
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+// Methods
-+void SAL_CALL 
-+ScVbaListBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
-+{
-+	mpListHelper->AddItem( pvargItem, pvargIndex );
-+		}
 +
-+void SAL_CALL 
-+ScVbaListBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
-+		{
-+	mpListHelper->removeItem( index );
-+		}
++const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") );
++const static rtl::OUString SPINVALUE( RTL_CONSTASCII_USTRINGPARAM("SpinValue") );
++const static rtl::OUString SPINMAX( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") );
++const static rtl::OUString SPINMIN( RTL_CONSTASCII_USTRINGPARAM("SpinValueMin") );
 +
-+void SAL_CALL 
-+ScVbaListBox::Clear(  ) throw (uno::RuntimeException)
++ScVbaSpinButton::ScVbaSpinButton(  const css::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 ) : SpinButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
-+	mpListHelper->Clear();
 +}
 +
-+// this is called when something like the following vba code is used
-+// to set the selected state of particular entries in the Listbox
-+// ListBox1.Selected( 3 ) = false
-+//PropListener
-+void 
-+ScVbaListBox::setValueEvent( const uno::Any& value )
++// Attributes
++uno::Any SAL_CALL 
++ScVbaSpinButton::getValue() throw (css::uno::RuntimeException)
 +{
-+    sal_Bool bValue = sal_False;
-+    if( !(value >>= bValue) )
-+        throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Invalid type\n. need boolean." ), uno::Reference< uno::XInterface >() );
-+    uno::Sequence< sal_Int16 > nList;
-+    m_xProps->getPropertyValue( SELECTEDITEMS ) >>= nList;
-+    sal_Int16 nLength = static_cast<sal_Int16>( nList.getLength() );
-+    sal_Int16 nIndex = m_nIndex;
-+    for( sal_Int16 i = 0; i < nLength; i++ )
-+    {
-+        if( nList[i] == nIndex )
-+        {
-+            if( bValue )
-+                return;
-+            else
-+            {
-+                for( ; i < nLength - 1; i++ )
-+                {
-+                    nList[i] = nList[i + 1];
-+                }
-+                nList.realloc( nLength - 1 );
-+                //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
-+		m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) );
-+                return;
-+            }
-+        }
-+    }
-+    if( bValue )
-+    {
-+        if( getMultiSelect() )
-+        {
-+            nList.realloc( nLength + 1 );
-+            nList[nLength] = nIndex;
-+        }
-+        else
-+        {
-+            nList.realloc( 1 );
-+            nList[0] = nIndex;
-+        }
-+        m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
-+    }
++    return  m_xProps->getPropertyValue( SPINVALUE );
 +}
 +
-+// this is called when something like the following vba code is used
-+// to determine the selected state of particular entries in the Listbox
-+// msgbox ListBox1.Selected( 3 )
-+
-+css::uno::Any 
-+ScVbaListBox::getValueEvent()
++void SAL_CALL 
++ScVbaSpinButton::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+    uno::Sequence< sal_Int16 > nList;
-+    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedItems" ) ) ) >>= nList;
-+    sal_Int32 nLength = nList.getLength();
-+    sal_Int32 nIndex = m_nIndex;
-+    
-+    for( sal_Int32 i = 0; i < nLength; i++ )
-+    {
-+        if( nList[i] == nIndex )
-+            return uno::makeAny( sal_True );
-+    }
++    m_xProps->setPropertyValue( SPINVALUE, _value );
++}
 +
-+    return uno::makeAny( sal_False );
++::sal_Int32 SAL_CALL 
++ScVbaSpinButton::getMax() throw (uno::RuntimeException)
++{
++    sal_Int32 nMax = 0;
++    m_xProps->getPropertyValue( SPINMAX ) >>= nMax;
++    return nMax;
 +}
 +
-+void SAL_CALL
-+ScVbaListBox::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaSpinButton::setMax( sal_Int32 nVal ) throw (uno::RuntimeException)
 +{
-+	ScVbaControl::setRowSource( _rowsource );
-+	mpListHelper->setRowSource( _rowsource );
++    m_xProps->setPropertyValue( SPINMAX, uno::makeAny( nVal ) ); 
 +}
 +
-+sal_Int32 SAL_CALL
-+ScVbaListBox::getListCount() throw (uno::RuntimeException)
++::sal_Int32 SAL_CALL 
++ScVbaSpinButton::getMin() throw (uno::RuntimeException)
 +{
-+	return mpListHelper->getListCount();
++    sal_Int32 nVal = 0;
++    m_xProps->getPropertyValue( SPINMIN ) >>= nVal;
++    return nVal;
 +}
 +
-+uno::Any SAL_CALL 
-+ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaSpinButton::setMin( sal_Int32 nVal ) throw (uno::RuntimeException)
 +{
-+	return mpListHelper->List( pvargIndex, pvarColumn );
++    m_xProps->setPropertyValue( SPINMIN, uno::makeAny( nVal ) ); 
 +}
 +
 +rtl::OUString& 
-+ScVbaListBox::getServiceImplName()
++ScVbaSpinButton::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaListBox") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaSpinButton") );
 +	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaListBox::getServiceNames()
++ScVbaSpinButton::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ScVbaListBox" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbalistbox.hxx vbahelper/source/msforms/vbalistbox.hxx
+diff --git vbahelper/source/msforms/vbaspinbutton.hxx vbahelper/source/msforms/vbaspinbutton.hxx
 new file mode 100644
-index 0000000..93e80a3
+index 0000000..8f1d6e3
 --- /dev/null
-+++ vbahelper/source/msforms/vbalistbox.hxx
-@@ -0,0 +1,90 @@
++++ vbahelper/source/msforms/vbaspinbutton.hxx
+@@ -0,0 +1,61 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbalistbox.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_LISTBOX_HXX
-+#define SC_VBA_LISTBOX_HXX
-+#include <cppuhelper/implbase2.hxx>
-+#include <com/sun/star/uno/XComponentContext.hpp>
-+#include <com/sun/star/script/XDefaultProperty.hpp>
-+#include <ooo/vba/msforms/XListBox.hpp>
-+#include <com/sun/star/beans/PropertyAttribute.hpp>
++#ifndef SC_VBA_SPINBUTTON_HXX
++#define SC_VBA_SPINBUTTON_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XSpinButton.hpp>
 +
 +#include "vbacontrol.hxx"
-+#include <vbahelper/vbapropvalue.hxx>
-+#include "vbalistcontrolhelper.hxx"
 +#include <vbahelper/vbahelper.hxx>
 +
-+typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XListBox, css::script::XDefaultProperty > ListBoxImpl_BASE;
-+class ScVbaListBox : public ListBoxImpl_BASE
-+    ,public PropListener
-+{		
-+	std::auto_ptr< ListControlHelper > mpListHelper;
-+	rtl::OUString sSourceName; 
-+	rtl::OUString msDftPropName;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XSpinButton > SpinButtonImpl_BASE;
 +
-+    sal_Int16 m_nIndex;
-+	
++class ScVbaSpinButton : public SpinButtonImpl_BASE
++{
 +public:
-+	ScVbaListBox( 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 getListIndex() throw (css::uno::RuntimeException);
-+	virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
-+	virtual ::sal_Int32 SAL_CALL getListCount() 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 rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
-+	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);
-+
-+	// Methods
-+	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);
-+	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
-+	// XControl
-+    virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
-+
-+	// XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
-+    
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();    
-+
-+    //PropListener
-+    virtual void setValueEvent( const css::uno::Any& value );
-+    virtual css::uno::Any getValueEvent();
-+
++    ScVbaSpinButton( 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);
++    virtual ::sal_Int32 SAL_CALL getMax() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException);
 +
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+
-+#endif //
-diff --git vbahelper/source/msforms/vbalistcontrolhelper.cxx vbahelper/source/msforms/vbalistcontrolhelper.cxx
++#endif //SC_VBA_SPINBUTTON_HXX
+diff --git vbahelper/source/msforms/vbatextbox.cxx vbahelper/source/msforms/vbatextbox.cxx
 new file mode 100644
-index 0000000..8582821
+index 0000000..d246970
 --- /dev/null
-+++ vbahelper/source/msforms/vbalistcontrolhelper.cxx
-@@ -0,0 +1,146 @@
-+#include <vbalistcontrolhelper.hxx>
++++ vbahelper/source/msforms/vbatextbox.cxx
+@@ -0,0 +1,137 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbatextbox.cxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 <com/sun/star/text/XTextRange.hpp>
++
++#include "vbatextbox.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") );
-+
-+void SAL_CALL 
-+ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException)
-+{
-+	if ( pvargItem.hasValue()  )
-+	{
-+		uno::Sequence< rtl::OUString > sList;
-+		m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+
-+		sal_Int32 nIndex = sList.getLength();
-+
-+		if ( pvargIndex.hasValue() )
-+			pvargIndex >>= nIndex;
 +
-+		rtl::OUString sString = getAnyAsString( pvargItem );
 +
-+		// if no index specified or item is to be appended to end of 
-+		// list just realloc the array and set the last item
-+		if ( nIndex  == sList.getLength() )
-+		{
-+			sal_Int32 nOldSize = sList.getLength();
-+			sList.realloc( nOldSize + 1 );
-+			sList[ nOldSize ] = sString; 
-+		}
-+		else
-+		{
-+			// just copy those elements above the one to be inserted
-+			std::vector< rtl::OUString > sVec;
-+			// reserve just the amount we need to copy
-+			sVec.reserve( sList.getLength() - nIndex );
++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 )
++{
++}
 +
-+			// point at first element to copy
-+			rtl::OUString* pString = sList.getArray() + nIndex;
-+			const rtl::OUString* pEndString = sList.getArray() + sList.getLength();
-+			// insert the new element
-+			sVec.push_back( sString );
-+			// copy elements	
-+			for ( ; pString != pEndString; ++pString )
-+				sVec.push_back( *pString );
-+		
-+			sList.realloc(  sList.getLength() + 1 );
++// Attributes
++uno::Any SAL_CALL 
++ScVbaTextBox::getValue() throw (css::uno::RuntimeException)
++{
++	return uno::makeAny( getText() );
++}
 +
-+			// point at first element to be overwritten
-+			pString = sList.getArray() + nIndex;
-+			pEndString = sList.getArray() + sList.getLength();
-+			std::vector< rtl::OUString >::iterator it = sVec.begin();
-+			for ( ; pString != pEndString; ++pString, ++it)
-+				*pString = *it;	
-+			//
-+		}
++void SAL_CALL 
++ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
++{
++	rtl::OUString sVal = getAnyAsString( _value );
++	setText( sVal );
++}
 +
-+		m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) );
-+		
-+	}
++//getString() will cause some imfo lose.
++rtl::OUString SAL_CALL 
++ScVbaTextBox::getText() throw (css::uno::RuntimeException)
++{
++    uno::Any aValue;
++    aValue = m_xProps->getPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) );
++    rtl::OUString sString;
++    aValue >>= sString;
++    return sString;
 +}
 +
 +void SAL_CALL 
-+ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
++ScVbaTextBox::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
 +{
-+    sal_Int32 nIndex = 0;
-+    // for int index
-+	if ( index >>= nIndex  )
-+	{
-+		uno::Sequence< rtl::OUString > sList;
-+		m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+        if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) )
-+            throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid index" ), uno::Reference< uno::XInterface > () );
-+        if( sList.hasElements() )
-+        {
-+            if( sList.getLength() == 1 )
-+            {
-+                Clear();
-+                return;
-+            }
-+            for( sal_Int32 i = nIndex; i < ( sList.getLength()-1 ); i++ )
-+            {
-+                sList[i] = sList[i+1];
-+            }
-+			sList.realloc(  sList.getLength() - 1 );
-+		}
++    if ( !mbDialog )
++    {
++    uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
++    xTextRange->setString( _text );
++}
++    else
++        m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), uno::makeAny( _text ) ); 
++}
 +
-+		m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) );
-+	}
++sal_Int32 SAL_CALL 
++ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
++{
++    uno::Any aValue;
++    aValue = m_xProps->getPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ) );
++    sal_Int32 nMaxLength = 0;
++    aValue >>= nMaxLength;
++    return nMaxLength;
 +}
 +
 +void SAL_CALL 
-+ListControlHelper::Clear(  ) throw (uno::RuntimeException)
++ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
 +{
-+	// urk, setValue doesn't seem to work !!
-+	//setValue( uno::makeAny( sal_Int16() ) );
-+	m_xProps->setPropertyValue( ITEMS, uno::makeAny( uno::Sequence< rtl::OUString >() ) );
++    uno::Any aValue( _maxlength );
++    m_xProps->setPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue);
 +}
 +
-+void SAL_CALL
-+ListControlHelper::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
++sal_Bool SAL_CALL 
++ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException)
 +{
-+	if ( _rowsource.getLength() == 0 )
-+		Clear();
++    uno::Any aValue;
++    aValue = m_xProps->getPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ) );
++    sal_Bool bRet = false;
++    aValue >>= bRet;
++    return bRet;
 +}
 +
-+sal_Int32 SAL_CALL
-+ListControlHelper::getListCount() throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException)
 +{
-+    uno::Sequence< rtl::OUString > sList;
-+    m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+    return sList.getLength();
++    uno::Any aValue( _multiline );
++    m_xProps->setPropertyValue
++            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
 +}
 +
-+uno::Any SAL_CALL 
-+ListControlHelper::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
++rtl::OUString& 
++ScVbaTextBox::getServiceImplName()
 +{
-+    uno::Sequence< rtl::OUString > sList;
-+    m_xProps->getPropertyValue( ITEMS ) >>= sList;
-+    sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
-+    uno::Any aRet;
-+    if ( pvargIndex.hasValue() )
-+    {
-+        sal_Int16 nIndex = -1;
-+        pvargIndex >>= nIndex;
-+        if( nIndex < 0 || nIndex >= nLength )
-+            throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Bad row Index" ), uno::Reference< uno::XInterface >() );       
-+        aRet <<= sList[ nIndex ];
-+    }
-+    else if ( pvarColumn.hasValue() ) // pvarColumn on its own would be bad
-+            throw uno::RuntimeException( rtl::OUString::createFromAscii(
-+                    "Bad column Index" ), uno::Reference< uno::XInterface >() );       
-+    else // List() ( e.g. no args )
-+    {
-+        uno::Sequence< uno::Sequence< rtl::OUString > > sReturnArray( nLength );
-+        for ( sal_Int32 i = 0; i < nLength; ++i )
-+        {
-+            sReturnArray[ i ].realloc( 10 );
-+            sReturnArray[ i ][ 0 ] = sList[ i ];
-+        }        
-+        aRet = uno::makeAny( sReturnArray );
-+    }
-+    return aRet;
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox") );
++	return sImplName;
 +}
-diff --git vbahelper/source/msforms/vbalistcontrolhelper.hxx vbahelper/source/msforms/vbalistcontrolhelper.hxx
++
++uno::Sequence< rtl::OUString > 
++ScVbaTextBox::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.TextBox" ) );
++	}
++	return aServiceNames;
++}
+diff --git vbahelper/source/msforms/vbatextbox.hxx vbahelper/source/msforms/vbatextbox.hxx
 new file mode 100644
-index 0000000..53f369f
+index 0000000..3abe491
 --- /dev/null
-+++ vbahelper/source/msforms/vbalistcontrolhelper.hxx
-@@ -0,0 +1,20 @@
-+#ifndef SC_VBA_LISTCONTROLHELPER
-+#define SC_VBA_LISTCONTROLHELPER
-+
++++ vbahelper/source/msforms/vbatextbox.hxx
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbatextbox.hxx,v $
++ * $Revision: 1.3 $
++ *
++ * 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 SC_VBA_TEXTBOX_HXX
++#define SC_VBA_TEXTBOX_HXX
++#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XTextBox.hpp>
++#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
 +
-+class ListControlHelper
-+{
-+	css::uno::Reference< css::beans::XPropertySet > m_xProps;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XTextBox > TextBoxImpl_BASE;
 +
++class ScVbaTextBox : public TextBoxImpl_BASE
++{
++    bool mbDialog;
 +public:
-+	ListControlHelper( const css::uno::Reference< css::beans::XPropertySet >& rxControl ) : m_xProps( rxControl ){}
-+
-+	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 setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
-+	virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException);
-+	virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException);
-+	virtual void SAL_CALL Clear(  ) throw (css::uno::RuntimeException);
++    ScVbaTextBox( 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, bool bDialog = false );
++   // 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 getText() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException);
++    virtual sal_Int32 SAL_CALL getMaxLength() throw (css::uno::RuntimeException);
++    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);
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+#endif
-diff --git vbahelper/source/msforms/vbamultipage.cxx vbahelper/source/msforms/vbamultipage.cxx
++#endif //SC_VBA_TEXTBOX_HXX
+diff --git vbahelper/source/msforms/vbatogglebutton.cxx vbahelper/source/msforms/vbatogglebutton.cxx
 new file mode 100644
-index 0000000..118e005
+index 0000000..f938ad1
 --- /dev/null
-+++ vbahelper/source/msforms/vbamultipage.cxx
-@@ -0,0 +1,132 @@
++++ vbahelper/source/msforms/vbatogglebutton.cxx
+@@ -0,0 +1,108 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13223,110 +26771,86 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbamultipage.hxx"
-+#include <ooo/vba/XCollection.hpp>
-+#include "vbapages.hxx"
++#include "vbatogglebutton.hxx"
 +#include <vector>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+// uno servicename com.sun.star.awt.UnoControlProgressBarMode
-+const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
-+const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") );
-+const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") );
 +
-+typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base;
-+class PagesImpl : public PagesImpl_Base
-+{
-+	sal_Int32 mnPages;
-+public:
-+	PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {}
-+	virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) { return mnPages; }
-+	virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, ::uno::RuntimeException)
-+	{
-+		if ( Index < 0 || Index > mnPages )
-+			throw lang::IndexOutOfBoundsException();
-+		return uno::makeAny( uno::Reference< uno::XInterface >() );
-+	}
-+	// XElementAccess
-+	virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
-+	{
-+		// no Pages object yet #FIXME
-+		//return msforms::XPage::static_type(0);
-+		return uno::XInterface::static_type(0);
-+	}
-+	virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
-+	{
-+		return ( mnPages > 0 );
-+	}
-+};
-+uno::Reference< container::XIndexAccess > 
-+ScVbaMultiPage::getPages( sal_Int32 nPages )
++const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
++const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
++ScVbaToggleButton::ScVbaToggleButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : ToggleButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
 +{
-+	return new PagesImpl( nPages );
++    OSL_TRACE("ScVbaToggleButton(ctor)");
++    m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
 +}
 +
-+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 )
++ScVbaToggleButton::~ScVbaToggleButton()
 +{
-+    mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
-+    // set dialog step to value of multipage pseudo model
-+    setValue(getValue());
++    OSL_TRACE("~ScVbaToggleButton(dtor)");
 +}
 +
 +// Attributes
-+sal_Int32 SAL_CALL 
-+ScVbaMultiPage::getValue() throw (css::uno::RuntimeException)
++rtl::OUString SAL_CALL 
++ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
 +{
-+    sal_Int32 nValue = 0;
-+    m_xProps->getPropertyValue( SVALUE ) >>= nValue;
-+    return nValue;
++    rtl::OUString Label;
++    m_xProps->getPropertyValue( LABEL ) >>= Label;
++    return Label;
 +}
 +
 +void SAL_CALL 
-+ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
 +{
-+    // track change in dialog ( dialog value is 1 based, 0 is a special value )
-+    m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) );
-+    mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) );
++    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
 +}
 +
++uno::Any SAL_CALL 
++ScVbaToggleButton::getValue() throw (uno::RuntimeException)
++{
++	sal_Int16 nState = 0;
++    	m_xProps->getPropertyValue( STATE ) >>= nState;
++ 	return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
++}
 +
-+rtl::OUString& 
-+ScVbaMultiPage::getServiceImplName()
++void SAL_CALL 
++ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMultiPage") );
-+	return sImplName;
++	sal_Int16 nState = 0;
++	_value >>= nState;
++        OSL_TRACE( "nState - %d", nState );
++	nState = ( nState == -1 ) ?  1 : 0;
++        OSL_TRACE( "nState - %d", nState );
++	m_xProps->setPropertyValue( STATE, uno::makeAny(  nState ) );
 +}
 +
-+uno::Any SAL_CALL 
-+ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException)
++rtl::OUString& 
++ScVbaToggleButton::getServiceImplName()
 +{
-+	sal_Int32 nValue = 0;
-+	m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue;
-+	uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) );
-+	if ( !index.hasValue() )
-+		return uno::makeAny( xColl );
-+	return xColl->Item( uno::makeAny( index ), uno::Any() );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
++	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaMultiPage::getServiceNames()
++ScVbaToggleButton::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.MultiPage" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbamultipage.hxx vbahelper/source/msforms/vbamultipage.hxx
++
+diff --git vbahelper/source/msforms/vbatogglebutton.hxx vbahelper/source/msforms/vbatogglebutton.hxx
 new file mode 100644
-index 0000000..05d0775
+index 0000000..dfa5c1c
 --- /dev/null
-+++ vbahelper/source/msforms/vbamultipage.hxx
-@@ -0,0 +1,65 @@
++++ vbahelper/source/msforms/vbatogglebutton.hxx
+@@ -0,0 +1,63 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13361,43 +26885,41 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_MULTIPAGE_HXX
-+#define SC_VBA_MULTIPAGE_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XMultiPage.hpp>
-+#include <com/sun/star/container/XIndexAccess.hpp>
++#ifndef SC_VBA_TOGGLEBUTTON_HXX
++#define SC_VBA_TOGGLEBUTTON_HXX
++#include <cppuhelper/implbase2.hxx>
++#include <ooo/vba/msforms/XToggleButton.hpp>
 +
 +#include "vbacontrol.hxx"
 +#include <vbahelper/vbahelper.hxx>
-+//#include <cppuhelper/implbase2.hxx>
-+#include <cppuhelper/implbase1.hxx>
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XMultiPage > MultiPageImpl_BASE;
++typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XToggleButton, css::script::XDefaultProperty  > ToggleButtonImpl_BASE;
 +
-+class ScVbaMultiPage : public MultiPageImpl_BASE
++class ScVbaToggleButton : public ToggleButtonImpl_BASE
 +{
-+    css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages );
-+    css::uno::Reference< css::beans::XPropertySet > mxDialogProps;
++	rtl::OUString msDftPropName;
 +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 );
++    ScVbaToggleButton( 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 );
++    ~ScVbaToggleButton();
 +   // Attributes
-+    virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setValue( const sal_Int32 _value ) throw (css::uno::RuntimeException);
-+    virtual css::uno::Any SAL_CALL Pages( const css::uno::Any& index ) 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 rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
 +    //XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +    // XDefaultProperty
 +    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
-+#endif //SC_VBA_LABEL_HXX
-diff --git vbahelper/source/msforms/vbapages.cxx vbahelper/source/msforms/vbapages.cxx
++#endif //SC_VBA_TOGGLEBUTTON_HXX
+diff --git vbahelper/source/msforms/vbauserform.cxx vbahelper/source/msforms/vbauserform.cxx
 new file mode 100644
-index 0000000..db28086
+index 0000000..775b539
 --- /dev/null
-+++ vbahelper/source/msforms/vbapages.cxx
-@@ -0,0 +1,80 @@
++++ vbahelper/source/msforms/vbauserform.cxx
+@@ -0,0 +1,226 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13432,58 +26954,204 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbapages.hxx"
++#include <vbahelper/helperdecl.hxx>
++#include "vbauserform.hxx"
++#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/awt/XControlContainer.hpp>
++#include <com/sun/star/beans/PropertyConcept.hpp>
++#include <basic/sbx.hxx>
++#include <basic/sbstar.hxx>
++#include <basic/sbmeth.hxx>
++#include "vbacontrols.hxx"
 +
 +using namespace ::ooo::vba;
 +using namespace ::com::sun::star;
 +
-+ScVbaPages::ScVbaPages( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPages ) throw( lang::IllegalArgumentException ) : ScVbaPages_BASE( xParent, xContext, xPages )
++// some little notes
++// XDialog implementation has the following interesting bits
++// a Controls property ( which is an array of the container controls )
++//   each item in the controls array is a XControl, where the model is 
++//   basically a property bag
++// additionally the XDialog instance has itself a model
++//     this model has a ControlModels ( array of models ) property
++//     the models in ControlModels can be accessed by name
++// also the XDialog is a XControl ( to access the model above
++
++ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) :  ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), static_cast< ooo::vba::AbstractGeometryAttributes* >(0) ),  mbDispose( true )
++{
++    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 ) );
++}
++
++ScVbaUserForm::~ScVbaUserForm()
++{
++}
++
++void SAL_CALL 
++ScVbaUserForm::Show(  ) throw (uno::RuntimeException)
++{
++	OSL_TRACE("ScVbaUserForm::Show(  )");
++	short aRet = 0;
++	if ( m_xDialog.is() )
++		aRet = m_xDialog->execute();
++	OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
++	if ( mbDispose )
++	{
++		try
++		{
++			uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
++			m_xDialog = NULL;
++			xComp->dispose();
++			mbDispose = false; 
++		}
++		catch( uno::Exception& )
++		{
++		}
++	}
++}
++
++rtl::OUString SAL_CALL 
++ScVbaUserForm::getCaption() throw (::com::sun::star::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)
 +{
++    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
 +}
 +
-+uno::Type SAL_CALL 
-+ScVbaPages::getElementType() throw (uno::RuntimeException)
++void SAL_CALL 
++ScVbaUserForm::Hide(  ) throw (uno::RuntimeException)
 +{
-+	// return msforms::XPage::static_type(0); 
-+	return uno::XInterface::static_type(0); 
++	mbDispose = false;  // hide not dispose
++	if ( m_xDialog.is() )
++		m_xDialog->endExecute();
 +}
 +
-+uno::Any 
-+ScVbaPages::createCollectionObject( const css::uno::Any& aSource )
++void SAL_CALL 
++ScVbaUserForm::RePaint(  ) throw (uno::RuntimeException)
 +{
-+	return aSource;
++	// do nothing
 +}
 +
-+rtl::OUString& 
-+ScVbaPages::getServiceImplName()
++void SAL_CALL 
++ScVbaUserForm::UnloadObject(  ) throw (uno::RuntimeException)
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPages") );
-+	return sImplName;
++	mbDispose = true;
++	if ( m_xDialog.is() )
++		m_xDialog->endExecute();
 +}
 +
-+uno::Reference< container::XEnumeration > SAL_CALL 
-+ScVbaPages::createEnumeration() throw (uno::RuntimeException)
++rtl::OUString& 
++ScVbaUserForm::getServiceImplName()
 +{
-+	return uno::Reference< container::XEnumeration >();
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
++	return sImplName;
 +}
 +
 +uno::Sequence< rtl::OUString > 
-+ScVbaPages::getServiceNames()
++ScVbaUserForm::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msform.Pages" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbapages.hxx vbahelper/source/msforms/vbapages.hxx
++
++uno::Reference< beans::XIntrospectionAccess > SAL_CALL 
++ScVbaUserForm::getIntrospection(  ) throw (uno::RuntimeException)
++{
++	return uno::Reference< beans::XIntrospectionAccess >();
++}
++
++uno::Any SAL_CALL 
++ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++{
++	throw uno::RuntimeException(); // unsupported operation
++}
++
++void SAL_CALL 
++ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++{
++	uno::Any aObject = getValue( aPropertyName );
++	// The Object *must* support XDefaultProperty here because getValue will
++	// only return properties that are Objects ( e.g. controls )
++	// e.g. Userform1.aControl = something
++	// 'aControl' has to support XDefaultProperty to make sense here
++	uno::Reference< script::XDefaultProperty > xDfltProp( aObject, uno::UNO_QUERY_THROW );
++	rtl::OUString aDfltPropName = xDfltProp->getDefaultPropertyName();
++	uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) );
++	uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY_THROW );
++	xPropSet->setPropertyValue( aDfltPropName, aValue );
++}
++
++uno::Any SAL_CALL 
++ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
++{
++	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
++	uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
++	uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
++	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 ) );
++	return uno::makeAny( xVBAControl );
++}
++
++::sal_Bool SAL_CALL 
++ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
++{
++	return sal_False;
++}
++uno::Any SAL_CALL 
++ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
++{
++	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
++	uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
++	if ( index.hasValue() )
++		return uno::makeAny( xControls->Item( index, uno::Any() ) );
++	return uno::makeAny( xControls );
++}
++
++::sal_Bool SAL_CALL 
++ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++{
++	uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
++	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() );
++	if ( xControl.is() )
++	{
++		uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );	
++		sal_Bool bRes =  xNameAccess->hasByName( aName );
++	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes );
++		return bRes;
++	}
++	return sal_False;
++}
++
++namespace userform
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++    serviceImpl,
++    "ScVbaUserForm",
++    "ooo.vba.msforms.UserForm" );
++}
++
+diff --git vbahelper/source/msforms/vbauserform.hxx vbahelper/source/msforms/vbauserform.hxx
 new file mode 100644
-index 0000000..c1755f5
+index 0000000..be93dc7
 --- /dev/null
-+++ vbahelper/source/msforms/vbapages.hxx
-@@ -0,0 +1,64 @@
++++ vbahelper/source/msforms/vbauserform.hxx
+@@ -0,0 +1,77 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13518,42 +27186,127 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_PAGES_HXX
-+#define SC_VBA_PAGES_HXX
++#ifndef SC_VBA_USERFORM_HXX
++#define SC_VBA_USERFORM_HXX
 +
-+#include <ooo/vba/office/MsoShapeType.hpp>
-+#include <com/sun/star/lang/XEventListener.hpp>
-+#include <com/sun/star/beans/XPropertySet.hpp>
-+#include <ooo/vba/msforms/XPages.hpp>
-+#include <cppuhelper/implbase2.hxx>
 +#include <cppuhelper/implbase1.hxx>
++#include <ooo/vba/msforms/XUserForm.hpp>
++#include <com/sun/star/awt/XDialog.hpp>
++#include <com/sun/star/frame/XModel.hpp>
 +
-+#include <vbahelper/vbacollectionimpl.hxx>
-+typedef CollTestImplHelper< 
-+ov::msforms::XPages > ScVbaPages_BASE;
++#include <vbahelper/vbahelperinterface.hxx>
++#include "vbacontrol.hxx"
 +
-+class ScVbaPages : public ScVbaPages_BASE
++//typedef InheritedHelperInterfaceImpl1< ov::msforms::XUserForm > ScVbaUserForm_BASE;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE;
++
++class ScVbaUserForm : public ScVbaUserForm_BASE
 +{
++private:
++    css::uno::Reference< css::awt::XDialog > m_xDialog;
++    bool mbDispose;
 +protected:
-+	virtual rtl::OUString& getServiceImplName();
-+	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +public:
-+    ScVbaPages( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPages ) throw ( css::lang::IllegalArgumentException );
-+    virtual ~ScVbaPages() {}
-+        // XEnumerationAccess
-+    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
-+    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
-+     // ScVbaPages_BASE
-+     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
++    ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
++    virtual ~ScVbaUserForm();
++    // 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 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);
++    //XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif
+diff --git vbahelper/source/vbahelper/makefile.mk vbahelper/source/vbahelper/makefile.mk
+new file mode 100644
+index 0000000..8f5862a
+--- /dev/null
++++ vbahelper/source/vbahelper/makefile.mk
+@@ -0,0 +1,66 @@
++#*************************************************************************
++#
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++# 
++# Copyright 2008 by Sun Microsystems, Inc.
++#
++# OpenOffice.org - a multi-platform office productivity suite
++#
++# $RCSfile: makefile.mk,v $
++#
++# $Revision: 1.45 $
++#
++# 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.
++#
++#*************************************************************************
++
++PRJ=..$/../
++PRJNAME=vbahelper
++TARGET=vbahelper
++
++ENABLE_EXCEPTIONS := TRUE
++
++# --- Settings -----------------------------------------------------
++
++.INCLUDE :  settings.mk
++
++SLOFILES=\
++    $(SLO)$/vbahelper.obj \
++    $(SLO)$/vbapropvalue.obj \
++    $(SLO)$/vbacommandbars.obj \
++    $(SLO)$/vbacommandbar.obj \
++    $(SLO)$/vbacommandbarcontrols.obj \
++    $(SLO)$/vbacommandbarcontrol.obj \
++    $(SLO)$/vbaapplicationbase.obj \
++    $(SLO)$/vbawindowbase.obj \
++    $(SLO)$/vbadocumentbase.obj \
++    $(SLO)$/vbaglobalbase.obj \
++
++# --- Targets -------------------------------------------------------
++
++.INCLUDE :  target.mk
++
++ALLTAR : \
++        $(MISC)$/$(TARGET).don \
++
++$(SLOFILES) : $(MISC)$/$(TARGET).don
 +
-+};
-+#endif//SC_VBA_SHAPE_HXX
-diff --git vbahelper/source/msforms/vbaprogressbar.cxx vbahelper/source/msforms/vbaprogressbar.cxx
++$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
++        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
++        echo $@
++
+diff --git vbahelper/source/vbahelper/vbaapplicationbase.cxx vbahelper/source/vbahelper/vbaapplicationbase.cxx
 new file mode 100644
-index 0000000..77f3eca
+index 0000000..b6a8dee
 --- /dev/null
-+++ vbahelper/source/msforms/vbaprogressbar.cxx
-@@ -0,0 +1,78 @@
++++ vbahelper/source/vbahelper/vbaapplicationbase.cxx
+@@ -0,0 +1,139 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13588,56 +27341,117 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbaprogressbar.hxx"
-+#include <vector>
++#include "vbahelper/vbaapplicationbase.hxx"
++#include <com/sun/star/container/XIndexAccess.hpp>
++#include <com/sun/star/frame/XLayoutManager.hpp>
++
++#include "vbacommandbars.hxx"
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+// uno servicename com.sun.star.awt.UnoControlProgressBarMode
-+const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
++VbaApplicationBase::VbaApplicationBase( const uno::Reference< css::uno::XComponentContext >& xContext )
++                    : ApplicationBase_BASE( uno::Reference< XHelperInterface >(), xContext )
++{
++}
 +
-+ScVbaProgressBar::ScVbaProgressBar( 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 ) : ProgressBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++VbaApplicationBase::~VbaApplicationBase()
 +{
 +}
 +
-+// Attributes
-+uno::Any SAL_CALL 
-+ScVbaProgressBar::getValue() throw (css::uno::RuntimeException)
++sal_Bool SAL_CALL
++VbaApplicationBase::getScreenUpdating() throw (uno::RuntimeException)
 +{
-+    return m_xProps->getPropertyValue( SVALUE );
++	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
++	return !xModel->hasControllersLocked();
 +}
 +
-+void SAL_CALL 
-+ScVbaProgressBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++void SAL_CALL
++VbaApplicationBase::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( SVALUE,  _value );
++	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
++	if (bUpdate)
++		xModel->unlockControllers();
++	else
++		xModel->lockControllers();
++}
++
++sal_Bool SAL_CALL
++VbaApplicationBase::getDisplayStatusBar() throw (uno::RuntimeException)
++{
++	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
++    uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
++    uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
++
++    if( xProps.is() ){
++        uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
++        rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
++        if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){
++            return sal_True;
++        }
++    }
++    return sal_False;
++}
++
++void SAL_CALL
++VbaApplicationBase::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException)
++{
++	uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
++    uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
++    uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
++
++    if( xProps.is() ){
++        uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
++        rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
++        if( xLayoutManager.is() ){
++            if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){
++                if( !xLayoutManager->showElement( url ) )
++                    xLayoutManager->createElement( url );
++                return;
++            }
++            else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){
++                xLayoutManager->hideElement( url ); 
++                return;
++            }
++        }
++    }
++    return;
++}
++
++uno::Any SAL_CALL
++VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    uno::Reference< XCommandBars > xCommandBars( new ScVbaCommandBars( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
++    if( aIndex.hasValue() )
++        return uno::makeAny( xCommandBars->Item( aIndex, uno::Any() ) );
++    return uno::makeAny( xCommandBars );
 +}
 +
 +rtl::OUString& 
-+ScVbaProgressBar::getServiceImplName()
++VbaApplicationBase::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaProgressBar") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaApplicationBase") );
 +	return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaProgressBar::getServiceNames()
++uno::Sequence<rtl::OUString> 
++VbaApplicationBase::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VbaApplicationBase" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbaprogressbar.hxx vbahelper/source/msforms/vbaprogressbar.hxx
++
++
+diff --git vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbar.cxx
 new file mode 100644
-index 0000000..86cbae4
+index 0000000..55ba7b6
 --- /dev/null
-+++ vbahelper/source/msforms/vbaprogressbar.hxx
-@@ -0,0 +1,59 @@
++++ vbahelper/source/vbahelper/vbacommandbar.cxx
+@@ -0,0 +1,346 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13672,211 +27486,437 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_PROGRESSBAR_HXX
-+#define SC_VBA_PROGRESSBAR_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XProgressBar.hpp>
-+
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
-+#include <cppuhelper/implbase2.hxx>
-+
-+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XProgressBar, css::script::XDefaultProperty  > ProgressBarImpl_BASE;
++#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
++#include <com/sun/star/frame/XFrame.hpp>
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <com/sun/star/frame/XLayoutManager.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++#include <com/sun/star/container/XNameContainer.hpp>
++#include <ooo/vba/office/MsoBarType.hpp>
 +
-+class ScVbaProgressBar : public ProgressBarImpl_BASE
-+{
-+public:
-+    ScVbaProgressBar( 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);
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+    // XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
-+};
-+#endif //SC_VBA_LABEL_HXX
-diff --git vbahelper/source/msforms/vbaradiobutton.cxx vbahelper/source/msforms/vbaradiobutton.cxx
-new file mode 100644
-index 0000000..5aa9d20
---- /dev/null
-+++ vbahelper/source/msforms/vbaradiobutton.cxx
-@@ -0,0 +1,107 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: vbaradiobutton.cxx,v $
-+ * $Revision: 1.3 $
-+ *
-+ * 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 "vbaradiobutton.hxx"
-+#include <vector>
++#include "vbacommandbar.hxx"
++#include "vbacommandbarcontrols.hxx"
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+
-+const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
-+ScVbaRadioButton::ScVbaRadioButton( 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 ) : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw (uno::RuntimeException) : CommandBar_BASE( xParent, xContext )
 +{
++    // it's a menu bar
++    // only supporting factory menus ( no custom menus )
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initCommandBar();
++    switch( nModuleType )
++    {
++        case 0:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" );
++            break;
++        case 1:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
++            break;
++        default:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
++    }
++    getMenuSettings();
++    m_bIsMenu = sal_True;
++    m_bCustom = sal_False;
++}
++ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw (uno::RuntimeException) :  CommandBar_BASE( xParent, xContext )
++{
++    // it's a tool bar
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initCommandBar();
++    m_bTemporary = bTemporary;
++    m_bCreate = bCreate;
++    // get OOo ToolBarName
++    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
++    if( iter != mCommandBarNameMap.end() )
++    {
++        m_sToolBarName = iter->second;
++    }
++    else
++    {
++        m_sToolBarName = sToolBarName;
++    }
++    m_sUIName = m_sToolBarName;
++    m_bIsMenu = sal_False;
++    getToolBarSettings( m_sToolBarName );
 +}
-+
-+// Attributes
-+rtl::OUString SAL_CALL 
-+ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException)
++void
++ScVbaCommandBar::initCommandBar() throw (uno::RuntimeException)
 +{
-+    rtl::OUString Label;
-+    m_xProps->getPropertyValue( LABEL ) >>= Label;
-+    return Label;
++    m_pScVbaCommandBars = dynamic_cast< ScVbaCommandBars* >( m_xParentHardRef.get() );
++    if ( !m_pScVbaCommandBars )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBars"), uno::Reference< uno::XInterface >() );
++    m_bIsMenu = sal_False;
++    m_bCustom = sal_False;
++    m_bTemporary = sal_True;
++    m_sToolBarName = rtl::OUString::createFromAscii("");
++    m_sUIName = rtl::OUString::createFromAscii("");
++    m_sMenuModuleName = m_pScVbaCommandBars->GetModuleName();
++}
++void
++ScVbaCommandBar::getToolBarSettings( rtl::OUString sToolBarName ) throw( uno::RuntimeException )
++{
++    rtl::OUString sFactoryToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/") + sToolBarName.toAsciiLowerCase();
++    rtl::OUString sCustomToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/custom_toolbar_") + sToolBarName;
++    uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++    uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
++    m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_pScVbaCommandBars->GetModuleName() ), uno::UNO_QUERY_THROW );
++    m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
++    if( m_xUICfgManager->hasSettings( sFactoryToolBar ) )
++    {
++        // exsiting standard ToolBar
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sFactoryToolBar, sal_True ), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sFactoryToolBar;
++    }
++    else if( m_xUICfgManager->hasSettings( sCustomToolBar ) )
++    {
++        // exisiting custom ToolBar
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sCustomToolBar, sal_True ), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sCustomToolBar;
++        m_bCustom = sal_True;
++    }
++    else if( m_bCreate )
++    {
++        // new custom ToolBar
++        m_xBarSettings.set( m_xUICfgManager->createSettings(), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sCustomToolBar;
++        m_bCustom = sal_True;
++        addCustomBar();
++    }
++    else
++        throw uno::RuntimeException( rtl::OUString::createFromAscii("ToolBar do not exist"), uno::Reference< uno::XInterface >() );
++    if( m_pScVbaCommandBars->GetWindows()->hasByName( m_sToolBarName ) )
++    {
++        uno::Any aToolBar = m_pScVbaCommandBars->GetWindows()->getByName( m_sToolBarName );
++        aToolBar >>= m_aToolBar; 
++    }
 +}
++void
++ScVbaCommandBar::addCustomBar()
++{
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    xPropertySet->setPropertyValue(rtl::OUString::createFromAscii("UIName"), uno::makeAny( m_sUIName ));
 +
++    if( m_xUICfgManager->hasSettings(m_sToolBarName) )
++    {
++        m_xUICfgManager->replaceSettings( m_sToolBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sToolBarName,  uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
++}
++void 
++ScVbaCommandBar::getMenuSettings()
++{
++    try
++    {
++        rtl::OUString sMenuBar = rtl::OUString::createFromAscii( "private:resource/menubar/menubar" );
++        uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++        uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
++        m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_sMenuModuleName ), uno::UNO_QUERY_THROW );
++        m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sMenuBar, sal_True ), uno::UNO_QUERY_THROW );
++    } 
++    catch ( uno::Exception e)
++    {
++        OSL_TRACE( "getMenuSetting got a error\n" );
++    }
++}
++::rtl::OUString SAL_CALL
++ScVbaCommandBar::getName() throw ( uno::RuntimeException )
++{
++    // This will get a "NULL length string" when Name is not set. 
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") );
++    rtl::OUString sName;
++    aName >>= sName;
++    if( sName.getLength() < 1 && !m_bIsMenu )
++    {
++        uno::Reference< container::XNameAccess > xNameAccess( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
++        if( xNameAccess->hasByName( m_sToolBarName ) )
++        {
++            beans::PropertyValues aToolBar; 
++            xNameAccess->getByName( m_sToolBarName ) >>= aToolBar;
++            sal_Int32 nCount = aToolBar.getLength();
++            beans::PropertyValue aPropertyValue;
++            for( sal_Int32 i = 0; i < nCount; i++ )
++            {
++                aPropertyValue = aToolBar[i];
++                if( aPropertyValue.Name.equals( rtl::OUString::createFromAscii("UIName") ) )
++                {
++                    aPropertyValue.Value >>= sName;
++                    return sName;
++                }
++            }
++        }
++    }
++    return sName;
++}
 +void SAL_CALL 
-+ScVbaRadioButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
++    uno::Reference< container::XIndexAccess > xIndexAccess( m_xBarSettings, uno::UNO_QUERY_THROW );
++    
++    if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sToolBarName, xIndexAccess );
++    }
++    else
++    {
++        // toolbar not found
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
 +}
-+
-+uno::Any SAL_CALL 
-+ScVbaRadioButton::getValue() throw (css::uno::RuntimeException)
++::sal_Bool SAL_CALL 
++ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
 +{
-+    sal_Int16 nValue = -1;
-+    m_xProps->getPropertyValue( STATE ) >>= nValue;
-+    if( nValue != 0 )
-+        nValue = -1;
-+//    return uno::makeAny( nValue ); 
-+// I must be missing something MSO says value should be -1 if selected, 0 if not
-+// selected
-+    return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); 
-+
++    sal_Bool bVisible = sal_False;
++    try
++    {
++        sal_Int32 i = 0;
++        while( !m_aToolBar[i].Name.equals( rtl::OUString::createFromAscii( "Visible" ) ) )
++        {
++            i++;
++        }
++        m_aToolBar[i].Value >>= bVisible;
++    }
++    catch ( uno::Exception e )
++    {
++    }
++    return bVisible;
 +}
-+
 +void SAL_CALL 
-+ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
++ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
 +{
-+    sal_Int16 nValue = 0;
-+    sal_Bool bValue = sal_False;
-+    if( _value >>= nValue )
++    try
 +    {
-+        if( nValue == -1)
-+        nValue = 1;
++        uno::Reference< frame::XFrame > xFrame( getCurrentDocument()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); 
++        uno::Reference< beans::XPropertySet > xPropertySet( xFrame, uno::UNO_QUERY_THROW );
++        uno::Reference< frame::XLayoutManager > xLayoutManager( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LayoutManager") ), uno::UNO_QUERY_THROW );
++        if( _visible )
++        {
++            xLayoutManager->createElement( m_sToolBarName );
++            xLayoutManager->showElement( m_sToolBarName );
++        }
++        else
++        {
++            xLayoutManager->hideElement( m_sToolBarName );
++            xLayoutManager->destroyElement( m_sToolBarName );
++        }
 +    }
-+    else if ( _value >>= bValue )
++    catch( uno::Exception e )
 +    {
-+        if ( bValue )
-+            nValue = 1;
++        OSL_TRACE( "SetVisible get an exception\n" );
++    }
++}
++void SAL_CALL 
++ScVbaCommandBar::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++    if( m_bCustom )
++    {
++        if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
++        {
++            m_xUICfgManager->removeSettings(m_sToolBarName);
++            // make it permanent
++            if( !m_bTemporary )
++            {
++                m_xUICfgPers->store();
++            }
++        }
++        else
++        {
++            // toolbar not found
++            // TODO throw Error
++        }
++        uno::Reference< container::XNameContainer > xNameContainer( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
++        if( xNameContainer->hasByName( m_sToolBarName ) )
++        {
++            xNameContainer->removeByName( m_sToolBarName );
++        }
++    }
++}
++uno::Any SAL_CALL 
++ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    sal_Int32 nIndex;
++    uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
++    if( aIndex.hasValue() )
++    {
++        if( aIndex >>= nIndex )
++        {
++            uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
++            return uno::makeAny( xCommandBarControl );
++        }
++        else
++            throw uno::RuntimeException( rtl::OUString::createFromAscii(  "invalid index" ), uno::Reference< uno::XInterface >() );
 +    }
-+    m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
++    return uno::makeAny( xCommandBarControls );
++}
++
++sal_Int32 SAL_CALL
++ScVbaCommandBar::Type() throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // #FIXME support msoBarTypePopup
++    sal_Int32 nType = office::MsoBarType::msoBarTypePopup;
++    nType = m_bIsMenu? office::MsoBarType::msoBarTypeNormal : office::MsoBarType::msoBarTypeMenuBar;
++    return nType;
++}
++
++uno::Any SAL_CALL 
++ScVbaCommandBar::FindControl( const uno::Any& /*aType*/, const uno::Any& /*aId*/, const uno::Any& /*aTag*/, const uno::Any& /*aVisible*/, const uno::Any& /*aRecursive*/ ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // alwayse fail to find control
++    return uno::makeAny( uno::Reference< XCommandBarControl > () );
 +}
 +
 +rtl::OUString& 
-+ScVbaRadioButton::getServiceImplName()
++ScVbaCommandBar::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRadioButton") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBar") );
 +	return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaRadioButton::getServiceNames()
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBar::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.RadioButton" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBar" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbaradiobutton.hxx vbahelper/source/msforms/vbaradiobutton.hxx
+diff --git vbahelper/source/vbahelper/vbacommandbar.hxx vbahelper/source/vbahelper/vbacommandbar.hxx
 new file mode 100644
-index 0000000..9a09dff
+index 0000000..0b830b2
 --- /dev/null
-+++ vbahelper/source/msforms/vbaradiobutton.hxx
-@@ -0,0 +1,55 @@
++++ vbahelper/source/vbahelper/vbacommandbar.hxx
+@@ -0,0 +1,107 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbaradiobutton.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_RADIOBUTTON_HXX
-+#define SC_VBA_RADIOBUTTON_HXX
-+#include <ooo/vba/msforms/XRadioButton.hpp>
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
-+#include <cppuhelper/implbase2.hxx>
++#ifndef SC_VBA_COMMANDBAR_HXX
++#define SC_VBA_COMMANDBAR_HXX
 +
-+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > RadioButtonImpl_BASE;
++#include <ooo/vba/XCommandBar.hpp>
++#include <com/sun/star/ui/XUIConfigurationManager.hpp>
++#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
++#include <com/sun/star/container/XIndexContainer.hpp>
++#include <com/sun/star/beans/PropertyValues.hpp>
 +
-+class ScVbaRadioButton : public RadioButtonImpl_BASE
++#include <vbahelper/vbahelperinterface.hxx>
++#include "vbacommandbars.hxx"
++
++#include <map>
++typedef std::map< const rtl::OUString, rtl::OUString > CommandBarNameMap;
++typedef std::pair< const rtl::OUString, rtl::OUString > CommandBarNamePair;
++const CommandBarNamePair namePair[] = { 
++    CommandBarNamePair(  rtl::OUString::createFromAscii("standard"), rtl::OUString::createFromAscii("standardbar") ),
++    CommandBarNamePair(  rtl::OUString::createFromAscii("formatting"), rtl::OUString::createFromAscii("formatobjectbar") ),
++};
++static const CommandBarNameMap mCommandBarNameMap( namePair, ( namePair + sizeof(namePair) / sizeof(namePair[0]) ) );
++
++
++typedef InheritedHelperInterfaceImpl1< ov::XCommandBar > CommandBar_BASE;
++
++class ScVbaCommandBar : public CommandBar_BASE
 +{
++private:
++    rtl::OUString       m_sToolBarName;
++    rtl::OUString       m_sMenuModuleName;
++    rtl::OUString       m_sUIName;
++    sal_Bool            m_bTemporary;
++    sal_Bool            m_bIsMenu;
++    sal_Bool            m_bCustom;
++    sal_Bool            m_bCreate;
++    ScVbaCommandBars*   m_pScVbaCommandBars;
++    css::beans::PropertyValues  m_aToolBar;
++    // hard reference for parent
++    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++    void initCommandBar() throw( css::uno::RuntimeException );
++protected:
++    void getToolBarSettings( rtl::OUString sToolBarName ) throw( css::uno::RuntimeException );
++    void getMenuSettings();
++    void addCustomBar();
 +public:
-+    ScVbaRadioButton( 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 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::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException);
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+    // XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
++    ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw( css::uno::RuntimeException );
++    ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw( css::uno::RuntimeException );
++    
++    sal_Bool IsMenu() { return m_bIsMenu; };
++    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
++    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
++    css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
++    rtl::OUString GetToolBarName() { return m_sToolBarName; };
++
++    // Attributes
++    virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setName( const ::rtl::OUString& _name ) throw (css::uno::RuntimeException);
++    virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
++
++    // Methods
++    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual sal_Int32 SAL_CALL Type(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL FindControl( const css::uno::Any& aType, const css::uno::Any& aId, const css::uno::Any& aTag, const css::uno::Any& aVisible, const css::uno::Any& aRecursive ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
 +
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+#endif //SC_VBA_RADIOBUTTON_HXX
-diff --git vbahelper/source/msforms/vbascrollbar.cxx vbahelper/source/msforms/vbascrollbar.cxx
++#endif//SC_VBA_COMMANDBAR_HXX
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
 new file mode 100644
-index 0000000..e754903
+index 0000000..8a39074
 --- /dev/null
-+++ vbahelper/source/msforms/vbascrollbar.cxx
-@@ -0,0 +1,139 @@
++++ vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+@@ -0,0 +1,443 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -13911,304 +27951,421 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbascrollbar.hxx"
-+#include <vector>
++#include "vbacommandbarcontrol.hxx"
++#include <basic/sbstar.hxx>
++#include <basic/sbmod.hxx>
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
-+
-+const static rtl::OUString LARGECHANGE( RTL_CONSTASCII_USTRINGPARAM("BlockIncrement") );
-+const static rtl::OUString SMALLCHANGE( RTL_CONSTASCII_USTRINGPARAM("LineIncrement") );
-+const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") );
-+const static rtl::OUString SCROLLVALUE( RTL_CONSTASCII_USTRINGPARAM("ScrollValue") );
-+const static rtl::OUString SCROLLMAX( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMax") );
-+const static rtl::OUString SCROLLMIN( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMin") );
-+
-+ScVbaScrollBar::ScVbaScrollBar(  const css::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 ) : ScrollBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName )
 +{
++    sal_Int32 nCount = aPropertyValues.getLength();
++    for( sal_Int32 i = 0; i < nCount; i++ )
++    {
++        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
++        {
++            return aPropertyValues[i].Value;
++        }
++    }
++    return uno::Any();
 +}
 +
-+// Attributes
-+uno::Any SAL_CALL 
-+ScVbaScrollBar::getValue() throw (css::uno::RuntimeException)
++beans::PropertyValues lcl_repalcePropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName, uno::Any aValue )
 +{
-+    return  m_xProps->getPropertyValue( SCROLLVALUE );
++    sal_Int32 nCount = aPropertyValues.getLength();
++    for( sal_Int32 i = 0; i < nCount; i++ )
++    {
++        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
++        {
++            aPropertyValues[i].Value = aValue;
++            return aPropertyValues;
++        }
++    }
++    return aPropertyValues;
 +}
 +
-+void SAL_CALL 
-+ScVbaScrollBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Int32 nType ) throw (uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), m_sName( sName ), m_nPosition( nPosition ), m_nType( nType )
 +{
-+    m_xProps->setPropertyValue( SCROLLVALUE, _value );
++    // exsiting CommandBarBarControl
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initObjects();
++    if( m_xBarSettings->hasElements() )
++    {
++        ScVbaCommandBarControl* pParentCommandBarControl = m_pCommandBarControls->GetParentCommandBarControl();
++        if( pParentCommandBarControl )
++        {
++            beans::PropertyValues aPropertyValues;
++            pParentCommandBarControl->GetCurrentSettings()->getByIndex( pParentCommandBarControl->GetPosition() ) >>= aPropertyValues;
++            pParentCommandBarControl->SetPropertyValues( aPropertyValues );
++            m_xCurrentSettings.set( lcl_getPropertyValue( pParentCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY_THROW );
++        }
++        if( !m_xCurrentSettings.is() )
++        {
++            m_xCurrentSettings.set( m_xUICfgManager->getSettings( m_pCommandBarControls->GetParentToolBarName(), sal_True ), uno::UNO_QUERY_THROW );
++        }
++    }
++    if( m_bIsMenu )
++    {
++        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
++    }
++    else
++    {
++        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
++    }
++    m_bTemporary = sal_True;
 +}
-+
-+::sal_Int32 SAL_CALL 
-+ScVbaScrollBar::getMax() throw (uno::RuntimeException)
++ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType) throw (uno::RuntimeException) :  CommandBarControl_BASE( xParent, xContext ), m_nPosition( nPosition ), m_bTemporary( bTemporary ), m_nType( nType )
 +{
-+    sal_Int32 nMax = 0;
-+    m_xProps->getPropertyValue( SCROLLMAX ) >>= nMax;
-+    return nMax;
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initObjects();
++    if( sName.getLength() > 0 )
++    {
++        m_sName = sName;
++    }
++    m_sCommand = rtl::OUString::createFromAscii("vnd.openoffice.org:") + sName;
++    if( m_bIsMenu )
++    {
++        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
++        createNewMenuBarControl();
++    }
++    else
++    {
++        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
++        createNewToolBarControl();
++    }
 +}
 +
-+void SAL_CALL 
-+ScVbaScrollBar::setMax( sal_Int32 nVal ) throw (uno::RuntimeException)
++void
++ScVbaCommandBarControl::initObjects() throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( SCROLLMAX, uno::makeAny( nVal ) ); 
++    m_pCommandBarControls = dynamic_cast< ScVbaCommandBarControls* >( m_xParentHardRef.get() );
++    if( !m_pCommandBarControls )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBarControls"), uno::Reference< uno::XInterface >() );
++    m_xUICfgManager.set( m_pCommandBarControls->GetUICfgManager(), uno::UNO_QUERY_THROW );
++    m_xUICfgPers.set( m_pCommandBarControls->GetUICfgPers(), uno::UNO_QUERY_THROW );
++    m_xBarSettings.set( m_pCommandBarControls->GetBarSettings(), uno::UNO_QUERY_THROW );
++    m_bIsMenu = m_pCommandBarControls->IsMenu();
++    m_sName = rtl::OUString::createFromAscii( "Custom" );
 +}
 +
-+::sal_Int32 SAL_CALL 
-+ScVbaScrollBar::getMin() throw (uno::RuntimeException)
++void
++ScVbaCommandBarControl::createNewMenuBarControl()
 +{
-+    sal_Int32 nVal = 0;
-+    m_xProps->getPropertyValue( SCROLLMIN ) >>= nVal;
-+    return nVal;
++    uno::Reference< lang::XSingleComponentFactory > xMenuMSF( m_xBarSettings, uno::UNO_QUERY_THROW );
++
++    uno::Sequence< beans::PropertyValue > aPropertys;
++    if( m_nType == office::MsoControlType::msoControlPopup )
++        aPropertys = uno::Sequence< beans::PropertyValue >( 4 );
++    else
++        aPropertys = uno::Sequence< beans::PropertyValue >( 3 );
++
++    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
++    aPropertys[0].Value <<= m_sCommand; 
++    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
++    aPropertys[1].Value <<= m_sName; 
++    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
++    aPropertys[2].Value <<= sal_Int32(0); 
++
++    if( m_nType == office::MsoControlType::msoControlPopup )
++    {
++        aPropertys[3].Name = rtl::OUString::createFromAscii("ItemDescriptorContainer");
++        aPropertys[3].Value <<= xMenuMSF->createInstanceWithContext( mxContext );
++    }    
++
++    if( m_pCommandBarControls->GetParentCommandBar() != NULL )
++    {
++        // create a new menu
++        m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++        m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
++    }
++    else if( m_pCommandBarControls->GetParentCommandBarControl() != NULL )
++    {
++        // create a new menu entry
++        ScVbaCommandBarControl* pPc = m_pCommandBarControls->GetParentCommandBarControl();
++        beans::PropertyValues aPropertyValues;
++        pPc->GetCurrentSettings()->getByIndex( pPc->GetPosition() ) >>= aPropertyValues;
++        pPc->SetPropertyValues( aPropertyValues );
++        
++        // has the property already been set?
++        if( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ).hasValue() )
++        {
++            lcl_repalcePropertyValue(  pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer"), uno::makeAny( xMenuMSF->createInstanceWithContext( mxContext ) ) );
++            pPc->GetCurrentSettings()->replaceByIndex( pPc->GetPosition(), uno::makeAny( pPc->GetPropertyValues() ) );
++        }
++        m_xCurrentSettings.set( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY_THROW );
++        m_xCurrentSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++    }
++    if( m_xUICfgManager->hasSettings( m_sBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
 +}
 +
-+void SAL_CALL 
-+ScVbaScrollBar::setMin( sal_Int32 nVal ) throw (uno::RuntimeException)
++void
++ScVbaCommandBarControl::createNewToolBarControl()
 +{
-+    m_xProps->setPropertyValue( SCROLLMIN, uno::makeAny( nVal ) ); 
++    uno::Sequence< beans::PropertyValue > aPropertys(4);
++    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
++    aPropertys[0].Value <<= m_sCommand; 
++    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
++    aPropertys[1].Value <<= m_sName; 
++    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
++    aPropertys[2].Value <<= sal_Int32(0); 
++    aPropertys[3].Name = rtl::OUString::createFromAscii("IsVisible");
++    aPropertys[3].Value <<= sal_True; 
++
++    m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    rtl::OUString sUIName;
++    xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") ) >>= sUIName;
++
++    m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
++    if( m_xUICfgManager->hasSettings( m_sBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
 +}
 +
++::rtl::OUString SAL_CALL
++ScVbaCommandBarControl::getCaption() throw ( uno::RuntimeException )
++{
++    // "Label" always empty
++    rtl::OUString sCaption;
++    beans::PropertyValues aPropertyValues;
++    if( m_xCurrentSettings.is() )
++    {
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
++    }
++    else if( m_xBarSettings.is() )
++    {
++        m_xBarSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
++    }
++    return sCaption;
++}
 +void SAL_CALL 
-+ScVbaScrollBar::setLargeChange( ::sal_Int32 _largechange ) throw (uno::RuntimeException)
++ScVbaCommandBarControl::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( LARGECHANGE, uno::makeAny( _largechange ) );
++    if( m_xCurrentSettings.is() )
++    {
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        beans::PropertyValues aNewPropertyValues;
++        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label"), uno::makeAny( _caption ) );
++        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
 +}
-+
-+::sal_Int32 SAL_CALL 
-+ScVbaScrollBar::getLargeChange() throw (uno::RuntimeException)
++::rtl::OUString SAL_CALL 
++ScVbaCommandBarControl::getOnAction() throw (uno::RuntimeException)
 +{
-+    sal_Int32 nVal = 0;
-+    m_xProps->getPropertyValue( LARGECHANGE ) >>= nVal;
-+    return nVal;
++    if( m_xCurrentSettings.is() )
++    {
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        rtl::OUString sCommandURL;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
++        return sCommandURL;
++    }
++    return ::rtl::OUString();
 +}
++void SAL_CALL 
++ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        // convert the comand url into something like vnd.sun.star.script:Standard.testMacro.Macro1?language=Basic&location=document
++        rtl::OUString aCommandURL;
++        rtl::OUString sUrlPart = rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.");
++        SbModule* pModule = StarBASIC::GetActiveModule();
++        if( pModule && ( _onaction.indexOf( sUrlPart ) == -1 ) )
++        {
++            rtl::OUString sUrlPart1 = rtl::OUString::createFromAscii( "?language=Basic&location=document");
++            aCommandURL = sUrlPart.concat( pModule->GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( _onaction ).concat( sUrlPart1 );
++        }
++        else
++        {
++            aCommandURL = _onaction;
++        }
++		OSL_TRACE(" ScVbaCommandBarControl::setOnAction: %s", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr() );
 +
-+::sal_Int32 SAL_CALL 
-+ScVbaScrollBar::getSmallChange() throw (uno::RuntimeException)
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        beans::PropertyValues aNewPropertyValues;
++        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURL ) );
++        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
++}
++::sal_Bool SAL_CALL 
++ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
 +{
-+    sal_Int32 nSmallChange = 0;
-+    m_xProps->getPropertyValue( SMALLCHANGE ) >>= nSmallChange;
-+    return nSmallChange;
++    // not possible in UNO?
++    return sal_True;
++}
++void SAL_CALL 
++ScVbaCommandBarControl::setVisible( ::sal_Bool /*_visible*/ ) throw (uno::RuntimeException)
++{
++    // "IsVisilbe"
++}
++void SAL_CALL 
++ScVbaCommandBarControl::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        m_xCurrentSettings->removeByIndex( m_nPosition );
++
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
 +}
-+
-+void SAL_CALL 
-+ScVbaScrollBar::setSmallChange( ::sal_Int32 _smallchange ) throw (uno::RuntimeException)
++uno::Any SAL_CALL 
++ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( SMALLCHANGE, uno::makeAny( _smallchange ) );
++    sal_Int32 nIndex;
++    uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >() ) );
++    if( aIndex.hasValue() )
++    {
++        if( aIndex >>= nIndex )
++        {
++            uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
++            return uno::makeAny( xCommandBarControl );
++        }
++        else
++            throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid index" ), uno::Reference< uno::XInterface >() );
++    }
++    return uno::makeAny( xCommandBarControls );
 +}
-+
 +rtl::OUString& 
-+ScVbaScrollBar::getServiceImplName()
++ScVbaCommandBarControl::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaScrollBar") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControl") );
 +	return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaScrollBar::getServiceNames()
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarControl::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControl" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbascrollbar.hxx vbahelper/source/msforms/vbascrollbar.hxx
-new file mode 100644
-index 0000000..459f610
---- /dev/null
-+++ vbahelper/source/msforms/vbascrollbar.hxx
-@@ -0,0 +1,66 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#ifndef SC_VBA_SCROLLBAR_HXX
-+#define SC_VBA_SCROLLBAR_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XScrollBar.hpp>
-+
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
-+
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XScrollBar > ScrollBarImpl_BASE;
-+
-+class ScVbaScrollBar : public ScrollBarImpl_BASE
-+{
-+public:
-+    ScVbaScrollBar( 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);
-+    virtual ::sal_Int32 SAL_CALL getMax() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException);
-+    virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException);
-+    virtual ::sal_Int32 SAL_CALL getLargeChange() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setLargeChange( ::sal_Int32 _largechange ) throw (css::uno::RuntimeException);
-+    virtual ::sal_Int32 SAL_CALL getSmallChange() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setSmallChange( ::sal_Int32 _smallchange ) throw (css::uno::RuntimeException);
-+
-+
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+};
-+#endif //SC_VBA_LABEL_HXX
-diff --git vbahelper/source/msforms/vbaspinbutton.cxx vbahelper/source/msforms/vbaspinbutton.cxx
-new file mode 100644
-index 0000000..05b6777
---- /dev/null
-+++ vbahelper/source/msforms/vbaspinbutton.cxx
-@@ -0,0 +1,109 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+#include "vbaspinbutton.hxx"
-+#include <vector>
-+
-+using namespace com::sun::star;
-+using namespace ooo::vba;
-+
-+
-+const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") );
-+const static rtl::OUString SPINVALUE( RTL_CONSTASCII_USTRINGPARAM("SpinValue") );
-+const static rtl::OUString SPINMAX( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") );
-+const static rtl::OUString SPINMIN( RTL_CONSTASCII_USTRINGPARAM("SpinValueMin") );
-+
-+ScVbaSpinButton::ScVbaSpinButton(  const css::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 ) : SpinButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
-+{
-+}
 +
-+// Attributes
-+uno::Any SAL_CALL 
-+ScVbaSpinButton::getValue() throw (css::uno::RuntimeException)
++//////////// ScVbaCommandBarPopup //////////////////////////////
++ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlPopup )
 +{
-+    return  m_xProps->getPropertyValue( SPINVALUE );
 +}
 +
-+void SAL_CALL 
-+ScVbaSpinButton::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
++ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlPopup) 
 +{
-+    m_xProps->setPropertyValue( SPINVALUE, _value );
 +}
 +
-+::sal_Int32 SAL_CALL 
-+ScVbaSpinButton::getMax() throw (uno::RuntimeException)
++rtl::OUString& 
++ScVbaCommandBarPopup::getServiceImplName()
 +{
-+    sal_Int32 nMax = 0;
-+    m_xProps->getPropertyValue( SPINMAX ) >>= nMax;
-+    return nMax;
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarPopup") );
++	return sImplName;
 +}
-+
-+void SAL_CALL 
-+ScVbaSpinButton::setMax( sal_Int32 nVal ) throw (uno::RuntimeException)
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarPopup::getServiceNames()
 +{
-+    m_xProps->setPropertyValue( SPINMAX, uno::makeAny( nVal ) ); 
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarPopup" ) );
++	}
++	return aServiceNames;
 +}
 +
-+::sal_Int32 SAL_CALL 
-+ScVbaSpinButton::getMin() throw (uno::RuntimeException)
++//////////// ScVbaCommandBarButton //////////////////////////////
++ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlButton )
 +{
-+    sal_Int32 nVal = 0;
-+    m_xProps->getPropertyValue( SPINMIN ) >>= nVal;
-+    return nVal;
 +}
 +
-+void SAL_CALL 
-+ScVbaSpinButton::setMin( sal_Int32 nVal ) throw (uno::RuntimeException)
++ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlButton) 
 +{
-+    m_xProps->setPropertyValue( SPINMIN, uno::makeAny( nVal ) ); 
 +}
 +
 +rtl::OUString& 
-+ScVbaSpinButton::getServiceImplName()
++ScVbaCommandBarButton::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaSpinButton") );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarButton") );
 +	return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaSpinButton::getServiceNames()
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarButton::getServiceNames()
 +{
 +	static uno::Sequence< rtl::OUString > aServiceNames;
 +	if ( aServiceNames.getLength() == 0 )
 +	{
 +		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarButton" ) );
 +	}
 +	return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbaspinbutton.hxx vbahelper/source/msforms/vbaspinbutton.hxx
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.hxx vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
 new file mode 100644
-index 0000000..8f1d6e3
+index 0000000..4d7d133
 --- /dev/null
-+++ vbahelper/source/msforms/vbaspinbutton.hxx
-@@ -0,0 +1,61 @@
++++ vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
+@@ -0,0 +1,120 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -14243,245 +28400,550 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_SPINBUTTON_HXX
-+#define SC_VBA_SPINBUTTON_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XSpinButton.hpp>
++#ifndef SC_VBA_COMMANDBARCONTROL_HXX
++#define SC_VBA_COMMANDBARCONTROL_HXX
 +
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
++#include <ooo/vba/XCommandBarControl.hpp>
++#include <ooo/vba/XCommandBarPopup.hpp>
++#include <ooo/vba/XCommandBarButton.hpp>
++#include <ooo/vba/office/MsoControlType.hpp>
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XSpinButton > SpinButtonImpl_BASE;
++#include <vbahelper/vbahelperinterface.hxx>
++#include "vbacommandbarcontrols.hxx"
 +
-+class ScVbaSpinButton : public SpinButtonImpl_BASE
++typedef InheritedHelperInterfaceImpl1< ov::XCommandBarControl > CommandBarControl_BASE;
++
++class ScVbaCommandBarControl : public CommandBarControl_BASE
 +{
++private:
++    rtl::OUString       m_sName;
++    rtl::OUString       m_sBarName;
++    rtl::OUString       m_sCommand;
++    sal_Int32           m_nType;
++    sal_Int32           m_nPosition;
++    sal_Bool            m_bTemporary;
++    sal_Bool            m_bIsMenu;
++    ScVbaCommandBarControls*        m_pCommandBarControls;
++    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++    css::uno::Reference< css::container::XIndexContainer >          m_xCurrentSettings;
++    css::beans::PropertyValues                                      m_aPropertyValues;
++    
++    void initObjects() throw (css::uno::RuntimeException);
++    void createNewMenuBarControl();
++    void createNewToolBarControl();
 +public:
-+    ScVbaSpinButton( 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);
-+    virtual ::sal_Int32 SAL_CALL getMax() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException);
-+    virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException);
++    ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
++    ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
++    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
++    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
++    css::uno::Reference< css::container::XIndexContainer >  GetBarSettings() { return m_xBarSettings; };
++    sal_Bool IsMenu() { return m_bIsMenu; };
++    sal_Int32 GetPosition() { return m_nPosition; };
++    css::uno::Reference< css::container::XIndexContainer > GetCurrentSettings() { return m_xCurrentSettings; };
++    css::beans::PropertyValues GetPropertyValues() { return m_aPropertyValues; };
++    void SetPropertyValues( css::beans::PropertyValues aPropertyValues ) { m_aPropertyValues = aPropertyValues; };
++    
++    // 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 ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
++    virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
++
++    // Methods
++    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
 +
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+#endif //SC_VBA_SPINBUTTON_HXX
-diff --git vbahelper/source/msforms/vbatextbox.cxx vbahelper/source/msforms/vbatextbox.cxx
++
++typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPopup > CommandBarPopup_BASE;
++class ScVbaCommandBarPopup : public CommandBarPopup_BASE
++{
++public:
++    ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
++    ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarButton > CommandBarButton_BASE;
++class ScVbaCommandBarButton : public CommandBarButton_BASE
++{
++public:
++    ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
++    ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif//SC_VBA_COMMANDBARCONTROL_HXX
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
 new file mode 100644
-index 0000000..d246970
+index 0000000..2b79cff
 --- /dev/null
-+++ vbahelper/source/msforms/vbatextbox.cxx
-@@ -0,0 +1,137 @@
++++ vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+@@ -0,0 +1,349 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbatextbox.cxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
 + *
-+ * 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.
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, 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).
++ *    This library 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 for more details.
 + *
-+ * 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.
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include <com/sun/star/text/XTextRange.hpp>
-+
-+#include "vbatextbox.hxx"
-+#include <vector>
++#include "vbacommandbarcontrols.hxx"
++#include "vbacommandbarcontrol.hxx"
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
++uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName );
 +
-+
-+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 )
-+{
-+}
-+
-+// Attributes
-+uno::Any SAL_CALL 
-+ScVbaTextBox::getValue() throw (css::uno::RuntimeException)
++typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarControlEnumeration_BASE;
++class CommandBarControlEnumeration : public CommandBarControlEnumeration_BASE
 +{
-+	return uno::makeAny( getText() );
-+}
++    //uno::Reference< uno::XComponentContext > m_xContext;
++    ScVbaCommandBarControls* m_pCommandBarControls;
++    sal_Int32 m_nCurrentPosition;
++public:
++    CommandBarControlEnumeration( ScVbaCommandBarControls* pCommandBarControls ) : m_pCommandBarControls( pCommandBarControls ), m_nCurrentPosition( 0 ) {}
++    virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
++    {
++        if( m_nCurrentPosition < m_pCommandBarControls->getCount() )
++            return sal_True;
++        return sal_False;
++    }
++    virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
++    {
++        if( hasMoreElements() )
++        {
++            rtl::OUString sName = m_pCommandBarControls->GetControlNameByIndex( m_nCurrentPosition );
++            m_nCurrentPosition = m_nCurrentPosition + 1;
++            if( sName.getLength() > 0 )
++                return m_pCommandBarControls->createCollectionObject( uno::makeAny( sName ) );
++            else
++                return nextElement();
++        }
++        else
++            throw container::NoSuchElementException();
++        return uno::Any();
++    }
++};
 +
-+void SAL_CALL 
-+ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
++ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess> xIndexAccess ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess )
 +{
-+	rtl::OUString sVal = getAnyAsString( _value );
-+	setText( sVal );
-+}
++    m_bIsMenu = sal_False;
++    m_bHasElements = sal_False;
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    m_pCommandBar = dynamic_cast< ScVbaCommandBar* >( m_xParentHardRef.get() );
++    m_pCommandBarControl = dynamic_cast< ScVbaCommandBarControl* >( m_xParentHardRef.get() );
++    if( m_pCommandBar )
++    {
++        m_xUICfgManager.set( m_pCommandBar->GetUICfgManager(), uno::UNO_QUERY_THROW );
++        m_xUICfgPers.set( m_pCommandBar->GetUICfgPers(), uno::UNO_QUERY_THROW );
++        m_xBarSettings.set( m_pCommandBar->GetBarSettings(), uno::UNO_QUERY_THROW );
++        m_bIsMenu = m_pCommandBar->IsMenu();
++        if( m_xBarSettings->hasElements() )
++        {
++            m_bHasElements = sal_True;
++        }
++    }
++    else if( m_pCommandBarControl )
++    {
++        m_xUICfgManager.set( m_pCommandBarControl->GetUICfgManager(), uno::UNO_QUERY_THROW );
++        m_xUICfgPers.set( m_pCommandBarControl->GetUICfgPers(), uno::UNO_QUERY_THROW );
++        beans::PropertyValues aPropertyValues;
++        m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
++        m_pCommandBarControl->SetPropertyValues( aPropertyValues );
++        m_xBarSettings.set( m_pCommandBarControl->GetCurrentSettings(), uno::UNO_QUERY_THROW );
 +
-+//getString() will cause some imfo lose.
-+rtl::OUString SAL_CALL 
-+ScVbaTextBox::getText() throw (css::uno::RuntimeException)
-+{
-+    uno::Any aValue;
-+    aValue = m_xProps->getPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) );
-+    rtl::OUString sString;
-+    aValue >>= sString;
-+    return sString;
++        uno::Any aValue = lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") );
++        if( aValue.hasValue() )
++        {
++            m_xCurrentSettings = m_pCommandBarControl->GetCurrentSettings();
++            m_bHasElements = sal_True;
++        }
++        else
++        {
++            m_bHasElements = sal_False;
++        }
++        m_bIsMenu = m_pCommandBarControl->IsMenu();
++    }
++    else
++    {
++        throw uno::RuntimeException( rtl::OUString::createFromAscii("Parent needs to be a ScVbaCommandBar or a ScVbaCommandBarControl"), uno::Reference< uno::XInterface >() );
++    }
 +}
-+
-+void SAL_CALL 
-+ScVbaTextBox::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
++rtl::OUString
++ScVbaCommandBarControls::GetControlNameByIndex( const sal_Int32 nIndex ) throw ( uno::RuntimeException )
 +{
-+    if ( !mbDialog )
++    sal_Int32 nCount = 0;
++    if( m_bHasElements )
 +    {
-+    uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
-+    xTextRange->setString( _text );
-+}
++        sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
++        for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
++        {
++            beans::PropertyValues aMenuValues;
++            m_xBarSettings->getByIndex( i ) >>= aMenuValues;
++            for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
++            {
++                if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
++                {
++                    nCount++;
++                    if( nIndex == nCount )
++                    {
++                        rtl::OUString sCommandURL;
++                        aMenuValues[j].Value >>= sCommandURL;
++                        sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
++                        if( ( nLastIndex != -1 ) && ( ( nLastIndex +1 ) < sCommandURL.getLength() ) )
++                        {
++                            sCommandURL = sCommandURL.copy( nLastIndex + 1 );
++                            return sCommandURL;
++                        }
++                    }
++                }
++            }
++        } 
++    }
 +    else
-+        m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), uno::makeAny( _text ) ); 
++        throw  uno::RuntimeException( rtl::OUString::createFromAscii( "Out of bound" ), uno::Reference< uno::XInterface >() );
++    return rtl::OUString();
 +}
 +
++// Attributes
 +sal_Int32 SAL_CALL 
-+ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
++ScVbaCommandBarControls::getCount() throw (uno::RuntimeException)
 +{
-+    uno::Any aValue;
-+    aValue = m_xProps->getPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ) );
-+    sal_Int32 nMaxLength = 0;
-+    aValue >>= nMaxLength;
-+    return nMaxLength;
++    sal_Int32 nCount = 0;
++    if( m_bHasElements )
++    {
++        sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
++        for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
++        {
++            beans::PropertyValues aMenuValues;
++            m_xBarSettings->getByIndex( i ) >>= aMenuValues;
++            for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
++            {
++                if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
++                {
++                    nCount++;
++                }
++            }
++        } 
++    }
++    return nCount;
 +}
-+
-+void SAL_CALL 
-+ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
++// XEnumerationAccess
++uno::Type SAL_CALL
++ScVbaCommandBarControls::getElementType() throw ( uno::RuntimeException )
 +{
-+    uno::Any aValue( _maxlength );
-+    m_xProps->setPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue);
++    return XCommandBarControls::static_type( 0 );
 +}
-+
-+sal_Bool SAL_CALL 
-+ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException)
++uno::Reference< container::XEnumeration >
++ScVbaCommandBarControls::createEnumeration() throw ( uno::RuntimeException )
 +{
-+    uno::Any aValue;
-+    aValue = m_xProps->getPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ) );
-+    sal_Bool bRet = false;
-+    aValue >>= bRet;
-+    return bRet;
++    return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) );
 +}
++uno::Any
++ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
++{
++    // only surport the aSource as a name string, because this class is a API wrapper
++    rtl::OUString sName;
++    if( aSource >>= sName )
++    {
++        uno::Reference< container::XIndexContainer > xCurrentSettings;
++        beans::PropertyValues aPropertyValues;
++        if( m_pCommandBarControl )
++        {
++            m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
++            xCurrentSettings.set( lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY );
++            if( !xCurrentSettings.is() )
++            {
++                xCurrentSettings.set( m_xUICfgManager->getSettings( GetParentToolBarName(), sal_True ), uno::UNO_QUERY );
++            }
++        }
 +
-+void SAL_CALL 
-+ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException)
++        sal_Int32 nPosition = -1;
++        for( sal_Int32 i = 0; i < xCurrentSettings->getCount(); i++ )
++        {
++            xCurrentSettings->getByIndex( i ) >>= aPropertyValues;
++            // Label always empty in OOo
++            rtl::OUString sLabel;
++            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel;
++            if( sLabel.equalsIgnoreAsciiCase( sName ) )
++            {
++                nPosition = i;
++                break;
++            }
++            // using CammandURL to find
++            rtl::OUString sCommandURL;
++            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
++            sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
++            if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sCommandURL.getLength() ) )
++            {
++                sCommandURL = sCommandURL.copy( nLastIndex + 1 );
++            }
++            if( sCommandURL.equalsIgnoreAsciiCase( sName ) )
++            {
++                nPosition = i;
++                break;
++            }
++        }
++
++        if( nPosition  != -1 )
++        {
++            uno::Reference< container::XIndexContainer > xSubMenu;
++            lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ) >>= xSubMenu;
++            ScVbaCommandBarControl* pNewCommandBarControl = NULL;
++            if( xSubMenu.is() )
++                pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sName, nPosition );
++            else
++                pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sName, nPosition );
++
++            return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
++        }
++        else
++            throw uno::RuntimeException( rtl::OUString::createFromAscii("The CommandBarControl do not exist"), uno::Reference< uno::XInterface >() );
++        
++    }
++    return uno::Any();
++}
++
++// Methods
++uno::Any SAL_CALL 
++ScVbaCommandBarControls::Item( const uno::Any& aIndex, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException)
 +{
-+    uno::Any aValue( _multiline );
-+    m_xProps->setPropertyValue
-+            (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
++    if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
++    {
++        return createCollectionObject( aIndex );
++    } 
++    sal_Int32 nIndex = 0;
++    if( aIndex >>= nIndex )
++    {
++        return createCollectionObject( uno::makeAny( GetControlNameByIndex( nIndex ) ) );
++    }
++    
++    return uno::Any();
 +}
++uno::Reference< XCommandBarControl > SAL_CALL 
++ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& /*Parameter*/, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // Parameter is not supported
++    // the following name needs to be individually created;
++    rtl::OUString sCaption( rtl::OUString::createFromAscii("custom Control") );
++    rtl::OUString sCommand( rtl::OUString::createFromAscii("macro:///Standard.Module1.Test()") );
++    sal_Int32 nType =0;
++    sal_Int32 nPosition = 0;
++    sal_Int32 nId;
++    sal_Bool bTemporary = sal_True;
++    
++    if( Type.hasValue() )
++        if( Type >>= nType )
++        {
++            // evalute the type of the new control
++        }
++    if( Id.hasValue() )
++        if( Id >>= nId )
++        {
++            // evalute the action of the new control
++        }
++    if( Before.hasValue() )
++        Before >>= nPosition;
++    else
++    {
++        // if Before is ignore, the new control should be placed at the end of the commandbars;
++        if( m_pCommandBar )
++            nPosition = getCount();
++        else if ( m_pCommandBarControl )
++        {
++            css::uno::Reference< css::container::XIndexContainer > xCurrentSettings;
++            xCurrentSettings.set( lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY );
++            if( xCurrentSettings.is() )
++            {
++                nPosition = xCurrentSettings->getCount();
++            }
++        }
++    }
++    if( Temporary.hasValue() )
++        if( Temporary >>= bTemporary )
++        {
++            // evalute the temporary of the new Control
++        }
++    
++    ScVbaCommandBarControl* pNewCommandBarControl = NULL;
++    if( nType == office::MsoControlType::msoControlButton )
++    {
++        pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sCaption, nPosition, bTemporary );
++    }
++    else if ( nType == office::MsoControlType::msoControlPopup )
++    {
++        pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sCaption, nPosition, bTemporary );
++    }
++    else
++    {
++        pNewCommandBarControl = new ScVbaCommandBarControl( this, mxContext, sCaption, nPosition, bTemporary );
++    }
 +
++    return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
++}
++   
++// XHelperInterface
 +rtl::OUString& 
-+ScVbaTextBox::getServiceImplName()
++ScVbaCommandBarControls::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox") );
-+	return sImplName;
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControls") );
++    return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaTextBox::getServiceNames()
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarControls::getServiceNames()
 +{
-+	static uno::Sequence< rtl::OUString > aServiceNames;
-+	if ( aServiceNames.getLength() == 0 )
-+	{
-+		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.TextBox" ) );
-+	}
-+	return aServiceNames;
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBarControls" ) );
++    }
++    return aServiceNames;
 +}
-diff --git vbahelper/source/msforms/vbatextbox.hxx vbahelper/source/msforms/vbatextbox.hxx
++
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.hxx vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
 new file mode 100644
-index 0000000..3abe491
+index 0000000..ff00609
 --- /dev/null
-+++ vbahelper/source/msforms/vbatextbox.hxx
-@@ -0,0 +1,57 @@
++++ vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+@@ -0,0 +1,91 @@
 +/*************************************************************************
 + *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
++ *  OpenOffice.org - a multi-platform office productivity suite
 + *
-+ * OpenOffice.org - a multi-platform office productivity suite
++ *  $RCSfile$
 + *
-+ * $RCSfile: vbatextbox.hxx,v $
-+ * $Revision: 1.3 $
++ *  $Revision$
 + *
-+ * This file is part of OpenOffice.org.
++ *  last change: $Author$ $Date$
 + *
-+ * 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.
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
 + *
-+ * 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.
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_TEXTBOX_HXX
-+#define SC_VBA_TEXTBOX_HXX
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XTextBox.hpp>
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
++#ifndef SC_VBA_COMMANDBARCONTROLS_HXX
++#define SC_VBA_COMMANDBARCONTROLS_HXX
 +
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XTextBox > TextBoxImpl_BASE;
++#include <ooo/vba/XCommandBarControls.hpp>
 +
-+class ScVbaTextBox : public TextBoxImpl_BASE
++#include <vbahelper/vbahelperinterface.hxx>
++#include "vbacommandbar.hxx"
++#include <vbahelper/vbacollectionimpl.hxx>
++
++class ScVbaCommandBarControl;
++
++typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
++
++class ScVbaCommandBarControls : public CommandBarControls_BASE
 +{
-+    bool mbDialog;
++private:
++    sal_Bool                    m_bIsMenu;
++    sal_Bool                    m_bHasElements;
++    ScVbaCommandBar*            m_pCommandBar; 
++    ScVbaCommandBarControl*     m_pCommandBarControl; 
++    css::uno::Reference< ov::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++    css::uno::Reference< css::container::XIndexContainer >          m_xCurrentSettings;
++
 +public:
-+    ScVbaTextBox( 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, bool bDialog = false );
-+   // 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 getText() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException);
-+    virtual sal_Int32 SAL_CALL getMaxLength() throw (css::uno::RuntimeException);
-+    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);
-+    //XHelperInterface
++    ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess ) throw( css::uno::RuntimeException );
++    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
++    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
++    css::uno::Reference< css::container::XIndexContainer >  GetBarSettings() { return m_xBarSettings; };
++    sal_Bool IsMenu() { return m_bIsMenu; };
++    ScVbaCommandBar* GetParentCommandBar() { return m_pCommandBar; };
++    ScVbaCommandBarControl* GetParentCommandBarControl() { return m_pCommandBarControl; };
++    rtl::OUString GetParentToolBarName() 
++    { 
++        if( m_pCommandBar ) return m_pCommandBar->GetToolBarName();
++        else return rtl::OUString();
++    }
++    rtl::OUString GetControlNameByIndex( const sal_Int32 nIndex ) throw ( css::uno::RuntimeException );
++
++    // Attributes
++    virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
++    // XEnumerationAccess
++    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
++
++    // Methods     
++    virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException); 
++    virtual css::uno::Reference< ov::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    // XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
 +};
-+#endif //SC_VBA_TEXTBOX_HXX
-diff --git vbahelper/source/msforms/vbatogglebutton.cxx vbahelper/source/msforms/vbatogglebutton.cxx
++
++#endif//SC_VBA_COMMANDBARCONTROLS_HXX
+diff --git vbahelper/source/vbahelper/vbacommandbars.cxx vbahelper/source/vbahelper/vbacommandbars.cxx
 new file mode 100644
-index 0000000..f938ad1
+index 0000000..66a1652
 --- /dev/null
-+++ vbahelper/source/msforms/vbatogglebutton.cxx
-@@ -0,0 +1,108 @@
++++ vbahelper/source/vbahelper/vbacommandbars.cxx
+@@ -0,0 +1,261 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -14516,86 +28978,239 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#include "vbatogglebutton.hxx"
-+#include <vector>
++#include <com/sun/star/lang/XServiceInfo.hpp>
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
++
++#include "vbacommandbars.hxx"
++#include "vbacommandbar.hxx"
 +
 +using namespace com::sun::star;
 +using namespace ooo::vba;
 +
++typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarEnumeration_BASE;
 +
-+const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-+const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
-+const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
-+ScVbaToggleButton::ScVbaToggleButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : ToggleButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
++static rtl::OUString sSpreadsheetDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" ) );
++static rtl::OUString sTextDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" ) );
++static rtl::OUString sWindowStateConfUrl( rtl::OUString::createFromAscii( "com.sun.star.ui.WindowStateConfiguration" ) );
++
++class CommandBarEnumeration : public CommandBarEnumeration_BASE
++{
++    uno::Reference< uno::XComponentContext > m_xContext;
++    uno::Reference< XCommandBars > m_xCommandBars;
++    uno::Sequence< rtl::OUString > m_sNames;
++    sal_Int32 m_nCurrentPosition;
++public:
++    CommandBarEnumeration( const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBars > xCommandBars, const uno::Sequence< rtl::OUString > sNames ) : m_xContext( xContext ), m_xCommandBars( xCommandBars ), m_sNames( sNames ), m_nCurrentPosition( 0 )
++    {
++    }
++    virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
++    {
++        if( m_nCurrentPosition < m_sNames.getLength() )
++            return sal_True;
++        return sal_False;
++    }
++    virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
++    {
++        if( hasMoreElements() )
++        {
++            rtl::OUString sName( m_sNames[ m_nCurrentPosition ] );
++            m_nCurrentPosition = m_nCurrentPosition + 1;
++            if( sName.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 ) 
++            {
++                sal_Int32 nLastIndex = sName.lastIndexOf( rtl::OUString::createFromAscii( "/" ) );
++                if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sName.getLength() ) )
++                {
++                   sName = sName.copy( nLastIndex + 1);
++                   if( sName.getLength() > 0 )
++                   {
++                        uno::Reference< XHelperInterface > xHelperInterface( m_xCommandBars, uno::UNO_QUERY_THROW );
++                        uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( xHelperInterface, m_xContext, sName, sal_True, sal_False ) );
++                        if( xCommandBar.is() )
++                            return uno::makeAny( xCommandBar );
++                        else
++                            return nextElement();
++                    }
++                    else
++                        return nextElement();
++                    }
++             }
++             else
++                return nextElement();
++        }
++        else
++            throw container::NoSuchElementException();
++        return uno::Any();
++    }
++};
++
++
++ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess > xIndexAccess ) : CommandBars_BASE( xParent, xContext, xIndexAccess )
 +{
-+    OSL_TRACE("ScVbaToggleButton(ctor)");
-+    m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
++    retrieveObjects();
 +}
-+
-+ScVbaToggleButton::~ScVbaToggleButton()
++void
++ScVbaCommandBars::retrieveObjects() throw ( uno::RuntimeException )
 +{
-+    OSL_TRACE("~ScVbaToggleButton(dtor)");
++    uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument(), uno::UNO_QUERY_THROW );
++    if( xServiceInfo->supportsService( sSpreadsheetDocumentUrl ) )
++    {
++        m_sModuleName = sSpreadsheetDocumentUrl;
++    }
++    else if( xServiceInfo->supportsService( sTextDocumentUrl ) )
++    {
++        m_sModuleName = sTextDocumentUrl;
++    }
++    else
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Unsupported Document" ), uno::Reference< uno::XInterface >() );
++    
++    uno::Reference < lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++    uno::Reference < container::XNameAccess > xNameAccess( xMSF->createInstance( sWindowStateConfUrl ), uno::UNO_QUERY_THROW );
++    m_xNameAccess.set( xNameAccess->getByName( m_sModuleName ), uno::UNO_QUERY_THROW );
 +}
 +
-+// Attributes
-+rtl::OUString SAL_CALL 
-+ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
++// XEnumerationAccess
++uno::Type SAL_CALL 
++ScVbaCommandBars::getElementType() throw ( uno::RuntimeException )
 +{
-+    rtl::OUString Label;
-+    m_xProps->getPropertyValue( LABEL ) >>= Label;
-+    return Label;
++    return XCommandBars::static_type( 0 );
++}
++uno::Reference< container::XEnumeration >
++ScVbaCommandBars::createEnumeration() throw ( uno::RuntimeException )
++{
++    return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( mxContext, this, m_xNameAccess->getElementNames() ) );
 +}
 +
-+void SAL_CALL 
-+ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++uno::Any
++ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
 +{
-+    m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
++    // aSource should be a name at this time, because of the class is API wrapper.
++    rtl::OUString sToolBarName;
++    if( aSource >>= sToolBarName )
++    {
++        sToolBarName = sToolBarName.toAsciiLowerCase();
++        if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") ) )
++        {
++            return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, 0 ) ) );
++        }
++        else if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
++        {
++            return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, 1 ) ) );
++        }
++        else if( checkToolBarExist( sToolBarName ) )
++        {
++            return uno::makeAny( uno::Reference< XCommandBar > (new ScVbaCommandBar( this, mxContext, sToolBarName, sal_True, sal_False ) ) );
++        }
++    }
++    return uno::Any();
 +}
 +
-+uno::Any SAL_CALL 
-+ScVbaToggleButton::getValue() throw (uno::RuntimeException)
++// XCommandBars
++uno::Reference< XCommandBar > SAL_CALL 
++ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Position*/, const css::uno::Any& /*MenuBar*/, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
 +{
-+	sal_Int16 nState = 0;
-+    	m_xProps->getPropertyValue( STATE ) >>= nState;
-+ 	return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
++    // Position - MsoBar MenuBar - sal_Bool
++    // Currently only the Name is supported.
++    rtl::OUString sName;
++    if( !( Name >>= sName ) )
++    {
++        sName = rtl::OUString::createFromAscii("Custom1");
++    }
++    sal_Bool bTemporary = false;
++    if( !( Temporary >>= bTemporary ) )
++    {
++        bTemporary = sal_True;
++    }
++    return uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, sName.toAsciiLowerCase(), bTemporary, sal_True ) );
++}
++sal_Int32 SAL_CALL 
++ScVbaCommandBars::getCount() throw(css::uno::RuntimeException)
++{
++    // Filter out all toolbars from the window collection
++    sal_Int32 nCount = 0;
++    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
++    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
++    {
++        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
++        {
++            nCount++;
++        }
++    }
++    return nCount;
 +}
 +
-+void SAL_CALL 
-+ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
++// ScVbaCollectionBaseImpl
++uno::Any SAL_CALL
++ScVbaCommandBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
 +{
-+	sal_Int16 nState = 0;
-+	_value >>= nState;
-+        OSL_TRACE( "nState - %d", nState );
-+	nState = ( nState == -1 ) ?  1 : 0;
-+        OSL_TRACE( "nState - %d", nState );
-+	m_xProps->setPropertyValue( STATE, uno::makeAny(  nState ) );
++    if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
++    {
++        return createCollectionObject( aIndex );    
++    }
++
++    // hardcode if "aIndex = 1" that would return "main menu".
++    sal_Int16 nIndex = 0;
++    aIndex >>= nIndex;
++    if( nIndex == 1 )
++    {
++        uno::Any aSource;
++        if( m_sModuleName.equalsIgnoreAsciiCase( sSpreadsheetDocumentUrl ) )
++            aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" );
++        else if( m_sModuleName.equalsIgnoreAsciiCase( sTextDocumentUrl ) )
++            aSource <<= rtl::OUString::createFromAscii( "Menu Bar" );
++        if( aSource.hasValue() )    
++            return createCollectionObject( aSource );
++    }
++    return uno::Any();
 +}
 +
++sal_Bool
++ScVbaCommandBars::checkToolBarExist( rtl::OUString sToolBarName )
++{
++    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
++    if( iter != mCommandBarNameMap.end() )
++    {
++        return sal_True;
++    }    
++    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
++    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
++    {
++        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
++        {
++            if( allNames[i].indexOf( sToolBarName ) != -1 )
++            {
++                return sal_True;
++            }
++        }
++    }
++    return sal_False;
++}
++    
++// XHelperInterface
 +rtl::OUString& 
-+ScVbaToggleButton::getServiceImplName()
++ScVbaCommandBars::getServiceImplName()
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
-+	return sImplName;
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBars") );
++    return sImplName;
 +}
-+
-+uno::Sequence< rtl::OUString > 
-+ScVbaToggleButton::getServiceNames()
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBars::getServiceNames()
 +{
-+	static uno::Sequence< rtl::OUString > aServiceNames;
-+	if ( aServiceNames.getLength() == 0 )
-+	{
-+		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
-+	}
-+	return aServiceNames;
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.CommandBars" ) );
++    }
++    return aServiceNames;
 +}
 +
-diff --git vbahelper/source/msforms/vbatogglebutton.hxx vbahelper/source/msforms/vbatogglebutton.hxx
+diff --git vbahelper/source/vbahelper/vbacommandbars.hxx vbahelper/source/vbahelper/vbacommandbars.hxx
 new file mode 100644
-index 0000000..dfa5c1c
+index 0000000..7442002
 --- /dev/null
-+++ vbahelper/source/msforms/vbatogglebutton.hxx
-@@ -0,0 +1,63 @@
++++ vbahelper/source/vbahelper/vbacommandbars.hxx
+@@ -0,0 +1,79 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -14630,273 +29245,286 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_TOGGLEBUTTON_HXX
-+#define SC_VBA_TOGGLEBUTTON_HXX
-+#include <cppuhelper/implbase2.hxx>
-+#include <ooo/vba/msforms/XToggleButton.hpp>
++#ifndef SC_VBA_COMMANDBARS_HXX
++#define SC_VBA_COMMANDBARS_HXX
 +
-+#include "vbacontrol.hxx"
-+#include <vbahelper/vbahelper.hxx>
++#include <ooo/vba/XCommandBar.hpp>
++#include <ooo/vba/XCommandBars.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
 +
-+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XToggleButton, css::script::XDefaultProperty  > ToggleButtonImpl_BASE;
++#include <cppuhelper/implbase1.hxx>
 +
-+class ScVbaToggleButton : public ToggleButtonImpl_BASE
++#include <vbahelper/vbahelperinterface.hxx>
++#include <vbahelper/vbacollectionimpl.hxx>
++
++typedef CollTestImplHelper< ov::XCommandBars > CommandBars_BASE;
++
++class ScVbaCommandBars : public CommandBars_BASE
 +{
-+	rtl::OUString msDftPropName;
++private:
++    css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
++    rtl::OUString m_sModuleName;
++    void retrieveObjects() throw( css::uno::RuntimeException );
 +public:
-+    ScVbaToggleButton( 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 );
-+    ~ScVbaToggleButton();
-+   // 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);
++    ScVbaCommandBars( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess );
 +
-+    virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
-+    virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
-+    //XHelperInterface
++    sal_Bool checkToolBarExist( rtl::OUString sToolBarName );
++    rtl::OUString GetModuleName(){ return m_sModuleName; };
++    css::uno::Reference< css::container::XNameAccess > GetWindows() 
++    { 
++        retrieveObjects();
++        return m_xNameAccess; 
++    };
++    // XCommandBars
++    virtual css::uno::Reference< ov::XCommandBar > SAL_CALL Add( const css::uno::Any& Name, const css::uno::Any& Position, const css::uno::Any& MenuBar, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    // XEnumerationAccess
++    virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
++    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
++
++    virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL Item( const css::uno::Any& aIndex, const css::uno::Any& /*aIndex2*/ ) throw( css::uno::RuntimeException);
++    // XHelperInterface
 +    virtual rtl::OUString& getServiceImplName();
 +    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+    // XDefaultProperty
-+    rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
 +};
-+#endif //SC_VBA_TOGGLEBUTTON_HXX
-diff --git vbahelper/source/msforms/vbauserform.cxx vbahelper/source/msforms/vbauserform.cxx
++
++#endif//SC_VBA_COMMANDBARS_HXX
+diff --git vbahelper/source/vbahelper/vbadocumentbase.cxx vbahelper/source/vbahelper/vbadocumentbase.cxx
 new file mode 100644
-index 0000000..a1116e3
+index 0000000..e53279e
 --- /dev/null
-+++ vbahelper/source/msforms/vbauserform.cxx
-@@ -0,0 +1,226 @@
++++ vbahelper/source/vbahelper/vbadocumentbase.cxx
+@@ -0,0 +1,223 @@
 +/*************************************************************************
 + *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile$
-+ *
-+ *  $Revision$
-+ *
-+ *  last change: $Author$ $Date$
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
 + *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
++ * OpenOffice.org - a multi-platform office productivity suite
 + *
++ * $RCSfile: 
++ * $Revision: 
 + *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ * This file is part of OpenOffice.org.
 + *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
++ * 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.
 + *
-+ *    This library 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 for more details.
++ * 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 along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
++ * 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/vbadocumentbase.hxx>
 +#include <vbahelper/helperdecl.hxx>
-+#include "vbauserform.hxx"
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/awt/XControlContainer.hpp>
-+#include <com/sun/star/beans/PropertyConcept.hpp>
-+#include <basic/sbx.hxx>
-+#include <basic/sbstar.hxx>
-+#include <basic/sbmeth.hxx>
-+#include "vbacontrols.hxx"
++#include <comphelper/unwrapargs.hxx>
++
++#include <com/sun/star/util/XModifiable.hpp>
++#include <com/sun/star/util/XProtectable.hpp>
++#include <com/sun/star/util/XCloseable.hpp>
++#include <com/sun/star/frame/XStorable.hpp>
++#include <com/sun/star/frame/XFrame.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
 +
-+using namespace ::ooo::vba;
-+using namespace ::com::sun::star;
++#include <tools/urlobj.hxx>
++#include <osl/file.hxx>
 +
-+// some little notes
-+// XDialog implementation has the following interesting bits
-+// a Controls property ( which is an array of the container controls )
-+//   each item in the controls array is a XControl, where the model is 
-+//   basically a property bag
-+// additionally the XDialog instance has itself a model
-+//     this model has a ControlModels ( array of models ) property
-+//     the models in ControlModels can be accessed by name
-+// also the XDialog is a XControl ( to access the model above
++using namespace ::com::sun::star;
++using namespace ::ooo::vba;
 +
-+ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) :  ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), static_cast< ooo::vba::AbstractGeometryAttributes* >(0) ),  mbDispose( true )
++VbaDocumentBase::VbaDocumentBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) :VbaDocumentBase_BASE( xParent, xContext ), mxModel(NULL)
 +{
-+    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 ) );
 +}
 +
-+ScVbaUserForm::~ScVbaUserForm()
-+{
++VbaDocumentBase::VbaDocumentBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > xModel ) : VbaDocumentBase_BASE( xParent, xContext ),  mxModel( xModel ) 
++{ 
 +}
 +
-+void SAL_CALL 
-+ScVbaUserForm::Show(  ) throw (uno::RuntimeException)
++VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args,
++    uno::Reference< uno::XComponentContext> const & xContext ) : VbaDocumentBase_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ),  mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) 
 +{
-+	OSL_TRACE("ScVbaUserForm::Show(  )");
-+	short aRet = 0;
-+	if ( m_xDialog.is() )
-+		aRet = m_xDialog->execute();
-+	OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
-+	if ( mbDispose )
-+	{
-+		try
-+		{
-+			uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
-+			m_xDialog = NULL;
-+			xComp->dispose();
-+			mbDispose = false; 
-+		}
-+		catch( uno::Exception& )
-+		{
-+		}
-+	}
 +}
 +
-+rtl::OUString SAL_CALL 
-+ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException)
++::rtl::OUString
++VbaDocumentBase::getName() throw (uno::RuntimeException)
 +{
-+    rtl::OUString sCaption;
-+    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption;
-+    return sCaption;
++	rtl::OUString sName = getModel()->getURL();
++	if ( sName.getLength() )
++	{
++
++		INetURLObject aURL( getModel()->getURL() );
++		::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
++	}
++	else
++	{
++		const static rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM("Title" ) );
++		// process "UntitledX - $(PRODUCTNAME)"
++		uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
++		uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
++		xProps->getPropertyValue(sTitle ) >>= sName;
++		sal_Int32 pos = 0;
++		sName = sName.getToken(0,' ',pos);	
++	}
++	return sName;
 +}
-+void
-+ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++::rtl::OUString
++VbaDocumentBase::getPath() throw (uno::RuntimeException)
 +{
-+    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
++	INetURLObject aURL( getModel()->getURL() );
++	aURL.CutLastName();
++	return aURL.GetURLPath();
 +}
 +
-+void SAL_CALL 
-+ScVbaUserForm::Hide(  ) throw (uno::RuntimeException)
++::rtl::OUString
++VbaDocumentBase::getFullName() throw (uno::RuntimeException)
 +{
-+	mbDispose = false;  // hide not dispose
-+	if ( m_xDialog.is() )
-+		m_xDialog->endExecute();
++	INetURLObject aURL( getModel()->getURL() );
++	return aURL.GetURLPath();
 +}
-+
-+void SAL_CALL 
-+ScVbaUserForm::RePaint(  ) throw (uno::RuntimeException)
++void
++VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg,
++					  const uno::Any &rRouteArg ) throw (uno::RuntimeException)
 +{
-+	// do nothing
-+}
++	sal_Bool bSaveChanges = sal_False;
++	rtl::OUString aFileName;
++	sal_Bool bRouteWorkbook = sal_True;
++
++	rSaveArg >>= bSaveChanges;
++	sal_Bool bFileName =  ( rFileArg >>= aFileName );
++	rRouteArg >>= bRouteWorkbook;
++	uno::Reference< frame::XStorable > xStorable( getModel(), uno::UNO_QUERY_THROW );
++	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
++
++	if( bSaveChanges )
++	{
++		if( xStorable->isReadonly() )
++		{	
++			throw uno::RuntimeException(::rtl::OUString( 
++				RTL_CONSTASCII_USTRINGPARAM( "Unable to save to a read only file ") ),
++                        	uno::Reference< XInterface >() );
++		}
++		if( bFileName )
++			xStorable->storeAsURL( aFileName, uno::Sequence< beans::PropertyValue >(0) ); 
++		else
++			xStorable->store();
++	}	
++	else
++		xModifiable->setModified( false );		
 +
-+void SAL_CALL 
-+ScVbaUserForm::UnloadObject(  ) throw (uno::RuntimeException)
-+{
-+	mbDispose = true;
-+	if ( m_xDialog.is() )
-+		m_xDialog->endExecute();
++	uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY );
++
++	if( xCloseable.is() )
++		// use close(boolean DeliverOwnership)
++	
++		// The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
++		// assume ownership if they object the closure by throwing a CloseVetoException
++		// Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
++		xCloseable->close(sal_True);
++	// If close is not supported by this model - try to dispose it.
++	// But if the model disagree with a reset request for the modify state
++	// we shouldn't do so. Otherwhise some strange things can happen.
++	else
++	{
++		uno::Reference< lang::XComponent > xDisposable ( getCurrentDocument(), uno::UNO_QUERY );
++		if ( xDisposable.is() )
++			xDisposable->dispose();
++	}
 +}
 +
-+rtl::OUString& 
-+ScVbaUserForm::getServiceImplName()
++void
++VbaDocumentBase::Protect( const uno::Any &aPassword ) throw (uno::RuntimeException)
 +{
-+	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
-+	return sImplName;
++	rtl::OUString rPassword;
++	uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
++	SC_VBA_FIXME(("Workbook::Protect stub"));
++	if(  aPassword >>= rPassword )
++		xProt->protect( rPassword );
++	else
++		xProt->protect( rtl::OUString() );
 +}
 +
-+uno::Sequence< rtl::OUString > 
-+ScVbaUserForm::getServiceNames()
++void 
++VbaDocumentBase::Unprotect( const uno::Any &aPassword ) throw (uno::RuntimeException)
 +{
-+	static uno::Sequence< rtl::OUString > aServiceNames;
-+	if ( aServiceNames.getLength() == 0 )
++	rtl::OUString rPassword;
++	uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
++	if( !xProt->isProtected() )
++		throw uno::RuntimeException(::rtl::OUString(
++			RTL_CONSTASCII_USTRINGPARAM( "File is already unprotected" ) ),
++			uno::Reference< XInterface >() );
++	else
 +	{
-+		aServiceNames.realloc( 1 );
-+		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm" ) );
++		if( aPassword >>= rPassword )
++			xProt->unprotect( rPassword );
++		else
++			xProt->unprotect( rtl::OUString() );
 +	}
-+	return aServiceNames;
 +}
-+
-+uno::Reference< beans::XIntrospectionAccess > SAL_CALL 
-+ScVbaUserForm::getIntrospection(  ) throw (uno::RuntimeException)
++		
++void 
++VbaDocumentBase::setSaved( sal_Bool bSave ) throw (uno::RuntimeException)
 +{
-+	return uno::Reference< beans::XIntrospectionAccess >();
++	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
++	xModifiable->setModified( bSave );
 +}
 +
-+uno::Any SAL_CALL 
-+ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++sal_Bool
++VbaDocumentBase::getSaved() throw (uno::RuntimeException)
 +{
-+	throw uno::RuntimeException(); // unsupported operation
++	uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
++	return xModifiable->isModified();
 +}
 +
-+void SAL_CALL 
-+ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++void
++VbaDocumentBase::Save() throw (uno::RuntimeException)
 +{
-+	uno::Any aObject = getValue( aPropertyName );
-+	// The Object *must* support XDefaultProperty here because getValue will
-+	// only return properties that are Objects ( e.g. controls )
-+	// e.g. Userform1.aControl = something
-+	// 'aControl' has to support XDefaultProperty to make sense here
-+	uno::Reference< script::XDefaultProperty > xDfltProp( aObject, uno::UNO_QUERY_THROW );
-+	rtl::OUString aDfltPropName = xDfltProp->getDefaultPropertyName();
-+	uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) );
-+	uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY_THROW );
-+	xPropSet->setPropertyValue( aDfltPropName, aValue );
++	rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Save"));
++	uno::Reference< frame::XModel > xModel = getModel();
++	dispatchRequests(xModel,url);
 +}
 +
-+uno::Any SAL_CALL 
-+ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
++void 
++VbaDocumentBase::Activate() throw (uno::RuntimeException)
 +{
-+	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
-+	uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
-+	uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
-+	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 ) );
-+	return uno::makeAny( xVBAControl );
-+}
++	uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
++	xFrame->activate();
++}	
 +
-+::sal_Bool SAL_CALL 
-+ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
-+{
-+	return sal_False;
-+}
-+uno::Any SAL_CALL 
-+ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
++rtl::OUString& 
++VbaDocumentBase::getServiceImplName()
 +{
-+	uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
-+	uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
-+	if ( index.hasValue() )
-+		return uno::makeAny( xControls->Item( index, uno::Any() ) );
-+	return uno::makeAny( xControls );
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaDocumentBase") );
++	return sImplName;
 +}
 +
-+::sal_Bool SAL_CALL 
-+ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++uno::Sequence< rtl::OUString > 
++VbaDocumentBase::getServiceNames()
 +{
-+	uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
-+	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() );
-+	if ( xControl.is() )
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
 +	{
-+		uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );	
-+		sal_Bool bRes =  xNameAccess->hasByName( aName );
-+	OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes );
-+		return bRes;
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VbaDocumentBase" ) );
 +	}
-+	return sal_False;
-+}
-+
-+namespace userform
-+{
-+namespace sdecl = comphelper::service_decl;
-+sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl;
-+extern sdecl::ServiceDecl const serviceDecl(
-+    serviceImpl,
-+    "ScVbaUserForm",
-+    "ooo.vba.excel.UserForm" );
++	return aServiceNames;
 +}
 +
-diff --git vbahelper/source/msforms/vbauserform.hxx vbahelper/source/msforms/vbauserform.hxx
+diff --git vbahelper/source/vbahelper/vbaglobalbase.cxx vbahelper/source/vbahelper/vbaglobalbase.cxx
 new file mode 100644
-index 0000000..be93dc7
+index 0000000..3ce0f72
 --- /dev/null
-+++ vbahelper/source/msforms/vbauserform.hxx
-@@ -0,0 +1,77 @@
++++ vbahelper/source/vbahelper/vbaglobalbase.cxx
+@@ -0,0 +1,113 @@
 +/*************************************************************************
 + *
 + *  OpenOffice.org - a multi-platform office productivity suite
@@ -14931,119 +29559,91 @@
 + *    MA  02111-1307  USA
 + *
 + ************************************************************************/
-+#ifndef SC_VBA_USERFORM_HXX
-+#define SC_VBA_USERFORM_HXX
-+
-+#include <cppuhelper/implbase1.hxx>
-+#include <ooo/vba/msforms/XUserForm.hpp>
-+#include <com/sun/star/awt/XDialog.hpp>
-+#include <com/sun/star/frame/XModel.hpp>
++#include "vbahelper/vbaglobalbase.hxx"
 +
-+#include <vbahelper/vbahelperinterface.hxx>
-+#include "vbacontrol.hxx"
++#include <cppuhelper/component_context.hxx>
++#include <comphelper/processfactory.hxx>
++#include <com/sun/star/container/XNameContainer.hpp>
 +
-+//typedef InheritedHelperInterfaceImpl1< ov::msforms::XUserForm > ScVbaUserForm_BASE;
-+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE;
++using namespace com::sun::star;
++using namespace ooo::vba;
 +
-+class ScVbaUserForm : public ScVbaUserForm_BASE
++VbaGlobalsBase::VbaGlobalsBase( 
++const uno::Reference< ov::XHelperInterface >& xParent, 
++const uno::Reference< uno::XComponentContext >& xContext) 
++:  Globals_BASE( xParent, xContext )
 +{
-+private:
-+    css::uno::Reference< css::awt::XDialog > m_xDialog;
-+    bool mbDispose;
-+protected:
-+public:
-+    ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
-+    virtual ~ScVbaUserForm();
-+    // 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 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);
-+    //XHelperInterface
-+    virtual rtl::OUString& getServiceImplName();
-+    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-+};
-+#endif
-diff --git vbahelper/source/vbahelper/makefile.mk vbahelper/source/vbahelper/makefile.mk
-new file mode 100644
-index 0000000..8d939b9
---- /dev/null
-+++ vbahelper/source/vbahelper/makefile.mk
-@@ -0,0 +1,58 @@
-+#*************************************************************************
-+#
-+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+# 
-+# Copyright 2008 by Sun Microsystems, Inc.
-+#
-+# OpenOffice.org - a multi-platform office productivity suite
-+#
-+# $RCSfile: makefile.mk,v $
-+#
-+# $Revision: 1.45 $
-+#
-+# 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.
-+#
-+#*************************************************************************
++    // overwrite context with custom one ( that contains the application )
++    ::cppu::ContextEntry_Init aHandlerContextInfo[] =
++    {
++        ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Application" ) ), uno::Any() ) 
++    };
 +
-+PRJ=..$/../
-+PRJNAME=vbahelper
-+TARGET=vbahelper
++    mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), xContext );
 +
-+ENABLE_EXCEPTIONS := TRUE
++}
 +
-+# --- Settings -----------------------------------------------------
++void
++VbaGlobalsBase::init(  uno::Reference< uno::XComponentContext >const& rxContext, const uno::Any& aApplication )
++{
++            uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY_THROW );
++            xNameContainer->replaceByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application") ), aApplication );
++            uno::Reference< XHelperInterface > xParent( aApplication, uno::UNO_QUERY );
++            mxParent = xParent;
++}
 +
-+.INCLUDE :  settings.mk
++uno::Reference< uno::XInterface > SAL_CALL 
++VbaGlobalsBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (uno::Exception, uno::RuntimeException)
++{
++    uno::Reference< uno::XInterface > xReturn;
 +
-+SLOFILES=\
-+    $(SLO)$/vbahelper.obj \
-+    $(SLO)$/vbapropvalue.obj \
++    if ( hasServiceName( aServiceSpecifier ) )
++        xReturn = mxContext->getServiceManager()->createInstanceWithContext( aServiceSpecifier, mxContext );
++    return xReturn;
++}
 +
-+# --- Targets -------------------------------------------------------
++uno::Reference< uno::XInterface > SAL_CALL 
++VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException)
++{
++    
++    uno::Reference< uno::XInterface > xReturn;
 +
-+.INCLUDE :  target.mk
++    if ( hasServiceName( ServiceSpecifier ) )
++        xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext );
++    return xReturn;
++}
 +
-+ALLTAR : \
-+        $(MISC)$/$(TARGET).don \
++uno::Sequence< ::rtl::OUString > SAL_CALL 
++VbaGlobalsBase::getAvailableServiceNames(  ) throw (uno::RuntimeException)
++{
++    static const rtl::OUString names[] = { 
++    // common
++        ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.msforms.UserForm" ) ),
++      };
++    static uno::Sequence< rtl::OUString > serviceNames( names, sizeof( names )/ sizeof( names[0] ) );
++    return serviceNames;
++}
 +
-+$(SLOFILES) : $(MISC)$/$(TARGET).don
++bool
++VbaGlobalsBase::hasServiceName( const rtl::OUString& serviceName )
++{
++    uno::Sequence< rtl::OUString > sServiceNames( getAvailableServiceNames() );
++    sal_Int32 nLen = sServiceNames.getLength();
++    for ( sal_Int32 index = 0; index < nLen; ++index )
++    {
++        if ( sServiceNames[ index ].equals( serviceName ) )
++            return true;
++    }
++    return false;
++}
 +
-+$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
-+        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
-+        echo $@
 +
 diff --git vbahelper/source/vbahelper/vbahelper.cxx vbahelper/source/vbahelper/vbahelper.cxx
 new file mode 100644
-index 0000000..f3634bb
+index 0000000..4e3ce8e
 --- /dev/null
 +++ vbahelper/source/vbahelper/vbahelper.cxx
-@@ -0,0 +1,837 @@
+@@ -0,0 +1,1168 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -15084,6 +29684,7 @@
 +#include <com/sun/star/lang/XMultiComponentFactory.hpp>
 +#include <com/sun/star/beans/XPropertySet.hpp>
 +#include <com/sun/star/beans/XIntrospection.hpp>
++#include <ooo/vba/msforms/XShape.hpp>
 +
 +#include <comphelper/processfactory.hxx>
 +
@@ -15101,10 +29702,20 @@
 +
 +#include <basic/sbx.hxx>
 +#include <basic/sbstar.hxx>
++#include <basic/basmgr.hxx>
++#include <basic/sbmod.hxx>
++#include <basic/sbmeth.hxx>
 +#include <rtl/math.hxx>
 +#include <sfx2/viewsh.hxx>
 +#include <math.h>
-+
++#include <tools/urlobj.hxx>
++#include <osl/file.hxx>
++#include <toolkit/awt/vclxwindow.hxx>
++#include <toolkit/helper/vclunohelper.hxx>
++#include <com/sun/star/frame/XModel2.hpp>
++#include <vcl/window.hxx>
++#include <vcl/syswin.hxx>
++#include <tools/diagnose_ex.h>
 +
 +#ifndef OOVBA_DLLIMPLEMENTATION
 +#define OOVBA_DLLIMPLEMENTATION
@@ -15133,6 +29744,30 @@
 +{
 +namespace vba
 +{
++
++uno::Reference< lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell )
++{
++    uno::Any aUnoVar;
++    if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) )
++        throw lang::IllegalArgumentException();
++    uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW );
++    return xVBAFactory;
++}
++
++css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException)
++{
++    OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
++    ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
++    return getVBAServiceFactory( pShell )->createInstance( sVarName );
++}
++
++css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw ( css::uno::RuntimeException )
++{
++    OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
++    ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
++    uno::Reference< uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs  );
++    return xIf;
++}
 +// helper method to determine if the view ( calc ) is in print-preview mode
 +bool isInPrintPreview( SfxViewFrame* pView )
 +{
@@ -15796,89 +30431,385 @@
 +		}
 +	}
 +
-+	if ( bForLike )
-+		sResult.append(static_cast<sal_Unicode>('$'));
++	if ( bForLike )
++		sResult.append(static_cast<sal_Unicode>('$'));
++
++	return sResult.makeStringAndClear( );
++}
++
++double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
++{
++	double fConvertFactor = 1.0;
++	if( bVertical )
++	{
++		fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000;
++	}
++	else
++	{
++		fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000;	
++	}
++	return fConvertFactor;
++}
++
++double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
++{
++	double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
++	return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor;
++}
++double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
++{
++	double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
++	return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR;
++}
++
++ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape )
++{
++// #FIXME needs to be an instantiable service
++//	m_xShape = new ScVbaShape( xContext, xShape );
++}
++
++static uno::Reference< frame::XController > lcl_getCurrentController()
++{
++    const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
++    uno::Reference< frame::XController > xController;
++    if ( xWorkingDoc.is() )
++        xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW );
++    else
++        xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
++    return xController;
++}
++
++sal_Int32 getPointerStyle()
++{
++    sal_Int32 nPointerStyle( POINTER_ARROW );
++    try
++    {
++        const uno::Reference< frame::XController > xController( lcl_getCurrentController(),     uno::UNO_SET_THROW );
++        const uno::Reference< frame::XFrame >      xFrame     ( xController->getFrame(),        uno::UNO_SET_THROW );
++        const uno::Reference< awt::XWindow >       xWindow    ( xFrame->getContainerWindow(),   uno::UNO_SET_THROW );
++        // why the heck isn't there an XWindowPeer::getPointer, but a setPointer only?
++        const Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
++        if ( pWindow )
++            nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle();
++    }
++    catch( const uno::Exception& )
++    {
++    	DBG_UNHANDLED_EXCEPTION();
++    }
++    return nPointerStyle;
++}
++
++void setCursorHelper( const Pointer& rPointer, sal_Bool bOverWrite )
++{
++    ::std::vector< uno::Reference< frame::XController > > aControllers;
++
++    const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
++    if ( xModel2.is() )
++    {
++        const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW );
++        while ( xEnumControllers->hasMoreElements() )
++        {
++            const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW );
++            aControllers.push_back( xController );
++        }
++    }
++    else
++    {
++        const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
++        if ( xModel.is() )
++        {
++            const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
++            aControllers.push_back( xController );
++        }
++        else
++        {
++            const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
++            aControllers.push_back( xController );
++        }
++    }
++
++    for (   ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin();
++            controller != aControllers.end();
++            ++controller
++        )
++    {
++        const uno::Reference< frame::XFrame >      xFrame     ( (*controller)->getFrame(),       uno::UNO_SET_THROW   );
++        const uno::Reference< awt::XWindow >       xWindow    ( xFrame->getContainerWindow(),    uno::UNO_SET_THROW   );
++
++        Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
++        OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" );
++        if ( !pWindow )
++            continue;
++
++        pWindow->GetSystemWindow()->SetPointer( rPointer );
++        pWindow->GetSystemWindow()->EnableChildPointerOverwrite( bOverWrite );
++    }
++}
++
++String docMacroExists( SfxObjectShell* pShell, const String& sMod, const String& sMacro )
++{
++	String sFullName;	
++	// would use the script provider to see if the macro exists but
++	// called at this stage tdoc content handler stuff is not set up
++	// so it fails
++
++    const static String sLibrary( RTL_CONSTASCII_USTRINGPARAM("Standard"));
++	BasicManager* pBasicMgr = pShell-> GetBasicManager();
++	if ( pBasicMgr )
++	{
++		StarBASIC* pBasic = pBasicMgr->GetLib( sLibrary );
++		if ( !pBasic )
++		{
++			USHORT nId = pBasicMgr->GetLibId( sLibrary );
++			pBasicMgr->LoadLib( nId );
++			pBasic = pBasicMgr->GetLib( sLibrary );
++		}
++		if ( pBasic )
++		{
++			if ( sMod.Len() ) // we wish to find the macro is a specific module
++			{
++				SbModule* pModule = pBasic->FindModule( sMod );
++				if ( pModule )
++				{
++					SbxArray* pMethods = pModule->GetMethods();
++					if ( pMethods )
++					{
++						SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxCLASS_METHOD ) );
++						if ( pMethod )
++						{
++							sFullName = sMacro;
++							sFullName.Insert( '.', 0 ).Insert( sMod, 0 ).Insert( '.', 0 ).Insert( sLibrary, 0 );
++						}
++					}
++				}
++			}
++			else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxCLASS_METHOD ) ) )
++			{
++					if( SbModule* pModule = pMethod->GetModule() )
++					{
++						sFullName = sMacro;
++						sFullName.Insert( '.', 0 ).Insert( pModule->GetName(), 0).Insert( '.', 0 ).Insert( sLibrary, 0 );
++					}
++			}		
++				
++		}
++	}
++	return sFullName;
++}
++
++#define VBA_LEFT "PositionX"
++#define VBA_TOP "PositionY"
++UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
++{
++    mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
++}
++    double UserFormGeometryHelper::getLeft()
++    {
++	sal_Int32 nLeft = 0;
++	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;	
++	return Millimeter::getInPoints( nLeft );
++    }
++    void UserFormGeometryHelper::setLeft( double nLeft )
++    {
++        mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) );
++    }
++    double UserFormGeometryHelper::getTop()
++    {
++	sal_Int32 nTop = 0;
++	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;	
++	return Millimeter::getInPoints( nTop );
++    }
++    void UserFormGeometryHelper::setTop( double nTop )
++    {
++	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) );
++    }
++    double UserFormGeometryHelper::getHeight()
++    {
++	sal_Int32 nHeight = 0;
++	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_HEIGHT ) ) ) >>= nHeight;	
++	return Millimeter::getInPoints( nHeight );
++    }
++    void UserFormGeometryHelper::setHeight( double nHeight )
++    {
++	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_HEIGHT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) );
++    }
++    double UserFormGeometryHelper::getWidth()
++    {
++	sal_Int32 nWidth = 0;
++	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_WIDTH ) ) ) >>= nWidth;	
++	return Millimeter::getInPoints( nWidth );
++    }
++    void UserFormGeometryHelper::setWidth( double nWidth)
++    {
++	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_WIDTH ) ), uno::makeAny(  Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
++    }
++
++    double ConcreteXShapeGeometryAttributes::getLeft()
++    {
++        return m_xShape->getLeft();
++    }
++    void ConcreteXShapeGeometryAttributes::setLeft( double nLeft )
++    {
++        m_xShape->setLeft( nLeft );
++    }
++    double ConcreteXShapeGeometryAttributes::getTop()
++    {
++        return m_xShape->getTop();
++    }
++    void ConcreteXShapeGeometryAttributes::setTop( double nTop )
++    {
++        m_xShape->setTop( nTop );
++    }
++
++    double ConcreteXShapeGeometryAttributes::getHeight()
++    {
++        return m_xShape->getHeight();
++    }
++    void ConcreteXShapeGeometryAttributes::setHeight( double nHeight )
++    {
++        m_xShape->setHeight( nHeight );
++    }
++    double ConcreteXShapeGeometryAttributes::getWidth()
++    {
++        return m_xShape->getWidth();
++    }
++    void ConcreteXShapeGeometryAttributes::setWidth( double nWidth)
++    {
++        m_xShape->setHeight( nWidth );
++    }
++
++
++	ShapeHelper::ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ) : xShape( _xShape )
++	{ 
++		if( !xShape.is() ) 
++			throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() );
++	}
++    
++	double ShapeHelper::getHeight()
++	{
++        	return  Millimeter::getInPoints(xShape->getSize().Height);
++    	}
++
++
++    	void ShapeHelper::setHeight(double _fheight) throw ( css::script::BasicErrorException )
++	{
++		try
++		{
++			css::awt::Size aSize = xShape->getSize();
++			aSize.Height = Millimeter::getInHundredthsOfOneMillimeter(_fheight);
++			xShape->setSize(aSize);
++		}
++		catch ( css::uno::Exception& /*e*/)
++		{
++			throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
++    		}
++	}
++    
++    
++	double ShapeHelper::getWidth()
++	{ 
++		return Millimeter::getInPoints(xShape->getSize().Width);
++    	}
++
++	void ShapeHelper::setWidth(double _fWidth) throw ( css::script::BasicErrorException )
++	{
++		try
++		{
++			css::awt::Size aSize = xShape->getSize();
++			aSize.Width = Millimeter::getInHundredthsOfOneMillimeter(_fWidth);
++			xShape->setSize(aSize);
++		}
++		catch (css::uno::Exception& /*e*/)
++		{
++			throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
++		}
++	}
++    
++    
++	double ShapeHelper::getLeft()
++	{
++		return Millimeter::getInPoints(xShape->getPosition().X);
++	}
++
++    
++	void ShapeHelper::setLeft(double _fLeft)
++	{
++		css::awt::Point aPoint = xShape->getPosition();
++		aPoint.X = Millimeter::getInHundredthsOfOneMillimeter(_fLeft);
++		xShape->setPosition(aPoint);
++	}
++    
 +
-+	return sResult.makeStringAndClear( );
-+}
++	double ShapeHelper::getTop()
++	{
++        	return Millimeter::getInPoints(xShape->getPosition().Y);
++	}
 +
-+double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
-+{
-+	double fConvertFactor = 1.0;
-+	if( bVertical )
++    
++	void ShapeHelper::setTop(double _fTop)
 +	{
-+		fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000;
++		css::awt::Point aPoint = xShape->getPosition();
++		aPoint.Y = Millimeter::getInHundredthsOfOneMillimeter(_fTop);
++		xShape->setPosition(aPoint);
 +	}
-+	else
++    
++	void DebugHelper::exception( const rtl::OUString&  DetailedMessage, const css::uno::Exception& ex,  int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException )
 +	{
-+		fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000;	
++		// #TODO #FIXME ( do we want to support additionalArg here )
++		throw css::script::BasicErrorException( DetailedMessage.concat( rtl::OUString::createFromAscii(" ") ).concat( ex.Message ), css::uno::Reference< css::uno::XInterface >(), err, rtl::OUString() );
 +	}
-+	return fConvertFactor;
-+}
 +
-+double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
-+{
-+	double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
-+	return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor;
-+}
-+double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
-+{
-+	double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
-+	return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR;
-+}
++	void DebugHelper::exception( int err,  const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException )
++	{
++		exception( rtl::OUString(), css::uno::Exception(), err, additionalArgument );
++	}
++	void DebugHelper::exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException )
++	{
++		exception( rtl::OUString(), ex, SbERR_INTERNAL_ERROR, rtl::OUString() );
++	}
++
++	Millimeter::Millimeter():m_nMillimeter(0) {}
++    
++	Millimeter::Millimeter(double mm):m_nMillimeter(mm) {}
++    
++	void Millimeter::set(double mm) { m_nMillimeter = mm; }
++	void Millimeter::setInPoints(double points) 
++	{ 
++		m_nMillimeter = points * 0.352777778; 
++		// 25.4mm / 72 
++	}
++      
++	void Millimeter::setInHundredthsOfOneMillimeter(double hmm)
++	{
++		m_nMillimeter = hmm / 100;
++	}
++    
++	double Millimeter::get()
++	{
++		return m_nMillimeter;
++	}
++	double Millimeter::getInHundredthsOfOneMillimeter()
++	{
++		return m_nMillimeter * 100;
++	}
++	double Millimeter::getInPoints()
++	{
++		return m_nMillimeter * 2.834645669; // 72 / 25.4mm
++	}    
++
++	sal_Int32 Millimeter::getInHundredthsOfOneMillimeter(double points)
++	{
++		sal_Int32 mm = static_cast<sal_Int32>(points * factor);
++		return mm;
++	}
++    
++	double Millimeter::getInPoints(int _hmm)
++	{
++		double points = double( static_cast<double>(_hmm) / factor);
++		return points;
++	}
 +
-+ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape )
-+{
-+// #FIXME needs to be an instantiable service
-+//	m_xShape = new ScVbaShape( xContext, xShape );
-+}
 +
-+#define VBA_LEFT "PositionX"
-+#define VBA_TOP "PositionY"
-+UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
-+{
-+    mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
-+}
-+    double UserFormGeometryHelper::getLeft()
-+    {
-+	sal_Int32 nLeft = 0;
-+	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;	
-+	return Millimeter::getInPoints( nLeft );
-+    }
-+    void UserFormGeometryHelper::setLeft( double nLeft )
-+    {
-+        mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) );
-+    }
-+    double UserFormGeometryHelper::getTop()
-+    {
-+	sal_Int32 nTop = 0;
-+	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;	
-+	return Millimeter::getInPoints( nTop );
-+    }
-+    void UserFormGeometryHelper::setTop( double nTop )
-+    {
-+	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) );
-+    }
-+    double UserFormGeometryHelper::getHeight()
-+    {
-+	sal_Int32 nHeight = 0;
-+	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( NAME_HEIGHT ) ) ) >>= nHeight;	
-+	return Millimeter::getInPoints( nHeight );
-+    }
-+    void UserFormGeometryHelper::setHeight( double nHeight )
-+    {
-+	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_HEIGHT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) );
-+    }
-+    double UserFormGeometryHelper::getWidth()
-+    {
-+	sal_Int32 nWidth = 0;
-+	mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_WIDTH ) ) ) >>= nWidth;	
-+	return Millimeter::getInPoints( nWidth );
-+    }
-+    void UserFormGeometryHelper::setWidth( double nWidth)
-+    {
-+	mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 	NAME_WIDTH ) ), uno::makeAny(  Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
-+    }
 +} // openoffice
 +} //org
 diff --git vbahelper/source/vbahelper/vbapropvalue.cxx vbahelper/source/vbahelper/vbapropvalue.cxx
@@ -15935,12 +30866,198 @@
 +{
 +    m_pListener->setValueEvent( _value );
 +}
+diff --git vbahelper/source/vbahelper/vbawindowbase.cxx vbahelper/source/vbahelper/vbawindowbase.cxx
+new file mode 100644
+index 0000000..5970de4
+--- /dev/null
++++ vbahelper/source/vbahelper/vbawindowbase.cxx
+@@ -0,0 +1,180 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright 2008 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: 
++ * $Revision: 
++ *
++ * 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/helperdecl.hxx>
++#include <vbahelper/vbawindowbase.hxx>
++#include <com/sun/star/awt/XWindow.hpp>
++#include <com/sun/star/awt/XWindow2.hpp>
++#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( 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 ) )
++{
++}
++
++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;
++}
++
++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 )
++{
++	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;
++}
++
++void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, USHORT 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 )
++		{
++			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;
++}
++
++void SAL_CALL 
++VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException)
++{
++	setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT);
++}
++
++sal_Int32 SAL_CALL 
++VbaWindowBase::getLeft() throw (uno::RuntimeException)
++{
++	css::awt::Rectangle aRect = getPosSize(m_xModel);
++	return aRect.X;
++}
++
++void SAL_CALL 
++VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException)
++{
++	setPosSize(m_xModel, _left, css::awt::PosSize::X);
++}
++sal_Int32 SAL_CALL 
++VbaWindowBase::getTop() throw (uno::RuntimeException)
++{
++	css::awt::Rectangle aRect = getPosSize(m_xModel);
++	return aRect.Y;
++}
++
++void SAL_CALL 
++VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException)
++{
++	setPosSize(m_xModel, _top, css::awt::PosSize::Y);
++}
++sal_Int32 SAL_CALL 
++VbaWindowBase::getWidth() throw (uno::RuntimeException)
++{
++	css::awt::Rectangle aRect = getPosSize(m_xModel);
++	return aRect.Width;
++}
++
++void SAL_CALL 
++VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException)
++{
++	setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH);
++}
++
++rtl::OUString& 
++VbaWindowBase::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaWindowBase") );
++	return sImplName;
++}
++
++uno::Sequence< rtl::OUString > 
++VbaWindowBase::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VbaWindowBase" ) );
++	}
++	return aServiceNames;
++}
 diff --git vbahelper/util/makefile.mk vbahelper/util/makefile.mk
 new file mode 100644
-index 0000000..b5553aa
+index 0000000..7835a0c
 --- /dev/null
 +++ vbahelper/util/makefile.mk
-@@ -0,0 +1,94 @@
+@@ -0,0 +1,97 @@
 +#*************************************************************************
 +#
 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -16003,6 +31120,8 @@
 +		$(SVTOOLLIB)    \
 +		$(SVLLIB) \
 +        $(VCLLIB) \
++		$(SVTOOLLIB)    \
++        $(TKLIB) \
 +
 +#SHL4DEPN=$(SHL1TARGETN)
 +SHL1LIBS=$(LIB1FILES)
@@ -16011,7 +31130,7 @@
 +SHL2TARGET=$(TARGET_MSFORMS)$(DLLPOSTFIX).uno
 +SHL2IMPLIB=     i$(TARGET_MSFORMS)
 +
-+#SHL4VERSIONMAP=$(TARGET_MSFORMS).map
++SHL2VERSIONMAP=$(TARGET_MSFORMS).map
 +SHL2DEF=$(MISC)$/$(SHL2TARGET).def
 +DEF2NAME=$(SHL2TARGET)
 +SHL2STDLIBS= \
@@ -16028,6 +31147,7 @@
 +                $(SVLLIB) \
 +        $(VCLLIB) \
 +        $(TKLIB) \
++                $(BASICLIB) \
 +
 +SHL2DEPN=$(SHL1TARGETN)
 +SHL2LIBS=$(SLB)$/$(TARGET_MSFORMS).lib
@@ -16035,3 +31155,18 @@
 +# --- Targets -----------------------------------------------------------
 +
 +.INCLUDE :  target.mk
+diff --git vbahelper/util/msforms.map vbahelper/util/msforms.map
+new file mode 100644
+index 0000000..832e82c
+--- /dev/null
++++ vbahelper/util/msforms.map
+@@ -0,0 +1,9 @@
++OOO_1.1 {
++	global:
++		component_getImplementationEnvironment;
++		component_getFactory;
++		component_writeInfo;
++
++	local:
++		*;
++};



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]