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