LibreOffice Module sw (master) 1
textglos.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sfx2/request.hxx>
21#include <svl/eitem.hxx>
22#include <svl/stritem.hxx>
23#include <osl/diagnose.h>
24
25#include <view.hxx>
26#include <cmdid.h>
27#include <textsh.hxx>
28#include <initui.hxx>
29#include <gloshdl.hxx>
30#include <glosdoc.hxx>
31#include <gloslst.hxx>
32#include <swabstdlg.hxx>
33
35{
36 const sal_uInt16 nSlot = rReq.GetSlot();
38 FN_GLOSSARY_DLG == nSlot );
39 SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
40 // Update SwGlossaryList?
41 bool bUpdateList = false;
42
43 const SfxItemSet *pArgs = rReq.GetArgs();
44 const SfxPoolItem* pItem = nullptr;
45 if(pArgs)
46 pArgs->GetItemState(nSlot, false, &pItem );
47
48 switch( nSlot )
49 {
50 case FN_GLOSSARY_DLG:
51 pGlosHdl->GlossaryDlg();
52 bUpdateList = true;
53 rReq.Ignore();
54 break;
56 {
57 bool bReturn;
58 bReturn = pGlosHdl->ExpandGlossary(rReq.GetFrameWeld());
59 rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) );
60 rReq.Done();
61 }
62 break;
63 case FN_NEW_GLOSSARY:
64 if(pItem && pArgs->Count() == 3 )
65 {
66 OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
67 OUString aName;
68 if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
69 aName = static_cast<const SfxStringItem *>(pItem)->GetValue();
70 OUString aShortName;
71 if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_2, false, &pItem ))
72 aShortName = static_cast<const SfxStringItem *>(pItem)->GetValue();
73
75 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
76 if ( fnSetActGroup )
77 (*fnSetActGroup)( aGroup );
78 pGlosHdl->SetCurGroup(aGroup, true);
79 // Chosen group must be created in NewGlossary if necessary!
80 pGlosHdl->NewGlossary( aName, aShortName, true );
81 rReq.Done();
82 }
83 bUpdateList = true;
84 break;
86 if(pItem)
87 {
88 OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
90 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
91 if ( fnSetActGroup )
92 (*fnSetActGroup)( aGroup );
93 rReq.Done();
94 }
95 break;
97 {
98 if(pItem && pArgs->Count() > 1)
99 {
100 OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
101 OUString aName;
102 if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
103 aName = static_cast<const SfxStringItem *>(pItem)->GetValue();
105 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
106 if ( fnSetActGroup )
107 (*fnSetActGroup)( aGroup );
108 pGlosHdl->SetCurGroup(aGroup, true);
109 rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName )));
110 rReq.Done();
111 }
112 }
113 break;
114 default:
115 OSL_FAIL("wrong dispatcher");
116 return;
117 }
118 if(bUpdateList)
119 {
121 if(pList->IsActive())
122 pList->Update();
123 }
124}
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetValue() const
sal_uInt16 Count() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
void SetReturnValue(const SfxPoolItem &)
weld::Window * GetFrameWeld() const
bool IsAPI() const
void Done(bool bRemove=false)
virtual GlossarySetActGroup SetGlossaryActGroupFunc()=0
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
SwView & GetView()
Definition: basesh.hxx:59
void UpdateGlosPath(bool bFull)
Definition: glosdoc.cxx:348
bool ExpandGlossary(weld::Window *pParent)
Definition: gloshdl.cxx:344
void GlossaryDlg()
Definition: gloshdl.cxx:69
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:512
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
Definition: gloshdl.cxx:95
bool NewGlossary(const OUString &rName, const OUString &rShortName, bool bApiCall=false, bool bNoAttr=false)
Definition: gloshdl.cxx:286
void Update()
Definition: gloslst.cxx:232
void ExecGlossary(SfxRequest &)
Definition: textglos.cxx:34
SwGlossaryHdl * GetGlosHdl()
Definition: view.cxx:1675
bool IsActive() const
#define FN_NEW_GLOSSARY
Definition: cmdid.h:616
#define FN_SET_ACT_GLOSSARY
Definition: cmdid.h:617
#define FN_EXPAND_GLOSSARY
Definition: cmdid.h:524
#define FN_INSERT_GLOSSARY
Definition: cmdid.h:615
#define FN_GLOSSARY_DLG
Definition: cmdid.h:522
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:174
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
Definition: initui.cxx:162
OUString aName
const char GetValue[]
void(* GlossarySetActGroup)(const OUString &rNewGroup)
Definition: swabstdlg.hxx:88