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
lcl_GetValidShortCut(const String & rName)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
GroupUserDataGroupUserData137cdf0e10cSrcweir 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
GetNewName() const168cdf0e10cSrcweir String GetNewName() const { return aNewName.GetText(); }
GetNewShort() const169cdf0e10cSrcweir String GetNewShort() const { return aNewShort.GetText(); }
170cdf0e10cSrcweir };
171cdf0e10cSrcweir
SwNewGlosNameDlg(Window * pParent,const String & rOldName,const String & rOldShort)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
GetCurrGroup()204cdf0e10cSrcweir String SwGlossaryDlg::GetCurrGroup()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() )
207cdf0e10cSrcweir return *(::GetCurrGlosGroup());
208cdf0e10cSrcweir return SwGlossaries::GetDefName();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir
212cdf0e10cSrcweir
SetActGroup(const String & rGrp)213cdf0e10cSrcweir void SwGlossaryDlg::SetActGroup(const String &rGrp)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir if( !::GetCurrGlosGroup() )
216cdf0e10cSrcweir ::SetCurrGlosGroup( new String );
217cdf0e10cSrcweir *(::GetCurrGlosGroup()) = rGrp;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir
221cdf0e10cSrcweir
SwGlossaryDlg(SfxViewFrame * pViewFrame,SwGlossaryHdl * pGlosHdl,SwWrtShell * pWrtShell)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
~SwGlossaryDlg()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
IMPL_LINK(SwGlossaryDlg,GrpSelect,SvTreeListBox *,pBox)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
352*6f9cb704STsutomu Uchino {
353*6f9cb704STsutomu Uchino aNameED.SetText(aEmptyStr);
354*6f9cb704STsutomu Uchino aShortNameEdit.SetText(aEmptyStr);
355*6f9cb704STsutomu Uchino aInsertBtn.Enable(sal_False);
356cdf0e10cSrcweir ShowAutoText(aEmptyStr, aEmptyStr);
357*6f9cb704STsutomu Uchino }
358cdf0e10cSrcweir //Controls aktualisieren
359cdf0e10cSrcweir NameModify(&aShortNameEdit);
360cdf0e10cSrcweir if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY );
363cdf0e10cSrcweir String sTemp(*::GetCurrGlosGroup());
364cdf0e10cSrcweir // der nullte Pfad wird nicht aufgezeichnet!
365cdf0e10cSrcweir if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
366cdf0e10cSrcweir sTemp = sTemp.GetToken(0, GLOS_DELIM);
367cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY, sTemp));
368cdf0e10cSrcweir aReq.Done();
369cdf0e10cSrcweir }
370cdf0e10cSrcweir return 0;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir /*--------------------------------------------------------------------
373cdf0e10cSrcweir Beschreibung:
374cdf0e10cSrcweir --------------------------------------------------------------------*/
375cdf0e10cSrcweir
376cdf0e10cSrcweir
Apply()377cdf0e10cSrcweir void SwGlossaryDlg::Apply()
378cdf0e10cSrcweir {
379cdf0e10cSrcweir const String aGlosName(aShortNameEdit.GetText());
380cdf0e10cSrcweir if(aGlosName.Len()) pGlossaryHdl->InsertGlossary(aGlosName);
381cdf0e10cSrcweir if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir SfxRequest aReq( pSh->GetView().GetViewFrame(), FN_INSERT_GLOSSARY );
384cdf0e10cSrcweir String sTemp(*::GetCurrGlosGroup());
385cdf0e10cSrcweir // der nullte Pfad wird nicht aufgezeichnet!
386cdf0e10cSrcweir if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
387cdf0e10cSrcweir sTemp = sTemp.GetToken(0, GLOS_DELIM);
388cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY, sTemp));
389cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_PARAM_1, aGlosName));
390cdf0e10cSrcweir aReq.Done();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir }
393cdf0e10cSrcweir /*--------------------------------------------------------------------
394cdf0e10cSrcweir Beschreibung:
395cdf0e10cSrcweir --------------------------------------------------------------------*/
EnableShortName(sal_Bool bOn)396cdf0e10cSrcweir /* inline */ void SwGlossaryDlg::EnableShortName(sal_Bool bOn)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir aShortNameLbl.Enable(bOn);
399cdf0e10cSrcweir aShortNameEdit.Enable(bOn);
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir /* -----------------26.11.98 16:15-------------------
403cdf0e10cSrcweir * existiert der Titel in der ausgewaehlten Gruppe?
404cdf0e10cSrcweir * --------------------------------------------------*/
DoesBlockExist(const String & rBlock,const String & rShort)405cdf0e10cSrcweir SvLBoxEntry* SwGlossaryDlg::DoesBlockExist(const String& rBlock,
406cdf0e10cSrcweir const String& rShort)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir //evtl. vorhandenen Eintrag in der TreeListBox suchen
409cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
410cdf0e10cSrcweir if(pEntry)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir if(aCategoryBox.GetParent(pEntry))
413cdf0e10cSrcweir pEntry = aCategoryBox.GetParent(pEntry);
414cdf0e10cSrcweir sal_uInt32 nChildCount = aCategoryBox.GetChildCount( pEntry );
415cdf0e10cSrcweir for(sal_uInt32 i = 0; i < nChildCount; i++)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir SvLBoxEntry* pChild = aCategoryBox.GetEntry( pEntry, i );
418cdf0e10cSrcweir if(rBlock == aCategoryBox.GetEntryText(pChild) &&
419cdf0e10cSrcweir (!rShort.Len() || rShort == *(String*)pChild->GetUserData()))
420cdf0e10cSrcweir {
421cdf0e10cSrcweir return pChild;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir }
424cdf0e10cSrcweir }
425cdf0e10cSrcweir return 0;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
428cdf0e10cSrcweir /*--------------------------------------------------------------------
429cdf0e10cSrcweir Beschreibung:
430cdf0e10cSrcweir --------------------------------------------------------------------*/
431cdf0e10cSrcweir
432cdf0e10cSrcweir
IMPL_LINK(SwGlossaryDlg,NameModify,Edit *,pEdit)433cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, NameModify, Edit *, pEdit )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir String aName(aNameED.GetText());
436cdf0e10cSrcweir sal_Bool bNameED = pEdit == &aNameED;
437cdf0e10cSrcweir if( !aName.Len() )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir if(bNameED)
440cdf0e10cSrcweir aShortNameEdit.SetText(aName);
441cdf0e10cSrcweir aInsertBtn.Enable(sal_False);
442cdf0e10cSrcweir return 0;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir String sShortSearch;
445cdf0e10cSrcweir if(!bNameED)
446cdf0e10cSrcweir sShortSearch = pEdit->GetText();
447cdf0e10cSrcweir sal_Bool bNotFound = !DoesBlockExist(aName, sShortSearch);
448cdf0e10cSrcweir if(bNameED)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir // ist der Text durch einen Klick in die Listbox in das
451cdf0e10cSrcweir // Edit gekommem?
452cdf0e10cSrcweir if(bNotFound)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir aShortNameEdit.SetText( lcl_GetValidShortCut( aName ) );
455cdf0e10cSrcweir EnableShortName();
456cdf0e10cSrcweir }
457cdf0e10cSrcweir else
458cdf0e10cSrcweir {
459cdf0e10cSrcweir aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aName));
460cdf0e10cSrcweir EnableShortName(!bReadOnly);
461cdf0e10cSrcweir }
462cdf0e10cSrcweir aInsertBtn.Enable(!bNotFound && !bIsDocReadOnly);
463cdf0e10cSrcweir }
464cdf0e10cSrcweir else
465cdf0e10cSrcweir {
466cdf0e10cSrcweir //ShortNameEdit
467cdf0e10cSrcweir if(!bNotFound)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir sal_Bool bEnable = !bNotFound;
470cdf0e10cSrcweir bEnable &= !bIsDocReadOnly;
471cdf0e10cSrcweir aInsertBtn.Enable(bEnable);
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir return 0;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir /*--------------------------------------------------------------------
477cdf0e10cSrcweir Beschreibung:
478cdf0e10cSrcweir --------------------------------------------------------------------*/
479cdf0e10cSrcweir
480cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SwGlossaryDlg,NameDoubleClick,SvTreeListBox *,pBox)481cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, pBox )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir SvLBoxEntry* pEntry = pBox->FirstSelected();
484cdf0e10cSrcweir if(pBox->GetParent(pEntry) && !bIsDocReadOnly)
485cdf0e10cSrcweir EndDialog( RET_OK );
486cdf0e10cSrcweir return 0;
487cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwGlossaryDlg,NameDoubleClick,SvTreeListBox *,EMPTYARG)488cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwGlossaryDlg, NameDoubleClick, SvTreeListBox*, EMPTYARG )
489cdf0e10cSrcweir /*--------------------------------------------------------------------
490cdf0e10cSrcweir Beschreibung:
491cdf0e10cSrcweir --------------------------------------------------------------------*/
492cdf0e10cSrcweir
493cdf0e10cSrcweir
494cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, EnableHdl, Menu *, pMn )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir const String aEditText(aNameED.GetText());
497cdf0e10cSrcweir const sal_Bool bHasEntry = aEditText.Len() && aShortNameEdit.GetText().Len();
498cdf0e10cSrcweir const sal_Bool bExists = 0 != DoesBlockExist(aEditText, aShortNameEdit.GetText());
499cdf0e10cSrcweir pMn->EnableItem(FN_GL_DEFINE, bSelection && bHasEntry && !bExists);
500cdf0e10cSrcweir pMn->EnableItem(FN_GL_DEFINE_TEXT, bSelection && bHasEntry && !bExists);
501cdf0e10cSrcweir pMn->EnableItem(FN_GL_COPY_TO_CLIPBOARD, bExists);
502cdf0e10cSrcweir pMn->EnableItem(FN_GL_REPLACE, bSelection && bExists && !bIsOld );
503cdf0e10cSrcweir pMn->EnableItem(FN_GL_REPLACE_TEXT, bSelection && bExists && !bIsOld );
504cdf0e10cSrcweir pMn->EnableItem(FN_GL_EDIT, bExists );
505cdf0e10cSrcweir pMn->EnableItem(FN_GL_RENAME, bExists );
506cdf0e10cSrcweir pMn->EnableItem(FN_GL_DELETE, bExists );
507cdf0e10cSrcweir pMn->EnableItem(FN_GL_MACRO, bExists && !bIsOld &&
508cdf0e10cSrcweir !pGlossaryHdl->IsReadOnly() );
509cdf0e10cSrcweir
510cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
511cdf0e10cSrcweir sal_Bool bEnable = sal_False;
512cdf0e10cSrcweir if ( pEntry )
513cdf0e10cSrcweir bEnable = !aCategoryBox.GetParent( pEntry ) && !bIsOld && !pGlossaryHdl->IsReadOnly();
514cdf0e10cSrcweir pMn->EnableItem( FN_GL_IMPORT, bEnable );
515cdf0e10cSrcweir return 1;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir /*--------------------------------------------------------------------
518cdf0e10cSrcweir Beschreibung:
519cdf0e10cSrcweir --------------------------------------------------------------------*/
520cdf0e10cSrcweir
521cdf0e10cSrcweir
IMPL_LINK(SwGlossaryDlg,MenuHdl,Menu *,pMn)522cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir sal_Bool bNoAttr = sal_False;
525cdf0e10cSrcweir
526cdf0e10cSrcweir switch(pMn->GetCurItemId())
527cdf0e10cSrcweir {
528cdf0e10cSrcweir case FN_GL_REPLACE:
529cdf0e10cSrcweir case FN_GL_REPLACE_TEXT:
530cdf0e10cSrcweir pGlossaryHdl->NewGlossary( aNameED.GetText(),
531cdf0e10cSrcweir aShortNameEdit.GetText(),
532cdf0e10cSrcweir sal_False,
533cdf0e10cSrcweir pMn->GetCurItemId() == FN_GL_REPLACE_TEXT);
534cdf0e10cSrcweir break;
535cdf0e10cSrcweir case FN_GL_DEFINE_TEXT:
536cdf0e10cSrcweir bNoAttr = sal_True;
537cdf0e10cSrcweir // Kein break!!!
538cdf0e10cSrcweir case FN_GL_DEFINE:
539cdf0e10cSrcweir {
540cdf0e10cSrcweir const String aStr(aNameED.GetText());
541cdf0e10cSrcweir const String aShortName(aShortNameEdit.GetText());
542cdf0e10cSrcweir if(pGlossaryHdl->HasShortName(aShortName))
543cdf0e10cSrcweir {
544cdf0e10cSrcweir InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
545cdf0e10cSrcweir aShortNameEdit.SetSelection(Selection(0, SELECTION_MAX));
546cdf0e10cSrcweir aShortNameEdit.GrabFocus();
547cdf0e10cSrcweir break;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir if(pGlossaryHdl->NewGlossary(aStr, aShortName, sal_False, bNoAttr ))
550cdf0e10cSrcweir {
551cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
552cdf0e10cSrcweir if(aCategoryBox.GetParent(pEntry))
553cdf0e10cSrcweir pEntry = aCategoryBox.GetParent(pEntry);
554cdf0e10cSrcweir
555cdf0e10cSrcweir SvLBoxEntry* pChild = aCategoryBox.InsertEntry(aStr, pEntry);
556cdf0e10cSrcweir pChild->SetUserData(new String(aShortName));
557cdf0e10cSrcweir aNameED.SetText(aStr);
558cdf0e10cSrcweir aShortNameEdit.SetText(aShortName);
559cdf0e10cSrcweir NameModify(&aNameED); // fuer Schalten der Buttons
560cdf0e10cSrcweir
561cdf0e10cSrcweir if( SfxRequest::HasMacroRecorder( pSh->GetView().GetViewFrame() ) )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir SfxRequest aReq(pSh->GetView().GetViewFrame(), FN_NEW_GLOSSARY);
564cdf0e10cSrcweir String sTemp(*::GetCurrGlosGroup());
565cdf0e10cSrcweir // der nullte Pfad wird nicht aufgezeichnet!
566cdf0e10cSrcweir if('0' == sTemp.GetToken(1, GLOS_DELIM).GetChar(0))
567cdf0e10cSrcweir sTemp = sTemp.GetToken(0, GLOS_DELIM);
568cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_NEW_GLOSSARY, sTemp));
569cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_PARAM_1, aShortName));
570cdf0e10cSrcweir aReq.AppendItem(SfxStringItem(FN_PARAM_2, aStr));
571cdf0e10cSrcweir aReq.Done();
572cdf0e10cSrcweir }
573cdf0e10cSrcweir }
574cdf0e10cSrcweir }
575cdf0e10cSrcweir break;
576cdf0e10cSrcweir case FN_GL_COPY_TO_CLIPBOARD :
577cdf0e10cSrcweir {
578cdf0e10cSrcweir pGlossaryHdl->CopyToClipboard(*pSh, aShortNameEdit.GetText());
579cdf0e10cSrcweir }
580cdf0e10cSrcweir break;
581cdf0e10cSrcweir case FN_GL_EDIT:
582cdf0e10cSrcweir break;
583cdf0e10cSrcweir case FN_GL_RENAME:
584cdf0e10cSrcweir {
585cdf0e10cSrcweir aShortNameEdit.SetText(pGlossaryHdl->GetGlossaryShortName(aNameED.GetText()));
586cdf0e10cSrcweir SwNewGlosNameDlg* pNewNameDlg = new SwNewGlosNameDlg(this, aNameED.GetText(),
587cdf0e10cSrcweir aShortNameEdit.GetText() );
588cdf0e10cSrcweir if( RET_OK == pNewNameDlg->Execute() &&
589cdf0e10cSrcweir pGlossaryHdl->Rename( aShortNameEdit.GetText(),
590cdf0e10cSrcweir pNewNameDlg->GetNewShort(),
591cdf0e10cSrcweir pNewNameDlg->GetNewName()))
592cdf0e10cSrcweir {
593cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
594cdf0e10cSrcweir SvLBoxEntry* pNewEntry = aCategoryBox.InsertEntry(
595cdf0e10cSrcweir pNewNameDlg->GetNewName(), aCategoryBox.GetParent(pEntry));
596cdf0e10cSrcweir pNewEntry->SetUserData(new String(pNewNameDlg->GetNewShort()));
597cdf0e10cSrcweir delete (String*)pEntry->GetUserData();
598cdf0e10cSrcweir aCategoryBox.GetModel()->Remove(pEntry);
599cdf0e10cSrcweir aCategoryBox.Select(pNewEntry);
600cdf0e10cSrcweir aCategoryBox.MakeVisible(pNewEntry);
601cdf0e10cSrcweir }
602cdf0e10cSrcweir GrpSelect( &aCategoryBox );
603cdf0e10cSrcweir delete pNewNameDlg;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir break;
606cdf0e10cSrcweir case FN_GL_DELETE:
607cdf0e10cSrcweir {
608cdf0e10cSrcweir QueryBox aQuery(this, SW_RES(MSG_QUERY_DELETE));
609cdf0e10cSrcweir if(RET_YES == aQuery.Execute())
610cdf0e10cSrcweir {
611cdf0e10cSrcweir const String aShortName(aShortNameEdit.GetText());
612cdf0e10cSrcweir const String aTitle(aNameED.GetText());
613cdf0e10cSrcweir if(aTitle.Len() && pGlossaryHdl->DelGlossary(aShortName))
614cdf0e10cSrcweir {
615cdf0e10cSrcweir SvLBoxEntry* pChild = DoesBlockExist(aTitle, aShortName);
616cdf0e10cSrcweir DBG_ASSERT(pChild, "Eintrag nicht gefunden!");
617cdf0e10cSrcweir SvLBoxEntry* pParent = aCategoryBox.GetParent(pChild);
618cdf0e10cSrcweir aCategoryBox.Select(pParent);
619cdf0e10cSrcweir
620cdf0e10cSrcweir aCategoryBox.GetModel()->Remove(pChild);
621cdf0e10cSrcweir aNameED.SetText( aEmptyStr );
622cdf0e10cSrcweir NameModify(&aNameED);
623cdf0e10cSrcweir }
624cdf0e10cSrcweir }
625cdf0e10cSrcweir }
626cdf0e10cSrcweir break;
627cdf0e10cSrcweir case FN_GL_MACRO:
628cdf0e10cSrcweir {
629cdf0e10cSrcweir SfxItemSet aSet( pSh->GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
630cdf0e10cSrcweir
631cdf0e10cSrcweir SvxMacro aStart(aEmptyStr, aEmptyStr, STARBASIC);
632cdf0e10cSrcweir SvxMacro aEnd(aEmptyStr, aEmptyStr, STARBASIC);
633cdf0e10cSrcweir pGlossaryHdl->GetMacros(aShortNameEdit.GetText(), aStart, aEnd );
634cdf0e10cSrcweir
635cdf0e10cSrcweir SvxMacroItem aItem(RES_FRMMACRO);
636cdf0e10cSrcweir if( aStart.GetMacName().Len() )
637cdf0e10cSrcweir aItem.SetMacro( SW_EVENT_START_INS_GLOSSARY, aStart );
638cdf0e10cSrcweir if( aEnd.GetMacName().Len() )
639cdf0e10cSrcweir aItem.SetMacro( SW_EVENT_END_INS_GLOSSARY, aEnd );
640cdf0e10cSrcweir
641cdf0e10cSrcweir aSet.Put( aItem );
642cdf0e10cSrcweir aSet.Put( SwMacroAssignDlg::AddEvents( MACASSGN_TEXTBAUST ) );
643cdf0e10cSrcweir
644cdf0e10cSrcweir const SfxPoolItem* pItem;
645cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
646cdf0e10cSrcweir SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet,
647cdf0e10cSrcweir pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG );
648cdf0e10cSrcweir if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
649cdf0e10cSrcweir SFX_ITEM_SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, sal_False, &pItem ) )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir const SvxMacroTableDtor& rTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
652cdf0e10cSrcweir pGlossaryHdl->SetMacros( aShortNameEdit.GetText(),
653cdf0e10cSrcweir rTbl.Get( SW_EVENT_START_INS_GLOSSARY ),
654cdf0e10cSrcweir rTbl.Get( SW_EVENT_END_INS_GLOSSARY ) );
655cdf0e10cSrcweir }
656cdf0e10cSrcweir
657cdf0e10cSrcweir delete pMacroDlg;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir break;
660cdf0e10cSrcweir
661cdf0e10cSrcweir case FN_GL_IMPORT:
662cdf0e10cSrcweir {
663cdf0e10cSrcweir // call the FileOpenDialog do find WinWord - Files with templates
664cdf0e10cSrcweir FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
665cdf0e10cSrcweir uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
666cdf0e10cSrcweir
667cdf0e10cSrcweir SvtPathOptions aPathOpt;
668cdf0e10cSrcweir xFP->setDisplayDirectory(aPathOpt.GetWorkPath() );
669cdf0e10cSrcweir String sWW8( C2S( FILTER_WW8 ) );
670cdf0e10cSrcweir
671cdf0e10cSrcweir uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
672cdf0e10cSrcweir SfxFilterMatcher aMatcher( String::CreateFromAscii(SwDocShell::Factory().GetShortName()) );
673cdf0e10cSrcweir SfxFilterMatcherIter aIter( &aMatcher );
674cdf0e10cSrcweir const SfxFilter* pFilter = aIter.First();
675cdf0e10cSrcweir while ( pFilter )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir if( pFilter->GetUserData() == sWW8 )
678cdf0e10cSrcweir {
679cdf0e10cSrcweir xFltMgr->appendFilter( pFilter->GetUIName(),
680cdf0e10cSrcweir ((WildCard&)pFilter->GetWildcard()).GetWildCard() );
681cdf0e10cSrcweir xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir
684cdf0e10cSrcweir pFilter = aIter.Next();
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
687cdf0e10cSrcweir if( aDlgHelper.Execute() == ERRCODE_NONE )
688cdf0e10cSrcweir {
689cdf0e10cSrcweir if( pGlossaryHdl->ImportGlossaries( xFP->getFiles().getConstArray()[0] ))
690cdf0e10cSrcweir Init();
691cdf0e10cSrcweir else
692cdf0e10cSrcweir {
693cdf0e10cSrcweir InfoBox(this, SW_RES( MSG_NO_GLOSSARIES )).Execute();
694cdf0e10cSrcweir }
695cdf0e10cSrcweir }
696cdf0e10cSrcweir }
697cdf0e10cSrcweir break;
698cdf0e10cSrcweir
699cdf0e10cSrcweir default:
700cdf0e10cSrcweir return 0;
701cdf0e10cSrcweir }
702cdf0e10cSrcweir return 1;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir /*--------------------------------------------------------------------
705cdf0e10cSrcweir Beschreibung: Dialog Verwaltung Bereiche
706cdf0e10cSrcweir --------------------------------------------------------------------*/
707cdf0e10cSrcweir
708cdf0e10cSrcweir
IMPL_LINK(SwGlossaryDlg,BibHdl,Button *,EMPTYARG)709cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, BibHdl, Button *, EMPTYARG )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir SwGlossaries* pGloss = ::GetGlossaries();
712cdf0e10cSrcweir if( pGloss->IsGlosPathErr() )
713cdf0e10cSrcweir pGloss->ShowError();
714cdf0e10cSrcweir else
715cdf0e10cSrcweir {
716cdf0e10cSrcweir //check if at least one glossary path is write enabled
717cdf0e10cSrcweir SvtPathOptions aPathOpt;
718cdf0e10cSrcweir String sGlosPath( aPathOpt.GetAutoTextPath() );
719cdf0e10cSrcweir sal_uInt16 nPaths = sGlosPath.GetTokenCount(';');
720cdf0e10cSrcweir sal_Bool bIsWritable = sal_False;
721cdf0e10cSrcweir for(sal_uInt16 nPath = 0; nPath < nPaths; nPath++)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir String sPath = URIHelper::SmartRel2Abs(
724cdf0e10cSrcweir INetURLObject(), sGlosPath.GetToken(nPath, ';'),
725cdf0e10cSrcweir URIHelper::GetMaybeFileHdl());
726cdf0e10cSrcweir try
727cdf0e10cSrcweir {
728cdf0e10cSrcweir Content aTestContent( sPath,
729cdf0e10cSrcweir uno::Reference< XCommandEnvironment >());
730cdf0e10cSrcweir Any aAny = aTestContent.getPropertyValue( C2U("IsReadOnly") );
731cdf0e10cSrcweir if(aAny.hasValue())
732cdf0e10cSrcweir {
733cdf0e10cSrcweir bIsWritable = !*(sal_Bool*)aAny.getValue();
734cdf0e10cSrcweir }
735cdf0e10cSrcweir }
736cdf0e10cSrcweir catch(Exception&)
737cdf0e10cSrcweir {}
738cdf0e10cSrcweir if(bIsWritable)
739cdf0e10cSrcweir break;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir if(bIsWritable)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir
744cdf0e10cSrcweir SwGlossaryGroupDlg *pDlg = new SwGlossaryGroupDlg( this, pGloss->GetPathArray(), pGlossaryHdl );
745cdf0e10cSrcweir if ( RET_OK == pDlg->Execute() )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir Init();
748cdf0e10cSrcweir //if new groups were created - select one of them
749cdf0e10cSrcweir String sNewGroup = pDlg->GetCreatedGroupName();
750cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.First();
751cdf0e10cSrcweir while(sNewGroup.Len() && pEntry)
752cdf0e10cSrcweir {
753cdf0e10cSrcweir if(!aCategoryBox.GetParent(pEntry))
754cdf0e10cSrcweir {
755cdf0e10cSrcweir GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
756cdf0e10cSrcweir String sGroup = pGroupData->sGroupName;
757cdf0e10cSrcweir sGroup += GLOS_DELIM;
758cdf0e10cSrcweir sGroup += String::CreateFromInt32(pGroupData->nPathIdx);
759cdf0e10cSrcweir if(sGroup == sNewGroup)
760cdf0e10cSrcweir {
761cdf0e10cSrcweir aCategoryBox.Select(pEntry);
762cdf0e10cSrcweir aCategoryBox.MakeVisible(pEntry);
763cdf0e10cSrcweir GrpSelect(&aCategoryBox);
764cdf0e10cSrcweir break;
765cdf0e10cSrcweir }
766cdf0e10cSrcweir }
767cdf0e10cSrcweir pEntry = aCategoryBox.Next(pEntry);
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
770cdf0e10cSrcweir }
771cdf0e10cSrcweir delete pDlg;
772cdf0e10cSrcweir }
773cdf0e10cSrcweir else
774cdf0e10cSrcweir {
775cdf0e10cSrcweir QueryBox aBox(this, WB_YES_NO, sReadonlyPath);
776cdf0e10cSrcweir if(RET_YES == aBox.Execute())
777cdf0e10cSrcweir PathHdl(&aPathBtn);
778cdf0e10cSrcweir }
779cdf0e10cSrcweir }
780cdf0e10cSrcweir return 0;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
783cdf0e10cSrcweir /*------------------------------------------------------------------------
784cdf0e10cSrcweir Beschreibung: Initialisierung; aus Ctor und nach Bearbeiten Bereiche
785cdf0e10cSrcweir ------------------------------------------------------------------------*/
786cdf0e10cSrcweir
787cdf0e10cSrcweir
Init()788cdf0e10cSrcweir void SwGlossaryDlg::Init()
789cdf0e10cSrcweir {
790cdf0e10cSrcweir aCategoryBox.SetUpdateMode( sal_False );
791cdf0e10cSrcweir aCategoryBox.Clear();
792cdf0e10cSrcweir // Textbausteinbereiche anzeigen
793cdf0e10cSrcweir const sal_uInt16 nCnt = pGlossaryHdl->GetGroupCnt();
794cdf0e10cSrcweir SvLBoxEntry* pSelEntry = 0;
795cdf0e10cSrcweir const String sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM));
796cdf0e10cSrcweir const sal_uInt16 nSelPath = static_cast< sal_uInt16 >(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM).ToInt32());
797cdf0e10cSrcweir for(sal_uInt16 nId = 0; nId < nCnt; ++nId )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir String sTitle;
800cdf0e10cSrcweir String sGroupName(pGlossaryHdl->GetGroupName(nId, &sTitle));
801cdf0e10cSrcweir if(!sGroupName.Len())
802cdf0e10cSrcweir continue;
803cdf0e10cSrcweir if(!sTitle.Len())
804cdf0e10cSrcweir sTitle = sGroupName.GetToken( 0, GLOS_DELIM );
805cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.InsertEntry( sTitle );
806cdf0e10cSrcweir sal_uInt16 nPath = static_cast< sal_uInt16 >(sGroupName.GetToken( 1, GLOS_DELIM ).ToInt32());
807cdf0e10cSrcweir
808cdf0e10cSrcweir GroupUserData* pData = new GroupUserData;
809cdf0e10cSrcweir pData->sGroupName = sGroupName.GetToken(0, GLOS_DELIM);
810cdf0e10cSrcweir pData->nPathIdx = nPath;
811cdf0e10cSrcweir pData->bReadonly = pGlossaryHdl->IsReadOnly(&sGroupName);
812cdf0e10cSrcweir
813cdf0e10cSrcweir pEntry->SetUserData(pData);
814cdf0e10cSrcweir if(sSelStr == pData->sGroupName && nSelPath == nPath)
815cdf0e10cSrcweir pSelEntry = pEntry;
816cdf0e10cSrcweir
817cdf0e10cSrcweir //Eintraege fuer die Gruppen auffuellen
818cdf0e10cSrcweir {
819cdf0e10cSrcweir pGlossaryHdl->SetCurGroup(sGroupName, sal_False, sal_True);
820cdf0e10cSrcweir const sal_uInt16 nCount = pGlossaryHdl->GetGlossaryCnt();
821cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i)
822cdf0e10cSrcweir {
823cdf0e10cSrcweir String sGroupTitle(pGlossaryHdl->GetGlossaryName(i));
824cdf0e10cSrcweir SvLBoxEntry* pChild = aCategoryBox.InsertEntry(
825cdf0e10cSrcweir sGroupTitle, pEntry);
826cdf0e10cSrcweir pChild->SetUserData(new String(pGlossaryHdl->GetGlossaryShortName(i)));
827cdf0e10cSrcweir }
828cdf0e10cSrcweir }
829cdf0e10cSrcweir }
830cdf0e10cSrcweir // Aktuelle Gruppe setzen und Textbausteine anzeigen
831cdf0e10cSrcweir if(!pSelEntry)
832cdf0e10cSrcweir {
833cdf0e10cSrcweir //find a non-readonly group
834cdf0e10cSrcweir SvLBoxEntry* pSearch = aCategoryBox.First();
835cdf0e10cSrcweir while(pSearch)
836cdf0e10cSrcweir {
837cdf0e10cSrcweir if(!aCategoryBox.GetParent(pSearch))
838cdf0e10cSrcweir {
839cdf0e10cSrcweir GroupUserData* pData = (GroupUserData*)pSearch->GetUserData();
840cdf0e10cSrcweir if(!pData->bReadonly)
841cdf0e10cSrcweir {
842cdf0e10cSrcweir pSelEntry = pSearch;
843cdf0e10cSrcweir break;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir pSearch = aCategoryBox.Next(pSearch);
847cdf0e10cSrcweir }
848cdf0e10cSrcweir if(!pSelEntry)
849cdf0e10cSrcweir pSelEntry = aCategoryBox.GetEntry(0);
850cdf0e10cSrcweir }
851cdf0e10cSrcweir if(pSelEntry)
852cdf0e10cSrcweir {
853cdf0e10cSrcweir aCategoryBox.Expand(pSelEntry);
854cdf0e10cSrcweir aCategoryBox.Select(pSelEntry);
855cdf0e10cSrcweir aCategoryBox.MakeVisible(pSelEntry);
856cdf0e10cSrcweir GrpSelect(&aCategoryBox);
857cdf0e10cSrcweir }
858cdf0e10cSrcweir //JP 16.11.99: the SvxTreeListBox has a Bug. The Box dont recalc the
859cdf0e10cSrcweir // outputsize, when all entries are insertet. The result is, that
860cdf0e10cSrcweir // the Focus/Highlight rectangle is to large and paintet over the
861cdf0e10cSrcweir // HScrollbar. -> Fix: call the resize
862cdf0e10cSrcweir aCategoryBox.Resize();
863cdf0e10cSrcweir
864cdf0e10cSrcweir aCategoryBox.GetModel()->Resort();
865cdf0e10cSrcweir aCategoryBox.SetUpdateMode( sal_True );
866cdf0e10cSrcweir aCategoryBox.Update();
867cdf0e10cSrcweir
868cdf0e10cSrcweir const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
869cdf0e10cSrcweir aFileRelCB.Check( pCfg->IsSaveRelFile() );
870cdf0e10cSrcweir aFileRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
871cdf0e10cSrcweir aNetRelCB.Check( pCfg->IsSaveRelNet() );
872cdf0e10cSrcweir aNetRelCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
873cdf0e10cSrcweir aInsertTipCB.Check( pCfg->IsAutoTextTip() );
874cdf0e10cSrcweir aInsertTipCB.SetClickHdl(LINK(this, SwGlossaryDlg, CheckBoxHdl));
875cdf0e10cSrcweir }
876cdf0e10cSrcweir /*------------------------------------------------------------------------
877cdf0e10cSrcweir Beschreibung:
878cdf0e10cSrcweir ------------------------------------------------------------------------*/
879cdf0e10cSrcweir
880cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SwGlossaryDlg,EditHdl,Button *,EMPTYARG)881cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir //EndDialog darf nicht im MenuHdl aufgerufen werden
884cdf0e10cSrcweir if(aEditBtn.GetCurItemId() == FN_GL_EDIT )
885cdf0e10cSrcweir {
886cdf0e10cSrcweir SwTextBlocks *pGroup = ::GetGlossaries()->GetGroupDoc ( GetCurrGrpName () );
887cdf0e10cSrcweir sal_Bool bRet = pGlossaryHdl->ConvertToNew ( *pGroup );
888cdf0e10cSrcweir delete pGroup;
889cdf0e10cSrcweir if ( bRet )
890cdf0e10cSrcweir EndDialog(RET_EDIT);
891cdf0e10cSrcweir }
892cdf0e10cSrcweir return 0;
893cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwGlossaryDlg,EditHdl,Button *,EMPTYARG)894cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwGlossaryDlg, EditHdl, Button *, EMPTYARG )
895cdf0e10cSrcweir
896cdf0e10cSrcweir /*------------------------------------------------------------------------
897cdf0e10cSrcweir Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces
898cdf0e10cSrcweir ------------------------------------------------------------------------*/
899cdf0e10cSrcweir
900cdf0e10cSrcweir IMPL_LINK( SwNewGlosNameDlg, Modify, Edit *, pBox )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir String aName(aNewName.GetText());
903cdf0e10cSrcweir SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
904cdf0e10cSrcweir
905cdf0e10cSrcweir if( pBox == &aNewName )
906cdf0e10cSrcweir aNewShort.SetText( lcl_GetValidShortCut( aName ) );
907cdf0e10cSrcweir
908cdf0e10cSrcweir sal_Bool bEnable = aName.Len() && aNewShort.GetText().Len() &&
909cdf0e10cSrcweir (!pDlg->DoesBlockExist(aName, aNewShort.GetText())
910cdf0e10cSrcweir || aName == aOldName.GetText());
911cdf0e10cSrcweir aOk.Enable(bEnable);
912cdf0e10cSrcweir return 0;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir /*------------------------------------------------------------------------
915cdf0e10cSrcweir Beschreibung:
916cdf0e10cSrcweir ------------------------------------------------------------------------*/
917cdf0e10cSrcweir
IMPL_LINK(SwNewGlosNameDlg,Rename,Button *,EMPTYARG)918cdf0e10cSrcweir IMPL_LINK( SwNewGlosNameDlg, Rename, Button *, EMPTYARG )
919cdf0e10cSrcweir {
920cdf0e10cSrcweir SwGlossaryDlg* pDlg = (SwGlossaryDlg*)GetParent();
921cdf0e10cSrcweir String sNew = aNewShort.GetText();
922cdf0e10cSrcweir GetAppCharClass().toUpper(sNew);
923cdf0e10cSrcweir if( pDlg->pGlossaryHdl->HasShortName(aNewShort.GetText())
924cdf0e10cSrcweir && sNew != aOldShort.GetText() )
925cdf0e10cSrcweir {
926cdf0e10cSrcweir InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME)).Execute();
927cdf0e10cSrcweir aNewShort.GrabFocus();
928cdf0e10cSrcweir }
929cdf0e10cSrcweir else
930cdf0e10cSrcweir EndDialog(sal_True);
931cdf0e10cSrcweir return 0;
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
934cdf0e10cSrcweir /*------------------------------------------------------------------------
935cdf0e10cSrcweir Beschreibung:
936cdf0e10cSrcweir ------------------------------------------------------------------------*/
937cdf0e10cSrcweir
IMPL_LINK(SwGlossaryDlg,CheckBoxHdl,CheckBox *,pBox)938cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, CheckBoxHdl, CheckBox *, pBox )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
941cdf0e10cSrcweir sal_Bool bCheck = pBox->IsChecked();
942cdf0e10cSrcweir if( pBox == &aInsertTipCB )
943cdf0e10cSrcweir pCfg->SetAutoTextTip(bCheck);
944cdf0e10cSrcweir else if(pBox == &aFileRelCB)
945cdf0e10cSrcweir pCfg->SetSaveRelFile(bCheck);
946cdf0e10cSrcweir else
947cdf0e10cSrcweir pCfg->SetSaveRelNet(bCheck);
948cdf0e10cSrcweir return 0;
949cdf0e10cSrcweir }
950cdf0e10cSrcweir
951cdf0e10cSrcweir /* -----------------26.11.98 15:18-------------------
952cdf0e10cSrcweir * TreeListBox fuer Gruppen und Bausteine
953cdf0e10cSrcweir * --------------------------------------------------*/
SwGlTreeListBox(Window * pParent,const ResId & rResId)954cdf0e10cSrcweir SwGlTreeListBox::SwGlTreeListBox(Window* pParent, const ResId& rResId) :
955cdf0e10cSrcweir SvTreeListBox(pParent, rResId),
956cdf0e10cSrcweir sReadonly (SW_RES(ST_READONLY)),
957cdf0e10cSrcweir pDragEntry(0)
958cdf0e10cSrcweir {
959cdf0e10cSrcweir FreeResource();
960cdf0e10cSrcweir SetDragDropMode( SV_DRAGDROP_CTRL_MOVE|SV_DRAGDROP_CTRL_COPY );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir /* -----------------30.11.98 10:49-------------------
963cdf0e10cSrcweir *
964cdf0e10cSrcweir * --------------------------------------------------*/
Clear()965cdf0e10cSrcweir void SwGlTreeListBox::Clear()
966cdf0e10cSrcweir {
967cdf0e10cSrcweir SvLBoxEntry* pEntry = First();
968cdf0e10cSrcweir while(pEntry)
969cdf0e10cSrcweir {
970cdf0e10cSrcweir if(GetParent(pEntry))
971cdf0e10cSrcweir delete (String*)pEntry->GetUserData();
972cdf0e10cSrcweir else
973cdf0e10cSrcweir delete (GroupUserData*)pEntry->GetUserData();
974cdf0e10cSrcweir pEntry = Next(pEntry);
975cdf0e10cSrcweir }
976cdf0e10cSrcweir SvTreeListBox::Clear();
977cdf0e10cSrcweir }
978cdf0e10cSrcweir
979cdf0e10cSrcweir /*-----------------10.06.97 14.52-------------------
980cdf0e10cSrcweir
981cdf0e10cSrcweir --------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)982cdf0e10cSrcweir void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
985cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( aPos );
986cdf0e10cSrcweir // Hilfe gibt es nur fuer die Gruppennamen
987cdf0e10cSrcweir if(pEntry)
988cdf0e10cSrcweir {
989cdf0e10cSrcweir SvLBoxTab* pTab;
990cdf0e10cSrcweir SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
991cdf0e10cSrcweir if(pItem)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir aPos = GetEntryPosition( pEntry );
994cdf0e10cSrcweir Size aSize(pItem->GetSize( this, pEntry ));
995cdf0e10cSrcweir aPos.X() = GetTabPos( pEntry, pTab );
996cdf0e10cSrcweir
997cdf0e10cSrcweir if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
998cdf0e10cSrcweir aSize.Width() = GetSizePixel().Width() - aPos.X();
999cdf0e10cSrcweir aPos = OutputToScreenPixel(aPos);
1000cdf0e10cSrcweir Rectangle aItemRect( aPos, aSize );
1001cdf0e10cSrcweir String sMsg;
1002cdf0e10cSrcweir if(!GetParent(pEntry))
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir GroupUserData* pData = (GroupUserData*)pEntry->GetUserData();
1005cdf0e10cSrcweir const SvStrings* pPathArr = ::GetGlossaries()->GetPathArray();
1006cdf0e10cSrcweir if(pPathArr->Count())
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir sMsg = (*(*pPathArr)[pData->nPathIdx]);
1009cdf0e10cSrcweir sMsg += INET_PATH_TOKEN;
1010cdf0e10cSrcweir sMsg += pData->sGroupName;
1011cdf0e10cSrcweir sMsg += SwGlossaries::GetExtension();
1012cdf0e10cSrcweir INetURLObject aTmp(sMsg);
1013cdf0e10cSrcweir sMsg = aTmp.GetPath();
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir if(pData->bReadonly)
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir sMsg += ' ';
1018cdf0e10cSrcweir sMsg += '(';
1019cdf0e10cSrcweir sMsg += sReadonly;
1020cdf0e10cSrcweir sMsg += ')';
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir else
1027cdf0e10cSrcweir sMsg = *(String*)pEntry->GetUserData();
1028cdf0e10cSrcweir Help::ShowQuickHelp( this, aItemRect, sMsg,
1029cdf0e10cSrcweir QUICKHELP_LEFT|QUICKHELP_VCENTER );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir /* -----------------26.11.98 14:42-------------------
1034cdf0e10cSrcweir *
1035cdf0e10cSrcweir * --------------------------------------------------*/
NotifyStartDrag(TransferDataContainer &,SvLBoxEntry * pEntry)1036cdf0e10cSrcweir DragDropMode SwGlTreeListBox::NotifyStartDrag(
1037cdf0e10cSrcweir TransferDataContainer& /*rContainer*/,
1038cdf0e10cSrcweir SvLBoxEntry* pEntry )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir DragDropMode eRet;
1041cdf0e10cSrcweir pDragEntry = pEntry;
1042cdf0e10cSrcweir if(!GetParent(pEntry))
1043cdf0e10cSrcweir eRet = SV_DRAGDROP_NONE;
1044cdf0e10cSrcweir else
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
1047cdf0e10cSrcweir SvLBoxEntry* pParent = GetParent(pEntry);
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir GroupUserData* pGroupData = (GroupUserData*)pParent->GetUserData();
1050cdf0e10cSrcweir String sEntry(pGroupData->sGroupName);
1051cdf0e10cSrcweir sEntry += GLOS_DELIM;
1052cdf0e10cSrcweir sEntry += String::CreateFromInt32(pGroupData->nPathIdx);
1053cdf0e10cSrcweir sal_Int8 nDragOption = DND_ACTION_COPY;
1054cdf0e10cSrcweir eRet = SV_DRAGDROP_CTRL_COPY;
1055cdf0e10cSrcweir if(!pDlg->pGlossaryHdl->IsReadOnly(&sEntry))
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir eRet |= SV_DRAGDROP_CTRL_MOVE;
1058cdf0e10cSrcweir nDragOption |= DND_ACTION_MOVE;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir SetDragOptions( nDragOption );
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir return eRet;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir /* -----------------27.11.98 09:35-------------------
1065cdf0e10cSrcweir *
1066cdf0e10cSrcweir * --------------------------------------------------*/
NotifyAcceptDrop(SvLBoxEntry * pEntry)1067cdf0e10cSrcweir sal_Bool SwGlTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry)
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir // TODO: Readonly - Ueberpruefung fehlt noch!
1070cdf0e10cSrcweir SvLBoxEntry* pSrcParent = GetParent(pEntry) ? GetParent(pEntry) : pEntry;
1071cdf0e10cSrcweir SvLBoxEntry* pDestParent =
1072cdf0e10cSrcweir GetParent(pDragEntry ) ? GetParent(pDragEntry ) : pDragEntry ;
1073cdf0e10cSrcweir return pDestParent != pSrcParent;
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir /* -----------------26.11.98 14:42-------------------
1077cdf0e10cSrcweir *
1078cdf0e10cSrcweir * --------------------------------------------------*/
NotifyMoving(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * &,sal_uLong &)1079cdf0e10cSrcweir sal_Bool SwGlTreeListBox::NotifyMoving( SvLBoxEntry* pTarget,
1080cdf0e10cSrcweir SvLBoxEntry* pEntry,
1081cdf0e10cSrcweir SvLBoxEntry*& /*rpNewParent*/,
1082cdf0e10cSrcweir sal_uLong& /*rNewChildPos*/
1083cdf0e10cSrcweir )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir pDragEntry = 0;
1086cdf0e10cSrcweir if(!pTarget) //An den Anfang verschieben
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir pTarget = GetEntry(0);
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir // 1. wird in verschiedene Gruppen verschoben?
1091cdf0e10cSrcweir // 2. darf in beiden Gruppen geschrieben werden?
1092cdf0e10cSrcweir SvLBoxEntry* pSrcParent = GetParent(pEntry);
1093cdf0e10cSrcweir SvLBoxEntry* pDestParent =
1094cdf0e10cSrcweir GetParent(pTarget) ? GetParent(pTarget) : pTarget;
1095cdf0e10cSrcweir sal_Bool bRet = sal_False;
1096cdf0e10cSrcweir if(pDestParent != pSrcParent)
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
10998ef2f12bSOliver-Rainer Wittmann SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), true );
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
1102cdf0e10cSrcweir String sSourceGroup(pGroupData->sGroupName);
1103cdf0e10cSrcweir sSourceGroup += GLOS_DELIM;
1104cdf0e10cSrcweir sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);
1105cdf0e10cSrcweir pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
1106cdf0e10cSrcweir String sTitle(GetEntryText(pEntry));
1107cdf0e10cSrcweir String sShortName(*(String*)pEntry->GetUserData());
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
1110cdf0e10cSrcweir String sDestName = pDestData->sGroupName;
1111cdf0e10cSrcweir sDestName += GLOS_DELIM;
1112cdf0e10cSrcweir sDestName += String::CreateFromInt32(pDestData->nPathIdx);
1113cdf0e10cSrcweir bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
1114cdf0e10cSrcweir sDestName, sTitle, sal_True );
1115cdf0e10cSrcweir if(bRet)
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
1118cdf0e10cSrcweir pChild->SetUserData(new String(sShortName));
1119cdf0e10cSrcweir GetModel()->Remove(pEntry);
1120cdf0e10cSrcweir }
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir return sal_False; //sonst wird der Eintrag automatisch vorgenommen
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir /* -----------------26.11.98 14:42-------------------
1125cdf0e10cSrcweir *
1126cdf0e10cSrcweir * --------------------------------------------------*/
NotifyCopying(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * &,sal_uLong &)1127cdf0e10cSrcweir sal_Bool SwGlTreeListBox::NotifyCopying( SvLBoxEntry* pTarget,
1128cdf0e10cSrcweir SvLBoxEntry* pEntry,
1129cdf0e10cSrcweir SvLBoxEntry*& /*rpNewParent*/,
1130cdf0e10cSrcweir sal_uLong& /*rNewChildPos*/
1131cdf0e10cSrcweir )
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir pDragEntry = 0;
1134cdf0e10cSrcweir // 1. wird in verschiedene Gruppen verschoben?
1135cdf0e10cSrcweir // 2. darf in beiden Gruppen geschrieben werden?
1136cdf0e10cSrcweir if(!pTarget) //An den Anfang verschieben
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir pTarget = GetEntry(0);
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir SvLBoxEntry* pSrcParent = GetParent(pEntry);
1141cdf0e10cSrcweir SvLBoxEntry* pDestParent =
1142cdf0e10cSrcweir GetParent(pTarget) ? GetParent(pTarget) : pTarget;
1143cdf0e10cSrcweir sal_Bool bRet = sal_False;
1144cdf0e10cSrcweir if(pDestParent != pSrcParent)
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir SwGlossaryDlg* pDlg = (SwGlossaryDlg*)Window::GetParent();
11478ef2f12bSOliver-Rainer Wittmann SwWait aWait( *pDlg->pSh->GetView().GetDocShell(), true );
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir GroupUserData* pGroupData = (GroupUserData*)pSrcParent->GetUserData();
1150cdf0e10cSrcweir String sSourceGroup(pGroupData->sGroupName);
1151cdf0e10cSrcweir sSourceGroup += GLOS_DELIM;
1152cdf0e10cSrcweir sSourceGroup += String::CreateFromInt32(pGroupData->nPathIdx);
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir pDlg->pGlossaryHdl->SetCurGroup(sSourceGroup);
1155cdf0e10cSrcweir String sTitle(GetEntryText(pEntry));
1156cdf0e10cSrcweir String sShortName(*(String*)pEntry->GetUserData());
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir GroupUserData* pDestData = (GroupUserData*)pDestParent->GetUserData();
1159cdf0e10cSrcweir String sDestName = pDestData->sGroupName;
1160cdf0e10cSrcweir sDestName += GLOS_DELIM;
1161cdf0e10cSrcweir sDestName += String::CreateFromInt32(pDestData->nPathIdx);
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir bRet = pDlg->pGlossaryHdl->CopyOrMove( sSourceGroup, sShortName,
1164cdf0e10cSrcweir sDestName, sTitle, sal_False );
1165cdf0e10cSrcweir if(bRet)
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir SvLBoxEntry* pChild = InsertEntry(sTitle, pDestParent);
1168cdf0e10cSrcweir pChild->SetUserData(new String(sShortName));
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir return sal_False; //sonst wird der Eintrag automatisch vorgenommen
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir /*-----------------10.06.97 15.18-------------------
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir --------------------------------------------------*/
GetCurrGrpName() const1178cdf0e10cSrcweir String SwGlossaryDlg::GetCurrGrpName() const
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir SvLBoxEntry* pEntry = aCategoryBox.FirstSelected();
1181cdf0e10cSrcweir String sRet;
1182cdf0e10cSrcweir if(pEntry)
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir pEntry =
1185cdf0e10cSrcweir aCategoryBox.GetParent(pEntry) ? aCategoryBox.GetParent(pEntry) : pEntry;
1186cdf0e10cSrcweir GroupUserData* pGroupData = (GroupUserData*)pEntry->GetUserData();
1187cdf0e10cSrcweir sRet = pGroupData->sGroupName;
1188cdf0e10cSrcweir sRet += GLOS_DELIM;
1189cdf0e10cSrcweir sRet += String::CreateFromInt32(pGroupData->nPathIdx);
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir return sRet;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir /*-----------------11.06.97 08.17-------------------
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryDlg,PathHdl,Button *,pBtn)1197cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, PathHdl, Button *, pBtn )
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1200cdf0e10cSrcweir if(pFact)
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir AbstractSvxMultiPathDialog* pDlg = pFact->CreateSvxMultiPathDialog( pBtn );
1203cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
1204cdf0e10cSrcweir SvtPathOptions aPathOpt;
1205cdf0e10cSrcweir String sGlosPath( aPathOpt.GetAutoTextPath() );
1206cdf0e10cSrcweir pDlg->SetPath(sGlosPath);
1207cdf0e10cSrcweir if(RET_OK == pDlg->Execute())
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir String sTmp(pDlg->GetPath());
1210cdf0e10cSrcweir if(sTmp != sGlosPath)
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir aPathOpt.SetAutoTextPath( sTmp );
1213cdf0e10cSrcweir ::GetGlossaries()->UpdateGlosPath( sal_True );
1214cdf0e10cSrcweir Init();
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir delete pDlg;
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir return 0;
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir /* -----------------28.07.99 13:48-------------------
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryDlg,ShowPreviewHdl,CheckBox *,pBox)1224cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, ShowPreviewHdl, CheckBox *, pBox )
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir sal_Bool bCreated = sal_False;
1227cdf0e10cSrcweir if(pBox->IsChecked())
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir //create example
1230cdf0e10cSrcweir if(!pExampleFrame)
1231cdf0e10cSrcweir {
1232cdf0e10cSrcweir Link aLink(LINK(this, SwGlossaryDlg, PreviewLoadedHdl));
1233cdf0e10cSrcweir pExampleFrame = new SwOneExampleFrame( aExampleWIN,
1234cdf0e10cSrcweir EX_SHOW_ONLINE_LAYOUT, &aLink );
1235cdf0e10cSrcweir bCreated = sal_True;
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir sal_Bool bShow = pBox->IsChecked() && !bCreated;
1240cdf0e10cSrcweir aExampleWIN.Show( bShow );
1241cdf0e10cSrcweir aExampleDummyWIN.Show(!bShow);
1242cdf0e10cSrcweir if( ::GetCurrGlosGroup() )
1243cdf0e10cSrcweir ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit.GetText());
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir return 0;
1246cdf0e10cSrcweir };
1247cdf0e10cSrcweir /* -----------------18.11.99 17:09-------------------
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlossaryDlg,PreviewLoadedHdl,void *,EMPTYARG)1250cdf0e10cSrcweir IMPL_LINK( SwGlossaryDlg, PreviewLoadedHdl, void *, EMPTYARG )
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir sal_Bool bShow = aShowExampleCB.IsChecked();
1253cdf0e10cSrcweir aExampleWIN.Show( bShow );
1254cdf0e10cSrcweir aExampleDummyWIN.Show(!bShow);
1255cdf0e10cSrcweir ResumeShowAutoText();
1256cdf0e10cSrcweir return 0;
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir /* -----------------28.07.99 16:28-------------------
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir --------------------------------------------------*/
ShowAutoText(const String & rGroup,const String & rShortName)1262cdf0e10cSrcweir void SwGlossaryDlg::ShowAutoText(const String& rGroup, const String& rShortName)
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir if(aExampleWIN.IsVisible())
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir SetResumeData(rGroup, rShortName);
1267cdf0e10cSrcweir //try to make an Undo()
1268cdf0e10cSrcweir pExampleFrame->ClearDocument( sal_True );
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir /* -----------------------------21.12.00 11:33--------------------------------
1272cdf0e10cSrcweir
1273cdf0e10cSrcweir ---------------------------------------------------------------------------*/
ResumeShowAutoText()1274cdf0e10cSrcweir void SwGlossaryDlg::ResumeShowAutoText()
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir String sGroup, sShortName;
1277cdf0e10cSrcweir if(GetResumeData(sGroup, sShortName) && aExampleWIN.IsVisible())
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir if(!_xAutoText.is())
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory >
1282cdf0e10cSrcweir xMgr = getProcessServiceFactory();
1283cdf0e10cSrcweir //now the AutoText ListBoxes have to be filled
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir uno::Reference< uno::XInterface > xAText = xMgr->createInstance( C2U("com.sun.star.text.AutoTextContainer") );
1286cdf0e10cSrcweir _xAutoText = uno::Reference< container::XNameAccess >(xAText, uno::UNO_QUERY);
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor();
1290cdf0e10cSrcweir if(xCrsr.is())
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir if(sShortName.Len())
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir uno::Any aGroup = _xAutoText->getByName(sGroup);
1295cdf0e10cSrcweir uno::Reference< XAutoTextGroup > xGroup;
1296cdf0e10cSrcweir OUString uShortName(sShortName);
1297cdf0e10cSrcweir if((aGroup >>= xGroup) && xGroup->hasByName(uShortName))
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir uno::Any aEntry(xGroup->getByName(uShortName));
1300cdf0e10cSrcweir uno::Reference< XAutoTextEntry > xEntry;
1301cdf0e10cSrcweir aEntry >>= xEntry;
1302cdf0e10cSrcweir uno::Reference< XTextRange > xRange(xCrsr, uno::UNO_QUERY);
1303cdf0e10cSrcweir xEntry->applyTo(xRange);
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir ResetResumeData();
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir
1311cdf0e10cSrcweir
1312