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