Kaydet (Commit) d650d404 authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Tor Lillqvist

Deduplicate CTB, TBC and CTBWrapper (for disable-dynloading)

Change-Id: I0e9895ca59fa75958107df2cbf4348214df52664
üst 45948e12
......@@ -343,7 +343,7 @@ void ImportExcel8::ReadBasic( void )
SvStorageStreamRef xXCB = xRootStrg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "XCB" ) ), STREAM_STD_READ | STREAM_NOCREATE );
if ( xXCB.Is()|| SVSTREAM_OK == xXCB->GetError() )
{
CTBWrapper wrapper;
ScCTBWrapper wrapper;
if ( wrapper.Read( *xXCB ) )
{
#if OSL_DEBUG_LEVEL > 1
......
......@@ -94,17 +94,17 @@ CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3
{
}
CTB::CTB() : nViews( 0 ), ectbid(0)
ScCTB::ScCTB() : nViews( 0 ), ectbid(0)
{
}
CTB::CTB(sal_uInt16 nNum ) : nViews( nNum ), ectbid(0)
ScCTB::ScCTB(sal_uInt16 nNum ) : nViews( nNum ), ectbid(0)
{
}
bool CTB::Read( SvStream &rS )
bool ScCTB::Read( SvStream &rS )
{
OSL_TRACE("CTB::Read() stream pos 0x%x", rS.Tell() );
OSL_TRACE("ScCTB::Read() stream pos 0x%x", rS.Tell() );
nOffSet = rS.Tell();
tb.Read( rS );
for ( sal_uInt16 index = 0; index < nViews; ++index )
......@@ -117,17 +117,17 @@ bool CTB::Read( SvStream &rS )
for ( sal_Int16 index = 0; index < tb.getcCL(); ++index )
{
TBC aTBC;
ScTBC aTBC;
aTBC.Read( rS );
rTBC.push_back( aTBC );
}
return true;
}
void CTB::Print( FILE* fp )
void ScCTB::Print( FILE* fp )
{
Indent a;
indent_printf( fp, "[ 0x%x ] CTB -- dump\n", nOffSet );
indent_printf( fp, "[ 0x%x ] ScCTB -- dump\n", nOffSet );
indent_printf( fp, " nViews 0x%x\n", nViews);
tb.Print( fp );
......@@ -141,25 +141,25 @@ void CTB::Print( FILE* fp )
it->Print( fp );
}
indent_printf( fp, " ectbid 0x%x\n", ectbid);
std::vector<TBC>::iterator it_end = rTBC.end();
std::vector<ScTBC>::iterator it_end = rTBC.end();
counter = 0;
for ( std::vector<TBC>::iterator it = rTBC.begin(); it != it_end; ++it )
for ( std::vector<ScTBC>::iterator it = rTBC.begin(); it != it_end; ++it )
{
indent_printf( fp, " TBC [%d]\n", counter++);
indent_printf( fp, " ScTBC [%d]\n", counter++);
Indent c;
it->Print( fp );
}
}
bool CTB::IsMenuToolbar()
bool ScCTB::IsMenuToolbar()
{
return tb.IsMenuToolbar();
}
bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xMenuDesc, CustomToolBarImportHelper& helper )
bool ScCTB::ImportMenuTB( ScCTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xMenuDesc, CustomToolBarImportHelper& helper )
{
sal_Int32 index = 0;
for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it, ++index )
for ( std::vector< ScTBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it, ++index )
{
if ( !it->ImportToolBarControl( rWrapper, xMenuDesc, helper, IsMenuToolbar() ) )
return false;
......@@ -167,7 +167,7 @@ bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::co
return true;
}
bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
bool ScCTB::ImportCustomToolBar( ScCTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
{
static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
......@@ -186,7 +186,7 @@ bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper&
xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UIName") ), uno::makeAny( name.getString() ) );
rtl::OUString sToolBarName = sToolbarPrefix.concat( name.getString() );
for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
for ( std::vector< ScTBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
{
if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
return false;
......@@ -236,14 +236,14 @@ void CTBS::Print( FILE* fp )
indent_printf( fp, " ictbView 0x%x\n", ictbView );
}
TBC::TBC()
ScTBC::ScTBC()
{
}
bool
TBC::Read(SvStream &rS)
ScTBC::Read(SvStream &rS)
{
OSL_TRACE("TBC::Read() stream pos 0x%x", rS.Tell() );
OSL_TRACE("ScTBC::Read() stream pos 0x%x", rS.Tell() );
nOffSet = rS.Tell();
if ( !tbch.Read( rS ) )
return false;
......@@ -266,10 +266,10 @@ TBC::Read(SvStream &rS)
void
TBC::Print(FILE* fp)
ScTBC::Print(FILE* fp)
{
Indent a;
indent_printf( fp, "[ 0x%x ] TBC -- dump\n", nOffSet );
indent_printf( fp, "[ 0x%x ] ScTBC -- dump\n", nOffSet );
tbch.Print( fp );
if ( tbcCmd.get() )
tbcCmd->Print( fp );
......@@ -277,7 +277,7 @@ TBC::Print(FILE* fp)
tbcd->Print( fp );
}
bool TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuToolbar )
bool ScTBC::ImportToolBarControl( ScCTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuToolbar )
{
// how to identify built-in-command ?
// bool bBuiltin = false;
......@@ -290,11 +290,11 @@ bool TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference<
TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
if ( pMenu )
{
// search for CTB with the appropriate name ( it contains the
// search for ScCTB with the appropriate name ( it contains the
// menu items, although we cannot import ( or create ) a menu on
// a custom toolbar we can import the menu items in a separate
// toolbar ( better than nothing )
CTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
ScCTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
if ( pCustTB )
{
uno::Reference< container::XIndexContainer > xMenuDesc;
......@@ -365,24 +365,24 @@ bool TBCCmd::Read( SvStream &rS )
return true;
}
CTBWrapper::CTBWrapper()
ScCTBWrapper::ScCTBWrapper()
{
}
CTBWrapper::~CTBWrapper()
ScCTBWrapper::~ScCTBWrapper()
{
}
bool
CTBWrapper::Read( SvStream &rS)
ScCTBWrapper::Read( SvStream &rS)
{
OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", rS.Tell() );
OSL_TRACE("ScCTBWrapper::Read() stream pos 0x%x", rS.Tell() );
nOffSet = rS.Tell();
if ( !ctbSet.Read( rS ) )
return false;
for ( sal_uInt16 index = 0; index < ctbSet.ctb; ++index )
{
CTB aCTB( ctbSet.ctbViews );
ScCTB aCTB( ctbSet.ctbViews );
if ( !aCTB.Read( rS ) )
return false;
rCTB.push_back( aCTB );
......@@ -391,23 +391,23 @@ CTBWrapper::Read( SvStream &rS)
}
void
CTBWrapper::Print( FILE* fp )
ScCTBWrapper::Print( FILE* fp )
{
Indent a;
indent_printf( fp, "[ 0x%x ] CTBWrapper -- dump\n", nOffSet );
indent_printf( fp, "[ 0x%x ] ScCTBWrapper -- dump\n", nOffSet );
ctbSet.Print( fp );
std::vector<CTB>::iterator it_end = rCTB.end();
for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
std::vector<ScCTB>::iterator it_end = rCTB.end();
for ( std::vector<ScCTB>::iterator it = rCTB.begin(); it != it_end; ++it )
{
Indent b;
it->Print( fp );
}
}
CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
ScCTB* ScCTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
{
CTB* pCTB = NULL;
for ( std::vector< CTB >::iterator it = rCTB.begin(); it != rCTB.end(); ++it )
ScCTB* pCTB = NULL;
for ( std::vector< ScCTB >::iterator it = rCTB.begin(); it != rCTB.end(); ++it )
{
if ( it->GetName().equals( sTBName ) )
{
......@@ -418,7 +418,7 @@ CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
return pCTB;
}
bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
bool ScCTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
{
if(rCTB.empty())
return true;
......@@ -426,8 +426,8 @@ bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( ui::ModuleUIConfigurationManagerSupplier::create(xContext) );
std::vector<CTB>::iterator it_end = rCTB.end();
for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
std::vector<ScCTB>::iterator it_end = rCTB.end();
for ( std::vector<ScCTB>::iterator it = rCTB.begin(); it != it_end; ++it )
{
// for each customtoolbar
CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ) ) ) );
......
......@@ -35,7 +35,7 @@
namespace css = ::com::sun::star;
class CTBWrapper;
class ScCTBWrapper;
// hmm I don't normally use these packed structures
// but.. hey always good to do something different
class TBCCmd : public TBBase
......@@ -52,36 +52,36 @@ public:
void Print(FILE* fp);
};
class TBC : public TBBase
class ScTBC : public TBBase
{
TBCHeader tbch;
boost::shared_ptr<TBCCmd> tbcCmd; // optional
boost::shared_ptr<TBCData> tbcd;
public:
TBC();
~TBC(){}
ScTBC();
~ScTBC(){}
void Print( FILE* );
bool Read(SvStream &rS);
bool ImportToolBarControl( CTBWrapper&, const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuBar );
bool ImportToolBarControl( ScCTBWrapper&, const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuBar );
};
class CTB : public TBBase
class ScCTB : public TBBase
{
sal_uInt16 nViews;
TB tb;
std::vector<TBVisualData> rVisualData;
sal_uInt32 ectbid;
std::vector< TBC > rTBC;
bool ImportCustomToolBar_Impl( CTBWrapper&, CustomToolBarImportHelper& );
std::vector< ScTBC > rTBC;
bool ImportCustomToolBar_Impl( ScCTBWrapper&, CustomToolBarImportHelper& );
public:
CTB();
CTB(sal_uInt16);
~CTB(){}
ScCTB();
ScCTB(sal_uInt16);
~ScCTB(){}
void Print( FILE* );
bool Read(SvStream &rS);
bool IsMenuToolbar();
bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenuTB( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
bool ImportCustomToolBar( ScCTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenuTB( ScCTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
rtl::OUString GetName() { return tb.getName().getString(); }
......@@ -106,19 +106,19 @@ public:
bool Read(SvStream &rS);
};
class CTBWrapper : public TBBase
class ScCTBWrapper : public TBBase
{
CTBS ctbSet;
std::vector< CTB > rCTB;
std::vector< ScCTB > rCTB;
public:
CTBWrapper();
~CTBWrapper();
ScCTBWrapper();
~ScCTBWrapper();
bool Read(SvStream &rS);
void Print( FILE* );
bool ImportCustomToolBar( SfxObjectShell& rDocSh );
CTB* GetCustomizationData( const rtl::OUString& name );
ScCTB* GetCustomizationData( const rtl::OUString& name );
};
......
......@@ -45,22 +45,22 @@ public:
void Print( FILE* fp );
};
class CTBWrapper;
class TBC : public TBBase
class SwCTBWrapper;
class SwTBC : public TBBase
{
TBCHeader tbch;
boost::shared_ptr< sal_uInt32 > cid; // optional
boost::shared_ptr<TBCData> tbcd;
public:
TBC();
~TBC();
SwTBC();
~SwTBC();
bool Read(SvStream &rS);
void Print( FILE* );
bool ImportToolBarControl( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, bool );
bool ImportToolBarControl( SwCTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, bool );
rtl::OUString GetCustomText();
};
class CTB : public TBBase
class SwCTB : public TBBase
{
Xst name;
sal_Int32 cbTBData;
......@@ -70,18 +70,18 @@ class CTB : public TBBase
sal_uInt16 reserved;
sal_uInt16 unused;
sal_Int32 cCtls;
std::vector< TBC > rTBC;
std::vector< SwTBC > rTBC;
CTB(const CTB&);
CTB& operator = ( const CTB&);
SwCTB(const SwCTB&);
SwCTB& operator = ( const SwCTB&);
public:
CTB();
~CTB();
SwCTB();
~SwCTB();
bool Read(SvStream &rS);
void Print( FILE* fp );
bool IsMenuToolbar();
bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenuTB( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
bool ImportCustomToolBar( SwCTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenuTB( SwCTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
rtl::OUString GetName() { return tb.getName().getString(); }
};
......@@ -124,32 +124,32 @@ public:
bool Read(SvStream &rS);
};
class CTBWrapper;
class SwCTBWrapper;
class Customization : public TBBase
{
friend class CTBWrapper;
friend class SwCTBWrapper;
sal_Int32 tbidForTBD;
sal_uInt16 reserved1;
sal_Int16 ctbds;
CTBWrapper* pWrapper;
boost::shared_ptr< CTB > customizationDataCTB;
SwCTBWrapper* pWrapper;
boost::shared_ptr< SwCTB > customizationDataCTB;
std::vector< TBDelta > customizationDataTBDelta;
bool bIsDroppedMenuTB;
bool ImportMenu( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
bool ImportMenu( SwCTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
public:
Customization( CTBWrapper* rapper );
Customization( SwCTBWrapper* rapper );
~Customization();
bool Read(SvStream &rS);
bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenu( CTBWrapper&, CustomToolBarImportHelper& );
bool ImportCustomToolBar( SwCTBWrapper&, CustomToolBarImportHelper& );
bool ImportMenu( SwCTBWrapper&, CustomToolBarImportHelper& );
void Print( FILE* );
sal_Int32 GetTBIDForTB(){ return tbidForTBD; }
CTB* GetCustomizationData() { return customizationDataCTB.get(); };
SwCTB* GetCustomizationData() { return customizationDataCTB.get(); };
};
class SfxObjectShell;
class CTBWrapper : public Tcg255SubStruct
class SwCTBWrapper : public Tcg255SubStruct
{
// reserved1 is the ch field of Tcg255SubStruct
sal_uInt16 reserved2;
......@@ -162,21 +162,21 @@ class CTBWrapper : public Tcg255SubStruct
sal_Int32 cbDTBC;
std::vector< TBC > rtbdc; //
std::vector< SwTBC > rtbdc; //
std::vector< Customization > rCustomizations; // array of Customizations
std::vector< sal_Int16 > dropDownMenuIndices; // array of indexes of Customization toolbars that are dropped by a menu
CTBWrapper(const CTBWrapper&);
CTBWrapper& operator = ( const CTBWrapper&);
SwCTBWrapper(const SwCTBWrapper&);
SwCTBWrapper& operator = ( const SwCTBWrapper&);
public:
CTBWrapper( bool bReadId = true );
~CTBWrapper();
SwCTBWrapper( bool bReadId = true );
~SwCTBWrapper();
void InsertDropIndex( sal_Int32 aIndex ) { dropDownMenuIndices.push_back( aIndex ); }
TBC* GetTBCAtOffset( sal_uInt32 nStreamOffset );
SwTBC* GetTBCAtOffset( sal_uInt32 nStreamOffset );
bool Read(SvStream &rS);
bool ImportCustomToolBar( SfxObjectShell& rDocSh );
Customization* GetCustomizaton( sal_Int16 index );
CTB* GetCustomizationData( const rtl::OUString& name );
SwCTB* GetCustomizationData( const rtl::OUString& name );
void Print( FILE* );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment