LCOV - code coverage report
Current view: top level - sw/source/ui/dochdl - gloshdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 383 4.4 %
Date: 2012-08-25 Functions: 4 32 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 840 1.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <hintids.hxx>
      30                 :            : #include <editeng/wghtitem.hxx>
      31                 :            : #include <editeng/adjitem.hxx>
      32                 :            : #ifndef __RSC //autogen
      33                 :            : #include <tools/errinf.hxx>
      34                 :            : #endif
      35                 :            : #include <vcl/msgbox.hxx>
      36                 :            : #include <svl/macitem.hxx>
      37                 :            : #include <sfx2/fcontnr.hxx>
      38                 :            : #include <sfx2/docfile.hxx>
      39                 :            : #include <svl/urihelper.hxx>
      40                 :            : #include <unotools/transliterationwrapper.hxx>
      41                 :            : #include <poolfmt.hxx>
      42                 :            : #include <fmtcol.hxx>
      43                 :            : #include <docary.hxx>
      44                 :            : #include <wrtsh.hxx>
      45                 :            : #include <uitool.hxx>                   // error messages
      46                 :            : #include <view.hxx>
      47                 :            : #include <swevent.hxx>
      48                 :            : #include <gloshdl.hxx>
      49                 :            : #include <glosdoc.hxx>
      50                 :            : #include <shellio.hxx>
      51                 :            : #include <swundo.hxx>                   // for Undo-Ids
      52                 :            : #include <expfld.hxx>
      53                 :            : #include <initui.hxx>                   // for ::GetGlossaries()
      54                 :            : #include <gloslst.hxx>
      55                 :            : #include <swdtflvr.hxx>
      56                 :            : #include <docsh.hxx>
      57                 :            : #include <crsskip.hxx>
      58                 :            : 
      59                 :            : #include <dochdl.hrc>
      60                 :            : #include <swerror.h>
      61                 :            : #include <frmmgr.hxx>
      62                 :            : #include <vcl/lstbox.hxx>
      63                 :            : 
      64                 :            : #include <editeng/acorrcfg.hxx>
      65                 :            : #include "swabstdlg.hxx"
      66                 :            : #include <misc.hrc>
      67                 :            : 
      68                 :            : #include <IDocumentFieldsAccess.hxx>
      69                 :            : 
      70                 :            : using namespace ::com::sun::star;
      71                 :            : 
      72                 :            : 
      73                 :            : const short RET_EDIT = 100;
      74                 :            : 
      75                 :            : // PUBLIC METHODS -------------------------------------------------------
      76 [ #  # ][ #  # ]:          0 : struct TextBlockInfo_Impl
         [ #  # ][ #  # ]
      77                 :            : {
      78                 :            :     String sTitle;
      79                 :            :     String sLongName;
      80                 :            :     String sGroupName;
      81                 :            : };
      82                 :            : typedef boost::ptr_vector<TextBlockInfo_Impl> TextBlockInfoArr;
      83         [ +  + ]:         10 : SV_IMPL_REF( SwDocShell )
      84                 :            : 
      85                 :            : /*------------------------------------------------------------------------
      86                 :            :     Description:    Dialog for edit templates
      87                 :            : ------------------------------------------------------------------------*/
      88                 :          0 : void SwGlossaryHdl::GlossaryDlg()
      89                 :            : {
      90         [ #  # ]:          0 :     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      91                 :            :     OSL_ENSURE(pFact, "Dialogdiet fail!");
      92                 :            :     AbstractGlossaryDlg* pDlg = pFact->CreateGlossaryDlg( DLG_RENAME_GLOS,
      93         [ #  # ]:          0 :                                                         pViewFrame, this, pWrtShell);
      94                 :            :     OSL_ENSURE(pDlg, "Dialogdiet fail!");
      95 [ #  # ][ #  # ]:          0 :     String sName, sShortName;
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 :     if( RET_EDIT == pDlg->Execute() )
      98                 :            :     {
      99 [ #  # ][ #  # ]:          0 :         sName = pDlg->GetCurrGrpName();
                 [ #  # ]
     100 [ #  # ][ #  # ]:          0 :         sShortName = pDlg->GetCurrShortName();
                 [ #  # ]
     101                 :            :     }
     102                 :            : 
     103 [ #  # ][ #  # ]:          0 :     delete pDlg;
     104 [ #  # ][ #  # ]:          0 :     DELETEZ(pCurGrp);
     105 [ #  # ][ #  # ]:          0 :     if(HasGlossaryList())
     106                 :            :     {
     107 [ #  # ][ #  # ]:          0 :         GetGlossaryList()->ClearGroups();
     108                 :            :     }
     109                 :            : 
     110 [ #  # ][ #  # ]:          0 :     if( sName.Len() || sShortName.Len() )
                 [ #  # ]
     111 [ #  # ][ #  # ]:          0 :         rStatGlossaries.EditGroupDoc( sName, sShortName );
         [ #  # ][ #  # ]
     112                 :          0 : }
     113                 :            : 
     114                 :            : /*------------------------------------------------------------------------
     115                 :            :     Description:    set the default group; if called from the dialog
     116                 :            :                     the group is created temporarily for faster access
     117                 :            : ------------------------------------------------------------------------*/
     118                 :          0 : void SwGlossaryHdl::SetCurGroup(const String &rGrp, sal_Bool bApi, sal_Bool bAlwaysCreateNew )
     119                 :            : {
     120         [ #  # ]:          0 :     String sGroup(rGrp);
     121 [ #  # ][ #  # ]:          0 :     if(STRING_NOTFOUND == sGroup.Search(GLOS_DELIM) && !FindGroupName(sGroup))
         [ #  # ][ #  # ]
                 [ #  # ]
     122                 :            :     {
     123         [ #  # ]:          0 :         sGroup += GLOS_DELIM;
     124         [ #  # ]:          0 :         sGroup += '0';
     125                 :            :     }
     126         [ #  # ]:          0 :     if(pCurGrp)
     127                 :            :     {
     128                 :          0 :         sal_Bool bPathEqual = sal_False;
     129         [ #  # ]:          0 :         if(!bAlwaysCreateNew)
     130                 :            :         {
     131 [ #  # ][ #  # ]:          0 :             INetURLObject aTemp( pCurGrp->GetFileName() );
                 [ #  # ]
     132 [ #  # ][ #  # ]:          0 :             String sCurBase = aTemp.getBase();
     133         [ #  # ]:          0 :             aTemp.removeSegment();
     134 [ #  # ][ #  # ]:          0 :             const String sCurEntryPath = aTemp.GetMainURL(INetURLObject::NO_DECODE);
     135                 :            :             const std::vector<String> & rPathArr =
     136                 :          0 :                 rStatGlossaries.GetPathArray();
     137                 :          0 :             sal_uInt16 nCurrentPath = USHRT_MAX;
     138         [ #  # ]:          0 :             for (size_t nPath = 0; nPath < rPathArr.size(); ++nPath)
     139                 :            :             {
     140 [ #  # ][ #  # ]:          0 :                 if (sCurEntryPath == rPathArr[nPath])
                 [ #  # ]
     141                 :            :                 {
     142                 :          0 :                     nCurrentPath = static_cast<sal_uInt16>(nPath);
     143                 :          0 :                     break;
     144                 :            :                 }
     145                 :            :             }
     146         [ #  # ]:          0 :             String sPath = sGroup.GetToken(1, GLOS_DELIM);
     147         [ #  # ]:          0 :             sal_uInt16 nComparePath = (sal_uInt16)sPath.ToInt32();
     148 [ #  # ][ #  # ]:          0 :             if(nCurrentPath == nComparePath &&
                 [ #  # ]
     149 [ #  # ][ #  # ]:          0 :                 sGroup.GetToken(0, GLOS_DELIM) == sCurBase)
         [ #  # ][ #  # ]
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :                 bPathEqual = sal_True;
         [ #  # ][ #  # ]
     151                 :            :         }
     152                 :            : 
     153                 :            :         // When path changed, the name is not reliable
     154 [ #  # ][ #  # ]:          0 :         if(!bAlwaysCreateNew && bPathEqual)
     155                 :          0 :             return;
     156                 :            :     }
     157         [ #  # ]:          0 :     aCurGrp = sGroup;
     158         [ #  # ]:          0 :     if(!bApi)
     159                 :            :     {
     160         [ #  # ]:          0 :         if(pCurGrp)
     161                 :            :         {
     162         [ #  # ]:          0 :             rStatGlossaries.PutGroupDoc(pCurGrp);
     163                 :          0 :             pCurGrp = 0;
     164                 :            :         }
     165         [ #  # ]:          0 :         pCurGrp = rStatGlossaries.GetGroupDoc(aCurGrp, sal_True);
     166 [ #  # ][ #  # ]:          0 :     }
     167                 :            : }
     168                 :            : 
     169                 :          0 : sal_uInt16 SwGlossaryHdl::GetGroupCnt() const
     170                 :            : {
     171                 :          0 :     return rStatGlossaries.GetGroupCnt();
     172                 :            : }
     173                 :            : 
     174                 :          0 : String SwGlossaryHdl::GetGroupName( sal_uInt16 nId, String* pTitle )
     175                 :            : {
     176                 :          0 :     String sRet = rStatGlossaries.GetGroupName(nId);
     177         [ #  # ]:          0 :     if(pTitle)
     178                 :            :     {
     179         [ #  # ]:          0 :         SwTextBlocks* pGroup = rStatGlossaries.GetGroupDoc(sRet, sal_False);
     180 [ #  # ][ #  # ]:          0 :         if(pGroup && !pGroup->GetError())
                 [ #  # ]
     181                 :            :         {
     182 [ #  # ][ #  # ]:          0 :             *pTitle = pGroup->GetName();
     183         [ #  # ]:          0 :             if(!pTitle->Len())
     184                 :            :             {
     185 [ #  # ][ #  # ]:          0 :                 *pTitle = sRet.GetToken(0, GLOS_DELIM);
                 [ #  # ]
     186         [ #  # ]:          0 :                 pGroup->SetName(*pTitle);
     187                 :            :             }
     188         [ #  # ]:          0 :             rStatGlossaries.PutGroupDoc( pGroup );
     189                 :            :         }
     190                 :            :         else
     191         [ #  # ]:          0 :             sRet.Erase();
     192                 :            :     }
     193                 :          0 :     return sRet;
     194                 :            : }
     195                 :            : 
     196                 :          0 : sal_Bool SwGlossaryHdl::NewGroup(String &rGrpName, const String& rTitle)
     197                 :            : {
     198         [ #  # ]:          0 :     if(STRING_NOTFOUND == rGrpName.Search(GLOS_DELIM))
     199                 :          0 :         FindGroupName(rGrpName);
     200                 :          0 :     return rStatGlossaries.NewGroupDoc(rGrpName, rTitle);
     201                 :            : }
     202                 :            : 
     203                 :          0 : sal_Bool SwGlossaryHdl::RenameGroup(const String & rOld, String& rNew, const String& rNewTitle)
     204                 :            : {
     205                 :          0 :     sal_Bool bRet = sal_False;
     206         [ #  # ]:          0 :     String sOldGroup(rOld);
     207 [ #  # ][ #  # ]:          0 :     if(STRING_NOTFOUND == rOld.Search(GLOS_DELIM))
     208         [ #  # ]:          0 :         FindGroupName(sOldGroup);
     209 [ #  # ][ #  # ]:          0 :     if(rOld == rNew)
     210                 :            :     {
     211         [ #  # ]:          0 :         SwTextBlocks* pGroup = rStatGlossaries.GetGroupDoc(sOldGroup, sal_False);
     212         [ #  # ]:          0 :         if(pGroup)
     213                 :            :         {
     214         [ #  # ]:          0 :             pGroup->SetName(rNewTitle);
     215         [ #  # ]:          0 :             rStatGlossaries.PutGroupDoc( pGroup );
     216                 :          0 :             bRet = sal_True;
     217                 :            :         }
     218                 :            :     }
     219                 :            :     else
     220                 :            :     {
     221         [ #  # ]:          0 :         String sNewGroup(rNew);
     222 [ #  # ][ #  # ]:          0 :         if(STRING_NOTFOUND == sNewGroup.Search(GLOS_DELIM))
     223                 :            :         {
     224         [ #  # ]:          0 :             sNewGroup += GLOS_DELIM;
     225         [ #  # ]:          0 :             sNewGroup += '0';
     226                 :            :         }
     227         [ #  # ]:          0 :         bRet = rStatGlossaries.RenameGroupDoc(sOldGroup, sNewGroup, rNewTitle);
     228 [ #  # ][ #  # ]:          0 :         rNew = sNewGroup;
     229                 :            :     }
     230         [ #  # ]:          0 :     return bRet;
     231                 :            : }
     232                 :            : 
     233                 :          0 : sal_Bool SwGlossaryHdl::CopyOrMove( const String& rSourceGroupName,  String& rSourceShortName,
     234                 :            :                         const String& rDestGroupName, const String& rLongName, sal_Bool bMove )
     235                 :            : {
     236                 :          0 :     SwTextBlocks* pSourceGroup = rStatGlossaries.GetGroupDoc(rSourceGroupName, sal_False);
     237                 :            : 
     238                 :          0 :     SwTextBlocks* pDestGroup = rStatGlossaries.GetGroupDoc(rDestGroupName, sal_False);
     239 [ #  # ][ #  # ]:          0 :     if(pDestGroup->IsReadOnly() || (bMove && pSourceGroup->IsReadOnly()) )
         [ #  # ][ #  # ]
     240                 :          0 :         return sal_False;
     241                 :            : 
     242                 :            :     //The index must be determined here because rSourceShortName maybe changed in CopyBlock
     243                 :          0 :     sal_uInt16 nDeleteIdx = pSourceGroup->GetIndex( rSourceShortName );
     244                 :            :     OSL_ENSURE(USHRT_MAX != nDeleteIdx, "entry not found");
     245                 :          0 :     sal_uLong nRet = pSourceGroup->CopyBlock( *pDestGroup, rSourceShortName, rLongName );
     246 [ #  # ][ #  # ]:          0 :     if(!nRet && bMove)
     247                 :            :     {
     248                 :            :         // the index must be existing
     249                 :          0 :         nRet = pSourceGroup->Delete( nDeleteIdx ) ? 0 : 1;
     250                 :            :     }
     251                 :          0 :     rStatGlossaries.PutGroupDoc( pSourceGroup );
     252                 :          0 :     rStatGlossaries.PutGroupDoc( pDestGroup );
     253                 :          0 :     return !nRet;
     254                 :            : }
     255                 :            : 
     256                 :            : /*------------------------------------------------------------------------
     257                 :            :     Description: delete a autotext-file-group
     258                 :            : ------------------------------------------------------------------------*/
     259                 :          0 : sal_Bool SwGlossaryHdl::DelGroup(const String &rGrpName)
     260                 :            : {
     261         [ #  # ]:          0 :     String sGroup(rGrpName);
     262 [ #  # ][ #  # ]:          0 :     if(STRING_NOTFOUND == sGroup.Search(GLOS_DELIM))
     263         [ #  # ]:          0 :         FindGroupName(sGroup);
     264 [ #  # ][ #  # ]:          0 :     if( rStatGlossaries.DelGroupDoc(sGroup) )
     265                 :            :     {
     266         [ #  # ]:          0 :         if(pCurGrp)
     267                 :            :         {
     268 [ #  # ][ #  # ]:          0 :             const String aMac_Tmp(pCurGrp->GetName());
     269 [ #  # ][ #  # ]:          0 :             if(aMac_Tmp == sGroup)
     270 [ #  # ][ #  # ]:          0 :                 DELETEZ(pCurGrp);
                 [ #  # ]
     271                 :            :         }
     272                 :          0 :         return sal_True;
     273                 :            :     }
     274         [ #  # ]:          0 :     return sal_False;
     275                 :            : }
     276                 :            : 
     277                 :            : /*------------------------------------------------------------------------
     278                 :            :     Description:    ask for number of autotexts
     279                 :            : ------------------------------------------------------------------------*/
     280                 :          0 : sal_uInt16 SwGlossaryHdl::GetGlossaryCnt()
     281                 :            : {
     282         [ #  # ]:          0 :     return pCurGrp ? pCurGrp->GetCount() : 0;
     283                 :            : }
     284                 :            : 
     285                 :          0 : String SwGlossaryHdl::GetGlossaryName( sal_uInt16 nId )
     286                 :            : {
     287                 :            :     OSL_ENSURE(nId < GetGlossaryCnt(), "Textbausteinarray ueberindiziert.");
     288                 :          0 :     return pCurGrp->GetLongName( nId );
     289                 :            : }
     290                 :            : 
     291                 :          0 : String  SwGlossaryHdl::GetGlossaryShortName(sal_uInt16 nId)
     292                 :            : {
     293                 :            :     OSL_ENSURE(nId < GetGlossaryCnt(), "Textbausteinarray ueberindiziert.");
     294                 :          0 :     return pCurGrp->GetShortName( nId );
     295                 :            : }
     296                 :            : 
     297                 :            : /*------------------------------------------------------------------------
     298                 :            :     Description:    ask for short name
     299                 :            : ------------------------------------------------------------------------*/
     300                 :          0 : String SwGlossaryHdl::GetGlossaryShortName(const String &rName)
     301                 :            : {
     302                 :          0 :     String sReturn;
     303                 :            :     SwTextBlocks *pTmp =
     304 [ #  # ][ #  # ]:          0 :         pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp, sal_False );
     305         [ #  # ]:          0 :     if(pTmp)
     306                 :            :     {
     307         [ #  # ]:          0 :         sal_uInt16 nIdx = pTmp->GetLongIndex( rName );
     308         [ #  # ]:          0 :         if( nIdx != (sal_uInt16) -1 )
     309 [ #  # ][ #  # ]:          0 :             sReturn = pTmp->GetShortName( nIdx );
     310         [ #  # ]:          0 :         if( !pCurGrp )
     311         [ #  # ]:          0 :             rStatGlossaries.PutGroupDoc( pTmp );
     312                 :            :     }
     313                 :          0 :     return sReturn;
     314                 :            : }
     315                 :            : 
     316                 :            : /*------------------------------------------------------------------------
     317                 :            :     Description:    short name for autotext already used?
     318                 :            : ------------------------------------------------------------------------*/
     319                 :          0 : sal_Bool SwGlossaryHdl::HasShortName(const String& rShortName) const
     320                 :            : {
     321                 :            :     SwTextBlocks *pBlock = pCurGrp ? pCurGrp
     322         [ #  # ]:          0 :                                    : rStatGlossaries.GetGroupDoc( aCurGrp );
     323                 :          0 :     sal_Bool bRet = pBlock->GetIndex( rShortName ) != (sal_uInt16) -1;
     324         [ #  # ]:          0 :     if( !pCurGrp )
     325                 :          0 :         rStatGlossaries.PutGroupDoc( pBlock );
     326                 :          0 :     return bRet;
     327                 :            : }
     328                 :            : 
     329                 :          0 : sal_Bool    SwGlossaryHdl::ConvertToNew(SwTextBlocks& /*rOld*/)
     330                 :            : {
     331                 :          0 :     return sal_True;
     332                 :            : }
     333                 :            : 
     334                 :            : /*------------------------------------------------------------------------
     335                 :            :     Desription:     Create autotext
     336                 :            : ------------------------------------------------------------------------*/
     337                 :          0 : sal_Bool SwGlossaryHdl::NewGlossary(const String& rName, const String& rShortName,
     338                 :            :                                 sal_Bool bCreateGroup, sal_Bool bNoAttr)
     339                 :            : {
     340                 :            :     SwTextBlocks *pTmp =
     341 [ #  # ][ #  # ]:          0 :         pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp, bCreateGroup );
     342                 :            :     //pTmp == 0 if the AutoText path setting is wrong
     343         [ #  # ]:          0 :     if(!pTmp)
     344                 :          0 :         return sal_False;
     345 [ #  # ][ #  # ]:          0 :     if(!ConvertToNew(*pTmp))
     346                 :          0 :         return sal_False;
     347                 :            : 
     348         [ #  # ]:          0 :     String sOnlyTxt;
     349                 :          0 :     String* pOnlyTxt = 0;
     350         [ #  # ]:          0 :     if( bNoAttr )
     351                 :            :     {
     352 [ #  # ][ #  # ]:          0 :         if( !pWrtShell->GetSelectedText( sOnlyTxt, GETSELTXT_PARABRK_TO_ONLYCR ))
     353                 :          0 :             return sal_False;
     354                 :          0 :         pOnlyTxt = &sOnlyTxt;
     355                 :            :     }
     356                 :            : 
     357         [ #  # ]:          0 :     const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
     358                 :            : 
     359                 :            :     const sal_uInt16 nSuccess = pWrtShell->MakeGlossary( *pTmp, rName, rShortName,
     360         [ #  # ]:          0 :                             rCfg.IsSaveRelFile(), pOnlyTxt );
     361         [ #  # ]:          0 :     if(nSuccess == (sal_uInt16) -1 )
     362                 :            :     {
     363 [ #  # ][ #  # ]:          0 :         InfoBox(pWrtShell->GetView().GetWindow(), SW_RES(MSG_ERR_INSERT_GLOS)).Execute();
                 [ #  # ]
     364                 :            :     }
     365         [ #  # ]:          0 :     if( !pCurGrp )
     366         [ #  # ]:          0 :         rStatGlossaries.PutGroupDoc( pTmp );
     367         [ #  # ]:          0 :     return sal_Bool( nSuccess != (sal_uInt16) -1 );
     368                 :            : }
     369                 :            : /*------------------------------------------------------------------------
     370                 :            :     Description:    Delete a autotext
     371                 :            : ------------------------------------------------------------------------*/
     372                 :          0 : sal_Bool SwGlossaryHdl::DelGlossary(const String &rShortName)
     373                 :            : {
     374                 :            :     SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
     375         [ #  # ]:          0 :                                     : rStatGlossaries.GetGroupDoc(aCurGrp);
     376                 :            :     //pTmp == 0 if the AutoText path setting is wrong
     377 [ #  # ][ #  # ]:          0 :     if(!pGlossary || !ConvertToNew(*pGlossary))
                 [ #  # ]
     378                 :          0 :         return sal_False;
     379                 :            : 
     380                 :          0 :     sal_uInt16 nIdx = pGlossary->GetIndex( rShortName );
     381         [ #  # ]:          0 :     if( nIdx != (sal_uInt16) -1 )
     382                 :          0 :         pGlossary->Delete( nIdx );
     383         [ #  # ]:          0 :     if( !pCurGrp )
     384                 :          0 :         rStatGlossaries.PutGroupDoc( pGlossary );
     385                 :          0 :     return sal_True;
     386                 :            : }
     387                 :            : 
     388                 :            : /*------------------------------------------------------------------------
     389                 :            :     Description: expand short name
     390                 :            : ------------------------------------------------------------------------*/
     391                 :          0 : sal_Bool SwGlossaryHdl::ExpandGlossary()
     392                 :            : {
     393                 :            :     OSL_ENSURE(pWrtShell->CanInsert(), "illegal");
     394                 :            :     SwTextBlocks *pGlossary;
     395         [ #  # ]:          0 :     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     396                 :            :     OSL_ENSURE(pFact, "Dialogdiet fail!");
     397         [ #  # ]:          0 :     ::GlossaryGetCurrGroup fnGetCurrGroup = pFact->GetGlossaryCurrGroupFunc( DLG_RENAME_GLOS );
     398                 :            :     OSL_ENSURE(fnGetCurrGroup, "Dialogdiet fail!");
     399         [ #  # ]:          0 :     String sGroupName( (*fnGetCurrGroup)() );
     400 [ #  # ][ #  # ]:          0 :     if(STRING_NOTFOUND == sGroupName.Search(GLOS_DELIM))
     401         [ #  # ]:          0 :         FindGroupName(sGroupName);
     402         [ #  # ]:          0 :     pGlossary = rStatGlossaries.GetGroupDoc(sGroupName);
     403                 :            : 
     404         [ #  # ]:          0 :     String aShortName;
     405                 :            : 
     406                 :            :         // use this at text selection
     407 [ #  # ][ #  # ]:          0 :     if(pWrtShell->SwCrsrShell::HasSelection() && !pWrtShell->IsBlockMode())
         [ #  # ][ #  # ]
     408                 :            :     {
     409 [ #  # ][ #  # ]:          0 :         aShortName = pWrtShell->GetSelTxt();
                 [ #  # ]
     410                 :            :     }
     411                 :            :     else
     412                 :            :     {
     413         [ #  # ]:          0 :         if(pWrtShell->IsAddMode())
     414         [ #  # ]:          0 :             pWrtShell->LeaveAddMode();
     415         [ #  # ]:          0 :         else if(pWrtShell->IsBlockMode())
     416         [ #  # ]:          0 :             pWrtShell->LeaveBlockMode();
     417         [ #  # ]:          0 :         else if(pWrtShell->IsExtMode())
     418         [ #  # ]:          0 :             pWrtShell->LeaveExtMode();
     419                 :            :         // select word
     420         [ #  # ]:          0 :         pWrtShell->SelNearestWrd();
     421                 :            :             // ask for word
     422         [ #  # ]:          0 :         if(pWrtShell->IsSelection())
     423 [ #  # ][ #  # ]:          0 :             aShortName = pWrtShell->GetSelTxt();
                 [ #  # ]
     424                 :            :     }
     425 [ #  # ][ #  # ]:          0 :     return pGlossary ? Expand( aShortName, &rStatGlossaries, pGlossary ) : sal_False;
         [ #  # ][ #  # ]
     426                 :            : }
     427                 :            : 
     428                 :          0 : sal_Bool SwGlossaryHdl::Expand( const String& rShortName,
     429                 :            :                             SwGlossaries *pGlossaries,
     430                 :            :                             SwTextBlocks *pGlossary  )
     431                 :            : {
     432         [ #  # ]:          0 :     TextBlockInfoArr aFoundArr;
     433         [ #  # ]:          0 :     String aShortName( rShortName );
     434                 :          0 :     sal_Bool bCancel = sal_False;
     435                 :            :     // search for text block
     436                 :            :     // - don't prefer current group depending on configuration setting
     437         [ #  # ]:          0 :     const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
     438 [ #  # ][ #  # ]:          0 :     sal_uInt16 nFound = !rCfg.IsSearchInAllCategories() ? pGlossary->GetIndex( aShortName ) : -1;
     439                 :            :     // if not found then search in all groups
     440         [ #  # ]:          0 :     if( nFound == (sal_uInt16) -1 )
     441                 :            :     {
     442         [ #  # ]:          0 :         const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
     443         [ #  # ]:          0 :         SwGlossaryList* pGlossaryList = ::GetGlossaryList();
     444         [ #  # ]:          0 :         sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount();
     445         [ #  # ]:          0 :         for(sal_uInt16 i = 1; i <= nGroupCount; i++)
     446                 :            :         {
     447                 :            :             // get group name with path-extension
     448         [ #  # ]:          0 :             String sTitle;
     449         [ #  # ]:          0 :             String sGroupName = pGlossaryList->GetGroupName(i - 1, sal_False, &sTitle);
     450 [ #  # ][ #  # ]:          0 :             if(sGroupName == pGlossary->GetName())
                 [ #  # ]
     451                 :          0 :                 continue;
     452         [ #  # ]:          0 :             sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
     453         [ #  # ]:          0 :             if(nBlockCount)
     454                 :            :             {
     455         [ #  # ]:          0 :                 for(sal_uInt16 j = 0; j < nBlockCount; j++)
     456                 :            :                 {
     457         [ #  # ]:          0 :                     String sEntry;
     458         [ #  # ]:          0 :                     String sLongName(pGlossaryList->GetBlockName(i - 1, j, sEntry));
     459 [ #  # ][ #  # ]:          0 :                     if( rSCmp.isEqual( rShortName, sEntry ))
     460                 :            :                     {
     461 [ #  # ][ #  # ]:          0 :                         TextBlockInfo_Impl* pData = new TextBlockInfo_Impl;
     462         [ #  # ]:          0 :                         pData->sTitle = sTitle;
     463         [ #  # ]:          0 :                         pData->sLongName = sLongName;
     464         [ #  # ]:          0 :                         pData->sGroupName = sGroupName;
     465         [ #  # ]:          0 :                         aFoundArr.push_back(pData);
     466                 :            :                     }
     467 [ #  # ][ #  # ]:          0 :                 }
     468                 :            :             }
     469 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
     470         [ #  # ]:          0 :         if( !aFoundArr.empty() )  // one was found
     471                 :            :         {
     472         [ #  # ]:          0 :             pGlossaries->PutGroupDoc(pGlossary);
     473         [ #  # ]:          0 :             if(1 == aFoundArr.size())
     474                 :            :             {
     475         [ #  # ]:          0 :                 TextBlockInfo_Impl* pData = &aFoundArr.front();
     476         [ #  # ]:          0 :                 pGlossary = (SwTextBlocks *)pGlossaries->GetGroupDoc(pData->sGroupName);
     477         [ #  # ]:          0 :                 nFound = pGlossary->GetIndex( aShortName );
     478                 :            :             }
     479                 :            :             else
     480                 :            :             {
     481         [ #  # ]:          0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     482                 :            :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     483                 :            : 
     484         [ #  # ]:          0 :                 AbstractSwSelGlossaryDlg* pDlg = pFact->CreateSwSelGlossaryDlg( 0, aShortName, DLG_SEL_GLOS );
     485                 :            :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     486         [ #  # ]:          0 :                 for(sal_uInt16 i = 0; i < aFoundArr.size(); ++i)
     487                 :            :                 {
     488         [ #  # ]:          0 :                     TextBlockInfo_Impl* pData = &aFoundArr[i];
     489         [ #  # ]:          0 :                     pDlg->InsertGlos(pData->sTitle, pData->sLongName);
     490                 :            :                 }
     491         [ #  # ]:          0 :                 pDlg->SelectEntryPos(0);
     492         [ #  # ]:          0 :                 const sal_uInt16 nRet = RET_OK == pDlg->Execute()?
     493                 :          0 :                                         pDlg->GetSelectedIdx():
     494 [ #  # ][ #  # ]:          0 :                                         LISTBOX_ENTRY_NOTFOUND;
     495 [ #  # ][ #  # ]:          0 :                 delete pDlg;
     496         [ #  # ]:          0 :                 if(LISTBOX_ENTRY_NOTFOUND != nRet)
     497                 :            :                 {
     498         [ #  # ]:          0 :                     TextBlockInfo_Impl* pData = &aFoundArr[nRet];
     499         [ #  # ]:          0 :                     pGlossary = (SwTextBlocks *)pGlossaries->GetGroupDoc(pData->sGroupName);
     500         [ #  # ]:          0 :                     nFound = pGlossary->GetIndex( aShortName );
     501                 :            :                 }
     502                 :            :                 else
     503                 :            :                 {
     504                 :          0 :                     nFound = (sal_uInt16) -1;
     505                 :          0 :                     bCancel = sal_True;
     506                 :            :                 }
     507                 :            :             }
     508                 :            :         }
     509                 :            :     }
     510                 :            : 
     511                 :            :     // not found
     512         [ #  # ]:          0 :     if( nFound == (sal_uInt16) -1 )
     513                 :            :     {
     514         [ #  # ]:          0 :         if( !bCancel )
     515                 :            :         {
     516         [ #  # ]:          0 :             pGlossaries->PutGroupDoc(pGlossary);
     517                 :            : 
     518                 :          0 :             const sal_uInt16 nMaxLen = 50;
     519 [ #  # ][ #  # ]:          0 :             if(pWrtShell->IsSelection() && aShortName.Len() > nMaxLen)
                 [ #  # ]
     520                 :            :             {
     521         [ #  # ]:          0 :                 aShortName.Erase(nMaxLen);
     522         [ #  # ]:          0 :                 aShortName.AppendAscii(" ...");
     523                 :            :             }
     524         [ #  # ]:          0 :             String aTmp( SW_RES(STR_NOGLOS));
     525         [ #  # ]:          0 :             aTmp.SearchAndReplaceAscii("%1", aShortName);
     526 [ #  # ][ #  # ]:          0 :             InfoBox( pWrtShell->GetView().GetWindow(), aTmp ).Execute();
         [ #  # ][ #  # ]
     527                 :            :         }
     528                 :            : 
     529                 :          0 :         return sal_False;
     530                 :            :     }
     531                 :            :     else
     532                 :            :     {
     533 [ #  # ][ #  # ]:          0 :         String aLongName = pGlossary->GetLongName( nFound );
     534 [ #  # ][ #  # ]:          0 :         SvxMacro aStartMacro(aEmptyStr, aEmptyStr, STARBASIC);
                 [ #  # ]
     535 [ #  # ][ #  # ]:          0 :         SvxMacro aEndMacro(aEmptyStr, aEmptyStr, STARBASIC);
                 [ #  # ]
     536         [ #  # ]:          0 :         GetMacros( aShortName, aStartMacro, aEndMacro, pGlossary );
     537                 :            : 
     538                 :            :     // StartAction must not be before HasSelection and DelRight,
     539                 :            :     // otherwise the possible Shell change gets delayed and
     540                 :            :     // API-programs would hang.
     541                 :            :     // Moreover the event macro must also not be called in an action
     542         [ #  # ]:          0 :         pWrtShell->StartUndo(UNDO_INSGLOSSARY);
     543         [ #  # ]:          0 :         if( aStartMacro.HasMacro() )
     544         [ #  # ]:          0 :             pWrtShell->ExecMacro( aStartMacro );
     545 [ #  # ][ #  # ]:          0 :         if(pWrtShell->HasSelection())
     546         [ #  # ]:          0 :             pWrtShell->DelLeft();
     547         [ #  # ]:          0 :         pWrtShell->StartAllAction();
     548                 :            : 
     549                 :            :         // cache all InputFields
     550         [ #  # ]:          0 :         SwInputFieldList aFldLst( pWrtShell, sal_True );
     551                 :            : 
     552         [ #  # ]:          0 :         pWrtShell->InsertGlossary(*pGlossary, aShortName);
     553         [ #  # ]:          0 :         pWrtShell->EndAllAction();
     554         [ #  # ]:          0 :         if( aEndMacro.HasMacro() )
     555                 :            :         {
     556         [ #  # ]:          0 :             pWrtShell->ExecMacro( aEndMacro );
     557                 :            :         }
     558         [ #  # ]:          0 :         pWrtShell->EndUndo(UNDO_INSGLOSSARY);
     559                 :            : 
     560                 :            :         // demand input for all new InputFields
     561 [ #  # ][ #  # ]:          0 :         if( aFldLst.BuildSortLst() )
     562 [ #  # ][ #  # ]:          0 :             pWrtShell->UpdateInputFlds( &aFldLst );
         [ #  # ][ #  # ]
                 [ #  # ]
     563                 :            :     }
     564         [ #  # ]:          0 :     pGlossaries->PutGroupDoc(pGlossary);
     565 [ #  # ][ #  # ]:          0 :     return sal_True;
     566                 :            : }
     567                 :            : 
     568                 :            : /*------------------------------------------------------------------------
     569                 :            :     Description: add autotext
     570                 :            : ------------------------------------------------------------------------*/
     571                 :          0 : sal_Bool SwGlossaryHdl::InsertGlossary(const String &rName)
     572                 :            : {
     573                 :            :     OSL_ENSURE(pWrtShell->CanInsert(), "illegal");
     574                 :            : 
     575                 :            :     SwTextBlocks *pGlos =
     576 [ #  # ][ #  # ]:          0 :         pCurGrp? pCurGrp: rStatGlossaries.GetGroupDoc(aCurGrp);
     577                 :            : 
     578         [ #  # ]:          0 :     if (!pGlos)
     579                 :          0 :         return sal_False;
     580                 :            : 
     581 [ #  # ][ #  # ]:          0 :     SvxMacro aStartMacro(aEmptyStr, aEmptyStr, STARBASIC);
                 [ #  # ]
     582 [ #  # ][ #  # ]:          0 :     SvxMacro aEndMacro(aEmptyStr, aEmptyStr, STARBASIC);
                 [ #  # ]
     583         [ #  # ]:          0 :     GetMacros( rName, aStartMacro, aEndMacro, pGlos );
     584                 :            : 
     585                 :            :     // StartAction must not be before HasSelection and DelRight,
     586                 :            :     // otherwise the possible Shell change gets delayed and
     587                 :            :     // API-programs would hang.
     588                 :            :     // Moreover the event macro must also not be called in an action
     589         [ #  # ]:          0 :     if( aStartMacro.HasMacro() )
     590         [ #  # ]:          0 :         pWrtShell->ExecMacro( aStartMacro );
     591 [ #  # ][ #  # ]:          0 :     if( pWrtShell->HasSelection() )
     592         [ #  # ]:          0 :         pWrtShell->DelRight();
     593         [ #  # ]:          0 :     pWrtShell->StartAllAction();
     594                 :            : 
     595                 :            :     // cache all InputFields
     596         [ #  # ]:          0 :     SwInputFieldList aFldLst( pWrtShell, sal_True );
     597                 :            : 
     598         [ #  # ]:          0 :     pWrtShell->InsertGlossary(*pGlos, rName);
     599         [ #  # ]:          0 :     pWrtShell->EndAllAction();
     600         [ #  # ]:          0 :     if( aEndMacro.HasMacro() )
     601                 :            :     {
     602         [ #  # ]:          0 :         pWrtShell->ExecMacro( aEndMacro );
     603                 :            :     }
     604                 :            : 
     605                 :            :     // demand input for all new InputFields
     606 [ #  # ][ #  # ]:          0 :     if( aFldLst.BuildSortLst() )
     607         [ #  # ]:          0 :         pWrtShell->UpdateInputFlds( &aFldLst );
     608                 :            : 
     609         [ #  # ]:          0 :     if(!pCurGrp)
     610         [ #  # ]:          0 :         rStatGlossaries.PutGroupDoc(pGlos);
     611 [ #  # ][ #  # ]:          0 :     return sal_True;
                 [ #  # ]
     612                 :            : }
     613                 :            : 
     614                 :            : /*------------------------------------------------------------------------
     615                 :            :  Description:   set / ask for macro
     616                 :            : ------------------------------------------------------------------------*/
     617                 :          0 : void SwGlossaryHdl::SetMacros(const String& rShortName,
     618                 :            :                               const SvxMacro* pStart,
     619                 :            :                               const SvxMacro* pEnd,
     620                 :            :                               SwTextBlocks *pGlossary )
     621                 :            : {
     622                 :            :     SwTextBlocks *pGlos = pGlossary ? pGlossary :
     623                 :            :                                 pCurGrp ? pCurGrp
     624 [ #  # ][ #  # ]:          0 :                                   : rStatGlossaries.GetGroupDoc( aCurGrp );
                 [ #  # ]
     625         [ #  # ]:          0 :     SvxMacroTableDtor aMacroTbl;
     626         [ #  # ]:          0 :     if( pStart )
     627         [ #  # ]:          0 :         aMacroTbl.Insert( SW_EVENT_START_INS_GLOSSARY, *pStart);
     628         [ #  # ]:          0 :     if( pEnd )
     629         [ #  # ]:          0 :         aMacroTbl.Insert( SW_EVENT_END_INS_GLOSSARY, *pEnd);
     630         [ #  # ]:          0 :     sal_uInt16 nIdx = pGlos->GetIndex( rShortName );
     631 [ #  # ][ #  # ]:          0 :     if( !pGlos->SetMacroTable( nIdx, aMacroTbl ) && pGlos->GetError() )
         [ #  # ][ #  # ]
     632         [ #  # ]:          0 :         ErrorHandler::HandleError( pGlos->GetError() );
     633                 :            : 
     634 [ #  # ][ #  # ]:          0 :     if(!pCurGrp && !pGlossary)
     635         [ #  # ]:          0 :         rStatGlossaries.PutGroupDoc(pGlos);
     636                 :          0 : }
     637                 :            : 
     638                 :          4 : void SwGlossaryHdl::GetMacros( const String &rShortName,
     639                 :            :                                 SvxMacro& rStart,
     640                 :            :                                 SvxMacro& rEnd,
     641                 :            :                                 SwTextBlocks *pGlossary  )
     642                 :            : {
     643                 :            :     SwTextBlocks *pGlos = pGlossary ? pGlossary
     644                 :            :                                     : pCurGrp ? pCurGrp
     645 [ -  + ][ #  # ]:          4 :                                         : rStatGlossaries.GetGroupDoc(aCurGrp);
     646                 :          4 :     sal_uInt16 nIndex = pGlos->GetIndex( rShortName );
     647         [ +  + ]:          4 :     if( nIndex != USHRT_MAX )
     648                 :            :     {
     649         [ +  - ]:          2 :         SvxMacroTableDtor aMacroTbl;
     650 [ +  - ][ -  + ]:          2 :         if( pGlos->GetMacroTable( nIndex, aMacroTbl ) )
     651                 :            :         {
     652         [ #  # ]:          0 :             SvxMacro *pMacro = aMacroTbl.Get( SW_EVENT_START_INS_GLOSSARY );
     653         [ #  # ]:          0 :             if( pMacro )
     654         [ #  # ]:          0 :                 rStart = *pMacro;
     655                 :            : 
     656         [ #  # ]:          0 :             pMacro = aMacroTbl.Get( SW_EVENT_END_INS_GLOSSARY );
     657         [ #  # ]:          0 :             if( pMacro )
     658         [ #  # ]:          0 :                 rEnd = *pMacro;
     659                 :          2 :         }
     660                 :            :     }
     661                 :            : 
     662 [ +  - ][ -  + ]:          4 :     if( !pCurGrp && !pGlossary )
     663                 :          0 :         rStatGlossaries.PutGroupDoc( pGlos );
     664                 :          4 : }
     665                 :            : 
     666                 :            : 
     667                 :            : /*------------------------------------------------------------------------
     668                 :            :     Description:    ctor, dtor
     669                 :            : ------------------------------------------------------------------------*/
     670                 :          2 : SwGlossaryHdl::SwGlossaryHdl(SfxViewFrame* pVwFrm, SwWrtShell *pSh)
     671                 :          2 :     : rStatGlossaries( *::GetGlossaries() ),
     672                 :            :     aCurGrp( rStatGlossaries.GetDefName() ),
     673                 :            :     pViewFrame( pVwFrm ),
     674                 :            :     pWrtShell( pSh ),
     675                 :          2 :     pCurGrp( 0 )
     676                 :            : {
     677                 :          2 : }
     678                 :            : 
     679                 :          2 : SwGlossaryHdl::~SwGlossaryHdl()
     680                 :            : {
     681         [ -  + ]:          2 :     if( pCurGrp )
     682         [ #  # ]:          0 :         rStatGlossaries.PutGroupDoc( pCurGrp );
     683                 :          2 : }
     684                 :            : 
     685                 :            : /*------------------------------------------------------------------------
     686                 :            :     Description:    rename an autotext
     687                 :            : ------------------------------------------------------------------------*/
     688                 :          0 : sal_Bool SwGlossaryHdl::Rename(const String& rOldShort, const String& rNewShortName,
     689                 :            :                            const String& rNewName )
     690                 :            : {
     691                 :          0 :     sal_Bool bRet = sal_False;
     692                 :            :     SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
     693         [ #  # ]:          0 :                                     : rStatGlossaries.GetGroupDoc(aCurGrp);
     694         [ #  # ]:          0 :     if(pGlossary)
     695                 :            :     {
     696         [ #  # ]:          0 :         if(!ConvertToNew(*pGlossary))
     697                 :          0 :             return sal_False;
     698                 :            : 
     699                 :          0 :         sal_uInt16 nIdx = pGlossary->GetIndex( rOldShort );
     700                 :          0 :         sal_uInt16 nOldLongIdx = pGlossary->GetLongIndex( rNewName );
     701                 :          0 :         sal_uInt16 nOldIdx = pGlossary->GetIndex( rNewShortName );
     702                 :            : 
     703 [ #  # ][ #  # ]:          0 :         if( nIdx != USHRT_MAX &&
         [ #  # ][ #  # ]
                 [ #  # ]
     704                 :            :                 (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
     705                 :            :                     (nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
     706                 :            :         {
     707         [ #  # ]:          0 :             String aNewShort( rNewShortName );
     708         [ #  # ]:          0 :             String aNewName( rNewName );
     709         [ #  # ]:          0 :             pGlossary->Rename( nIdx, &aNewShort, &aNewName );
     710 [ #  # ][ #  # ]:          0 :             bRet = pGlossary->GetError() == 0;
     711                 :            :         }
     712         [ #  # ]:          0 :         if( !pCurGrp )
     713                 :          0 :             rStatGlossaries.PutGroupDoc(pGlossary);
     714                 :            :     }
     715                 :          0 :     return bRet;
     716                 :            : }
     717                 :            : 
     718                 :            : 
     719                 :          0 : sal_Bool SwGlossaryHdl::IsReadOnly( const String* pGrpNm ) const
     720                 :            : {
     721                 :          0 :     SwTextBlocks *pGlossary = 0;
     722                 :            : 
     723         [ #  # ]:          0 :     if (pGrpNm)
     724                 :          0 :         pGlossary = rStatGlossaries.GetGroupDoc( *pGrpNm );
     725         [ #  # ]:          0 :     else if (pCurGrp)
     726                 :          0 :         pGlossary = pCurGrp;
     727                 :            :     else
     728                 :          0 :         pGlossary = rStatGlossaries.GetGroupDoc(aCurGrp);
     729                 :            : 
     730         [ #  # ]:          0 :     sal_Bool bRet = pGlossary ? pGlossary->IsReadOnly() : sal_True;
     731 [ #  # ][ #  # ]:          0 :     if( pGrpNm || !pCurGrp )
     732         [ #  # ]:          0 :         delete pGlossary;
     733                 :          0 :     return bRet;
     734                 :            : }
     735                 :            : 
     736                 :            : 
     737                 :          0 : sal_Bool SwGlossaryHdl::IsOld() const
     738                 :            : {
     739                 :            :     SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
     740         [ #  # ]:          0 :                                       : rStatGlossaries.GetGroupDoc(aCurGrp);
     741         [ #  # ]:          0 :     sal_Bool bRet = pGlossary ? pGlossary->IsOld() : sal_False;
     742         [ #  # ]:          0 :     if( !pCurGrp )
     743         [ #  # ]:          0 :         delete pGlossary;
     744                 :          0 :     return bRet;
     745                 :            : }
     746                 :            : 
     747                 :            : /*--------------------------------------------------
     748                 :            :     find group without path index
     749                 :            : --------------------------------------------------*/
     750                 :          0 : sal_Bool SwGlossaryHdl::FindGroupName(String & rGroup)
     751                 :            : {
     752                 :          0 :     return rStatGlossaries.FindGroupName(rGroup);
     753                 :            : }
     754                 :            : 
     755                 :          0 : sal_Bool SwGlossaryHdl::CopyToClipboard(SwWrtShell& rSh, const String& rShortName)
     756                 :            : {
     757                 :            :     SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
     758 [ #  # ][ #  # ]:          0 :                                     : rStatGlossaries.GetGroupDoc(aCurGrp);
     759                 :            : 
     760         [ #  # ]:          0 :     SwTransferable* pTransfer = new SwTransferable( rSh );
     761                 :            : /*??*/uno::Reference<
     762 [ #  # ][ #  # ]:          0 :         datatransfer::XTransferable > xRef( pTransfer );
     763                 :            : 
     764         [ #  # ]:          0 :     int nRet = pTransfer->CopyGlossary( *pGlossary, rShortName );
     765         [ #  # ]:          0 :     if( !pCurGrp )
     766         [ #  # ]:          0 :         rStatGlossaries.PutGroupDoc( pGlossary );
     767                 :          0 :     return 0 != nRet;
     768                 :            : }
     769                 :            : 
     770                 :          0 : sal_Bool SwGlossaryHdl::ImportGlossaries( const String& rName )
     771                 :            : {
     772                 :          0 :     sal_Bool bRet = sal_False;
     773         [ #  # ]:          0 :     if( rName.Len() )
     774                 :            :     {
     775                 :          0 :         const SfxFilter* pFilter = 0;
     776 [ #  # ][ #  # ]:          0 :         SfxMedium* pMed = new SfxMedium( rName, STREAM_READ, 0, 0 );
     777 [ #  # ][ #  # ]:          0 :         SfxFilterMatcher aMatcher( rtl::OUString("swriter") );
                 [ #  # ]
     778         [ #  # ]:          0 :         pMed->UseInteractionHandler( sal_True );
     779 [ #  # ][ #  # ]:          0 :         if( !aMatcher.GuessFilter( *pMed, &pFilter, sal_False ) )
     780                 :            :         {
     781                 :            :             SwTextBlocks *pGlossary;
     782         [ #  # ]:          0 :             pMed->SetFilter( pFilter );
     783 [ #  # ][ #  # ]:          0 :             Reader* pR = SwReaderWriter::GetReader( pFilter->GetUserData() );
                 [ #  # ]
     784 [ #  # ][ #  # ]:          0 :             if( pR && 0 != ( pGlossary = pCurGrp ? pCurGrp
         [ #  # ][ #  # ]
                 [ #  # ]
     785                 :          0 :                                     : rStatGlossaries.GetGroupDoc(aCurGrp)) )
     786                 :            :             {
     787         [ #  # ]:          0 :                 SwReader aReader( *pMed, rName );
     788 [ #  # ][ #  # ]:          0 :                 if( aReader.HasGlossaries( *pR ) )
     789                 :            :                 {
     790         [ #  # ]:          0 :                     const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get();
     791                 :            :                     bRet = aReader.ReadGlossaries( *pR, *pGlossary,
     792         [ #  # ]:          0 :                                 rCfg.IsSaveRelFile() );
     793         [ #  # ]:          0 :                 }
     794                 :            :             }
     795                 :            :         }
     796 [ #  # ][ #  # ]:          0 :         DELETEZ(pMed);
                 [ #  # ]
     797                 :            :     }
     798                 :          0 :     return bRet;
     799                 :            : }
     800                 :            : 
     801                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10