1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: glossary.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
39 #define _SVSTDARR_STRINGSDTOR
40 #define _SVSTDARR_STRINGS
41 #include <hintids.hxx>
43 #ifndef _MENU_HXX //autogen
44 #include <vcl/menu.hxx>
46 #ifndef _MSGBOX_HXX //autogen
47 #include <vcl/msgbox.hxx>
49 #ifndef _HELP_HXX //autogen
50 #include <vcl/help.hxx>
53 #include <svtools/svstdarr.hxx>
55 #include <svtools/stritem.hxx>
56 #include <svtools/pathoptions.hxx>
57 #include <svtools/lingucfg.hxx>
58 #include <sfx2/request.hxx>
59 #include <sfx2/fcontnr.hxx>
61 #include <svx/svxdlg.hxx>
62 #include <svx/dialogs.hrc>
63 #include <svx/acorrcfg.hxx>
64 #include <sfx2/viewfrm.hxx>
65 #include <unocrsr.hxx>
66 #include <unotools.hxx>
68 #include <comphelper/processfactory.hxx>
69 #include <ucbhelper/content.hxx>
70 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
71 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
72 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
73 #include <svtools/urihelper.hxx>
74 #include <unotools/charclass.hxx>
76 #include <swtypes.hxx>
84 #include <glossary.hxx>
85 #include <gloshdl.hxx>
86 #include <glosbib.hxx>
87 #include <initui.hxx> // fuer ::GetGlossaries()
88 #include <glosdoc.hxx>
89 #include <macassgn.hxx>
90 #include <swevent.hxx>
94 #include <shellio.hxx>
106 #include <globals.hrc>
111 #ifndef _GLOSSARY_HRC
112 #include <glossary.hrc>
114 #include <swmodule.hxx>
115 #include <sfx2/filedlghelper.hxx>
117 #define LONG_LENGTH 60
118 #define SHORT_LENGTH 30
121 using namespace ::com::sun::star
;
122 using namespace ::com::sun::star::lang
;
123 using namespace ::com::sun::star::uno
;
124 using namespace ::com::sun::star::text
;
125 using namespace ::com::sun::star::ucb
;
126 using namespace ::com::sun::star::ui::dialogs
;
127 using namespace ::comphelper
;
128 using namespace ::ucbhelper
;
129 using ::rtl::OUString
;
130 using namespace ::sfx2
;
132 String
lcl_GetValidShortCut( const String
& rName
)
134 const sal_uInt16 nSz
= rName
.Len();
139 sal_uInt16 nStart
= 1;
140 while( rName
.GetChar( nStart
-1 ) == ' ' && nStart
< nSz
)
143 String
aBuf( rName
.GetChar( nStart
-1 ));
145 for( ; nStart
< nSz
; ++nStart
)
147 if( rName
.GetChar( nStart
-1 ) == ' ' && rName
.GetChar( nStart
) != ' ')
148 aBuf
+= rName
.GetChar( nStart
);
153 /* -----------------------------08.02.00 10:28--------------------------------
155 ---------------------------------------------------------------------------*/
167 /*------------------------------------------------------------------------
168 Beschreibung: Dialog fuer neuen Bausteinnamen
169 ------------------------------------------------------------------------*/
170 class SwNewGlosNameDlg
: public ModalDialog
175 NoSpaceEdit aNewShort
;
177 CancelButton aCancel
;
185 DECL_LINK( Modify
, Edit
* );
186 DECL_LINK( Rename
, Button
* );
189 SwNewGlosNameDlg( Window
* pParent
,
190 const String
& rOldName
,
191 const String
& rOldShort
);
193 String
GetNewName() const { return aNewName
.GetText(); }
194 String
GetNewShort() const { return aNewShort
.GetText(); }
197 SwNewGlosNameDlg::SwNewGlosNameDlg(Window
* pParent
,
198 const String
& rOldName
,
199 const String
& rOldShort
) :
200 ModalDialog( pParent
, SW_RES( DLG_RENAME_GLOS
) ),
201 aNNFT (this, SW_RES( FT_NN
)),
202 aNewName(this, SW_RES( ED_NN
)),
203 aNSFT (this, SW_RES( FT_NS
)),
204 aNewShort(this,SW_RES( ED_NS
)),
205 aOk (this, SW_RES( BT_OKNEW
)),
206 aCancel (this, SW_RES( BT_CANCEL
)),
207 aFL (this, SW_RES( FL_NN
)),
208 aONFT (this, SW_RES( FT_ON
)),
209 aOldName(this, SW_RES( ED_ON
)),
210 aOSFT (this, SW_RES( FT_OS
)),
211 aOldShort(this,SW_RES( ED_OS
))
214 aOldName
.SetText( rOldName
);
215 aOldShort
.SetText( rOldShort
);
216 aNewShort
.SetMaxTextLen(SHORT_LENGTH
);
217 aNewName
.SetMaxTextLen(LONG_LENGTH
);
218 aNewName
.SetModifyHdl(LINK(this, SwNewGlosNameDlg
, Modify
));
219 aNewShort
.SetModifyHdl(LINK(this, SwNewGlosNameDlg
, Modify
));
220 aOk
.SetClickHdl(LINK(this, SwNewGlosNameDlg
, Rename
));
221 aNewName
.GrabFocus();
224 /*------------------------------------------------------------------------
225 Beschreibung: aktuell eingestellte Gruppe erfragen / setzen
226 ------------------------------------------------------------------------*/
228 String
SwGlossaryDlg::GetCurrGroup()
230 if( ::GetCurrGlosGroup() && ::GetCurrGlosGroup()->Len() )
231 return *(::GetCurrGlosGroup());
232 return SwGlossaries::GetDefName();
237 void SwGlossaryDlg::SetActGroup(const String
&rGrp
)
239 if( !::GetCurrGlosGroup() )
240 ::SetCurrGlosGroup( new String
);
241 *(::GetCurrGlosGroup()) = rGrp
;
246 SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame
* pViewFrame
,
247 SwGlossaryHdl
* pGlosHdl
, SwWrtShell
*pWrtShell
) :
249 SvxStandardDialog(&pViewFrame
->GetWindow(), SW_RES(DLG_GLOSSARY
)),
251 aInsertTipCB (this, SW_RES(CB_INSERT_TIP
)),
252 aNameLbl (this, SW_RES(FT_NAME
)),
253 aNameED (this, SW_RES(ED_NAME
)),
254 aShortNameLbl (this, SW_RES(FT_SHORTNAME
)),
255 aShortNameEdit(this, SW_RES(ED_SHORTNAME
)),
256 aCategoryBox (this, SW_RES(LB_BIB
)),
257 aRelativeFL (this, SW_RES(FL_RELATIVE
)),
258 aFileRelCB (this, SW_RES(CB_FILE_REL
)),
259 aNetRelCB (this, SW_RES(CB_NET_REL
)),
260 aExampleWIN (this, SW_RES(WIN_EXAMPLE
)),
261 aExampleDummyWIN(this, SW_RES(WIN_EXAMPLE_DUMMY
)),
262 aShowExampleCB(this, SW_RES(CB_SHOW_EXAMPLE
)),
263 aInsertBtn (this, SW_RES(PB_INSERT
)),
264 aCloseBtn (this, SW_RES(PB_CLOSE
)),
265 aHelpBtn (this, SW_RES(PB_HELP
)),
266 aEditBtn (this, SW_RES(PB_EDIT
)),
267 aBibBtn (this, SW_RES(PB_BIB
)),
268 aPathBtn (this, SW_RES(PB_PATH
)),
270 sReadonlyPath (SW_RES(ST_READONLY_PATH
)),
273 pMenu (new PopupMenu(SW_RES(MNU_EDIT
))),
274 pGlossaryHdl (pGlosHdl
),
278 bSelection( pWrtShell
->IsSelection() ),
279 bReadOnly( sal_False
),
281 bIsDocReadOnly(sal_False
),
285 SvtLinguConfig aLocalLinguConfig
;
287 // Static-Pointer initialisieren
288 if( !::GetCurrGlosGroup() )
289 ::SetCurrGlosGroup(new String
);//(SwGlossaries::GetDefName());
291 pMenu
->SetActivateHdl(LINK(this,SwGlossaryDlg
,EnableHdl
));
292 pMenu
->SetSelectHdl(LINK(this,SwGlossaryDlg
,MenuHdl
));
293 aEditBtn
.SetPopupMenu(pMenu
);
294 aEditBtn
.SetSelectHdl(LINK(this,SwGlossaryDlg
,EditHdl
));
295 aPathBtn
.SetClickHdl(LINK(this, SwGlossaryDlg
, PathHdl
));
297 aNameED
.SetModifyHdl(LINK(this,SwGlossaryDlg
,NameModify
));
298 aShortNameEdit
.SetModifyHdl(LINK(this,SwGlossaryDlg
,NameModify
));
300 aCategoryBox
.SetDoubleClickHdl(LINK(this,SwGlossaryDlg
, NameDoubleClick
));
301 aCategoryBox
.SetSelectHdl(LINK(this,SwGlossaryDlg
,GrpSelect
));
302 aBibBtn
.SetClickHdl(LINK(this,SwGlossaryDlg
,BibHdl
));
303 aShowExampleCB
.SetClickHdl(LINK(this, SwGlossaryDlg
, ShowPreviewHdl
));
305 aShortNameEdit
.SetMaxTextLen(SHORT_LENGTH
);
306 aNameED
.SetMaxTextLen(LONG_LENGTH
);
309 const SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
311 aShowExampleCB
.Check( pCfg
->IsAutoTextPreview());
312 ShowPreviewHdl(&aShowExampleCB
);
314 bIsDocReadOnly
= pSh
->GetView().GetDocShell()->IsReadOnly() ||
315 pSh
->HasReadonlySel();
317 aInsertBtn
.Enable(sal_False
);
319 aCategoryBox
.SetHelpId(HID_MD_GLOS_CATEGORY
);
320 aCategoryBox
.SetWindowBits(WB_HASBUTTONS
|WB_HASBUTTONSATROOT
|WB_HSCROLL
|WB_VSCROLL
|WB_CLIPCHILDREN
|WB_SORT
);
321 aCategoryBox
.GetModel()->SetSortMode(SortAscending
);
322 aCategoryBox
.SetHighlightRange(); // ueber volle Breite selektieren
323 aCategoryBox
.SetNodeDefaultImages( );
327 /*--------------------------------------------------------------------
329 --------------------------------------------------------------------*/
332 SwGlossaryDlg::~SwGlossaryDlg()
334 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
335 pCfg
->SetAutoTextPreview(aShowExampleCB
.IsChecked()) ;
337 aCategoryBox
.Clear();
338 aEditBtn
.SetPopupMenu(0);
340 delete pExampleFrame
;
342 /*------------------------------------------------------------------------
343 Beschreibung: Auswahl neue Gruppe
344 ------------------------------------------------------------------------*/
347 IMPL_LINK( SwGlossaryDlg
, GrpSelect
, SvTreeListBox
*, pBox
)
349 SvLBoxEntry
* pEntry
= pBox
->FirstSelected();
352 SvLBoxEntry
* pParent
= pBox
->GetParent(pEntry
) ? pBox
->GetParent(pEntry
) : pEntry
;
353 GroupUserData
* pGroupData
= (GroupUserData
*)pParent
->GetUserData();
354 String
*pGlosGroup
= ::GetCurrGlosGroup();
355 (*pGlosGroup
) = pGroupData
->sGroupName
;
356 (*pGlosGroup
) += GLOS_DELIM
;
357 (*pGlosGroup
) += String::CreateFromInt32(pGroupData
->nPathIdx
);
358 pGlossaryHdl
->SetCurGroup(*pGlosGroup
);
359 // Aktuellen Textbaustein setzen
360 bReadOnly
= pGlossaryHdl
->IsReadOnly();
361 EnableShortName( !bReadOnly
);
362 aEditBtn
.Enable(!bReadOnly
);
363 bIsOld
= pGlossaryHdl
->IsOld();
364 if( pParent
!= pEntry
)
366 String
aName(pBox
->GetEntryText(pEntry
));
367 aNameED
.SetText(aName
);
368 aShortNameEdit
.SetText(*(String
*)pEntry
->GetUserData());
369 pEntry
= pBox
->GetParent(pEntry
);
370 aInsertBtn
.Enable( !bIsDocReadOnly
);
371 ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit
.GetText());
374 ShowAutoText(aEmptyStr
, aEmptyStr
);
375 //Controls aktualisieren
376 NameModify(&aShortNameEdit
);
377 if( SfxRequest::HasMacroRecorder( pSh
->GetView().GetViewFrame() ) )
379 SfxRequest
aReq( pSh
->GetView().GetViewFrame(), FN_SET_ACT_GLOSSARY
);
380 String
sTemp(*::GetCurrGlosGroup());
381 // der nullte Pfad wird nicht aufgezeichnet!
382 if('0' == sTemp
.GetToken(1, GLOS_DELIM
).GetChar(0))
383 sTemp
= sTemp
.GetToken(0, GLOS_DELIM
);
384 aReq
.AppendItem(SfxStringItem(FN_SET_ACT_GLOSSARY
, sTemp
));
389 /*--------------------------------------------------------------------
391 --------------------------------------------------------------------*/
394 void SwGlossaryDlg::Apply()
396 const String
aGlosName(aShortNameEdit
.GetText());
397 if(aGlosName
.Len()) pGlossaryHdl
->InsertGlossary(aGlosName
);
398 if( SfxRequest::HasMacroRecorder( pSh
->GetView().GetViewFrame() ) )
400 SfxRequest
aReq( pSh
->GetView().GetViewFrame(), FN_INSERT_GLOSSARY
);
401 String
sTemp(*::GetCurrGlosGroup());
402 // der nullte Pfad wird nicht aufgezeichnet!
403 if('0' == sTemp
.GetToken(1, GLOS_DELIM
).GetChar(0))
404 sTemp
= sTemp
.GetToken(0, GLOS_DELIM
);
405 aReq
.AppendItem(SfxStringItem(FN_INSERT_GLOSSARY
, sTemp
));
406 aReq
.AppendItem(SfxStringItem(FN_PARAM_1
, aGlosName
));
410 /*--------------------------------------------------------------------
412 --------------------------------------------------------------------*/
413 /* inline */ void SwGlossaryDlg::EnableShortName(sal_Bool bOn
)
415 aShortNameLbl
.Enable(bOn
);
416 aShortNameEdit
.Enable(bOn
);
419 /* -----------------26.11.98 16:15-------------------
420 * existiert der Titel in der ausgewaehlten Gruppe?
421 * --------------------------------------------------*/
422 SvLBoxEntry
* SwGlossaryDlg::DoesBlockExist(const String
& rBlock
,
423 const String
& rShort
)
425 //evtl. vorhandenen Eintrag in der TreeListBox suchen
426 SvLBoxEntry
* pEntry
= aCategoryBox
.FirstSelected();
429 if(aCategoryBox
.GetParent(pEntry
))
430 pEntry
= aCategoryBox
.GetParent(pEntry
);
431 sal_uInt32 nChildCount
= aCategoryBox
.GetChildCount( pEntry
);
432 for(sal_uInt32 i
= 0; i
< nChildCount
; i
++)
434 SvLBoxEntry
* pChild
= aCategoryBox
.GetEntry( pEntry
, i
);
435 if(rBlock
== aCategoryBox
.GetEntryText(pChild
) &&
436 (!rShort
.Len() || rShort
== *(String
*)pChild
->GetUserData()))
445 /*--------------------------------------------------------------------
447 --------------------------------------------------------------------*/
450 IMPL_LINK( SwGlossaryDlg
, NameModify
, Edit
*, pEdit
)
452 String
aName(aNameED
.GetText());
453 sal_Bool bNameED
= pEdit
== &aNameED
;
457 aShortNameEdit
.SetText(aName
);
458 aInsertBtn
.Enable(sal_False
);
463 sShortSearch
= pEdit
->GetText();
464 sal_Bool bNotFound
= !DoesBlockExist(aName
, sShortSearch
);
467 // ist der Text durch einen Klick in die Listbox in das
471 aShortNameEdit
.SetText( lcl_GetValidShortCut( aName
) );
476 aShortNameEdit
.SetText(pGlossaryHdl
->GetGlossaryShortName(aName
));
477 EnableShortName(!bReadOnly
);
479 aInsertBtn
.Enable(!bNotFound
&& !bIsDocReadOnly
);
486 sal_Bool bEnable
= !bNotFound
;
487 bEnable
&= !bIsDocReadOnly
;
488 aInsertBtn
.Enable(bEnable
);
493 /*--------------------------------------------------------------------
495 --------------------------------------------------------------------*/
498 IMPL_LINK_INLINE_START( SwGlossaryDlg
, NameDoubleClick
, SvTreeListBox
*, pBox
)
500 SvLBoxEntry
* pEntry
= pBox
->FirstSelected();
501 if(pBox
->GetParent(pEntry
) && !bIsDocReadOnly
)
505 IMPL_LINK_INLINE_END( SwGlossaryDlg
, NameDoubleClick
, SvTreeListBox
*, EMPTYARG
)
506 /*--------------------------------------------------------------------
508 --------------------------------------------------------------------*/
511 IMPL_LINK( SwGlossaryDlg
, EnableHdl
, Menu
*, pMn
)
513 const String
aEditText(aNameED
.GetText());
514 const sal_Bool bHasEntry
= aEditText
.Len() && aShortNameEdit
.GetText().Len();
515 const sal_Bool bExists
= 0 != DoesBlockExist(aEditText
, aShortNameEdit
.GetText());
516 pMn
->EnableItem(FN_GL_DEFINE
, bSelection
&& bHasEntry
&& !bExists
);
517 pMn
->EnableItem(FN_GL_DEFINE_TEXT
, bSelection
&& bHasEntry
&& !bExists
);
518 pMn
->EnableItem(FN_GL_COPY_TO_CLIPBOARD
, bExists
);
519 pMn
->EnableItem(FN_GL_REPLACE
, bSelection
&& bExists
&& !bIsOld
);
520 pMn
->EnableItem(FN_GL_REPLACE_TEXT
, bSelection
&& bExists
&& !bIsOld
);
521 pMn
->EnableItem(FN_GL_EDIT
, bExists
);
522 pMn
->EnableItem(FN_GL_RENAME
, bExists
);
523 pMn
->EnableItem(FN_GL_DELETE
, bExists
);
524 pMn
->EnableItem(FN_GL_MACRO
, bExists
&& !bIsOld
&&
525 !pGlossaryHdl
->IsReadOnly() );
527 SvLBoxEntry
* pEntry
= aCategoryBox
.FirstSelected();
528 sal_Bool bEnable
= sal_False
;
530 bEnable
= !aCategoryBox
.GetParent( pEntry
) && !bIsOld
&& !pGlossaryHdl
->IsReadOnly();
531 pMn
->EnableItem( FN_GL_IMPORT
, bEnable
);
534 /*--------------------------------------------------------------------
536 --------------------------------------------------------------------*/
539 IMPL_LINK( SwGlossaryDlg
, MenuHdl
, Menu
*, pMn
)
541 sal_Bool bNoAttr
= sal_False
;
543 switch(pMn
->GetCurItemId())
546 case FN_GL_REPLACE_TEXT
:
547 pGlossaryHdl
->NewGlossary( aNameED
.GetText(),
548 aShortNameEdit
.GetText(),
550 pMn
->GetCurItemId() == FN_GL_REPLACE_TEXT
);
552 case FN_GL_DEFINE_TEXT
:
557 const String
aStr(aNameED
.GetText());
558 const String
aShortName(aShortNameEdit
.GetText());
559 if(pGlossaryHdl
->HasShortName(aShortName
))
561 InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME
)).Execute();
562 aShortNameEdit
.SetSelection(Selection(0, SELECTION_MAX
));
563 aShortNameEdit
.GrabFocus();
566 if(pGlossaryHdl
->NewGlossary(aStr
, aShortName
, sal_False
, bNoAttr
))
568 SvLBoxEntry
* pEntry
= aCategoryBox
.FirstSelected();
569 if(aCategoryBox
.GetParent(pEntry
))
570 pEntry
= aCategoryBox
.GetParent(pEntry
);
572 SvLBoxEntry
* pChild
= aCategoryBox
.InsertEntry(aStr
, pEntry
);
573 pChild
->SetUserData(new String(aShortName
));
574 aNameED
.SetText(aStr
);
575 aShortNameEdit
.SetText(aShortName
);
576 NameModify(&aNameED
); // fuer Schalten der Buttons
578 if( SfxRequest::HasMacroRecorder( pSh
->GetView().GetViewFrame() ) )
580 SfxRequest
aReq(pSh
->GetView().GetViewFrame(), FN_NEW_GLOSSARY
);
581 String
sTemp(*::GetCurrGlosGroup());
582 // der nullte Pfad wird nicht aufgezeichnet!
583 if('0' == sTemp
.GetToken(1, GLOS_DELIM
).GetChar(0))
584 sTemp
= sTemp
.GetToken(0, GLOS_DELIM
);
585 aReq
.AppendItem(SfxStringItem(FN_NEW_GLOSSARY
, sTemp
));
586 aReq
.AppendItem(SfxStringItem(FN_PARAM_1
, aShortName
));
587 aReq
.AppendItem(SfxStringItem(FN_PARAM_2
, aStr
));
593 case FN_GL_COPY_TO_CLIPBOARD
:
595 pGlossaryHdl
->CopyToClipboard(*pSh
, aShortNameEdit
.GetText());
602 aShortNameEdit
.SetText(pGlossaryHdl
->GetGlossaryShortName(aNameED
.GetText()));
603 SwNewGlosNameDlg
* pNewNameDlg
= new SwNewGlosNameDlg(this, aNameED
.GetText(),
604 aShortNameEdit
.GetText() );
605 if( RET_OK
== pNewNameDlg
->Execute() &&
606 pGlossaryHdl
->Rename( aShortNameEdit
.GetText(),
607 pNewNameDlg
->GetNewShort(),
608 pNewNameDlg
->GetNewName()))
610 SvLBoxEntry
* pEntry
= aCategoryBox
.FirstSelected();
611 SvLBoxEntry
* pNewEntry
= aCategoryBox
.InsertEntry(
612 pNewNameDlg
->GetNewName(), aCategoryBox
.GetParent(pEntry
));
613 pNewEntry
->SetUserData(new String(pNewNameDlg
->GetNewShort()));
614 delete (String
*)pEntry
->GetUserData();
615 aCategoryBox
.GetModel()->Remove(pEntry
);
616 aCategoryBox
.Select(pNewEntry
);
617 aCategoryBox
.MakeVisible(pNewEntry
);
619 GrpSelect( &aCategoryBox
);
625 QueryBox
aQuery(this, SW_RES(MSG_QUERY_DELETE
));
626 if(RET_YES
== aQuery
.Execute())
628 const String
aShortName(aShortNameEdit
.GetText());
629 const String
aTitle(aNameED
.GetText());
630 if(aTitle
.Len() && pGlossaryHdl
->DelGlossary(aShortName
))
632 SvLBoxEntry
* pChild
= DoesBlockExist(aTitle
, aShortName
);
633 DBG_ASSERT(pChild
, "Eintrag nicht gefunden!");
634 SvLBoxEntry
* pParent
= aCategoryBox
.GetParent(pChild
);
635 aCategoryBox
.Select(pParent
);
637 aCategoryBox
.GetModel()->Remove(pChild
);
638 aNameED
.SetText( aEmptyStr
);
639 NameModify(&aNameED
);
646 SfxItemSet
aSet( pSh
->GetAttrPool(), RES_FRMMACRO
, RES_FRMMACRO
, SID_EVENTCONFIG
, SID_EVENTCONFIG
, 0 );
648 SvxMacro
aStart(aEmptyStr
, aEmptyStr
, STARBASIC
);
649 SvxMacro
aEnd(aEmptyStr
, aEmptyStr
, STARBASIC
);
650 pGlossaryHdl
->GetMacros(aShortNameEdit
.GetText(), aStart
, aEnd
);
652 SvxMacroItem
aItem(RES_FRMMACRO
);
653 if( aStart
.GetMacName().Len() )
654 aItem
.SetMacro( SW_EVENT_START_INS_GLOSSARY
, aStart
);
655 if( aEnd
.GetMacName().Len() )
656 aItem
.SetMacro( SW_EVENT_END_INS_GLOSSARY
, aEnd
);
659 aSet
.Put( SwMacroAssignDlg::AddEvents( MACASSGN_TEXTBAUST
) );
661 const SfxPoolItem
* pItem
;
662 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
663 SfxAbstractDialog
* pMacroDlg
= pFact
->CreateSfxDialog( this, aSet
,
664 pSh
->GetView().GetViewFrame()->GetFrame()->GetFrameInterface(), SID_EVENTCONFIG
);
665 if ( pMacroDlg
&& pMacroDlg
->Execute() == RET_OK
&&
666 SFX_ITEM_SET
== pMacroDlg
->GetOutputItemSet()->GetItemState( RES_FRMMACRO
, sal_False
, &pItem
) )
668 const SvxMacroTableDtor
& rTbl
= ((SvxMacroItem
*)pItem
)->GetMacroTable();
669 pGlossaryHdl
->SetMacros( aShortNameEdit
.GetText(),
670 rTbl
.Get( SW_EVENT_START_INS_GLOSSARY
),
671 rTbl
.Get( SW_EVENT_END_INS_GLOSSARY
) );
680 // call the FileOpenDialog do find WinWord - Files with templates
681 FileDialogHelper
aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE
, 0 );
682 uno::Reference
< XFilePicker
> xFP
= aDlgHelper
.GetFilePicker();
684 SvtPathOptions aPathOpt
;
685 xFP
->setDisplayDirectory(aPathOpt
.GetWorkPath() );
686 String
sWW8( C2S( FILTER_WW8
) );
688 uno::Reference
<XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
689 SfxFilterMatcher
aMatcher( String::CreateFromAscii(SwDocShell::Factory().GetShortName()) );
690 SfxFilterMatcherIter
aIter( &aMatcher
);
691 const SfxFilter
* pFilter
= aIter
.First();
694 if( pFilter
->GetUserData() == sWW8
)
696 xFltMgr
->appendFilter( pFilter
->GetUIName(),
697 ((WildCard
&)pFilter
->GetWildcard()).GetWildCard() );
698 xFltMgr
->setCurrentFilter( pFilter
->GetUIName() ) ;
701 pFilter
= aIter
.Next();
704 if( aDlgHelper
.Execute() == ERRCODE_NONE
)
706 if( pGlossaryHdl
->ImportGlossaries( xFP
->getFiles().getConstArray()[0] ))
710 InfoBox(this, SW_RES( MSG_NO_GLOSSARIES
)).Execute();
721 /*--------------------------------------------------------------------
722 Beschreibung: Dialog Verwaltung Bereiche
723 --------------------------------------------------------------------*/
726 IMPL_LINK( SwGlossaryDlg
, BibHdl
, Button
*, EMPTYARG
)
728 SwGlossaries
* pGloss
= ::GetGlossaries();
729 if( pGloss
->IsGlosPathErr() )
733 //check if at least one glossary path is write enabled
734 SvtPathOptions aPathOpt
;
735 String
sGlosPath( aPathOpt
.GetAutoTextPath() );
736 USHORT nPaths
= sGlosPath
.GetTokenCount(';');
737 BOOL bIsWritable
= FALSE
;
738 for(USHORT nPath
= 0; nPath
< nPaths
; nPath
++)
740 String sPath
= URIHelper::SmartRel2Abs(
741 INetURLObject(), sGlosPath
.GetToken(nPath
, ';'),
742 URIHelper::GetMaybeFileHdl());
745 Content
aTestContent( sPath
,
746 uno::Reference
< XCommandEnvironment
>());
747 Any aAny
= aTestContent
.getPropertyValue( C2U("IsReadOnly") );
750 bIsWritable
= !*(sal_Bool
*)aAny
.getValue();
761 SwGlossaryGroupDlg
*pDlg
= new SwGlossaryGroupDlg( this, pGloss
->GetPathArray(), pGlossaryHdl
);
762 if ( RET_OK
== pDlg
->Execute() )
765 //if new groups were created - select one of them
766 String sNewGroup
= pDlg
->GetCreatedGroupName();
767 SvLBoxEntry
* pEntry
= aCategoryBox
.First();
768 while(sNewGroup
.Len() && pEntry
)
770 if(!aCategoryBox
.GetParent(pEntry
))
772 GroupUserData
* pGroupData
= (GroupUserData
*)pEntry
->GetUserData();
773 String sGroup
= pGroupData
->sGroupName
;
774 sGroup
+= GLOS_DELIM
;
775 sGroup
+= String::CreateFromInt32(pGroupData
->nPathIdx
);
776 if(sGroup
== sNewGroup
)
778 aCategoryBox
.Select(pEntry
);
779 aCategoryBox
.MakeVisible(pEntry
);
780 GrpSelect(&aCategoryBox
);
784 pEntry
= aCategoryBox
.Next(pEntry
);
792 QueryBox
aBox(this, WB_YES_NO
, sReadonlyPath
);
793 if(RET_YES
== aBox
.Execute())
800 /*------------------------------------------------------------------------
801 Beschreibung: Initialisierung; aus Ctor und nach Bearbeiten Bereiche
802 ------------------------------------------------------------------------*/
805 void SwGlossaryDlg::Init()
807 aCategoryBox
.SetUpdateMode( sal_False
);
808 aCategoryBox
.Clear();
809 // Textbausteinbereiche anzeigen
810 const sal_uInt16 nCnt
= pGlossaryHdl
->GetGroupCnt();
811 SvLBoxEntry
* pSelEntry
= 0;
812 const String
sSelStr(::GetCurrGlosGroup()->GetToken(0, GLOS_DELIM
));
813 const sal_uInt16 nSelPath
= static_cast< sal_uInt16
>(::GetCurrGlosGroup()->GetToken(1, GLOS_DELIM
).ToInt32());
814 for(sal_uInt16 nId
= 0; nId
< nCnt
; ++nId
)
817 String
sGroupName(pGlossaryHdl
->GetGroupName(nId
, &sTitle
));
818 if(!sGroupName
.Len())
821 sTitle
= sGroupName
.GetToken( 0, GLOS_DELIM
);
822 SvLBoxEntry
* pEntry
= aCategoryBox
.InsertEntry( sTitle
);
823 sal_uInt16 nPath
= static_cast< sal_uInt16
>(sGroupName
.GetToken( 1, GLOS_DELIM
).ToInt32());
825 GroupUserData
* pData
= new GroupUserData
;
826 pData
->sGroupName
= sGroupName
.GetToken(0, GLOS_DELIM
);
827 pData
->nPathIdx
= nPath
;
828 pData
->bReadonly
= pGlossaryHdl
->IsReadOnly(&sGroupName
);
830 pEntry
->SetUserData(pData
);
831 if(sSelStr
== pData
->sGroupName
&& nSelPath
== nPath
)
834 //Eintraege fuer die Gruppen auffuellen
836 pGlossaryHdl
->SetCurGroup(sGroupName
, sal_False
, sal_True
);
837 const sal_uInt16 nCount
= pGlossaryHdl
->GetGlossaryCnt();
838 for(sal_uInt16 i
= 0; i
< nCount
; ++i
)
840 String
sGroupTitle(pGlossaryHdl
->GetGlossaryName(i
));
841 SvLBoxEntry
* pChild
= aCategoryBox
.InsertEntry(
842 sGroupTitle
, pEntry
);
843 pChild
->SetUserData(new String(pGlossaryHdl
->GetGlossaryShortName(i
)));
847 // Aktuelle Gruppe setzen und Textbausteine anzeigen
850 //find a non-readonly group
851 SvLBoxEntry
* pSearch
= aCategoryBox
.First();
854 if(!aCategoryBox
.GetParent(pSearch
))
856 GroupUserData
* pData
= (GroupUserData
*)pSearch
->GetUserData();
857 if(!pData
->bReadonly
)
863 pSearch
= aCategoryBox
.Next(pSearch
);
866 pSelEntry
= aCategoryBox
.GetEntry(0);
870 aCategoryBox
.Expand(pSelEntry
);
871 aCategoryBox
.Select(pSelEntry
);
872 aCategoryBox
.MakeVisible(pSelEntry
);
873 GrpSelect(&aCategoryBox
);
875 //JP 16.11.99: the SvxTreeListBox has a Bug. The Box dont recalc the
876 // outputsize, when all entries are insertet. The result is, that
877 // the Focus/Highlight rectangle is to large and paintet over the
878 // HScrollbar. -> Fix: call the resize
879 aCategoryBox
.Resize();
881 aCategoryBox
.GetModel()->Resort();
882 aCategoryBox
.SetUpdateMode( sal_True
);
883 aCategoryBox
.Update();
885 const SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
886 aFileRelCB
.Check( pCfg
->IsSaveRelFile() );
887 aFileRelCB
.SetClickHdl(LINK(this, SwGlossaryDlg
, CheckBoxHdl
));
888 aNetRelCB
.Check( pCfg
->IsSaveRelNet() );
889 aNetRelCB
.SetClickHdl(LINK(this, SwGlossaryDlg
, CheckBoxHdl
));
890 aInsertTipCB
.Check( pCfg
->IsAutoTextTip() );
891 aInsertTipCB
.SetClickHdl(LINK(this, SwGlossaryDlg
, CheckBoxHdl
));
893 /*------------------------------------------------------------------------
895 ------------------------------------------------------------------------*/
898 IMPL_LINK_INLINE_START( SwGlossaryDlg
, EditHdl
, Button
*, EMPTYARG
)
900 //EndDialog darf nicht im MenuHdl aufgerufen werden
901 if(aEditBtn
.GetCurItemId() == FN_GL_EDIT
)
903 SwTextBlocks
*pGroup
= ::GetGlossaries()->GetGroupDoc ( GetCurrGrpName () );
904 BOOL bRet
= pGlossaryHdl
->ConvertToNew ( *pGroup
);
911 IMPL_LINK_INLINE_END( SwGlossaryDlg
, EditHdl
, Button
*, EMPTYARG
)
913 /*------------------------------------------------------------------------
914 Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces
915 ------------------------------------------------------------------------*/
917 IMPL_LINK( SwNewGlosNameDlg
, Modify
, Edit
*, pBox
)
919 String
aName(aNewName
.GetText());
920 SwGlossaryDlg
* pDlg
= (SwGlossaryDlg
*)GetParent();
922 if( pBox
== &aNewName
)
923 aNewShort
.SetText( lcl_GetValidShortCut( aName
) );
925 sal_Bool bEnable
= aName
.Len() && aNewShort
.GetText().Len() &&
926 (!pDlg
->DoesBlockExist(aName
, aNewShort
.GetText())
927 || aName
== aOldName
.GetText());
931 /*------------------------------------------------------------------------
933 ------------------------------------------------------------------------*/
935 IMPL_LINK( SwNewGlosNameDlg
, Rename
, Button
*, EMPTYARG
)
937 SwGlossaryDlg
* pDlg
= (SwGlossaryDlg
*)GetParent();
938 String sNew
= aNewShort
.GetText();
939 GetAppCharClass().toUpper(sNew
);
940 if( pDlg
->pGlossaryHdl
->HasShortName(aNewShort
.GetText())
941 && sNew
!= aOldShort
.GetText() )
943 InfoBox(this, SW_RES(MSG_DOUBLE_SHORTNAME
)).Execute();
944 aNewShort
.GrabFocus();
951 /*------------------------------------------------------------------------
953 ------------------------------------------------------------------------*/
955 IMPL_LINK( SwGlossaryDlg
, CheckBoxHdl
, CheckBox
*, pBox
)
957 SvxAutoCorrCfg
* pCfg
= SvxAutoCorrCfg::Get();
958 sal_Bool bCheck
= pBox
->IsChecked();
959 if( pBox
== &aInsertTipCB
)
960 pCfg
->SetAutoTextTip(bCheck
);
961 else if(pBox
== &aFileRelCB
)
962 pCfg
->SetSaveRelFile(bCheck
);
964 pCfg
->SetSaveRelNet(bCheck
);
968 /* -----------------26.11.98 15:18-------------------
969 * TreeListBox fuer Gruppen und Bausteine
970 * --------------------------------------------------*/
971 SwGlTreeListBox::SwGlTreeListBox(Window
* pParent
, const ResId
& rResId
) :
972 SvTreeListBox(pParent
, rResId
),
973 sReadonly (SW_RES(ST_READONLY
)),
977 SetDragDropMode( SV_DRAGDROP_CTRL_MOVE
|SV_DRAGDROP_CTRL_COPY
);
979 /* -----------------30.11.98 10:49-------------------
981 * --------------------------------------------------*/
982 void SwGlTreeListBox::Clear()
984 SvLBoxEntry
* pEntry
= First();
987 if(GetParent(pEntry
))
988 delete (String
*)pEntry
->GetUserData();
990 delete (GroupUserData
*)pEntry
->GetUserData();
991 pEntry
= Next(pEntry
);
993 SvTreeListBox::Clear();
996 /*-----------------10.06.97 14.52-------------------
998 --------------------------------------------------*/
999 void SwGlTreeListBox::RequestHelp( const HelpEvent
& rHEvt
)
1001 Point
aPos( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ));
1002 SvLBoxEntry
* pEntry
= GetEntry( aPos
);
1003 // Hilfe gibt es nur fuer die Gruppennamen
1007 SvLBoxItem
* pItem
= GetItem( pEntry
, aPos
.X(), &pTab
);
1010 aPos
= GetEntryPosition( pEntry
);
1011 Size
aSize(pItem
->GetSize( this, pEntry
));
1012 aPos
.X() = GetTabPos( pEntry
, pTab
);
1014 if((aPos
.X() + aSize
.Width()) > GetSizePixel().Width())
1015 aSize
.Width() = GetSizePixel().Width() - aPos
.X();
1016 aPos
= OutputToScreenPixel(aPos
);
1017 Rectangle
aItemRect( aPos
, aSize
);
1019 if(!GetParent(pEntry
))
1021 GroupUserData
* pData
= (GroupUserData
*)pEntry
->GetUserData();
1022 const SvStrings
* pPathArr
= ::GetGlossaries()->GetPathArray();
1023 if(pPathArr
->Count())
1025 sMsg
= (*(*pPathArr
)[pData
->nPathIdx
]);
1026 sMsg
+= INET_PATH_TOKEN
;
1027 sMsg
+= pData
->sGroupName
;
1028 sMsg
+= SwGlossaries::GetExtension();
1029 INetURLObject
aTmp(sMsg
);
1030 sMsg
= aTmp
.GetPath();
1032 if(pData
->bReadonly
)
1044 sMsg
= *(String
*)pEntry
->GetUserData();
1045 Help::ShowQuickHelp( this, aItemRect
, sMsg
,
1046 QUICKHELP_LEFT
|QUICKHELP_VCENTER
);
1050 /* -----------------26.11.98 14:42-------------------
1052 * --------------------------------------------------*/
1053 DragDropMode
SwGlTreeListBox::NotifyStartDrag(
1054 TransferDataContainer
& /*rContainer*/,
1055 SvLBoxEntry
* pEntry
)
1058 pDragEntry
= pEntry
;
1059 if(!GetParent(pEntry
))
1060 eRet
= SV_DRAGDROP_NONE
;
1063 SwGlossaryDlg
* pDlg
= (SwGlossaryDlg
*)Window::GetParent();
1064 SvLBoxEntry
* pParent
= GetParent(pEntry
);
1066 GroupUserData
* pGroupData
= (GroupUserData
*)pParent
->GetUserData();
1067 String
sEntry(pGroupData
->sGroupName
);
1068 sEntry
+= GLOS_DELIM
;
1069 sEntry
+= String::CreateFromInt32(pGroupData
->nPathIdx
);
1070 sal_Int8 nDragOption
= DND_ACTION_COPY
;
1071 eRet
= SV_DRAGDROP_CTRL_COPY
;
1072 if(!pDlg
->pGlossaryHdl
->IsReadOnly(&sEntry
))
1074 eRet
|= SV_DRAGDROP_CTRL_MOVE
;
1075 nDragOption
|= DND_ACTION_MOVE
;
1077 SetDragOptions( nDragOption
);
1081 /* -----------------27.11.98 09:35-------------------
1083 * --------------------------------------------------*/
1084 sal_Bool
SwGlTreeListBox::NotifyAcceptDrop( SvLBoxEntry
* pEntry
)
1086 // TODO: Readonly - Ueberpruefung fehlt noch!
1087 SvLBoxEntry
* pSrcParent
= GetParent(pEntry
) ? GetParent(pEntry
) : pEntry
;
1088 SvLBoxEntry
* pDestParent
=
1089 GetParent(pDragEntry
) ? GetParent(pDragEntry
) : pDragEntry
;
1090 return pDestParent
!= pSrcParent
;
1093 /* -----------------26.11.98 14:42-------------------
1095 * --------------------------------------------------*/
1096 sal_Bool
SwGlTreeListBox::NotifyMoving( SvLBoxEntry
* pTarget
,
1097 SvLBoxEntry
* pEntry
,
1098 SvLBoxEntry
*& /*rpNewParent*/,
1099 ULONG
& /*rNewChildPos*/
1103 if(!pTarget
) //An den Anfang verschieben
1105 pTarget
= GetEntry(0);
1107 // 1. wird in verschiedene Gruppen verschoben?
1108 // 2. darf in beiden Gruppen geschrieben werden?
1109 SvLBoxEntry
* pSrcParent
= GetParent(pEntry
);
1110 SvLBoxEntry
* pDestParent
=
1111 GetParent(pTarget
) ? GetParent(pTarget
) : pTarget
;
1112 sal_Bool bRet
= sal_False
;
1113 if(pDestParent
!= pSrcParent
)
1115 SwGlossaryDlg
* pDlg
= (SwGlossaryDlg
*)Window::GetParent();
1116 SwWait
aWait( *pDlg
->pSh
->GetView().GetDocShell(), sal_True
);
1118 GroupUserData
* pGroupData
= (GroupUserData
*)pSrcParent
->GetUserData();
1119 String
sSourceGroup(pGroupData
->sGroupName
);
1120 sSourceGroup
+= GLOS_DELIM
;
1121 sSourceGroup
+= String::CreateFromInt32(pGroupData
->nPathIdx
);
1122 pDlg
->pGlossaryHdl
->SetCurGroup(sSourceGroup
);
1123 String
sTitle(GetEntryText(pEntry
));
1124 String
sShortName(*(String
*)pEntry
->GetUserData());
1126 GroupUserData
* pDestData
= (GroupUserData
*)pDestParent
->GetUserData();
1127 String sDestName
= pDestData
->sGroupName
;
1128 sDestName
+= GLOS_DELIM
;
1129 sDestName
+= String::CreateFromInt32(pDestData
->nPathIdx
);
1130 bRet
= pDlg
->pGlossaryHdl
->CopyOrMove( sSourceGroup
, sShortName
,
1131 sDestName
, sTitle
, sal_True
);
1134 SvLBoxEntry
* pChild
= InsertEntry(sTitle
, pDestParent
);
1135 pChild
->SetUserData(new String(sShortName
));
1136 GetModel()->Remove(pEntry
);
1139 return sal_False
; //sonst wird der Eintrag automatisch vorgenommen
1141 /* -----------------26.11.98 14:42-------------------
1143 * --------------------------------------------------*/
1144 sal_Bool
SwGlTreeListBox::NotifyCopying( SvLBoxEntry
* pTarget
,
1145 SvLBoxEntry
* pEntry
,
1146 SvLBoxEntry
*& /*rpNewParent*/,
1147 ULONG
& /*rNewChildPos*/
1151 // 1. wird in verschiedene Gruppen verschoben?
1152 // 2. darf in beiden Gruppen geschrieben werden?
1153 if(!pTarget
) //An den Anfang verschieben
1155 pTarget
= GetEntry(0);
1157 SvLBoxEntry
* pSrcParent
= GetParent(pEntry
);
1158 SvLBoxEntry
* pDestParent
=
1159 GetParent(pTarget
) ? GetParent(pTarget
) : pTarget
;
1160 sal_Bool bRet
= sal_False
;
1161 if(pDestParent
!= pSrcParent
)
1163 SwGlossaryDlg
* pDlg
= (SwGlossaryDlg
*)Window::GetParent();
1164 SwWait
aWait( *pDlg
->pSh
->GetView().GetDocShell(), sal_True
);
1166 GroupUserData
* pGroupData
= (GroupUserData
*)pSrcParent
->GetUserData();
1167 String
sSourceGroup(pGroupData
->sGroupName
);
1168 sSourceGroup
+= GLOS_DELIM
;
1169 sSourceGroup
+= String::CreateFromInt32(pGroupData
->nPathIdx
);
1171 pDlg
->pGlossaryHdl
->SetCurGroup(sSourceGroup
);
1172 String
sTitle(GetEntryText(pEntry
));
1173 String
sShortName(*(String
*)pEntry
->GetUserData());
1175 GroupUserData
* pDestData
= (GroupUserData
*)pDestParent
->GetUserData();
1176 String sDestName
= pDestData
->sGroupName
;
1177 sDestName
+= GLOS_DELIM
;
1178 sDestName
+= String::CreateFromInt32(pDestData
->nPathIdx
);
1180 bRet
= pDlg
->pGlossaryHdl
->CopyOrMove( sSourceGroup
, sShortName
,
1181 sDestName
, sTitle
, sal_False
);
1184 SvLBoxEntry
* pChild
= InsertEntry(sTitle
, pDestParent
);
1185 pChild
->SetUserData(new String(sShortName
));
1188 return sal_False
; //sonst wird der Eintrag automatisch vorgenommen
1192 /*-----------------10.06.97 15.18-------------------
1194 --------------------------------------------------*/
1195 String
SwGlossaryDlg::GetCurrGrpName() const
1197 SvLBoxEntry
* pEntry
= aCategoryBox
.FirstSelected();
1202 aCategoryBox
.GetParent(pEntry
) ? aCategoryBox
.GetParent(pEntry
) : pEntry
;
1203 GroupUserData
* pGroupData
= (GroupUserData
*)pEntry
->GetUserData();
1204 sRet
= pGroupData
->sGroupName
;
1206 sRet
+= String::CreateFromInt32(pGroupData
->nPathIdx
);
1211 /*-----------------11.06.97 08.17-------------------
1213 --------------------------------------------------*/
1214 IMPL_LINK( SwGlossaryDlg
, PathHdl
, Button
*, pBtn
)
1216 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1219 AbstractSvxMultiPathDialog
* pDlg
= pFact
->CreateSvxMultiPathDialog( pBtn
, RID_SVXDLG_MULTIPATH
);
1220 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1221 SvtPathOptions aPathOpt
;
1222 String
sGlosPath( aPathOpt
.GetAutoTextPath() );
1223 pDlg
->SetPath(sGlosPath
);
1224 if(RET_OK
== pDlg
->Execute())
1226 String
sTmp(pDlg
->GetPath());
1227 if(sTmp
!= sGlosPath
)
1229 aPathOpt
.SetAutoTextPath( sTmp
);
1230 ::GetGlossaries()->UpdateGlosPath( sal_True
);
1238 /* -----------------28.07.99 13:48-------------------
1240 --------------------------------------------------*/
1241 IMPL_LINK( SwGlossaryDlg
, ShowPreviewHdl
, CheckBox
*, pBox
)
1243 sal_Bool bCreated
= sal_False
;
1244 if(pBox
->IsChecked())
1249 Link
aLink(LINK(this, SwGlossaryDlg
, PreviewLoadedHdl
));
1250 pExampleFrame
= new SwOneExampleFrame( aExampleWIN
,
1251 EX_SHOW_ONLINE_LAYOUT
, &aLink
);
1252 bCreated
= sal_True
;
1256 BOOL bShow
= pBox
->IsChecked() && !bCreated
;
1257 aExampleWIN
.Show( bShow
);
1258 aExampleDummyWIN
.Show(!bShow
);
1259 if( ::GetCurrGlosGroup() )
1260 ShowAutoText(*::GetCurrGlosGroup(), aShortNameEdit
.GetText());
1264 /* -----------------18.11.99 17:09-------------------
1266 --------------------------------------------------*/
1267 IMPL_LINK( SwGlossaryDlg
, PreviewLoadedHdl
, void *, EMPTYARG
)
1269 BOOL bShow
= aShowExampleCB
.IsChecked();
1270 aExampleWIN
.Show( bShow
);
1271 aExampleDummyWIN
.Show(!bShow
);
1272 ResumeShowAutoText();
1276 /* -----------------28.07.99 16:28-------------------
1278 --------------------------------------------------*/
1279 void SwGlossaryDlg::ShowAutoText(const String
& rGroup
, const String
& rShortName
)
1281 if(aExampleWIN
.IsVisible())
1283 SetResumeData(rGroup
, rShortName
);
1284 //try to make an Undo()
1285 pExampleFrame
->ClearDocument( TRUE
);
1288 /* -----------------------------21.12.00 11:33--------------------------------
1290 ---------------------------------------------------------------------------*/
1291 void SwGlossaryDlg::ResumeShowAutoText()
1293 String sGroup
, sShortName
;
1294 if(GetResumeData(sGroup
, sShortName
) && aExampleWIN
.IsVisible())
1296 if(!_xAutoText
.is())
1298 uno::Reference
< lang::XMultiServiceFactory
>
1299 xMgr
= getProcessServiceFactory();
1300 //now the AutoText ListBoxes have to be filled
1302 uno::Reference
< uno::XInterface
> xAText
= xMgr
->createInstance( C2U("com.sun.star.text.AutoTextContainer") );
1303 _xAutoText
= uno::Reference
< container::XNameAccess
>(xAText
, uno::UNO_QUERY
);
1306 uno::Reference
< XTextCursor
> & xCrsr
= pExampleFrame
->GetTextCursor();
1309 if(sShortName
.Len())
1311 uno::Any aGroup
= _xAutoText
->getByName(sGroup
);
1312 uno::Reference
< XAutoTextGroup
> xGroup
;
1313 OUString
uShortName(sShortName
);
1314 if((aGroup
>>= xGroup
) && xGroup
->hasByName(uShortName
))
1316 uno::Any
aEntry(xGroup
->getByName(uShortName
));
1317 uno::Reference
< XAutoTextEntry
> xEntry
;
1319 uno::Reference
< XTextRange
> xRange(xCrsr
, uno::UNO_QUERY
);
1320 xEntry
->applyTo(xRange
);