12#include <com/sun/star/beans/XPropertySet.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>
34 MSOExcelCommandConvertor();
41MSOExcelCommandConvertor::MSOExcelCommandConvertor()
55OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
58 IdToString::iterator it = msoToOOcmd.find( key );
59 if ( it != msoToOOcmd.end() )
64OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
67 IdToString::iterator it = tcidToOOcmd.find( key );
68 if ( it != tcidToOOcmd.end() )
73CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3(0), ctb(0), ctbViews(0), ictbView(0)
88 const size_t nMinRecordSize = 20;
89 const size_t nMaxPossibleRecords = rS.
remainingSize() / nMinRecordSize;
90 if (
nViews > nMaxPossibleRecords)
92 SAL_WARN(
"sc.filter",
"ScCTB::Read more entries claimed than stream could contain");
110 const size_t nMinRecordSize = 11;
111 const size_t nMaxPossibleRecords = rS.
remainingSize() / nMinRecordSize;
112 if (nIndexes > nMaxPossibleRecords)
114 SAL_WARN(
"sc.filter",
"ScCTB::Read more entries claimed than stream could contain");
122 rTBC.push_back( aTBC );
130void ScCTB::Print( FILE* fp )
133 indent_printf( fp,
"[ 0x%x ] ScCTB -- dump\n",
nOffSet );
134 indent_printf( fp,
" nViews 0x%x\n",
nViews);
137 sal_Int32 counter = 0;
140 indent_printf( fp,
" TBVisualData [%d]\n", counter++ );
144 indent_printf( fp,
" ectbid 0x%x\n",
ectbid);
146 for (
auto& rItem :
rTBC )
148 indent_printf( fp,
" ScTBC [%d]\n", counter++);
162 for (
auto& rItem :
rTBC )
180 uno::Reference< container::XIndexContainer > xIndexContainer(
helper.getCfgManager()->createSettings(), uno::UNO_SET_THROW );
181 uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
182 uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
185 xProps->setPropertyValue(
"UIName",
uno::Any(
name.getString() ) );
187 OUString sToolBarName =
"private:resource/toolbar/custom_" +
name.getString();
188 for (
auto& rItem :
rTBC )
194 helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
197 uno::Reference< ui::XUIConfigurationPersistence > xPersistence(
helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
198 xPersistence->store();
200 xPersistence.set(
helper.getCfgManager(), uno::UNO_QUERY_THROW );
201 xPersistence->store();
205 catch( uno::Exception& )
220void CTBS::Print( FILE* fp )
223 indent_printf( fp,
"[ 0x%x ] CTBS -- dump\n",
nOffSet );
225 indent_printf( fp,
" bSignature 0x%x\n",
bSignature);
226 indent_printf( fp,
" bVersion 0x%x\n",
bVersion);
228 indent_printf( fp,
" reserved1 0x%x\n",
reserved1 );
229 indent_printf( fp,
" reserved2 0x%x\n",
reserved2 );
230 indent_printf( fp,
" reserved3 0x%x\n",
reserved3 );
232 indent_printf( fp,
" ctb 0x%x\n",
ctb );
233 indent_printf( fp,
" ctbViews 0x%x\n",
ctbViews );
234 indent_printf( fp,
" ictbView 0x%x\n",
ictbView );
251 if ( ( tcid != 0x0001 && tcid != 0x06CC && tcid != 0x03D8 && tcid != 0x03EC && tcid != 0x1051 ) && ( ( tct > 0 && tct < 0x0B ) || ( ( tct > 0x0B && tct < 0x10 ) || tct == 0x15 ) ) )
253 tbcCmd = std::make_shared<TBCCmd>();
254 if ( !
tbcCmd->Read( rS ) )
259 tbcd = std::make_shared<TBCData>(
tbch );
260 if ( !
tbcd->Read( rS ) )
268ScTBC::Print(FILE* fp)
271 indent_printf( fp,
"[ 0x%x ] ScTBC -- dump\n",
nOffSet );
286 std::vector< css::beans::PropertyValue >
props;
287 bool bBeginGroup =
false;
288 tbcd->ImportToolBarControl(
helper,
props, bBeginGroup, bIsMenuToolbar );
302 if ( !bIsMenuToolbar )
304 if ( !
helper.createMenu( pMenu->
Name(), xMenuDesc ) )
309 beans::PropertyValue aProp;
310 aProp.Name =
"ItemDescriptorContainer";
311 aProp.Value <<= uno::Reference< container::XIndexContainer >(xMenuDesc);
312 props.push_back( aProp );
321 ui::ItemType::SEPARATOR_LINE) };
322 toolbarcontainer->insertByIndex( toolbarcontainer->getCount(),
uno::Any( sProps ) );
331TBCCmd::Print(FILE* fp)
334 indent_printf( fp,
" TBCCmd -- dump\n" );
335 indent_printf( fp,
" cmdID 0x%x\n",
cmdID );
336 indent_printf( fp,
" A ( fHideDrawing ) %s\n",
A ?
"true" :
"false" );
337 indent_printf( fp,
" B ( reserved - ignored ) %s\n",
A ?
"true" :
"false" );
338 indent_printf( fp,
" cmdType 0x%x\n",
cmdType );
339 indent_printf( fp,
" C ( reserved - ignored ) %s\n",
A ?
"true" :
"false" );
340 indent_printf( fp,
" reserved3 0x%x\n",
reserved3 );
351 A = (temp & 0x8000 ) == 0x8000;
352 B = (temp & 0x4000) == 0x4000;
353 cmdType = ( temp & 0x3E00 ) >> 9;
354 C = ( temp & 0x100 ) == 0x100;
378 const size_t nMaxPossibleRecords = rS.
remainingSize()/nMinRecordSize;
385 if ( !aCTB.
Read( rS ) )
387 rCTB.push_back( aCTB );
394ScCTBWrapper::Print( FILE* fp )
397 indent_printf( fp,
"[ 0x%x ] ScCTBWrapper -- dump\n",
nOffSet );
399 for (
auto& rItem :
rCTB )
409 ScCTB* pCTB =
nullptr;
410 auto it = std::find_if(
rCTB.begin(),
rCTB.end(), [&sTBName](
ScCTB& rItem) { return rItem.GetName() == sTBName; });
411 if (it !=
rCTB.end())
421 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
422 uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( ui::theModuleUIConfigurationManagerSupplier::get(xContext) );
424 for (
auto& rItem :
rCTB )
428 helper.setMSOCommandMap(
new MSOExcelCommandConvertor() );
434 if ( !rItem.IsMenuToolbar() && !rItem.ImportCustomToolBar( *
this,
helper ) )
bool Read(SvStream &rS) override
virtual OUString MSOCommandToOOCommand(sal_Int16 msoCmd)=0
virtual OUString MSOTCIDToOOCommand(sal_Int16 msoTCID)=0
void ImportCustomToolBar(SfxObjectShell &rDocSh)
ScCTB * GetCustomizationData(const OUString &name)
std::vector< ScCTB > rCTB
virtual ~ScCTBWrapper() override
bool Read(SvStream &rS) override
bool ImportCustomToolBar(ScCTBWrapper &, CustomToolBarImportHelper &)
std::vector< ScTBC > rTBC
bool ImportMenuTB(ScCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &)
bool IsMenuToolbar() const
bool Read(SvStream &rS) override
std::vector< TBVisualData > rVisualData
bool Read(SvStream &rS) override
std::shared_ptr< TBCCmd > tbcCmd
bool ImportToolBarControl(ScCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &toolbarcontainer, CustomToolBarImportHelper &helper, bool bIsMenuBar)
std::shared_ptr< TBCData > tbcd
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
bool Read(SvStream &rS) override
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
T sanitizing_min(T a, T b)