summaryrefslogtreecommitdiff
path: root/sw/source/ui/misc/glossary.cxx
blob: 990406d4a80db6ac4c7264d250e71067ce8d6f2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif

#define _SVSTDARR_STRINGSDTOR
#define _SVSTDARR_STRINGS
#include <hintids.hxx>

#include <vcl/menu.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/help.hxx>
#include <svl/svstdarr.hxx>
#include <svl/stritem.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/lingucfg.hxx>
#include <sfx2/request.hxx>
#include <sfx2/fcontnr.hxx>

#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
#include <editeng/acorrcfg.hxx>
#include <sfx2/viewfrm.hxx>
#include <unocrsr.hxx>
#include <unotools.hxx>
#include <comphelper/processfactory.hxx>
#include <ucbhelper/content.hxx>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <svl/urihelper.hxx>
#include <unotools/charclass.hxx>
#include <swwait.hxx>
#include <swtypes.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <basesh.hxx>
#include <glossary.hxx>
#include <gloshdl.hxx>
#include <glosbib.hxx>
#include <initui.hxx>					// fuer ::GetGlossaries()
#include <glosdoc.hxx>
#include <macassgn.hxx>
#include <swevent.hxx>
#include <docsh.hxx>
#include <shellio.hxx>

#include <cmdid.h>
#include <helpid.h>
#include <swerror.h>
#include <globals.hrc>
#include <misc.hrc>
#include <glossary.hrc>
#include <swmodule.hxx>
#include <sfx2/filedlghelper.hxx>

#define LONG_LENGTH 60
#define SHORT_LENGTH 30


using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::comphelper;
using namespace ::ucbhelper;
using ::rtl::OUString;
using namespace ::sfx2;

String lcl_GetValidShortCut( const String& rName )
{
    const sal_uInt16 nSz = rName.Len();

    if ( 0 == nSz )
        return rName;

    sal_uInt16 nStart = 1;
    while( rName.GetChar( nStart-1 ) == ' ' && nStart < nSz )
        nStart++;

    String aBuf( rName.GetChar( nStart-1 ));

    for( ; nStart < nSz; ++nStart )
    {
        if( rName.GetChar( nStart-1 ) == ' ' && rName.GetChar( nStart ) != ' ')
            aBuf += rName.GetChar( nStart );
    }
    return aBuf;
}

struct GroupUserData
{
    String 		sGroupName;
    sal_uInt16 	nPathIdx;
    BOOL 		bReadonly;

    GroupUserData()
        : nPathIdx(0),
          bReadonly(FALSE)	{}
};

/*------------------------------------------------------------------------
 Beschreibung:	Dialog fuer neuen Bausteinnamen
------------------------------------------------------------------------*/
class SwNewGlosNameDlg : public ModalDialog
{
    FixedText		aNNFT;
    Edit			aNewName;
    FixedText		aNSFT;
    NoSpaceEdit		aNewShort;
    OKButton		aOk;
    CancelButton	aCancel;
    FixedLine       aFL;
    FixedText		aONFT;
    Edit			aOldName;
    FixedText 		aOSFT;
    Edit			aOldShort;

protected:
    DECL_LINK( Modify, Edit * );
    DECL_LINK( Rename, Button * );

public:
    SwNewGlosNameDlg( Window* pParent,
                      const String& rOldName,
                      const String& rOldShort );

    String GetNewName()  const { return aNewName.GetText(); }
    String GetNewShort() const { return aNewShort.GetText(); }
};

SwNewGlosNameDlg::SwNewGlosNameDlg(Window* pParent,
                            const String& rOldName,
                            const String& rOldShort ) :
    ModalDialog( pParent, SW_RES( DLG_RENAME_GLOS ) ),
    aNNFT   (this, SW_RES( FT_NN    )),
    aNewName(this, SW_RES( ED_NN    )),
    aNSFT   (this, SW_RES( FT_NS    )),
    aNewShort(this,SW_RES( ED_NS    )),
    aOk		(this, SW_RES( BT_OKNEW)),
    aCancel	(this, SW_RES( BT_CANCEL)),
    aFL    (this, SW_RES( FL_NN    )),
    aONFT	(this, SW_RES( FT_ON	)),
    aOldName(this, SW_RES( ED_ON    )),
    aOSFT	(this, SW_RES( FT_OS	)),
    aOldShort(this,SW_RES( ED_OS    ))
{
    FreeResource();
    aOldName.SetText( rOldName );
    aOldShort.SetText( rOldShort );
    aNewShort.SetMaxTextLen(SHORT_LENGTH);
    aNewName.SetMaxTextLen(LONG_LENGTH);
    aNewName.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
    aNewShort.SetModifyHdl(LINK(this, SwNewGlosNameDlg, Modify ));
    aOk.SetClickHdl(LINK(this, SwNewGlosNameDlg, Rename ));
    aNewName.GrabFocus();
}

/*------------------------------------------------------------------------
 Beschreibung:	aktuell eingestellte Gruppe erfragen / setzen
------------------------------------------------------------------------*/
String SwGlossaryDlg::GetCurrGroup()
{
    if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() )
        return *(::GetCurrGlosGroup());
    return SwGlossaries::GetDefName();
}

void SwGlossaryDlg::SetActGroup(const String &rGrp)
{
    if( !::GetCurrGlosGroup() )
        ::SetCurrGlosGroup( new String );
    *(::GetCurrGlosGroup()) = rGrp;
}

SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
                            SwGlossaryHdl * pGlosHdl, SwWrtShell *pWrtShell) :

    SvxStandardDialog(&pViewFrame->GetWindow(), SW_RES(DLG_GLOSSARY)),

    aInsertTipCB  (this, SW_RES(CB_INSERT_TIP)),
    aNameLbl	  (this, SW_RES(FT_NAME)),
    aNameED       (this, SW_RES(ED_NAME)),
    aShortNameLbl (this, SW_RES(FT_SHORTNAME)),
    aShortNameEdit(this, SW_RES(ED_SHORTNAME)),
    aCategoryBox  (this, SW_RES(LB_BIB)),
    aRelativeFL   (this, SW_RES(FL_RELATIVE)),
    aFileRelCB    (this, SW_RES(CB_FILE_REL)),
    aNetRelCB     (this, SW_RES(CB_NET_REL)),
    aExampleWIN   (this, SW_RES(WIN_EXAMPLE )),
    aExampleDummyWIN(this, SW_RES(WIN_EXAMPLE_DUMMY )),
    aShowExampleCB(this, SW_RES(CB_SHOW_EXAMPLE )),
    aInsertBtn    (this, SW_RES(PB_INSERT)),
    aCloseBtn     (this, SW_RES(PB_CLOSE)),
    aHelpBtn      (this, SW_RES(PB_HELP)),
    aEditBtn      (this, SW_RES(PB_EDIT)),
    aBibBtn		  (this, SW_RES(PB_BIB)),
    aPathBtn	  (this, SW_RES(PB_PATH)),

    sReadonlyPath (SW_RES(ST_READONLY_PATH)),
    pExampleFrame(0),

    pMenu         (new PopupMenu(SW_RES(MNU_EDIT))),
    pGlossaryHdl  (pGlosHdl),

    bResume(sal_False),

    bSelection( pWrtShell->IsSelection() ),
    bReadOnly( sal_False ),
    bIsOld( sal_False ),
    bIsDocReadOnly(sal_False),

    pSh           (pWrtShell)
{
    SvtLinguConfig aLocalLinguConfig;

    // Static-Pointer initialisieren
    if( !::GetCurrGlosGroup() )
        ::SetCurrGlosGroup(new String);//(SwGlossaries::GetDefName());

    pMenu->SetActivateHdl(LINK(this,SwGlossaryDlg,EnableHdl));
    pMenu->SetSelectHdl(LINK(this,SwGlossaryDlg,MenuHdl));
    aEditBtn.SetPopupMenu(pMenu);
    aEditBtn.SetSelectHdl(LINK(this,SwGlossaryDlg,EditHdl));
    aPathBtn.SetClickHdl(LINK(this, SwGlossaryDlg, PathHdl));

    aNameED.SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));
    aShortNameEdit.SetModifyHdl(LINK(this,SwGlossaryDlg,NameModify));

    aCategoryBox.SetDoubleClickHdl(LINK(this,SwGlossaryDlg, NameDoubleClick));
    aCategoryBox.SetSelectHdl(LINK(this,SwGlossaryDlg,GrpSelect));
    aBibBtn.SetClickHdl(LINK(this,SwGlossaryDlg,BibHdl));
    aShowExampleCB.SetClickHdl(LINK(this, SwGlossaryDlg, ShowPreviewHdl));

    aShortNameEdit.SetMaxTextLen(SHORT_LENGTH);
    aNameED.SetMaxTextLen(LONG_LENGTH);
    FreeResource();

    const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();

    aShowExampleCB.Check( pCfg->IsAutoTextPreview());
    ShowPreviewHdl(&aShowExampleCB);

    bIsDocReadOnly = pSh->GetView().GetDocShell()->IsReadOnly() ||
                      pSh->HasReadonlySel();
    if( bIsDocReadOnly )
        aInsertBtn.Enable(sal_False);
    aNameED.GrabFocus();
    aCategoryBox.SetHelpId(HID_MD_GLOS_CATEGORY);
    aCategoryBox.SetWindowBits(WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL|WB_VSCROLL|WB_CLIPCHILDREN|WB_SORT);
    aCategoryBox.GetModel()->SetSortMode(SortAscending);
    aCategoryBox.SetHighlightRange();	// ueber volle Breite selektieren
    aCategoryBox.SetNodeDefaultImages( );

    Init();
}

SwGlossaryDlg::~SwGlossaryDlg()
{
    SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
    pCfg->SetAutoTextPreview(aShowExampleCB.IsChecked()) ;

    aCategoryBox.Clear();
    aEditBtn.SetPopupMenu(0);
    delete pMenu;
    delete pExampleFrame;
}

/*------------------------------------------------------------------------
 Beschreibung:	Auswahl neue Gruppe
------------------------------------------------------------------------*/
IMPL_LINK( SwGlossaryDlg, GrpSelect, SvTreeListBox *, pBox )
{
    SvLBoxEntry* pEntry = pBox->FirstSelected();
    if(!pEntry)
        return 0;
    SvLBoxEntry* pParent = pBox->GetParent(pEntry) ? pBox->GetParent(pEntry) : pEntry;
    GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
    String *pGlosGroup = ::GetCurrGlosGroup();
    (*pGlosGroup) = pGroupData->sGroupName;
    (*pGlosGroup) += GLOS_DELIM;
    (*pGlosGroup) += String::CreateFromInt32(pGroupData->nPathIdx);
    pGlossaryHdl->SetCurGroup(*pGlosGroup);
    // Aktuellen Textbaustein setzen
    bReadOnly = pGlossaryHdl->IsReadOnly();
    EnableShortName( !bReadOnly );
    aEditBtn.Enable(!bReadOnly);
    bIsOld = pGlossaryHdl->IsOld();
    if( pParent != pEntry)
    {
        String aName(pBox->GetEntryText(pEntry));
        aNameED.SetText(aName);
        aShortNameEdit.SetText(*(String*)pEntry->GetUserData());
        pEntry = pBox->GetParent(pEntry);
        aInsertBtn.Enable( !bIsDocReadOnly);
        ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit.GetText());
    }
    else
        ShowAutoText(aEmptyStr, aEmptyStr);
    //Controls aktualisieren
    NameModify(&aShortNameEdit);
    if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
    {
        SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
        String sTemp(*::GetCurrGlosGroup());
        // der nullte Pfad wird nicht aufgezeichnet!
        if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
            sTemp = sTemp.GetToken(0, GLOS_DELIM);
        aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
        aReq.Done();
    }
    return 0;
}

void SwGlossaryDlg::Apply()
{
    const String aGlosName(aShortNameEdit.GetText());
    if(aGlosName.Len())	pGlossaryHdl->InsertGlossary(aGlosName);
    if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
    {
        SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY );
        String sTemp(*::GetCurrGlosGroup());
        // der nullte Pfad wird nicht aufgezeichnet!
        if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
            sTemp = sTemp.GetToken(0, GLOS_DELIM);
        aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp));
        aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
        aReq.Done();
    }
}

/* inline */ void SwGlossaryDlg::EnableShortName(sal_Bool bOn)
{
    aShortNameLbl.Enable(bOn);
    aShortNameEdit.Enable(bOn);
}

/* --------------------------------------------------
 * existiert der Titel in der ausgewaehlten Gruppe?
 * --------------------------------------------------*/
SvLBoxEntry* SwGlossaryDlg::DoesBlockExist(const String& rBlock,
                const String& rShort)
{
    //evtl. vorhandenen Eintrag in der TreeListBox suchen
    SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
    if(pEntry)
    {
        if(aCategoryBox.GetParent(pEntry))
            pEntry = aCategoryBox.GetParent(pEntry);
        sal_uInt32 nChildCount = aCategoryBox.GetChildCount( pEntry );
        for(sal_uInt32 i = 0; i < nChildCount; i++)
        {
            SvLBoxEntry* pChild = aCategoryBox.GetEntry( pEntry, i );
            if(rBlock == aCategoryBox.GetEntryText(pChild) &&
                (!rShort.Len() || rShort == *(String*)pChild->GetUserData()))
            {
                return pChild;
            }
        }
    }
    return 0;
}

IMPL_LINK( SwGlossaryDlg, NameModify, Edit *, pEdit )
{
    String aName(aNameED.GetText());
    sal_Bool bNameED = pEdit == &aNameED;
    if( !aName.Len() )
    {
        if(bNameED)
            aShortNameEdit.SetText(aName);
        aInsertBtn.Enable(sal_False);
        return 0;
    }
    String sShortSearch;
    if(!bNameED)
        sShortSearch = pEdit->GetText();
    sal_Bool bNotFound = !DoesBlockExist(aName, sShortSearch);
    if(bNameED)
    {
            // ist der Text durch einen Klick in die Listbox in das
            // Edit gekommem?
        if(bNotFound)
        {
            aShortNameEdit.SetText( lcl_GetValidShortCut( aName ) );
            EnableShortName();
        }
        else
        {
            aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aName));
            EnableShortName(!bReadOnly);
        }
        aInsertBtn.Enable(!bNotFound && !bIsDocReadOnly);
    }
    else
    {
        //ShortNameEdit
        if(!bNotFound)
        {
            sal_Bool bEnable = !bNotFound;
            bEnable &= !bIsDocReadOnly;
            aInsertBtn.Enable(bEnable);
        }
    }
    return 0;
}

IMPL_LINK_INLINE_START( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox )
{
    SvLBoxEntry* pEntry = pBox->FirstSelected();
    if(pBox->GetParent(pEntry) && !bIsDocReadOnly)
        EndDialog( RET_OK );
    return 0;
}
IMPL_LINK_INLINE_END( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, EMPTYARG )

IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn )
{
    const String aEditText(aNameED.GetText());
    const sal_Bool bHasEntry = aEditText.Len() && aShortNameEdit.GetText().Len();
    const sal_Bool bExists = 0 != DoesBlockExist(aEditText, aShortNameEdit.GetText());
    pMn->EnableItem(FN_GL_DEFINE, bSelection && bHasEntry && !bExists);
    pMn->EnableItem(FN_GL_DEFINE_TEXT, bSelection && bHasEntry && !bExists);
    pMn->EnableItem(FN_GL_COPY_TO_CLIPBOARD, bExists);
    pMn->EnableItem(FN_GL_REPLACE, bSelection && bExists && !bIsOld );
    pMn->EnableItem(FN_GL_REPLACE_TEXT, bSelection && bExists && !bIsOld );
    pMn->EnableItem(FN_GL_EDIT, bExists );
    pMn->EnableItem(FN_GL_RENAME, bExists  );
    pMn->EnableItem(FN_GL_DELETE, bExists  );
    pMn->EnableItem(FN_GL_MACRO, bExists && !bIsOld  &&
                                    !pGlossaryHdl->IsReadOnly() );

    SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
    sal_Bool bEnable = sal_False;
    if ( pEntry )
        bEnable = !aCategoryBox.GetParent( pEntry ) && !bIsOld && !pGlossaryHdl->IsReadOnly();
    pMn->EnableItem( FN_GL_IMPORT, bEnable );
    return 1;
}

IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
{
    sal_Bool bNoAttr = sal_False;

    switch(pMn->GetCurItemId())
    {
        case FN_GL_REPLACE:
        case FN_GL_REPLACE_TEXT:
            pGlossaryHdl->NewGlossary(	aNameED.GetText(),
                                        aShortNameEdit.GetText(),
                                        sal_False,
                                        pMn->GetCurItemId() == FN_GL_REPLACE_TEXT);
        break;
        case FN_GL_DEFINE_TEXT:
            bNoAttr = sal_True;
            // Kein break!!!
        case FN_GL_DEFINE:
        {
            const String aStr(aNameED.GetText());
            const String aShortName(aShortNameEdit.GetText());
            if(pGlossaryHdl->HasShortName(aShortName))
            {
                InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
                aShortNameEdit.SetSelection(Selection(0, SELECTION_MAX));
                aShortNameEdit.GrabFocus();
                break;
            }
            if(pGlossaryHdl->NewGlossary(aStr, aShortName, sal_False, bNoAttr ))
            {
                SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
                if(aCategoryBox.GetParent(pEntry))
                    pEntry = aCategoryBox.GetParent(pEntry);

                SvLBoxEntry* pChild = aCategoryBox.InsertEntry(aStr, pEntry);
                pChild->SetUserData(new String(aShortName));
                aNameED.SetText(aStr);
                aShortNameEdit.SetText(aShortName);
                NameModify(&aNameED);		// fuer Schalten der Buttons

                if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
                {
                    SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
                    String sTemp(*::GetCurrGlosGroup());
                    // der nullte Pfad wird nicht aufgezeichnet!
                    if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
                        sTemp = sTemp.GetToken(0, GLOS_DELIM);
                    aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp));
                    aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
                    aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
                    aReq.Done();
                }
            }
        }
        break;
        case FN_GL_COPY_TO_CLIPBOARD :
        {
            pGlossaryHdl->CopyToClipboard(*pSh, aShortNameEdit.GetText());
        }
        break;
        case FN_GL_EDIT:
        break;
        case FN_GL_RENAME:
        {
            aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aNameED.GetText()));
            SwNewGlosNameDlg* pNewNameDlg = new SwNewGlosNameDlg(this, aNameED.GetText(),
                                            aShortNameEdit.GetText() );
            if( RET_OK == pNewNameDlg->Execute() &&
                pGlossaryHdl->Rename( aShortNameEdit.GetText(),
                                        pNewNameDlg->GetNewShort(),
                                        pNewNameDlg->GetNewName()))
            {
                SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
                SvLBoxEntry* pNewEntry = aCategoryBox.InsertEntry(
                        pNewNameDlg->GetNewName(), aCategoryBox.GetParent(pEntry));
                pNewEntry->SetUserData(new String(pNewNameDlg->GetNewShort()));
                delete (String*)pEntry->GetUserData();
                aCategoryBox.GetModel()->Remove(pEntry);
                aCategoryBox.Select(pNewEntry);
                aCategoryBox.MakeVisible(pNewEntry);
            }
            GrpSelect( &aCategoryBox );
            delete pNewNameDlg;
        }
        break;
        case FN_GL_DELETE:
        {
            QueryBox aQuery(this, SW_RES(MSG_QUERY_DELETE));
            if(RET_YES == aQuery.Execute())
            {
                const String aShortName(aShortNameEdit.GetText());
                const String aTitle(aNameED.GetText());
                if(aTitle.Len() && pGlossaryHdl->DelGlossary(aShortName))
                {
                    SvLBoxEntry* pChild = DoesBlockExist(aTitle, aShortName);
                    OSL_ENSURE(pChild, "entry not found!");
                    SvLBoxEntry* pParent = aCategoryBox.GetParent(pChild);
                    aCategoryBox.Select(pParent);

                    aCategoryBox.GetModel()->Remove(pChild);
                    aNameED.SetText( aEmptyStr );
                    NameModify(&aNameED);
                }
            }
        }
        break;
        case FN_GL_MACRO:
        {
            SfxItemSet aSet( pSh->GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );

            SvxMacro aStart(aEmptyStr, aEmptyStr, STARBASIC);
            SvxMacro aEnd(aEmptyStr, aEmptyStr, STARBASIC);
            pGlossaryHdl->GetMacros(aShortNameEdit.GetText(), aStart, aEnd );

            SvxMacroItem aItem(RES_FRMMACRO);
            if( aStart.GetMacName().Len() )
                aItem.SetMacro( SW_EVENT_START_INS_GLOSSARY, aStart );
            if( aEnd.GetMacName().Len() )
                aItem.SetMacro( SW_EVENT_END_INS_GLOSSARY, aEnd );

            aSet.Put( aItem );
            aSet.Put( SwMacroAssignDlg::AddEvents( MACASSGN_TEXTBAUST ) );

            const SfxPoolItem* pItem;
            SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
            SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet,
                pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG );
            if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
                SFX_ITEM_SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, sal_False, &pItem ) )
            {
                const SvxMacroTableDtor& rTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
                pGlossaryHdl->SetMacros( aShortNameEdit.GetText(),
                                            rTbl.Get( SW_EVENT_START_INS_GLOSSARY ),
                                            rTbl.Get( SW_EVENT_END_INS_GLOSSARY ) );
            }

            delete pMacroDlg;
        }
        break;

        case FN_GL_IMPORT:
        {
            // call the FileOpenDialog do find WinWord - Files with templates
            FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
            uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();

            SvtPathOptions aPathOpt;
            xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
            String sWW8( C2S( FILTER_WW8 ) );

            uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
            SfxFilterMatcher aMatcher( String::CreateFromAscii(SwDocShell::Factory().GetShortName()) );
            SfxFilterMatcherIter aIter( &aMatcher );
            const SfxFilter* pFilter = aIter.First();
            while ( pFilter )
            {
                if( pFilter->GetUserData() == sWW8 )
                {
                    xFltMgr->appendFilter( pFilter->GetUIName(),
                                ((WildCard&)pFilter->GetWildcard()).GetWildCard() );
                    xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
                }

                pFilter = aIter.Next();
            }

            if( aDlgHelper.Execute() == ERRCODE_NONE )
            {
                if( pGlossaryHdl->ImportGlossaries( xFP->getFiles().getConstArray()[0] ))
                    Init();
                else
                {
                    InfoBox(this, SW_RES( MSG_NO_GLOSSARIES )).Execute();
                }
            }
        }
           break;

        default:
            return 0;
    }
    return 1;
}

/*--------------------------------------------------------------------
     Beschreibung:	Dialog Verwaltung Bereiche
 --------------------------------------------------------------------*/
IMPL_LINK( SwGlossaryDlg, BibHdl, Button *, EMPTYARG )
{
    SwGlossaries* pGloss = ::GetGlossaries();
    if( pGloss->IsGlosPathErr() )
        pGloss->ShowError();
    else
    {
        //check if at least one glossary path is write enabled
        SvtPathOptions aPathOpt;
        String sGlosPath( aPathOpt.GetAutoTextPath() );
        USHORT nPaths = sGlosPath.GetTokenCount(';');
        BOOL bIsWritable = FALSE;
        for(USHORT nPath = 0; nPath < nPaths; nPath++)
        {
            String sPath = URIHelper::SmartRel2Abs(
                INetURLObject(), sGlosPath.GetToken(nPath, ';'),
                URIHelper::GetMaybeFileHdl());
            try
            {
                Content aTestContent( sPath,
                            uno::Reference< XCommandEnvironment >());
                Any aAny = aTestContent.getPropertyValue( C2U("IsReadOnly") );
                if(aAny.hasValue())
                {
                    bIsWritable = !*(sal_Bool*)aAny.getValue();
                }
            }
            catch(Exception&)
            {}
            if(bIsWritable)
                break;
        }
        if(bIsWritable)
        {

            SwGlossaryGroupDlg *pDlg = new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
            if ( RET_OK == pDlg->Execute() )
            {
                Init();
                //if new groups were created - select one of them
                String sNewGroup = pDlg->GetCreatedGroupName();
                SvLBoxEntry* pEntry = aCategoryBox.First();
                while(sNewGroup.Len() && pEntry)
                {
                    if(!aCategoryBox.GetParent(pEntry))
                    {
                        GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
                        String sGroup = pGroupData->sGroupName;
                        sGroup += GLOS_DELIM;
                        sGroup += String::CreateFromInt32(pGroupData->nPathIdx);
                        if(sGroup == sNewGroup)
                        {
                            aCategoryBox.Select(pEntry);
                            aCategoryBox.MakeVisible(pEntry);
                            GrpSelect(&aCategoryBox);
                            break;
                        }
                    }
                    pEntry = aCategoryBox.Next(pEntry);
                }

            }
            delete pDlg;
        }
        else
        {
            QueryBox aBox(this, WB_YES_NO, sReadonlyPath);
            if(RET_YES == aBox.Execute())
                PathHdl(&aPathBtn);
        }
    }
    return 0;
}

/*------------------------------------------------------------------------
 Beschreibung:	Initialisierung; aus Ctor und nach Bearbeiten Bereiche
------------------------------------------------------------------------*/
void SwGlossaryDlg::Init()
{
    aCategoryBox.SetUpdateMode( sal_False );
    aCategoryBox.Clear();
    // Textbausteinbereiche anzeigen
    const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt();
    SvLBoxEntry* pSelEntry = 0;
    const String sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM));
    const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM).ToInt32());
    // #i66304# - "My AutoText" comes from mytexts.bau, but should be translated
    const String sMyAutoTextEnglish(RTL_CONSTASCII_USTRINGPARAM("My AutoText"));
    const String sMyAutoTextTranslated(SW_RESSTR(STR_MY_AUTOTEXT));
    for(sal_uInt16 nId = 0; nId < nCnt; ++nId )
    {
        String sTitle;
        String sGroupName(pGlossaryHdl->GetGroupName(nId, &sTitle));
        if(!sGroupName.Len())
            continue;
        if(!sTitle.Len())
            sTitle = sGroupName.GetToken( 0, GLOS_DELIM );
        if(sTitle == sMyAutoTextEnglish)
            sTitle = sMyAutoTextTranslated;
        SvLBoxEntry* pEntry = aCategoryBox.InsertEntry( sTitle );
        sal_uInt16 nPath = static_cast< sal_uInt16 >(sGroupName.GetToken( 1, GLOS_DELIM ).ToInt32());

        GroupUserData* pData = new GroupUserData;
        pData->sGroupName = sGroupName.GetToken(0, GLOS_DELIM);
        pData->nPathIdx = nPath;
        pData->bReadonly = pGlossaryHdl->IsReadOnly(&sGroupName);

        pEntry->SetUserData(pData);
        if(sSelStr == pData->sGroupName && nSelPath == nPath)
            pSelEntry = pEntry;

        //Eintraege fuer die Gruppen auffuellen
        {
            pGlossaryHdl->SetCurGroup(sGroupName, sal_False, sal_True);
            const sal_uInt16 nCount = pGlossaryHdl->GetGlossaryCnt();
            for(sal_uInt16 i = 0; i < nCount; ++i)
            {
                String sGroupTitle(pGlossaryHdl->GetGlossaryName(i));
                SvLBoxEntry* pChild = aCategoryBox.InsertEntry(
                                    sGroupTitle, pEntry);
                pChild->SetUserData(new String(pGlossaryHdl->GetGlossaryShortName(i)));
            }
        }
    }
        // Aktuelle Gruppe setzen und Textbausteine anzeigen
    if(!pSelEntry)
    {
        //find a non-readonly group
        SvLBoxEntry* pSearch = aCategoryBox.First();
        while(pSearch)
        {
            if(!aCategoryBox.GetParent(pSearch))
            {
                GroupUserData* pData = (GroupUserData*)pSearch->GetUserData();
                if(!pData->bReadonly)
                {
                    pSelEntry = pSearch;
                    break;
                }
            }
            pSearch = aCategoryBox.Next(pSearch);
        }
        if(!pSelEntry)
            pSelEntry = aCategoryBox.GetEntry(0);
    }
    if(pSelEntry)
    {
        aCategoryBox.Expand(pSelEntry);
        aCategoryBox.Select(pSelEntry);
        aCategoryBox.MakeVisible(pSelEntry);
        GrpSelect(&aCategoryBox);
    }
    //JP 16.11.99: the SvxTreeListBox has a Bug. The Box dont recalc the
    //		outputsize, when all entries are insertet. The result is, that
    //		the Focus/Highlight rectangle is to large and paintet over the
    //		HScrollbar. -> Fix: call the resize
    aCategoryBox.Resize();

    aCategoryBox.GetModel()->Resort();
    aCategoryBox.SetUpdateMode( sal_True );
    aCategoryBox.Update();

    const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
    aFileRelCB.Check( pCfg->IsSaveRelFile() );
    aFileRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
    aNetRelCB.Check( pCfg->IsSaveRelNet() );
    aNetRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
    aInsertTipCB.Check( pCfg->IsAutoTextTip() );
    aInsertTipCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
}

IMPL_LINK_INLINE_START( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )
{
//EndDialog darf nicht im MenuHdl aufgerufen werden
    if(aEditBtn.GetCurItemId() == FN_GL_EDIT )
    {
        SwTextBlocks *pGroup = ::GetGlossaries()->GetGroupDoc (  GetCurrGrpName () );
        BOOL bRet = pGlossaryHdl->ConvertToNew ( *pGroup );
        delete pGroup;
        if ( bRet )
            EndDialog(RET_EDIT);
    }
    return 0;
}
IMPL_LINK_INLINE_END( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )

/*------------------------------------------------------------------------
 Beschreibung:	KeyInput fuer ShortName - Edits ohne Spaces
------------------------------------------------------------------------*/
IMPL_LINK( SwNewGlosNameDlg, Modify, Edit *, pBox )
{
    String aName(aNewName.GetText());
    SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();

    if( pBox == &aNewName )
        aNewShort.SetText( lcl_GetValidShortCut( aName ) );

    sal_Bool bEnable = aName.Len() && aNewShort.GetText().Len() &&
        (!pDlg->DoesBlockExist(aName, aNewShort.GetText())
            || aName == aOldName.GetText());
    aOk.Enable(bEnable);
    return 0;
}

IMPL_LINK( SwNewGlosNameDlg, Rename, Button *, EMPTYARG )
{
    SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
    String sNew = aNewShort.GetText();
    GetAppCharClass().toUpper(sNew);
    if( pDlg->pGlossaryHdl->HasShortName(aNewShort.GetText())
        && sNew != aOldShort.GetText() )
    {
        InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
        aNewShort.GrabFocus();
    }
    else
        EndDialog(sal_True);
    return 0;
}

IMPL_LINK( SwGlossaryDlg, CheckBoxHdl, CheckBox *, pBox )
{
    SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
    sal_Bool bCheck = pBox->IsChecked();
    if( pBox == &aInsertTipCB )
        pCfg->SetAutoTextTip(bCheck);
    else if(pBox == &aFileRelCB)
        pCfg->SetSaveRelFile(bCheck);
    else
        pCfg->SetSaveRelNet(bCheck);
    return 0;
}

/* --------------------------------------------------
 * TreeListBox fuer Gruppen und Bausteine
 * --------------------------------------------------*/
SwGlTreeListBox::SwGlTreeListBox(Window* pParent, const ResId& rResId) :
    SvTreeListBox(pParent, rResId),
    sReadonly	  (SW_RES(ST_READONLY)),
    pDragEntry(0)
{
    FreeResource();
    SetDragDropMode( SV_DRAGDROP_CTRL_MOVE|SV_DRAGDROP_CTRL_COPY );
}

void SwGlTreeListBox::Clear()
{
    SvLBoxEntry* pEntry = First();
    while(pEntry)
    {
        if(GetParent(pEntry))
            delete (String*)pEntry->GetUserData();
        else
            delete (GroupUserData*)pEntry->GetUserData();
        pEntry = Next(pEntry);
    }
    SvTreeListBox::Clear();
}

void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
{
    Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
    SvLBoxEntry* pEntry = GetEntry( aPos );
    // Hilfe gibt es nur fuer die Gruppennamen
    if(pEntry)
    {
        SvLBoxTab* pTab;
        SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
        if(pItem)
        {
            aPos = GetEntryPosition( pEntry );
             Size aSize(pItem->GetSize( this, pEntry ));
            aPos.X() = GetTabPos( pEntry, pTab );

            if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
                aSize.Width() = GetSizePixel().Width() - aPos.X();
            aPos = OutputToScreenPixel(aPos);
             Rectangle aItemRect( aPos, aSize );
            String sMsg;
            if(!GetParent(pEntry))
            {
                GroupUserData* pData = (GroupUserData*)pEntry->GetUserData();
                const SvStrings* pPathArr = ::GetGlossaries()->GetPathArray();
                if(pPathArr->Count())
                {
                    sMsg = (*(*pPathArr)[pData->nPathIdx]);
                    sMsg += INET_PATH_TOKEN;
                    sMsg += pData->sGroupName;
                    sMsg += SwGlossaries::GetExtension();
                    INetURLObject aTmp(sMsg);
                    sMsg = aTmp.GetPath();

                    if(pData->bReadonly)
                    {
                        sMsg += ' ';
                        sMsg += '(';
                        sMsg += sReadonly;
                        sMsg += ')';
                    }


                }
            }
            else
                sMsg = *(String*)pEntry->GetUserData();
            Help::ShowQuickHelp( this, aItemRect, sMsg,
                        QUICKHELP_LEFT|QUICKHELP_VCENTER );
        }
    }
}

DragDropMode SwGlTreeListBox::NotifyStartDrag(
                    TransferDataContainer& /*rContainer*/,
                    SvLBoxEntry* pEntry )
{
    DragDropMode  eRet;
    pDragEntry = pEntry;
    if(!GetParent(pEntry))
        eRet = SV_DRAGDROP_NONE;
    else
    {
        SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
        SvLBoxEntry* pParent = GetParent(pEntry);

        GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
        String sEntry(pGroupData->sGroupName);
        sEntry += GLOS_DELIM;
        sEntry += String::CreateFromInt32(pGroupData->nPathIdx);
        sal_Int8 nDragOption = DND_ACTION_COPY;
        eRet = SV_DRAGDROP_CTRL_COPY;
        if(!pDlg->pGlossaryHdl->IsReadOnly(&sEntry))
        {
            eRet |= SV_DRAGDROP_CTRL_MOVE;
            nDragOption |= DND_ACTION_MOVE;
        }
        SetDragOptions( nDragOption );
    }
    return eRet;
}

sal_Bool    SwGlTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry)
{
    // TODO: Readonly - Ueberpruefung fehlt noch!
    SvLBoxEntry* pSrcParent = GetParent(pEntry) ? GetParent(pEntry) : pEntry;
    SvLBoxEntry* pDestParent =
        GetParent(pDragEntry ) ? GetParent(pDragEntry ) : pDragEntry ;
    return pDestParent != pSrcParent;

}

sal_Bool  SwGlTreeListBox::NotifyMoving(   SvLBoxEntry*  pTarget,
                                    SvLBoxEntry*  pEntry,
                                    SvLBoxEntry*& /*rpNewParent*/,
                                    ULONG&        /*rNewChildPos*/
                                )
{
    pDragEntry = 0;
    if(!pTarget) //An den Anfang verschieben
    {
        pTarget = GetEntry(0);
    }
    // 1. wird in verschiedene Gruppen verschoben?
    // 2. darf in beiden Gruppen geschrieben werden?
    SvLBoxEntry* pSrcParent = GetParent(pEntry);
    SvLBoxEntry* pDestParent =
        GetParent(pTarget) ? GetParent(pTarget) : pTarget;
    sal_Bool bRet = sal_False;
    if(pDestParent != pSrcParent)
    {
        SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
        SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );

        GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
        String sSourceGroup(pGroupData->sGroupName);
        sSourceGroup += GLOS_DELIM;
        sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);
        pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
        String sTitle(GetEntryText(pEntry));
        String sShortName(*(String*)pEntry->GetUserData());

        GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
        String sDestName = pDestData->sGroupName;
        sDestName += GLOS_DELIM;
        sDestName += String::CreateFromInt32(pDestData->nPathIdx);
        bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup,  sShortName,
                        sDestName, sTitle, sal_True );
        if(bRet)
        {
            SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
            pChild->SetUserData(new String(sShortName));
            GetModel()->Remove(pEntry);
        }
    }
    return sal_False; //sonst wird der Eintrag automatisch vorgenommen
}

sal_Bool  SwGlTreeListBox::NotifyCopying(   SvLBoxEntry*  pTarget,
                                    SvLBoxEntry*  pEntry,
                                    SvLBoxEntry*& /*rpNewParent*/,
                                    ULONG&        /*rNewChildPos*/
                                )
{
    pDragEntry = 0;
    // 1. wird in verschiedene Gruppen verschoben?
    // 2. darf in beiden Gruppen geschrieben werden?
    if(!pTarget) //An den Anfang verschieben
    {
        pTarget = GetEntry(0);
    }
    SvLBoxEntry* pSrcParent = GetParent(pEntry);
    SvLBoxEntry* pDestParent =
        GetParent(pTarget) ? GetParent(pTarget) : pTarget;
    sal_Bool bRet = sal_False;
    if(pDestParent != pSrcParent)
    {
        SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
        SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), sal_True );

        GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
        String sSourceGroup(pGroupData->sGroupName);
        sSourceGroup += GLOS_DELIM;
        sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);

        pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
        String sTitle(GetEntryText(pEntry));
        String sShortName(*(String*)pEntry->GetUserData());

        GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
        String sDestName = pDestData->sGroupName;
        sDestName += GLOS_DELIM;
        sDestName += String::CreateFromInt32(pDestData->nPathIdx);

        bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup,  sShortName,
                        sDestName, sTitle, sal_False );
        if(bRet)
        {
            SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
            pChild->SetUserData(new String(sShortName));
        }
    }
    return sal_False; //sonst wird der Eintrag automatisch vorgenommen
}

String SwGlossaryDlg::GetCurrGrpName() const
{
    SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
    String sRet;
    if(pEntry)
    {
        pEntry =
            aCategoryBox.GetParent(pEntry) ? aCategoryBox.GetParent(pEntry) : pEntry;
        GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
        sRet = pGroupData->sGroupName;
        sRet += GLOS_DELIM;
        sRet += String::CreateFromInt32(pGroupData->nPathIdx);
    }
    return sRet;
}

IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
{
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    if(pFact)
    {
        AbstractSvxMultiPathDialog* pDlg = pFact->CreateSvxMultiPathDialog( pBtn );
        OSL_ENSURE(pDlg, "Dialogdiet fail!");
        SvtPathOptions aPathOpt;
        String sGlosPath( aPathOpt.GetAutoTextPath() );
        pDlg->SetPath(sGlosPath);
        if(RET_OK == pDlg->Execute())
        {
            String sTmp(pDlg->GetPath());
            if(sTmp != sGlosPath)
            {
                aPathOpt.SetAutoTextPath( sTmp );
                ::GetGlossaries()->UpdateGlosPath( sal_True );
                Init();
            }
        }
        delete pDlg;
    }
    return 0;
}

IMPL_LINK( SwGlossaryDlg, ShowPreviewHdl, CheckBox *, pBox )
{
    sal_Bool bCreated = sal_False;
    if(pBox->IsChecked())
    {
        //create example
        if(!pExampleFrame)
        {
            Link aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
            pExampleFrame = new SwOneExampleFrame( aExampleWIN,
                            EX_SHOW_ONLINE_LAYOUT, &aLink );
            bCreated = sal_True;
        }
    }

    BOOL bShow = pBox->IsChecked() && !bCreated;
    aExampleWIN.Show( bShow );
    aExampleDummyWIN.Show(!bShow);
    if( ::GetCurrGlosGroup() )
        ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit.GetText());

    return 0;
};

IMPL_LINK( SwGlossaryDlg, PreviewLoadedHdl,  void *, EMPTYARG )
{
    BOOL bShow = aShowExampleCB.IsChecked();
    aExampleWIN.Show( bShow );
    aExampleDummyWIN.Show(!bShow);
    ResumeShowAutoText();
    return 0;
}

void SwGlossaryDlg::ShowAutoText(const String& rGroup, const String& rShortName)
{
    if(aExampleWIN.IsVisible())
    {
        SetResumeData(rGroup, rShortName);
        //try to make an Undo()
        pExampleFrame->ClearDocument( TRUE );
    }
}

void	SwGlossaryDlg::ResumeShowAutoText()
{
    String sGroup, sShortName;
    if(GetResumeData(sGroup, sShortName) && aExampleWIN.IsVisible())
    {
        if(!_xAutoText.is())
        {
            uno::Reference< lang::XMultiServiceFactory >
                                    xMgr = getProcessServiceFactory();
            //now the AutoText ListBoxes have to be filled

            uno::Reference< uno::XInterface >  xAText = xMgr->createInstance( C2U("com.sun.star.text.AutoTextContainer") );
            _xAutoText = uno::Reference< container::XNameAccess >(xAText, uno::UNO_QUERY);
        }

        uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor();
        if(xCrsr.is())
        {
            if(sShortName.Len())
            {
                uno::Any aGroup = _xAutoText->getByName(sGroup);
                uno::Reference< XAutoTextGroup >  xGroup;
                OUString uShortName(sShortName);
                if((aGroup >>= xGroup) && xGroup->hasByName(uShortName))
                {
                    uno::Any aEntry(xGroup->getByName(uShortName));
                    uno::Reference< XAutoTextEntry >  xEntry;
                    aEntry >>= xEntry;
                    uno::Reference< XTextRange >  xRange(xCrsr, uno::UNO_QUERY);
                    xEntry->applyTo(xRange);
                }
            }
        }
    }
    ResetResumeData();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */