[Libreoffice-commits] .: sw/source

Michael Meeks michael at kemper.freedesktop.org
Wed May 9 04:11:23 PDT 2012


 sw/source/ui/misc/glossary.cxx |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit f802b568d639950c2f8005cf143fd628cc29a3a0
Author: Brad Sowden <code at sowden.org>
Date:   Thu Jan 5 23:55:18 2012 +1300

    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).

diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index ce888c1..044402b 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;
 }
 


More information about the Libreoffice-commits mailing list