summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-11-28 21:43:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-11-28 21:46:57 +0000
commitb2be75d95899a3babc16b2a590f8568cfca8124f (patch)
treede5278a4112cb9e8d4499085c75fd83869f06ed0
parent9324268b51383a5957818f810c83a770258b94ce (diff)
Resolves: fdo#41554 ww6 file cannot be opened
it falls into a (apparently) ww8 specific old school macro parser we use to scrape out some toolbar info and tries to allocate some nutso numbers which throws and aborts the import. Skip importing these in ww6 document, and tweak the code to be a bit more forgiving in ww8 documents where the load fails via exceptions Change-Id: I9bba60db3b95ece54f68d4fa23031f46545697da
-rw-r--r--sw/source/filter/ww8/ww8par.cxx34
-rw-r--r--sw/source/filter/ww8/ww8toolbar.cxx44
-rw-r--r--sw/source/filter/ww8/ww8toolbar.hxx8
3 files changed, 59 insertions, 27 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index ef163cd62132..9b1b5dbdf9a2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4252,22 +4252,30 @@ WW8Customizations::WW8Customizations( SvStream* pTableStream, WW8Fib& rFib ) : m
bool WW8Customizations::Import( SwDocShell* pShell )
{
- if ( mWw8Fib.lcbCmds == 0 )
+ if ( mWw8Fib.lcbCmds == 0 || !IsEightPlus(mWw8Fib.GetFIBVersion()) )
return false;
- Tcg aTCG;
- long nCur = mpTableStream->Tell();
- mpTableStream->Seek( mWw8Fib.fcCmds ); // point at tgc record
- bool bReadResult = aTCG.Read( *mpTableStream );
- mpTableStream->Seek( nCur ); // return to previous position, is that necessary?
- if ( !bReadResult )
- {
- OSL_TRACE("** Read of Customization data failed!!!! ");
- return false;
- }
+ try
+ {
+ Tcg aTCG;
+ long nCur = mpTableStream->Tell();
+ mpTableStream->Seek( mWw8Fib.fcCmds ); // point at tgc record
+ bool bReadResult = aTCG.Read( *mpTableStream );
+ mpTableStream->Seek( nCur ); // return to previous position, is that necessary?
+ if ( !bReadResult )
+ {
+ SAL_WARN("sw.ww8", "** Read of Customization data failed!!!! ");
+ return false;
+ }
#if DEBUG
- aTCG.Print( stderr );
+ aTCG.Print( stderr );
#endif
- return aTCG.ImportCustomToolBar( *pShell );
+ return aTCG.ImportCustomToolBar( *pShell );
+ }
+ catch(...)
+ {
+ SAL_WARN("sw.ww8", "** Read of Customization data failed!!!! epically");
+ return false;
+ }
}
bool SwWW8ImplReader::ReadGlobalTemplateSettings( const rtl::OUString& sCreatedFrom, const uno::Reference< container::XNameContainer >& xPrjNameCache )
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 696bbb488a61..2d8f5c7da70f 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -955,16 +955,12 @@ bool Tcg255SubStruct::Read(SvStream &rS)
return true;
}
-PlfMcd::PlfMcd( bool bReadId ): Tcg255SubStruct( bReadId ), iMac(0), rgmcd( NULL )
+PlfMcd::PlfMcd(bool bReadId)
+ : Tcg255SubStruct(bReadId)
+ , iMac(0)
{
}
-PlfMcd::~PlfMcd()
-{
- if ( rgmcd )
- delete[] rgmcd;
-}
-
bool PlfMcd::Read(SvStream &rS)
{
OSL_TRACE("PffMcd::Read() stream pos 0x%x", rS.Tell() );
@@ -973,7 +969,7 @@ bool PlfMcd::Read(SvStream &rS)
rS >> iMac;
if ( iMac )
{
- rgmcd = new MCD[ iMac ];
+ rgmcd.resize(iMac);
for ( sal_Int32 index = 0; index < iMac; ++index )
{
if ( !rgmcd[ index ].Read( rS ) )
@@ -1312,7 +1308,37 @@ MCD::MCD() : reserved1(0x56)
{
}
-bool MCD::Read(SvStream &rS)
+MCD::MCD(const MCD& rO)
+ : reserved1(rO.reserved1)
+ , reserved2(rO.reserved2)
+ , ibst(rO.ibst)
+ , ibstName(rO.ibstName)
+ , reserved3(rO.reserved3)
+ , reserved4(rO.reserved4)
+ , reserved5(rO.reserved5)
+ , reserved6(rO.reserved6)
+ , reserved7(rO.reserved7)
+{
+}
+
+MCD& MCD::operator=(const MCD& rO)
+{
+ if (this != &rO)
+ {
+ reserved1 = rO.reserved1;
+ reserved2 = rO.reserved2;
+ ibst = rO.ibst;
+ ibstName = rO.ibstName;
+ reserved3 = rO.reserved3;
+ reserved4 = rO.reserved4;
+ reserved5 = rO.reserved5;
+ reserved6 = rO.reserved6;
+ reserved7 = rO.reserved7;
+ }
+ return *this;
+}
+
+bool MCD::Read(SvStream &rS)
{
OSL_TRACE("MCD::Read() stream pos 0x%x", rS.Tell() );
nOffSet = rS.Tell();
diff --git a/sw/source/filter/ww8/ww8toolbar.hxx b/sw/source/filter/ww8/ww8toolbar.hxx
index 542d28839e11..954958f92da5 100644
--- a/sw/source/filter/ww8/ww8toolbar.hxx
+++ b/sw/source/filter/ww8/ww8toolbar.hxx
@@ -192,11 +192,10 @@ class MCD : public TBBase
sal_uInt32 reserved6; //MUST be ignored.
sal_uInt32 reserved7; //MUST be ignored
- MCD(const MCD&);
- MCD& operator = ( const MCD&);
public:
MCD();
- ~MCD(){}
+ MCD(const MCD&);
+ MCD& operator = ( const MCD&);
bool Read(SvStream &rS);
void Print( FILE* );
};
@@ -204,12 +203,11 @@ public:
class PlfMcd : public Tcg255SubStruct
{
sal_Int32 iMac;
- MCD* rgmcd; // array of MCD's
+ std::vector<MCD> rgmcd; // array of MCD's
PlfMcd(const PlfMcd&);
PlfMcd& operator = ( const PlfMcd&);
public:
PlfMcd( bool bReadId = true );
- ~PlfMcd();
bool Read(SvStream &rS);
void Print( FILE* );
};