diff options
Diffstat (limited to 'cui/source/customize/cfg.cxx')
-rw-r--r-- | cui/source/customize/cfg.cxx | 423 |
1 files changed, 2 insertions, 421 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index af75d2a2af30..31a56d32941d 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -58,6 +58,7 @@ #include "acccfg.hxx" #include "cfg.hxx" +#include "SvxMenuConfigPage.hxx" #include "eventdlg.hxx" #include <dialmgr.hxx> @@ -2353,427 +2354,7 @@ bool SvxConfigPage::MoveEntryData( return false; } -SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSet, bool bIsMenuBar) - : SvxConfigPage(pParent, rSet) - , m_bIsMenuBar( bIsMenuBar ) -{ - m_pContentsListBox = VclPtr<SvxMenuEntriesListBox>::Create(m_pEntries, this); - m_pContentsListBox->set_grid_left_attach(0); - m_pContentsListBox->set_grid_top_attach(0); - m_pContentsListBox->set_hexpand(true); - m_pContentsListBox->set_vexpand(true); - m_pContentsListBox->Show(); - - m_pAddSubmenuButton->Enable(); - m_pAddSubmenuButton->Show(); - - m_pTopLevelListBox->SetSelectHdl( - LINK( this, SvxMenuConfigPage, SelectMenu ) ); - - m_pContentsListBox->SetSelectHdl( - LINK( this, SvxMenuConfigPage, SelectMenuEntry ) ); - - m_pMoveUpButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) ); - m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) ); - - m_pNewTopLevelButton->SetClickHdl ( - LINK( this, SvxMenuConfigPage, NewMenuHdl ) ); - - m_pAddCommandsButton->SetClickHdl ( - LINK( this, SvxMenuConfigPage, AddCommandsHdl ) ); - - m_pAddSeparatorButton->SetClickHdl ( - LINK( this, SvxMenuConfigPage, AddSeparatorHdl ) ); - - m_pAddSubmenuButton->SetClickHdl ( - LINK( this, SvxMenuConfigPage, AddSubmenuHdl ) ); - - m_pDeleteCommandButton->SetClickHdl ( - LINK( this, SvxMenuConfigPage, DeleteCommandHdl ) ); - - PopupMenu* pMenu = m_pModifyTopLevelButton->GetPopupMenu(); - pMenu->SetMenuFlags( - pMenu->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries ); - - m_pModifyTopLevelButton->SetSelectHdl( - LINK( this, SvxMenuConfigPage, MenuSelectHdl ) ); - - PopupMenu* pEntry = m_pModifyCommandButton->GetPopupMenu(); - pEntry->SetMenuFlags( - pEntry->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries ); - - m_pModifyCommandButton->SetSelectHdl( - LINK( this, SvxMenuConfigPage, EntrySelectHdl ) ); - - if ( !bIsMenuBar ) - { - m_pTopLevel->set_label( CuiResId( RID_SVXSTR_PRODUCTNAME_CONTEXTMENUS ) ); - m_pNewTopLevelButton->Hide(); - pMenu->HideItem( pMenu->GetItemId( "move" ) ); - pMenu->HideItem( pMenu->GetItemId( "menuitem3" ) ); - } -} - -SvxMenuConfigPage::~SvxMenuConfigPage() -{ - disposeOnce(); -} - -// Populates the Menu combo box -void SvxMenuConfigPage::Init() -{ - // ensure that the UI is cleared before populating it - m_pTopLevelListBox->Clear(); - m_pContentsListBox->Clear(); - - ReloadTopLevelListBox(); - - m_pTopLevelListBox->SelectEntryPos(0); - m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox); -} - -void SvxMenuConfigPage::dispose() -{ - for ( sal_Int32 i = 0 ; i < m_pSaveInListBox->GetEntryCount(); ++i ) - { - delete static_cast<SaveInData*>(m_pSaveInListBox->GetEntryData( i )); - } - m_pSaveInListBox->Clear(); - - SvxConfigPage::dispose(); -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenuEntry, SvTreeListBox *, void ) -{ - UpdateButtonStates(); -} - -void SvxMenuConfigPage::UpdateButtonStates() -{ - PopupMenu* pPopup = m_pModifyCommandButton->GetPopupMenu(); - - // Disable Up and Down buttons depending on current selection - SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry(); - - if ( m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr ) - { - m_pMoveUpButton->Enable( false ); - m_pMoveDownButton->Enable( false ); - m_pDeleteCommandButton->Enable(false); - - pPopup->EnableItem( "modrename", false ); - - m_pDescriptionField->SetText(""); - - return; - } - - SvTreeListEntry* first = m_pContentsListBox->First(); - SvTreeListEntry* last = m_pContentsListBox->Last(); - - m_pMoveUpButton->Enable( selection != first ); - m_pMoveDownButton->Enable( selection != last ); - - SvxConfigEntry* pEntryData = - static_cast<SvxConfigEntry*>(selection->GetUserData()); - - if ( pEntryData->IsSeparator() ) - { - pPopup->EnableItem( "modrename", false ); - - m_pDescriptionField->SetText(""); - - m_pAddSeparatorButton->Enable( false ); - m_pDeleteCommandButton->Enable(); - } - else - { - pPopup->EnableItem( "modrename" ); - - m_pDeleteCommandButton->Enable(); - m_pAddSeparatorButton->Enable(); - - m_pDescriptionField->SetText(pEntryData->GetHelpText()); - } -} - -void SvxMenuConfigPage::DeleteSelectedTopLevel() -{ - SvxConfigEntry* pMenuData = GetTopLevelSelection(); - - SvxEntries* pParentEntries = - FindParentForChild( GetSaveInData()->GetEntries(), pMenuData ); - - RemoveEntry( pParentEntries, pMenuData ); - delete pMenuData; - - ReloadTopLevelListBox(); - - GetSaveInData()->SetModified( ); -} - -void SvxMenuConfigPage::DeleteSelectedContent() -{ - SvTreeListEntry *pActEntry = m_pContentsListBox->FirstSelected(); - - if ( pActEntry != nullptr ) - { - // get currently selected menu entry - SvxConfigEntry* pMenuEntry = - static_cast<SvxConfigEntry*>(pActEntry->GetUserData()); - - // get currently selected menu - SvxConfigEntry* pMenu = GetTopLevelSelection(); - - // remove menu entry from the list for this menu - RemoveEntry( pMenu->GetEntries(), pMenuEntry ); - - // remove menu entry from UI - m_pContentsListBox->GetModel()->Remove( pActEntry ); - - // if this is a submenu entry, redraw the menus list box - if ( pMenuEntry->IsPopup() ) - { - ReloadTopLevelListBox(); - } - - // delete data for menu entry - delete pMenuEntry; - - GetSaveInData()->SetModified(); - pMenu->SetModified(); - } -} - -short SvxMenuConfigPage::QueryReset() -{ - OUString msg = CuiResId( RID_SVXSTR_CONFIRM_MENU_RESET ); - - OUString saveInName = m_pSaveInListBox->GetEntry( - m_pSaveInListBox->GetSelectEntryPos() ); - - OUString label = replaceSaveInName( msg, saveInName ); - - ScopedVclPtrInstance<QueryBox> qbox( this, WB_YES_NO, label ); - - return qbox->Execute(); -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void ) -{ - m_pContentsListBox->Clear(); - - SvxConfigEntry* pMenuData = GetTopLevelSelection(); - m_pModifyTopLevelButton->Enable( pMenuData != nullptr ); - m_pModifyCommandButton->Enable( pMenuData != nullptr ); - m_pAddCommandsButton->Enable( pMenuData != nullptr ); - m_pAddSeparatorButton->Enable( pMenuData != nullptr ); - m_pAddSubmenuButton->Enable( pMenuData != nullptr ); - - PopupMenu* pPopup = m_pModifyTopLevelButton->GetPopupMenu(); - if ( pMenuData ) - { - pPopup->EnableItem( "delete", pMenuData->IsDeletable() ); - pPopup->EnableItem( "rename", pMenuData->IsRenamable() ); - pPopup->EnableItem( "move", pMenuData->IsMovable() ); - - SvxEntries* pEntries = pMenuData->GetEntries(); - SvxEntries::const_iterator iter = pEntries->begin(); - - for ( ; iter != pEntries->end(); ++iter ) - { - SvxConfigEntry* pEntry = *iter; - InsertEntryIntoUI( pEntry ); - } - } - - UpdateButtonStates(); -} - -IMPL_LINK( SvxMenuConfigPage, MenuSelectHdl, MenuButton *, pButton, void ) -{ - OString sIdent = pButton->GetCurItemIdent(); - - if (sIdent == "delete") - { - DeleteSelectedTopLevel(); - } - else if (sIdent == "rename") - { - SvxConfigEntry* pMenuData = GetTopLevelSelection(); - - OUString aNewName( stripHotKey( pMenuData->GetName() ) ); - OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME ); - - VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc ); - pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU ); - pNameDialog->SetText( CuiResId( RID_SVXSTR_RENAME_MENU ) ); - - if ( pNameDialog->Execute() == RET_OK ) { - pNameDialog->GetName( aNewName ); - pMenuData->SetName( aNewName ); - - ReloadTopLevelListBox(); - - GetSaveInData()->SetModified(); - } - } - else if (sIdent == "move") - { - SvxConfigEntry* pMenuData = GetTopLevelSelection(); - - VclPtr<SvxMainMenuOrganizerDialog> pDialog( - VclPtr<SvxMainMenuOrganizerDialog>::Create( this, - GetSaveInData()->GetEntries(), pMenuData )); - - if ( pDialog->Execute() == RET_OK ) - { - GetSaveInData()->SetEntries( pDialog->GetEntries() ); - - ReloadTopLevelListBox( pDialog->GetSelectedEntry() ); - - GetSaveInData()->SetModified(); - } - } -} - -IMPL_LINK( SvxMenuConfigPage, EntrySelectHdl, MenuButton *, pButton, void ) -{ - OString sIdent = pButton->GetCurItemIdent(); - if (sIdent == "modrename") - { - SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry(); - SvxConfigEntry* pEntry = - static_cast<SvxConfigEntry*>(pActEntry->GetUserData()); - - OUString aNewName( stripHotKey( pEntry->GetName() ) ); - OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME ); - - VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc ); - pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU_ITEM ); - pNameDialog->SetText( CuiResId( RID_SVXSTR_RENAME_MENU ) ); - - if ( pNameDialog->Execute() == RET_OK ) { - pNameDialog->GetName(aNewName); - - pEntry->SetName( aNewName ); - m_pContentsListBox->SetEntryText( pActEntry, aNewName ); - - GetSaveInData()->SetModified(); - GetTopLevelSelection()->SetModified(); - } - } - else - { - return; - } - - if ( GetSaveInData()->IsModified() ) - { - UpdateButtonStates(); - } -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, AddFunctionHdl, SvxScriptSelectorDialog&, void ) -{ - AddFunction(); -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, NewMenuHdl, Button *, void ) -{ - VclPtrInstance<SvxMainMenuOrganizerDialog> pDialog( - nullptr, GetSaveInData()->GetEntries(), nullptr, true ); - - if ( pDialog->Execute() == RET_OK ) - { - GetSaveInData()->SetEntries( pDialog->GetEntries() ); - ReloadTopLevelListBox( pDialog->GetSelectedEntry() ); - GetSaveInData()->SetModified(); - } -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandsHdl, Button *, void ) -{ - if ( m_pSelectorDlg == nullptr ) - { - // Create Script Selector which also shows builtin commands - m_pSelectorDlg = VclPtr<SvxScriptSelectorDialog>::Create( this, true, m_xFrame ); - - m_pSelectorDlg->SetAddHdl( - LINK( this, SvxMenuConfigPage, AddFunctionHdl ) ); - - m_pSelectorDlg->SetDialogDescription( CuiResId( RID_SVXSTR_MENU_ADDCOMMANDS_DESCRIPTION ) ); - } - - // Position the Script Selector over the Add button so it is - // beside the menu contents list and does not obscure it - m_pSelectorDlg->SetPosPixel( m_pAddCommandsButton->GetPosPixel() ); - - m_pSelectorDlg->SetImageProvider( GetSaveInData() ); - - m_pSelectorDlg->Execute(); -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, AddSeparatorHdl, Button *, void ) -{ - SvxConfigEntry* pNewEntryData = new SvxConfigEntry; - pNewEntryData->SetUserDefined(); - InsertEntry( pNewEntryData ); - - if ( GetSaveInData()->IsModified() ) - { - UpdateButtonStates(); - } -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, AddSubmenuHdl, Button *, void ) -{ - OUString aNewName; - OUString aDesc = CuiResId( RID_SVXSTR_SUBMENU_NAME ); - - VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc ); - pNameDialog->SetHelpId( HID_SVX_CONFIG_NAME_SUBMENU ); - pNameDialog->SetText( CuiResId( RID_SVXSTR_ADD_SUBMENU ) ); - - if ( pNameDialog->Execute() == RET_OK ) - { - pNameDialog->GetName(aNewName); - - SvxConfigEntry* pNewEntryData = - new SvxConfigEntry( aNewName, aNewName, true ); - pNewEntryData->SetName( aNewName ); - pNewEntryData->SetUserDefined(); - - InsertEntry( pNewEntryData ); - - ReloadTopLevelListBox(); - - GetSaveInData()->SetModified(); - - UpdateButtonStates(); - } -} - -IMPL_LINK_NOARG( SvxMenuConfigPage, DeleteCommandHdl, Button *, void ) -{ - DeleteSelectedContent(); - if ( GetSaveInData()->IsModified() ) - { - UpdateButtonStates(); - } -} - -SaveInData* SvxMenuConfigPage::CreateSaveInData( - const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr, - const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr, - const OUString& aModuleId, - bool bDocConfig ) -{ - if ( !m_bIsMenuBar ) - return static_cast< SaveInData* >( new ContextMenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ) ); - - return static_cast< SaveInData* >( new MenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ) ); -} +// SvxMenuConfigPage was here SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( vcl::Window* pParent, SvxEntries* entries, |