ooo-build r15356 - in trunk: . patches/vba



Author: noelpwer
Date: Tue Feb 17 17:53:57 2009
New Revision: 15356
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15356&view=rev

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

        * patches/vba/vba-word-support.diff: add simple vba project  referencing
        * patches/vba/vba-word-support-m0.diff: 



Modified:
   trunk/ChangeLog
   trunk/patches/vba/vba-word-support-m0.diff
   trunk/patches/vba/vba-word-support.diff

Modified: trunk/patches/vba/vba-word-support-m0.diff
==============================================================================
--- trunk/patches/vba/vba-word-support-m0.diff	(original)
+++ trunk/patches/vba/vba-word-support-m0.diff	Tue Feb 17 17:53:57 2009
@@ -14758,14 +14758,25 @@
  
  class SVX_DLLPUBLIC TBCBitMap : public TBBase
 diff --git svx/inc/svxmsbas.hxx svx/inc/svxmsbas.hxx
-index 5e87fe6..74c89f9 100644
+index 5e87fe6..a777795 100644
 --- svx/inc/svxmsbas.hxx
 +++ svx/inc/svxmsbas.hxx
-@@ -102,6 +102,7 @@ private:
+@@ -59,6 +59,8 @@ typedef std::hash_map< sal_Int32, String >  ObjIdToName;
+ 
+ typedef std::map< String, ObjIdToName >  ControlAttributeInfo;
+ 
++class VBA_Impl;
++
+ class SVX_DLLPUBLIC SvxImportMSVBasic
+ { 
+ 	ControlAttributeInfo m_ModuleNameToObjIdHash;
+@@ -102,6 +104,9 @@ private:
  		const String &rSubStorageName, BOOL bVBAMode );
  	SVX_DLLPRIVATE BOOL CopyStorage_Impl( const String& rStorageName,
  						   const String &rSubStorageName);
 +        rtl::OUString msProjectName;
++	SVX_DLLPRIVATE BOOL ImportCode_Impl( VBA_Impl&, BOOL, BOOL );
++	SVX_DLLPRIVATE bool ImportForms_Impl( VBA_Impl&, const String&, const String&, BOOL);
  };
  
  #endif
@@ -14852,7 +14863,7 @@
  
          // #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
+index 2eff354..cd2c5ff 100644
 --- svx/source/msfilter/msvbasic.cxx
 +++ svx/source/msfilter/msvbasic.cxx
 @@ -40,9 +40,929 @@
@@ -15415,7 +15426,7 @@
 +};
 +
 +ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), pLibidAbsolute( NULL ), SizeOfLibidRelative( 0 ), pLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
-+{
++{ 
 +}
 +
 +ReferenceProjectRecord::~ReferenceProjectRecord()
@@ -15804,7 +15815,23 @@
  	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 )
+@@ -455,6 +1385,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+ 	if( !xMacros.Is() || SVSTREAM_OK != xMacros->GetError() )
+ 	{
+ 		DBG_WARNING("No Macros Storage");
++		OSL_TRACE("No Macros Storage");
+ 	}
+ 	else
+ 	{
+@@ -464,6 +1395,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+ 		if( !xVBA.Is() || SVSTREAM_OK != xVBA->GetError() )
+ 		{
+ 			DBG_WARNING("No Visual Basic in Storage");
++			OSL_TRACE("No Visual Basic in Storage");
+ 		}
+ 		else
+ 		{
+@@ -478,6 +1410,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" ) ) );
@@ -15813,10 +15840,10 @@
          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
+index a0536ae..93ae0a2 100644
 --- svx/source/msfilter/msvbasic.hxx
 +++ svx/source/msfilter/msvbasic.hxx
-@@ -97,9 +97,12 @@ public:
+@@ -97,9 +97,14 @@ public:
      //
      // #117718# member map of module names to types of module
      ModType GetModuleType( const UniString& rModuleName );
@@ -15824,14 +15851,16 @@
 -    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); }
++    const std::vector<rtl::OUString>& ProjectReferences() { return maPrjReferences; }
++    void AddProjectReference( const rtl::OUString& rProject ) { maPrjReferences.push_back( rProject); }
++    SvStorage* GetStorage() { return xStor; }
  private:
 +    std::vector<rtl::OUString> maReferences;
++    std::vector<rtl::OUString> maPrjReferences;
      struct VBAOffset_Impl
      {
          String sName;
-@@ -125,6 +128,7 @@ private:
+@@ -125,6 +130,7 @@ private:
      int ReadVBAProject(const SvStorageRef &rxVBAStorage);
      int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
      sal_uInt8 ReadPString(SvStorageStreamRef &xVBAProject, bool bIsUnicode);
@@ -15840,7 +15869,7 @@
  
  #endif
 diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
-index 843491f..7d0e701 100644
+index 843491f..5efc08f 100644
 --- svx/source/msfilter/svxmsbas.cxx
 +++ svx/source/msfilter/svxmsbas.cxx
 @@ -83,6 +83,7 @@ int SvxImportMSVBasic::Import( const String& rStorageName,
@@ -15851,45 +15880,135 @@
  	int nRet = 0;
  	if( bImport && ImportCode_Impl( rStorageName, rSubStorageName,
  									bAsComment, bStripped ))
-@@ -133,6 +134,11 @@ bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
+@@ -100,7 +101,42 @@ int SvxImportMSVBasic::Import( const String& rStorageName,
+ bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
+     const String& rSubStorageName, BOOL bVBAMode )
+ {
+-    SvStorageRef xVBAStg(xRoot->OpenSotStorage(rStorageName,
++    BOOL bRet = FALSE;
++    // #FIXME VBA_Impl ( or some other new class ) should handle both userforms
++    // and code 
++	VBA_Impl aVBA( *xRoot, TRUE );
++    // This call is a waste we read the source ( again ) only to get the refereneces
++    // *AGAIN*, we really need to rewrite all of this
++    aVBA.Open( rStorageName, rSubStorageName ); 
++
++    bRet = ImportForms_Impl( aVBA, rStorageName, rSubStorageName, bVBAMode );
++	std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
++
++	for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
++    {
++       rtl::OUString sFileName = *it;
++#ifndef WIN 
++#ifdef DEBUG
++       // hacky test code to read referenced projects on linux
++       sal_Int32 nPos = (*it).lastIndexOf('\\');
++       sFileName = (*it).copy( nPos + 1 );
++       sFileName =  rtl::OUString::createFromAscii("~/Documents/") + sFileName;
++#endif
++#endif
++       SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
++	   VBA_Impl refVBA( *rRoot, TRUE );        
++       refVBA.Open( rStorageName, rSubStorageName );
++       // The return from ImportForms doesn't indicate and error ( it could )
++       // but also it just means no userforms were imported
++       if ( ImportForms_Impl( refVBA, rStorageName, rSubStorageName, bVBAMode ) )
++           bRet = true; // mark that at least on userform was imported
++    }
++    return bRet;
++}
++
++bool SvxImportMSVBasic::ImportForms_Impl( VBA_Impl& rVBA, const String& rStorageName, const String& rSubStorageName, BOOL bVBAMode )
++{
++    SvStorageRef xVBAStg(rVBA.GetStorage()->OpenSotStorage(rStorageName,
+         STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL));
+     if (!xVBAStg.Is() || xVBAStg->GetError())
+         return false;
+@@ -133,6 +169,10 @@ 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
-+        }
++
++        if (rVBA.ProjectName().getLength() )
++            aLibName = rVBA.ProjectName();
++        OSL_TRACE( "userformage lib name %s", rtl::OUStringToOString( aLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
          Reference<XNameContainer> xLib;
          if (xLibContainer.is())
          {
-@@ -262,6 +268,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+@@ -260,17 +300,55 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+ {
+ 	BOOL bRet = FALSE;
  	VBA_Impl aVBA( *xRoot, bAsComment );
++        
  	if( aVBA.Open(rStorageName,rSubStorageName) )
  	{
-+                msProjectName = aVBA.ProjectName();
++        msProjectName = aVBA.ProjectName();
++
++        if ( msProjectName.getLength() )
++            rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
++
++        bRet = ImportCode_Impl( aVBA, bAsComment, bStripped );
++    	std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
++    
++    	for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
++        {
++            rtl::OUString sFileName = *it;
++#ifndef WIN 
++#ifdef DEBUG
++            // hacky test code to read referenced projects on linux
++            sal_Int32 nPos = (*it).lastIndexOf('\\');
++            sFileName = (*it).copy( nPos + 1 );
++            sFileName =  rtl::OUString::createFromAscii("~/Documents/") + sFileName;
++#endif
++#endif
++    		OSL_TRACE("referenced project %s ", rtl::OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() );
++            SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
++    	    VBA_Impl refVBA( *rRoot, bAsComment );
++    	    if( refVBA.Open(rStorageName,rSubStorageName) && ImportCode_Impl( refVBA, bAsComment, bStripped ) )
++                bRet = TRUE; // mark that some code was imported
++        }
++    }
++    return bRet;
++}
++
++BOOL SvxImportMSVBasic::ImportCode_Impl( VBA_Impl& aVBA, BOOL bAsComment, BOOL bStripped )
++{
++        BOOL bRet = FALSE;
  		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,
+ 
+         UINT16 nStreamCount = aVBA.GetNoStreams();
+ 		Reference<XNameContainer> xLib;
++
++        String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++
          if( xLibContainer.is() && nStreamCount )
          {
-             String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-+            if ( msProjectName.getLength() )
-+                aLibName = msProjectName;
-+                rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
+-            String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++            if ( aVBA.ProjectName().getLength() )
++                aLibName = aVBA.ProjectName();
++
  		    if( !xLibContainer->hasByName( aLibName ) )
  			    xLibContainer->createLibrary( aLibName );
  
-@@ -282,7 +292,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+@@ -282,7 +360,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
              Reference< container::XNameAccess > xVBAObjectForCodeName;
  			if ( !bAsComment )
              {
 -                rDocSh.GetBasic()->SetVBAEnabled( true );
-+                rDocSh.GetBasicManager()->GetLib( msProjectName )->SetVBAEnabled( true );
++                rDocSh.GetBasicManager()->GetLib( aLibName )->SetVBAEnabled( true );
                  Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
                  if ( xSF.is() )
                  {
+@@ -483,7 +561,6 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+ 		}
+         if( bRet )
+ 		SFX_APP()->LeaveBasicCall();
+-	}
+ 	return bRet;
+ }
+ 
 diff --git sw/inc/unocoll.hxx sw/inc/unocoll.hxx
 index 7b4632d..06fe329 100644
 --- sw/inc/unocoll.hxx
@@ -16105,7 +16224,7 @@
              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
+index 290ffda..041abce 100644
 --- sw/source/filter/ww8/ww8par.cxx
 +++ sw/source/filter/ww8/ww8par.cxx
 @@ -132,6 +132,9 @@
@@ -16248,7 +16367,7 @@
      }
  
      ::SetProgressState(nProgress, mpDocShell);    // Update
-@@ -3986,41 +4100,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
+@@ -3986,41 +4104,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
              eMode |= nsRedlineMode_t::REDLINE_ON;
          if( pWDop->fRMView )
              eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;

Modified: trunk/patches/vba/vba-word-support.diff
==============================================================================
--- trunk/patches/vba/vba-word-support.diff	(original)
+++ trunk/patches/vba/vba-word-support.diff	Tue Feb 17 17:53:57 2009
@@ -14757,14 +14757,25 @@
  
  class SVX_DLLPUBLIC TBCBitMap : public TBBase
 diff --git svx/inc/svxmsbas.hxx svx/inc/svxmsbas.hxx
-index 5e87fe6..74c89f9 100644
+index 5e87fe6..a777795 100644
 --- svx/inc/svxmsbas.hxx
 +++ svx/inc/svxmsbas.hxx
-@@ -102,6 +102,7 @@ private:
+@@ -59,6 +59,8 @@ typedef std::hash_map< sal_Int32, String >  ObjIdToName;
+ 
+ typedef std::map< String, ObjIdToName >  ControlAttributeInfo;
+ 
++class VBA_Impl;
++
+ class SVX_DLLPUBLIC SvxImportMSVBasic
+ { 
+ 	ControlAttributeInfo m_ModuleNameToObjIdHash;
+@@ -102,6 +104,9 @@ private:
  		const String &rSubStorageName, BOOL bVBAMode );
  	SVX_DLLPRIVATE BOOL CopyStorage_Impl( const String& rStorageName,
  						   const String &rSubStorageName);
 +        rtl::OUString msProjectName;
++	SVX_DLLPRIVATE BOOL ImportCode_Impl( VBA_Impl&, BOOL, BOOL );
++	SVX_DLLPRIVATE bool ImportForms_Impl( VBA_Impl&, const String&, const String&, BOOL);
  };
  
  #endif
@@ -14851,7 +14862,7 @@
  
          // #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
+index 2eff354..cd2c5ff 100644
 --- svx/source/msfilter/msvbasic.cxx
 +++ svx/source/msfilter/msvbasic.cxx
 @@ -40,9 +40,929 @@
@@ -15414,7 +15425,7 @@
 +};
 +
 +ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), pLibidAbsolute( NULL ), SizeOfLibidRelative( 0 ), pLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
-+{
++{ 
 +}
 +
 +ReferenceProjectRecord::~ReferenceProjectRecord()
@@ -15803,7 +15814,23 @@
  	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 )
+@@ -455,6 +1385,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+ 	if( !xMacros.Is() || SVSTREAM_OK != xMacros->GetError() )
+ 	{
+ 		DBG_WARNING("No Macros Storage");
++		OSL_TRACE("No Macros Storage");
+ 	}
+ 	else
+ 	{
+@@ -464,6 +1395,7 @@ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+ 		if( !xVBA.Is() || SVSTREAM_OK != xVBA->GetError() )
+ 		{
+ 			DBG_WARNING("No Visual Basic in Storage");
++			OSL_TRACE("No Visual Basic in Storage");
+ 		}
+ 		else
+ 		{
+@@ -478,6 +1410,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" ) ) );
@@ -15812,10 +15839,10 @@
          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
+index a0536ae..93ae0a2 100644
 --- svx/source/msfilter/msvbasic.hxx
 +++ svx/source/msfilter/msvbasic.hxx
-@@ -97,9 +97,12 @@ public:
+@@ -97,9 +97,14 @@ public:
      //
      // #117718# member map of module names to types of module
      ModType GetModuleType( const UniString& rModuleName );
@@ -15823,14 +15850,16 @@
 -    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); }
++    const std::vector<rtl::OUString>& ProjectReferences() { return maPrjReferences; }
++    void AddProjectReference( const rtl::OUString& rProject ) { maPrjReferences.push_back( rProject); }
++    SvStorage* GetStorage() { return xStor; }
  private:
 +    std::vector<rtl::OUString> maReferences;
++    std::vector<rtl::OUString> maPrjReferences;
      struct VBAOffset_Impl
      {
          String sName;
-@@ -125,6 +128,7 @@ private:
+@@ -125,6 +130,7 @@ private:
      int ReadVBAProject(const SvStorageRef &rxVBAStorage);
      int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
      sal_uInt8 ReadPString(SvStorageStreamRef &xVBAProject, bool bIsUnicode);
@@ -15839,7 +15868,7 @@
  
  #endif
 diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
-index 843491f..7d0e701 100644
+index 843491f..5efc08f 100644
 --- svx/source/msfilter/svxmsbas.cxx
 +++ svx/source/msfilter/svxmsbas.cxx
 @@ -83,6 +83,7 @@ int SvxImportMSVBasic::Import( const String& rStorageName,
@@ -15850,45 +15879,135 @@
  	int nRet = 0;
  	if( bImport && ImportCode_Impl( rStorageName, rSubStorageName,
  									bAsComment, bStripped ))
-@@ -133,6 +134,11 @@ bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
+@@ -100,7 +101,42 @@ int SvxImportMSVBasic::Import( const String& rStorageName,
+ bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
+     const String& rSubStorageName, BOOL bVBAMode )
+ {
+-    SvStorageRef xVBAStg(xRoot->OpenSotStorage(rStorageName,
++    BOOL bRet = FALSE;
++    // #FIXME VBA_Impl ( or some other new class ) should handle both userforms
++    // and code 
++	VBA_Impl aVBA( *xRoot, TRUE );
++    // This call is a waste we read the source ( again ) only to get the refereneces
++    // *AGAIN*, we really need to rewrite all of this
++    aVBA.Open( rStorageName, rSubStorageName ); 
++
++    bRet = ImportForms_Impl( aVBA, rStorageName, rSubStorageName, bVBAMode );
++	std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
++
++	for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
++    {
++       rtl::OUString sFileName = *it;
++#ifndef WIN 
++#ifdef DEBUG
++       // hacky test code to read referenced projects on linux
++       sal_Int32 nPos = (*it).lastIndexOf('\\');
++       sFileName = (*it).copy( nPos + 1 );
++       sFileName =  rtl::OUString::createFromAscii("~/Documents/") + sFileName;
++#endif
++#endif
++       SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
++	   VBA_Impl refVBA( *rRoot, TRUE );        
++       refVBA.Open( rStorageName, rSubStorageName );
++       // The return from ImportForms doesn't indicate and error ( it could )
++       // but also it just means no userforms were imported
++       if ( ImportForms_Impl( refVBA, rStorageName, rSubStorageName, bVBAMode ) )
++           bRet = true; // mark that at least on userform was imported
++    }
++    return bRet;
++}
++
++bool SvxImportMSVBasic::ImportForms_Impl( VBA_Impl& rVBA, const String& rStorageName, const String& rSubStorageName, BOOL bVBAMode )
++{
++    SvStorageRef xVBAStg(rVBA.GetStorage()->OpenSotStorage(rStorageName,
+         STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL));
+     if (!xVBAStg.Is() || xVBAStg->GetError())
+         return false;
+@@ -133,6 +169,10 @@ 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
-+        }
++
++        if (rVBA.ProjectName().getLength() )
++            aLibName = rVBA.ProjectName();
++        OSL_TRACE( "userformage lib name %s", rtl::OUStringToOString( aLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
          Reference<XNameContainer> xLib;
          if (xLibContainer.is())
          {
-@@ -262,6 +268,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+@@ -260,17 +300,55 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+ {
+ 	BOOL bRet = FALSE;
  	VBA_Impl aVBA( *xRoot, bAsComment );
++        
  	if( aVBA.Open(rStorageName,rSubStorageName) )
  	{
-+                msProjectName = aVBA.ProjectName();
++        msProjectName = aVBA.ProjectName();
++
++        if ( msProjectName.getLength() )
++            rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
++
++        bRet = ImportCode_Impl( aVBA, bAsComment, bStripped );
++    	std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
++    
++    	for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
++        {
++            rtl::OUString sFileName = *it;
++#ifndef WIN 
++#ifdef DEBUG
++            // hacky test code to read referenced projects on linux
++            sal_Int32 nPos = (*it).lastIndexOf('\\');
++            sFileName = (*it).copy( nPos + 1 );
++            sFileName =  rtl::OUString::createFromAscii("~/Documents/") + sFileName;
++#endif
++#endif
++    		OSL_TRACE("referenced project %s ", rtl::OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() );
++            SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
++    	    VBA_Impl refVBA( *rRoot, bAsComment );
++    	    if( refVBA.Open(rStorageName,rSubStorageName) && ImportCode_Impl( refVBA, bAsComment, bStripped ) )
++                bRet = TRUE; // mark that some code was imported
++        }
++    }
++    return bRet;
++}
++
++BOOL SvxImportMSVBasic::ImportCode_Impl( VBA_Impl& aVBA, BOOL bAsComment, BOOL bStripped )
++{
++        BOOL bRet = FALSE;
  		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,
+ 
+         UINT16 nStreamCount = aVBA.GetNoStreams();
+ 		Reference<XNameContainer> xLib;
++
++        String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++
          if( xLibContainer.is() && nStreamCount )
          {
-             String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-+            if ( msProjectName.getLength() )
-+                aLibName = msProjectName;
-+                rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
+-            String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++            if ( aVBA.ProjectName().getLength() )
++                aLibName = aVBA.ProjectName();
++
  		    if( !xLibContainer->hasByName( aLibName ) )
  			    xLibContainer->createLibrary( aLibName );
  
-@@ -282,7 +292,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+@@ -282,7 +360,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
              Reference< container::XNameAccess > xVBAObjectForCodeName;
  			if ( !bAsComment )
              {
 -                rDocSh.GetBasic()->SetVBAEnabled( true );
-+                rDocSh.GetBasicManager()->GetLib( msProjectName )->SetVBAEnabled( true );
++                rDocSh.GetBasicManager()->GetLib( aLibName )->SetVBAEnabled( true );
                  Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
                  if ( xSF.is() )
                  {
+@@ -483,7 +561,6 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
+ 		}
+         if( bRet )
+ 		SFX_APP()->LeaveBasicCall();
+-	}
+ 	return bRet;
+ }
+ 
 diff --git sw/inc/unocoll.hxx sw/inc/unocoll.hxx
 index 7b4632d..06fe329 100644
 --- sw/inc/unocoll.hxx
@@ -16104,7 +16223,7 @@
              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
+index 290ffda..041abce 100644
 --- sw/source/filter/ww8/ww8par.cxx
 +++ sw/source/filter/ww8/ww8par.cxx
 @@ -132,6 +132,9 @@
@@ -16247,7 +16366,7 @@
      }
  
      ::SetProgressState(nProgress, mpDocShell);    // Update
-@@ -3986,41 +4100,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
+@@ -3986,41 +4104,6 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
              eMode |= nsRedlineMode_t::REDLINE_ON;
          if( pWDop->fRMView )
              eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;



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