12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/document/IndexedPropertyValues.hpp>
14 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
15 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
16 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
17 #include <com/sun/star/ui/ItemType.hpp>
44 MSOWordCommandConvertor();
45 virtual OUString MSOCommandToOOCommand( sal_Int16 msoCmd )
override;
46 virtual OUString MSOTCIDToOOCommand( sal_Int16 key )
override;
51 MSOWordCommandConvertor::MSOWordCommandConvertor()
55 msoToOOcmd[ 0x20b ] =
".uno:CloseDoc";
56 msoToOOcmd[ 0x50 ] =
".uno:Open";
60 tcidToOOcmd[ 0x9d9 ] =
".uno:Print";
63 OUString MSOWordCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
65 IdToString::iterator it = msoToOOcmd.find( key );
66 if ( it != msoToOOcmd.end() )
71 OUString MSOWordCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
73 IdToString::iterator it = tcidToOOcmd.find( key );
74 if ( it != tcidToOOcmd.end() )
97 if ( index < 0 || index >= static_cast<sal_Int16>(
rCustomizations.size() ) )
106 SwCTB* pCTB = rCustomization.GetCustomizationData();
107 return pCTB && pCTB->
GetName() == sTBName;
110 return it->GetCustomizationData();
116 SAL_INFO(
"sw.ww8",
"SwCTBWrapper::Read() stream pos 0x" << std::hex << rS.
Tell() );
126 int nStart = rS.
Tell();
135 if ( !aTBC.
Read( rS ) )
137 rtbdc.push_back( aTBC );
138 bytesToRead =
cbDTBC - ( rS.
Tell() - nStart );
139 }
while ( bytesToRead > 0 );
141 if ( static_cast< tools::Long >( rS.
Tell() ) != nExpectedPos )
146 SAL_WARN_IF( static_cast< tools::Long >(rS.
Tell()) != nExpectedPos,
"sw.ww8",
"### Error: Expected pos not equal to actual pos after reading rtbdc");
147 SAL_INFO(
"sw.ww8",
"\tPos now is 0x" << std::hex << rS.
Tell() <<
" should be 0x" << std::hex << nExpectedPos );
149 rS.
Seek( nExpectedPos );
155 if (
cCust > nMaxPossibleRecords)
162 if ( !aCust.
Read( rS ) )
178 auto it = std::find_if(
rtbdc.begin(),
rtbdc.end(),
179 [&nStreamOffset](
SwTBC& rItem) {
return rItem.GetOffset() == nStreamOffset; });
180 if ( it !=
rtbdc.end() )
191 css::uno::Reference<css::ui::XUIConfigurationManager> xCfgMgr;
194 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
196 xCfgMgr = xAppCfgSupp->getUIConfigurationManager(
"com.sun.star.text.TextDocument");
201 if ( !rCustomization.ImportCustomToolBar( *
this, helper ) )
216 , pWrapper( wrapper )
217 , bIsDroppedMenuTB( false )
223 SAL_INFO(
"sw.ww8",
"Customization::Read() stream pos 0x" << std::hex << rS.
Tell() );
230 if (
ctbds > nMaxAvailableRecords)
235 if (!aTBDelta.
Read( rS ) )
260 if ( rTBDelta.ControlIsInserted() && rTBDelta.ControlDropsToolBar() )
266 const OUString sMenuBar(
"private:resource/menubar/menubar" );
272 const OUString sMenuName = pTBC->
GetCustomText().replace(
'&',
'~');
276 uno::Reference< container::XIndexContainer > xIndexContainer;
277 bool bHasSettings =
false;
280 xIndexContainer.set( helper.
getCfgManager()->getSettings( sMenuBar,
true ), uno::UNO_QUERY_THROW );
286 xIndexContainer.set( helper.
getAppCfgManager()->getSettings( sMenuBar,
true ), uno::UNO_QUERY_THROW );
288 xIndexContainer.set( helper.
getAppCfgManager()->createSettings(), uno::UNO_SET_THROW );
291 uno::Reference< lang::XSingleComponentFactory > xSCF( xIndexContainer, uno::UNO_QUERY_THROW );
292 uno::Reference< uno::XComponentContext > xContext(
295 uno::Sequence< beans::PropertyValue > aPopupMenu( 4 );
296 aPopupMenu[0].Name =
"CommandURL";
297 aPopupMenu[0].Value <<=
"vnd.openoffice.org:" + sMenuName;
298 aPopupMenu[1].Name =
"Label";
299 aPopupMenu[1].Value <<= sMenuName;
300 aPopupMenu[2].Name =
"Type";
301 aPopupMenu[2].Value <<= sal_Int32( 0 );
302 aPopupMenu[3].Name =
"ItemDescriptorContainer";
303 uno::Reference< container::XIndexContainer > xMenuContainer( xSCF->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
304 aPopupMenu[3].Value <<= xMenuContainer;
307 SAL_INFO(
"sw.ww8",
"** there are " << xIndexContainer->getCount() <<
" menu items on the bar, inserting after that");
308 xIndexContainer->insertByIndex( xIndexContainer->getCount(), uno::makeAny( aPopupMenu ) );
311 helper.
getCfgManager()->replaceSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
313 helper.
getCfgManager()->insertSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
315 uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.
getCfgManager(), uno::UNO_QUERY_THROW );
316 xPersistence->store();
357 return !(
CiTBDE & 0x8000 );
364 nIndex = nIndex >> 1;
371 SAL_INFO(
"sw.ww8",
"TBDelta::Read() stream pos 0x" << std::hex << rS.
Tell() );
397 SAL_INFO(
"sw.ww8",
"SwCTB::Read() stream pos 0x" << std::hex << rS.
Tell() );
418 if ( !aTBC.
Read( rS ) )
420 rTBC.push_back( aTBC );
434 uno::Reference< container::XIndexContainer > xIndexContainer( helper.
getCfgManager()->createSettings(), uno::UNO_SET_THROW );
435 uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
436 uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
439 xProps->setPropertyValue(
"UIName", uno::makeAny(
name.
getString() ) );
441 const OUString sToolBarName =
"private:resource/toolbar/custom_" +
name.
getString();
442 for (
auto& rItem :
rTBC )
445 if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, helper,
IsMenuToolbar() ) )
449 SAL_INFO(
"sw.ww8",
"Name of toolbar :-/ " << sToolBarName );
451 helper.
getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
453 #if 1 // don't think this is necessary
454 uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.
getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
455 xPersistence->store();
457 xPersistence.set( helper.
getCfgManager(), uno::UNO_QUERY_THROW );
458 xPersistence->store();
462 catch(
const uno::Exception& )
472 for (
auto& rItem :
rTBC )
475 if ( !rItem.ImportToolBarControl( rWrapper, xIndexContainer, rHelper,
true ) )
487 SAL_INFO(
"sw.ww8",
"SwTBC::Read() stream pos 0x" << std::hex << rS.
Tell() );
493 cid = std::make_shared<sal_uInt32>();
499 tbcd = std::make_shared<TBCData>(
tbch );
500 if ( !
tbcd->Read( rS ) )
513 bool bBuiltin =
false;
517 const sal_uInt32 nCid = ( *
cid & 0xFFFF );
520 const sal_Int16 arg2 =
static_cast<sal_Int16
>( nCid >> 3 );
525 SAL_INFO(
"sw.ww8",
"cmt is cmtFci builtin command 0x" << std::hex << arg2);
530 SAL_INFO(
"sw.ww8",
"cmt is cmtMacro macro 0x" << std::hex << arg2);
533 SAL_INFO(
"sw.ww8",
"cmt is cmtAllocated [???] 0x" << std::hex << arg2);
536 SAL_INFO(
"sw.ww8",
"cmt is cmNill no-thing 0x" << std::hex << arg2);
539 SAL_INFO(
"sw.ww8",
"illegal 0x" << std::hex << cmt);
546 std::vector< css::beans::PropertyValue >
props;
550 if ( !sCommand.isEmpty() )
552 beans::PropertyValue aProp;
554 aProp.Name =
"CommandURL";
555 aProp.Value <<= sCommand;
556 props.push_back( aProp );
559 bool bBeginGroup =
false;
560 tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuBar );
565 SAL_INFO(
"sw.ww8",
"** control has a menu, name of toolbar with menu items is " << pMenu->
Name() );
574 if ( !pCustTB->ImportMenuTB( rWrapper,xMenuDesc, helper ) )
583 beans::PropertyValue aProp;
584 aProp.Name =
"ItemDescriptorContainer";
585 aProp.Value <<= xMenuDesc;
586 props.push_back( aProp );
594 uno::Sequence< beans::PropertyValue > sProps( 1 );
595 sProps[ 0 ].Name =
"Type";
596 sProps[ 0 ].Value <<= ui::ItemType::SEPARATOR_LINE;
597 toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
609 return tbcd->getGeneralInfo().CustomText();
616 SAL_INFO(
"sw.ww8",
"Xst::Read() stream pos 0x" << std::hex << rS.
Tell() );
628 SAL_INFO(
"sw.ww8",
"Tcg::Read() stream pos 0x" << std::hex << rS.
Tell() );
634 return tcg->Read( rS );
640 return tcg->ImportCustomToolBar( rDocSh );
654 std::unique_ptr<Tcg255SubStruct> xSubStruct;
659 xSubStruct.reset(
new PlfMcd);
664 xSubStruct.reset(
new PlfAcd);
670 xSubStruct.reset(
new PlfKme);
689 SAL_INFO(
"sw.ww8",
"Unknown id 0x" << std::hex << nId);
692 xSubStruct->ch = nId;
693 if (!xSubStruct->Read(rS))
695 rgtcgData.push_back(std::move(xSubStruct));
702 for (
const auto & rSubStruct :
rgtcgData )
704 if ( rSubStruct->id() == 0x12 )
724 SAL_INFO(
"sw.ww8",
"Tcg255::Read() stream pos 0x" << std::hex << rS.
Tell() );
728 while ( nId != 0x40 )
745 SAL_INFO(
"sw.ww8",
"Tcg255SubStruct::Read() stream pos 0x" << std::hex << rS.
Tell() );
757 SAL_INFO(
"sw.ww8",
"PffMcd::Read() stream pos 0x" << std::hex << rS.
Tell() );
766 SAL_WARN(
"sw.ww8",
iMac <<
" records claimed, but max possible is " << nMaxPossibleRecords);
767 iMac = nMaxPossibleRecords;
792 SAL_INFO(
"sw.ww8",
"PffAcd::Read() stream pos 0x" << std::hex << rS.
Tell() );
798 auto nMaxPossibleRecords = rS.
remainingSize() / (
sizeof(sal_uInt16)*2);
801 SAL_WARN(
"sw.ww8",
iMac <<
" records claimed, but max possible is " << nMaxPossibleRecords);
802 iMac = nMaxPossibleRecords;
827 SAL_INFO(
"sw.ww8",
"PlfKme::Read() stream pos 0x" << std::hex << rS.
Tell() );
854 SAL_INFO(
"sw.ww8",
"TcgSttbf::Read() stream pos 0x" << std::hex << rS.
Tell() );
872 SAL_INFO(
"sw.ww8",
"TcgSttbfCore::Read() stream pos 0x" << std::hex << rS.
Tell() );
901 SAL_INFO(
"sw.ww8",
"MacroNames::Read() stream pos 0x" << std::hex << rS.
Tell() );
908 size_t nMaxAvailableRecords = rS.
remainingSize()/
sizeof(sal_uInt16);
909 if (
iMac > nMaxAvailableRecords)
927 SAL_INFO(
"sw.ww8",
"MacroName::Read() stream pos 0x" << std::hex << rS.
Tell() );
940 SAL_INFO(
"sw.ww8",
"Xstz::Read() stream pos 0x" << std::hex << rS.
Tell() );
966 SAL_INFO(
"sw.ww8",
"Kme::Read() stream pos 0x" << std::hex << rS.
Tell() );
979 SAL_INFO(
"sw.ww8",
"Acd::Read() stream pos 0x" << std::hex << rS.
Tell() );
999 SAL_INFO(
"sw.ww8",
"MCD::Read() stream pos 0x" << rS.
Tell() );
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool Read(SvStream &rS) override
const OUString & getString() const
bool Read(SvStream &rS) override
SvStream & ReadInt16(sal_Int16 &rInt16)
bool ImportToolBarControl(SwCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &, bool)
std::vector< sal_Int16 > dropDownMenuIndices
bool ControlDropsToolBar()
bool ImportCustomToolBar(SwCTBWrapper &, CustomToolBarImportHelper &)
std::vector< TBVisualData > rVisualData
sal_uInt8 doprfatendFlags
OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nLen)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
virtual ~SwCTBWrapper() override
bool processSubStruct(sal_uInt8 nId, SvStream &)
virtual ~PlfAcd() override
std::unique_ptr< Tcg255 > tcg
sal_uInt64 Seek(sal_uInt64 nPos)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
SwCTB * GetCustomizationData(const OUString &name)
std::vector< std::unique_ptr< Tcg255SubStruct > > rgtcgData
bool Read(SvStream &rS) override
std::vector< SwTBC > rtbdc
virtual ~SwCTB() override
bool Read(SvStream &rS) override
OUString const & GetName()
sal_uInt64 remainingSize()
css::uno::Reference< css::frame::XModel > GetBaseModel() const
bool Read(SvStream &rS) override
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
bool ImportMenu(SwCTBWrapper &, CustomToolBarImportHelper &)
virtual ~MacroNames() override
bool Read(SvStream &rS) override
SwTBC * GetTBCAtOffset(sal_uInt32 nStreamOffset)
sal_Int16 CustomizationIndex()
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::shared_ptr< SwCTB > customizationDataCTB
bool Read(SvStream &rS) override
std::shared_ptr< sal_uInt32 > cid
std::shared_ptr< TBCData > tbcd
bool Read(SvStream &rS) override
Customization * GetCustomizaton(sal_Int16 index)
SvStream & ReadUChar(unsigned char &rChar)
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
std::vector< Customization > rCustomizations
bool Read(SvStream &rS) override
std::vector< TBDelta > customizationDataTBDelta
SvStream & ReadInt32(sal_Int32 &rInt32)
#define TOOLS_INFO_EXCEPTION(area, stream)
std::vector< SwTBC > rTBC
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
std::unique_ptr< MacroName[]> rgNames
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
#define SAL_WARN_IF(condition, area, stream)
bool Read(SvStream &rS) override
std::unique_ptr< Acd[]> rgacd
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
virtual ~Tcg255() override
#define SAL_INFO(area, stream)
virtual ~PlfKme() override
Customization(SwCTBWrapper *rapper)
virtual ~TcgSttbfCore() override
Reference< XComponentContext > getProcessComponentContext()
bool ImportMenuTB(SwCTBWrapper &, const css::uno::Reference< css::container::XIndexContainer > &, CustomToolBarImportHelper &)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
#define SAL_WARN(area, stream)
Reference< XModel > xModel
std::unique_ptr< SBBItem[]> dataItems
bool ImportCustomToolBar(SfxObjectShell &rDocSh)
std::unique_ptr< Kme[]> rgkme
void InsertDropIndex(sal_Int32 aIndex)
OUString read_uInt16_PascalString(SvStream &rStrm)
COMPHELPER_DLLPUBLIC void notifyMacroEventRead(const css::uno::Reference< css::frame::XModel > &_rxDocument)
bool Read(SvStream &rS) override
bool ImportCustomToolBar(SwCTBWrapper &, CustomToolBarImportHelper &)
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool Read(SvStream &rS) override
bool IsMenuToolbar() const
SvStream & ReadSChar(signed char &rChar)