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