1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR 34*cdf0e10cSrcweir #define _SVSTDARR_STRINGSISORTDTOR 35*cdf0e10cSrcweir #define _SVSTDARR_STRINGS 36*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <vcl/dialog.hxx> 39*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 40*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX //autogen 41*cdf0e10cSrcweir #include <vcl/button.hxx> 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #ifndef _FIXED_HXX //autogen 44*cdf0e10cSrcweir #include <vcl/fixed.hxx> 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 47*cdf0e10cSrcweir #ifndef SVTOOLS_FSTATHELPER_HXX 48*cdf0e10cSrcweir #include <svl/fstathelper.hxx> 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 51*cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx> 52*cdf0e10cSrcweir #include <swtypes.hxx> 53*cdf0e10cSrcweir #include <swmodule.hxx> 54*cdf0e10cSrcweir #include <shellio.hxx> 55*cdf0e10cSrcweir #include <initui.hxx> 56*cdf0e10cSrcweir #include <glosdoc.hxx> 57*cdf0e10cSrcweir #include <gloslst.hxx> 58*cdf0e10cSrcweir #include <swunohelper.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #ifndef _UTLUI_HRC 61*cdf0e10cSrcweir #include <utlui.hrc> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir #ifndef _GLOSLST_HRC 64*cdf0e10cSrcweir #include <gloslst.hrc> 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #define STRING_DELIM (char)0x0A 69*cdf0e10cSrcweir #define GLOS_TIMEOUT 30000 // alle 30 s updaten 70*cdf0e10cSrcweir #define FIND_MAX_GLOS 20 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir struct TripleString 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir String sGroup; 76*cdf0e10cSrcweir String sBlock; 77*cdf0e10cSrcweir String sShort; 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir typedef TripleString* TripleStringPtr; 81*cdf0e10cSrcweir SV_DECL_PTRARR_DEL( TripleStrings, TripleStringPtr, 0, 4 ) 82*cdf0e10cSrcweir SV_IMPL_PTRARR( TripleStrings, TripleStringPtr ) 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir class SwGlossDecideDlg : public ModalDialog 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir OKButton aOk; 87*cdf0e10cSrcweir CancelButton aCancel; 88*cdf0e10cSrcweir HelpButton aHelp; 89*cdf0e10cSrcweir ListBox aListLB; 90*cdf0e10cSrcweir FixedLine aFL; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir DECL_LINK(DoubleClickHdl, ListBox*); 93*cdf0e10cSrcweir DECL_LINK(SelectHdl, ListBox*); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir public: 96*cdf0e10cSrcweir SwGlossDecideDlg(Window* pParent); 97*cdf0e10cSrcweir ListBox& GetListBox() {return aListLB;} 98*cdf0e10cSrcweir }; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir /*-----------------21.01.97 13.25------------------- 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir --------------------------------------------------*/ 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir SwGlossDecideDlg::SwGlossDecideDlg(Window* pParent) : 105*cdf0e10cSrcweir ModalDialog(pParent, SW_RES(DLG_GLOSSARY_DECIDE_DLG)), 106*cdf0e10cSrcweir aOk(this, SW_RES(PB_OK)), 107*cdf0e10cSrcweir aCancel(this, SW_RES(PB_CANCEL)), 108*cdf0e10cSrcweir aHelp(this, SW_RES(PB_HELP)), 109*cdf0e10cSrcweir aListLB(this, SW_RES(LB_LIST)), 110*cdf0e10cSrcweir aFL(this, SW_RES(FL_GLOSS)) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir FreeResource(); 113*cdf0e10cSrcweir aListLB.SetDoubleClickHdl(LINK(this, SwGlossDecideDlg, DoubleClickHdl)); 114*cdf0e10cSrcweir aListLB.SetSelectHdl(LINK(this, SwGlossDecideDlg, SelectHdl)); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /*-----------------21.01.97 13.25------------------- 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir --------------------------------------------------*/ 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir IMPL_LINK(SwGlossDecideDlg, DoubleClickHdl, ListBox*, EMPTYARG) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir EndDialog(RET_OK); 124*cdf0e10cSrcweir return 0; 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir /*-----------------21.01.97 13.29------------------- 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir --------------------------------------------------*/ 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir IMPL_LINK(SwGlossDecideDlg, SelectHdl, ListBox*, EMPTYARG) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir aOk.Enable(LISTBOX_ENTRY_NOTFOUND != aListLB.GetSelectEntryPos()); 133*cdf0e10cSrcweir return 0; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /******************************************************************** 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir ********************************************************************/ 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir SwGlossaryList::SwGlossaryList() : 142*cdf0e10cSrcweir bFilled(sal_False) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir SvtPathOptions aPathOpt; 145*cdf0e10cSrcweir sPath = aPathOpt.GetAutoTextPath(); 146*cdf0e10cSrcweir SetTimeout(GLOS_TIMEOUT); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir /******************************************************************** 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir ********************************************************************/ 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir SwGlossaryList::~SwGlossaryList() 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir ClearGroups(); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir /******************************************************************** 160*cdf0e10cSrcweir * Wenn der GroupName bereits bekannt ist, dann wird nur 161*cdf0e10cSrcweir * rShortName gefuellt, sonst wird rGroupName ebenfals gesetzt und 162*cdf0e10cSrcweir * bei Bedarf nach der richtigen Gruppe gefragt 163*cdf0e10cSrcweir ********************************************************************/ 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir sal_Bool SwGlossaryList::GetShortName(const String& rLongName, 167*cdf0e10cSrcweir String& rShortName, String& rGroupName ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir if(!bFilled) 170*cdf0e10cSrcweir Update(); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir TripleStrings aTripleStrings; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir sal_uInt16 nCount = aGroupArr.Count(); 175*cdf0e10cSrcweir sal_uInt16 nFound = 0; 176*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; i++ ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(i); 179*cdf0e10cSrcweir if(!rGroupName.Len() || rGroupName == pGroup->sName) 180*cdf0e10cSrcweir for(sal_uInt16 j = 0; j < pGroup->nCount; j++) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir String sLong = pGroup->sLongNames.GetToken(j, STRING_DELIM); 183*cdf0e10cSrcweir if((rLongName == sLong)) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir TripleString* pTriple = new TripleString; 186*cdf0e10cSrcweir pTriple->sGroup = pGroup->sName; 187*cdf0e10cSrcweir pTriple->sBlock = sLong; 188*cdf0e10cSrcweir pTriple->sShort = pGroup->sShortNames.GetToken(j, STRING_DELIM); 189*cdf0e10cSrcweir aTripleStrings.Insert(pTriple, nFound++); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir sal_Bool bRet = sal_False; 195*cdf0e10cSrcweir nCount = aTripleStrings.Count(); 196*cdf0e10cSrcweir if(1 == nCount ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir TripleString* pTriple = aTripleStrings[0]; 199*cdf0e10cSrcweir rShortName = pTriple->sShort; 200*cdf0e10cSrcweir rGroupName = pTriple->sGroup; 201*cdf0e10cSrcweir bRet = sal_True; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir else if(1 < nCount) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir SwGlossDecideDlg aDlg(0); 206*cdf0e10cSrcweir String sTitle = aDlg.GetText(); 207*cdf0e10cSrcweir sTitle += ' '; 208*cdf0e10cSrcweir sTitle += aTripleStrings[0]->sBlock; 209*cdf0e10cSrcweir aDlg.SetText(sTitle); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir ListBox& rLB = aDlg.GetListBox(); 212*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; i++ ) 213*cdf0e10cSrcweir rLB.InsertEntry(aTripleStrings[i]->sGroup.GetToken(0, GLOS_DELIM)); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir rLB.SelectEntryPos(0); 216*cdf0e10cSrcweir if(RET_OK == aDlg.Execute() && 217*cdf0e10cSrcweir LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectEntryPos()) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir TripleString* pTriple = aTripleStrings[rLB.GetSelectEntryPos()]; 220*cdf0e10cSrcweir rShortName = pTriple->sShort; 221*cdf0e10cSrcweir rGroupName = pTriple->sGroup; 222*cdf0e10cSrcweir bRet = sal_True; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir else 225*cdf0e10cSrcweir bRet = sal_False; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir return bRet; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir /******************************************************************** 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir ********************************************************************/ 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir sal_uInt16 SwGlossaryList::GetGroupCount() 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir if(!bFilled) 238*cdf0e10cSrcweir Update(); 239*cdf0e10cSrcweir return aGroupArr.Count(); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir /******************************************************************** 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir ********************************************************************/ 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir String SwGlossaryList::GetGroupName(sal_uInt16 nPos, sal_Bool bNoPath, String* pTitle) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir DBG_ASSERT(aGroupArr.Count() > nPos, "Gruppe nicht vorhanden"); 250*cdf0e10cSrcweir String sRet(aEmptyStr); 251*cdf0e10cSrcweir if(nPos < aGroupArr.Count()) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(nPos); 254*cdf0e10cSrcweir sRet = pGroup->sName; 255*cdf0e10cSrcweir if(bNoPath) 256*cdf0e10cSrcweir sRet = sRet.GetToken(0, GLOS_DELIM); 257*cdf0e10cSrcweir if(pTitle) 258*cdf0e10cSrcweir *pTitle = pGroup->sTitle; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir return sRet; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir /******************************************************************** 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir ********************************************************************/ 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir sal_uInt16 SwGlossaryList::GetBlockCount(sal_uInt16 nGroup) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir DBG_ASSERT(aGroupArr.Count() > nGroup, "Gruppe nicht vorhanden"); 272*cdf0e10cSrcweir if(nGroup < aGroupArr.Count()) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(nGroup); 275*cdf0e10cSrcweir return pGroup->nCount; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir return 0; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir /******************************************************************** 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir ********************************************************************/ 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir String SwGlossaryList::GetBlockName(sal_uInt16 nGroup, sal_uInt16 nBlock, String& rShortName) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir DBG_ASSERT(aGroupArr.Count() > nGroup, "Gruppe nicht vorhanden"); 288*cdf0e10cSrcweir if(nGroup < aGroupArr.Count()) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(nGroup); 291*cdf0e10cSrcweir rShortName = pGroup->sShortNames.GetToken(nBlock, STRING_DELIM); 292*cdf0e10cSrcweir return pGroup->sLongNames.GetToken(nBlock, STRING_DELIM); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir return aEmptyStr; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir /******************************************************************** 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir ********************************************************************/ 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir void SwGlossaryList::Update() 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir if(!IsActive()) 305*cdf0e10cSrcweir Start(); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir SvtPathOptions aPathOpt; 308*cdf0e10cSrcweir String sTemp( aPathOpt.GetAutoTextPath() ); 309*cdf0e10cSrcweir if(sTemp != sPath) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir sPath = sTemp; 312*cdf0e10cSrcweir bFilled = sal_False; 313*cdf0e10cSrcweir ClearGroups(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir SwGlossaries* pGlossaries = ::GetGlossaries(); 316*cdf0e10cSrcweir const SvStrings* pPathArr = pGlossaries->GetPathArray(); 317*cdf0e10cSrcweir String sExt( SwGlossaries::GetExtension() ); 318*cdf0e10cSrcweir if(!bFilled) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir sal_uInt16 nGroupCount = pGlossaries->GetGroupCnt(); 321*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nGroupCount; i++) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir String sGrpName = pGlossaries->GetGroupName(i); 324*cdf0e10cSrcweir sal_uInt16 nPath = (sal_uInt16)sGrpName.GetToken(1, GLOS_DELIM).ToInt32(); 325*cdf0e10cSrcweir if(nPath < pPathArr->Count()) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir AutoTextGroup* pGroup = new AutoTextGroup; 328*cdf0e10cSrcweir pGroup->sName = sGrpName; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir FillGroup(pGroup, pGlossaries); 331*cdf0e10cSrcweir String sName = *(*pPathArr)[nPath]; 332*cdf0e10cSrcweir sName += INET_PATH_TOKEN; 333*cdf0e10cSrcweir sName += pGroup->sName.GetToken(0, GLOS_DELIM); 334*cdf0e10cSrcweir sName += sExt; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir FStatHelper::GetModifiedDateTimeOfFile( sName, 337*cdf0e10cSrcweir &pGroup->aDateModified, 338*cdf0e10cSrcweir &pGroup->aDateModified ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir aGroupArr.Insert( pGroup, i ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir bFilled = sal_True; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir else 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir for(sal_uInt16 nPath = 0; nPath < pPathArr->Count(); nPath++) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir SvStringsDtor aFoundGroupNames; 350*cdf0e10cSrcweir SvStrings aFiles( 16, 16 ); 351*cdf0e10cSrcweir SvPtrarr aDateTimeArr( 16, 16 ); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir SWUnoHelper::UCB_GetFileListOfFolder( *(*pPathArr)[nPath], aFiles, 354*cdf0e10cSrcweir &sExt, &aDateTimeArr ); 355*cdf0e10cSrcweir for( sal_uInt16 nFiles = 0, nFEnd = aFiles.Count(); 356*cdf0e10cSrcweir nFiles < nFEnd; ++nFiles ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir String* pTitle = aFiles[ nFiles ]; 359*cdf0e10cSrcweir ::DateTime* pDT = (::DateTime*) aDateTimeArr[ nFiles ]; 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir String sName( pTitle->Copy( 0, pTitle->Len() - sExt.Len() )); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir aFoundGroupNames.Insert( new String(sName), 364*cdf0e10cSrcweir aFoundGroupNames.Count()); 365*cdf0e10cSrcweir sName += GLOS_DELIM; 366*cdf0e10cSrcweir sName += String::CreateFromInt32( nPath ); 367*cdf0e10cSrcweir AutoTextGroup* pFound = FindGroup( sName ); 368*cdf0e10cSrcweir if( !pFound ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir pFound = new AutoTextGroup; 371*cdf0e10cSrcweir pFound->sName = sName; 372*cdf0e10cSrcweir FillGroup( pFound, pGlossaries ); 373*cdf0e10cSrcweir pFound->aDateModified = *pDT; 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir aGroupArr.Insert(pFound, aGroupArr.Count()); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir else if( pFound->aDateModified < *pDT ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir FillGroup(pFound, pGlossaries); 380*cdf0e10cSrcweir pFound->aDateModified = *pDT; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir // don't need any more these pointers 384*cdf0e10cSrcweir delete pTitle; 385*cdf0e10cSrcweir delete pDT; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir sal_uInt16 nArrCount = aGroupArr.Count(); 389*cdf0e10cSrcweir for( sal_uInt16 i = nArrCount; i; --i) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir // evtl. geloeschte Gruppen entfernen 392*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(i - 1); 393*cdf0e10cSrcweir sal_uInt16 nGroupPath = (sal_uInt16)pGroup->sName.GetToken( 1, 394*cdf0e10cSrcweir GLOS_DELIM).ToInt32(); 395*cdf0e10cSrcweir // nur die Gruppen werden geprueft, die fuer den 396*cdf0e10cSrcweir // aktuellen Teilpfad registriert sind 397*cdf0e10cSrcweir if(nGroupPath == nPath) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir sal_Bool bFound = sal_False; 400*cdf0e10cSrcweir String sCompareGroup = pGroup->sName.GetToken(0, GLOS_DELIM); 401*cdf0e10cSrcweir for( sal_uInt16 j = 0; j < aFoundGroupNames.Count() && !bFound; ++j) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir bFound = sCompareGroup == *aFoundGroupNames[j]; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir if(!bFound) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir aGroupArr.Remove(i - 1); 408*cdf0e10cSrcweir delete pGroup; 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir /******************************************************************** 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir ********************************************************************/ 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir void SwGlossaryList::Timeout() 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir // nur, wenn eine SwView den Fokus hat, wird automatisch upgedated 424*cdf0e10cSrcweir if(::GetActiveView()) 425*cdf0e10cSrcweir Update(); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir /******************************************************************** 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir ********************************************************************/ 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir AutoTextGroup* SwGlossaryList::FindGroup(const String& rGroupName) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < aGroupArr.Count(); i++) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir AutoTextGroup* pRet = aGroupArr.GetObject(i); 438*cdf0e10cSrcweir if(pRet->sName == rGroupName) 439*cdf0e10cSrcweir return pRet; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir return 0; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir /******************************************************************** 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir ********************************************************************/ 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir void SwGlossaryList::FillGroup(AutoTextGroup* pGroup, SwGlossaries* pGlossaries) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(pGroup->sName); 452*cdf0e10cSrcweir pGroup->nCount = pBlock ? pBlock->GetCount() : 0; 453*cdf0e10cSrcweir pGroup->sLongNames = pGroup->sShortNames = aEmptyStr; 454*cdf0e10cSrcweir if(pBlock) 455*cdf0e10cSrcweir pGroup->sTitle = pBlock->GetName(); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir for(sal_uInt16 j = 0; j < pGroup->nCount; j++) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir pGroup->sLongNames += pBlock->GetLongName(j); 460*cdf0e10cSrcweir pGroup->sLongNames += STRING_DELIM; 461*cdf0e10cSrcweir pGroup->sShortNames += pBlock->GetShortName(j); 462*cdf0e10cSrcweir pGroup->sShortNames += STRING_DELIM; 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir pGlossaries->PutGroupDoc(pBlock); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir /******************************************************************** 468*cdf0e10cSrcweir Alle (nicht mehr als FIND_MAX_GLOS) gefunden Bausteine mit 469*cdf0e10cSrcweir passendem Anfang zurueckgeben 470*cdf0e10cSrcweir ********************************************************************/ 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir sal_Bool SwGlossaryList::HasLongName(const String& rBegin, SvStringsISortDtor* pLongNames ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir if(!bFilled) 475*cdf0e10cSrcweir Update(); 476*cdf0e10cSrcweir sal_uInt16 nFound = 0; 477*cdf0e10cSrcweir sal_uInt16 nCount = aGroupArr.Count(); 478*cdf0e10cSrcweir sal_uInt16 nBeginLen = rBegin.Len(); 479*cdf0e10cSrcweir const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; i++ ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir AutoTextGroup* pGroup = aGroupArr.GetObject(i); 484*cdf0e10cSrcweir for(sal_uInt16 j = 0; j < pGroup->nCount; j++) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir String sBlock = pGroup->sLongNames.GetToken(j, STRING_DELIM); 487*cdf0e10cSrcweir if( rSCmp.isEqual( sBlock.Copy(0, nBeginLen), rBegin ) && 488*cdf0e10cSrcweir nBeginLen + 1 < sBlock.Len()) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir String* pBlock = new String(sBlock); 491*cdf0e10cSrcweir pLongNames->Insert(pBlock); 492*cdf0e10cSrcweir nFound++; 493*cdf0e10cSrcweir if(FIND_MAX_GLOS == nFound) 494*cdf0e10cSrcweir break; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir return nFound > 0; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir /******************************************************************** 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir ********************************************************************/ 504*cdf0e10cSrcweir void SwGlossaryList::ClearGroups() 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir sal_uInt16 nCount = aGroupArr.Count(); 507*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; ++i ) 508*cdf0e10cSrcweir delete aGroupArr.GetObject( i ); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir aGroupArr.Remove( 0, nCount ); 511*cdf0e10cSrcweir bFilled = sal_False; 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir 515