xref: /aoo41x/main/sw/source/ui/misc/glosbib.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 #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #define _SVSTDARR_STRINGS
33cdf0e10cSrcweir #include <tools/urlobj.hxx>
34cdf0e10cSrcweir #include <tools/stream.hxx>
35cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
36cdf0e10cSrcweir #include <vcl/msgbox.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <vcl/help.hxx>
39cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx>
40cdf0e10cSrcweir #include <unotools/tempfile.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <svl/svstdarr.hxx>
43cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
44cdf0e10cSrcweir #include <swtypes.hxx>
45cdf0e10cSrcweir #include <glosbib.hxx>
46cdf0e10cSrcweir #include <gloshdl.hxx>
47cdf0e10cSrcweir #include <actctrl.hxx>
48cdf0e10cSrcweir #include <glossary.hxx>
49cdf0e10cSrcweir #include <glosdoc.hxx>
50cdf0e10cSrcweir #include <swunohelper.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #ifndef _GLOSBIB_HRC
53cdf0e10cSrcweir #include <glosbib.hrc>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _MISC_HRC
56cdf0e10cSrcweir #include <misc.hrc>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #ifndef _HELPID_H
59cdf0e10cSrcweir #include <helpid.h>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #define PATH_CASE_SENSITIVE 0x01
64cdf0e10cSrcweir #define PATH_READONLY 		0x02
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #define RENAME_TOKEN_DELIM		(sal_Unicode)1
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /*-----------------09.06.97 13:05-------------------
69cdf0e10cSrcweir 
70cdf0e10cSrcweir --------------------------------------------------*/
SwGlossaryGroupDlg(Window * pParent,const SvStrings * pPathArr,SwGlossaryHdl * pHdl)71cdf0e10cSrcweir SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent,
72cdf0e10cSrcweir 						const SvStrings* pPathArr,
73cdf0e10cSrcweir 						SwGlossaryHdl *pHdl) :
74cdf0e10cSrcweir 	SvxStandardDialog(pParent, SW_RES(DLG_BIB_BASE)),
75cdf0e10cSrcweir     aBibFT(     this, SW_RES(FT_BIB)),
76cdf0e10cSrcweir 	aNameED( 	this, SW_RES(ED_NAME)),
77cdf0e10cSrcweir     aPathFT(     this, SW_RES(FT_PATH)),
78cdf0e10cSrcweir     aPathLB(	this, SW_RES(LB_PATH)),
79cdf0e10cSrcweir     aSelectFT(   this, SW_RES(FT_SELECT)),
80cdf0e10cSrcweir     aGroupTLB(  this, SW_RES(TLB_GROUPS)),
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     aOkPB(      this, SW_RES(BT_OK)),
83cdf0e10cSrcweir     aCancelPB(  this, SW_RES(BT_CANCEL)),
84cdf0e10cSrcweir     aHelpPB(    this, SW_RES(BT_HELP)),
85cdf0e10cSrcweir     aNewPB(     this, SW_RES(PB_NEW)),
86cdf0e10cSrcweir     aDelPB(     this, SW_RES(PB_DELETE)),
87cdf0e10cSrcweir     aRenamePB(  this, SW_RES(PB_RENAME)),
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     pRemovedArr(0),
90cdf0e10cSrcweir 	pInsertedArr(0),
91cdf0e10cSrcweir 	pRenamedArr(0),
92cdf0e10cSrcweir 	pGlosHdl(pHdl)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	sal_uInt16 i;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	FreeResource();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	long nTabs[] =
99cdf0e10cSrcweir 	{	2, // Number of Tabs
100cdf0e10cSrcweir 		0, 160
101cdf0e10cSrcweir 	};
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	aGroupTLB.SetHelpId(HID_GLOS_GROUP_TREE);
104cdf0e10cSrcweir 	aGroupTLB.SetTabs( &nTabs[0], MAP_APPFONT );
105cdf0e10cSrcweir 	aGroupTLB.SetStyle(aGroupTLB.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN|WB_SORT);
106cdf0e10cSrcweir 	aGroupTLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, SelectHdl));
107cdf0e10cSrcweir 	aGroupTLB.GetModel()->SetSortMode(SortAscending);
108cdf0e10cSrcweir 	aNewPB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, NewHdl));
109cdf0e10cSrcweir 	aDelPB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, DeleteHdl));
110cdf0e10cSrcweir 	aNameED.SetModifyHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl));
111cdf0e10cSrcweir 	aPathLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl));
112cdf0e10cSrcweir 	aRenamePB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, RenameHdl));
113cdf0e10cSrcweir 	for( i = 0; i < pPathArr->Count(); i++)
114cdf0e10cSrcweir 	{
115cdf0e10cSrcweir 		String sPath(*(*pPathArr)[i]);
116cdf0e10cSrcweir         INetURLObject aTempURL(sPath);
117cdf0e10cSrcweir         sPath = aTempURL.GetMainURL(INetURLObject::DECODE_WITH_CHARSET );
118cdf0e10cSrcweir 		aPathLB.InsertEntry(sPath);
119cdf0e10cSrcweir 		sal_uLong nCaseReadonly = 0;
120cdf0e10cSrcweir 		utl::TempFile aTempFile(&sPath);
121cdf0e10cSrcweir 		aTempFile.EnableKillingFile();
122cdf0e10cSrcweir 		if(!aTempFile.IsValid())
123cdf0e10cSrcweir 			nCaseReadonly |= PATH_READONLY;
124cdf0e10cSrcweir 		else if( SWUnoHelper::UCB_IsCaseSensitiveFileName( aTempFile.GetURL()))
125cdf0e10cSrcweir 			nCaseReadonly |= PATH_CASE_SENSITIVE;
126cdf0e10cSrcweir 		aPathLB.SetEntryData(i, (void*)nCaseReadonly);
127cdf0e10cSrcweir 	}
128cdf0e10cSrcweir 	aPathLB.SelectEntryPos(0);
129cdf0e10cSrcweir 	aPathLB.Enable(sal_True);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	const sal_uInt16 nCount = pHdl->GetGroupCnt();
132cdf0e10cSrcweir 	for(i = 0; i < nCount; ++i)
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir 		String sTitle;
135cdf0e10cSrcweir 		String sGroup = pHdl->GetGroupName(i, &sTitle);
136cdf0e10cSrcweir 		if(!sGroup.Len())
137cdf0e10cSrcweir 			continue;
138cdf0e10cSrcweir 		GlosBibUserData* pData = new GlosBibUserData;
139cdf0e10cSrcweir 		pData->sGroupName = sGroup;
140cdf0e10cSrcweir 		pData->sGroupTitle = sTitle;
141cdf0e10cSrcweir 		String sTemp(sTitle);
142cdf0e10cSrcweir 		//sGroup.GetToken(0, GLOS_DELIM)
143cdf0e10cSrcweir 		sTemp += '\t';
144cdf0e10cSrcweir         pData->sPath = aPathLB.GetEntry((sal_uInt16)sGroup.GetToken(1, GLOS_DELIM).ToInt32());
145cdf0e10cSrcweir 		sTemp += pData->sPath;
146cdf0e10cSrcweir 		SvLBoxEntry* pEntry = aGroupTLB.InsertEntry(sTemp);
147cdf0e10cSrcweir 		pEntry->SetUserData(pData);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	}
150cdf0e10cSrcweir 	aGroupTLB.GetModel()->Resort();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir /*-----------------09.06.97 13:05-------------------
154cdf0e10cSrcweir 
155cdf0e10cSrcweir --------------------------------------------------*/
~SwGlossaryGroupDlg()156cdf0e10cSrcweir SwGlossaryGroupDlg::~SwGlossaryGroupDlg()
157cdf0e10cSrcweir {
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	if(pInsertedArr)
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		pInsertedArr->DeleteAndDestroy(0, pInsertedArr->Count());
162cdf0e10cSrcweir 		delete pInsertedArr;
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir 	if(pRemovedArr)
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		pRemovedArr->DeleteAndDestroy(0, pRemovedArr->Count());
167cdf0e10cSrcweir 		delete pRemovedArr;
168cdf0e10cSrcweir 	}
169cdf0e10cSrcweir 	if(pRenamedArr)
170cdf0e10cSrcweir 	{
171cdf0e10cSrcweir 		pRenamedArr->DeleteAndDestroy(0, pRenamedArr->Count());
172cdf0e10cSrcweir 		delete pRenamedArr;
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir /*-----------------09.06.97 13:11-------------------
178cdf0e10cSrcweir 
179cdf0e10cSrcweir --------------------------------------------------*/
180cdf0e10cSrcweir 
Apply()181cdf0e10cSrcweir void __EXPORT SwGlossaryGroupDlg::Apply()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	if(aNewPB.IsEnabled())
184cdf0e10cSrcweir 		NewHdl(&aNewPB);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	String aActGroup = SwGlossaryDlg::GetCurrGroup();
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	if(pRemovedArr && pRemovedArr->Count())
189cdf0e10cSrcweir 	{
190cdf0e10cSrcweir 		sal_uInt16 nCount = pRemovedArr->Count();
191cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
192cdf0e10cSrcweir 		{
193cdf0e10cSrcweir 			const String* pDelEntry = (*pRemovedArr)[i];
194cdf0e10cSrcweir 			const String sDelGroup = pDelEntry->GetToken(0, '\t');
195cdf0e10cSrcweir 			if( sDelGroup == aActGroup )
196cdf0e10cSrcweir 			{
197cdf0e10cSrcweir 				//soll die aktuelle Gruppe geloescht werden, muss die akt. Gruppe
198cdf0e10cSrcweir 				//umgesetzt werden
199cdf0e10cSrcweir 				if(aGroupTLB.GetEntryCount())
200cdf0e10cSrcweir 				{
201cdf0e10cSrcweir 					SvLBoxEntry* pFirst = aGroupTLB.First();
202cdf0e10cSrcweir 					GlosBibUserData* pUserData = (GlosBibUserData*)pFirst->GetUserData();
203cdf0e10cSrcweir 					pGlosHdl->SetCurGroup(pUserData->sGroupName);
204cdf0e10cSrcweir 				}
205cdf0e10cSrcweir 			}
206cdf0e10cSrcweir 			String sMsg(SW_RES(STR_QUERY_DELETE_GROUP1));
207cdf0e10cSrcweir 			String sTitle(pDelEntry->GetToken(1, '\t'));
208cdf0e10cSrcweir 			if(sTitle.Len())
209cdf0e10cSrcweir 				sMsg += sTitle;
210cdf0e10cSrcweir 			else
211cdf0e10cSrcweir 				sDelGroup.GetToken(1, GLOS_DELIM);
212cdf0e10cSrcweir 			sMsg += SW_RESSTR(STR_QUERY_DELETE_GROUP2);
213cdf0e10cSrcweir 			QueryBox aQuery(this->GetParent(), WB_YES_NO|WB_DEF_NO, sMsg );
214cdf0e10cSrcweir 			if(RET_YES == aQuery.Execute())
215cdf0e10cSrcweir 				pGlosHdl->DelGroup( sDelGroup );
216cdf0e10cSrcweir 		}
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	}
219cdf0e10cSrcweir 	//erst umbenennen, falls es schon eins gab
220cdf0e10cSrcweir 	if(pRenamedArr && pRenamedArr->Count())
221cdf0e10cSrcweir 	{
222cdf0e10cSrcweir 		sal_uInt16 nCount = pRenamedArr->Count();
223cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
224cdf0e10cSrcweir 		{
225cdf0e10cSrcweir 			String * pEntry = (*pRenamedArr)[i];
226cdf0e10cSrcweir 			xub_StrLen nStrSttPos = 0;
227cdf0e10cSrcweir 			String sOld( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos ) );
228cdf0e10cSrcweir 			String sNew( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
229cdf0e10cSrcweir 			String sTitle( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
230cdf0e10cSrcweir 			pGlosHdl->RenameGroup(sOld, sNew, sTitle);
231cdf0e10cSrcweir 			if(!i)
232cdf0e10cSrcweir 				sCreatedGroup = sNew;
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 	}
235cdf0e10cSrcweir 	if(pInsertedArr && pInsertedArr->Count())
236cdf0e10cSrcweir 	{
237cdf0e10cSrcweir 		sal_uInt16 nCount = pInsertedArr->Count();
238cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			String sNewGroup = *(*pInsertedArr)[i];
241cdf0e10cSrcweir 			String sNewTitle = sNewGroup.GetToken(0, GLOS_DELIM);
242cdf0e10cSrcweir 			if( *(*pInsertedArr)[i] != aActGroup )
243cdf0e10cSrcweir 			{
244cdf0e10cSrcweir 				pGlosHdl->NewGroup(sNewGroup, sNewTitle);
245cdf0e10cSrcweir 				if(!sCreatedGroup.Len())
246cdf0e10cSrcweir 					sCreatedGroup = sNewGroup;
247cdf0e10cSrcweir 			}
248cdf0e10cSrcweir 		}
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir }
251cdf0e10cSrcweir /*-----------------09.06.97 13:12-------------------
252cdf0e10cSrcweir 
253cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryGroupDlg,SelectHdl,SvTabListBox *,EMPTYARG)254cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, SelectHdl, SvTabListBox*, EMPTYARG  )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	aNewPB.Enable(sal_False);
257cdf0e10cSrcweir     SvLBoxEntry* pFirstEntry = aGroupTLB.FirstSelected();
258cdf0e10cSrcweir     if(pFirstEntry)
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir         GlosBibUserData* pUserData = (GlosBibUserData*)pFirstEntry->GetUserData();
261cdf0e10cSrcweir 		String sEntry(pUserData->sGroupName);
262cdf0e10cSrcweir 		String sName(aNameED.GetText());
263cdf0e10cSrcweir 		sal_Bool bExists = sal_False;
264cdf0e10cSrcweir 		sal_uLong nPos = aGroupTLB.GetEntryPos(sName, 0);
265cdf0e10cSrcweir 		if( 0xffffffff > nPos)
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			SvLBoxEntry* pEntry = aGroupTLB.GetEntry(nPos);
268cdf0e10cSrcweir 			GlosBibUserData* pFoundData = (GlosBibUserData*)pEntry->GetUserData();
269cdf0e10cSrcweir 			String sGroup = pFoundData->sGroupName;
270cdf0e10cSrcweir 			bExists = sGroup == sEntry;
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 		aRenamePB.Enable(!bExists && sName.Len());
274cdf0e10cSrcweir 		aDelPB.Enable(IsDeleteAllowed(sEntry));
275cdf0e10cSrcweir 	}
276cdf0e10cSrcweir 	return 0;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir /*-----------------09.06.97 13:22-------------------
280cdf0e10cSrcweir 
281cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryGroupDlg,NewHdl,Button *,EMPTYARG)282cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, NewHdl, Button*, EMPTYARG )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir 	String sGroup(aNameED.GetText());
285cdf0e10cSrcweir //	sGroup.ToLower();
286cdf0e10cSrcweir 	sGroup += GLOS_DELIM;
287cdf0e10cSrcweir 	sGroup += String::CreateFromInt32(aPathLB.GetSelectEntryPos());
288cdf0e10cSrcweir 	DBG_ASSERT(!pGlosHdl->FindGroupName(sGroup), "Gruppe bereits vorhanden!");
289cdf0e10cSrcweir 	if(!pInsertedArr)
290cdf0e10cSrcweir 		pInsertedArr = new SvStrings;
291cdf0e10cSrcweir 	pInsertedArr->Insert(new String(sGroup), pInsertedArr->Count());
292cdf0e10cSrcweir 	String sTemp(aNameED.GetText());
293cdf0e10cSrcweir //	sTemp.ToLower();
294cdf0e10cSrcweir 	sTemp += '\t';
295cdf0e10cSrcweir 	sTemp += aPathLB.GetSelectEntry();
296cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aGroupTLB.InsertEntry(sTemp);
297cdf0e10cSrcweir 	GlosBibUserData* pData = new GlosBibUserData;
298cdf0e10cSrcweir 	pData->sPath = aPathLB.GetSelectEntry();
299cdf0e10cSrcweir 	pData->sGroupName = sGroup;
300cdf0e10cSrcweir 	pData->sGroupTitle = aNameED.GetText();
301cdf0e10cSrcweir 	pEntry->SetUserData(pData);
302cdf0e10cSrcweir 	aGroupTLB.Select(pEntry);
303cdf0e10cSrcweir 	aGroupTLB.MakeVisible(pEntry);
304cdf0e10cSrcweir 	aGroupTLB.GetModel()->Resort();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	return 0;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir /*-----------------09.06.97 13:22-------------------
309cdf0e10cSrcweir 
310cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryGroupDlg,DeleteHdl,Button *,pButton)311cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton  )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aGroupTLB.FirstSelected();
314cdf0e10cSrcweir 	if(!pEntry)
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		pButton->Enable(sal_False);
317cdf0e10cSrcweir 		return 0;
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir 	GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData();
320cdf0e10cSrcweir 	String sEntry(pUserData->sGroupName);
321cdf0e10cSrcweir 	// befindet sich der zu loeschende Name schon unter den
322cdf0e10cSrcweir 	// den neuen - dann weg damit
323cdf0e10cSrcweir 	sal_Bool bDelete = sal_True;
324cdf0e10cSrcweir 	if(pInsertedArr && pInsertedArr->Count())
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		sal_uInt16 nCount = pInsertedArr->Count();
327cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
328cdf0e10cSrcweir 		{
329cdf0e10cSrcweir 			const String* pTemp = (*pInsertedArr)[i];
330cdf0e10cSrcweir 			if(*pTemp == sEntry)
331cdf0e10cSrcweir 			{
332cdf0e10cSrcweir 				pInsertedArr->Remove(i);
333cdf0e10cSrcweir 				bDelete = sal_False;
334cdf0e10cSrcweir 				break;
335cdf0e10cSrcweir 			}
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 		}
338cdf0e10cSrcweir 	}
339cdf0e10cSrcweir 	// moeglicherweise sollte es schon umbenannt werden?
340cdf0e10cSrcweir 	if(bDelete)
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		if(pRenamedArr && pRenamedArr->Count())
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			sal_uInt16 nCount = pRenamedArr->Count();
345cdf0e10cSrcweir 			for(sal_uInt16 i = 0; i < nCount; ++i)
346cdf0e10cSrcweir 			{
347cdf0e10cSrcweir 				const String* pTemp = (*pRenamedArr)[i];
348cdf0e10cSrcweir 				String sTemp( pTemp->GetToken(0, RENAME_TOKEN_DELIM ));
349cdf0e10cSrcweir 				if(sTemp == sEntry)
350cdf0e10cSrcweir 				{
351cdf0e10cSrcweir 					pRenamedArr->Remove(i);
352cdf0e10cSrcweir 					bDelete = sal_False;
353cdf0e10cSrcweir 					break;
354cdf0e10cSrcweir 				}
355cdf0e10cSrcweir 			}
356cdf0e10cSrcweir 		}
357cdf0e10cSrcweir 	}
358cdf0e10cSrcweir 	if(bDelete)
359cdf0e10cSrcweir 	{
360cdf0e10cSrcweir 		if(!pRemovedArr)
361cdf0e10cSrcweir 			pRemovedArr = new SvStrings;
362cdf0e10cSrcweir         String sGroupEntry(pUserData->sGroupName);
363cdf0e10cSrcweir         sGroupEntry += '\t';
364cdf0e10cSrcweir         sGroupEntry += pUserData->sGroupTitle;
365cdf0e10cSrcweir         pRemovedArr->Insert(new String(sGroupEntry), pRemovedArr->Count());
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 	delete pUserData;
368cdf0e10cSrcweir 	aGroupTLB.GetModel()->Remove(pEntry);
369cdf0e10cSrcweir 	if(!aGroupTLB.First())
370cdf0e10cSrcweir 		pButton->Enable(sal_False);
371cdf0e10cSrcweir 	//the content must be deleted - otherwise the new handler would be called in Apply()
372cdf0e10cSrcweir 	aNameED.SetText(aEmptyStr);
373cdf0e10cSrcweir 	return 0;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir /* -----------------23.11.98 12:26-------------------
377cdf0e10cSrcweir  *
378cdf0e10cSrcweir  * --------------------------------------------------*/
IMPL_LINK(SwGlossaryGroupDlg,RenameHdl,Button *,EMPTYARG)379cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, RenameHdl, Button *, EMPTYARG )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aGroupTLB.FirstSelected();
382cdf0e10cSrcweir 	GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData();
383cdf0e10cSrcweir 	String sEntryText(aGroupTLB.GetEntryText(pEntry));
384cdf0e10cSrcweir 	String sEntry(pUserData->sGroupName);
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	String sNewName(aNameED.GetText());
387cdf0e10cSrcweir 	String sNewTitle(sNewName);
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	sNewName += GLOS_DELIM;
390cdf0e10cSrcweir 	sNewName += String::CreateFromInt32(aPathLB.GetSelectEntryPos());
391cdf0e10cSrcweir 	DBG_ASSERT(!pGlosHdl->FindGroupName(sNewName), "Gruppe bereits vorhanden!");
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	// befindet sich der umzubenennende Name unter den
394cdf0e10cSrcweir 	// den neuen - dann austauschen
395cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
396cdf0e10cSrcweir 	if(pInsertedArr && pInsertedArr->Count())
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		sal_uInt16 nCount = pInsertedArr->Count();
399cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
400cdf0e10cSrcweir 		{
401cdf0e10cSrcweir 			const String* pTemp = (*pInsertedArr)[i];
402cdf0e10cSrcweir 			if(*pTemp == sEntry)
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				pInsertedArr->Remove(i);
405cdf0e10cSrcweir 				pInsertedArr->Insert(new String(sNewName), pInsertedArr->Count());
406cdf0e10cSrcweir 				bDone = sal_True;
407cdf0e10cSrcweir 				break;
408cdf0e10cSrcweir 			}
409cdf0e10cSrcweir 		}
410cdf0e10cSrcweir 	}
411cdf0e10cSrcweir 	if(!bDone)
412cdf0e10cSrcweir 	{
413cdf0e10cSrcweir 		if(!pRenamedArr)
414cdf0e10cSrcweir 			pRenamedArr = new SvStrings;
415cdf0e10cSrcweir 		sEntry += RENAME_TOKEN_DELIM;
416cdf0e10cSrcweir 		sEntry += sNewName;
417cdf0e10cSrcweir 		sEntry += RENAME_TOKEN_DELIM;
418cdf0e10cSrcweir 		sEntry += sNewTitle;
419cdf0e10cSrcweir 		pRenamedArr->Insert(new String(sEntry), pRenamedArr->Count());
420cdf0e10cSrcweir 	}
421cdf0e10cSrcweir 	delete (GlosBibUserData*)pEntry->GetUserData();
422cdf0e10cSrcweir 	aGroupTLB.GetModel()->Remove(pEntry);
423cdf0e10cSrcweir 	String sTemp(aNameED.GetText());
424cdf0e10cSrcweir //	sTemp.ToLower();
425cdf0e10cSrcweir 	sTemp += '\t';
426cdf0e10cSrcweir 	sTemp += aPathLB.GetSelectEntry();
427cdf0e10cSrcweir 	pEntry = aGroupTLB.InsertEntry(sTemp);
428cdf0e10cSrcweir 	GlosBibUserData* pData = new GlosBibUserData;
429cdf0e10cSrcweir 	pData->sPath = aPathLB.GetSelectEntry();
430cdf0e10cSrcweir 	pData->sGroupName = sNewName;
431cdf0e10cSrcweir 	pData->sGroupTitle = sNewTitle;
432cdf0e10cSrcweir 	pEntry->SetUserData(pData);
433cdf0e10cSrcweir 	aGroupTLB.Select(pEntry);
434cdf0e10cSrcweir 	aGroupTLB.MakeVisible(pEntry);
435cdf0e10cSrcweir 	aGroupTLB.GetModel()->Resort();
436cdf0e10cSrcweir 	return 0;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir /*-----------------09.06.97 13:42-------------------
439cdf0e10cSrcweir 
440cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryGroupDlg,ModifyHdl,Edit *,EMPTYARG)441cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, ModifyHdl, Edit*, EMPTYARG )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir 	String sEntry(aNameED.GetText());
444cdf0e10cSrcweir //	sEntry.ToLower();
445cdf0e10cSrcweir 	sal_Bool bEnableNew = sal_True;
446cdf0e10cSrcweir 	sal_Bool bEnableDel = sal_False;
447cdf0e10cSrcweir 	sal_uLong nCaseReadonly =
448cdf0e10cSrcweir 			(sal_uLong)aPathLB.GetEntryData(aPathLB.GetSelectEntryPos());
449cdf0e10cSrcweir 	sal_Bool bDirReadonly = 0 != (nCaseReadonly&PATH_READONLY);
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	if(!sEntry.Len() || bDirReadonly)
452cdf0e10cSrcweir 		bEnableNew = sal_False;
453cdf0e10cSrcweir 	else if(sEntry.Len())
454cdf0e10cSrcweir 	{
455cdf0e10cSrcweir 		sal_uLong nPos = 0xffffffff;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 		nPos = aGroupTLB.GetEntryPos(sEntry, 0);
459cdf0e10cSrcweir 		//ist es nicht case sensitive muss man selbst suchen
460cdf0e10cSrcweir 		if( 0xffffffff == nPos)
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 			const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
463cdf0e10cSrcweir 			for(sal_uInt16 i = 0; i < aGroupTLB.GetEntryCount(); i++)
464cdf0e10cSrcweir 			{
465cdf0e10cSrcweir 				String sTemp = aGroupTLB.GetEntryText( i, 0 );
466cdf0e10cSrcweir                 nCaseReadonly = (sal_uLong)aPathLB.GetEntryData(
467cdf0e10cSrcweir 					aPathLB.GetEntryPos(aGroupTLB.GetEntryText(i,1)));
468cdf0e10cSrcweir 				sal_Bool bCase = 0 != (nCaseReadonly & PATH_CASE_SENSITIVE);
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				if( !bCase && rSCmp.isEqual( sTemp, sEntry ))
471cdf0e10cSrcweir 				{
472cdf0e10cSrcweir 					nPos = i;
473cdf0e10cSrcweir 					break;
474cdf0e10cSrcweir 				}
475cdf0e10cSrcweir 			}
476cdf0e10cSrcweir 		}
477cdf0e10cSrcweir 		if( 0xffffffff > nPos)
478cdf0e10cSrcweir 		{
479cdf0e10cSrcweir 			bEnableNew = sal_False;
480cdf0e10cSrcweir 			aGroupTLB.Select(aGroupTLB.GetEntry( nPos ));
481cdf0e10cSrcweir 			aGroupTLB.MakeVisible(aGroupTLB.GetEntry( nPos ));
482cdf0e10cSrcweir 		}
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aGroupTLB.FirstSelected();
485cdf0e10cSrcweir 	if(pEntry)
486cdf0e10cSrcweir 	{
487cdf0e10cSrcweir 		GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData();
488cdf0e10cSrcweir 		bEnableDel = IsDeleteAllowed(pUserData->sGroupName);
489cdf0e10cSrcweir 
490cdf0e10cSrcweir //		String sGroup = aGroupTLB.GetEntryText(pEntry, 0);
491cdf0e10cSrcweir //		sGroup += GLOS_DELIM;
492cdf0e10cSrcweir //		sGroup += String::CreateFromInt32(aPathLB.GetEntryPos(aGroupTLB.GetEntryText(pEntry, 1)));
493cdf0e10cSrcweir //		bEnableDel = IsDeleteAllowed(sGroup);
494cdf0e10cSrcweir 	}
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	aDelPB.Enable(bEnableDel);
497cdf0e10cSrcweir 	aNewPB.Enable(bEnableNew);
498cdf0e10cSrcweir 	aRenamePB.Enable(bEnableNew && pEntry);
499cdf0e10cSrcweir 	return 0;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir /*------------------------------------------------------------------------
503cdf0e10cSrcweir  Beschreibung:
504cdf0e10cSrcweir ------------------------------------------------------------------------*/
505cdf0e10cSrcweir 
IsDeleteAllowed(const String & rGroup)506cdf0e10cSrcweir sal_Bool SwGlossaryGroupDlg::IsDeleteAllowed(const String &rGroup)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	sal_Bool bDel = (!pGlosHdl->IsReadOnly(&rGroup));
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	// OM: befindet sich der Name unter den den neuen Bereichsnamen,
511cdf0e10cSrcweir 	// dann ist er auch loeschbar! Bei noch nicht existenten Bereichsnamen
512cdf0e10cSrcweir 	// liefert ReadOnly naemlich sal_True.
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	if(pInsertedArr && pInsertedArr->Count())
515cdf0e10cSrcweir 	{
516cdf0e10cSrcweir 		sal_uInt16 nCount = pInsertedArr->Count();
517cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)
518cdf0e10cSrcweir 		{
519cdf0e10cSrcweir 			const String* pTemp = (*pInsertedArr)[i];
520cdf0e10cSrcweir 			if(*pTemp == rGroup)
521cdf0e10cSrcweir 			{
522cdf0e10cSrcweir 				bDel = sal_True;
523cdf0e10cSrcweir 				break;
524cdf0e10cSrcweir 			}
525cdf0e10cSrcweir 		}
526cdf0e10cSrcweir 	}
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	return bDel;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir /*-----------------18.07.97 19:06-------------------
532cdf0e10cSrcweir 
533cdf0e10cSrcweir --------------------------------------------------*/
KeyInput(const KeyEvent & rKEvent)534cdf0e10cSrcweir void FEdit::KeyInput( const KeyEvent& rKEvent )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	KeyCode aCode = rKEvent.GetKeyCode();
537cdf0e10cSrcweir 	if( KEYGROUP_CURSOR == aCode.GetGroup() ||
538cdf0e10cSrcweir 		( KEYGROUP_MISC == aCode.GetGroup() &&
539cdf0e10cSrcweir 		  KEY_DELETE >= aCode.GetCode() ) ||
540cdf0e10cSrcweir 		SVT_SEARCHPATH_DELIMITER != rKEvent.GetCharCode() )
541cdf0e10cSrcweir 		Edit::KeyInput( rKEvent );
542cdf0e10cSrcweir }
543cdf0e10cSrcweir /* -----------------------------08.02.00 15:07--------------------------------
544cdf0e10cSrcweir 
545cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)546cdf0e10cSrcweir void 	SwGlossaryGroupTLB::RequestHelp( const HelpEvent& rHEvt )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir 	Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
549cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( aPos );
550cdf0e10cSrcweir 	if(pEntry)
551cdf0e10cSrcweir 	{
552cdf0e10cSrcweir 		SvLBoxTab* pTab;
553cdf0e10cSrcweir 		SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
554cdf0e10cSrcweir 		if(pItem)
555cdf0e10cSrcweir 		{
556cdf0e10cSrcweir 			aPos = GetEntryPosition( pEntry );
557cdf0e10cSrcweir 			Size aSize(pItem->GetSize( this, pEntry ));
558cdf0e10cSrcweir 			aPos.X() = GetTabPos( pEntry, pTab );
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 			if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
561cdf0e10cSrcweir 				aSize.Width() = GetSizePixel().Width() - aPos.X();
562cdf0e10cSrcweir 			aPos = OutputToScreenPixel(aPos);
563cdf0e10cSrcweir 			Rectangle aItemRect( aPos, aSize );
564cdf0e10cSrcweir 			String sMsg;
565cdf0e10cSrcweir 			GlosBibUserData* pData = (GlosBibUserData*)pEntry->GetUserData();
566cdf0e10cSrcweir 			sMsg = pData->sPath;
567cdf0e10cSrcweir 			sMsg += INET_PATH_TOKEN;
568cdf0e10cSrcweir 			sMsg += pData->sGroupName.GetToken(0, GLOS_DELIM);
569cdf0e10cSrcweir 			sMsg += SwGlossaries::GetExtension();
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 			Help::ShowQuickHelp( this, aItemRect, sMsg,
572cdf0e10cSrcweir 						QUICKHELP_LEFT|QUICKHELP_VCENTER );
573cdf0e10cSrcweir 		}
574cdf0e10cSrcweir 	}
575cdf0e10cSrcweir }
576