diff options
author | Brad Sowden <code@sowden.org> | 2012-01-05 23:55:18 +1300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-05-09 12:09:31 +0100 |
commit | f802b568d639950c2f8005cf143fd628cc29a3a0 (patch) | |
tree | dd31da5d5f608ea137dd7b0166b8e6b0e140446d /sw | |
parent | 93a7ad0b686ec772a3988256a7856f2130cf8ae7 (diff) |
AutoText: fix segfault when delete/rename action applied while group selected.
In the Edit -> AutoText dialog, if an entry is selected and then a group
selected the delete/rename/etc actions are still shown in the "AutoText" menu
when they should not be. These actions are only applicable to entries and if
a user attempts to apply these actions while a group is selected the list box
becomes corrupted and leads to a segfault (the code for these actions
assumes the selected entry has a parent in the listbox).
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index ce888c1aab2f..044402b95350 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -449,25 +449,23 @@ IMPL_LINK_INLINE_END( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox ) IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn ) { + SvLBoxEntry* pEntry = aCategoryBox.FirstSelected(); + const String aEditText(aNameED.GetText()); const sal_Bool bHasEntry = aEditText.Len() && aShortNameEdit.GetText().Len(); const sal_Bool bExists = 0 != DoesBlockExist(aEditText, aShortNameEdit.GetText()); + const sal_Bool bIsGroup = pEntry && !aCategoryBox.GetParent(pEntry); pMn->EnableItem(FN_GL_DEFINE, bSelection && bHasEntry && !bExists); pMn->EnableItem(FN_GL_DEFINE_TEXT, bSelection && bHasEntry && !bExists); - pMn->EnableItem(FN_GL_COPY_TO_CLIPBOARD, bExists); - pMn->EnableItem(FN_GL_REPLACE, bSelection && bExists && !bIsOld ); - pMn->EnableItem(FN_GL_REPLACE_TEXT, bSelection && bExists && !bIsOld ); - pMn->EnableItem(FN_GL_EDIT, bExists ); - pMn->EnableItem(FN_GL_RENAME, bExists ); - pMn->EnableItem(FN_GL_DELETE, bExists ); - pMn->EnableItem(FN_GL_MACRO, bExists && !bIsOld && + pMn->EnableItem(FN_GL_COPY_TO_CLIPBOARD, bExists && !bIsGroup); + pMn->EnableItem(FN_GL_REPLACE, bSelection && bExists && !bIsGroup && !bIsOld ); + pMn->EnableItem(FN_GL_REPLACE_TEXT, bSelection && bExists && !bIsGroup && !bIsOld ); + pMn->EnableItem(FN_GL_EDIT, bExists && !bIsGroup ); + pMn->EnableItem(FN_GL_RENAME, bExists && !bIsGroup ); + pMn->EnableItem(FN_GL_DELETE, bExists && !bIsGroup ); + pMn->EnableItem(FN_GL_MACRO, bExists && !bIsGroup && !bIsOld && !pGlossaryHdl->IsReadOnly() ); - - SvLBoxEntry* pEntry = aCategoryBox.FirstSelected(); - sal_Bool bEnable = sal_False; - if ( pEntry ) - bEnable = !aCategoryBox.GetParent( pEntry ) && !bIsOld && !pGlossaryHdl->IsReadOnly(); - pMn->EnableItem( FN_GL_IMPORT, bEnable ); + pMn->EnableItem( FN_GL_IMPORT, bIsGroup && !bIsOld && !pGlossaryHdl->IsReadOnly() ); return 1; } |