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