xref: /AOO41X/main/sw/source/ui/misc/glossary.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #ifdef SW_DLLIMPLEMENTATION
32 #undef SW_DLLIMPLEMENTATION
33 #endif
34 
35 #define _SVSTDARR_STRINGSDTOR
36 #define _SVSTDARR_STRINGS
37 #include <hintids.hxx>
38 
39 #include <vcl/menu.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/help.hxx>
42 #ifndef _SVSTDARR_HXX
43 #include <svl/svstdarr.hxx>
44 #endif
45 #include <svl/stritem.hxx>
46 #include <unotools/pathoptions.hxx>
47 #include <unotools/lingucfg.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/fcontnr.hxx>
50 
51 #include <svx/svxdlg.hxx>
52 #include <svx/dialogs.hrc>
53 #include <editeng/acorrcfg.hxx>
54 #include <sfx2/viewfrm.hxx>
55 #include <unocrsr.hxx>
56 #include <unotools.hxx>
57 #include <comphelper/processfactory.hxx>
58 #include <ucbhelper/content.hxx>
59 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
60 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
61 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
62 #include <svl/urihelper.hxx>
63 #include <unotools/charclass.hxx>
64 #include <swwait.hxx>
65 #include <swtypes.hxx>
66 #include <wrtsh.hxx>
67 #include <view.hxx>
68 #include <basesh.hxx>
69 #include <glossary.hxx>
70 #include <gloshdl.hxx>
71 #include <glosbib.hxx>
72 #include <initui.hxx>					// fuer ::GetGlossaries()
73 #include <glosdoc.hxx>
74 #include <macassgn.hxx>
75 #include <swevent.hxx>
76 #include <docsh.hxx>
77 #include <shellio.hxx>
78 
79 #include <cmdid.h>
80 #include <helpid.h>
81 #include <swerror.h>
82 #ifndef _GLOBALS_HRC
83 #include <globals.hrc>
84 #endif
85 #ifndef _MISC_HRC
86 #include <misc.hrc>
87 #endif
88 #ifndef _GLOSSARY_HRC
89 #include <glossary.hrc>
90 #endif
91 #include <swmodule.hxx>
92 #include <sfx2/filedlghelper.hxx>
93 
94 #include "access.hrc"
95 
96 #define LONG_LENGTH 60
97 #define SHORT_LENGTH 30
98 
99 
100 using namespace ::com::sun::star;
101 using namespace ::com::sun::star::lang;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::text;
104 using namespace ::com::sun::star::ucb;
105 using namespace ::com::sun::star::ui::dialogs;
106 using namespace ::comphelper;
107 using namespace ::ucbhelper;
108 using ::rtl::OUString;
109 using namespace ::sfx2;
110 
111 String lcl_GetValidShortCut( const String& rName )
112 {
113     const sal_uInt16 nSz = rName.Len();
114 
115     if ( 0 == nSz )
116         return rName;
117 
118     sal_uInt16 nStart = 1;
119     while( rName.GetChar( nStart-1 ) == ' ' && nStart < nSz )
120         nStart++;
121 
122     String aBuf( rName.GetChar( nStart-1 ));
123 
124     for( ; nStart < nSz; ++nStart )
125     {
126         if( rName.GetChar( nStart-1 ) == ' ' && rName.GetChar( nStart ) != ' ')
127             aBuf += rName.GetChar( nStart );
128     }
129     return aBuf;
130 }
131 
132 /* -----------------------------08.02.00 10:28--------------------------------
133 
134  ---------------------------------------------------------------------------*/
135 struct GroupUserData
136 {
137 	String 		sGroupName;
138 	sal_uInt16 	nPathIdx;
139 	sal_Bool 		bReadonly;
140 
141 	GroupUserData()
142 		: nPathIdx(0),
143 		  bReadonly(sal_False)	{}
144 };
145 
146 /*------------------------------------------------------------------------
147  Beschreibung:	Dialog fuer neuen Bausteinnamen
148 ------------------------------------------------------------------------*/
149 class SwNewGlosNameDlg : public ModalDialog
150 {
151 	FixedText		aNNFT;
152 	Edit			aNewName;
153 	FixedText		aNSFT;
154 	NoSpaceEdit		aNewShort;
155 	OKButton		aOk;
156 	CancelButton	aCancel;
157 	FixedText		aONFT;
158 	Edit			aOldName;
159 	FixedText 		aOSFT;
160 	Edit			aOldShort;
161 	FixedLine       aFL;
162 
163 protected:
164 	DECL_LINK( Modify, Edit * );
165 	DECL_LINK( Rename, Button * );
166 
167 public:
168 	SwNewGlosNameDlg( Window* pParent,
169 					  const String& rOldName,
170 					  const String& rOldShort );
171 
172 	String GetNewName()  const { return aNewName.GetText(); }
173 	String GetNewShort() const { return aNewShort.GetText(); }
174 };
175 
176 SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent,
177 							const String& rOldName,
178 							const String& rOldShort ) :
179 	ModalDialog( pParent, SW_RES( DLG_RENAME_GLOS ) ),
180     aNNFT   (this, SW_RES( FT_NN    )),
181     aNewName(this, SW_RES( ED_NN    )),
182     aNSFT   (this, SW_RES( FT_NS    )),
183     aNewShort(this,SW_RES( ED_NS    )),
184 	aOk		(this, SW_RES( BT_OKNEW)),
185 	aCancel	(this, SW_RES( BT_CANCEL)),
186 	aONFT	(this, SW_RES( FT_ON	)),
187     aOldName(this, SW_RES( ED_ON    )),
188 	aOSFT	(this, SW_RES( FT_OS	)),
189     aOldShort(this,SW_RES( ED_OS    )),
190     aFL    (this, SW_RES( FL_NN    ))
191 
192 {
193 	FreeResource();
194 	aOldName.SetText( rOldName );
195 	aOldShort.SetText( rOldShort );
196 	aNewShort.SetMaxTextLen(SHORT_LENGTH);
197 	aNewName.SetMaxTextLen(LONG_LENGTH);
198 	aNewName.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
199 	aNewShort.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
200 	aOk.SetClickHdl(LINK(this, SwNewGlosNameDlg, Rename ));
201 	aNewName.GrabFocus();
202 }
203 
204 /*------------------------------------------------------------------------
205  Beschreibung:	aktuell eingestellte Gruppe erfragen / setzen
206 ------------------------------------------------------------------------*/
207 
208 String SwGlossaryDlg::GetCurrGroup()
209 {
210 	if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() )
211 		return *(::GetCurrGlosGroup());
212 	return SwGlossaries::GetDefName();
213 }
214 
215 
216 
217 void SwGlossaryDlg::SetActGroup(const String &rGrp)
218 {
219 	if( !::GetCurrGlosGroup() )
220 		::SetCurrGlosGroup( new String );
221 	*(::GetCurrGlosGroup()) = rGrp;
222 }
223 
224 
225 
226 SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
227 							SwGlossaryHdl * pGlosHdl, SwWrtShell *pWrtShell) :
228 
229 	SvxStandardDialog(&pViewFrame->GetWindow(), SW_RES(DLG_GLOSSARY)),
230 
231     aInsertTipCB  (this, SW_RES(CB_INSERT_TIP)),
232 	aNameLbl	  (this, SW_RES(FT_NAME)),
233 	aNameED       (this, SW_RES(ED_NAME)),
234 	aShortNameLbl (this, SW_RES(FT_SHORTNAME)),
235 	aShortNameEdit(this, SW_RES(ED_SHORTNAME)),
236 	aCategoryBox  (this, SW_RES(LB_BIB)),
237     aRelativeFL   (this, SW_RES(FL_RELATIVE)),
238     aFileRelCB    (this, SW_RES(CB_FILE_REL)),
239 	aNetRelCB     (this, SW_RES(CB_NET_REL)),
240     aExampleWIN   (this, SW_RES(WIN_EXAMPLE )),
241     aExampleDummyWIN(this, SW_RES(WIN_EXAMPLE_DUMMY )),
242     aShowExampleCB(this, SW_RES(CB_SHOW_EXAMPLE )),
243     aInsertBtn    (this, SW_RES(PB_INSERT)),
244     aCloseBtn     (this, SW_RES(PB_CLOSE)),
245     aHelpBtn      (this, SW_RES(PB_HELP)),
246     aEditBtn      (this, SW_RES(PB_EDIT)),
247 	aBibBtn		  (this, SW_RES(PB_BIB)),
248 	aPathBtn	  (this, SW_RES(PB_PATH)),
249 
250     sReadonlyPath (SW_RES(ST_READONLY_PATH)),
251     pExampleFrame(0),
252 
253     pMenu         (new PopupMenu(SW_RES(MNU_EDIT))),
254 	pGlossaryHdl  (pGlosHdl),
255 
256     bResume(sal_False),
257 
258     bSelection( pWrtShell->IsSelection() ),
259     bReadOnly( sal_False ),
260     bIsOld( sal_False ),
261     bIsDocReadOnly(sal_False),
262 
263     pSh           (pWrtShell)
264 {
265     SvtLinguConfig aLocalLinguConfig;
266 
267     // Static-Pointer initialisieren
268 	if( !::GetCurrGlosGroup() )
269 		::SetCurrGlosGroup(new String);//(SwGlossaries::GetDefName());
270 
271 	pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl));
272 	pMenu->SetSelectHdl(LINK(this,SwGlossaryDlg,MenuHdl));
273 	aEditBtn.SetPopupMenu(pMenu);
274 	aEditBtn.SetSelectHdl(LINK(this,SwGlossaryDlg,EditHdl));
275 	aPathBtn.SetClickHdl(LINK(this, SwGlossaryDlg, PathHdl));
276 
277 	aNameED.SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
278 	aShortNameEdit.SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
279 
280 	aCategoryBox.SetDoubleClickHdl(LINK(this,SwGlossaryDlg, NameDoubleClick));
281 	aCategoryBox.SetSelectHdl(LINK(this,SwGlossaryDlg,GrpSelect));
282 	aBibBtn.SetClickHdl(LINK(this,SwGlossaryDlg,BibHdl));
283 	aShowExampleCB.SetClickHdl(LINK(this, SwGlossaryDlg, ShowPreviewHdl));
284 
285 	aShortNameEdit.SetMaxTextLen(SHORT_LENGTH);
286 	aNameED.SetMaxTextLen(LONG_LENGTH);
287 	FreeResource();
288 
289 	const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
290 
291 	aShowExampleCB.Check( pCfg->IsAutoTextPreview());
292 	ShowPreviewHdl(&aShowExampleCB);
293 
294 	bIsDocReadOnly = pSh->GetView().GetDocShell()->IsReadOnly() ||
295 					  pSh->HasReadonlySel();
296 	if( bIsDocReadOnly )
297 		aInsertBtn.Enable(sal_False);
298 	aNameED.GrabFocus();
299 	aCategoryBox.SetHelpId(HID_MD_GLOS_CATEGORY);
300 	aCategoryBox.SetStyle(aCategoryBox.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL|WB_VSCROLL|WB_CLIPCHILDREN|WB_SORT);
301 	aCategoryBox.GetModel()->SetSortMode(SortAscending);
302 	aCategoryBox.SetHighlightRange();	// ueber volle Breite selektieren
303 	aCategoryBox.SetNodeDefaultImages( );
304 	aCategoryBox.SetAccessibleName(SW_RES(STR_ACCESS_SW_CATEGORY));
305 	aCategoryBox.SetAccessibleRelationLabeledBy(&aInsertTipCB);
306 
307 	Init();
308 }
309 /*--------------------------------------------------------------------
310 	 Beschreibung:
311  --------------------------------------------------------------------*/
312 
313 
314 SwGlossaryDlg::~SwGlossaryDlg()
315 {
316 	SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
317 	pCfg->SetAutoTextPreview(aShowExampleCB.IsChecked()) ;
318 
319 	aCategoryBox.Clear();
320 	aEditBtn.SetPopupMenu(0);
321 	delete pMenu;
322 	delete pExampleFrame;
323 }
324 /*------------------------------------------------------------------------
325  Beschreibung:	Auswahl neue Gruppe
326 ------------------------------------------------------------------------*/
327 
328 
329 IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
330 {
331 	SvLBoxEntry* pEntry = pBox->FirstSelected();
332 	if(!pEntry)
333 		return 0;
334 	SvLBoxEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
335 	GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
336 	String *pGlosGroup = ::GetCurrGlosGroup();
337 	(*pGlosGroup) = pGroupData->sGroupName;
338 	(*pGlosGroup) += GLOS_DELIM;
339 	(*pGlosGroup) += String::CreateFromInt32(pGroupData->nPathIdx);
340 	pGlossaryHdl->SetCurGroup(*pGlosGroup);
341 	// Aktuellen Textbaustein setzen
342 	bReadOnly = pGlossaryHdl->IsReadOnly();
343 	EnableShortName( !bReadOnly );
344 	aEditBtn.Enable(!bReadOnly);
345 	bIsOld = pGlossaryHdl->IsOld();
346 	if( pParent != pEntry)
347 	{
348 		String aName(pBox->GetEntryText(pEntry));
349 		aNameED.SetText(aName);
350 		aShortNameEdit.SetText(*(String*)pEntry->GetUserData());
351 		pEntry = pBox->GetParent(pEntry);
352 		aInsertBtn.Enable( !bIsDocReadOnly);
353 		ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit.GetText());
354 	}
355 	else
356 		ShowAutoText(aEmptyStr, aEmptyStr);
357 	//Controls aktualisieren
358 	NameModify(&aShortNameEdit);
359     if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
360 	{
361         SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
362 		String sTemp(*::GetCurrGlosGroup());
363 		// der nullte Pfad wird nicht aufgezeichnet!
364         if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
365 			sTemp = sTemp.GetToken(0, GLOS_DELIM);
366 		aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
367 		aReq.Done();
368 	}
369 	return 0;
370 }
371 /*--------------------------------------------------------------------
372 	 Beschreibung:
373  --------------------------------------------------------------------*/
374 
375 
376 void SwGlossaryDlg::Apply()
377 {
378 	const String aGlosName(aShortNameEdit.GetText());
379 	if(aGlosName.Len())	pGlossaryHdl->InsertGlossary(aGlosName);
380     if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
381 	{
382         SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY );
383 		String sTemp(*::GetCurrGlosGroup());
384 		// der nullte Pfad wird nicht aufgezeichnet!
385         if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
386 			sTemp = sTemp.GetToken(0, GLOS_DELIM);
387 		aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp));
388 		aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
389 		aReq.Done();
390 	}
391 }
392 /*--------------------------------------------------------------------
393 	 Beschreibung:
394  --------------------------------------------------------------------*/
395 /* inline */ void SwGlossaryDlg::EnableShortName(sal_Bool bOn)
396 {
397 	aShortNameLbl.Enable(bOn);
398 	aShortNameEdit.Enable(bOn);
399 }
400 
401 /* -----------------26.11.98 16:15-------------------
402  * existiert der Titel in der ausgewaehlten Gruppe?
403  * --------------------------------------------------*/
404 SvLBoxEntry* SwGlossaryDlg::DoesBlockExist(const String& rBlock,
405 				const String& rShort)
406 {
407 	//evtl. vorhandenen Eintrag in der TreeListBox suchen
408 	SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
409     if(pEntry)
410     {
411         if(aCategoryBox.GetParent(pEntry))
412             pEntry = aCategoryBox.GetParent(pEntry);
413         sal_uInt32 nChildCount = aCategoryBox.GetChildCount( pEntry );
414         for(sal_uInt32 i = 0; i < nChildCount; i++)
415         {
416             SvLBoxEntry* pChild = aCategoryBox.GetEntry( pEntry, i );
417             if(rBlock == aCategoryBox.GetEntryText(pChild) &&
418                 (!rShort.Len() || rShort == *(String*)pChild->GetUserData()))
419             {
420                 return pChild;
421             }
422         }
423     }
424 	return 0;
425 }
426 
427 /*--------------------------------------------------------------------
428 	 Beschreibung:
429  --------------------------------------------------------------------*/
430 
431 
432 IMPL_LINK( SwGlossaryDlg, NameModify, Edit *, pEdit )
433 {
434 	String aName(aNameED.GetText());
435 	sal_Bool bNameED = pEdit == &aNameED;
436 	if( !aName.Len() )
437 	{
438 		if(bNameED)
439 			aShortNameEdit.SetText(aName);
440 		aInsertBtn.Enable(sal_False);
441 		return 0;
442 	}
443 	String sShortSearch;
444 	if(!bNameED)
445 		sShortSearch = pEdit->GetText();
446 	sal_Bool bNotFound = !DoesBlockExist(aName, sShortSearch);
447 	if(bNameED)
448 	{
449 			// ist der Text durch einen Klick in die Listbox in das
450 			// Edit gekommem?
451 		if(bNotFound)
452 		{
453             aShortNameEdit.SetText( lcl_GetValidShortCut( aName ) );
454 			EnableShortName();
455 		}
456 		else
457 		{
458 			aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aName));
459 			EnableShortName(!bReadOnly);
460 		}
461 		aInsertBtn.Enable(!bNotFound && !bIsDocReadOnly);
462 	}
463 	else
464 	{
465 		//ShortNameEdit
466 		if(!bNotFound)
467 		{
468 			sal_Bool bEnable = !bNotFound;
469 			bEnable &= !bIsDocReadOnly;
470 			aInsertBtn.Enable(bEnable);
471 		}
472 	}
473 	return 0;
474 }
475 /*--------------------------------------------------------------------
476 	 Beschreibung:
477  --------------------------------------------------------------------*/
478 
479 
480 IMPL_LINK_INLINE_START( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox )
481 {
482 	SvLBoxEntry* pEntry = pBox->FirstSelected();
483 	if(pBox->GetParent(pEntry) && !bIsDocReadOnly)
484 		EndDialog( RET_OK );
485 	return 0;
486 }
487 IMPL_LINK_INLINE_END( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, EMPTYARG )
488 /*--------------------------------------------------------------------
489 	 Beschreibung:
490  --------------------------------------------------------------------*/
491 
492 
493 IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn )
494 {
495 	const String aEditText(aNameED.GetText());
496 	const sal_Bool bHasEntry = aEditText.Len() && aShortNameEdit.GetText().Len();
497 	const sal_Bool bExists = 0 != DoesBlockExist(aEditText, aShortNameEdit.GetText());
498 	pMn->EnableItem(FN_GL_DEFINE, bSelection && bHasEntry && !bExists);
499 	pMn->EnableItem(FN_GL_DEFINE_TEXT, bSelection && bHasEntry && !bExists);
500 	pMn->EnableItem(FN_GL_COPY_TO_CLIPBOARD, bExists);
501 	pMn->EnableItem(FN_GL_REPLACE, bSelection && bExists && !bIsOld );
502 	pMn->EnableItem(FN_GL_REPLACE_TEXT, bSelection && bExists && !bIsOld );
503 	pMn->EnableItem(FN_GL_EDIT, bExists );
504     pMn->EnableItem(FN_GL_RENAME, bExists  );
505     pMn->EnableItem(FN_GL_DELETE, bExists  );
506 	pMn->EnableItem(FN_GL_MACRO, bExists && !bIsOld  &&
507 									!pGlossaryHdl->IsReadOnly() );
508 
509 	SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
510 	sal_Bool bEnable = sal_False;
511 	if ( pEntry )
512 		bEnable = !aCategoryBox.GetParent( pEntry ) && !bIsOld && !pGlossaryHdl->IsReadOnly();
513 	pMn->EnableItem( FN_GL_IMPORT, bEnable );
514 	return 1;
515 }
516 /*--------------------------------------------------------------------
517 	 Beschreibung:
518  --------------------------------------------------------------------*/
519 
520 
521 IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
522 {
523 	sal_Bool bNoAttr = sal_False;
524 
525 	switch(pMn->GetCurItemId())
526 	{
527 		case FN_GL_REPLACE:
528 		case FN_GL_REPLACE_TEXT:
529 			pGlossaryHdl->NewGlossary(	aNameED.GetText(),
530 										aShortNameEdit.GetText(),
531 										sal_False,
532 										pMn->GetCurItemId() == FN_GL_REPLACE_TEXT);
533 		break;
534 		case FN_GL_DEFINE_TEXT:
535 			bNoAttr = sal_True;
536 			// Kein break!!!
537 		case FN_GL_DEFINE:
538 		{
539 			const String aStr(aNameED.GetText());
540 			const String aShortName(aShortNameEdit.GetText());
541 			if(pGlossaryHdl->HasShortName(aShortName))
542 			{
543 				InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
544 				aShortNameEdit.SetSelection(Selection(0, SELECTION_MAX));
545 				aShortNameEdit.GrabFocus();
546 				break;
547 			}
548 			if(pGlossaryHdl->NewGlossary(aStr, aShortName, sal_False, bNoAttr ))
549 			{
550 				SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
551 				if(aCategoryBox.GetParent(pEntry))
552 					pEntry = aCategoryBox.GetParent(pEntry);
553 
554 				SvLBoxEntry* pChild = aCategoryBox.InsertEntry(aStr, pEntry);
555 				pChild->SetUserData(new String(aShortName));
556 				aNameED.SetText(aStr);
557 				aShortNameEdit.SetText(aShortName);
558 				NameModify(&aNameED);		// fuer Schalten der Buttons
559 
560                 if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
561 				{
562                     SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
563 					String sTemp(*::GetCurrGlosGroup());
564 					// der nullte Pfad wird nicht aufgezeichnet!
565                     if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
566 						sTemp = sTemp.GetToken(0, GLOS_DELIM);
567 					aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp));
568 					aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
569 					aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
570 					aReq.Done();
571 				}
572 			}
573 		}
574 		break;
575 		case FN_GL_COPY_TO_CLIPBOARD :
576 		{
577 			pGlossaryHdl->CopyToClipboard(*pSh, aShortNameEdit.GetText());
578 		}
579 		break;
580 		case FN_GL_EDIT:
581 		break;
582 		case FN_GL_RENAME:
583 		{
584 			aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aNameED.GetText()));
585 			SwNewGlosNameDlg* pNewNameDlg = new SwNewGlosNameDlg(this, aNameED.GetText(),
586 											aShortNameEdit.GetText() );
587 			if( RET_OK == pNewNameDlg->Execute() &&
588 				pGlossaryHdl->Rename( aShortNameEdit.GetText(),
589 										pNewNameDlg->GetNewShort(),
590 										pNewNameDlg->GetNewName()))
591 			{
592 				SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
593 				SvLBoxEntry* pNewEntry = aCategoryBox.InsertEntry(
594 						pNewNameDlg->GetNewName(), aCategoryBox.GetParent(pEntry));
595 				pNewEntry->SetUserData(new String(pNewNameDlg->GetNewShort()));
596 				delete (String*)pEntry->GetUserData();
597 				aCategoryBox.GetModel()->Remove(pEntry);
598 				aCategoryBox.Select(pNewEntry);
599 				aCategoryBox.MakeVisible(pNewEntry);
600 			}
601 			GrpSelect( &aCategoryBox );
602 			delete pNewNameDlg;
603 		}
604 		break;
605 		case FN_GL_DELETE:
606 		{
607 			QueryBox aQuery(this, SW_RES(MSG_QUERY_DELETE));
608 			if(RET_YES == aQuery.Execute())
609 			{
610 				const String aShortName(aShortNameEdit.GetText());
611 				const String aTitle(aNameED.GetText());
612 				if(aTitle.Len() && pGlossaryHdl->DelGlossary(aShortName))
613 				{
614 					SvLBoxEntry* pChild = DoesBlockExist(aTitle, aShortName);
615 					DBG_ASSERT(pChild, "Eintrag nicht gefunden!");
616 					SvLBoxEntry* pParent = aCategoryBox.GetParent(pChild);
617 					aCategoryBox.Select(pParent);
618 
619 					aCategoryBox.GetModel()->Remove(pChild);
620 					aNameED.SetText( aEmptyStr );
621 					NameModify(&aNameED);
622 				}
623 			}
624 		}
625 		break;
626 		case FN_GL_MACRO:
627 		{
628 			SfxItemSet aSet( pSh->GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
629 
630             SvxMacro aStart(aEmptyStr, aEmptyStr, STARBASIC);
631 			SvxMacro aEnd(aEmptyStr, aEmptyStr, STARBASIC);
632 			pGlossaryHdl->GetMacros(aShortNameEdit.GetText(), aStart, aEnd );
633 
634             SvxMacroItem aItem(RES_FRMMACRO);
635 			if( aStart.GetMacName().Len() )
636 				aItem.SetMacro( SW_EVENT_START_INS_GLOSSARY, aStart );
637 			if( aEnd.GetMacName().Len() )
638 				aItem.SetMacro( SW_EVENT_END_INS_GLOSSARY, aEnd );
639 
640 			aSet.Put( aItem );
641 			aSet.Put( SwMacroAssignDlg::AddEvents( MACASSGN_TEXTBAUST ) );
642 
643 			const SfxPoolItem* pItem;
644 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
645 			SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet,
646 				pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG );
647 			if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
648 				SFX_ITEM_SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, sal_False, &pItem ) )
649 			{
650 				const SvxMacroTableDtor& rTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
651 				pGlossaryHdl->SetMacros( aShortNameEdit.GetText(),
652 											rTbl.Get( SW_EVENT_START_INS_GLOSSARY ),
653 											rTbl.Get( SW_EVENT_END_INS_GLOSSARY ) );
654 			}
655 
656 			delete pMacroDlg;
657 		}
658 		break;
659 
660 		case FN_GL_IMPORT:
661 		{
662 			// call the FileOpenDialog do find WinWord - Files with templates
663             FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
664             uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
665 
666 			SvtPathOptions aPathOpt;
667             xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
668 			String sWW8( C2S( FILTER_WW8 ) );
669 
670             uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
671 			SfxFilterMatcher aMatcher( String::CreateFromAscii(SwDocShell::Factory().GetShortName()) );
672 			SfxFilterMatcherIter aIter( &aMatcher );
673             const SfxFilter* pFilter = aIter.First();
674 			while ( pFilter )
675 			{
676 				if( pFilter->GetUserData() == sWW8 )
677 				{
678                     xFltMgr->appendFilter( pFilter->GetUIName(),
679                                 ((WildCard&)pFilter->GetWildcard()).GetWildCard() );
680                     xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
681                 }
682 
683 				pFilter = aIter.Next();
684 			}
685 
686             if( aDlgHelper.Execute() == ERRCODE_NONE )
687 			{
688                 if( pGlossaryHdl->ImportGlossaries( xFP->getFiles().getConstArray()[0] ))
689 					Init();
690 				else
691 				{
692 					InfoBox(this, SW_RES( MSG_NO_GLOSSARIES )).Execute();
693 				}
694 			}
695 		}
696 	   	break;
697 
698 		default:
699 			return 0;
700 	}
701 	return 1;
702 }
703 /*--------------------------------------------------------------------
704 	 Beschreibung:	Dialog Verwaltung Bereiche
705  --------------------------------------------------------------------*/
706 
707 
708 IMPL_LINK( SwGlossaryDlg, BibHdl, Button *, EMPTYARG )
709 {
710 	SwGlossaries* pGloss = ::GetGlossaries();
711 	if( pGloss->IsGlosPathErr() )
712 		pGloss->ShowError();
713 	else
714 	{
715 		//check if at least one glossary path is write enabled
716 		SvtPathOptions aPathOpt;
717 		String sGlosPath( aPathOpt.GetAutoTextPath() );
718 		sal_uInt16 nPaths = sGlosPath.GetTokenCount(';');
719 		sal_Bool bIsWritable = sal_False;
720 		for(sal_uInt16 nPath = 0; nPath < nPaths; nPath++)
721 		{
722             String sPath = URIHelper::SmartRel2Abs(
723                 INetURLObject(), sGlosPath.GetToken(nPath, ';'),
724                 URIHelper::GetMaybeFileHdl());
725 			try
726 			{
727 				Content aTestContent( sPath,
728 							uno::Reference< XCommandEnvironment >());
729 				Any aAny = aTestContent.getPropertyValue( C2U("IsReadOnly") );
730 				if(aAny.hasValue())
731 				{
732 					bIsWritable = !*(sal_Bool*)aAny.getValue();
733 				}
734 			}
735             catch(Exception&)
736 			{}
737 			if(bIsWritable)
738 				break;
739 		}
740 		if(bIsWritable)
741 		{
742 
743 			SwGlossaryGroupDlg *pDlg = new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
744 			if ( RET_OK == pDlg->Execute() )
745 			{
746 				Init();
747 				//if new groups were created - select one of them
748 				String sNewGroup = pDlg->GetCreatedGroupName();
749 				SvLBoxEntry* pEntry = aCategoryBox.First();
750 				while(sNewGroup.Len() && pEntry)
751 				{
752 					if(!aCategoryBox.GetParent(pEntry))
753 					{
754 						GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
755 						String sGroup = pGroupData->sGroupName;
756 						sGroup += GLOS_DELIM;
757 						sGroup += String::CreateFromInt32(pGroupData->nPathIdx);
758 						if(sGroup == sNewGroup)
759 						{
760 							aCategoryBox.Select(pEntry);
761 							aCategoryBox.MakeVisible(pEntry);
762 							GrpSelect(&aCategoryBox);
763 							break;
764 						}
765 					}
766 					pEntry = aCategoryBox.Next(pEntry);
767 				}
768 
769 			}
770 			delete pDlg;
771 		}
772 		else
773 		{
774 			QueryBox aBox(this, WB_YES_NO, sReadonlyPath);
775 			if(RET_YES == aBox.Execute())
776 				PathHdl(&aPathBtn);
777 		}
778 	}
779 	return 0;
780 }
781 
782 /*------------------------------------------------------------------------
783  Beschreibung:	Initialisierung; aus Ctor und nach Bearbeiten Bereiche
784 ------------------------------------------------------------------------*/
785 
786 
787 void SwGlossaryDlg::Init()
788 {
789 	aCategoryBox.SetUpdateMode( sal_False );
790 	aCategoryBox.Clear();
791 	// Textbausteinbereiche anzeigen
792 	const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt();
793 	SvLBoxEntry* pSelEntry = 0;
794     const String sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM));
795     const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM).ToInt32());
796 	for(sal_uInt16 nId = 0; nId < nCnt; ++nId )
797 	{
798 		String sTitle;
799 		String sGroupName(pGlossaryHdl->GetGroupName(nId, &sTitle));
800         if(!sGroupName.Len())
801             continue;
802 		if(!sTitle.Len())
803 			sTitle = sGroupName.GetToken( 0, GLOS_DELIM );
804 		SvLBoxEntry* pEntry = aCategoryBox.InsertEntry( sTitle );
805         sal_uInt16 nPath = static_cast< sal_uInt16 >(sGroupName.GetToken( 1, GLOS_DELIM ).ToInt32());
806 
807 		GroupUserData* pData = new GroupUserData;
808 		pData->sGroupName = sGroupName.GetToken(0, GLOS_DELIM);
809 		pData->nPathIdx = nPath;
810 		pData->bReadonly = pGlossaryHdl->IsReadOnly(&sGroupName);
811 
812 		pEntry->SetUserData(pData);
813 		if(sSelStr == pData->sGroupName && nSelPath == nPath)
814 			pSelEntry = pEntry;
815 
816 		//Eintraege fuer die Gruppen auffuellen
817 		{
818 			pGlossaryHdl->SetCurGroup(sGroupName, sal_False, sal_True);
819 			const sal_uInt16 nCount = pGlossaryHdl->GetGlossaryCnt();
820 			for(sal_uInt16 i = 0; i < nCount; ++i)
821 			{
822                 String sGroupTitle(pGlossaryHdl->GetGlossaryName(i));
823 				SvLBoxEntry* pChild = aCategoryBox.InsertEntry(
824                                     sGroupTitle, pEntry);
825 				pChild->SetUserData(new String(pGlossaryHdl->GetGlossaryShortName(i)));
826 			}
827 		}
828 	}
829 		// Aktuelle Gruppe setzen und Textbausteine anzeigen
830 	if(!pSelEntry)
831 	{
832 		//find a non-readonly group
833 		SvLBoxEntry* pSearch = aCategoryBox.First();
834 		while(pSearch)
835 		{
836 			if(!aCategoryBox.GetParent(pSearch))
837 			{
838 				GroupUserData* pData = (GroupUserData*)pSearch->GetUserData();
839 				if(!pData->bReadonly)
840 				{
841 					pSelEntry = pSearch;
842 					break;
843 				}
844 			}
845 			pSearch = aCategoryBox.Next(pSearch);
846 		}
847 		if(!pSelEntry)
848 			pSelEntry = aCategoryBox.GetEntry(0);
849 	}
850 	if(pSelEntry)
851 	{
852 		aCategoryBox.Expand(pSelEntry);
853 		aCategoryBox.Select(pSelEntry);
854 		aCategoryBox.MakeVisible(pSelEntry);
855 		GrpSelect(&aCategoryBox);
856 	}
857 	//JP 16.11.99: the SvxTreeListBox has a Bug. The Box dont recalc the
858 	//		outputsize, when all entries are insertet. The result is, that
859 	//		the Focus/Highlight rectangle is to large and paintet over the
860 	//		HScrollbar. -> Fix: call the resize
861 	aCategoryBox.Resize();
862 
863 	aCategoryBox.GetModel()->Resort();
864 	aCategoryBox.SetUpdateMode( sal_True );
865 	aCategoryBox.Update();
866 
867 	const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
868 	aFileRelCB.Check( pCfg->IsSaveRelFile() );
869 	aFileRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
870 	aNetRelCB.Check( pCfg->IsSaveRelNet() );
871 	aNetRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
872 	aInsertTipCB.Check( pCfg->IsAutoTextTip() );
873 	aInsertTipCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
874 }
875 /*------------------------------------------------------------------------
876  Beschreibung:
877 ------------------------------------------------------------------------*/
878 
879 
880 IMPL_LINK_INLINE_START( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )
881 {
882 //EndDialog darf nicht im MenuHdl aufgerufen werden
883 	if(aEditBtn.GetCurItemId() == FN_GL_EDIT )
884 	{
885 		SwTextBlocks *pGroup = ::GetGlossaries()->GetGroupDoc (  GetCurrGrpName () );
886 		sal_Bool bRet = pGlossaryHdl->ConvertToNew ( *pGroup );
887 		delete pGroup;
888 		if ( bRet )
889 			EndDialog(RET_EDIT);
890 	}
891 	return 0;
892 }
893 IMPL_LINK_INLINE_END( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )
894 
895 /*------------------------------------------------------------------------
896  Beschreibung:	KeyInput fuer ShortName - Edits ohne Spaces
897 ------------------------------------------------------------------------*/
898 
899 IMPL_LINK( SwNewGlosNameDlg, Modify, Edit *, pBox )
900 {
901 	String aName(aNewName.GetText());
902 	SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
903 
904 	if( pBox == &aNewName )
905         aNewShort.SetText( lcl_GetValidShortCut( aName ) );
906 
907 	sal_Bool bEnable = aName.Len() && aNewShort.GetText().Len() &&
908 		(!pDlg->DoesBlockExist(aName, aNewShort.GetText())
909 			|| aName == aOldName.GetText());
910 	aOk.Enable(bEnable);
911 	return 0;
912 }
913 /*------------------------------------------------------------------------
914  Beschreibung:
915 ------------------------------------------------------------------------*/
916 
917 IMPL_LINK( SwNewGlosNameDlg, Rename, Button *, EMPTYARG )
918 {
919 	SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
920 	String sNew = aNewShort.GetText();
921 	GetAppCharClass().toUpper(sNew);
922 	if( pDlg->pGlossaryHdl->HasShortName(aNewShort.GetText())
923 		&& sNew != aOldShort.GetText() )
924 	{
925 		InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
926 		aNewShort.GrabFocus();
927 	}
928 	else
929 		EndDialog(sal_True);
930 	return 0;
931 }
932 
933 /*------------------------------------------------------------------------
934  Beschreibung:
935 ------------------------------------------------------------------------*/
936 
937 IMPL_LINK( SwGlossaryDlg, CheckBoxHdl, CheckBox *, pBox )
938 {
939 	SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
940 	sal_Bool bCheck = pBox->IsChecked();
941 	if( pBox == &aInsertTipCB )
942 		pCfg->SetAutoTextTip(bCheck);
943 	else if(pBox == &aFileRelCB)
944 		pCfg->SetSaveRelFile(bCheck);
945 	else
946 		pCfg->SetSaveRelNet(bCheck);
947 	return 0;
948 }
949 
950 /* -----------------26.11.98 15:18-------------------
951  * TreeListBox fuer Gruppen und Bausteine
952  * --------------------------------------------------*/
953 SwGlTreeListBox::SwGlTreeListBox(Window* pParent, const ResId& rResId) :
954 	SvTreeListBox(pParent, rResId),
955 	sReadonly	  (SW_RES(ST_READONLY)),
956 	pDragEntry(0)
957 {
958 	FreeResource();
959 	SetDragDropMode( SV_DRAGDROP_CTRL_MOVE|SV_DRAGDROP_CTRL_COPY );
960 }
961 /* -----------------30.11.98 10:49-------------------
962  *
963  * --------------------------------------------------*/
964 void SwGlTreeListBox::Clear()
965 {
966 	SvLBoxEntry* pEntry = First();
967 	while(pEntry)
968 	{
969 		if(GetParent(pEntry))
970 			delete (String*)pEntry->GetUserData();
971 		else
972 			delete (GroupUserData*)pEntry->GetUserData();
973 		pEntry = Next(pEntry);
974 	}
975 	SvTreeListBox::Clear();
976 }
977 
978 /*-----------------10.06.97 14.52-------------------
979 
980 --------------------------------------------------*/
981 void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
982 {
983 	Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
984 	SvLBoxEntry* pEntry = GetEntry( aPos );
985 	// Hilfe gibt es nur fuer die Gruppennamen
986 	if(pEntry)
987 	{
988 		SvLBoxTab* pTab;
989 		SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
990 		if(pItem)
991 		{
992 			aPos = GetEntryPosition( pEntry );
993 		 	Size aSize(pItem->GetSize( this, pEntry ));
994 			aPos.X() = GetTabPos( pEntry, pTab );
995 
996 			if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
997 				aSize.Width() = GetSizePixel().Width() - aPos.X();
998 			aPos = OutputToScreenPixel(aPos);
999 		 	Rectangle aItemRect( aPos, aSize );
1000 			String sMsg;
1001 			if(!GetParent(pEntry))
1002 			{
1003 				GroupUserData* pData = (GroupUserData*)pEntry->GetUserData();
1004 				const SvStrings* pPathArr = ::GetGlossaries()->GetPathArray();
1005 				if(pPathArr->Count())
1006 				{
1007 					sMsg = (*(*pPathArr)[pData->nPathIdx]);
1008 					sMsg += INET_PATH_TOKEN;
1009 					sMsg += pData->sGroupName;
1010 					sMsg += SwGlossaries::GetExtension();
1011 					INetURLObject aTmp(sMsg);
1012 					sMsg = aTmp.GetPath();
1013 
1014 					if(pData->bReadonly)
1015 					{
1016 						sMsg += ' ';
1017 						sMsg += '(';
1018 						sMsg += sReadonly;
1019 						sMsg += ')';
1020 					}
1021 
1022 
1023 				}
1024 			}
1025 			else
1026 				sMsg = *(String*)pEntry->GetUserData();
1027 			Help::ShowQuickHelp( this, aItemRect, sMsg,
1028 						QUICKHELP_LEFT|QUICKHELP_VCENTER );
1029 		}
1030 	}
1031 }
1032 /* -----------------26.11.98 14:42-------------------
1033  *
1034  * --------------------------------------------------*/
1035 DragDropMode SwGlTreeListBox::NotifyStartDrag(
1036                     TransferDataContainer& /*rContainer*/,
1037 					SvLBoxEntry* pEntry )
1038 {
1039 	DragDropMode  eRet;
1040 	pDragEntry = pEntry;
1041 	if(!GetParent(pEntry))
1042 		eRet = SV_DRAGDROP_NONE;
1043 	else
1044 	{
1045 		SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
1046 		SvLBoxEntry* pParent = GetParent(pEntry);
1047 
1048 		GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
1049 		String sEntry(pGroupData->sGroupName);
1050 		sEntry += GLOS_DELIM;
1051 		sEntry += String::CreateFromInt32(pGroupData->nPathIdx);
1052         sal_Int8 nDragOption = DND_ACTION_COPY;
1053 		eRet = SV_DRAGDROP_CTRL_COPY;
1054 		if(!pDlg->pGlossaryHdl->IsReadOnly(&sEntry))
1055 		{
1056 			eRet |= SV_DRAGDROP_CTRL_MOVE;
1057             nDragOption |= DND_ACTION_MOVE;
1058 		}
1059         SetDragOptions( nDragOption );
1060 	}
1061 	return eRet;
1062 }
1063 /* -----------------27.11.98 09:35-------------------
1064  *
1065  * --------------------------------------------------*/
1066 sal_Bool    SwGlTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry)
1067 {
1068 	// TODO: Readonly - Ueberpruefung fehlt noch!
1069 	SvLBoxEntry* pSrcParent = GetParent(pEntry) ? GetParent(pEntry) : pEntry;
1070 	SvLBoxEntry* pDestParent =
1071 		GetParent(pDragEntry ) ? GetParent(pDragEntry ) : pDragEntry ;
1072 	return pDestParent != pSrcParent;
1073 
1074 }
1075 /* -----------------26.11.98 14:42-------------------
1076  *
1077  * --------------------------------------------------*/
1078 sal_Bool  SwGlTreeListBox::NotifyMoving(   SvLBoxEntry*  pTarget,
1079 									SvLBoxEntry*  pEntry,
1080                                     SvLBoxEntry*& /*rpNewParent*/,
1081                                     sal_uLong&        /*rNewChildPos*/
1082 								)
1083 {
1084 	pDragEntry = 0;
1085 	if(!pTarget) //An den Anfang verschieben
1086 	{
1087 		pTarget = GetEntry(0);
1088 	}
1089 	// 1. wird in verschiedene Gruppen verschoben?
1090 	// 2. darf in beiden Gruppen geschrieben werden?
1091 	SvLBoxEntry* pSrcParent = GetParent(pEntry);
1092 	SvLBoxEntry* pDestParent =
1093 		GetParent(pTarget) ? GetParent(pTarget) : pTarget;
1094 	sal_Bool bRet = sal_False;
1095 	if(pDestParent != pSrcParent)
1096 	{
1097 		SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
1098 		SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );
1099 
1100 		GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
1101 		String sSourceGroup(pGroupData->sGroupName);
1102 		sSourceGroup += GLOS_DELIM;
1103 		sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);
1104 		pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
1105 		String sTitle(GetEntryText(pEntry));
1106 		String sShortName(*(String*)pEntry->GetUserData());
1107 
1108 		GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
1109 		String sDestName = pDestData->sGroupName;
1110 		sDestName += GLOS_DELIM;
1111 		sDestName += String::CreateFromInt32(pDestData->nPathIdx);
1112 		bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup,  sShortName,
1113 						sDestName, sTitle, sal_True );
1114 		if(bRet)
1115 		{
1116 			SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
1117 			pChild->SetUserData(new String(sShortName));
1118 			GetModel()->Remove(pEntry);
1119 		}
1120 	}
1121 	return sal_False; //sonst wird der Eintrag automatisch vorgenommen
1122 }
1123 /* -----------------26.11.98 14:42-------------------
1124  *
1125  * --------------------------------------------------*/
1126 sal_Bool  SwGlTreeListBox::NotifyCopying(   SvLBoxEntry*  pTarget,
1127 									SvLBoxEntry*  pEntry,
1128                                     SvLBoxEntry*& /*rpNewParent*/,
1129                                     sal_uLong&        /*rNewChildPos*/
1130 								)
1131 {
1132 	pDragEntry = 0;
1133 	// 1. wird in verschiedene Gruppen verschoben?
1134 	// 2. darf in beiden Gruppen geschrieben werden?
1135 	if(!pTarget) //An den Anfang verschieben
1136 	{
1137 		pTarget = GetEntry(0);
1138 	}
1139 	SvLBoxEntry* pSrcParent = GetParent(pEntry);
1140 	SvLBoxEntry* pDestParent =
1141 		GetParent(pTarget) ? GetParent(pTarget) : pTarget;
1142 	sal_Bool bRet = sal_False;
1143 	if(pDestParent != pSrcParent)
1144 	{
1145 		SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
1146 		SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );
1147 
1148 		GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
1149 		String sSourceGroup(pGroupData->sGroupName);
1150 		sSourceGroup += GLOS_DELIM;
1151 		sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);
1152 
1153 		pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
1154 		String sTitle(GetEntryText(pEntry));
1155 		String sShortName(*(String*)pEntry->GetUserData());
1156 
1157 		GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
1158 		String sDestName = pDestData->sGroupName;
1159 		sDestName += GLOS_DELIM;
1160 		sDestName += String::CreateFromInt32(pDestData->nPathIdx);
1161 
1162 		bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup,  sShortName,
1163 						sDestName, sTitle, sal_False );
1164 		if(bRet)
1165 		{
1166 			SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
1167 			pChild->SetUserData(new String(sShortName));
1168 		}
1169 	}
1170 	return sal_False; //sonst wird der Eintrag automatisch vorgenommen
1171 }
1172 
1173 
1174 /*-----------------10.06.97 15.18-------------------
1175 
1176 --------------------------------------------------*/
1177 String SwGlossaryDlg::GetCurrGrpName() const
1178 {
1179 	SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
1180 	String sRet;
1181 	if(pEntry)
1182 	{
1183 		pEntry =
1184 			aCategoryBox.GetParent(pEntry) ? aCategoryBox.GetParent(pEntry) : pEntry;
1185 		GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
1186 		sRet = pGroupData->sGroupName;
1187 		sRet += GLOS_DELIM;
1188 		sRet += String::CreateFromInt32(pGroupData->nPathIdx);
1189 	}
1190 	return sRet;
1191 }
1192 
1193 /*-----------------11.06.97 08.17-------------------
1194 
1195 --------------------------------------------------*/
1196 IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
1197 {
1198 	SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1199 	if(pFact)
1200 	{
1201         AbstractSvxMultiPathDialog* pDlg = pFact->CreateSvxMultiPathDialog( pBtn );
1202         DBG_ASSERT(pDlg, "Dialogdiet fail!");
1203 		SvtPathOptions aPathOpt;
1204 		String sGlosPath( aPathOpt.GetAutoTextPath() );
1205 		pDlg->SetPath(sGlosPath);
1206 		if(RET_OK == pDlg->Execute())
1207 		{
1208 			String sTmp(pDlg->GetPath());
1209 			if(sTmp != sGlosPath)
1210 			{
1211 				aPathOpt.SetAutoTextPath( sTmp );
1212 				::GetGlossaries()->UpdateGlosPath( sal_True );
1213 				Init();
1214 			}
1215 		}
1216 		delete pDlg;
1217 	}
1218 	return 0;
1219 }
1220 /* -----------------28.07.99 13:48-------------------
1221 
1222  --------------------------------------------------*/
1223 IMPL_LINK( SwGlossaryDlg, ShowPreviewHdl, CheckBox *, pBox )
1224 {
1225 	sal_Bool bCreated = sal_False;
1226 	if(pBox->IsChecked())
1227 	{
1228 		//create example
1229 		if(!pExampleFrame)
1230 		{
1231 			Link aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
1232 			pExampleFrame = new SwOneExampleFrame( aExampleWIN,
1233 							EX_SHOW_ONLINE_LAYOUT, &aLink );
1234 			bCreated = sal_True;
1235 		}
1236 	}
1237 
1238     sal_Bool bShow = pBox->IsChecked() && !bCreated;
1239     aExampleWIN.Show( bShow );
1240     aExampleDummyWIN.Show(!bShow);
1241 	if( ::GetCurrGlosGroup() )
1242 		ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit.GetText());
1243 
1244 	return 0;
1245 };
1246 /* -----------------18.11.99 17:09-------------------
1247 
1248  --------------------------------------------------*/
1249 IMPL_LINK( SwGlossaryDlg, PreviewLoadedHdl,  void *, EMPTYARG )
1250 {
1251     sal_Bool bShow = aShowExampleCB.IsChecked();
1252     aExampleWIN.Show( bShow );
1253     aExampleDummyWIN.Show(!bShow);
1254     ResumeShowAutoText();
1255 	return 0;
1256 }
1257 
1258 /* -----------------28.07.99 16:28-------------------
1259 
1260  --------------------------------------------------*/
1261 void SwGlossaryDlg::ShowAutoText(const String& rGroup, const String& rShortName)
1262 {
1263 	if(aExampleWIN.IsVisible())
1264 	{
1265 		SetResumeData(rGroup, rShortName);
1266 		//try to make an Undo()
1267 		pExampleFrame->ClearDocument( sal_True );
1268 	}
1269 }
1270 /* -----------------------------21.12.00 11:33--------------------------------
1271 
1272  ---------------------------------------------------------------------------*/
1273 void	SwGlossaryDlg::ResumeShowAutoText()
1274 {
1275 	String sGroup, sShortName;
1276 	if(GetResumeData(sGroup, sShortName) && aExampleWIN.IsVisible())
1277 	{
1278 		if(!_xAutoText.is())
1279 		{
1280 			uno::Reference< lang::XMultiServiceFactory >
1281 									xMgr = getProcessServiceFactory();
1282 			//now the AutoText ListBoxes have to be filled
1283 
1284             uno::Reference< uno::XInterface >  xAText = xMgr->createInstance( C2U("com.sun.star.text.AutoTextContainer") );
1285 			_xAutoText = uno::Reference< container::XNameAccess >(xAText, uno::UNO_QUERY);
1286 		}
1287 
1288 		uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor();
1289 		if(xCrsr.is())
1290 		{
1291 			if(sShortName.Len())
1292 			{
1293 				uno::Any aGroup = _xAutoText->getByName(sGroup);
1294                 uno::Reference< XAutoTextGroup >  xGroup;
1295 				OUString uShortName(sShortName);
1296                 if((aGroup >>= xGroup) && xGroup->hasByName(uShortName))
1297 				{
1298 					uno::Any aEntry(xGroup->getByName(uShortName));
1299                     uno::Reference< XAutoTextEntry >  xEntry;
1300                     aEntry >>= xEntry;
1301 					uno::Reference< XTextRange >  xRange(xCrsr, uno::UNO_QUERY);
1302 					xEntry->applyTo(xRange);
1303 				}
1304 			}
1305 		}
1306 	}
1307 	ResetResumeData();
1308 }
1309 
1310 
1311