summaryrefslogtreecommitdiff
path: root/basic/source/classes
diff options
context:
space:
mode:
authornpower Developer <npower@openoffice.org>2010-04-26 13:09:41 +0100
committernpower Developer <npower@openoffice.org>2010-04-26 13:09:41 +0100
commit9e090f35c699eb8fcec6ba0d385bd76b76c744b5 (patch)
treef18b24ef8040b4c9bcb1fc45002d5691f3ee0a52 /basic/source/classes
parent3574d419d1e406f0256d4659069739b3dda22e91 (diff)
npower13_objectmodules: #i111097# fix for reset of vba mode for modules
Diffstat (limited to 'basic/source/classes')
-rw-r--r--basic/source/classes/sbxmod.cxx38
1 files changed, 37 insertions, 1 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 4b0ca569df..0a11015018 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -55,7 +55,10 @@
#include <basic/sbobjmod.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/XVBACompat.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+using namespace com::sun::star;
// for the bsearch
#ifdef WNT
@@ -98,6 +101,26 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
SV_IMPL_VARARR(HighlightPortions, HighlightPortion)
+bool getDefaultVBAMode( StarBASIC* pb )
+{
+ bool bResult = false;
+ if ( pb && pb->IsDocBasic() )
+ {
+ uno::Any aDoc;
+ if ( pb->GetUNOConstant( "ThisComponent", aDoc ) )
+ {
+ uno::Reference< beans::XPropertySet > xProp( aDoc, uno::UNO_QUERY );
+ if ( xProp.is() )
+ {
+ uno::Reference< script::XVBACompat > xVBAMode( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY );
+ if ( xVBAMode.is() )
+ bResult = ( xVBAMode->getVBACompatModeOn() == sal_True );
+ }
+ }
+ }
+ return bResult;
+}
+
class AsyncQuitHandler
{
AsyncQuitHandler() {}
@@ -443,10 +466,11 @@ void SbModule::SetSource( const String& r )
void SbModule::SetSource32( const ::rtl::OUString& r )
{
+ // Default basic mode to library container mode, but.. allow Option VBASupport 0/1 override
+ SetVBACompat( getDefaultVBAMode( static_cast< StarBASIC*>( GetParent() ) ) );
aOUSource = r;
StartDefinitions();
SbiTokenizer aTok( r );
- aTok.SetCompatible( IsVBACompat() );
while( !aTok.IsEof() )
{
SbiToken eEndTok = NIL;
@@ -471,6 +495,18 @@ void SbModule::SetSource32( const ::rtl::OUString& r )
{
eEndTok = ENDPROPERTY; break;
}
+ if( eCurTok == OPTION )
+ {
+ eCurTok = aTok.Next();
+ if( eCurTok == COMPATIBLE )
+ aTok.SetCompatible( true );
+ else if ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) )
+ {
+ BOOL bIsVBA = ( aTok.GetDbl()== 1 );
+ SetVBACompat( bIsVBA );
+ aTok.SetCompatible( bIsVBA );
+ }
+ }
}
eLastTok = eCurTok;
}