xref: /aoo42x/main/sw/source/ui/shells/textglos.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <sfx2/request.hxx>
29cdf0e10cSrcweir #include <svl/eitem.hxx>
30cdf0e10cSrcweir #include <svl/stritem.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "errhdl.hxx"
33cdf0e10cSrcweir #include "view.hxx"
34cdf0e10cSrcweir #include "initui.hxx"
35cdf0e10cSrcweir #include "cmdid.h"
36cdf0e10cSrcweir #include "textsh.hxx"
37cdf0e10cSrcweir #include "initui.hxx"
38cdf0e10cSrcweir #include "gloshdl.hxx"
39cdf0e10cSrcweir #include "glosdoc.hxx"
40cdf0e10cSrcweir #include "gloslst.hxx"
41cdf0e10cSrcweir #include "swabstdlg.hxx"
42cdf0e10cSrcweir #include <misc.hrc>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
45cdf0e10cSrcweir 
ExecGlossary(SfxRequest & rReq)46cdf0e10cSrcweir void SwTextShell::ExecGlossary(SfxRequest &rReq)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
49cdf0e10cSrcweir 	::GetGlossaries()->UpdateGlosPath(!rReq.IsAPI() ||
50cdf0e10cSrcweir 										FN_GLOSSARY_DLG == nSlot );
51cdf0e10cSrcweir 	SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
52cdf0e10cSrcweir 	// SwGlossaryList updaten?
53cdf0e10cSrcweir 	sal_Bool bUpdateList = sal_False;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	const SfxItemSet *pArgs = rReq.GetArgs();
56cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
57cdf0e10cSrcweir 	if(pArgs)
58cdf0e10cSrcweir 	   pArgs->GetItemState(nSlot, sal_False, &pItem );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	switch( nSlot )
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 		case FN_GLOSSARY_DLG:
63cdf0e10cSrcweir 			pGlosHdl->GlossaryDlg();
64cdf0e10cSrcweir 			bUpdateList = sal_True;
65cdf0e10cSrcweir             rReq.Ignore();
66cdf0e10cSrcweir 			break;
67cdf0e10cSrcweir 		case FN_EXPAND_GLOSSARY:
68cdf0e10cSrcweir 		{
69cdf0e10cSrcweir 			sal_Bool bReturn;
70cdf0e10cSrcweir             bReturn = pGlosHdl->ExpandGlossary();
71cdf0e10cSrcweir 			rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) );
72cdf0e10cSrcweir             rReq.Done();
73cdf0e10cSrcweir 		}
74cdf0e10cSrcweir 		break;
75cdf0e10cSrcweir 		case FN_NEW_GLOSSARY:
76cdf0e10cSrcweir 			if(pItem && pArgs->Count() == 3 )
77cdf0e10cSrcweir 			{
78cdf0e10cSrcweir 				String aGroup = (( const SfxStringItem *)pItem)->GetValue();
79cdf0e10cSrcweir 				String aName;
80cdf0e10cSrcweir 				if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem ))
81cdf0e10cSrcweir 					aName = (( const SfxStringItem *)pItem)->GetValue();
82cdf0e10cSrcweir 				String aShortName;
83cdf0e10cSrcweir 				if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_2, sal_False, &pItem ))
84cdf0e10cSrcweir 					aShortName = (( const SfxStringItem *)pItem)->GetValue();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
87cdf0e10cSrcweir                 DBG_ASSERT(pFact, "Dialogdiet fail!");
88cdf0e10cSrcweir 				::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
89cdf0e10cSrcweir 				if ( fnSetActGroup )
90cdf0e10cSrcweir 					(*fnSetActGroup)( aGroup );
91cdf0e10cSrcweir 				pGlosHdl->SetCurGroup(aGroup, sal_True);
92cdf0e10cSrcweir 				//eingestellte Gruppe muss in NewGlossary ggf. erzeugt werden!
93cdf0e10cSrcweir 				pGlosHdl->NewGlossary( aName, aShortName, sal_True );
94cdf0e10cSrcweir                 rReq.Done();
95cdf0e10cSrcweir 			}
96cdf0e10cSrcweir 			bUpdateList = sal_True;
97cdf0e10cSrcweir 		break;
98cdf0e10cSrcweir 		case FN_SET_ACT_GLOSSARY:
99cdf0e10cSrcweir 			if(pItem)
100cdf0e10cSrcweir 			{
101cdf0e10cSrcweir 				String aGroup = (( const SfxStringItem *)pItem)->GetValue();
102cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
103cdf0e10cSrcweir                 DBG_ASSERT(pFact, "Dialogdiet fail!");
104cdf0e10cSrcweir 				::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
105cdf0e10cSrcweir 				if ( fnSetActGroup )
106cdf0e10cSrcweir 					(*fnSetActGroup)( aGroup );
107cdf0e10cSrcweir 				rReq.Done();
108cdf0e10cSrcweir 			}
109cdf0e10cSrcweir 		break;
110cdf0e10cSrcweir 		case FN_INSERT_GLOSSARY:
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			if(pItem && pArgs->Count() > 1)
113cdf0e10cSrcweir 			{
114cdf0e10cSrcweir 				String aGroup = (( const SfxStringItem *)pItem)->GetValue();
115cdf0e10cSrcweir 				String aName;
116cdf0e10cSrcweir 				if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem ))
117cdf0e10cSrcweir 					aName = (( const SfxStringItem *)pItem)->GetValue();
118cdf0e10cSrcweir 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
119cdf0e10cSrcweir                 DBG_ASSERT(pFact, "Dialogdiet fail!");
120cdf0e10cSrcweir 				::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
121cdf0e10cSrcweir 				if ( fnSetActGroup )
122cdf0e10cSrcweir 					(*fnSetActGroup)( aGroup );
123cdf0e10cSrcweir 				pGlosHdl->SetCurGroup(aGroup, sal_True);
124cdf0e10cSrcweir                 rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName )));
125cdf0e10cSrcweir                 rReq.Done();
126cdf0e10cSrcweir 			}
127cdf0e10cSrcweir 		}
128cdf0e10cSrcweir 		break;
129cdf0e10cSrcweir 		default:
130cdf0e10cSrcweir 			ASSERT(sal_False, falscher Dispatcher);
131cdf0e10cSrcweir 			return;
132cdf0e10cSrcweir 	}
133cdf0e10cSrcweir 	if(bUpdateList)
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		SwGlossaryList* pList = ::GetGlossaryList();
136cdf0e10cSrcweir 		if(pList->IsActive())
137cdf0e10cSrcweir 			pList->Update();
138cdf0e10cSrcweir 	}
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
142