diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-11-01 15:32:51 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-11-01 15:32:51 +0100 |
commit | b8cfd18781873e188239b7c9b90983b74368d445 (patch) | |
tree | 2a5510da1573662cf354b47f5908918d1fe0dc98 /cui | |
parent | 99375cc6d3ec82912918f95c60bf60e930dbbe46 (diff) |
undoapi: get rid of the usage of SfxMacroConfig::GetSlotId: the only thing done here is creating an SfxMacroInfo instance, whose only usage is the macro name (nowadays: script name) it carries. This can be done cheaper, by just carrying the string. The slot ID was never actually used.
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/customize/cfgutil.cxx | 26 | ||||
-rw-r--r-- | cui/source/inc/cfgutil.hxx | 11 | ||||
-rw-r--r-- | cui/source/tabpages/macroass.cxx | 49 | ||||
-rw-r--r-- | cui/source/tabpages/macroass.src | 2 |
4 files changed, 31 insertions, 57 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index f501a334beed..b778da8e3814 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -352,9 +352,8 @@ void SfxConfigFunctionListBox_Impl::ClearAll() if ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) { - SfxMacroInfo *pInfo = (SfxMacroInfo*) pData->pObject; - SFX_APP()->GetMacroConfig()->ReleaseSlotId( pInfo->GetSlotId() ); - delete pInfo; + String* pScriptURI = (String*)pData->pObject; + delete pScriptURI; } if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER @@ -374,20 +373,16 @@ void SfxConfigFunctionListBox_Impl::ClearAll() Clear(); } -SfxMacroInfo* SfxConfigFunctionListBox_Impl::GetMacroInfo() -/* Beschreibung - Gibt die MacroInfo des selektierten Entry zur"uck ( sofern vorhanden ). -*/ +String SfxConfigFunctionListBox_Impl::GetSelectedScriptURI() { SvLBoxEntry *pEntry = FirstSelected(); if ( pEntry ) { SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData(); if ( pData && ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) ) - return (SfxMacroInfo*) pData->pObject; + return *(String*)pData->pObject; } - - return 0; + return String(); } String SfxConfigFunctionListBox_Impl::GetCurCommand() @@ -1007,7 +1002,7 @@ void SfxConfigGroupListBox_Impl::GroupSelected() { case SFX_CFGGROUP_FUNCTION : { - USHORT nGroup = pInfo->nOrd; + USHORT nGroup = pInfo->nUniqueID; css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW); css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup); sal_Int32 c = lCommands.getLength(); @@ -1056,13 +1051,8 @@ void SfxConfigGroupListBox_Impl::GroupSelected() xPropSet->getPropertyValue( String::CreateFromAscii( "URI" ) ); value >>= uri; - SfxMacroInfo* aInfo = new SfxMacroInfo( (String)uri ); - aInfo->SetHelpText( uri ); - SFX_APP()->GetMacroConfig()->GetSlotId( aInfo ); - - SfxGroupInfo_Impl* pGrpInfo = - new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SCRIPT, - aInfo->GetSlotId(), aInfo); + String* pScriptURI = new String( uri ); + SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGFUNCTION_SCRIPT, 0, pScriptURI ); Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL ); SvLBoxEntry* pNewEntry = diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx index ea4271d18035..66238e7ac7f3 100644 --- a/cui/source/inc/cfgutil.hxx +++ b/cui/source/inc/cfgutil.hxx @@ -50,7 +50,6 @@ class SfxSlotPool; class SfxStringItem; class SfxFontItem; class SfxMacroInfoItem; -class SfxMacroInfo; struct SfxStyleInfo_Impl; struct SfxStylesInfo_Impl; @@ -104,14 +103,18 @@ struct SfxStylesInfo_Impl struct SfxGroupInfo_Impl { USHORT nKind; - USHORT nOrd; + USHORT nUniqueID; void* pObject; BOOL bWasOpened; String sCommand; String sLabel; SfxGroupInfo_Impl( USHORT n, USHORT nr, void* pObj = 0 ) : - nKind( n ), nOrd( nr ), pObject( pObj ), bWasOpened(FALSE) {} + nKind( n ), nUniqueID( nr ), pObject( pObj ), bWasOpened(FALSE) {} +}; + +struct CuiMacroInfo +{ }; typedef SfxGroupInfo_Impl* SfxGroupInfoPtr; @@ -137,7 +140,7 @@ public: String GetHelpText( SvLBoxEntry *pEntry ); String GetCurCommand(); String GetCurLabel(); - SfxMacroInfo* GetMacroInfo(); + String GetSelectedScriptURI(); void FunctionSelected(); void SetStylesInfo(SfxStylesInfo_Impl* pStyles); }; diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx index 62a450dde4c9..3d504ecdff55 100644 --- a/cui/source/tabpages/macroass.cxx +++ b/cui/source/tabpages/macroass.cxx @@ -164,13 +164,11 @@ void _SfxMacroTabPage::EnableButtons() String sEventMacro; sEventMacro = ((SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS ))->GetText(); - SfxMacroInfo* pInfo = mpImpl->pMacroLB->GetMacroInfo(); - String sSelMacro; - if ( pInfo ) - sSelMacro = pInfo->GetMacroName(); - - mpImpl->pAssignPB->Enable( pInfo && !mpImpl->bReadOnly && !sSelMacro.EqualsIgnoreCaseAscii( sEventMacro ) ); + String sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI(); + mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly && !sScriptURI.EqualsIgnoreCaseAscii( sEventMacro ) ); } + else + mpImpl->pAssignPB->Enable( FALSE ); } _SfxMacroTabPage::_SfxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet ) @@ -298,21 +296,13 @@ IMPL_STATIC_LINK( _SfxMacroTabPage, SelectGroup_Impl, ListBox*, EMPTYARG ) _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl; String sSel( pImpl->pGroupLB->GetGroup() ); pImpl->pGroupLB->GroupSelected(); - SfxMacroInfo* pMacro = pImpl->pMacroLB->GetMacroInfo(); + const String sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI(); String aLabelText; - if( pMacro ) - { + if( sScriptURI.Len() > 0 ) aLabelText = pImpl->maStaticMacroLBLabel; - aLabelText += pMacro->GetModuleName(); - } - else - { - // Wenn dort ein Macro drin ist, wurde es selektiert und der - // AssignButton schon in SelectMacro richtig enabled - pImpl->pAssignPB->Enable( FALSE ); - } - pImpl->pFT_MacroLBLabel->SetText( aLabelText ); + + pThis->EnableButtons(); return 0; } @@ -344,34 +334,25 @@ IMPL_STATIC_LINK( _SfxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn ) SvxMacro *pRemoveMacro = pThis->aTbl.Remove( nEvent ); delete pRemoveMacro; - String sNew; + String sScriptURI; if( bAssEnabled ) { - String sGroup; - String sMacro; - String aEntryText( sNew ); - - SfxMacroInfo* pMacro = pImpl->pMacroLB->GetMacroInfo(); - sMacro = pMacro->GetQualifiedName(); - sGroup = pImpl->pGroupLB->GetGroup(); - sNew = pMacro->GetMacroName(); - - if( sMacro.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL ) + sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI(); + if( sScriptURI.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL ) { - OSL_TRACE("ASSIGN_DELETE: Its a script"); pThis->aTbl.Insert( - nEvent, new SvxMacro( sMacro, String::CreateFromAscii( SVX_MACRO_LANGUAGE_SF ) ) ); + nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_SF ) ) ); } else { - OSL_TRACE("ASSIGN_DELETE: Its a basic macro"); + OSL_ENSURE( false, "_SfxMacroTabPage::AssignDeleteHdl_Impl: this branch is *not* dead??! (out of interest: tell fs, please!)" ); pThis->aTbl.Insert( - nEvent, new SvxMacro( sMacro, String::CreateFromAscii( SVX_MACRO_LANGUAGE_STARBASIC ) ) ); + nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_STARBASIC ) ) ); } } pImpl->pEventLB->SetUpdateMode( FALSE ); - pE->ReplaceItem( new SvLBoxString( pE, 0, sNew ), LB_MACROS_ITEMPOS ); + pE->ReplaceItem( new SvLBoxString( pE, 0, sScriptURI ), LB_MACROS_ITEMPOS ); rListBox.GetModel()->InvalidateEntry( pE ); rListBox.Select( pE ); rListBox.MakeVisible( pE ); diff --git a/cui/source/tabpages/macroass.src b/cui/source/tabpages/macroass.src index 8d20eadf25b6..05e81658b8a3 100644 --- a/cui/source/tabpages/macroass.src +++ b/cui/source/tabpages/macroass.src @@ -78,7 +78,7 @@ TabPage RID_SVXPAGE_EVENTASSIGN Pos = MAP_APPFONT ( COL2 , ROW7 ) ; Size = MAP_APPFONT ( WIDTH1 , RSC_CD_FIXEDTEXT_HEIGHT + HEIGHT_EXTRA7 ) ; WordBreak = TRUE; - Text [ en-US ] = "~Existing macros in:\n" ; + Text [ en-US ] = "~Existing macros\n" ; }; Control LB_MACROS { |