ooo-build r15483 - in trunk/patches: dev300 vba



Author: noelpwer
Date: Fri Mar  6 10:53:39 2009
New Revision: 15483
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15483&view=rev

Log:
2009-03-06  Noel Power<noel power novell com>

        * patches/dev300/apply: add the patch below, I added the patch 
        previously but forgot to commit apply :-(
        * patches/dev300/vba-sc-autoshapes-hyperlinks.diff: fix error in sources
        * patches/vba/read-vba-dir-stream-fix.diff: some rework



Modified:
   trunk/patches/dev300/apply
   trunk/patches/dev300/vba-sc-autoshapes-hyperlinks.diff
   trunk/patches/vba/read-vba-dir-stream-fix.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Fri Mar  6 10:53:39 2009
@@ -1171,7 +1171,7 @@
 [ BuildBits < ooo310-m4 ]
 novell-win32-agfa-monotype-fonts-m3.diff, tml
 [ BuildBits >= ooo310-m4 ]
-novell-win32-agfa-monotype-fonts.diff, tml
+#novell-win32-agfa-monotype-fonts.diff, tml
 
 [ BuildBits ]
 # allow to define java target, so the build is usable with the JVM 1.5
@@ -1887,6 +1887,7 @@
 # fix core when there is an error in the doc close vba
 # event handler ( bit of a hack )
 fix-doc-exit-basic-error-core.diff
+read-vba-dir-stream-fix.diff
 [ VBAUntested ]
 SectionOwner => noelpwer
 vba-basic-null.diff i#85349, jjiao

Modified: trunk/patches/dev300/vba-sc-autoshapes-hyperlinks.diff
==============================================================================
--- trunk/patches/dev300/vba-sc-autoshapes-hyperlinks.diff	(original)
+++ trunk/patches/dev300/vba-sc-autoshapes-hyperlinks.diff	Fri Mar  6 10:53:39 2009
@@ -209,13 +209,14 @@
 index 4d6fddf..7b8f936 100644
 --- sc/source/filter/excel/xiescher.cxx
 +++ sc/source/filter/excel/xiescher.cxx
-@@ -491,7 +491,6 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const
+@@ -491,7 +491,7 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const
      }
  
      // macro and hyperlink
 -#ifdef ISSUE66550_HLINK_FOR_SHAPES
 -     if( mbSimpleMacro && ((maMacroName.Len() > 0) || (maHyperlink.getLength() > 0)) )
-+     if( ( mbSimpleMacro && (maMacroName.Len() > 0) ) || (maHyperlink.Len() > 0) )
++    if( mbSimpleMacro && ((maMacroName.Len() > 0) ||
++ (maHyperlink.Len() > 0)) )
      {
          if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) )
 @@ -500,11 +499,6 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const

Modified: trunk/patches/vba/read-vba-dir-stream-fix.diff
==============================================================================
--- trunk/patches/vba/read-vba-dir-stream-fix.diff	(original)
+++ trunk/patches/vba/read-vba-dir-stream-fix.diff	Fri Mar  6 10:53:39 2009
@@ -1,18 +1,757 @@
+diff --git svtools/inc/filterutils.hxx svtools/inc/filterutils.hxx
+new file mode 100644
+index 0000000..a05025f
+--- /dev/null
++++ svtools/inc/filterutils.hxx
+@@ -0,0 +1,22 @@
++#ifndef SVTOOLS_INC_FILTERUTILS_HXX
++#define SVTOOLS_INC_FILTERUTILS_HXX
++
++#include "svtools/svtdllapi.h"
++#include <com/sun/star/uno/RuntimeException.hpp>
++namespace svt
++{
++    class BinFilterUtils
++    {
++    private:
++        BinFilterUtils();    // never implemented
++
++    public:
++        SVT_DLLPUBLIC static  rtl::OUString CreateOUStringFromUniStringArray( const char* pcCharArr, sal_uInt32 nBufSize );
++        SVT_DLLPUBLIC static  rtl::OUString CreateOUStringFromStringArray( const char* pcCharArr, sal_uInt32 nBufSize );
++    };
++
++//........................................................................
++} // namespace svt
++//........................................................................
++
++#endif 
+diff --git svtools/prj/d.lst svtools/prj/d.lst
+index d0a7a98..7757b38 100644
+--- svtools/prj/d.lst
++++ svtools/prj/d.lst
+@@ -173,6 +173,7 @@ mkdir: %_DEST%\inc%_EXT%\svtools
+ ..\inc\svtools\httpcook.hxx %_DEST%\inc%_EXT%\svtools\httpcook.hxx
+ ..\inc\imageresourceaccess.hxx %_DEST%\inc%_EXT%\svtools\imageresourceaccess.hxx
+ ..\inc\bindablecontrolhelper.hxx %_DEST%\inc%_EXT%\svtools\bindablecontrolhelper.hxx
++..\inc\filterutils.hxx %_DEST%\inc%_EXT%\svtools\filterutils.hxx
+ ..\inc\svtools\itemprop.hxx %_DEST%\inc%_EXT%\svtools\itemprop.hxx
+ ..\inc\addresstemplate.hxx %_DEST%\inc%_EXT%\svtools\addresstemplate.hxx
+ ..\inc\svtools\genericunodialog.hxx %_DEST%\inc%_EXT%\svtools\genericunodialog.hxx
+diff --git svtools/source/misc/filterutils.cxx svtools/source/misc/filterutils.cxx
+new file mode 100644
+index 0000000..91a6ca4
+--- /dev/null
++++ svtools/source/misc/filterutils.cxx
+@@ -0,0 +1,56 @@
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_svtools.hxx"
++#include "filterutils.hxx"
++#include <rtl/ustrbuf.hxx>
++
++namespace svt
++{
++//........................................................................
++
++    using namespace ::com::sun::star;
++
++    rtl::OUString lcl_createStringFromArray( const char* pcCharArr, sal_uInt32 nBufSize, bool bIsCompressed )
++    {
++        rtl::OUStringBuffer aBuffer;
++        if( bIsCompressed )
++        {
++            // 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();
++    }
++
++    rtl::OUString BinFilterUtils::CreateOUStringFromUniStringArray( const char* pcCharArr, sal_uInt32 nBufSize )
++    {
++        return lcl_createStringFromArray( pcCharArr, nBufSize, false );
++    }
++
++    rtl::OUString BinFilterUtils::CreateOUStringFromStringArray( const char* pcCharArr, sal_uInt32 nBufSize )
++    {
++        return lcl_createStringFromArray( pcCharArr, nBufSize, true );
++    }    
++//........................................................................
++} // namespace svt
++//........................................................................
++
+diff --git svtools/source/misc/makefile.mk svtools/source/misc/makefile.mk
+index 58943ad..e78ee40 100644
+--- svtools/source/misc/makefile.mk
++++ svtools/source/misc/makefile.mk
+@@ -86,6 +86,7 @@ SLOFILES=\
+     $(SLO)$/sharecontrolfile.obj   \
+     $(SLO)$/documentlockfile.obj   \
+     $(SLO)$/bindablecontrolhelper.obj   \
++    $(SLO)$/filterutils.obj   \
+     $(SLO)$/langtab.obj
+ 
+ # --- Targets -------------------------------------------------------
+diff --git svx/source/msfilter/msocximex.cxx svx/source/msfilter/msocximex.cxx
+index c4f61b3..598e0ea 100644
+--- svx/source/msfilter/msocximex.cxx
++++ svx/source/msfilter/msocximex.cxx
+@@ -97,6 +97,7 @@
+ #include <com/sun/star/sheet/XSpreadsheetView.hpp>
+ #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+ #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
++#include <svtools/filterutils.hxx>
+  
+ #ifndef C2S
+ #define C2S(cChar)	String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
+@@ -354,35 +355,11 @@ void lclReadCharArray( SvStorageStream& rStrm, char*& rpcCharArr, sal_uInt32 nLe
+  */
+ OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
+ {
+-    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();
++        return svt::BinFilterUtils::CreateOUStringFromStringArray( pcCharArr, nBufSize );
++
++    return svt::BinFilterUtils::CreateOUStringFromUniStringArray( pcCharArr, nBufSize );
+ }
+ 
+ // export ---------------------------------------------------------------------
+diff --git svx/source/msfilter/mstoolbar.cxx svx/source/msfilter/mstoolbar.cxx
+index 6e1dec0..2647c58 100644
+--- svx/source/msfilter/mstoolbar.cxx
++++ svx/source/msfilter/mstoolbar.cxx
+@@ -10,6 +10,8 @@
+ #include <map>
+ #include <sfx2/objsh.hxx>
+ #include <basic/basmgr.hxx>
++#include <svtools/filterutils.hxx>
++#include <boost/scoped_array.hpp>
+ 
+ int TBBase::nIndent = 0;
+ 
+@@ -26,7 +28,10 @@ void CustomToolBarImportHelper::applyIcons()
+         uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
+         // 1 seems to work best for MSO images, otherwise they don't get displayed ( I guess the default size
+         // in ooo is different )
+-        xImageManager->insertImages( 1,  commands, images );
++        //xImageManager->insertImages( 1,  commands, images );
++        xImageManager->replaceImages( 1,  commands, images );
++        xImageManager->replaceImages( 2,  commands, images );
++        xImageManager->replaceImages( 3,  commands, images );
+     }
+ }
+ 
+@@ -107,15 +112,10 @@ TBBase::indent_printf( FILE* fp, const char* format, ... )
+ 
+ rtl::OUString TBBase::readUnicodeString( SvStream* pS, sal_Int32 nChars )
+ {
+-    rtl::OUStringBuffer buf(40);
+-    for ( sal_Int32 index = 0; index < nChars; ++index )
+-    {
+-        sal_uInt16 ch = 0;
+-        *pS >> ch;
+-        sal_Unicode uni = static_cast< sal_Unicode >( ch );
+-        buf.append( &uni, 1 );
+-    }
+-    return buf.makeStringAndClear();
++    sal_Int32 nBufSize = nChars * 2;
++    boost::scoped_array< sal_uInt8 > pArray( new sal_uInt8[ nBufSize ] );
++    pS->Read( pArray.get(), nBufSize );
++    return svt::BinFilterUtils::CreateOUStringFromUniStringArray(  reinterpret_cast< const char* >( pArray.get() ), nBufSize );
+ }
+ 
+ TBCHeader::TBCHeader() : bSignature( 0x3 )
 diff --git svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
-index a8aac8a..9cec8e5 100644
+index a8aac8a..e040862 100644
 --- svx/source/msfilter/msvbasic.cxx
 +++ svx/source/msfilter/msvbasic.cxx
-@@ -681,8 +681,7 @@ ReferenceRegisteredRecord::read( SvStream* pStream )
+@@ -43,79 +43,13 @@
+ #include <fstream>
+ #include <memory>
+ #include <rtl/ustrbuf.hxx>
++#include <boost/shared_ptr.hpp>
++#include <boost/scoped_array.hpp>
++#include <boost/shared_array.hpp>
++#include <svtools/filterutils.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 )
+@@ -238,23 +172,21 @@ sal_Int16 Reserved1;
+ sal_Int16 Version;
+ sal_Int8 Reserved2;
+ sal_Int16 Reserved3;
+-sal_uInt8* PerformanceCache;
++boost::scoped_array< sal_uInt8 > PerformanceCache;
+ sal_Int32 PerformanceCacheSize;
+-_VBA_PROJECT_VDPI(): Reserved1( 0x61CC), Version( 0xFFFF ), Reserved2(0x0), Reserved3(0x0), PerformanceCache(0),  PerformanceCacheSize(0) {}
++_VBA_PROJECT_VDPI(): Reserved1( 0x61CC), Version( 0xFFFF ), Reserved2(0x0), Reserved3(0x0), 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 )
++    if ( PerformanceCacheSize )
+     {
+-        *pStream >> PerformanceCache[ i ];
++        PerformanceCache.reset( new sal_uInt8[ PerformanceCacheSize ] );
++        pStream->Read( PerformanceCache.get(), PerformanceCacheSize );
+     }
+ }
+ };
+@@ -320,27 +252,22 @@ class ProjectNameRecord
+ public:
+ sal_Int16 Id;
+ sal_Int32 SizeOfProjectName;
+-sal_uInt8* ProjectName;
+-rtl::OUString msProjectName;
+-ProjectNameRecord() : Id( 0x04 ), SizeOfProjectName( 0x0 ), ProjectName(0) {}
++rtl::OUString ProjectName;
++ProjectNameRecord() : Id( 0x04 ), SizeOfProjectName( 0x0 ){}
+ ~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 ];
++        boost::scoped_array< sal_uInt8 > pProjectName( 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 ) );
++        pStream->Read( pProjectName.get(), SizeOfProjectName );
++        ProjectName = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pProjectName.get() ), SizeOfProjectName );
+     }
+ }
+ };
+@@ -350,42 +277,34 @@ class ProjectDocStringRecord
+ public:
+ sal_Int16 Id;
+ sal_Int32 SizeOfDocString;
+-sal_uInt8* DocString;
+ sal_Int16 Reserved;
+ sal_Int32 SizeOfDocStringUnicode;
+-sal_uInt8* DocStringUnicode;
++rtl::OUString DocString;
++rtl::OUString DocStringUnicode; 
+ 
+-ProjectDocStringRecord() : Id( 0x5 ), SizeOfDocString( 0x0 ), DocString( 0 ), Reserved( 0x0 ), SizeOfDocStringUnicode( 0 ), DocStringUnicode( 0 ) {}
++ProjectDocStringRecord() : Id( 0x5 ), SizeOfDocString( 0x0 ), Reserved( 0x0 ), SizeOfDocStringUnicode( 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;
++    boost::scoped_array< sal_uInt8 > pDocString( new sal_uInt8[ SizeOfDocString ] );
++    pStream->Read( pDocString.get(), SizeOfDocString );
++ 
++    DocString = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pDocString.get() ), SizeOfDocString );
+ 
+     *pStream >> Reserved >> SizeOfDocStringUnicode;
+ 
+-    if ( DocStringUnicode )
+-        delete [] DocStringUnicode;
++    boost::scoped_array< sal_uInt8 > pDocStringUnicode( new sal_uInt8[ SizeOfDocStringUnicode ] );
+ 
+-    DocStringUnicode =  new sal_uInt8[ SizeOfDocStringUnicode ];
++    pStream->Read( pDocStringUnicode.get(), SizeOfDocStringUnicode );
++    DocStringUnicode = svt::BinFilterUtils::CreateOUStringFromUniStringArray( reinterpret_cast< const char* >( pDocStringUnicode.get() ), SizeOfDocString );
+ 
+-    pStream->Read( DocStringUnicode, SizeOfDocStringUnicode );
+ }
+ 
+ };
+@@ -395,39 +314,28 @@ class ProjectHelpFilePath
+ public:
+ sal_Int16 Id;
+ sal_Int32 SizeOfHelpFile1;
+-sal_uInt8* HelpFile1;
++boost::scoped_array< sal_uInt8 > HelpFile1;
+ sal_Int16 Reserved;
+ sal_Int32 SizeOfHelpFile2;
+-sal_uInt8* HelpFile2;
++boost::scoped_array< sal_uInt8 > HelpFile2;
+ 
+-ProjectHelpFilePath() : Id( 0x06 ), SizeOfHelpFile1(0), HelpFile1(0), Reserved(0x0), SizeOfHelpFile2(0), HelpFile2(0) {}
++ProjectHelpFilePath() : Id( 0x06 ), SizeOfHelpFile1(0), Reserved(0x0), SizeOfHelpFile2(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 );
++    HelpFile1.reset( new sal_uInt8[ SizeOfHelpFile1 ] );
++    pStream->Read( HelpFile1.get(), SizeOfHelpFile1 );
+ 
+     *pStream >> Reserved >> SizeOfHelpFile2;
+ 
+-    if ( HelpFile2 )
+-        delete HelpFile2;
+-
+-    HelpFile2 = new sal_uInt8[ SizeOfHelpFile2 ];
+-    pStream->Read( HelpFile2, SizeOfHelpFile2 );
++    HelpFile2.reset( new sal_uInt8[ SizeOfHelpFile2 ] );
++    pStream->Read( HelpFile2.get(), SizeOfHelpFile2 );
+   
+ }
+ };
+@@ -483,40 +391,31 @@ class ProjectConstantsRecord
+ {
+ sal_Int16 Id;
+ sal_Int32 SizeOfConstants;
+-sal_uInt8* Constants;
++boost::scoped_array< sal_uInt8 > Constants;
+ sal_Int16 Reserved;
+ sal_Int32 SizeOfConstantsUnicode;
+-sal_uInt8* ConstantsUnicode;
++boost::scoped_array< 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 ];
++    Constants.reset( new sal_uInt8[ SizeOfConstants ] );
+ 
+-    pStream->Read( Constants, SizeOfConstants );
++    pStream->Read( Constants.get(), SizeOfConstants );
+ 
+     *pStream >> Reserved;
+ 
+-    if ( ConstantsUnicode )
+-        delete [] ConstantsUnicode;
+-
+     *pStream >> SizeOfConstantsUnicode;
+ 
+-    ConstantsUnicode = new sal_uInt8[ SizeOfConstantsUnicode ];
+-    pStream->Read( ConstantsUnicode, SizeOfConstantsUnicode );
++    ConstantsUnicode.reset( new sal_uInt8[ SizeOfConstantsUnicode ] );
++    pStream->Read( ConstantsUnicode.get(), SizeOfConstantsUnicode );
+ }
+ 
+ };
+@@ -526,18 +425,14 @@ class ReferenceNameRecord
+ public:
+ sal_Int16 Id;
+ sal_Int32 SizeOfName;
+-sal_uInt8* Name;
++rtl::OUString Name;
+ sal_Int16 Reserved;
+ sal_Int32 SizeOfNameUnicode;
+-sal_uInt8* NameUnicode;
++rtl::OUString NameUnicode;
+ 
+-ReferenceNameRecord() : Id( 0x16 ), SizeOfName( 0 ), Name( 0 ), Reserved( 0x3E ), SizeOfNameUnicode( 0 ), NameUnicode( 0 ) {}
++ReferenceNameRecord() : Id( 0x16 ), SizeOfName( 0 ), Reserved( 0x3E ), SizeOfNameUnicode( 0 ){}
+ ~ReferenceNameRecord()
+ {
+-    delete [] Name;
+-    Name = 0;
+-    delete [] NameUnicode;
+-    NameUnicode = 0;
+ }
+ 
+ void read( SvStream* pStream )
+@@ -545,20 +440,16 @@ void read( SvStream* pStream )
+     OSL_TRACE("NameRecord [0x%x]", pStream->Tell() );
+     *pStream >> Id >> SizeOfName;
+  
+-    if ( Name )
+-        delete [] Name;
++    boost::scoped_array< sal_uInt8 > pName( new sal_uInt8[ SizeOfName ] );
+ 
+-    Name = new sal_uInt8[ SizeOfName ];
+-
+-    pStream->Read( Name, SizeOfName );
++    pStream->Read( pName.get(), SizeOfName );
++    Name = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pName.get() ), SizeOfName );
+ 
+     *pStream >> Reserved >> SizeOfNameUnicode;
+ 
+-    if ( NameUnicode )
+-        delete [] Name;
+-
+-    NameUnicode = new sal_uInt8[ SizeOfNameUnicode ];
+-    pStream->Read( NameUnicode, SizeOfNameUnicode );
++    boost::scoped_array< sal_uInt8 > pNameUnicode( new sal_uInt8[ SizeOfNameUnicode ] );
++    pStream->Read( pNameUnicode.get(), SizeOfNameUnicode );
++    NameUnicode = svt::BinFilterUtils::CreateOUStringFromUniStringArray( reinterpret_cast< const char* >( pNameUnicode.get() ), SizeOfName );
+ }
+ 
+ };
+@@ -581,13 +472,11 @@ 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; 
++    rtl::OUString AbsoluteLibid; 
++    rtl::OUString RelativeLibid; 
+ 
+     virtual bool read( SvStream* pStream );
+     virtual void import( VBA_Impl& rDir );
+@@ -595,16 +484,12 @@ public:
+     ~ReferenceProjectRecord();
+ };
+ 
+-ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), pLibidAbsolute( NULL ), SizeOfLibidRelative( 0 ), pLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
++ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), SizeOfLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
+ {
+ }
+ 
+ ReferenceProjectRecord::~ReferenceProjectRecord()
+ {
+-    if ( pLibidAbsolute )
+-        delete[] pLibidAbsolute;
+-    if ( pLibidRelative )
+-        delete[] pLibidRelative;
+ }
+ 
+ bool ReferenceProjectRecord::read( SvStream* pStream )
+@@ -612,21 +497,15 @@ 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 );
+-    }
++    boost::scoped_array< sal_uInt8 > pLibidAbsolute( new sal_uInt8[ SizeOfLibidAbsolute ] );
++    OSL_TRACE("ReferenceProjectRecord about to read LibidAbsolute at [0x%x]", pStream->Tell() );
++    pStream->Read( pLibidAbsolute.get(), 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 );
+-    }
++    boost::scoped_array< sal_uInt8 > pLibidRelative( new sal_uInt8[ SizeOfLibidRelative ] );
++    OSL_TRACE("ReferenceProjectRecord about to read LibidRelative at [0x%x]", pStream->Tell() );
++    pStream->Read( pLibidRelative.get(), SizeOfLibidRelative );
+ 
+     *pStream >> MajorVersion >> MinorVersion;
+ 
+@@ -634,17 +513,17 @@ bool ReferenceProjectRecord::read( SvStream* pStream )
+     // 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 )));
++    AbsoluteLibid = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pLibidAbsolute.get() + 3 ), (SizeOfLibidAbsolute - 3 ) );
++    RelativeLibid = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pLibidRelative.get() + 3 ), ( 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() );
++    OSL_TRACE("ReferenceProjectRecord - absolute path %s", rtl::OUStringToOString( AbsoluteLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
++    OSL_TRACE("ReferenceProjectRecord - relative path %s", rtl::OUStringToOString( RelativeLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
+     return true;
+ }
+ 
+ void ReferenceProjectRecord::import( VBA_Impl& rDir )
+ {
+-    rDir.AddProjectReference( msAbsoluteLibid );
++    rDir.AddProjectReference( AbsoluteLibid );
+ }
+ 
+ class ReferenceRegisteredRecord : public BaseReferenceRecord
+@@ -653,7 +532,7 @@ public:
+     sal_uInt16 Id;
+     sal_uInt32 Size;
+     sal_uInt32 SizeOfLibid;
+-    sal_uInt8* pLibid;
++    boost::scoped_array< sal_uInt8> pLibid;
+     sal_Int32 Reserved1;
+     sal_Int16 Reserved2;
+ 
+@@ -662,16 +541,12 @@ public:
+     bool read( SvStream* pStream );
+ };
+ 
+-ReferenceRegisteredRecord::ReferenceRegisteredRecord() : Id( 0x000D ), Size( 0 ), SizeOfLibid( 0 ), pLibid( NULL ), Reserved1( 0 ), Reserved2( 0 )
++ReferenceRegisteredRecord::ReferenceRegisteredRecord() : Id( 0x000D ), Size( 0 ), SizeOfLibid( 0 ), Reserved1( 0 ), Reserved2( 0 )
+ {
+ }
+ 
+ ReferenceRegisteredRecord::~ReferenceRegisteredRecord()
+ {
+-    if ( pLibid )
+-    {
+-        delete[] pLibid;
+-    }
+ }
+ 
+ bool 
+@@ -681,9 +556,8 @@ ReferenceRegisteredRecord::read( SvStream* pStream )
      *pStream >> Id >> Size >> SizeOfLibid;
      if ( SizeOfLibid )
      {
 -        pLibid = new sal_uInt8[ SizeOfLibid ];
 -        OSL_TRACE("ReferenceRegisteredRecord about to read Libid [0x%x]", pStream->Tell() ); 
-+        pLibid = new sal_uInt8[ SizeOfLibid];
-         pStream->Read( pLibid, SizeOfLibid );
+-        pStream->Read( pLibid, SizeOfLibid );
++        pLibid.reset( new sal_uInt8[ SizeOfLibid] );
++        pStream->Read( pLibid.get(), SizeOfLibid );
      }
      *pStream >> Reserved1 >> Reserved2;
-@@ -758,7 +757,14 @@ ReferenceControlRecord() : Id( 0x2F ), SizeTwiddled( 0 ), SizeOfLibidTwiddled( 0
+     return true;
+@@ -694,17 +568,15 @@ class ReferenceOriginalRecord
+ public:
+     sal_uInt16 Id;
+     sal_uInt32 SizeOfLibOriginal;
+-    sal_uInt8* pLibidOriginal;
++    boost::scoped_array< sal_uInt8 > pLibidOriginal;
+ 
+ 
+-ReferenceOriginalRecord() : Id( 0x033 ), SizeOfLibOriginal( 0 ), pLibidOriginal( NULL )
++ReferenceOriginalRecord() : Id( 0x033 ), SizeOfLibOriginal( 0 )
+ {
+ }
+ 
+ ~ReferenceOriginalRecord()
+ {
+-    if ( pLibidOriginal )
+-        delete[] pLibidOriginal;
+ }
+ 
+ void read( SvStream* pStream )
+@@ -712,8 +584,8 @@ void read( SvStream* pStream )
+     *pStream >> Id >> SizeOfLibOriginal;
+     if ( SizeOfLibOriginal )
+     {
+-        pLibidOriginal = new sal_uInt8[ SizeOfLibOriginal ];
+-        pStream->Read( pLibidOriginal, SizeOfLibOriginal );
++        pLibidOriginal.reset( new sal_uInt8[ SizeOfLibOriginal ] );
++        pStream->Read( pLibidOriginal.get(), SizeOfLibOriginal );
+     }
+ }
+ 
+@@ -722,24 +594,24 @@ void read( SvStream* pStream )
+ class ReferenceControlRecord : public BaseReferenceRecord
+ {
+ public:
+-ReferenceOriginalRecord OriginalRecord;
++std::auto_ptr< ReferenceOriginalRecord > OriginalRecord;
+ sal_Int16 Id;
+ sal_uInt32 SizeTwiddled;
+ sal_uInt32 SizeOfLibidTwiddled;
+-sal_uInt8* LibidTwiddled;
++boost::shared_array< sal_uInt8 > LibidTwiddled;
+ sal_uInt32 Reserved1;
+ sal_uInt16 Reserved2;
+-ReferenceNameRecord* NameRecordExtended;// Optional
++std::auto_ptr< ReferenceNameRecord > NameRecordExtended;// Optional
+ sal_uInt16 Reserved3;
+ sal_uInt32 SizeExtended;
+ sal_uInt32 SizeOfLibidExtended;
+-sal_uInt8* LibidExtended;
++boost::shared_array< 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 )
++ReferenceControlRecord() : Id( 0x2F ), SizeTwiddled( 0 ), SizeOfLibidTwiddled( 0 ), Reserved1( 0 ), Reserved2( 0 ), Reserved3( 0x30 ), SizeExtended( 0 ), SizeOfLibidExtended( 0 ), Reserved4( 0 ), Reserved5( 0 ), Cookie( 0 )
+ {
+     for( int i = 0; i < 16; ++i )
+         OriginalTypeLib[ i ] = 0;
+@@ -747,29 +619,31 @@ ReferenceControlRecord() : Id( 0x2F ), SizeTwiddled( 0 ), SizeOfLibidTwiddled( 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() ); 
@@ -23,12 +762,18 @@
 +    pStream->Seek( nPos ); // point before the peeked Id
 +    if ( Id == 0x33 ) // we have an OriginalRecord
 +    {
-+        OriginalRecord.read( pStream );
++        OriginalRecord.reset( new ReferenceOriginalRecord() );
++        OriginalRecord->read( pStream );
 +    }
      *pStream >> Id >> SizeTwiddled >> SizeOfLibidTwiddled;
  
      if ( SizeOfLibidTwiddled )
-@@ -769,7 +775,7 @@ bool read( SvStream* pStream )
+     {
+-        LibidTwiddled = new sal_uInt8[ SizeOfLibidTwiddled ];
+-        pStream->Read( LibidTwiddled,  SizeOfLibidTwiddled );
++        LibidTwiddled.reset( new sal_uInt8[ SizeOfLibidTwiddled ] );
++        pStream->Read( LibidTwiddled.get(),  SizeOfLibidTwiddled );
+     }
  
      *pStream >> Reserved1 >> Reserved2;
  
@@ -37,3 +782,104 @@
      // peek at the id for optional NameRecord
      sal_Int16 nTmpId;
      *pStream >> nTmpId;
+@@ -780,7 +654,7 @@ bool read( SvStream* pStream )
+     else
+     {
+         pStream->Seek( nPos );
+-        NameRecordExtended = new ReferenceNameRecord();
++        NameRecordExtended.reset( new ReferenceNameRecord() );
+         NameRecordExtended->read( pStream );
+         *pStream >> Reserved3;
+     }
+@@ -788,8 +662,8 @@ bool read( SvStream* pStream )
+ 
+     if ( SizeExtended )
+     {
+-        LibidExtended = new sal_uInt8[ SizeOfLibidExtended ]; 
+-        pStream->Read( LibidExtended, SizeOfLibidExtended );
++        LibidExtended.reset( new sal_uInt8[ SizeOfLibidExtended ] ); 
++        pStream->Read( LibidExtended.get(), SizeOfLibidExtended );
+     } 
+ 
+     *pStream >> Reserved4;
+@@ -806,15 +680,12 @@ class ReferenceRecord : public BaseReferenceRecord
+ {
+ public:
+ // NameRecord is Optional
+-ReferenceNameRecord* NameRecord;
+-BaseReferenceRecord*  aReferenceRecord;
+-ReferenceRecord(): NameRecord(0), aReferenceRecord(0) {}
++std::auto_ptr< ReferenceNameRecord > NameRecord;
++std::auto_ptr< BaseReferenceRecord >  aReferenceRecord;
++
++ReferenceRecord(){}
+ ~ReferenceRecord()
+ {
+-    if ( NameRecord )
+-        delete NameRecord;       
+-    if ( aReferenceRecord )
+-        delete aReferenceRecord;       
+ }
+ 
+ // false return would mean failed to read Record e.g. end of array encountered
+@@ -833,7 +704,7 @@ bool read( SvStream* pStream )
+     pStream->Seek( nPos ); // place back before Id
+     if ( Id == 0x16 ) // Optional NameRecord
+     {
+-        NameRecord = new ReferenceNameRecord();
++        NameRecord.reset( new ReferenceNameRecord() );
+         NameRecord->read( pStream ); 
+     }
+     else if ( Id == 0x0f )
+@@ -850,14 +721,14 @@ bool read( SvStream* pStream )
+     switch( Id )
+     {
+         case 0x0D:
+-            aReferenceRecord = new ReferenceRegisteredRecord();
++            aReferenceRecord.reset( new ReferenceRegisteredRecord() );
+             break; 
+         case 0x0E:
+-            aReferenceRecord = new ReferenceProjectRecord();
++            aReferenceRecord.reset( new ReferenceProjectRecord() );
+             break; 
+         case 0x2F:
+         case 0x33:
+-            aReferenceRecord = new ReferenceControlRecord();
++            aReferenceRecord.reset( new ReferenceControlRecord() );
+             break; 
+         default:
+             bRead = false;
+@@ -871,7 +742,7 @@ bool read( SvStream* pStream )
+ 
+ void import( VBA_Impl& rVBA )
+ {
+-    if ( aReferenceRecord )
++    if ( aReferenceRecord.get() )
+         aReferenceRecord->import( rVBA );
+ }
+ 
+@@ -904,6 +775,7 @@ DirDumper() {}
+ void read( SvStream* pStream )
+ {
+     sal_Int32 nPos = pStream->Tell();
++#ifdef DEBUG
+     std::ofstream aDump("dir.dump");
+     while ( !pStream->IsEof() ) 
+     {
+@@ -912,6 +784,7 @@ void read( SvStream* pStream )
+         aDump << aByte;
+     }
+     aDump.flush();
++#endif
+     pStream->Seek( nPos );
+     readProjectInformation( pStream );
+     readProjectReferenceInformation( pStream );
+@@ -957,7 +830,7 @@ 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 );
++    rVBA.SetProjectName( mProjectNameRec.ProjectName );
+     
+ }
+ };



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