ooo-build r15269 - trunk/patches/test



Author: noelpwer
Date: Mon Feb  2 12:22:52 2009
New Revision: 15269
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15269&view=rev

Log:
add some debug for offset in file record lives
change raw pointer stuff to use boost::shared_ptr and arrays of pointers
to vectors ( big ripple :-( )




Modified:
   trunk/patches/test/word-read-custom-toolbar-filter.diff

Modified: trunk/patches/test/word-read-custom-toolbar-filter.diff
==============================================================================
--- trunk/patches/test/word-read-custom-toolbar-filter.diff	(original)
+++ trunk/patches/test/word-read-custom-toolbar-filter.diff	Mon Feb  2 12:22:52 2009
@@ -1,8 +1,18 @@
 diff --git sw/source/filter/ww8/makefile.mk sw/source/filter/ww8/makefile.mk
-index 25cb969..95b12fb 100644
+index 25cb969..3360d48 100644
 --- sw/source/filter/ww8/makefile.mk
 +++ sw/source/filter/ww8/makefile.mk
-@@ -95,7 +95,9 @@ SLOFILES =	\
+@@ -68,7 +68,8 @@ EXCEPTIONSFILES = \
+ 		$(SLO)$/writerwordglue.obj \
+         $(SLO)$/ww8scan.obj \
+         $(SLO)$/WW8TableInfo.obj \
+-        $(SLO)$/WW8FFData.obj
++        $(SLO)$/WW8FFData.obj \
++        $(SLO)$/ww8toolbar.obj \
+ 
+ 
+ SLOFILES =	\
+@@ -95,7 +96,9 @@ SLOFILES =	\
  		$(SLO)$/writerhelper.obj \
  		$(SLO)$/writerwordglue.obj \
          $(SLO)$/WW8TableInfo.obj \
@@ -72,8 +82,8 @@
              pTableStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
  
 --- /dev/null	2008-04-22 00:28:44.000000000 +0100
-+++ sw/source/filter/ww8/ww8toolbar.hxx	2009-02-01 10:05:39.000000000 +0000
-@@ -0,0 +1,555 @@
++++ sw/source/filter/ww8/ww8toolbar.hxx	2009-02-02 12:06:14.000000000 +0000
+@@ -0,0 +1,539 @@
 +#ifndef _WW8TOOLBAR_HXX
 +#define _WW8TOOLBAR_HXX
 +
@@ -82,7 +92,7 @@
 +#include <ostream>
 +#include <memory>
 +#include <vector>
-+
++#include <boost/shared_ptr.hpp>
 +class TBCHeader;
 +
 +class TBBase
@@ -91,8 +101,9 @@
 +    static int nIndent; // num spaces to indent before printing 
 +protected:
 +    void indent_printf(FILE* fp, const char* format, ... );
++    sal_uInt32 nOffSet; // usually for debug we can store the offset in the stream to this record
 +public:
-+    TBBase(){}
++    TBBase() : nOffSet( 0 ) {}
 +    virtual ~TBBase(){}
 +    virtual bool Read(SotStorageStream *pS) = 0;
 +    virtual void Print( FILE* ) {} // #FIXME remove this an implement the debug routines in all the classes below to enable some sort of readable output
@@ -126,8 +137,6 @@
 +{
 +    rtl::OUString sString;
 +
-+    WString(const WString&);
-+    WString& operator = ( const WString&);
 +public:
 +    WString(){};
 +    ~WString(){};
@@ -177,21 +186,20 @@
 +    sal_Int32 cbDIB;
 +//    BITMapInfoHeader biHeader;  // lets cheat and not read the bit map stuff right now
 +    sal_uInt8* pRestOfIt;
-+    TBCBitMap(const TBCBitMap&);
-+    TBCBitMap& operator = ( const TBCBitMap&);
++    int size;
 +public:
 +    TBCBitMap();
 +    ~TBCBitMap();
 +    bool Read(SotStorageStream *pS);
 +    void Print( FILE* );
++    TBCBitMap(const TBCBitMap&);
++    TBCBitMap& operator = ( const TBCBitMap&);
 +};
 +
 +class TBCMenuSpecific : public TBBase
 +{
 +    sal_Int32 tbid;
-+    std::auto_ptr< WString > name; //exist only if tbid equals 0x00000001
-+    TBCMenuSpecific(const TBCMenuSpecific&);
-+    TBCMenuSpecific& operator = ( const TBCMenuSpecific&);
++    boost::shared_ptr< WString > name; //exist only if tbid equals 0x00000001
 +public:
 +    TBCMenuSpecific();
 +    ~TBCMenuSpecific(){}
@@ -202,15 +210,13 @@
 +class TBCCDData : public TBBase
 +{
 +    sal_Int16 cwstrItems; //Signed integer that specifies the number of items in wstrList. MUST be positive.
-+    WString* wstrList;  // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
++    std::vector< WString > wstrList;  // Zero-based index array of WString structures. Number of elements MUST be equal to cwstrItems.
 +    sal_Int16 cwstrMRU; // Signed integer that specifies the number of most recently used string
 +    sal_Int16 iSel ; // Signed integer that specifies the zero-based index of the selected item in the wstrList field. MUST be equal to 0xFFFF (-1) or greater than or equal to 0x0000.
 +    sal_Int16 cLines; // Signed integer that specifies the suggested number of lines that the toolbar control will display at any time when displaying the elements of wstrList of available items. 
 +    sal_Int16 dxWidth; // Signed integer that specifies the width in pixels that the interior of the dropdown has. This excludes the width of the toolbar control border and scroll bar.
 +    WString wstrEdit; //Structure of type WString. Editable text for editable area of the ComboBox toolbar control.
 +
-+    TBCCDData(const TBCCDData&);
-+    TBCCDData& operator = ( const TBCCDData&);
 +public:
 +    TBCCDData();
 +    ~TBCCDData();
@@ -220,9 +226,7 @@
 +
 +class TBCComboDropdownSpecific : public TBBase
 +{
-+    std::auto_ptr< TBCCDData > data;
-+    TBCComboDropdownSpecific(const TBCComboDropdownSpecific&);
-+    TBCComboDropdownSpecific& operator = ( const TBCComboDropdownSpecific&);
++    boost::shared_ptr< TBCCDData > data;
 +public:
 +    TBCComboDropdownSpecific( const TBCHeader& header );
 +    TBCComboDropdownSpecific(){}
@@ -233,13 +237,11 @@
 +class TBCBSpecific :  public TBBase
 +{
 +    sal_uInt8 bFlags;
-+    std::auto_ptr< TBCBitMap > icon; // optional
-+    std::auto_ptr< TBCBitMap > iconMask; // optional
-+    std::auto_ptr< sal_uInt16 > iBtnFace; // optional
-+    std::auto_ptr< WString > wstrAcc; // optional
++    boost::shared_ptr< TBCBitMap > icon; // optional
++    boost::shared_ptr< TBCBitMap > iconMask; // optional
++    boost::shared_ptr< sal_uInt16 > iBtnFace; // optional
++    boost::shared_ptr< WString > wstrAcc; // optional
 +   
-+    TBCBSpecific(const TBCBSpecific&);
-+    TBCBSpecific& operator = ( const TBCBSpecific&);
 +public:
 +    TBCBSpecific();
 +    ~TBCBSpecific(){}
@@ -273,11 +275,11 @@
 +{
 +    const TBCHeader& rHeader;
 +    TBCGeneralInfo controlGeneralInfo;
-+    std::auto_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct 
++    boost::shared_ptr< TBBase > controlSpecificInfo; // can be one of TBCBSpecific, TBCMenuSpecific or TBCComboDropdow nSpecific depending on the control type specified by TBCHeader.tct 
 +    TBCData(const TBCData&);
 +    TBCData& operator = ( const TBCData&);
 +public:
-+    TBCData( const TBCHeader& Header ) : rHeader( Header ) {}
++    TBCData( const TBCHeader& Header );
 +    ~TBCData(){}
 +    bool Read(SotStorageStream *pS);
 +    void Print( FILE* );
@@ -292,11 +294,9 @@
 +    sal_uInt16 tcid;
 +    sal_uInt32 tbct;
 +    sal_uInt8 bPriority;
-+    sal_uInt16* width;  //optional
-+    sal_uInt16* height; //optional
++    boost::shared_ptr< sal_uInt16 > width;  //optional
++    boost::shared_ptr< sal_uInt16 > height; //optional
 +
-+    TBCHeader(const TBCHeader&);
-+    TBCHeader& operator = ( const TBCHeader&);
 +public:
 +    TBCHeader();
 +    ~TBCHeader();
@@ -309,10 +309,8 @@
 +class TBC : public TBBase
 +{
 +    TBCHeader tbch;
-+    sal_uInt32* cid; // optional
-+    std::auto_ptr<TBCData> tbcd;
-+    TBC(const TBC&);
-+    TBC& operator = ( const TBC&);
++    boost::shared_ptr< sal_uInt32 > cid; // optional
++    boost::shared_ptr<TBCData> tbcd;
 +public:
 +    TBC();
 +    ~TBC();
@@ -349,7 +347,7 @@
 +    sal_uInt16 reserved;
 +    sal_uInt16 unused;
 +    sal_Int32 cCtls;
-+    TBC* rTBC;
++    std::vector< TBC > rTBC;
 +
 +    CTB(const CTB&);
 +    CTB& operator = ( const CTB&);
@@ -367,10 +365,8 @@
 +    sal_Int32 cidNext; 
 +    sal_Int32 cid;
 +    sal_Int32 fc;
-+    sal_uInt8 CiTBDE[2]; // careful of this ( endian matters etc. )
++    sal_uInt16 CiTBDE; // careful of this ( endian matters etc. )
 +    sal_uInt16 cbTBC;
-+    TBDelta(const TBDelta&);
-+    TBDelta& operator = ( const TBDelta&);
 +public:
 +    TBDelta();
 +    ~TBDelta(){}
@@ -399,11 +395,9 @@
 +    sal_uInt16 reserved1;
 +    sal_Int16 ctbds;
 +
-+    CTB* customizationDataCTB;
-+    TBDelta* customizationDataTBDelta; // we don't read these yet
++    boost::shared_ptr< CTB > customizationDataCTB;
++    std::vector< TBDelta > customizationDataTBDelta; 
 +    
-+    Customization(const Customization&);
-+    Customization& operator = ( const Customization&);
 +public:    
 +    Customization();
 +    ~Customization();
@@ -424,8 +418,8 @@
 +
 +    sal_Int32 cbDTBC;
 +
-+    sal_uInt8* rtbdc; // array of TBC's - we don't read these yet 
-+    Customization* rCustomizations; // array of Customizations
++    std::vector< TBC > rtbdc; // array of TBC's - we don't read these yet 
++    std::vector< Customization > rCustomizations; // array of Customizations
 +
 +    CTBWrapper(const CTBWrapper&);
 +    CTBWrapper& operator = ( const CTBWrapper&);
@@ -630,8 +624,8 @@
 +
 +#endif
 --- /dev/null	2008-04-22 00:28:44.000000000 +0100
-+++ sw/source/filter/ww8/ww8toolbar.cxx	2009-02-01 10:05:39.000000000 +0000
-@@ -0,0 +1,1220 @@
++++ sw/source/filter/ww8/ww8toolbar.cxx	2009-02-02 12:16:27.000000000 +0000
+@@ -0,0 +1,1275 @@
 +#include "ww8toolbar.hxx"
 +#include <rtl/ustrbuf.hxx>
 +#include <stdarg.h>
@@ -678,21 +672,17 @@
 +,cCust(0)
 +,cbDTBC(0)
 +,rtbdc(0)
-+,rCustomizations(0)
 +{
 +}
 +
 +CTBWrapper::~CTBWrapper()
 +{
-+    if ( rtbdc )
-+        delete [] rtbdc; 
-+    if ( rCustomizations )
-+        delete [] rCustomizations; 
 +}
 +
 +bool CTBWrapper::Read( SotStorageStream* pS )
 +{
 +    OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    *pS >> reserved2 >> reserved3 >> reserved4 >> reserved5;
 +    *pS >> cbTBD >> cCust >> cbDTBC;
@@ -701,15 +691,31 @@
 +        // cbDTBC is the size in bytes of the TBC array
 +        // but the size of a TBC element is dynamic ( and this relates to TBDelta's
 +        // which we don't read right now )
-+        pS->SeekRel( cbDTBC );
++        //pS->SeekRel( cbDTBC );
++        int nStart = pS->Tell();
++
++        int bytesRead = 0;
++        int bytesToRead = cbDTBC - bytesRead; 
++        // cbDTBC specifies the size ( in bytes ) taken by an array ( of unspecified size )
++        // of TBC records ( TBC records have dynamic length, so we need to check our position
++        // after each read )
++        do
++        {
++            TBC aTBC;
++            if ( !aTBC.Read( pS ) )
++                return false;
++            rtbdc.push_back( aTBC );
++            bytesToRead = cbDTBC - ( pS->Tell() - nStart ); 
++        } while ( bytesToRead > 0 );
 +    }
 +    if ( cCust )
 +    {
-+        rCustomizations = new Customization[ cCust ];
++        Customization aCust;
 +        for ( sal_Int32 index = 0; index < cCust; ++index )
 +        {
-+            if ( !rCustomizations[ index ].Read( pS ) )
++            if ( !aCust.Read( pS ) )
 +                return false;
++            rCustomizations.push_back( aCust );
 +        } 
 +    } 
 +    return true;
@@ -718,7 +724,7 @@
 +void CTBWrapper::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"CTBWrapper - dump\n");
++    indent_printf(fp,"[ 0x%x ] CTBWrapper - dump\n", nOffSet );
 +    bool bRes = ( ch == 0x12 && reserved2 == 0x0 && reserved3 == 0x7 && reserved4 == 0x6 && reserved5 == 0xC );
 +    if ( bRes )
 +        indent_printf(fp,"  sanity check ( first 8 bytes conform )\n");
@@ -732,52 +738,56 @@
 +        indent_printf(fp,"Quiting dump");
 +        return;
 +    }
-+    indent_printf(fp,"  cbTBD: no. of TBDelta structures ( skipped if present ) 0x%x\n", cbTBD );
++    indent_printf(fp,"  size of TBDelta structures 0x%x\n", cbTBD );
 +    indent_printf(fp,"  cCust: no. of cCust structures 0x%x\n",cCust);
 +    indent_printf(fp,"  cbDTBC: no. of bytes in rtbdc array 0x%x\n", static_cast< unsigned int >( cbDTBC ));
-+    indent_printf(fp,"  .... skipping rtbdc\n");
-+    if ( rCustomizations )
++
++    sal_Int32 index = 0;
++
++    for ( std::vector< TBC >::iterator it = rtbdc.begin(); it != rtbdc.end(); ++it, ++index )
 +    {
-+        for ( sal_Int32 index = 0; index < cCust; ++index )
-+        {
-+            indent_printf(fp,"  Dumping custimization [%d]\n", static_cast< int >( index ));
-+            INDENT;
-+            rCustomizations[ index ].Print(fp);
-+        }
++        indent_printf(fp,"  Dumping rtbdc[%d]\n", static_cast< int >( index ));
++        INDENT;
++        it->Print( fp );
++    }
++
++    index = 0;
++
++    for ( std::vector< Customization >::iterator it = rCustomizations.begin(); it != rCustomizations.end(); ++it, ++index )
++    {
++        indent_printf(fp,"  Dumping custimization [%d]\n", static_cast< int >( index ));
++        INDENT;
++        it->Print(fp);
 +    }
 +}
 +Customization::Customization() : tbidForTBD( 0 )
 +,reserved1( 0 )
 +, ctbds( 0 )
-+, customizationDataCTB( 0 )
-+, customizationDataTBDelta( 0 )
 +{
 +}
 +
 +Customization::~Customization()
 +{
-+    if ( customizationDataCTB )
-+        delete customizationDataCTB;
-+    if ( customizationDataTBDelta )
-+        delete [] customizationDataTBDelta;
 +}
 +
 +bool Customization::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("Custimization::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> tbidForTBD >> reserved1 >> ctbds;
 +    if ( tbidForTBD && ctbds )
 +    {
-+        customizationDataTBDelta = new TBDelta[ ctbds ];
++        TBDelta aTBDelta;
 +        for ( sal_Int32 index = 0; index < ctbds; ++index )
 +        {
-+            if (!customizationDataTBDelta[ index ].Read( pS ) )
++            if (!aTBDelta.Read( pS ) )
 +                return false;
++            customizationDataTBDelta.push_back( aTBDelta );
 +        }
 +    }
 +    else
 +    {
-+        customizationDataCTB = new CTB();
++        customizationDataCTB.reset( new CTB() );
 +        if ( !customizationDataCTB->Read( pS ) )
 +                return false;
 +    }
@@ -787,7 +797,7 @@
 +void Customization::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp,"Customization -- dump \n");
++    indent_printf( fp,"[ 0x%x ] Customization -- dump \n", nOffSet );
 +    indent_printf( fp,"  tbidForTBD 0x%x ( should be 0 for CTBs )\n", static_cast< unsigned int >( tbidForTBD ));
 +    indent_printf( fp,"  reserved1 0x%x \n", reserved1);
 +    indent_printf( fp,"  ctbds - number of customisations %d(0x%x) \n", ctbds, ctbds );
@@ -795,8 +805,9 @@
 +        customizationDataCTB->Print( fp );
 +    else
 +    {
-+        for ( sal_Int32 index = 0; index < ctbds; ++index )
-+            customizationDataTBDelta[ index ].Print( fp );
++        std::vector< TBDelta >::iterator it = customizationDataTBDelta.begin();
++        for ( sal_Int32 index = 0; index < ctbds; ++it,++index )
++            it->Print( fp );
 +    }
 +    
 +}
@@ -813,9 +824,9 @@
 +bool TBDelta::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("TBDelta::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> doprfatendFlags >> ibts >> cidNext >> cid >> fc ;
-+    pS->Read( CiTBDE, sizeof( CiTBDE ) );
-+    *pS >> cbTBC;
++    *pS >> CiTBDE >> cbTBC;
 +    return true;
 +}
 +
@@ -823,16 +834,15 @@
 +{
 +    // Like most of the debug output, it's raw and little ( no )
 +    // interpretation of the data is output ( e.g. flag values etc. )
-+    indent_printf( fp, "TBDelta -- dump\n" );
++    indent_printf( fp, "[ 0x%x ] TBDelta -- dump\n", nOffSet );
 +    indent_printf( fp, " doprfatendFlags 0x%x\n",doprfatendFlags );
 +    
 +    indent_printf( fp, " ibts 0x%x\n",ibts );
 +    indent_printf( fp, " cidNext 0x%x\n", static_cast< unsigned int >( cidNext ) );
 +    indent_printf( fp, " cid 0x%x\n", static_cast< unsigned int >( cid ) );
 +    indent_printf( fp, " fc 0x%x\n", static_cast< unsigned int >( fc ) );
-+    indent_printf( fp, " CiTBDE[0] 0x%x\n",CiTBDE[0] );
-+    indent_printf( fp, " CiTBDE[1] 0x%x\n",CiTBDE[1] );
-+    indent_printf( fp, " cbTCB 0x%x\n", cbTBC );
++    indent_printf( fp, " CiTBDE 0x%x\n",CiTBDE );
++    indent_printf( fp, " cbTBC 0x%x\n", cbTBC );
 +}
 +
 +CTB::CTB() : cbTBData( 0 )
@@ -840,19 +850,17 @@
 +,reserved( 0 )
 +,unused( 0 )
 +,cCtls( 0 )
-+,rTBC( 0 )
 +{
 +}
 +
 +CTB::~CTB()
 +{
-+    if ( rTBC )
-+        delete [] rTBC;
 +}
 +
 +bool CTB::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("CTB::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if ( !name.Read( pS ) )
 +        return false;
 +    *pS >> cbTBData;
@@ -865,11 +873,12 @@
 +    
 +    if ( cCtls )
 +    {
-+        rTBC = new TBC[ cCtls ];
 +        for ( sal_Int32 index = 0; index < cCtls; ++index )
 +        {
-+            if ( !rTBC[ index ].Read( pS ) )
++            TBC aTBC;
++            if ( !aTBC.Read( pS ) )
 +                return false;
++            rTBC.push_back( aTBC );
 +        }
 +    }
 +    return true;
@@ -879,7 +888,7 @@
 +CTB::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "CTB - dump\n");
++    indent_printf(fp, "[ 0x%x ] CTB - dump\n", nOffSet );
 +    indent_printf(fp, "  name %s\n", rtl::OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
 +    indent_printf(fp, "  cbTBData size, in bytes, of this structure excluding the name, cCtls, and rTBC fields.  %x\n", static_cast< unsigned int >( cbTBData ) );
 +    
@@ -909,6 +918,7 @@
 +bool TB::Read( SotStorageStream* pS )
 +{
 +    OSL_TRACE("TB::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> bSignature >> bVersion >> cCL >> ltbid >> ltbtr >> cRowsDefault >> bFlags;
 +    return name.Read( pS );
 +}
@@ -916,30 +926,29 @@
 +void TB::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TB -- dump\n");
++    indent_printf( fp, "[ 0x%x ] TB -- dump\n", nOffSet );
 +    indent_printf( fp, "  bSignature (0x%x), bVersion(0x%x), cCL(0x%x), ltbid(0x%x), cRowsDefault (0x%x), ltbtr(0x%x), bFlags(0x%x)\n", bSignature, bVersion, cCL, static_cast< unsigned int >( ltbid ), static_cast< unsigned int >( ltbtr ), cRowsDefault, bFlags );
 +    indent_printf( fp, "  name %s\n", rtl::OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
 +
 +}
 +
-+TBC::TBC() : cid( 0 )
++TBC::TBC()
 +{
 +}
 +
 +TBC::~TBC()
 +{
-+    if ( cid )
-+        delete cid;
 +}
 +
 +bool TBC::Read( SotStorageStream *pS )
 +{
 +    OSL_TRACE("TBC::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if ( !tbch.Read( pS ) )
 +        return false;
 +    if ( tbch.getTcID() != 0x1 && tbch.getTcID() != 0x1051 )
 +    {
-+        cid = new sal_uInt32;
++        cid.reset( new sal_uInt32 );
 +        *pS >> *cid;
 +    }
 +    // MUST exist if tbch.tct is not equal to 0x16
@@ -955,10 +964,10 @@
 +void TBC::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"TCB -- dump\n");
++    indent_printf(fp,"[ 0x%x ] TBC -- dump\n", nOffSet );
 +    indent_printf(fp,"  dumping header ( TBCHeader )\n");
 +    tbch.Print( fp );
-+    if ( cid )
++    if ( cid.get() )
 +        indent_printf(fp,"  cid = 0x%x\n", static_cast< unsigned int >( *cid ) );
 +    if ( tbcd.get() )
 +    {
@@ -973,29 +982,24 @@
 +,tct(0x1) // default to Button
 +,tcid(0)
 +,tbct(0)
-+,width(NULL)
-+,height(NULL)
 +{
 +}
 +
 +
 +TBCHeader::~TBCHeader()
 +{
-+    if ( width )
-+        delete width;
-+    if ( height )
-+        delete height;
 +}
 +
 +bool TBCHeader::Read( SotStorageStream* pS )
 +{
 +    OSL_TRACE("TBCHeader::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> bSignature >> bVersion >> bFlagsTCR >> tct >> tcid >> tbct >> bPriority;
 +    //  bit 4 ( from lsb ) 
 +    if ( bFlagsTCR & 0x10 )
 +    {
-+        width = new sal_uInt16;
-+        height = new sal_uInt16;
++        width.reset( new sal_uInt16 );
++        height.reset( new sal_uInt16 );
 +        *pS >> *width >> *height;
 +    }
 +    return true;
@@ -1004,7 +1008,7 @@
 +void TBCHeader::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"TBCHeader -- dump\n");
++    indent_printf(fp,"[ 0x%x ] TBCHeader -- dump\n", nOffSet );
 +    indent_printf(fp,"  bSignature 0x%xn", bSignature );
 +    indent_printf(fp,"  bVersion 0x%x\n", bVersion );
 +    indent_printf(fp,"  bFlagsTCR 0x%x\n", bFlagsTCR );
@@ -1012,15 +1016,20 @@
 +    indent_printf(fp,"  tcid 0x%x\n", tcid );
 +    indent_printf(fp,"  tbct 0x%x\n", static_cast< unsigned int >( tbct ));
 +    indent_printf(fp,"  bPriority 0x%x\n", bPriority );
-+    if ( width )
++    if ( width.get() )
 +        indent_printf(fp,"  width 0x%d(0x%x)\n", *width, *width);
-+    if ( height )
++    if ( height.get() )
 +        indent_printf(fp,"  height 0x%d(0x%x)\n", *height, *height);
 +}
 +
++TBCData::TBCData( const TBCHeader& Header ) : rHeader( Header )
++{
++}
++
 +bool TBCData::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("TBCData::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if ( !controlGeneralInfo.Read(pS) /*|| !controlSpecificInfo.Read(pS)*/ )
 +        return false;
 +    switch ( rHeader.getTct() )
@@ -1057,7 +1066,7 @@
 +void TBCData::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"TBCData -- dump\n");
++    indent_printf(fp,"[ 0x%x ] TBCData -- dump\n", nOffSet );
 +    indent_printf(fp,"  dumping controlGeneralInfo( TBCGeneralInfo )\n");
 +    controlGeneralInfo.Print( fp );
 +    if ( rHeader.getTct() == 1 )
@@ -1071,6 +1080,7 @@
 +WString::Read( SotStorageStream *pS )
 +{
 +    OSL_TRACE("WString::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    sal_Int8 nChars = 0;
 +    *pS >> nChars;
 +    sString = readUnicodeString( pS, static_cast< sal_Int32 >( nChars  ) );
@@ -1081,6 +1091,7 @@
 +Xst::Read( SotStorageStream* pS )
 +{
 +    OSL_TRACE("Xst::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    sal_Int16 nChars = 0;
 +    *pS >> nChars;
 +    sString = readUnicodeString( pS, static_cast< sal_Int32 >( nChars  ) );
@@ -1091,7 +1102,7 @@
 +Xst::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "Xst -- dump\n");
++    indent_printf( fp, "[ 0x%x ] Xst -- dump\n", nOffSet );
 +    indent_printf( fp, " %s",  rtl::OUStringToOString( sString, RTL_TEXTENCODING_UTF8 ).getStr() );
 +}
 +TBCExtraInfo::TBCExtraInfo() : idHelpContext( 0 )
@@ -1102,6 +1113,7 @@
 +TBCExtraInfo::Read( SotStorageStream *pS )
 +{
 +    OSL_TRACE("TBCExtraInfo::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if( !wstrHelpFile.Read( pS )  )
 +        return false;
 +
@@ -1118,7 +1130,7 @@
 +TBCExtraInfo::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TBCExtraInfo -- dump\n");
++    indent_printf( fp, "[ 0x%x ] TBCExtraInfo -- dump\n", nOffSet );
 +    indent_printf( fp, "  wstrHelpFile %s\n", 
 +        rtl::OUStringToOString( wstrHelpFile.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
 +    indent_printf( fp, "  idHelpContext 0x%x\n", static_cast< unsigned int >( idHelpContext ) );
@@ -1140,6 +1152,7 @@
 +bool TBCGeneralInfo::Read( SotStorageStream *pS )
 +{
 +    OSL_TRACE("TBCGeneralInfo::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> bFlags;
 +
 +    if ( ( bFlags & 0x1 ) && !customText.Read( pS ) )
@@ -1155,7 +1168,7 @@
 +TBCGeneralInfo::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TBCGeneralInfo -- dump\n");
++    indent_printf( fp, "[ 0x%x ] TBCGeneralInfo -- dump\n", nOffSet );
 +    indent_printf( fp, "  bFlags 0x%x\n", bFlags );
 +    indent_printf( fp, "  customText %s\n", 
 +        rtl::OUStringToOString( customText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
@@ -1163,7 +1176,8 @@
 +        rtl::OUStringToOString( descriptionText.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
 +    indent_printf( fp, "  tooltip %s\n", 
 +        rtl::OUStringToOString( tooltip.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
-+    extraInfo.Print( fp );
++    if ( bFlags & 0x4 ) 
++        extraInfo.Print( fp );
 +}
 +
 +TBCMenuSpecific::TBCMenuSpecific() : tbid( 0 )
@@ -1174,6 +1188,7 @@
 +TBCMenuSpecific::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("TBCMenuSpecific::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> tbid;
 +    if ( tbid == 1 ) 
 +    {
@@ -1187,7 +1202,7 @@
 +TBCMenuSpecific::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TBCMenuSpecific -- dump\n");
++    indent_printf( fp, "[ 0x%x ] TBCMenuSpecific -- dump\n", nOffSet );
 +    indent_printf( fp, "  tbid 0x%x\n", static_cast< unsigned int >( tbid ) );
 +    if ( tbid == 1 )
 +        indent_printf( fp, "  name %s", rtl::OUStringToOString( name->getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
@@ -1201,6 +1216,7 @@
 +bool TBCBSpecific::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("TBCBSpecific::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> bFlags;
 +
 +    // bFlags determines what we read next
@@ -1232,7 +1248,7 @@
 +void TBCBSpecific::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TBCBSpecific -- dump\n");
++    indent_printf( fp, "[ 0x%x ] TBCBSpecific -- dump\n", nOffSet );
 +    indent_printf( fp, "  bFlags 0x%x\n", bFlags );
 +    bool bResult = ( icon.get() != NULL );
 +    indent_printf( fp, "  icon present? %s\n", bResult ? "true" : "false" );
@@ -1266,6 +1282,7 @@
 +
 +bool TBCComboDropdownSpecific::Read( SotStorageStream *pS)
 +{
++    nOffSet = pS->Tell();
 +    if ( data.get() )
 +        return data->Read( pS );
 +    return true;
@@ -1274,7 +1291,7 @@
 +void TBCComboDropdownSpecific::Print( FILE* fp)
 +{
 +    INDENT;
-+    indent_printf(fp,"TBCComboDropdownSpecific -- dump" );
++    indent_printf(fp,"[ 0x%x ] TBCComboDropdownSpecific -- dump\n", nOffSet );
 +    if ( data.get() )
 +        data->Print( fp );
 +    else
@@ -1282,7 +1299,6 @@
 +}
 +
 +TBCCDData::TBCCDData() : cwstrItems( 0 )
-+,wstrList( NULL ) 
 +,iSel( 0 )
 +,cLines( 0 )
 +,dxWidth( 0 )
@@ -1291,20 +1307,20 @@
 +
 +TBCCDData::~TBCCDData()
 +{
-+    if ( wstrList )
-+        delete[] wstrList;
 +}
 +
 +bool TBCCDData::Read( SotStorageStream *pS)
 +{
++    nOffSet = pS->Tell();
 +    *pS >> cwstrItems;
 +    if ( cwstrItems )
 +    {
-+        wstrList = new WString[ cwstrItems ];
 +        for( sal_Int32 index=0; index < cwstrItems; ++index )
 +        {
-+            if ( !wstrList[ index ].Read( pS ) )
++            WString aString;
++            if ( !aString.Read( pS ) )
 +                return false;
++            wstrList.push_back( aString );
 +        } 
 +    }
 +    *pS >> cwstrMRU >> iSel >> cLines >> dxWidth;
@@ -1315,7 +1331,7 @@
 +void TBCCDData::Print( FILE* fp)
 +{
 +    INDENT;
-+    indent_printf(fp,"TBCCDData -- dump\n");
++    indent_printf(fp,"[ 0x%x ] TBCCDData -- dump\n", nOffSet );
 +    indent_printf(fp,"  cwstrItems items in wstrList 0x%d\n", cwstrItems);
 +    for ( sal_Int32 index=0; index < cwstrItems; ++index )
 +    {
@@ -1329,7 +1345,7 @@
 +    indent_printf(fp,"  wstrEdit %s", rtl::OUStringToOString( wstrEdit.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
 +}
 +
-+TBCBitMap::TBCBitMap() : cbDIB( 0 ), pRestOfIt( NULL )
++TBCBitMap::TBCBitMap() : cbDIB( 0 ), pRestOfIt( NULL ), size( 0 )
 +{
 +}
 +
@@ -1339,9 +1355,28 @@
 +        delete [] pRestOfIt;
 +}
 +
++TBCBitMap::TBCBitMap(const TBCBitMap& other)
++{
++    *this = other;
++}
++
++
++TBCBitMap& TBCBitMap::operator = ( const TBCBitMap& other )
++{
++    if ( pRestOfIt )
++        delete [] pRestOfIt;
++    if ( other.size && other.pRestOfIt )
++    {
++        pRestOfIt = new sal_uInt8[ other.size ];
++        pRestOfIt = static_cast< sal_uInt8* > ( memcpy( static_cast< void* >( pRestOfIt) , static_cast< void* >( other.pRestOfIt ), other.size ) );
++    }
++    return *this; 
++}
++
 +bool TBCBitMap::Read( SotStorageStream* pS)
 +{
 +    OSL_TRACE("TBCBitMap::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> cbDIB;
 +    // cbDIB = sizeOf(biHeader) + sizeOf(colors) + sizeOf(bitmapData) + 10
 +    // slurp the rest of the structure as a blob ( we'll get to it later )
@@ -1354,7 +1389,7 @@
 +void TBCBitMap::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "TBCBitMap -- dump\n");
++    indent_printf(fp, "[ 0x%x ] TBCBitMap -- dump\n", nOffSet );
 +    indent_printf(fp, "  TBCBitMap size of bitmap data 0x%x\n", static_cast< unsigned int > ( cbDIB ) );
 +}
 +
@@ -1365,6 +1400,7 @@
 +bool Tcg::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Tcg::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> nTcgVer;
 +    if ( nTcgVer != (sal_Int8)255 )
 +        return false;
@@ -1375,7 +1411,7 @@
 +void Tcg::Print( FILE* fp )
 +{
 +    INDENT_INIT;
-+    indent_printf(fp, "Tcg - dump %d\n", nTcgVer);
++    indent_printf(fp, "[ 0x%x ] Tcg - dump %d\n", nOffSet, nTcgVer);
 +    indent_printf(fp,"  nTcgVer %d\n", nTcgVer);
 +    tcg->Print( fp );
 +}
@@ -1441,6 +1477,7 @@
 +bool Tcg255::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Tcg255::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    sal_uInt8 nId = 0; // 
 +    *pS >> nId;
 +    while (  nId != 0x40  )
@@ -1456,7 +1493,7 @@
 +void Tcg255::Print( FILE* fp)
 +{
 +    INDENT;
-+    indent_printf(fp, "Tcg255 - dump\n");
++    indent_printf(fp, "[ 0x%x ] Tcg255 - dump\n", nOffSet );
 +    indent_printf(fp, "  contains %d sub records\n", rgtcgData.size() );
 +    std::vector< Tcg255SubStruct* >::iterator it = rgtcgData.begin(); 
 +    std::vector< Tcg255SubStruct* >::iterator it_end = rgtcgData.end(); 
@@ -1477,6 +1514,7 @@
 +bool Tcg255SubStruct::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Tcg255SubStruct::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if ( mbReadId )
 +        *pS >> ch;
 +    return true;
@@ -1494,6 +1532,7 @@
 +bool PlfMcd::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("PffMcd::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    *pS >> iMac;
 +    if ( iMac )
@@ -1511,7 +1550,7 @@
 +void PlfMcd::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "PlfMcd ( Tcg255SubStruct ) - dump\n");
++    indent_printf(fp, "[ 0x%x ] PlfMcd ( Tcg255SubStruct ) - dump\n", nOffSet );
 +    indent_printf(fp, " contains %d MCD records\n", static_cast<int>( iMac ) );
 +    for ( sal_Int32 count=0; count < iMac; ++count )
 +    {
@@ -1538,6 +1577,7 @@
 +bool PlfAcd::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("PffAcd::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    *pS >> iMac;
 +    if ( iMac )
@@ -1554,7 +1594,7 @@
 +void PlfAcd::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "PlfAcd ( Tcg255SubStruct ) - dump\n");
++    indent_printf(fp, "[ 0x%x ] PlfAcd ( Tcg255SubStruct ) - dump\n", nOffSet );
 +    indent_printf(fp, " contains %d ACD records\n", static_cast< int >( iMac ) );
 +    for ( sal_Int32 count=0; count < iMac; ++count )
 +    {
@@ -1580,6 +1620,7 @@
 +bool PlfKme::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("PlfKme::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    *pS >> iMac;
 +    if ( iMac )
@@ -1597,7 +1638,7 @@
 +void PlfKme::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "PlfKme ( Tcg255SubStruct ) - dump\n");
++    indent_printf(fp, "[ 0x%x ] PlfKme ( Tcg255SubStruct ) - dump\n", nOffSet );
 +    indent_printf(fp, " contains %d Kme records\n", static_cast< int >( iMac ) );
 +    for ( sal_Int32 count=0; count < iMac; ++count )
 +    {
@@ -1615,6 +1656,7 @@
 +bool TcgSttbf::Read( SotStorageStream *pS) 
 +{
 +    OSL_TRACE("TcgSttbf::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    return sttbf.Read( pS );
 +}
@@ -1622,7 +1664,7 @@
 +void TcgSttbf::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"TcgSttbf - dump\n");
++    indent_printf(fp,"[ 0x%x ] TcgSttbf - dump\n", nOffSet );
 +    sttbf.Print( fp );
 +}
 +
@@ -1642,6 +1684,7 @@
 +bool TcgSttbfCore::Read( SotStorageStream* pS )
 +{
 +    OSL_TRACE("TcgSttbfCore::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> fExtend >> cData >> cbExtra;
 +    if ( cData )
 +    {
@@ -1659,7 +1702,7 @@
 +void TcgSttbfCore::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "TcgSttbfCore - dump\n");
++    indent_printf( fp, "[ 0x%x ] TcgSttbfCore - dump\n");
 +    indent_printf( fp, " fExtend 0x%x [expected 0xFFFF ]\n", fExtend );
 +    indent_printf( fp, " cbExtra 0x%x [expected 0x02 ]\n", cbExtra );
 +    indent_printf( fp, " cData no. or string data items %d (0x%x)\n", cData, cData );
@@ -1686,6 +1729,7 @@
 +bool MacroNames::Read( SotStorageStream *pS)
 +{
 +    OSL_TRACE("MacroNames::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    Tcg255SubStruct::Read( pS );
 +    *pS >> iMac;
 +    if ( iMac )
@@ -1703,7 +1747,7 @@
 +void MacroNames::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp, "MacroNames ( Tcg255SubStruct ) - dump\n");
++    indent_printf(fp, "[ 0x%x ] MacroNames ( Tcg255SubStruct ) - dump\n");
 +    indent_printf(fp, " contains %d MacroName records\n", iMac );
 +    for ( sal_Int32 count=0; count < iMac; ++count )
 +    {
@@ -1722,6 +1766,7 @@
 +bool MacroName::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("MacroName::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> ibst;
 +    return xstz.Read( pS );
 +}
@@ -1729,7 +1774,7 @@
 +void MacroName::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "MacroName - dump");
++    indent_printf( fp, "[ 0x%x ] MacroName - dump");
 +    indent_printf( fp,"  index - 0x%x has associated following record\n", ibst );
 +    xstz.Print( fp );
 +}
@@ -1744,6 +1789,7 @@
 +Xstz::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Xstz::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    if ( !xst.Read( pS ) )
 +        return false;
 +    *pS >> chTerm;
@@ -1755,7 +1801,7 @@
 +void Xstz::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf(fp,"Xstz -- dump\n");
++    indent_printf(fp,"[ 0x%x ] Xstz -- dump\n", nOffSet );
 +    indent_printf(fp,"  Xst\n");
 +    xst.Print( fp ); 
 +    indent_printf(fp,"  chterm 0x%x ( should be zero )\n", chTerm);
@@ -1778,6 +1824,7 @@
 +Kme::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Kme::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> reserved1 >> reserved2 >> kcm1 >> kcm2 >> param;
 +    return true;
 +}
@@ -1786,7 +1833,7 @@
 +{
 +    INDENT;
 +    
-+   indent_printf( fp, "Kme - dump\n");
++   indent_printf( fp, "[ 0x%x ] Kme - dump\n", nOffSet );
 +   indent_printf( fp, " reserved1 0x%x [expected 0x0 ]\n", reserved1 );
 +   indent_printf( fp, " reserved2 0x%x [expected 0x0 ]\n", reserved2 );
 +   indent_printf( fp, " kcm1 0x%x [shortcut key]\n", kcm1 );
@@ -1803,6 +1850,7 @@
 +bool Acd::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("Acd::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> ibst >> fciBasedOnABC;
 +    return true;
 +}
@@ -1810,7 +1858,7 @@
 +void Acd::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp,"ACD - dump\n");
++    indent_printf( fp,"[ 0x%x ] ACD - dump\n", nOffSet );
 +    // #TODO flesh out interpretation of these values
 +    indent_printf( fp,"  ibst 0x%x\n", ibst);
 +    indent_printf( fp,"  fciBaseObABC 0x%x\n", fciBasedOnABC);
@@ -1831,6 +1879,7 @@
 +bool  MCD::Read(SotStorageStream *pS)
 +{
 +    OSL_TRACE("MCD::Read() stream pos 0x%x", pS->Tell() );
++    nOffSet = pS->Tell();
 +    *pS >> reserved1 >> reserved2 >> ibst >> ibstName >> reserved3;
 +    *pS >> reserved4 >> reserved5 >> reserved6 >> reserved7;
 +    return true;
@@ -1839,7 +1888,7 @@
 +void MCD::Print( FILE* fp )
 +{
 +    INDENT;
-+    indent_printf( fp, "MCD - dump\n");
++    indent_printf( fp, "[ 0x%x ] MCD - dump\n", nOffSet );
 +    indent_printf( fp, " reserved1 0x%x [expected 0x56 ]\n", reserved1 );
 +    indent_printf( fp, " reserved2 0x%x [expected 0x0 ]\n", reserved2 );
 +    indent_printf( fp, " ibst 0x%x specifies macro with MacroName.xstz = 0x%x\n", ibst, ibst );



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