[ooo-build-commit] 2 commits - patches/dev300 patches/vba
Noel Power
noelp at kemper.freedesktop.org
Mon Jul 27 09:15:52 PDT 2009
patches/dev300/apply | 5
patches/vba/tool-menu-bar-improvements.diff | 920 ++++++++++++++++++++++++++++
2 files changed, 925 insertions(+)
New commits:
commit 7a0ddb8577607962148ccc876735dd55ffbad67f
Author: Noel Power <noel.power at novell.com>
Date: Mon Jul 27 16:55:00 2009 +0100
toolbar import fix and improvements
* patches/dev300/apply:
diff --git a/patches/dev300/apply b/patches/dev300/apply
index fde816f..78489a9 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1877,6 +1877,7 @@ vba-workbook-auto-open-event.diff, n#520228, Fong
vba-buildin-toolbar-fix.diff, n#520228, Fong
# support WorkBook.PrecisionAsDisplayed
vba-workbook-precisionasdisplayed.diff, n#520228, Fong
+<<<<<<< HEAD:patches/dev300/apply
# fix for uno api in XMenu::getPopupMenu
uno-xmenu-getpopupMenu-fix.diff, i#103486, Fong
# support CommandbarControl.Enabled
@@ -1887,9 +1888,9 @@ vba-commandbar-document-scope.diff, Fong
vba-dim-as-contants-fix.diff, n#521820, Fong
# fix for set involving an automation object ( in vba mode )
vba-automation-set-fix.diff, n#507501
-# various improvements, handle tooltip, fix bug where toolbar control
-# doesn't appear if the macro isn't found, class for reading toolbar on
-# excel import ( disabled )
+# various improvements, handle tooltip, handle seperators, fix bug where
+# toolbar control isn't displayed if the macro isn't resolved,
+# added classed for excel toolbar import ( disabled )
tool-menu-bar-improvements.diff
[VBAUntested]
SectionOwner => noelpwer
commit 50b0c1f1091ae3bb71f44675ee23607d4ca18ae0
Author: Noel Power <noel.power at novell.com>
Date: Mon Jul 27 16:52:18 2009 +0100
fix broken toolbar import, add support for tooltips and seperators
* patches/dev300/apply:
* patches/vba/tool-menu-bar-improvements.diff: various improvements, handle tooltip, handle seperators, fix bug where toolbar control isn't displayed if the macro isn't resolved, Added classed for excel toolbar import ( disabled )
diff --git a/patches/dev300/apply b/patches/dev300/apply
index a34756f..fde816f 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1887,6 +1887,10 @@ vba-commandbar-document-scope.diff, Fong
vba-dim-as-contants-fix.diff, n#521820, Fong
# fix for set involving an automation object ( in vba mode )
vba-automation-set-fix.diff, n#507501
+# various improvements, handle tooltip, fix bug where toolbar control
+# doesn't appear if the macro isn't found, class for reading toolbar on
+# excel import ( disabled )
+tool-menu-bar-improvements.diff
[VBAUntested]
SectionOwner => noelpwer
# doesn't work
diff --git a/patches/vba/tool-menu-bar-improvements.diff b/patches/vba/tool-menu-bar-improvements.diff
new file mode 100644
index 0000000..88d0f9d
--- /dev/null
+++ b/patches/vba/tool-menu-bar-improvements.diff
@@ -0,0 +1,920 @@
+diff --git framework/source/uielement/toolbarmanager.cxx framework/source/uielement/toolbarmanager.cxx
+index a4de9c1..38d6324 100644
+--- framework/source/uielement/toolbarmanager.cxx
++++ framework/source/uielement/toolbarmanager.cxx
+@@ -122,6 +122,7 @@ namespace framework
+
+ static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
+ static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
++static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip";
+ static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
+ static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
+ static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
+@@ -131,6 +132,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
+
+ static const sal_Int32 ITEM_DESCRIPTOR_COMMANDURL_LEN = 10;
+ static const sal_Int32 ITEM_DESCRIPTOR_HELPURL_LEN = 7;
++static const sal_Int32 ITEM_DESCRIPTOR_TOOLTIP_LEN = 7;
+ static const sal_Int32 ITEM_DESCRIPTOR_CONTAINER_LEN = 23;
+ static const sal_Int32 ITEM_DESCRIPTOR_LABEL_LEN = 5;
+ static const sal_Int32 ITEM_DESCRIPTOR_TYPE_LEN = 4;
+@@ -1250,6 +1252,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
+ rtl::OUString aCommandURL;
+ rtl::OUString aLabel;
+ rtl::OUString aHelpURL;
++ rtl::OUString aTooltip;
+ sal_uInt16 nType( ::com::sun::star::ui::ItemType::DEFAULT );
+ sal_uInt16 nWidth( 0 );
+ sal_Bool bIsVisible( sal_True );
+@@ -1265,6 +1268,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
+ aProp[i].Value >>= aCommandURL;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, ITEM_DESCRIPTOR_HELPURL_LEN ))
+ aProp[i].Value >>= aHelpURL;
++ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TOOLTIP, ITEM_DESCRIPTOR_TOOLTIP_LEN ))
++ aProp[i].Value >>= aTooltip;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, ITEM_DESCRIPTOR_LABEL_LEN ))
+ aProp[i].Value >>= aLabel;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, ITEM_DESCRIPTOR_TYPE_LEN ))
+@@ -1282,9 +1287,13 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
+ ::rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
+
+ sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
++ OSL_TRACE("** style for command url %s is 0x%x", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr(), nItemBits );
+ m_pToolBar->InsertItem( nId, aString, nItemBits );
+ m_pToolBar->SetItemCommand( nId, aCommandURL );
+- m_pToolBar->SetQuickHelpText( nId, aString );
++ if ( aTooltip.getLength() )
++ m_pToolBar->SetQuickHelpText( nId, aTooltip );
++ else
++ m_pToolBar->SetQuickHelpText( nId, aString );
+ if ( aLabel.getLength() > 0 )
+ m_pToolBar->SetItemText( nId, aLabel );
+ else
+diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+index 07394d8..e5eb48a 100644
+--- sc/source/filter/excel/excimp8.cxx
++++ sc/source/filter/excel/excimp8.cxx
+@@ -109,7 +109,7 @@
+
+ #include <com/sun/star/container/XNameContainer.hpp>
+ #include <sfx2/app.hxx>
+-
++#include "xltoolbar.hxx"
+ using namespace com::sun::star;
+
+
+@@ -306,6 +306,21 @@ void ImportExcel8::ReadBasic( void )
+ uno::Any aModel = uno::makeAny( pShell->GetModel() );
+ pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aModel );
+ }
++ // see if we have the XCB stream
++ SvStorageStreamRef xXCB = xRootStrg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "XCB" ) ), STREAM_STD_READ | STREAM_NOCREATE );
++ if ( xXCB.Is()|| SVSTREAM_OK == xXCB->GetError() )
++ {
++#if 0
++ CTBWrapper wrapper;
++ if ( wrapper.Read( xXCB ) )
++ {
++#if DEBUG
++ wrapper.Print( stderr );
++#endif
++ wrapper.ImportCustomToolBar( *pShell );
++ }
++#endif
++ }
+
+ }
+ }
+diff --git sc/source/filter/excel/makefile.mk sc/source/filter/excel/makefile.mk
+index 6ecc0ef..385b552 100644
+--- sc/source/filter/excel/makefile.mk
++++ sc/source/filter/excel/makefile.mk
+@@ -106,7 +106,8 @@ SLOFILES = \
+ $(SLO)$/xlstyle.obj \
+ $(SLO)$/xltools.obj \
+ $(SLO)$/xltracer.obj \
+- $(SLO)$/xlview.obj
++ $(SLO)$/xlview.obj \
++ $(SLO)$/xltoolbar.obj \
+
+ .IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC"
+ NOOPTFILES = \
+@@ -153,7 +154,8 @@ EXCEPTIONSFILES = \
+ $(SLO)$/xlformula.obj \
+ $(SLO)$/xlpivot.obj \
+ $(SLO)$/xlstyle.obj \
+- $(SLO)$/xlview.obj
++ $(SLO)$/xlview.obj \
++ $(SLO)$/xltoolbar.obj \
+
+ # --- Targets -------------------------------------------------------
+
+diff --git sc/source/filter/excel/xltoolbar.cxx sc/source/filter/excel/xltoolbar.cxx
+new file mode 100644
+index 0000000..47b5ee5
+--- /dev/null
++++ sc/source/filter/excel/xltoolbar.cxx
+@@ -0,0 +1,354 @@
++#include "xltoolbar.hxx"
++#include <rtl/ustrbuf.hxx>
++#include <stdarg.h>
++#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
++#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
++#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
++#include <com/sun/star/lang/XMultiServiceFactory.hpp>
++#include <com/sun/star/lang/XSingleComponentFactory.hpp>
++#include <com/sun/star/lang/XMultiComponentFactory.hpp>
++#include <com/sun/star/ui/XImageManager.hpp>
++#include <com/sun/star/ui/ItemType.hpp>
++#include <fstream>
++#include <comphelper/processfactory.hxx>
++#include <vcl/graph.hxx>
++#include <map>
++using namespace com::sun::star;
++
++typedef std::map< sal_Int16, rtl::OUString > IdToString;
++
++class MSOExcelCommandConvertor : public MSOCommandConvertor
++{
++ IdToString msoToOOcmd;
++ IdToString tcidToOOcmd;
++public:
++ MSOExcelCommandConvertor();
++ virtual rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
++ virtual rtl::OUString MSOTCIDToOOCommand( sal_Int16 key );
++};
++
++MSOExcelCommandConvertor::MSOExcelCommandConvertor()
++{
++/*
++ // mso command id to ooo command string
++ // #FIXME and *HUNDREDS* of id's to added here
++ msoToOOcmd[ 0x20b ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc") );
++ msoToOOcmd[ 0x50 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Open") );
++
++ // mso tcid to ooo command string
++ // #FIXME and *HUNDREDS* of id's to added here
++ tcidToOOcmd[ 0x9d9 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Print") );
++*/
++}
++
++rtl::OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
++{
++ rtl::OUString sResult;
++ IdToString::iterator it = msoToOOcmd.find( key );
++ if ( it != msoToOOcmd.end() )
++ sResult = it->second;
++ return sResult;
++}
++
++rtl::OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
++{
++ rtl::OUString sResult;
++ IdToString::iterator it = tcidToOOcmd.find( key );
++ if ( it != tcidToOOcmd.end() )
++ sResult = it->second;
++ return sResult;
++}
++
++
++
++CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3(0), ctb(0), ctbViews(0), ictbView(0)
++{
++}
++
++CTB::CTB() : nViews( 0 ), ectbid(0)
++{
++}
++
++CTB::CTB(sal_uInt16 nNum ) : nViews( nNum ), ectbid(0)
++{
++}
++
++bool CTB::Read( SvStream *pS )
++{
++ OSL_TRACE("CTB::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ tb.Read( pS );
++ for ( sal_uInt16 index = 0; index < nViews; ++index )
++ {
++ TBVisualData aVisData;
++ aVisData.Read( pS );
++ rVisualData.push_back( aVisData );
++ }
++ *pS >> ectbid;
++
++ for ( sal_Int16 index = 0; index < tb.getcCL(); ++index )
++ {
++ TBC aTBC;
++ aTBC.Read( pS );
++ rTBC.push_back( aTBC );
++ }
++ return true;
++}
++
++void CTB::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf( fp, "[ 0x%x ] CTB -- dump\n", nOffSet );
++ indent_printf( fp, " nViews 0x%x\n", nViews);
++ tb.Print( fp );
++
++ std::vector<TBVisualData>::iterator visData_end = rVisualData.end();
++ sal_Int32 counter = 0;
++ for ( std::vector<TBVisualData>::iterator it = rVisualData.begin(); it != visData_end; ++it )
++ {
++
++ indent_printf( fp, " TBVisualData [%d]\n", counter++ );
++ Indent b;
++ it->Print( fp );
++ }
++ indent_printf( fp, " ectbid 0x%x\n", ectbid);
++ std::vector<TBC>::iterator it_end = rTBC.end();
++ counter = 0;
++ for ( std::vector<TBC>::iterator it = rTBC.begin(); it != it_end; ++it )
++ {
++ indent_printf( fp, " TBC [%d]\n", counter++);
++ Indent c;
++ it->Print( fp );
++ }
++}
++
++bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
++{
++ static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
++ if ( !tb.IsEnabled() )
++ return true; // didn't fail, just ignoring
++ // Create default setting
++ uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
++ uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
++ WString& name = tb.getName();
++ // set UI name for toolbar
++ 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 )
++ {
++ // createToolBar item for control
++ if ( !it->ImportToolBarControl( xIndexContainer, helper ) )
++ return false;
++ }
++
++ OSL_TRACE("Name of toolbar :-/ %s", rtl::OUStringToOString( sToolBarName, RTL_TEXTENCODING_UTF8 ).getStr() );
++
++ helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
++ helper.applyIcons();
++
++ uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
++ xPersistence->store();
++
++ xPersistence.set( helper.getCfgManager(), uno::UNO_QUERY_THROW );
++ xPersistence->store();
++
++ return true;
++}
++bool CTBS::Read( SvStream *pS )
++{
++ OSL_TRACE("CTBS::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ *pS >> bSignature >> bVersion >> reserved1 >> reserved2 >> reserved3 >> ctb >> ctbViews >> ictbView;
++ return true;
++}
++
++void CTBS::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf( fp, "[ 0x%x ] CTBS -- dump\n", nOffSet );
++
++ indent_printf( fp, " bSignature 0x%x\n", bSignature);
++ indent_printf( fp, " bVersion 0x%x\n", bVersion);
++
++ indent_printf( fp, " reserved1 0x%x\n", reserved1 );
++ indent_printf( fp, " reserved2 0x%x\n", reserved2 );
++ indent_printf( fp, " reserved3 0x%x\n", reserved3 );
++
++ indent_printf( fp, " ctb 0x%x\n", ctb );
++ indent_printf( fp, " ctbViews 0x%x\n", ctbViews );
++ indent_printf( fp, " ictbView 0x%x\n", ictbView );
++}
++
++TBC::TBC()
++{
++}
++
++bool
++TBC::Read(SvStream *pS)
++{
++ OSL_TRACE("TBC::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ if ( !tbch.Read( pS ) )
++ return false;
++ sal_uInt16 tcid = tbch.getTcID();
++ sal_uInt8 tct = tbch.getTct();
++ if ( ( tcid != 0x0001 && tcid != 0x06CC && tcid != 0x03D8 && tcid != 0x03EC && tcid != 0x1051 ) && ( ( tct > 0 && tct < 0x0B ) || ( ( tct > 0x0B && tct < 0x10 ) || tct == 0x15 ) ) )
++ {
++ tbcCmd.reset( new TBCCmd );
++ if ( ! tbcCmd->Read( pS ) )
++ return false;
++ }
++ if ( tct != 0x16 )
++ {
++ tbcd.reset( new TBCData( tbch ) );
++ if ( !tbcd->Read( pS ) )
++ return false;
++ }
++ return true;
++}
++
++
++void
++TBC::Print(FILE* fp)
++{
++ Indent a;
++ indent_printf( fp, "[ 0x%x ] TBC -- dump\n", nOffSet );
++ tbch.Print( fp );
++ if ( tbcCmd.get() )
++ tbcCmd->Print( fp );
++ if ( tbcd.get() )
++ tbcd->Print( fp );
++}
++
++bool TBC::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper )
++{
++ // how to identify built-in-command ?
++// bool bBuiltin = false;
++ if ( tbcd.get() )
++ {
++ std::vector< css::beans::PropertyValue > props;
++/*
++ if ( bBuiltin )
++ {
++ rtl::OUString sCommand = helper.MSOCommandToOOCommand( cmdId );
++ if ( sCommand.getLength() > 0 )
++ {
++ beans::PropertyValue aProp;
++
++ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") );
++ aProp.Value <<= sCommand;
++ props.push_back( aProp );
++ }
++
++ }
++*/
++ bool bBeginGroup = false;
++ if ( ! tbcd->ImportToolBarControl( toolbarcontainer, helper, props, bBeginGroup ) )
++ return false;
++
++ if ( bBeginGroup )
++ {
++ // insert spacer
++ uno::Sequence< beans::PropertyValue > sProps( 1 );
++ sProps[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Type") );
++ sProps[ 0 ].Value = uno::makeAny( ui::ItemType::SEPARATOR_LINE );
++ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
++ }
++ uno::Sequence< beans::PropertyValue > sProps( props.size() );
++ beans::PropertyValue* pProp = sProps.getArray();
++
++ for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it, ++pProp )
++ *pProp = *it;
++
++ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
++ }
++ return true;
++}
++
++void
++TBCCmd::Print(FILE* fp)
++{
++ Indent a;
++ indent_printf( fp, " TBCCmd -- dump\n" );
++ indent_printf( fp, " cmdID 0x%x\n", cmdID );
++ indent_printf( fp, " A ( fHideDrawing ) %s\n", A ? "true" : "false" );
++ indent_printf( fp, " B ( reserved - ignored ) %s\n", A ? "true" : "false" );
++ indent_printf( fp, " cmdType 0x%x\n", cmdType );
++ indent_printf( fp, " C ( reserved - ignored ) %s\n", A ? "true" : "false" );
++ indent_printf( fp, " reserved3 0x%x\n", reserved3 );
++}
++
++bool TBCCmd::Read( SvStream *pS )
++{
++ OSL_TRACE("TBCCmd::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ *pS >> cmdID;
++ sal_uInt16 temp;
++ *pS >> temp;
++ OSL_TRACE("TBCmd temp = 0x%x", temp );
++ A = (temp & 0x8000 ) == 0x8000;
++ B = (temp & 0x4000) == 0x4000;
++ cmdType = ( temp & 0x3E00 ) >> 9;
++ C = ( temp & 0x100 ) == 0x100;
++ reserved3 = ( temp & 0xFF );
++ return true;
++}
++
++CTBWrapper::CTBWrapper()
++{
++}
++
++CTBWrapper::~CTBWrapper()
++{
++}
++
++bool
++CTBWrapper::Read( SvStream *pS)
++{
++ OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ if ( !ctbSet.Read( pS ) )
++ return false;
++ for ( sal_uInt16 index = 0; index < ctbSet.ctb; ++index )
++ {
++ CTB aCTB( ctbSet.ctbViews );
++ if ( !aCTB.Read( pS ) )
++ return false;
++ rCTB.push_back( aCTB );
++ }
++ return true;
++}
++
++void
++CTBWrapper::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf( fp, "[ 0x%x ] CTBWrapper -- 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 )
++ {
++ Indent b;
++ it->Print( fp );
++ }
++}
++
++bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
++{
++ std::vector<CTB>::iterator it_end = rCTB.end();
++ for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
++ {
++ // for each customtoolbar
++ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++ uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW );
++ CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ) ) ) );
++ helper.setMSOCommandMap( new MSOExcelCommandConvertor() );
++ if ( !(*it).ImportCustomToolBar( helper ) )
++ return false;
++ }
++ return true;
++}
++
++
+diff --git sc/source/filter/excel/xltoolbar.hxx sc/source/filter/excel/xltoolbar.hxx
+new file mode 100644
+index 0000000..af986c7
+--- /dev/null
++++ sc/source/filter/excel/xltoolbar.hxx
+@@ -0,0 +1,87 @@
++#ifndef _XLTOOLBAR_HXX
++#define _XLTOOLBAR_HXX
++
++#include <svx/mstoolbar.hxx>
++
++namespace css = ::com::sun::star;
++
++// hmm I don't normally use these packed structures
++// but.. hey always good to do something different
++class TBCCmd : public TBBase
++{
++public:
++ TBCCmd() : cmdID(0), A(0), B(0), cmdType(0), C(0), reserved3(0) {}
++ sal_uInt16 cmdID;
++ sal_uInt16 A:1;
++ sal_uInt16 B:1;
++ sal_uInt16 cmdType:5;
++ sal_uInt16 C:1;
++ sal_uInt16 reserved3:8;
++ bool Read( SvStream* pS );
++ void Print(FILE* fp);
++};
++
++class TBC : public TBBase
++{
++ TBCHeader tbch;
++ boost::shared_ptr<TBCCmd> tbcCmd; // optional
++ boost::shared_ptr<TBCData> tbcd;
++public:
++ TBC();
++ ~TBC(){}
++ void Print( FILE* );
++ bool Read(SvStream *pS);
++ bool ImportToolBarControl( const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper );
++};
++
++class CTB : public TBBase
++{
++ sal_uInt16 nViews;
++ TB tb;
++ std::vector<TBVisualData> rVisualData;
++ sal_uInt32 ectbid;
++ std::vector< TBC > rTBC;
++public:
++ CTB();
++ CTB(sal_uInt16);
++ ~CTB(){}
++ void Print( FILE* );
++ bool Read(SvStream *pS);
++ bool ImportCustomToolBar( CustomToolBarImportHelper& );
++};
++
++class CTBS : public TBBase
++{
++public:
++ sal_uInt8 bSignature;
++ sal_uInt8 bVersion;
++ sal_uInt16 reserved1;
++ sal_uInt16 reserved2;
++ sal_uInt16 reserved3;
++ sal_uInt16 ctb;
++ sal_uInt16 ctbViews;
++ sal_uInt16 ictbView;
++ CTBS(const CTBS&);
++ CTBS& operator = ( const CTBS&);
++ CTBS();
++ ~CTBS(){}
++ void Print( FILE* );
++ bool Read(SvStream *pS);
++};
++
++class CTBWrapper : public TBBase
++{
++ CTBS ctbSet;
++
++ std::vector< CTB > rCTB;
++
++public:
++ CTBWrapper();
++ ~CTBWrapper();
++ bool Read(SvStream *pS);
++ void Print( FILE* );
++ bool ImportCustomToolBar( SfxObjectShell& rDocSh );
++};
++
++
++#endif //_XLTOOLBAR_HXX
+diff --git svx/inc/svx/mstoolbar.hxx svx/inc/svx/mstoolbar.hxx
+index 5d76eaf..2772f23 100644
+--- svx/inc/svx/mstoolbar.hxx
++++ svx/inc/svx/mstoolbar.hxx
+@@ -250,6 +250,7 @@ public:
+ sal_uInt8 getTct() const { return tct; }
+ sal_uInt16 getTcID() const { return tcid; }
+ bool isVisible() { return !( bFlagsTCR & 0x1 ); }
++ bool isBeginGroup() { return ( bFlagsTCR & 0x2 ); }
+ bool Read(SvStream *pS);
+ void Print( FILE* );
+ sal_uInt32 getTbct() { return tbct; };
+@@ -267,8 +268,56 @@ public:
+ ~TBCData(){}
+ bool Read(SvStream *pS);
+ void Print( FILE* );
+- bool ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >& );
++ bool ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup );
+ TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
+ };
+
++class SVX_DLLPUBLIC TB : public TBBase
++{
++ sal_uInt8 bSignature;// Signed integer that specifies the toolbar signature number. MUST be 0x02.
++ sal_uInt8 bVersion; // Signed integer that specifies the toolbar version number. MUST be 0x01.
++ sal_Int16 cCL; // Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
++ sal_Int32 ltbid;// Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
++ sal_uInt32 ltbtr;// Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
++ sal_uInt16 cRowsDefault;// Unsigned integer that specifies the number of preferred rows for the toolbar when the toolbar is not docked. MUST be less than or equal to 255.
++ sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
++ WString name; //Structure of type WString that specifies the toolbar name
++public:
++ TB();
++ ~TB(){}
++ bool Read(SvStream *pS);
++ void Print( FILE* );
++ sal_Int16 getcCL(){ return cCL; }
++ WString& getName(){ return name; }
++ bool IsEnabled();
++};
++
++class SVX_DLLPUBLIC SRECT : public TBBase
++{
++public:
++ SRECT() : left(0), top(0), right(0), bottom(0) {}
++ sal_Int16 left;
++ sal_Int16 top;
++ sal_Int16 right;
++ sal_Int16 bottom;
++ bool Read( SvStream* pS ) { *pS >> left >> top >> right >> bottom; return true; }
++ void Print( FILE* fo );
++};
++
++class SVX_DLLPUBLIC TBVisualData : public TBBase
++{
++ sal_Int8 tbds;
++ sal_Int8 tbv;
++ sal_Int8 tbdsDock;
++ sal_Int8 iRow;
++
++ SRECT rcDock;
++ SRECT rcFloat;
++
++public:
++ TBVisualData();
++ ~TBVisualData(){}
++ bool Read(SvStream *pS);
++ void Print( FILE* );
++};
+ #endif
+diff --git svx/source/msfilter/mstoolbar.cxx svx/source/msfilter/mstoolbar.cxx
+index fa66fe5..8c3934a 100644
+--- svx/source/msfilter/mstoolbar.cxx
++++ svx/source/msfilter/mstoolbar.cxx
+@@ -25,7 +25,7 @@ void CustomToolBarImportHelper::applyIcons()
+ commands[ 0 ] = it->sCommand;
+ uno::Sequence< uno::Reference< graphic::XGraphic > > images(1);
+ images[ 0 ] = it->image;
+-
++ OSL_TRACE("About to applyIcons for command %s, have image ? %s", rtl::OUStringToOString( commands[ 0 ], RTL_TEXTENCODING_UTF8 ).getStr(), images[ 0 ].is() ? "yes" : "no" );
+ 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 )
+@@ -144,7 +144,7 @@ void TBCHeader::Print( FILE* fp )
+ {
+ Indent a;
+ indent_printf(fp,"[ 0x%x ] TBCHeader -- dump\n", nOffSet );
+- indent_printf(fp," bSignature 0x%xn", bSignature );
++ indent_printf(fp," bSignature 0x%x\n", bSignature );
+ indent_printf(fp," bVersion 0x%x\n", bVersion );
+ indent_printf(fp," bFlagsTCR 0x%x\n", bFlagsTCR );
+ indent_printf(fp," tct 0x%x\n", tct );
+@@ -192,14 +192,13 @@ bool TBCData::Read(SvStream *pS)
+ }
+ if ( controlSpecificInfo.get() )
+ return controlSpecificInfo->Read( pS );
++ //#FIXME I need to be able to handle different controlSpecificInfo types.
+ return true;
+-
+- OSL_TRACE("#FIXME I need to be able to handle different controlSpecificInfo types.");
+- return false;
+ }
+
+-bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& /*toolbarcontainer*/, CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props )
++bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& /*toolbarcontainer*/, CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup )
+ {
++ bBeginGroup = rHeader.isBeginGroup();
+ controlGeneralInfo.ImportToolBarControlData( helper, props );
+ beans::PropertyValue aProp;
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Visible") ) ;
+@@ -222,16 +221,19 @@ bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::X
+ }
+ if ( TBCBitMap* pIcon = pSpecificInfo->getIcon() )
+ {
+-
+- BitmapEx aBitEx( pIcon->getBitMap() );
+- if ( pSpecificInfo->getIconMask() )
+- // according to the spec:
+- // "the iconMask is white in all the areas in which the icon is
+- // displayed as transparent and is black in all other areas."
+- aBitEx = BitmapEx( aBitEx.GetBitmap(), pSpecificInfo->getIconMask()->getBitMap().CreateMask( Color( COL_WHITE ) ) );
+-
+- Graphic aGraphic( aBitEx );
+- helper.addIcon( aGraphic.GetXGraphic(), sCommand );
++ // Without a command openoffice won't display the icon
++ if ( sCommand.getLength() )
++ {
++ BitmapEx aBitEx( pIcon->getBitMap() );
++ if ( pSpecificInfo->getIconMask() )
++ // according to the spec:
++ // "the iconMask is white in all the areas in which the icon is
++ // displayed as transparent and is black in all other areas."
++ aBitEx = BitmapEx( aBitEx.GetBitmap(), pSpecificInfo->getIconMask()->getBitMap().CreateMask( Color( COL_WHITE ) ) );
++
++ Graphic aGraphic( aBitEx );
++ helper.addIcon( aGraphic.GetXGraphic(), sCommand );
++ }
+ }
+ else if ( pSpecificInfo->getBtnFace() )
+ {
+@@ -373,6 +375,8 @@ TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std
+ ooo::vba::VBAMacroResolvedInfo aMacroInf = ooo::vba::resolveVBAMacro( &helper.GetDocShell(), extraInfo.getOnAction(), true );
+ if ( aMacroInf.IsResolved() )
+ aProp.Value = helper.createCommandFromMacro( aMacroInf.ResolvedMacro() );
++ else
++ aProp.Value <<= rtl::OUString::createFromAscii("UnResolvedMacro[").concat( extraInfo.getOnAction() ).concat( rtl::OUString::createFromAscii("]") );
+ sControlData.push_back( aProp );
+ }
+
+@@ -384,7 +388,7 @@ TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std
+ aProp.Value = uno::makeAny( ui::ItemType::DEFAULT );
+ sControlData.push_back( aProp );
+
+- aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") );
++ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Tooltip") );
+ aProp.Value = uno::makeAny( tooltip.getString() );
+ sControlData.push_back( aProp );
+
+@@ -429,7 +433,7 @@ TBCMenuSpecific::Print( FILE* fp )
+ 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() );
++ indent_printf( fp, " name %s\n", rtl::OUStringToOString( name->getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ }
+
+@@ -611,3 +615,79 @@ void TBCBitMap::Print( FILE* fp )
+ 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 ) );
+ }
++
++TB::TB() : bSignature(0x2),
++bVersion(0x1),
++cCL(0),
++ltbid( 0x1 ),
++ltbtr(0),
++cRowsDefault( 0 ),
++bFlags( 0 )
++{
++}
++
++bool TB::Read(SvStream *pS)
++{
++ OSL_TRACE("TB::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ *pS >> bSignature >> bVersion >> cCL >> ltbid >> ltbtr >> cRowsDefault >> bFlags;
++ name.Read( pS );
++ return true;
++
++}
++
++bool TB::IsEnabled()
++{
++ //return ( bFlags & 0x10 ) != 0x10;
++ return ( bFlags & 0x01 ) != 0x01;
++}
++
++void TB::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf(fp,"[ 0x%x ] TB -- dump\n", nOffSet );
++ indent_printf(fp," bSignature 0x%x\n", bSignature );
++ indent_printf(fp," bVersion 0x%x\n", bVersion );
++ indent_printf(fp," cCL 0x%x\n", cCL );
++ indent_printf(fp," ltbid 0x%x\n", ltbid );
++ indent_printf(fp," ltbtr 0x%x\n", ltbtr );
++ indent_printf(fp," cRowsDefault 0x%x\n", cRowsDefault );
++ indent_printf(fp," bFlags 0x%x\n", bFlags );
++ indent_printf(fp, " name %s\n", rtl::OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr() );
++}
++
++TBVisualData::TBVisualData() : tbds(0), tbv(0), tbdsDock(0), iRow(0)
++{
++}
++
++bool TBVisualData::Read( SvStream* pS )
++{
++ OSL_TRACE("TBVisualData::Read() stream pos 0x%x", pS->Tell() );
++ nOffSet = pS->Tell();
++ *pS >> tbds >> tbv >> tbdsDock >> iRow;
++ rcDock.Read( pS );
++ rcFloat.Read( pS );
++ return true;
++}
++
++void SRECT::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf( fp, " left 0x%x\n", left);
++ indent_printf( fp, " top 0x%x\n", top);
++ indent_printf( fp, " right 0x%x\n", right);
++ indent_printf( fp, " bottom 0x%x\n", bottom);
++}
++
++void TBVisualData::Print( FILE* fp )
++{
++ Indent a;
++ indent_printf( fp, "[ 0x%x ] TBVisualData -- dump\n", nOffSet );
++ indent_printf( fp, " tbds 0x%x\n", tbds);
++ indent_printf( fp, " tbv 0x%x\n", tbv);
++ indent_printf( fp, " tbdsDoc 0x%x\n", tbdsDock);
++ indent_printf( fp, " iRow 0x%x\n", iRow);
++ rcDock.Print( fp );
++ rcFloat.Print( fp );
++}
++
+diff --git sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par.cxx
+index 21a8014..a8a1348 100644
+--- sw/source/filter/ww8/ww8par.cxx
++++ sw/source/filter/ww8/ww8par.cxx
+@@ -3890,7 +3890,7 @@ bool WW8Customizations::Import( SwDocShell* pShell )
+ if (!aTCG.Read( mpTableStream ) )
+ OSL_TRACE("** Read of Customization data failed!!!! ");
+ mpTableStream->Seek( nCur ); // return to previous position, is that necessary?
+-#if 1
++#if DEBUG
+ aTCG.Print( stderr );
+ #endif
+ return aTCG.ImportCustomToolBar( *pShell );
+diff --git sw/source/filter/ww8/ww8toolbar.cxx sw/source/filter/ww8/ww8toolbar.cxx
+index bb3fc2e..22ab038 100644
+--- sw/source/filter/ww8/ww8toolbar.cxx
++++ sw/source/filter/ww8/ww8toolbar.cxx
+@@ -525,38 +525,6 @@ bool CTB::ImportMenu( const css::uno::Reference< css::container::XIndexContainer
+ return true;
+ }
+
+-TB::TB() : bSignature( 0 )
+-,bVersion( 0 )
+-,cCL( 0 )
+-,ltbid( 0 )
+-,ltbtr( 0 )
+-,cRowsDefault( 0 )
+-,bFlags( 0 )
+-{
+-}
+-
+-bool TB::Read( SvStream* 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 );
+-}
+-
+-bool TB::IsEnabled()
+-{
+- return ( bFlags & 0x10 ) != 0x10;
+-}
+-
+-void TB::Print( FILE* fp )
+-{
+- Indent a;
+- 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 state - %s\n", rtl::OUStringToOString( name.getString(), RTL_TEXTENCODING_UTF8 ).getStr(), IsEnabled() ? "true" : "false" );
+-
+-}
+-
+ TBC::TBC()
+ {
+ }
+@@ -655,10 +623,19 @@ TBC::ImportToolBarControl( const css::uno::Reference< css::container::XIndexCont
+ }
+
+ }
+- if ( ! tbcd->ImportToolBarControl( toolbarcontainer, helper, props ) )
++ bool bBeginGroup = false;
++ if ( ! tbcd->ImportToolBarControl( toolbarcontainer, helper, props, bBeginGroup ) )
+ return false;
+
+-
++ if ( bBeginGroup )
++ {
++ // insert spacer
++ uno::Sequence< beans::PropertyValue > sProps( 1 );
++ sProps[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Type") );
++ sProps[ 0 ].Value = uno::makeAny( ui::ItemType::SEPARATOR_LINE );
++ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
++ }
++
+ uno::Sequence< beans::PropertyValue > sProps( props.size() );
+ beans::PropertyValue* pProp = sProps.getArray();
+
+diff --git sw/source/filter/ww8/ww8toolbar.hxx sw/source/filter/ww8/ww8toolbar.hxx
+index ae23835..b533cbf 100644
+--- sw/source/filter/ww8/ww8toolbar.hxx
++++ sw/source/filter/ww8/ww8toolbar.hxx
+@@ -29,26 +29,6 @@ public:
+ rtl::OUString GetCustomText();
+ };
+
+-class TB : public TBBase
+-{
+- sal_Int8 bSignature; //Signed integer that specifies the toolbar signature number. MUST be 0x02.
+- sal_Int8 bVersion; //Signed integer that specifies the toolbar version number. MUST be 0x01.
+- sal_Int16 cCL; //Signed integer that SHOULD specify the number of toolbar controls contained in this toolbar.
+- sal_Int32 ltbid; //Signed integer that specifies the toolbar ID. MUST be 0x0001 (custom toolbar ID).
+- sal_uInt32 ltbtr; //Unsigned integer of type TBTRFlags that specifies the toolbar type and toolbar restrictions.
+- sal_uInt16 cRowsDefault; //Unsigned integer that specifies the number of preferred rows for the toolbar when the toolbar is not docked. MUST be less than or equal to 255.
+- sal_uInt16 bFlags; //Unsigned integer of type TBFlags.
+- WString name; //Structure of type WString that specifies the toolbar name.
+- TB(const TB&);
+- TB& operator = ( const TB&);
+-public:
+- TB();
+- ~TB(){}
+- bool Read(SvStream *pS);
+- void Print( FILE* );
+- bool IsEnabled();
+-};
+-
+ class CTB : public TBBase
+ {
+ Xst name;
More information about the ooo-build-commit
mailing list