idl/source/objects/object.cxx | 4 +-- idl/source/objects/slot.cxx | 6 ++--- idl/source/objects/types.cxx | 4 +-- include/sfx2/msg.hxx | 33 ++++---------------------------- sfx2/source/appl/appuno.cxx | 40 ++++++++++++++++++--------------------- sfx2/source/control/bindings.cxx | 2 - sfx2/source/control/msg.cxx | 6 ++--- sfx2/source/control/request.cxx | 4 +-- sfx2/source/control/shell.cxx | 4 +-- sfx2/source/control/statcach.cxx | 2 - sfx2/source/control/unoctitm.cxx | 4 +-- 11 files changed, 42 insertions(+), 67 deletions(-)
New commits: commit b265b547b9e09893187aab0aa1085ba51c43563b Author: Noel Grandin <[email protected]> AuthorDate: Tue Apr 30 22:03:51 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed May 1 19:29:37 2024 +0200 use more OUString in sfx slots Change-Id: I900d9f1d35bc1e620822eedd5722a502704d6de0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166959 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 908ef3d16548..0b2fadec2d77 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -292,7 +292,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) { // at least one dummy WriteTab( rOutStm, 1 ); - rOutStm.WriteOString("{ (const SfxType*) &aSfxVoidItem_Impl, 0, 0 }" ) << endl; + rOutStm.WriteOString("{ (const SfxType*) &aSfxVoidItem_Impl, u\"\"_ustr, 0 }" ) << endl; } rOutStm << endl; rOutStm.WriteOString( "};" ) << endl << endl; @@ -319,7 +319,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) .WriteOString( ", 0, SfxGroupId::NONE, " ) .WriteOString( "SFX_STUB_PTR_EXEC_NONE," ) .WriteOString( "SFX_STUB_PTR_STATE_NONE," ) - .WriteOString( "SfxSlotMode::NONE, SfxVoidItem, 0, 0, \"\", SfxSlotMode::NONE )" ) << endl; + .WriteOString( "SfxSlotMode::NONE, SfxVoidItem, 0, 0, u\"\"_ustr, SfxSlotMode::NONE )" ) << endl; } rOutStm << endl; rOutStm.WriteOString( "};" ) << endl; diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index 58b3faa522b4..8edff3a63efd 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -559,9 +559,9 @@ void SvMetaSlot::WriteSlot( std::string_view rShellName, sal_uInt16 nCount, } { - rOutStm.WriteOString( ",\"" ); + rOutStm.WriteOString( ",u\"" ); rOutStm.WriteOString( GetName() ); - rOutStm.WriteOString( "\"" ); + rOutStm.WriteOString( "\"_ustr" ); } rOutStm.WriteOString( " )," ) << endl; @@ -588,7 +588,7 @@ sal_uInt16 SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rO // item type .WriteOString(pPType->GetName()).WriteOString("_Impl, ") // parameter name - .WriteOString("\"").WriteOString(pPar->GetName()).WriteOString("\", ") + .WriteOString("u\"").WriteOString(pPar->GetName()).WriteOString("\"_ustr, ") // slot id .WriteOString(pPar->GetSlotId().getString()).WriteOString(" },") << endl; if( !SvIdlDataBase::FindType( pPType, rBase.aUsedTypes ) ) diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index f6a77e77e07a..b98d90c93d85 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -108,9 +108,9 @@ size_t SvMetaAttribute::MakeSfx( OStringBuffer& rAttrArray ) const { rAttrArray.append('{'); rAttrArray.append(GetSlotId().getString()); - rAttrArray.append(",\""); + rAttrArray.append(",u\""); rAttrArray.append(GetName()); - rAttrArray.append("\"}"); + rAttrArray.append("\"_ustr}"); return 1; } } diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx index 86ecfd423644..8023f0846f60 100644 --- a/include/sfx2/msg.hxx +++ b/include/sfx2/msg.hxx @@ -90,8 +90,8 @@ enum class SfxSlotKind struct SfxTypeAttrib { - sal_uInt16 nAID; - const char* pName; + sal_uInt16 nAID; + OUString aName; }; template<class T> SfxPoolItem* createSfxPoolItem() @@ -171,7 +171,7 @@ SFX_DECL_TYPE(23); // for SvxSearchItem struct SfxFormalArgument { const SfxType* pType; // Type of the parameter (SfxPoolItem subclass) - const char* pName; // Name of the sParameters + OUString aName; // Name of the sParameters sal_uInt16 nSlotId; // Slot-Id for identification of the Parameters std::unique_ptr<SfxPoolItem> CreateItem() const @@ -201,30 +201,7 @@ public: SfxDisableFlags nDisableFlags; // DisableFlags that need to be // present, so that the Slot // can be enabled - OUString pUnoName; // UnoName for the Slots - -public: - - template <size_t N> - SfxSlot(sal_uInt16 sId, SfxGroupId gId, SfxSlotMode flags, sal_uInt16 masterSlotId, - sal_uInt16 value, SfxExecFunc exec, SfxStateFunc state, const SfxType* type, - const SfxSlot* nextSlot, const SfxFormalArgument* firstArgDef, sal_uInt16 argDefCount, - SfxDisableFlags disableFlags, const char (&literal)[N]) - : nSlotId(sId) - , nGroupId(gId) - , nFlags(flags) - , nMasterSlotId(masterSlotId) - , nValue(value) - , fnExec(exec) - , fnState(state) - , pType(type) - , pNextSlot(nextSlot) - , pFirstArgDef(firstArgDef) - , nArgDefCount(argDefCount) - , nDisableFlags(disableFlags) - , pUnoName(literal) - { - } + OUString aUnoName; // UnoName for the Slots SfxSlotKind GetKind() const; sal_uInt16 GetSlotId() const; @@ -233,7 +210,7 @@ public: SfxGroupId GetGroupId() const; sal_uInt16 GetWhich( const SfxItemPool &rPool ) const; const SfxType* GetType() const { return pType; } - const OUString& GetUnoName() const { return pUnoName; } + const OUString& GetUnoName() const { return aUnoName; } SFX2_DLLPUBLIC OUString GetCommand() const; sal_uInt16 GetFormalArgumentCount() const { return nArgDefCount; } diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 1c4030bb6070..7aa37e031143 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -202,7 +202,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert const beans::PropertyValue& rProp = pPropsVal[0]; const OUString& rName = rProp.Name; - if ( nCount == 1 && rName == pSlot->pUnoName ) + if ( nCount == 1 && rName == pSlot->aUnoName ) { // there is only one parameter and its name matches the name of the property, // so it's either a simple property or a complex property in one single UNO struct @@ -211,7 +211,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert rSet.Put( std::move(pItem) ); else { - SAL_WARN( "sfx", "Property not convertible: " << pSlot->pUnoName ); + SAL_WARN( "sfx", "Property not convertible: " << pSlot->aUnoName ); } } #ifdef DBG_UTIL @@ -242,8 +242,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert for ( nSub=0; nSub<nSubCount; nSub++ ) { // search sub item by name - OUString aStr = pSlot->pUnoName + "." + OUString::createFromAscii(pType->aAttrib[nSub].pName); - if ( rPropValue.Name == aStr ) + if ( rPropValue.Name == (pSlot->aUnoName + "." + pType->aAttrib[nSub].aName) ) { sal_uInt8 nSubId = static_cast<sal_uInt8>(static_cast<sal_Int8>(pType->aAttrib[nSub].nAID)); if ( bConvertTwips ) @@ -252,7 +251,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert nFound++; else { - SAL_WARN( "sfx.appl", "Property not convertible: " << pSlot->pUnoName); + SAL_WARN( "sfx.appl", "Property not convertible: " << pSlot->aUnoName); } break; } @@ -283,7 +282,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert std::unique_ptr<SfxPoolItem> pItem(rArg.CreateItem()); if ( !pItem ) { - SAL_WARN( "sfx", "No creator method for argument: " << rArg.pName ); + SAL_WARN( "sfx", "No creator method for argument: " << rArg.aName ); return; } @@ -296,7 +295,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert { // "simple" (base type) argument auto pProp = std::find_if(rArgs.begin(), rArgs.end(), - [&rArg](const beans::PropertyValue& rProp) { return rProp.Name.equalsAscii(rArg.pName); }); + [&rArg](const beans::PropertyValue& rProp) { return rProp.Name == rArg.aName; }); if (pProp != rArgs.end()) { #ifdef DBG_UTIL @@ -307,7 +306,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert rSet.Put( std::move(pItem) ); else { - SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); + SAL_WARN( "sfx", "Property not convertible: " << rArg.aName ); } } } @@ -318,7 +317,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert for ( const beans::PropertyValue& rProp : rArgs ) { const OUString& rName = rProp.Name; - if ( rName == OUString(rArg.pName, strlen(rArg.pName), RTL_TEXTENCODING_UTF8) ) + if ( rName == rArg.aName ) { bAsWholeItem = true; #ifdef DBG_UTIL @@ -329,7 +328,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert rSet.Put( std::move(pItem) ); else { - SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); + SAL_WARN( "sfx", "Property not convertible: " << rArg.aName ); } } } @@ -345,8 +344,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert for ( sal_uInt16 nSub=0; nSub<nSubCount; nSub++ ) { // search sub item by name - OString aStr = OString::Concat(rArg.pName) + "." + pType->aAttrib[nSub].pName; - if ( rProp.Name.equalsAsciiL(aStr.getStr(), aStr.getLength()) ) + if ( rProp.Name == (rArg.aName + "." + pType->aAttrib[nSub].aName) ) { // at least one member found ... bRet = true; @@ -360,7 +358,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert { // ... but it was not convertible bRet = false; - SAL_WARN( "sfx", "Property not convertible: " << rArg.pName ); + SAL_WARN( "sfx", "Property not convertible: " << rArg.aName ); } break; @@ -884,7 +882,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert else { // transform parameter "OptionsPageURL" of slot "OptionsTreeDialog" - if ( "OptionsTreeDialog" == pSlot->pUnoName ) + if ( "OptionsTreeDialog" == pSlot->aUnoName ) { auto pProp = std::find_if(rArgs.begin(), rArgs.end(), [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL" || rProp.Name == "OptionsPageID"; }); @@ -903,7 +901,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if ( nFoundArgs == nCount ) { // except for the "special" slots: assure that every argument was convertible - SAL_INFO( "sfx.appl", "MacroPlayer: Some properties didn't match to any formal argument for slot: "<< pSlot->pUnoName ); + SAL_INFO( "sfx.appl", "MacroPlayer: Some properties didn't match to any formal argument for slot: "<< pSlot->aUnoName ); } #endif } @@ -1302,7 +1300,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b sal_uInt16 nSubCount = pType->nAttribs; if ( !nSubCount ) { - pValue[nActProp].Name = pSlot->pUnoName; + pValue[nActProp].Name = pSlot->aUnoName; if ( !pItem->QueryValue( pValue[nActProp].Value ) ) { SAL_WARN( "sfx", "Item not convertible: " << nSlotId ); @@ -1318,9 +1316,9 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b nSubId |= CONVERT_TWIPS; DBG_ASSERT(( pType->aAttrib[n-1].nAID ) <= 127, "Member ID out of range" ); - pValue[nActProp].Name = pSlot->pUnoName + + pValue[nActProp].Name = pSlot->aUnoName + "." + - OUString::createFromAscii( pType->aAttrib[n-1].pName ); + pType->aAttrib[n-1].aName; if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) ) { SAL_WARN( "sfx", "Sub item " << pType->aAttrib[n-1].nAID @@ -1347,7 +1345,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b sal_uInt16 nSubCount = rArg.pType->nAttribs; if ( !nSubCount ) { - pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) ; + pValue[nActProp].Name = rArg.aName; if ( !pItem->QueryValue( pValue[nActProp++].Value ) ) { SAL_WARN( "sfx", "Item not convertible: " << rArg.nSlotId ); @@ -1363,9 +1361,9 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b nSubId |= CONVERT_TWIPS; DBG_ASSERT((rArg.pType->aAttrib[n-1].nAID) <= 127, "Member ID out of range" ); - pValue[nActProp].Name = OUString::createFromAscii( rArg.pName ) + + pValue[nActProp].Name = rArg.aName + "." + - OUString::createFromAscii( rArg.pType->aAttrib[n-1].pName ) ; + rArg.pType->aAttrib[n-1].aName ; if ( !pItem->QueryValue( pValue[nActProp++].Value, nSubId ) ) { SAL_WARN( "sfx", "Sub item " diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index f07287ee631c..a56174b96d94 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1513,7 +1513,7 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, std::unique_ptr<SfxPoolI if ( xDisp.is() || !pCache ) { const SfxSlot* pSlot = SfxSlotPool::GetSlotPool( pDispatcher->GetFrame() ).GetSlot( nSlot ); - if ( !pSlot || pSlot->pUnoName.isEmpty() ) + if ( !pSlot || pSlot->aUnoName.isEmpty() ) return SfxItemState::DISABLED; css::util::URL aURL; diff --git a/sfx2/source/control/msg.cxx b/sfx2/source/control/msg.cxx index c15c46c86f66..9df69d00c5d4 100644 --- a/sfx2/source/control/msg.cxx +++ b/sfx2/source/control/msg.cxx @@ -45,10 +45,10 @@ sal_uInt16 SfxSlot::GetWhich( const SfxItemPool &rPool ) const OUString SfxSlot::GetCommand() const { - if("FocusToFindbar" == pUnoName) - return "vnd.sun.star.findbar:" + pUnoName; + if("FocusToFindbar" == aUnoName) + return "vnd.sun.star.findbar:" + aUnoName; else - return ".uno:" + pUnoName; + return ".uno:" + aUnoName; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index e58475c325f1..edb17a3f8bb3 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -576,10 +576,10 @@ void SfxRequest::Done_Impl // recordable? // new Recording uses UnoName! - SAL_WARN_IF( pImpl->pSlot->pUnoName.isEmpty(), "sfx", "Recording not exported slot: " + SAL_WARN_IF( pImpl->pSlot->aUnoName.isEmpty(), "sfx", "Recording not exported slot: " << pImpl->pSlot->GetSlotId() ); - if ( pImpl->pSlot->pUnoName.isEmpty() ) // playing it safe + if ( pImpl->pSlot->aUnoName.isEmpty() ) // playing it safe return; // often required values diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 3511d33ff69d..f368d3d2824d 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -562,7 +562,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& if (nSlotId > SID_VERB_END) break; - SfxSlot* pNewSlot = new SfxSlot( + SfxSlot* pNewSlot = new SfxSlot{ nSlotId, SfxGroupId::NONE, // Verb slots must be executed asynchronously, so that they can be // destroyed while executing. @@ -570,7 +570,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& 0, 0, SFX_STUB_PTR(SfxShell, VerbExec), SFX_STUB_PTR(SfxShell, VerbState), nullptr, // HACK(SFX_TYPE(SfxVoidItem)) ??? - nullptr, nullptr, 0, SfxDisableFlags::NONE, ""); + nullptr, nullptr, 0, SfxDisableFlags::NONE, u""_ustr}; if (!pImpl->aSlotArr.empty()) { diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index 7ce4f11e3ff2..daf1f37a56c3 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -245,7 +245,7 @@ const SfxSlotServer* SfxStateCache::GetSlotServer( SfxDispatcher &rDispat , cons // get the slot - even if it is disabled on the dispatcher pSlot = SfxSlotPool::GetSlotPool( rDispat.GetFrame() ).GetSlot( nId ); - if ( !pSlot || pSlot->pUnoName.isEmpty() ) + if ( !pSlot || pSlot->aUnoName.isEmpty() ) { bSlotDirty = false; bCtrlDirty = true; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index c6250e27d170..7d518f435d81 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -335,7 +335,7 @@ SfxDispatchController_Impl::SfxDispatchController_Impl( , bMasterSlave( false ) , bVisible( true ) { - if ( aDispatchURL.Protocol == "slot:" && !pSlot->pUnoName.isEmpty() ) + if ( aDispatchURL.Protocol == "slot:" && !pSlot->aUnoName.isEmpty() ) { aDispatchURL.Complete = pSlot->GetCommand(); Reference< XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) ); @@ -658,7 +658,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, sal_Int32 nIndex = lNewArgs.getLength(); lNewArgs.realloc( nIndex+1 ); auto plNewArgs = lNewArgs.getArray(); - plNewArgs[nIndex].Name = pSlot->pUnoName; + plNewArgs[nIndex].Name = pSlot->aUnoName; plNewArgs[nIndex].Value <<= SfxDispatchController_Impl::getSlaveCommand( aDispatchURL ); }
