1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <sfx2/request.hxx> 33 #include <svl/eitem.hxx> 34 #include <svl/stritem.hxx> 35 36 #include "errhdl.hxx" 37 #include "view.hxx" 38 #include "initui.hxx" 39 #include "cmdid.h" 40 #include "textsh.hxx" 41 #include "initui.hxx" 42 #include "gloshdl.hxx" 43 #include "glosdoc.hxx" 44 #include "gloslst.hxx" 45 #include "swabstdlg.hxx" 46 #include <misc.hrc> 47 48 // STATIC DATA ----------------------------------------------------------- 49 50 void SwTextShell::ExecGlossary(SfxRequest &rReq) 51 { 52 sal_uInt16 nSlot = rReq.GetSlot(); 53 ::GetGlossaries()->UpdateGlosPath(!rReq.IsAPI() || 54 FN_GLOSSARY_DLG == nSlot ); 55 SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl(); 56 // SwGlossaryList updaten? 57 sal_Bool bUpdateList = sal_False; 58 59 const SfxItemSet *pArgs = rReq.GetArgs(); 60 const SfxPoolItem* pItem = 0; 61 if(pArgs) 62 pArgs->GetItemState(nSlot, sal_False, &pItem ); 63 64 switch( nSlot ) 65 { 66 case FN_GLOSSARY_DLG: 67 pGlosHdl->GlossaryDlg(); 68 bUpdateList = sal_True; 69 rReq.Ignore(); 70 break; 71 case FN_EXPAND_GLOSSARY: 72 { 73 sal_Bool bReturn; 74 bReturn = pGlosHdl->ExpandGlossary(); 75 rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) ); 76 rReq.Done(); 77 } 78 break; 79 case FN_NEW_GLOSSARY: 80 if(pItem && pArgs->Count() == 3 ) 81 { 82 String aGroup = (( const SfxStringItem *)pItem)->GetValue(); 83 String aName; 84 if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem )) 85 aName = (( const SfxStringItem *)pItem)->GetValue(); 86 String aShortName; 87 if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_2, sal_False, &pItem )) 88 aShortName = (( const SfxStringItem *)pItem)->GetValue(); 89 90 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 91 DBG_ASSERT(pFact, "Dialogdiet fail!"); 92 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); 93 if ( fnSetActGroup ) 94 (*fnSetActGroup)( aGroup ); 95 pGlosHdl->SetCurGroup(aGroup, sal_True); 96 //eingestellte Gruppe muss in NewGlossary ggf. erzeugt werden! 97 pGlosHdl->NewGlossary( aName, aShortName, sal_True ); 98 rReq.Done(); 99 } 100 bUpdateList = sal_True; 101 break; 102 case FN_SET_ACT_GLOSSARY: 103 if(pItem) 104 { 105 String aGroup = (( const SfxStringItem *)pItem)->GetValue(); 106 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 107 DBG_ASSERT(pFact, "Dialogdiet fail!"); 108 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); 109 if ( fnSetActGroup ) 110 (*fnSetActGroup)( aGroup ); 111 rReq.Done(); 112 } 113 break; 114 case FN_INSERT_GLOSSARY: 115 { 116 if(pItem && pArgs->Count() > 1) 117 { 118 String aGroup = (( const SfxStringItem *)pItem)->GetValue(); 119 String aName; 120 if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem )) 121 aName = (( const SfxStringItem *)pItem)->GetValue(); 122 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 123 DBG_ASSERT(pFact, "Dialogdiet fail!"); 124 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); 125 if ( fnSetActGroup ) 126 (*fnSetActGroup)( aGroup ); 127 pGlosHdl->SetCurGroup(aGroup, sal_True); 128 rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName ))); 129 rReq.Done(); 130 } 131 } 132 break; 133 default: 134 ASSERT(sal_False, falscher Dispatcher); 135 return; 136 } 137 if(bUpdateList) 138 { 139 SwGlossaryList* pList = ::GetGlossaryList(); 140 if(pList->IsActive()) 141 pList->Update(); 142 } 143 } 144 145 146