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 
24 #include <view.hxx>
25 #include <cmdid.h>
26 #include <textsh.hxx>
27 #include <initui.hxx>
28 #include <gloshdl.hxx>
29 #include <glosdoc.hxx>
30 #include <gloslst.hxx>
31 #include <swabstdlg.hxx>
32 
34 {
35  const sal_uInt16 nSlot = rReq.GetSlot();
37  FN_GLOSSARY_DLG == nSlot );
38  SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
39  // Update SwGlossaryList?
40  bool bUpdateList = false;
41 
42  const SfxItemSet *pArgs = rReq.GetArgs();
43  const SfxPoolItem* pItem = nullptr;
44  if(pArgs)
45  pArgs->GetItemState(nSlot, false, &pItem );
46 
47  switch( nSlot )
48  {
49  case FN_GLOSSARY_DLG:
50  pGlosHdl->GlossaryDlg();
51  bUpdateList = true;
52  rReq.Ignore();
53  break;
54  case FN_EXPAND_GLOSSARY:
55  {
56  bool bReturn;
57  bReturn = pGlosHdl->ExpandGlossary(rReq.GetFrameWeld());
58  rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) );
59  rReq.Done();
60  }
61  break;
62  case FN_NEW_GLOSSARY:
63  if(pItem && pArgs->Count() == 3 )
64  {
65  OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
66  OUString aName;
67  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
68  aName = static_cast<const SfxStringItem *>(pItem)->GetValue();
69  OUString aShortName;
70  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_2, false, &pItem ))
71  aShortName = static_cast<const SfxStringItem *>(pItem)->GetValue();
72 
74  ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
75  if ( fnSetActGroup )
76  (*fnSetActGroup)( aGroup );
77  pGlosHdl->SetCurGroup(aGroup, true);
78  // Chosen group must be created in NewGlossary if necessary!
79  pGlosHdl->NewGlossary( aName, aShortName, true );
80  rReq.Done();
81  }
82  bUpdateList = true;
83  break;
85  if(pItem)
86  {
87  OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
89  ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
90  if ( fnSetActGroup )
91  (*fnSetActGroup)( aGroup );
92  rReq.Done();
93  }
94  break;
95  case FN_INSERT_GLOSSARY:
96  {
97  if(pItem && pArgs->Count() > 1)
98  {
99  OUString aGroup = static_cast<const SfxStringItem *>(pItem)->GetValue();
100  OUString aName;
101  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem ))
102  aName = static_cast<const SfxStringItem *>(pItem)->GetValue();
104  ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
105  if ( fnSetActGroup )
106  (*fnSetActGroup)( aGroup );
107  pGlosHdl->SetCurGroup(aGroup, true);
108  rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName )));
109  rReq.Done();
110  }
111  }
112  break;
113  default:
114  OSL_FAIL("wrong dispatcher");
115  return;
116  }
117  if(bUpdateList)
118  {
120  if(pList->IsActive())
121  pList->Update();
122  }
123 }
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwView & GetView()
Definition: basesh.hxx:57
std::string GetValue
void(* GlossarySetActGroup)(const OUString &rNewGroup)
Definition: swabstdlg.hxx:86
void Update()
Definition: gloslst.cxx:227
void Done(bool bRemove=false)
const SfxItemSet * GetArgs() const
bool IsActive() const
#define FN_EXPAND_GLOSSARY
Definition: cmdid.h:478
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
Definition: gloshdl.cxx:102
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
Definition: initui.cxx:165
#define FN_INSERT_GLOSSARY
Definition: cmdid.h:567
void GlossaryDlg()
Definition: gloshdl.cxx:76
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define FN_GLOSSARY_DLG
Definition: cmdid.h:476
sal_uInt16 Count() const
bool ExpandGlossary(weld::Window *pParent)
Definition: gloshdl.cxx:329
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
void UpdateGlosPath(bool bFull)
Definition: glosdoc.cxx:349
void SetReturnValue(const SfxPoolItem &)
weld::Window * GetFrameWeld() const
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:497
sal_uInt16 GetSlot() const
#define FN_SET_ACT_GLOSSARY
Definition: cmdid.h:569
SwGlossaryHdl * GetGlosHdl()
Definition: view.cxx:1625
OString const aName
bool IsAPI() const
virtual GlossarySetActGroup SetGlossaryActGroupFunc()=0
bool NewGlossary(const OUString &rName, const OUString &rShortName, bool bApiCall=false, bool bNoAttr=false)
Definition: gloshdl.cxx:271
void Ignore()
void ExecGlossary(SfxRequest &)
Definition: textglos.cxx:33
#define FN_NEW_GLOSSARY
Definition: cmdid.h:568
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:177