1. mst
  2. ooo340

Commits

Daniel Rentz [dr]  committed 9f3d64f

mib19: #163691# use the same instance of the VBACodeNameProvider when loading document modules

  • Participants
  • Parent commits 2af8347
  • Branches default

Comments (0)

Files changed (2)

File basic/source/inc/scriptcont.hxx

View file
  • Ignore whitespace
 class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword
 {
 	::rtl::OUString maScriptLanguage;
+    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxCodeNameAccess;
 
 	// Methods to distinguish between deffirent library types
 	virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName );

File basic/source/uno/scriptcont.cxx

View file
  • Ignore whitespace
 using namespace com::sun::star::xml::sax;
 using namespace com::sun::star;
 using namespace cppu;
-using namespace rtl;
 using namespace osl;
 
-using com::sun::star::uno::Reference;
+using ::rtl::OUString;
 
 //============================================================================
 // Implementation class SfxScriptLibraryContainer
 					RTL_CONSTASCII_STRINGPARAM("document") ))
 		{
             aModInfo.ModuleType = ModuleType::DOCUMENT;
-    		Reference<frame::XModel > xModel( mxOwnerDocument );
-			Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY);
-			Reference< container::XNameAccess > xVBACodeNameAccess;
-			if( xSF.is() )
+
+            // #163691# use the same codename access instance for all document modules
+            if( !mxCodeNameAccess.is() ) try
+            {
+                Reference<frame::XModel > xModel( mxOwnerDocument );
+                Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY_THROW );
+                mxCodeNameAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider" ) ) ), UNO_QUERY );
+            }
+            catch( Exception& ) {}
+
+			if( mxCodeNameAccess.is() )
 			{
 				try
 				{
-					xVBACodeNameAccess.set( xSF->createInstance( 
-						rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 
-							"ooo.vba.VBAObjectModuleObjectProvider"))), 
-						UNO_QUERY );
-				}
-				catch(uno::Exception&) {}
-			}
-			if( xVBACodeNameAccess.is() )
-			{
-				try
-				{
-					aModInfo.ModuleObject.set( xVBACodeNameAccess->getByName( aElementName), uno::UNO_QUERY );    
+					aModInfo.ModuleObject.set( mxCodeNameAccess->getByName( aElementName), uno::UNO_QUERY );
 				}
 				catch(uno::Exception&)
 				{