1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #define _SVSTDARR_STRINGS 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <tools/stream.hxx> 39*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 40*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #include <vcl/help.hxx> 43*cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx> 44*cdf0e10cSrcweir #include <unotools/tempfile.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 47*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 48*cdf0e10cSrcweir #include <swtypes.hxx> 49*cdf0e10cSrcweir #include <glosbib.hxx> 50*cdf0e10cSrcweir #include <gloshdl.hxx> 51*cdf0e10cSrcweir #include <actctrl.hxx> 52*cdf0e10cSrcweir #include <glossary.hxx> 53*cdf0e10cSrcweir #include <glosdoc.hxx> 54*cdf0e10cSrcweir #include <swunohelper.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #ifndef _GLOSBIB_HRC 57*cdf0e10cSrcweir #include <glosbib.hrc> 58*cdf0e10cSrcweir #endif 59*cdf0e10cSrcweir #ifndef _MISC_HRC 60*cdf0e10cSrcweir #include <misc.hrc> 61*cdf0e10cSrcweir #endif 62*cdf0e10cSrcweir #ifndef _HELPID_H 63*cdf0e10cSrcweir #include <helpid.h> 64*cdf0e10cSrcweir #endif 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir #define PATH_CASE_SENSITIVE 0x01 68*cdf0e10cSrcweir #define PATH_READONLY 0x02 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #define RENAME_TOKEN_DELIM (sal_Unicode)1 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir /*-----------------09.06.97 13:05------------------- 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir --------------------------------------------------*/ 75*cdf0e10cSrcweir SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent, 76*cdf0e10cSrcweir const SvStrings* pPathArr, 77*cdf0e10cSrcweir SwGlossaryHdl *pHdl) : 78*cdf0e10cSrcweir SvxStandardDialog(pParent, SW_RES(DLG_BIB_BASE)), 79*cdf0e10cSrcweir aBibFT( this, SW_RES(FT_BIB)), 80*cdf0e10cSrcweir aNameED( this, SW_RES(ED_NAME)), 81*cdf0e10cSrcweir aPathFT( this, SW_RES(FT_PATH)), 82*cdf0e10cSrcweir aPathLB( this, SW_RES(LB_PATH)), 83*cdf0e10cSrcweir aSelectFT( this, SW_RES(FT_SELECT)), 84*cdf0e10cSrcweir aGroupTLB( this, SW_RES(TLB_GROUPS)), 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir aOkPB( this, SW_RES(BT_OK)), 87*cdf0e10cSrcweir aCancelPB( this, SW_RES(BT_CANCEL)), 88*cdf0e10cSrcweir aHelpPB( this, SW_RES(BT_HELP)), 89*cdf0e10cSrcweir aNewPB( this, SW_RES(PB_NEW)), 90*cdf0e10cSrcweir aDelPB( this, SW_RES(PB_DELETE)), 91*cdf0e10cSrcweir aRenamePB( this, SW_RES(PB_RENAME)), 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir pRemovedArr(0), 94*cdf0e10cSrcweir pInsertedArr(0), 95*cdf0e10cSrcweir pRenamedArr(0), 96*cdf0e10cSrcweir pGlosHdl(pHdl) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_uInt16 i; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir FreeResource(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir long nTabs[] = 103*cdf0e10cSrcweir { 2, // Number of Tabs 104*cdf0e10cSrcweir 0, 160 105*cdf0e10cSrcweir }; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir aGroupTLB.SetHelpId(HID_GLOS_GROUP_TREE); 108*cdf0e10cSrcweir aGroupTLB.SetTabs( &nTabs[0], MAP_APPFONT ); 109*cdf0e10cSrcweir aGroupTLB.SetStyle(aGroupTLB.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN|WB_SORT); 110*cdf0e10cSrcweir aGroupTLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, SelectHdl)); 111*cdf0e10cSrcweir aGroupTLB.GetModel()->SetSortMode(SortAscending); 112*cdf0e10cSrcweir aNewPB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, NewHdl)); 113*cdf0e10cSrcweir aDelPB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, DeleteHdl)); 114*cdf0e10cSrcweir aNameED.SetModifyHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl)); 115*cdf0e10cSrcweir aPathLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl)); 116*cdf0e10cSrcweir aRenamePB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, RenameHdl)); 117*cdf0e10cSrcweir for( i = 0; i < pPathArr->Count(); i++) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir String sPath(*(*pPathArr)[i]); 120*cdf0e10cSrcweir INetURLObject aTempURL(sPath); 121*cdf0e10cSrcweir sPath = aTempURL.GetMainURL(INetURLObject::DECODE_WITH_CHARSET ); 122*cdf0e10cSrcweir aPathLB.InsertEntry(sPath); 123*cdf0e10cSrcweir sal_uLong nCaseReadonly = 0; 124*cdf0e10cSrcweir utl::TempFile aTempFile(&sPath); 125*cdf0e10cSrcweir aTempFile.EnableKillingFile(); 126*cdf0e10cSrcweir if(!aTempFile.IsValid()) 127*cdf0e10cSrcweir nCaseReadonly |= PATH_READONLY; 128*cdf0e10cSrcweir else if( SWUnoHelper::UCB_IsCaseSensitiveFileName( aTempFile.GetURL())) 129*cdf0e10cSrcweir nCaseReadonly |= PATH_CASE_SENSITIVE; 130*cdf0e10cSrcweir aPathLB.SetEntryData(i, (void*)nCaseReadonly); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir aPathLB.SelectEntryPos(0); 133*cdf0e10cSrcweir aPathLB.Enable(sal_True); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir const sal_uInt16 nCount = pHdl->GetGroupCnt(); 136*cdf0e10cSrcweir for(i = 0; i < nCount; ++i) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir String sTitle; 139*cdf0e10cSrcweir String sGroup = pHdl->GetGroupName(i, &sTitle); 140*cdf0e10cSrcweir if(!sGroup.Len()) 141*cdf0e10cSrcweir continue; 142*cdf0e10cSrcweir GlosBibUserData* pData = new GlosBibUserData; 143*cdf0e10cSrcweir pData->sGroupName = sGroup; 144*cdf0e10cSrcweir pData->sGroupTitle = sTitle; 145*cdf0e10cSrcweir String sTemp(sTitle); 146*cdf0e10cSrcweir //sGroup.GetToken(0, GLOS_DELIM) 147*cdf0e10cSrcweir sTemp += '\t'; 148*cdf0e10cSrcweir pData->sPath = aPathLB.GetEntry((sal_uInt16)sGroup.GetToken(1, GLOS_DELIM).ToInt32()); 149*cdf0e10cSrcweir sTemp += pData->sPath; 150*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.InsertEntry(sTemp); 151*cdf0e10cSrcweir pEntry->SetUserData(pData); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir aGroupTLB.GetModel()->Resort(); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir /*-----------------09.06.97 13:05------------------- 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir --------------------------------------------------*/ 160*cdf0e10cSrcweir SwGlossaryGroupDlg::~SwGlossaryGroupDlg() 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir if(pInsertedArr) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir pInsertedArr->DeleteAndDestroy(0, pInsertedArr->Count()); 166*cdf0e10cSrcweir delete pInsertedArr; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir if(pRemovedArr) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir pRemovedArr->DeleteAndDestroy(0, pRemovedArr->Count()); 171*cdf0e10cSrcweir delete pRemovedArr; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir if(pRenamedArr) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir pRenamedArr->DeleteAndDestroy(0, pRenamedArr->Count()); 176*cdf0e10cSrcweir delete pRenamedArr; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /*-----------------09.06.97 13:11------------------- 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir --------------------------------------------------*/ 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void __EXPORT SwGlossaryGroupDlg::Apply() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if(aNewPB.IsEnabled()) 188*cdf0e10cSrcweir NewHdl(&aNewPB); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir String aActGroup = SwGlossaryDlg::GetCurrGroup(); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if(pRemovedArr && pRemovedArr->Count()) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir sal_uInt16 nCount = pRemovedArr->Count(); 195*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir const String* pDelEntry = (*pRemovedArr)[i]; 198*cdf0e10cSrcweir const String sDelGroup = pDelEntry->GetToken(0, '\t'); 199*cdf0e10cSrcweir if( sDelGroup == aActGroup ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir //soll die aktuelle Gruppe geloescht werden, muss die akt. Gruppe 202*cdf0e10cSrcweir //umgesetzt werden 203*cdf0e10cSrcweir if(aGroupTLB.GetEntryCount()) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir SvLBoxEntry* pFirst = aGroupTLB.First(); 206*cdf0e10cSrcweir GlosBibUserData* pUserData = (GlosBibUserData*)pFirst->GetUserData(); 207*cdf0e10cSrcweir pGlosHdl->SetCurGroup(pUserData->sGroupName); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir String sMsg(SW_RES(STR_QUERY_DELETE_GROUP1)); 211*cdf0e10cSrcweir String sTitle(pDelEntry->GetToken(1, '\t')); 212*cdf0e10cSrcweir if(sTitle.Len()) 213*cdf0e10cSrcweir sMsg += sTitle; 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir sDelGroup.GetToken(1, GLOS_DELIM); 216*cdf0e10cSrcweir sMsg += SW_RESSTR(STR_QUERY_DELETE_GROUP2); 217*cdf0e10cSrcweir QueryBox aQuery(this->GetParent(), WB_YES_NO|WB_DEF_NO, sMsg ); 218*cdf0e10cSrcweir if(RET_YES == aQuery.Execute()) 219*cdf0e10cSrcweir pGlosHdl->DelGroup( sDelGroup ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir //erst umbenennen, falls es schon eins gab 224*cdf0e10cSrcweir if(pRenamedArr && pRenamedArr->Count()) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir sal_uInt16 nCount = pRenamedArr->Count(); 227*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir String * pEntry = (*pRenamedArr)[i]; 230*cdf0e10cSrcweir xub_StrLen nStrSttPos = 0; 231*cdf0e10cSrcweir String sOld( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos ) ); 232*cdf0e10cSrcweir String sNew( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) ); 233*cdf0e10cSrcweir String sTitle( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) ); 234*cdf0e10cSrcweir pGlosHdl->RenameGroup(sOld, sNew, sTitle); 235*cdf0e10cSrcweir if(!i) 236*cdf0e10cSrcweir sCreatedGroup = sNew; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir if(pInsertedArr && pInsertedArr->Count()) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir sal_uInt16 nCount = pInsertedArr->Count(); 242*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir String sNewGroup = *(*pInsertedArr)[i]; 245*cdf0e10cSrcweir String sNewTitle = sNewGroup.GetToken(0, GLOS_DELIM); 246*cdf0e10cSrcweir if( *(*pInsertedArr)[i] != aActGroup ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir pGlosHdl->NewGroup(sNewGroup, sNewTitle); 249*cdf0e10cSrcweir if(!sCreatedGroup.Len()) 250*cdf0e10cSrcweir sCreatedGroup = sNewGroup; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir /*-----------------09.06.97 13:12------------------- 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir --------------------------------------------------*/ 258*cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, SelectHdl, SvTabListBox*, EMPTYARG ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir aNewPB.Enable(sal_False); 261*cdf0e10cSrcweir SvLBoxEntry* pFirstEntry = aGroupTLB.FirstSelected(); 262*cdf0e10cSrcweir if(pFirstEntry) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir GlosBibUserData* pUserData = (GlosBibUserData*)pFirstEntry->GetUserData(); 265*cdf0e10cSrcweir String sEntry(pUserData->sGroupName); 266*cdf0e10cSrcweir String sName(aNameED.GetText()); 267*cdf0e10cSrcweir sal_Bool bExists = sal_False; 268*cdf0e10cSrcweir sal_uLong nPos = aGroupTLB.GetEntryPos(sName, 0); 269*cdf0e10cSrcweir if( 0xffffffff > nPos) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.GetEntry(nPos); 272*cdf0e10cSrcweir GlosBibUserData* pFoundData = (GlosBibUserData*)pEntry->GetUserData(); 273*cdf0e10cSrcweir String sGroup = pFoundData->sGroupName; 274*cdf0e10cSrcweir bExists = sGroup == sEntry; 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir aRenamePB.Enable(!bExists && sName.Len()); 278*cdf0e10cSrcweir aDelPB.Enable(IsDeleteAllowed(sEntry)); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir return 0; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir /*-----------------09.06.97 13:22------------------- 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir --------------------------------------------------*/ 286*cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, NewHdl, Button*, EMPTYARG ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir String sGroup(aNameED.GetText()); 289*cdf0e10cSrcweir // sGroup.ToLower(); 290*cdf0e10cSrcweir sGroup += GLOS_DELIM; 291*cdf0e10cSrcweir sGroup += String::CreateFromInt32(aPathLB.GetSelectEntryPos()); 292*cdf0e10cSrcweir DBG_ASSERT(!pGlosHdl->FindGroupName(sGroup), "Gruppe bereits vorhanden!"); 293*cdf0e10cSrcweir if(!pInsertedArr) 294*cdf0e10cSrcweir pInsertedArr = new SvStrings; 295*cdf0e10cSrcweir pInsertedArr->Insert(new String(sGroup), pInsertedArr->Count()); 296*cdf0e10cSrcweir String sTemp(aNameED.GetText()); 297*cdf0e10cSrcweir // sTemp.ToLower(); 298*cdf0e10cSrcweir sTemp += '\t'; 299*cdf0e10cSrcweir sTemp += aPathLB.GetSelectEntry(); 300*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.InsertEntry(sTemp); 301*cdf0e10cSrcweir GlosBibUserData* pData = new GlosBibUserData; 302*cdf0e10cSrcweir pData->sPath = aPathLB.GetSelectEntry(); 303*cdf0e10cSrcweir pData->sGroupName = sGroup; 304*cdf0e10cSrcweir pData->sGroupTitle = aNameED.GetText(); 305*cdf0e10cSrcweir pEntry->SetUserData(pData); 306*cdf0e10cSrcweir aGroupTLB.Select(pEntry); 307*cdf0e10cSrcweir aGroupTLB.MakeVisible(pEntry); 308*cdf0e10cSrcweir aGroupTLB.GetModel()->Resort(); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir return 0; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir /*-----------------09.06.97 13:22------------------- 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir --------------------------------------------------*/ 315*cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton ) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.FirstSelected(); 318*cdf0e10cSrcweir if(!pEntry) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir pButton->Enable(sal_False); 321*cdf0e10cSrcweir return 0; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData(); 324*cdf0e10cSrcweir String sEntry(pUserData->sGroupName); 325*cdf0e10cSrcweir // befindet sich der zu loeschende Name schon unter den 326*cdf0e10cSrcweir // den neuen - dann weg damit 327*cdf0e10cSrcweir sal_Bool bDelete = sal_True; 328*cdf0e10cSrcweir if(pInsertedArr && pInsertedArr->Count()) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir sal_uInt16 nCount = pInsertedArr->Count(); 331*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir const String* pTemp = (*pInsertedArr)[i]; 334*cdf0e10cSrcweir if(*pTemp == sEntry) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir pInsertedArr->Remove(i); 337*cdf0e10cSrcweir bDelete = sal_False; 338*cdf0e10cSrcweir break; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir // moeglicherweise sollte es schon umbenannt werden? 344*cdf0e10cSrcweir if(bDelete) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir if(pRenamedArr && pRenamedArr->Count()) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir sal_uInt16 nCount = pRenamedArr->Count(); 349*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir const String* pTemp = (*pRenamedArr)[i]; 352*cdf0e10cSrcweir String sTemp( pTemp->GetToken(0, RENAME_TOKEN_DELIM )); 353*cdf0e10cSrcweir if(sTemp == sEntry) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir pRenamedArr->Remove(i); 356*cdf0e10cSrcweir bDelete = sal_False; 357*cdf0e10cSrcweir break; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir if(bDelete) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir if(!pRemovedArr) 365*cdf0e10cSrcweir pRemovedArr = new SvStrings; 366*cdf0e10cSrcweir String sGroupEntry(pUserData->sGroupName); 367*cdf0e10cSrcweir sGroupEntry += '\t'; 368*cdf0e10cSrcweir sGroupEntry += pUserData->sGroupTitle; 369*cdf0e10cSrcweir pRemovedArr->Insert(new String(sGroupEntry), pRemovedArr->Count()); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir delete pUserData; 372*cdf0e10cSrcweir aGroupTLB.GetModel()->Remove(pEntry); 373*cdf0e10cSrcweir if(!aGroupTLB.First()) 374*cdf0e10cSrcweir pButton->Enable(sal_False); 375*cdf0e10cSrcweir //the content must be deleted - otherwise the new handler would be called in Apply() 376*cdf0e10cSrcweir aNameED.SetText(aEmptyStr); 377*cdf0e10cSrcweir return 0; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir /* -----------------23.11.98 12:26------------------- 381*cdf0e10cSrcweir * 382*cdf0e10cSrcweir * --------------------------------------------------*/ 383*cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, RenameHdl, Button *, EMPTYARG ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.FirstSelected(); 386*cdf0e10cSrcweir GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData(); 387*cdf0e10cSrcweir String sEntryText(aGroupTLB.GetEntryText(pEntry)); 388*cdf0e10cSrcweir String sEntry(pUserData->sGroupName); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir String sNewName(aNameED.GetText()); 391*cdf0e10cSrcweir String sNewTitle(sNewName); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir sNewName += GLOS_DELIM; 394*cdf0e10cSrcweir sNewName += String::CreateFromInt32(aPathLB.GetSelectEntryPos()); 395*cdf0e10cSrcweir DBG_ASSERT(!pGlosHdl->FindGroupName(sNewName), "Gruppe bereits vorhanden!"); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // befindet sich der umzubenennende Name unter den 398*cdf0e10cSrcweir // den neuen - dann austauschen 399*cdf0e10cSrcweir sal_Bool bDone = sal_False; 400*cdf0e10cSrcweir if(pInsertedArr && pInsertedArr->Count()) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir sal_uInt16 nCount = pInsertedArr->Count(); 403*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir const String* pTemp = (*pInsertedArr)[i]; 406*cdf0e10cSrcweir if(*pTemp == sEntry) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir pInsertedArr->Remove(i); 409*cdf0e10cSrcweir pInsertedArr->Insert(new String(sNewName), pInsertedArr->Count()); 410*cdf0e10cSrcweir bDone = sal_True; 411*cdf0e10cSrcweir break; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir if(!bDone) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir if(!pRenamedArr) 418*cdf0e10cSrcweir pRenamedArr = new SvStrings; 419*cdf0e10cSrcweir sEntry += RENAME_TOKEN_DELIM; 420*cdf0e10cSrcweir sEntry += sNewName; 421*cdf0e10cSrcweir sEntry += RENAME_TOKEN_DELIM; 422*cdf0e10cSrcweir sEntry += sNewTitle; 423*cdf0e10cSrcweir pRenamedArr->Insert(new String(sEntry), pRenamedArr->Count()); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir delete (GlosBibUserData*)pEntry->GetUserData(); 426*cdf0e10cSrcweir aGroupTLB.GetModel()->Remove(pEntry); 427*cdf0e10cSrcweir String sTemp(aNameED.GetText()); 428*cdf0e10cSrcweir // sTemp.ToLower(); 429*cdf0e10cSrcweir sTemp += '\t'; 430*cdf0e10cSrcweir sTemp += aPathLB.GetSelectEntry(); 431*cdf0e10cSrcweir pEntry = aGroupTLB.InsertEntry(sTemp); 432*cdf0e10cSrcweir GlosBibUserData* pData = new GlosBibUserData; 433*cdf0e10cSrcweir pData->sPath = aPathLB.GetSelectEntry(); 434*cdf0e10cSrcweir pData->sGroupName = sNewName; 435*cdf0e10cSrcweir pData->sGroupTitle = sNewTitle; 436*cdf0e10cSrcweir pEntry->SetUserData(pData); 437*cdf0e10cSrcweir aGroupTLB.Select(pEntry); 438*cdf0e10cSrcweir aGroupTLB.MakeVisible(pEntry); 439*cdf0e10cSrcweir aGroupTLB.GetModel()->Resort(); 440*cdf0e10cSrcweir return 0; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir /*-----------------09.06.97 13:42------------------- 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir --------------------------------------------------*/ 445*cdf0e10cSrcweir IMPL_LINK( SwGlossaryGroupDlg, ModifyHdl, Edit*, EMPTYARG ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir String sEntry(aNameED.GetText()); 448*cdf0e10cSrcweir // sEntry.ToLower(); 449*cdf0e10cSrcweir sal_Bool bEnableNew = sal_True; 450*cdf0e10cSrcweir sal_Bool bEnableDel = sal_False; 451*cdf0e10cSrcweir sal_uLong nCaseReadonly = 452*cdf0e10cSrcweir (sal_uLong)aPathLB.GetEntryData(aPathLB.GetSelectEntryPos()); 453*cdf0e10cSrcweir sal_Bool bDirReadonly = 0 != (nCaseReadonly&PATH_READONLY); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir if(!sEntry.Len() || bDirReadonly) 456*cdf0e10cSrcweir bEnableNew = sal_False; 457*cdf0e10cSrcweir else if(sEntry.Len()) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir sal_uLong nPos = 0xffffffff; 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir nPos = aGroupTLB.GetEntryPos(sEntry, 0); 463*cdf0e10cSrcweir //ist es nicht case sensitive muss man selbst suchen 464*cdf0e10cSrcweir if( 0xffffffff == nPos) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); 467*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < aGroupTLB.GetEntryCount(); i++) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir String sTemp = aGroupTLB.GetEntryText( i, 0 ); 470*cdf0e10cSrcweir nCaseReadonly = (sal_uLong)aPathLB.GetEntryData( 471*cdf0e10cSrcweir aPathLB.GetEntryPos(aGroupTLB.GetEntryText(i,1))); 472*cdf0e10cSrcweir sal_Bool bCase = 0 != (nCaseReadonly & PATH_CASE_SENSITIVE); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if( !bCase && rSCmp.isEqual( sTemp, sEntry )) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir nPos = i; 477*cdf0e10cSrcweir break; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir if( 0xffffffff > nPos) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir bEnableNew = sal_False; 484*cdf0e10cSrcweir aGroupTLB.Select(aGroupTLB.GetEntry( nPos )); 485*cdf0e10cSrcweir aGroupTLB.MakeVisible(aGroupTLB.GetEntry( nPos )); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir SvLBoxEntry* pEntry = aGroupTLB.FirstSelected(); 489*cdf0e10cSrcweir if(pEntry) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir GlosBibUserData* pUserData = (GlosBibUserData*)pEntry->GetUserData(); 492*cdf0e10cSrcweir bEnableDel = IsDeleteAllowed(pUserData->sGroupName); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir // String sGroup = aGroupTLB.GetEntryText(pEntry, 0); 495*cdf0e10cSrcweir // sGroup += GLOS_DELIM; 496*cdf0e10cSrcweir // sGroup += String::CreateFromInt32(aPathLB.GetEntryPos(aGroupTLB.GetEntryText(pEntry, 1))); 497*cdf0e10cSrcweir // bEnableDel = IsDeleteAllowed(sGroup); 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir aDelPB.Enable(bEnableDel); 501*cdf0e10cSrcweir aNewPB.Enable(bEnableNew); 502*cdf0e10cSrcweir aRenamePB.Enable(bEnableNew && pEntry); 503*cdf0e10cSrcweir return 0; 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir /*------------------------------------------------------------------------ 507*cdf0e10cSrcweir Beschreibung: 508*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir sal_Bool SwGlossaryGroupDlg::IsDeleteAllowed(const String &rGroup) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir sal_Bool bDel = (!pGlosHdl->IsReadOnly(&rGroup)); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // OM: befindet sich der Name unter den den neuen Bereichsnamen, 515*cdf0e10cSrcweir // dann ist er auch loeschbar! Bei noch nicht existenten Bereichsnamen 516*cdf0e10cSrcweir // liefert ReadOnly naemlich sal_True. 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir if(pInsertedArr && pInsertedArr->Count()) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir sal_uInt16 nCount = pInsertedArr->Count(); 521*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir const String* pTemp = (*pInsertedArr)[i]; 524*cdf0e10cSrcweir if(*pTemp == rGroup) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir bDel = sal_True; 527*cdf0e10cSrcweir break; 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir return bDel; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir /*-----------------18.07.97 19:06------------------- 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir --------------------------------------------------*/ 538*cdf0e10cSrcweir void FEdit::KeyInput( const KeyEvent& rKEvent ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir KeyCode aCode = rKEvent.GetKeyCode(); 541*cdf0e10cSrcweir if( KEYGROUP_CURSOR == aCode.GetGroup() || 542*cdf0e10cSrcweir ( KEYGROUP_MISC == aCode.GetGroup() && 543*cdf0e10cSrcweir KEY_DELETE >= aCode.GetCode() ) || 544*cdf0e10cSrcweir SVT_SEARCHPATH_DELIMITER != rKEvent.GetCharCode() ) 545*cdf0e10cSrcweir Edit::KeyInput( rKEvent ); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir /* -----------------------------08.02.00 15:07-------------------------------- 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 550*cdf0e10cSrcweir void SwGlossaryGroupTLB::RequestHelp( const HelpEvent& rHEvt ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); 553*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( aPos ); 554*cdf0e10cSrcweir if(pEntry) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir SvLBoxTab* pTab; 557*cdf0e10cSrcweir SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); 558*cdf0e10cSrcweir if(pItem) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir aPos = GetEntryPosition( pEntry ); 561*cdf0e10cSrcweir Size aSize(pItem->GetSize( this, pEntry )); 562*cdf0e10cSrcweir aPos.X() = GetTabPos( pEntry, pTab ); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir if((aPos.X() + aSize.Width()) > GetSizePixel().Width()) 565*cdf0e10cSrcweir aSize.Width() = GetSizePixel().Width() - aPos.X(); 566*cdf0e10cSrcweir aPos = OutputToScreenPixel(aPos); 567*cdf0e10cSrcweir Rectangle aItemRect( aPos, aSize ); 568*cdf0e10cSrcweir String sMsg; 569*cdf0e10cSrcweir GlosBibUserData* pData = (GlosBibUserData*)pEntry->GetUserData(); 570*cdf0e10cSrcweir sMsg = pData->sPath; 571*cdf0e10cSrcweir sMsg += INET_PATH_TOKEN; 572*cdf0e10cSrcweir sMsg += pData->sGroupName.GetToken(0, GLOS_DELIM); 573*cdf0e10cSrcweir sMsg += SwGlossaries::GetExtension(); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir Help::ShowQuickHelp( this, aItemRect, sMsg, 576*cdf0e10cSrcweir QUICKHELP_LEFT|QUICKHELP_VCENTER ); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580