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/lang/XSingleComponentFactory.hpp>
16#include <com/sun/star/ui/ItemType.hpp>
46 MSOWordCommandConvertor();
53MSOWordCommandConvertor::MSOWordCommandConvertor()
57 m_MSOToOOcmd[ 0x20b ] =
".uno:CloseDoc";
58 m_MSOToOOcmd[ 0x50 ] =
".uno:Open";
62 m_TCIDToOOcmd[ 0x9d9 ] =
".uno:Print";
65OUString MSOWordCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
67 IdToString::iterator it = m_MSOToOOcmd.find( key );
68 if ( it != m_MSOToOOcmd.end() )
73OUString MSOWordCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
75 IdToString::iterator it = m_TCIDToOOcmd.find( key );
76 if ( it != m_TCIDToOOcmd.end() )
108 SwCTB* pCTB = rCustomization.GetCustomizationData();
109 return pCTB && pCTB->GetName() == sTBName;
112 return it->GetCustomizationData();
118 SAL_INFO(
"sw.ww8",
"SwCTBWrapper::Read() stream pos 0x" << std::hex << rS.
Tell() );
128 int nStart = rS.
Tell();
137 if ( !aTBC.
Read( rS ) )
141 }
while ( bytesToRead > 0 );
143 if ( rS.
Tell() != nExpectedPos )
148 SAL_WARN_IF( rS.
Tell() != nExpectedPos,
"sw.ww8",
"### Error: Expected pos not equal to actual pos after reading rtbdc");
149 SAL_INFO(
"sw.ww8",
"\tPos now is 0x" << std::hex << rS.
Tell() <<
" should be 0x" << std::hex << nExpectedPos );
151 rS.
Seek( nExpectedPos );
157 if (
m_cCust > nMaxPossibleRecords)
164 if ( !aCust.
Read( rS ) )
181 [&nStreamOffset](
SwTBC& rItem) { return rItem.GetOffset() == nStreamOffset; });
193 css::uno::Reference<css::ui::XUIConfigurationManager> xCfgMgr;
196 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
198 xCfgMgr = xAppCfgSupp->getUIConfigurationManager(
"com.sun.star.text.TextDocument");
201 helper.setMSOCommandMap(
new MSOWordCommandConvertor() );
203 if ( !rCustomization.ImportCustomToolBar( *
this,
helper ) )
218 , m_pWrapper( wrapper )
219 , m_bIsDroppedMenuTB( false )
225 SAL_INFO(
"sw.ww8",
"Customization::Read() stream pos 0x" << std::hex << rS.
Tell() );
232 if (
m_ctbds > nMaxAvailableRecords)
237 if (!aTBDelta.
Read( rS ) )
262 if ( rTBDelta.ControlIsInserted() && rTBDelta.ControlDropsToolBar() )
268 static constexpr OUStringLiteral sMenuBar(
u"private:resource/menubar/menubar" );
274 const OUString sMenuName = pTBC->
GetCustomText().replace(
'&',
'~');
278 uno::Reference< container::XIndexContainer > xIndexContainer;
279 bool bHasSettings =
false;
280 if (
helper.getCfgManager()->hasSettings( sMenuBar ) )
282 xIndexContainer.set(
helper.getCfgManager()->getSettings( sMenuBar,
true ), uno::UNO_QUERY_THROW );
287 if (
helper.getAppCfgManager()->hasSettings( sMenuBar ) )
288 xIndexContainer.set(
helper.getAppCfgManager()->getSettings( sMenuBar,
true ), uno::UNO_QUERY_THROW );
290 xIndexContainer.set(
helper.getAppCfgManager()->createSettings(), uno::UNO_SET_THROW );
293 uno::Reference< lang::XSingleComponentFactory > xSCF( xIndexContainer, uno::UNO_QUERY_THROW );
294 uno::Reference< uno::XComponentContext > xContext(
296 uno::Reference< container::XIndexContainer > xMenuContainer( xSCF->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
298 uno::Sequence< beans::PropertyValue > aPopupMenu{
306 SAL_INFO(
"sw.ww8",
"** there are " << xIndexContainer->getCount() <<
" menu items on the bar, inserting after that");
307 xIndexContainer->insertByIndex( xIndexContainer->getCount(),
uno::Any( aPopupMenu ) );
310 helper.getCfgManager()->replaceSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
312 helper.getCfgManager()->insertSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
314 uno::Reference< ui::XUIConfigurationPersistence > xPersistence(
helper.getCfgManager(), uno::UNO_QUERY_THROW );
315 xPersistence->store();
339 : m_doprfatendFlags(0)
370 SAL_INFO(
"sw.ww8",
"TBDelta::Read() stream pos 0x" << std::hex << rS.
Tell() );
396 SAL_INFO(
"sw.ww8",
"SwCTB::Read() stream pos 0x" << std::hex << rS.
Tell() );
417 if ( !aTBC.
Read( rS ) )
433 uno::Reference< container::XIndexContainer > xIndexContainer(
helper.getCfgManager()->createSettings(), uno::UNO_SET_THROW );
434 uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
435 uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
440 const OUString sToolBarName =
"private:resource/toolbar/custom_" +
m_name.
getString();
441 for (
auto& rItem :
m_rTBC )
448 SAL_INFO(
"sw.ww8",
"Name of toolbar :-/ " << sToolBarName );
450 helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
453 uno::Reference< ui::XUIConfigurationPersistence > xPersistence(
helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
454 xPersistence->store();
456 xPersistence.set(
helper.getCfgManager(), uno::UNO_QUERY_THROW );
457 xPersistence->store();
461 catch(
const uno::Exception& )
471 for (
auto& rItem :
m_rTBC )
474 if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, rHelper,
true ) )
486 SAL_INFO(
"sw.ww8",
"SwTBC::Read() stream pos 0x" << std::hex << rS.
Tell() );
492 m_cid = std::make_shared<sal_uInt32>();
499 if ( !
m_tbcd->Read( rS ) )
512 bool bBuiltin =
false;
516 const sal_uInt32 nCid = ( *
m_cid & 0xFFFF );
519 const sal_Int16 arg2 =
static_cast<sal_Int16
>( nCid >> 3 );
524 SAL_INFO(
"sw.ww8",
"cmt is cmtFci builtin command 0x" << std::hex << arg2);
529 SAL_INFO(
"sw.ww8",
"cmt is cmtMacro macro 0x" << std::hex << arg2);
532 SAL_INFO(
"sw.ww8",
"cmt is cmtAllocated [???] 0x" << std::hex << arg2);
535 SAL_INFO(
"sw.ww8",
"cmt is cmNill no-thing 0x" << std::hex << arg2);
538 SAL_INFO(
"sw.ww8",
"illegal 0x" << std::hex << cmt);
545 std::vector< css::beans::PropertyValue >
props;
548 const OUString sCommand =
helper.MSOCommandToOOCommand( cmdId );
549 if ( !sCommand.isEmpty() )
551 beans::PropertyValue aProp;
553 aProp.Name =
"CommandURL";
554 aProp.Value <<= sCommand;
555 props.push_back( aProp );
558 bool bBeginGroup =
false;
564 SAL_INFO(
"sw.ww8",
"** control has a menu, name of toolbar with menu items is " << pMenu->
Name() );
577 if ( !
helper.createMenu( pMenu->
Name(), xMenuDesc ) )
582 beans::PropertyValue aProp;
583 aProp.Name =
"ItemDescriptorContainer";
584 aProp.Value <<= uno::Reference< container::XIndexContainer >(xMenuDesc);
585 props.push_back( aProp );
594 "Type", ui::ItemType::SEPARATOR_LINE) };
595 toolbarcontainer->insertByIndex( toolbarcontainer->getCount(),
uno::Any( sProps ) );
607 return m_tbcd->getGeneralInfo().CustomText();
614 SAL_INFO(
"sw.ww8",
"Xst::Read() stream pos 0x" << std::hex << rS.
Tell() );
626 SAL_INFO(
"sw.ww8",
"Tcg::Read() stream pos 0x" << std::hex << rS.
Tell() );
632 return m_tcg->Read( rS );
638 return m_tcg->ImportCustomToolBar( rDocSh );
652 std::unique_ptr<Tcg255SubStruct> xSubStruct;
657 xSubStruct.reset(
new PlfMcd);
662 xSubStruct.reset(
new PlfAcd);
668 xSubStruct.reset(
new PlfKme);
687 SAL_INFO(
"sw.ww8",
"Unknown id 0x" << std::hex <<
nId);
690 xSubStruct->m_ch =
nId;
691 if (!xSubStruct->Read(rS))
702 if ( rSubStruct->id() == 0x12 )
722 SAL_INFO(
"sw.ww8",
"Tcg255::Read() stream pos 0x" << std::hex << rS.
Tell() );
726 while (
nId != 0x40 )
743 SAL_INFO(
"sw.ww8",
"Tcg255SubStruct::Read() stream pos 0x" << std::hex << rS.
Tell() );
755 SAL_INFO(
"sw.ww8",
"PffMcd::Read() stream pos 0x" << std::hex << rS.
Tell() );
764 SAL_WARN(
"sw.ww8",
m_iMac <<
" records claimed, but max possible is " << nMaxPossibleRecords);
765 m_iMac = nMaxPossibleRecords;
790 SAL_INFO(
"sw.ww8",
"PffAcd::Read() stream pos 0x" << std::hex << rS.
Tell() );
796 auto nMaxPossibleRecords = rS.
remainingSize() / (
sizeof(sal_uInt16)*2);
799 SAL_WARN(
"sw.ww8",
m_iMac <<
" records claimed, but max possible is " << nMaxPossibleRecords);
800 m_iMac = nMaxPossibleRecords;
825 SAL_INFO(
"sw.ww8",
"PlfKme::Read() stream pos 0x" << std::hex << rS.
Tell() );
852 SAL_INFO(
"sw.ww8",
"TcgSttbf::Read() stream pos 0x" << std::hex << rS.
Tell() );
870 SAL_INFO(
"sw.ww8",
"TcgSttbfCore::Read() stream pos 0x" << std::hex << rS.
Tell() );
899 SAL_INFO(
"sw.ww8",
"MacroNames::Read() stream pos 0x" << std::hex << rS.
Tell() );
906 size_t nMaxAvailableRecords = rS.
remainingSize()/
sizeof(sal_uInt16);
907 if (
m_iMac > nMaxAvailableRecords)
925 SAL_INFO(
"sw.ww8",
"MacroName::Read() stream pos 0x" << std::hex << rS.
Tell() );
938 SAL_INFO(
"sw.ww8",
"Xstz::Read() stream pos 0x" << std::hex << rS.
Tell() );
964 SAL_INFO(
"sw.ww8",
"Kme::Read() stream pos 0x" << std::hex << rS.
Tell() );
971, m_fciBasedOnABC( 0 )
977 SAL_INFO(
"sw.ww8",
"Acd::Read() stream pos 0x" << std::hex << rS.
Tell() );
987,m_reserved3( 0xFFFF )
997 SAL_INFO(
"sw.ww8",
"MCD::Read() stream pos 0x" << rS.
Tell() );
bool Read(SvStream &rS) override
sal_uInt16 m_fciBasedOnABC
std::shared_ptr< SwCTB > m_customizationDataCTB
bool ImportMenu(SwCTBWrapper &, CustomToolBarImportHelper &)
SwCTBWrapper * m_pWrapper
bool ImportCustomToolBar(SwCTBWrapper &, CustomToolBarImportHelper &)
bool Read(SvStream &rS) override
Customization(SwCTBWrapper *rapper)
std::vector< TBDelta > m_customizationDataTBDelta
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
virtual OUString MSOCommandToOOCommand(sal_Int16 msoCmd)=0
virtual OUString MSOTCIDToOOCommand(sal_Int16 msoTCID)=0
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
std::unique_ptr< MacroName[]> m_rgNames
virtual ~MacroNames() override
bool Read(SvStream &rS) override
std::unique_ptr< Acd[]> m_rgacd
virtual ~PlfAcd() override
std::unique_ptr< Kme[]> m_rgkme
bool Read(SvStream &rS) override
virtual ~PlfKme() override
bool Read(SvStream &rS) override
std::vector< MCD > m_rgmcd
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadInt32(sal_Int32 &rInt32)
SvStream & ReadSChar(signed char &rChar)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
SvStream & ReadUChar(unsigned char &rChar)
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
SwCTB * GetCustomizationData(const OUString &name)
bool Read(SvStream &rS) override
Customization * GetCustomizaton(sal_Int16 index)
std::vector< SwTBC > m_rtbdc
void InsertDropIndex(sal_Int32 aIndex)
virtual ~SwCTBWrapper() override
std::vector< Customization > m_rCustomizations
std::vector< sal_Int16 > m_dropDownMenuIndices
SwTBC * GetTBCAtOffset(sal_uInt32 nStreamOffset)
bool ImportMenuTB(SwCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &)
std::vector< SwTBC > m_rTBC
std::vector< TBVisualData > m_rVisualData
bool ImportCustomToolBar(SwCTBWrapper &, CustomToolBarImportHelper &)
virtual ~SwCTB() override
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
std::shared_ptr< sal_uInt32 > m_cid
bool ImportToolBarControl(SwCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &, bool)
bool Read(SvStream &rS) override
std::shared_ptr< TBCData > m_tbcd
sal_uInt8 m_doprfatendFlags
sal_Int16 CustomizationIndex()
bool Read(SvStream &rS) override
bool ControlDropsToolBar()
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
virtual ~Tcg255() override
std::vector< std::unique_ptr< Tcg255SubStruct > > m_rgtcgData
bool processSubStruct(sal_uInt8 nId, SvStream &)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
std::unique_ptr< SBBItem[]> m_dataItems
virtual ~TcgSttbfCore() override
bool Read(SvStream &rS) override
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
std::unique_ptr< Tcg255 > m_tcg
bool Read(SvStream &rS) override
const OUString & getString() const
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
#define TOOLS_INFO_EXCEPTION(area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
COMPHELPER_DLLPUBLIC void notifyMacroEventRead(const css::uno::Reference< css::frame::XModel > &_rxDocument)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
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)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nUnits)
Reference< XModel > xModel
OUString read_uInt16_PascalString(SvStream &rStrm)