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