LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - textglos.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 63 1.6 %
Date: 2012-12-27 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <misc.hrc>
      33             : 
      34             : // STATIC DATA -----------------------------------------------------------
      35           0 : void SwTextShell::ExecGlossary(SfxRequest &rReq)
      36             : {
      37           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      38           0 :     ::GetGlossaries()->UpdateGlosPath(!rReq.IsAPI() ||
      39           0 :                                         FN_GLOSSARY_DLG == nSlot );
      40           0 :     SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
      41             :     // SwGlossaryList updaten?
      42           0 :     sal_Bool bUpdateList = sal_False;
      43             : 
      44           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
      45           0 :     const SfxPoolItem* pItem = 0;
      46           0 :     if(pArgs)
      47           0 :        pArgs->GetItemState(nSlot, sal_False, &pItem );
      48             : 
      49           0 :     switch( nSlot )
      50             :     {
      51             :         case FN_GLOSSARY_DLG:
      52           0 :             pGlosHdl->GlossaryDlg();
      53           0 :             bUpdateList = sal_True;
      54           0 :             rReq.Ignore();
      55           0 :             break;
      56             :         case FN_EXPAND_GLOSSARY:
      57             :         {
      58             :             sal_Bool bReturn;
      59           0 :             bReturn = pGlosHdl->ExpandGlossary();
      60           0 :             rReq.SetReturnValue( SfxBoolItem( nSlot, bReturn ) );
      61           0 :             rReq.Done();
      62             :         }
      63           0 :         break;
      64             :         case FN_NEW_GLOSSARY:
      65           0 :             if(pItem && pArgs->Count() == 3 )
      66             :             {
      67           0 :                 String aGroup = (( const SfxStringItem *)pItem)->GetValue();
      68           0 :                 String aName;
      69           0 :                 if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem ))
      70           0 :                     aName = (( const SfxStringItem *)pItem)->GetValue();
      71           0 :                 String aShortName;
      72           0 :                 if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_2, sal_False, &pItem ))
      73           0 :                     aShortName = (( const SfxStringItem *)pItem)->GetValue();
      74             : 
      75           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      76             :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
      77           0 :                 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
      78           0 :                 if ( fnSetActGroup )
      79           0 :                     (*fnSetActGroup)( aGroup );
      80           0 :                 pGlosHdl->SetCurGroup(aGroup, sal_True);
      81             :                 //eingestellte Gruppe muss in NewGlossary ggf. erzeugt werden!
      82           0 :                 pGlosHdl->NewGlossary( aName, aShortName, sal_True );
      83           0 :                 rReq.Done();
      84             :             }
      85           0 :             bUpdateList = sal_True;
      86           0 :         break;
      87             :         case FN_SET_ACT_GLOSSARY:
      88           0 :             if(pItem)
      89             :             {
      90           0 :                 String aGroup = (( const SfxStringItem *)pItem)->GetValue();
      91           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      92             :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
      93           0 :                 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
      94           0 :                 if ( fnSetActGroup )
      95           0 :                     (*fnSetActGroup)( aGroup );
      96           0 :                 rReq.Done();
      97             :             }
      98           0 :         break;
      99             :         case FN_INSERT_GLOSSARY:
     100             :         {
     101           0 :             if(pItem && pArgs->Count() > 1)
     102             :             {
     103           0 :                 String aGroup = (( const SfxStringItem *)pItem)->GetValue();
     104           0 :                 String aName;
     105           0 :                 if(SFX_ITEM_SET ==  pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem ))
     106           0 :                     aName = (( const SfxStringItem *)pItem)->GetValue();
     107           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     108             :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
     109           0 :                 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
     110           0 :                 if ( fnSetActGroup )
     111           0 :                     (*fnSetActGroup)( aGroup );
     112           0 :                 pGlosHdl->SetCurGroup(aGroup, sal_True);
     113           0 :                 rReq.SetReturnValue(SfxBoolItem(nSlot, pGlosHdl->InsertGlossary( aName ) ? sal_True : sal_False));
     114           0 :                 rReq.Done();
     115             :             }
     116             :         }
     117           0 :         break;
     118             :         default:
     119             :             OSL_FAIL("wrong dispatcher");
     120           0 :             return;
     121             :     }
     122           0 :     if(bUpdateList)
     123             :     {
     124           0 :         SwGlossaryList* pList = ::GetGlossaryList();
     125           0 :         if(pList->IsActive())
     126           0 :             pList->Update();
     127             :     }
     128          30 : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10