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