1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/request.hxx>
21 #include <svl/eitem.hxx>
22 #include <svl/stritem.hxx>
23 #include <osl/diagnose.h>
29 #include <gloshdl.hxx>
30 #include <glosdoc.hxx>
31 #include <gloslst.hxx>
32 #include <swabstdlg.hxx>
34 void SwTextShell::ExecGlossary(SfxRequest
&rReq
)
36 const sal_uInt16 nSlot
= rReq
.GetSlot();
37 ::GetGlossaries()->UpdateGlosPath(!rReq
.IsAPI() ||
38 FN_GLOSSARY_DLG
== nSlot
);
39 SwGlossaryHdl
* pGlosHdl
= GetView().GetGlosHdl();
40 // Update SwGlossaryList?
41 bool bUpdateList
= false;
43 const SfxItemSet
*pArgs
= rReq
.GetArgs();
44 const SfxPoolItem
* pItem
= nullptr;
46 pArgs
->GetItemState(nSlot
, false, &pItem
);
51 pGlosHdl
->GlossaryDlg();
55 case FN_EXPAND_GLOSSARY
:
58 bReturn
= pGlosHdl
->ExpandGlossary(rReq
.GetFrameWeld());
59 rReq
.SetReturnValue( SfxBoolItem( nSlot
, bReturn
) );
64 if(pItem
&& pArgs
->Count() == 3 )
66 OUString aGroup
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
68 if(SfxItemState::SET
== pArgs
->GetItemState(FN_PARAM_1
, false, &pItem
))
69 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
71 if(SfxItemState::SET
== pArgs
->GetItemState(FN_PARAM_2
, false, &pItem
))
72 aShortName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
74 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
75 ::GlossarySetActGroup fnSetActGroup
= pFact
->SetGlossaryActGroupFunc();
77 (*fnSetActGroup
)( aGroup
);
78 pGlosHdl
->SetCurGroup(aGroup
, true);
79 // Chosen group must be created in NewGlossary if necessary!
80 pGlosHdl
->NewGlossary( aName
, aShortName
, true );
85 case FN_SET_ACT_GLOSSARY
:
88 OUString aGroup
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
89 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
90 ::GlossarySetActGroup fnSetActGroup
= pFact
->SetGlossaryActGroupFunc();
92 (*fnSetActGroup
)( aGroup
);
96 case FN_INSERT_GLOSSARY
:
98 if(pItem
&& pArgs
->Count() > 1)
100 OUString aGroup
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
102 if(SfxItemState::SET
== pArgs
->GetItemState(FN_PARAM_1
, false, &pItem
))
103 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
104 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
105 ::GlossarySetActGroup fnSetActGroup
= pFact
->SetGlossaryActGroupFunc();
107 (*fnSetActGroup
)( aGroup
);
108 pGlosHdl
->SetCurGroup(aGroup
, true);
109 rReq
.SetReturnValue(SfxBoolItem(nSlot
, pGlosHdl
->InsertGlossary( aName
)));
115 OSL_FAIL("wrong dispatcher");
120 SwGlossaryList
* pList
= ::GetGlossaryList();
121 if(pList
->IsActive())
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */