11 #include <com/sun/star/beans/XPropertySet.hpp>
12 #include <com/sun/star/document/IndexedPropertyValues.hpp>
13 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
14 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
15 #include <com/sun/star/ui/ItemType.hpp>
31 MSOExcelCommandConvertor();
32 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd )
override;
33 virtual OUString MSOTCIDToOOCommand( sal_Int16 key )
override;
38 MSOExcelCommandConvertor::MSOExcelCommandConvertor()
52 OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
55 IdToString::iterator it = msoToOOcmd.find( key );
56 if ( it != msoToOOcmd.end() )
61 OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
64 IdToString::iterator it = tcidToOOcmd.find( key );
65 if ( it != tcidToOOcmd.end() )
70 CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3(0), ctb(0), ctbViews(0), ictbView(0)
95 rTBC.push_back( aTBC );
100 #ifdef DEBUG_SC_EXCEL
101 void ScCTB::Print( FILE* fp )
104 indent_printf( fp,
"[ 0x%x ] ScCTB -- dump\n",
nOffSet );
105 indent_printf( fp,
" nViews 0x%x\n",
nViews);
108 sal_Int32 counter = 0;
111 indent_printf( fp,
" TBVisualData [%d]\n", counter++ );
115 indent_printf( fp,
" ectbid 0x%x\n",
ectbid);
117 for (
auto& rItem :
rTBC )
119 indent_printf( fp,
" ScTBC [%d]\n", counter++);
133 for (
auto& rItem : rTBC )
135 if ( !rItem.ImportToolBarControl( rWrapper, xMenuDesc, helper,
IsMenuToolbar() ) )
151 uno::Reference< container::XIndexContainer > xIndexContainer( helper.
getCfgManager()->createSettings(), uno::UNO_SET_THROW );
152 uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
153 uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
156 xProps->setPropertyValue(
"UIName", uno::makeAny( name.
getString() ) );
158 OUString sToolBarName =
"private:resource/toolbar/custom_" + name.
getString();
159 for (
auto& rItem : rTBC )
161 if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, helper,
IsMenuToolbar() ) )
165 helper.
getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
168 uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.
getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
169 xPersistence->store();
171 xPersistence.set( helper.
getCfgManager(), uno::UNO_QUERY_THROW );
172 xPersistence->store();
176 catch( uno::Exception& )
190 #ifdef DEBUG_SC_EXCEL
191 void CTBS::Print( FILE* fp )
194 indent_printf( fp,
"[ 0x%x ] CTBS -- dump\n",
nOffSet );
196 indent_printf( fp,
" bSignature 0x%x\n",
bSignature);
197 indent_printf( fp,
" bVersion 0x%x\n",
bVersion);
199 indent_printf( fp,
" reserved1 0x%x\n",
reserved1 );
200 indent_printf( fp,
" reserved2 0x%x\n",
reserved2 );
201 indent_printf( fp,
" reserved3 0x%x\n",
reserved3 );
203 indent_printf( fp,
" ctb 0x%x\n",
ctb );
204 indent_printf( fp,
" ctbViews 0x%x\n",
ctbViews );
205 indent_printf( fp,
" ictbView 0x%x\n",
ictbView );
222 if ( ( tcid != 0x0001 && tcid != 0x06CC && tcid != 0x03D8 && tcid != 0x03EC && tcid != 0x1051 ) && ( ( tct > 0 && tct < 0x0B ) || ( ( tct > 0x0B && tct < 0x10 ) || tct == 0x15 ) ) )
224 tbcCmd = std::make_shared<TBCCmd>();
225 if ( !
tbcCmd->Read( rS ) )
230 tbcd = std::make_shared<TBCData>(
tbch );
231 if ( !
tbcd->Read( rS ) )
237 #ifdef DEBUG_SC_EXCEL
239 ScTBC::Print(FILE* fp)
242 indent_printf( fp,
"[ 0x%x ] ScTBC -- dump\n",
nOffSet );
257 std::vector< css::beans::PropertyValue >
props;
258 bool bBeginGroup =
false;
259 tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuToolbar );
271 if ( !pCustTB->
ImportMenuTB( rWrapper, xMenuDesc, helper ) )
273 if ( !bIsMenuToolbar )
280 beans::PropertyValue aProp;
281 aProp.Name =
"ItemDescriptorContainer";
282 aProp.Value <<= xMenuDesc;
283 props.push_back( aProp );
291 uno::Sequence< beans::PropertyValue > sProps( 1 );
292 sProps[ 0 ].Name =
"Type";
293 sProps[ 0 ].Value <<= ui::ItemType::SEPARATOR_LINE;
294 toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
301 #ifdef DEBUG_SC_EXCEL
303 TBCCmd::Print(FILE* fp)
306 indent_printf( fp,
" TBCCmd -- dump\n" );
307 indent_printf( fp,
" cmdID 0x%x\n",
cmdID );
308 indent_printf( fp,
" A ( fHideDrawing ) %s\n",
A ?
"true" :
"false" );
309 indent_printf( fp,
" B ( reserved - ignored ) %s\n",
A ?
"true" :
"false" );
310 indent_printf( fp,
" cmdType 0x%x\n",
cmdType );
311 indent_printf( fp,
" C ( reserved - ignored ) %s\n",
A ?
"true" :
"false" );
312 indent_printf( fp,
" reserved3 0x%x\n",
reserved3 );
323 A = (temp & 0x8000 ) == 0x8000;
324 B = (temp & 0x4000) == 0x4000;
325 cmdType = ( temp & 0x3E00 ) >> 9;
326 C = ( temp & 0x100 ) == 0x100;
357 const size_t nMaxPossibleRecords = rS.
remainingSize()/nMinRecordSize;
364 if ( !aCTB.
Read( rS ) )
366 rCTB.push_back( aCTB );
371 #ifdef DEBUG_SC_EXCEL
373 ScCTBWrapper::Print( FILE* fp )
376 indent_printf( fp,
"[ 0x%x ] ScCTBWrapper -- dump\n",
nOffSet );
378 for (
auto& rItem :
rCTB )
388 ScCTB* pCTB =
nullptr;
389 auto it = std::find_if(rCTB.begin(), rCTB.end(), [&sTBName](
ScCTB& rItem) {
return rItem.GetName() == sTBName; });
390 if (it != rCTB.end())
401 uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( ui::theModuleUIConfigurationManagerSupplier::get(xContext) );
403 for (
auto& rItem : rCTB )
407 helper.setMSOCommandMap(
new MSOExcelCommandConvertor() );
413 if ( !rItem.IsMenuToolbar() && !rItem.ImportCustomToolBar( *
this,
helper ) )
bool Read(SvStream &rS) override
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
bool IsMenuToolbar() const
std::vector< TBVisualData > rVisualData
bool ImportToolBarControl(ScCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &toolbarcontainer, CustomToolBarImportHelper &helper, bool bIsMenuBar)
void ImportCustomToolBar(SfxObjectShell &rDocSh)
sal_uInt64 remainingSize()
std::shared_ptr< TBCData > tbcd
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
std::vector< ScCTB > rCTB
bool Read(SvStream &rS) override
ScCTB * GetCustomizationData(const OUString &name)
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
bool ImportCustomToolBar(ScCTBWrapper &, CustomToolBarImportHelper &)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
SvStream & ReadUChar(unsigned char &rChar)
std::vector< ScTBC > rTBC
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
virtual ~ScCTBWrapper() override
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
const OUString & getString() const
std::shared_ptr< TBCCmd > tbcCmd
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool ImportMenuTB(ScCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &)