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>
20 #include <rtl/ref.hxx>
34 MSOExcelCommandConvertor();
35 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd )
override;
36 virtual OUString MSOTCIDToOOCommand( sal_Int16 key )
override;
41 MSOExcelCommandConvertor::MSOExcelCommandConvertor()
55 OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
58 IdToString::iterator it = msoToOOcmd.find( key );
59 if ( it != msoToOOcmd.end() )
64 OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
67 IdToString::iterator it = tcidToOOcmd.find( key );
68 if ( it != tcidToOOcmd.end() )
73 CTBS::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 );
129 #ifdef DEBUG_SC_EXCEL
130 void 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 )
164 if ( !rItem.ImportToolBarControl( rWrapper, xMenuDesc, helper,
IsMenuToolbar() ) )
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 );
187 OUString sToolBarName =
"private:resource/toolbar/custom_" + name.
getString();
188 for (
auto& rItem : rTBC )
190 if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, helper,
IsMenuToolbar() ) )
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& )
219 #ifdef DEBUG_SC_EXCEL
220 void 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 ) )
266 #ifdef DEBUG_SC_EXCEL
268 ScTBC::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 );
300 if ( !pCustTB->
ImportMenuTB( rWrapper, xMenuDesc, helper ) )
302 if ( !bIsMenuToolbar )
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 ) );
329 #ifdef DEBUG_SC_EXCEL
331 TBCCmd::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 );
392 #ifdef DEBUG_SC_EXCEL
394 ScCTBWrapper::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())
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
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
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)
T sanitizing_min(T a, T b)
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 &)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
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
#define SAL_WARN(area, stream)
bool Read(SvStream &rS) override
bool ImportMenuTB(ScCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &)