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 #ifdef SW_DLLIMPLEMENTATION 27 #undef SW_DLLIMPLEMENTATION 28 #endif 29 30 31 #include <vcl/waitobj.hxx> 32 #include <rtl/ustring.hxx> 33 #include <com/sun/star/uno/Sequence.h> 34 #include <swtypes.hxx> 35 #include <wrtsh.hxx> 36 #include <initui.hxx> 37 #include <labimp.hxx> 38 #include <labfmt.hxx> 39 #include <labprt.hxx> 40 #include <unotools.hxx> 41 #ifndef _DBMGR_HXX 42 #include <dbmgr.hxx> 43 #endif 44 #include "uitool.hxx" 45 #ifndef _CMDID_H 46 #include <cmdid.h> 47 #endif 48 #ifndef _HELPID_H 49 #include <helpid.h> 50 #endif 51 #ifndef _GLOBALS_HRC 52 #include <globals.hrc> 53 #endif 54 #ifndef _LABEL_HRC 55 #include <label.hrc> 56 #endif 57 58 //impl in envimg.cxx 59 extern SW_DLLPUBLIC String MakeSender(); 60 61 62 SV_IMPL_PTRARR( SwLabRecs, SwLabRec* ); 63 64 void SwLabRec::SetFromItem( const SwLabItem& rItem ) 65 { 66 lHDist = rItem.lHDist; 67 lVDist = rItem.lVDist; 68 lWidth = rItem.lWidth; 69 lHeight = rItem.lHeight; 70 lLeft = rItem.lLeft; 71 lUpper = rItem.lUpper; 72 nCols = rItem.nCols; 73 nRows = rItem.nRows; 74 lPaperWidth = rItem.lPaperWidth; 75 lPaperHeight = rItem.lPaperHeight; 76 bCont = rItem.bCont; 77 } 78 79 void SwLabRec::FillItem( SwLabItem& rItem ) const 80 { 81 rItem.lHDist = lHDist; 82 rItem.lVDist = lVDist; 83 rItem.lWidth = lWidth; 84 rItem.lHeight = lHeight; 85 rItem.lLeft = lLeft; 86 rItem.lUpper = lUpper; 87 rItem.nCols = nCols; 88 rItem.nRows = nRows; 89 rItem.lPaperWidth = lPaperWidth; 90 rItem.lPaperHeight = lPaperHeight; 91 } 92 93 // -------------------------------------------------------------------------- 94 void SwLabDlg::_ReplaceGroup( const String &rMake ) 95 { 96 //Die alten Eintraege vernichten. 97 pRecs->Remove( 1, pRecs->Count() - 1 ); 98 aLabelsCfg.FillLabels(rtl::OUString(rMake), *pRecs); 99 aLstGroup = rMake; 100 } 101 102 // -------------------------------------------------------------------------- 103 104 105 106 void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) 107 { 108 if (nId == TP_LAB_LAB) 109 { 110 if(m_bLabel) 111 { 112 ((SwLabPage*)&rPage)->SetNewDBMgr(pNewDBMgr); 113 ((SwLabPage*)&rPage)->InitDatabaseBox(); 114 } 115 else 116 ((SwLabPage*)&rPage)->SetToBusinessCard(); 117 } 118 else if (nId == TP_LAB_PRT) 119 pPrtPage = (SwLabPrtPage*)&rPage; 120 } 121 122 // -------------------------------------------------------------------------- 123 124 125 126 SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet, 127 SwNewDBMgr* pDBMgr, sal_Bool bLabel) : 128 SfxTabDialog( pParent, SW_RES(DLG_LAB), &rSet, sal_False ), 129 pNewDBMgr(pDBMgr), 130 pPrtPage(0), 131 132 aTypeIds( 50, 10 ), 133 aMakes ( 5, 0 ), 134 135 pRecs ( new SwLabRecs() ), 136 sBusinessCardDlg(SW_RES(ST_BUSINESSCARDDLG)), 137 sFormat(SW_RES(ST_FIRSTPAGE_LAB)), 138 sMedium(SW_RES(ST_FIRSTPAGE_BC)), 139 m_bLabel(bLabel) 140 { 141 WaitObject aWait( pParent ); 142 143 FreeResource(); 144 145 GetOKButton().SetText(String(SW_RES(STR_BTN_NEW_DOC))); 146 GetOKButton().SetHelpId(HID_LABEL_INSERT); 147 GetOKButton().SetHelpText(aEmptyStr); // Damit generierter Hilfetext verwendet wird 148 149 AddTabPage(TP_LAB_LAB, m_bLabel ? sFormat : sMedium ,SwLabPage ::Create, 0, sal_False, 0); 150 AddTabPage(TP_VISITING_CARDS, SwVisitingCardPage::Create, 0); 151 AddTabPage(TP_LAB_FMT, SwLabFmtPage::Create, 0); 152 AddTabPage(TP_LAB_PRT, SwLabPrtPage::Create, 0); 153 AddTabPage(TP_BUSINESS_DATA, SwBusinessDataPage::Create, 0 ); 154 AddTabPage(TP_PRIVATE_DATA, SwPrivateDataPage::Create, 0); 155 156 157 if(m_bLabel) 158 { 159 RemoveTabPage(TP_BUSINESS_DATA); 160 RemoveTabPage(TP_PRIVATE_DATA); 161 RemoveTabPage(TP_VISITING_CARDS); 162 } 163 else 164 { 165 SetText(sBusinessCardDlg); 166 } 167 // Benutzer-Etikette aus writer.cfg lesen 168 SwLabItem aItem((const SwLabItem&)rSet.Get( FN_LABEL )); 169 SwLabRec* pRec = new SwLabRec; 170 const String aTmp( SW_RES( STR_CUSTOM ) ); 171 pRec->aMake = pRec->aType = aTmp; 172 pRec->SetFromItem( aItem ); 173 174 sal_Bool bDouble = sal_False; 175 176 for (sal_uInt16 nRecPos = 0; nRecPos < pRecs->Count(); nRecPos++) 177 { 178 if (pRec->aMake == pRecs->GetObject(nRecPos)->aMake && 179 pRec->aType == pRecs->GetObject(nRecPos)->aType) 180 { 181 bDouble = sal_True; 182 break; 183 } 184 } 185 186 if (!bDouble) 187 pRecs->C40_INSERT( SwLabRec, pRec, 0 ); 188 else 189 delete pRec; 190 191 sal_uInt16 nLstGroup = 0; 192 const UNO_NMSPC::Sequence<rtl::OUString>& rMan = aLabelsCfg.GetManufacturers(); 193 const rtl::OUString* pMan = rMan.getConstArray(); 194 for(sal_Int32 nMan = 0; nMan < rMan.getLength(); nMan++) 195 { 196 aMakes.Insert( new String(pMan[nMan]), aMakes.Count() ); 197 if ( pMan[nMan] == aItem.aLstMake ) 198 nLstGroup = (sal_uInt16) nMan; 199 } 200 201 if ( aMakes.Count() ) 202 _ReplaceGroup( *aMakes[nLstGroup] ); 203 if (pExampleSet) 204 pExampleSet->Put(aItem); 205 } 206 207 // -------------------------------------------------------------------------- 208 209 SwLabDlg::~SwLabDlg() 210 { 211 delete pRecs; 212 } 213 // -------------------------------------------------------------------------- 214 215 void SwLabDlg::GetLabItem(SwLabItem &rItem) 216 { 217 const SwLabItem& rActItem = (const SwLabItem&)GetExampleSet()->Get(FN_LABEL); 218 const SwLabItem& rOldItem = (const SwLabItem&)GetInputSetImpl()->Get(FN_LABEL); 219 220 if (rActItem != rOldItem) 221 { // Wurde schon mal mit (hoffentlich) korrektem Inhalt "geputtet" 222 rItem = rActItem; 223 } 224 else 225 { 226 rItem = rOldItem; 227 228 // Im rItem stehen (vom Namen mal abgesehen) immer nur die 229 // benutzerdefinierbaren Einstellungen. Daher richtige Werte 230 // direkt aus dem Record besorgen: 231 SwLabRec* pRec = GetRecord(rItem.aType, rItem.bCont); 232 pRec->FillItem( rItem ); 233 } 234 } 235 236 // -------------------------------------------------------------------------- 237 238 SwLabRec* SwLabDlg::GetRecord(const String &rRecName, sal_Bool bCont) 239 { 240 SwLabRec* pRec = NULL; 241 sal_Bool bFound = sal_False; 242 String sCustom(SW_RES(STR_CUSTOM)); 243 244 const sal_uInt16 nCount = Recs().Count(); 245 for (sal_uInt16 i = 0; i < nCount; i++) 246 { 247 pRec = Recs()[i]; 248 if (pRec->aType != sCustom && 249 rRecName == pRec->aType && bCont == pRec->bCont) 250 { 251 bFound = sal_True; 252 break; 253 } 254 } 255 if (!bFound) // Benutzerdefiniert 256 pRec = Recs()[0]; 257 258 return(pRec); 259 } 260 261 // -------------------------------------------------------------------------- 262 263 Printer *SwLabDlg::GetPrt() 264 { 265 if (pPrtPage) 266 return (pPrtPage->GetPrt()); 267 else 268 return (NULL); 269 } 270 271 // -------------------------------------------------------------------------- 272 SwLabPage::SwLabPage(Window* pParent, const SfxItemSet& rSet) : 273 SfxTabPage(pParent, SW_RES(TP_LAB_LAB), rSet), 274 pNewDBMgr(NULL), 275 aItem ((const SwLabItem&) rSet.Get(FN_LABEL)), 276 277 aWritingFL (this, SW_RES(FL_WRITING)), 278 aWritingText (this, SW_RES(TXT_WRITING)), 279 aAddrBox (this, SW_RES(BOX_ADDR )), 280 aWritingEdit (this, SW_RES(EDT_WRITING)), 281 aDatabaseFT (this, SW_RES(FT_DATABASE)), 282 aDatabaseLB (this, SW_RES(LB_DATABASE)), 283 aTableFT (this, SW_RES(FT_TABLE )), 284 aTableLB (this, SW_RES(LB_TABLE )), 285 aInsertBT (this, SW_RES(BTN_INSERT )), 286 aDBFieldFT (this, SW_RES(FT_DBFIELD )), 287 aDBFieldLB (this, SW_RES(LB_DBFIELD )), 288 aFormatFL (this, SW_RES(FL_FORMAT )), 289 aContButton (this, SW_RES(BTN_CONT )), 290 aSheetButton (this, SW_RES(BTN_SHEET )), 291 aMakeText (this, SW_RES(TXT_MAKE )), 292 aMakeBox (this, SW_RES(BOX_MAKE )), 293 aTypeText (this, SW_RES(TXT_TYPE )), 294 aTypeBox (this, SW_RES(BOX_TYPE )), 295 aHiddenSortTypeBox(this, WB_SORT|WB_HIDE), 296 aFormatInfo (this, SW_RES(INF_FORMAT )) 297 { 298 WaitObject aWait( pParent ); 299 300 FreeResource(); 301 SetExchangeSupport(); 302 303 304 // Handler installieren 305 aAddrBox .SetClickHdl (LINK(this, SwLabPage, AddrHdl )); 306 aDatabaseLB .SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl )); 307 aTableLB .SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl )); 308 aInsertBT .SetClickHdl (LINK(this, SwLabPage, FieldHdl )); 309 aContButton .SetClickHdl (LINK(this, SwLabPage, PageHdl )); 310 aSheetButton .SetClickHdl (LINK(this, SwLabPage, PageHdl )); 311 aMakeBox .SetSelectHdl(LINK(this, SwLabPage, MakeHdl )); 312 aTypeBox .SetSelectHdl(LINK(this, SwLabPage, TypeHdl )); 313 314 InitDatabaseBox(); 315 316 sal_uInt16 nLstGroup = 0; 317 318 const sal_uInt16 nCount = (sal_uInt16)GetParent()->Makes().Count(); 319 for (sal_uInt16 i = 0; i < nCount; ++i) 320 { 321 String &rStr = *GetParent()->Makes()[i]; 322 aMakeBox.InsertEntry( rStr ); 323 if ( rStr == String(aItem.aLstMake) ) 324 nLstGroup = i; 325 } 326 // Reset(rSet); 327 aMakeBox.SelectEntryPos( nLstGroup ); 328 aMakeBox.GetSelectHdl().Call( &aMakeBox ); 329 } 330 331 // -------------------------------------------------------------------------- 332 333 334 335 SwLabPage::~SwLabPage() 336 { 337 } 338 /* -----------------29.09.99 09:08------------------- 339 340 --------------------------------------------------*/ 341 void lcl_ChgYPos(Window& rWin, long nDiff) 342 { 343 Point aTempPos(rWin.GetPosPixel()); 344 aTempPos.Y() += nDiff; 345 rWin.SetPosPixel(aTempPos); 346 } 347 348 void SwLabPage::SetToBusinessCard() 349 { 350 SetHelpId(HID_BUSINESS_FMT_PAGE); 351 aContButton.SetHelpId(HID_BUSINESS_FMT_PAGE_CONT); 352 aSheetButton.SetHelpId(HID_BUSINESS_FMT_PAGE_SHEET); 353 aMakeBox.SetHelpId(HID_BUSINESS_FMT_PAGE_BRAND); 354 aTypeBox.SetHelpId(HID_BUSINESS_FMT_PAGE_TYPE); 355 m_bLabel = sal_False; 356 aWritingText.Hide(); 357 aAddrBox.Hide(); 358 aWritingEdit.Hide(); 359 aDatabaseFT.Hide(); 360 aDatabaseLB.Hide(); 361 aTableFT.Hide(); 362 aTableLB.Hide(); 363 aInsertBT.Hide(); 364 aDBFieldFT.Hide(); 365 aDBFieldLB.Hide(); 366 aWritingFL.Hide(); 367 368 //resize the form 369 Point aFLPos(aWritingFL.GetPosPixel()); 370 long nDiffPos = aFormatFL.GetPosPixel().Y() - aFLPos.Y(); 371 Size aFLSz(aFormatFL.GetSizePixel()); 372 // aFLSz.Height() += nDiffPos; 373 aFormatFL.SetPosSizePixel(aFLPos, aFLSz); 374 375 // move all controls up 376 lcl_ChgYPos(aContButton, -nDiffPos); 377 lcl_ChgYPos(aSheetButton, -nDiffPos); 378 lcl_ChgYPos(aMakeText, -nDiffPos); 379 380 lcl_ChgYPos(aTypeText, -nDiffPos); 381 lcl_ChgYPos(aFormatInfo, -nDiffPos); 382 383 Size aTmpSz(3, 3); 384 aTmpSz = LogicToPixel(aTmpSz, MAP_APPFONT); 385 386 lcl_ChgYPos(aMakeBox, - nDiffPos); 387 Point aLBPos(aMakeBox.GetPosPixel()); 388 aLBPos.Y() += aMakeBox.GetSizePixel().Height() + aTmpSz.Height(); 389 aTypeBox.SetPosPixel(aLBPos); 390 }; 391 392 // -------------------------------------------------------------------------- 393 394 395 IMPL_LINK( SwLabPage, AddrHdl, Button *, EMPTYARG ) 396 { 397 String aWriting; 398 if ( aAddrBox.IsChecked() ) 399 aWriting = MakeSender(); 400 aWritingEdit.SetText( aWriting.ConvertLineEnd() ); 401 aWritingEdit.GrabFocus(); 402 return 0; 403 } 404 405 // -------------------------------------------------------------------------- 406 407 408 409 IMPL_LINK( SwLabPage, DatabaseHdl, ListBox *, pListBox ) 410 { 411 sActDBName = aDatabaseLB.GetSelectEntry(); 412 413 WaitObject aObj( GetParent() ); 414 415 if (pListBox == &aDatabaseLB) 416 GetNewDBMgr()->GetTableNames(&aTableLB, sActDBName); 417 GetNewDBMgr()->GetColumnNames(&aDBFieldLB, sActDBName, aTableLB.GetSelectEntry()); 418 return 0; 419 } 420 421 422 423 IMPL_LINK( SwLabPage, FieldHdl, Button *, EMPTYARG ) 424 { 425 String aStr ( '<' ); 426 aStr += aDatabaseLB.GetSelectEntry(); 427 aStr += '.'; 428 aStr += aTableLB.GetSelectEntry(); 429 aStr += '.'; 430 aStr += aTableLB.GetEntryData(aTableLB.GetSelectEntryPos()) == 0 ? '0' : '1'; 431 aStr += '.'; 432 aStr += aDBFieldLB.GetSelectEntry(); 433 aStr += '>'; 434 aWritingEdit.ReplaceSelected(aStr); 435 Selection aSel = aWritingEdit.GetSelection(); 436 aWritingEdit.GrabFocus(); 437 aWritingEdit.SetSelection(aSel); 438 return 0; 439 } 440 441 // -------------------------------------------------------------------------- 442 443 444 445 IMPL_LINK_INLINE_START( SwLabPage, PageHdl, Button *, EMPTYARG ) 446 { 447 aMakeBox.GetSelectHdl().Call( &aMakeBox ); 448 return 0; 449 } 450 IMPL_LINK_INLINE_END( SwLabPage, PageHdl, Button *, EMPTYARG ) 451 452 // -------------------------------------------------------------------------- 453 454 455 456 IMPL_LINK( SwLabPage, MakeHdl, ListBox *, EMPTYARG ) 457 { 458 WaitObject aWait( GetParent() ); 459 460 aTypeBox.Clear(); 461 aHiddenSortTypeBox.Clear(); 462 GetParent()->TypeIds().Remove( 0, GetParent()->TypeIds().Count() ); 463 464 const String aMake = aMakeBox.GetSelectEntry(); 465 GetParent()->ReplaceGroup( aMake ); 466 aItem.aLstMake = aMake; 467 468 const sal_Bool bCont = aContButton.IsChecked(); 469 const sal_uInt16 nCount = GetParent()->Recs().Count(); 470 sal_uInt16 nLstType = 0; 471 472 const String sCustom(SW_RES(STR_CUSTOM)); 473 //insert the entries into the sorted list box 474 for ( sal_uInt16 i = 0; i < nCount; ++i ) 475 { 476 const String aType ( GetParent()->Recs()[i]->aType ); 477 sal_Bool bInsert = sal_False; 478 if ( GetParent()->Recs()[i]->aType == sCustom ) 479 { 480 bInsert = sal_True; 481 aTypeBox.InsertEntry(aType ); 482 } 483 else if ( GetParent()->Recs()[i]->bCont == bCont ) 484 { 485 if ( aHiddenSortTypeBox.GetEntryPos(aType) == LISTBOX_ENTRY_NOTFOUND ) 486 { 487 bInsert = sal_True; 488 aHiddenSortTypeBox.InsertEntry( aType ); 489 } 490 } 491 if(bInsert) 492 { 493 GetParent()->TypeIds().Insert(i, GetParent()->TypeIds().Count()); 494 if ( !nLstType && aType == String(aItem.aLstType) ) 495 nLstType = GetParent()->TypeIds().Count(); 496 } 497 } 498 for(sal_uInt16 nEntry = 0; nEntry < aHiddenSortTypeBox.GetEntryCount(); nEntry++) 499 { 500 aTypeBox.InsertEntry(aHiddenSortTypeBox.GetEntry(nEntry)); 501 } 502 if (nLstType) 503 aTypeBox.SelectEntry(aItem.aLstType); 504 else 505 aTypeBox.SelectEntryPos(0); 506 aTypeBox.GetSelectHdl().Call( &aTypeBox ); 507 return 0; 508 } 509 510 // -------------------------------------------------------------------------- 511 512 513 514 IMPL_LINK_INLINE_START( SwLabPage, TypeHdl, ListBox *, EMPTYARG ) 515 { 516 DisplayFormat(); 517 aItem.aType = aTypeBox.GetSelectEntry(); 518 return 0; 519 } 520 IMPL_LINK_INLINE_END( SwLabPage, TypeHdl, ListBox *, EMPTYARG ) 521 522 // -------------------------------------------------------------------------- 523 524 525 526 void SwLabPage::DisplayFormat() 527 { 528 MetricField aField(this, WinBits(0)); 529 FieldUnit aMetric = ::GetDfltMetric(sal_False); 530 SetMetric(aField, aMetric); 531 aField.SetDecimalDigits(2); 532 aField.SetMin (0); 533 aField.SetMax (LONG_MAX); 534 535 SwLabRec* pRec = GetSelectedEntryPos(); 536 aItem.aLstType = pRec->aType; 537 SETFLDVAL(aField, pRec->lWidth); 538 aField.Reformat(); 539 const String aWString = aField.GetText(); 540 541 SETFLDVAL(aField, pRec->lHeight); 542 aField.Reformat(); 543 544 String aText = pRec->aType; 545 aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": ")); 546 aText += aWString; 547 aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x ")); 548 aText += aField.GetText(); 549 aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" (")); 550 aText += String::CreateFromInt32( pRec->nCols ); 551 aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" x ")); 552 aText += String::CreateFromInt32( pRec->nRows ); 553 aText += ')'; 554 aFormatInfo.SetText(aText); 555 } 556 557 // -------------------------------------------------------------------------- 558 559 SwLabRec* SwLabPage::GetSelectedEntryPos() 560 { 561 String sSelEntry(aTypeBox.GetSelectEntry()); 562 563 return GetParent()->GetRecord(sSelEntry, aContButton.IsChecked()); 564 } 565 566 // -------------------------------------------------------------------------- 567 568 569 570 void SwLabPage::InitDatabaseBox() 571 { 572 if( GetNewDBMgr() ) 573 { 574 aDatabaseLB.Clear(); 575 UNO_NMSPC::Sequence<rtl::OUString> aDataNames = SwNewDBMgr::GetExistingDatabaseNames(); 576 const rtl::OUString* pDataNames = aDataNames.getConstArray(); 577 for (long i = 0; i < aDataNames.getLength(); i++) 578 aDatabaseLB.InsertEntry(pDataNames[i]); 579 String sDBName = sActDBName.GetToken( 0, DB_DELIM ); 580 String sTableName = sActDBName.GetToken( 1, DB_DELIM ); 581 aDatabaseLB.SelectEntry(sDBName); 582 if( sDBName.Len() && GetNewDBMgr()->GetTableNames(&aTableLB, sDBName)) 583 { 584 aTableLB.SelectEntry(sTableName); 585 GetNewDBMgr()->GetColumnNames(&aDBFieldLB, sActDBName, sTableName); 586 } 587 else 588 aDBFieldLB.Clear(); 589 } 590 } 591 592 // -------------------------------------------------------------------------- 593 SfxTabPage* SwLabPage::Create(Window* pParent, const SfxItemSet& rSet) 594 { 595 return new SwLabPage(pParent, rSet); 596 } 597 598 // -------------------------------------------------------------------------- 599 void SwLabPage::ActivatePage(const SfxItemSet& rSet) 600 { 601 Reset( rSet ); 602 } 603 // -------------------------------------------------------------------------- 604 int SwLabPage::DeactivatePage(SfxItemSet* _pSet) 605 { 606 if (_pSet) 607 FillItemSet(*_pSet); 608 609 return sal_True; 610 } 611 612 // -------------------------------------------------------------------------- 613 614 615 616 void SwLabPage::FillItem(SwLabItem& rItem) 617 { 618 rItem.bAddr = aAddrBox.IsChecked(); 619 rItem.aWriting = aWritingEdit.GetText(); 620 rItem.bCont = aContButton.IsChecked(); 621 rItem.aMake = aMakeBox.GetSelectEntry(); 622 rItem.aType = aTypeBox.GetSelectEntry(); 623 rItem.sDBName = sActDBName; 624 625 SwLabRec* pRec = GetSelectedEntryPos(); 626 pRec->FillItem( rItem ); 627 628 rItem.aLstMake = aMakeBox.GetSelectEntry(); 629 rItem.aLstType = aTypeBox.GetSelectEntry(); 630 } 631 632 // -------------------------------------------------------------------------- 633 634 635 636 sal_Bool SwLabPage::FillItemSet(SfxItemSet& rSet) 637 { 638 FillItem( aItem ); 639 rSet.Put( aItem ); 640 641 return sal_True; 642 } 643 644 // -------------------------------------------------------------------------- 645 646 void SwLabPage::Reset(const SfxItemSet& rSet) 647 { 648 aItem = (const SwLabItem&) rSet.Get(FN_LABEL); 649 String sDBName = aItem.sDBName; 650 651 String aWriting( aItem.aWriting ); 652 653 aAddrBox .Check ( aItem.bAddr ); 654 aWritingEdit.SetText ( aWriting.ConvertLineEnd() ); 655 656 const sal_uInt16 nCount = (sal_uInt16)GetParent()->Makes().Count(); 657 for (sal_uInt16 i = 0; i < nCount; ++i) 658 { 659 String &rStr = *GetParent()->Makes()[i]; 660 if(aMakeBox.GetEntryPos(String(rStr)) == LISTBOX_ENTRY_NOTFOUND) 661 aMakeBox.InsertEntry( rStr ); 662 } 663 664 665 aMakeBox .SelectEntry( aItem.aMake ); 666 //save the current type 667 String sType(aItem.aType); 668 aMakeBox.GetSelectHdl().Call( &aMakeBox ); 669 aItem.aType = sType; 670 //#102806# a newly added make may not be in the type ListBox already 671 if (aTypeBox.GetEntryPos(String(aItem.aType)) == LISTBOX_ENTRY_NOTFOUND && aItem.aMake.getLength()) 672 GetParent()->UpdateGroup( aItem.aMake ); 673 if (aTypeBox.GetEntryPos(String(aItem.aType)) != LISTBOX_ENTRY_NOTFOUND) 674 { 675 aTypeBox.SelectEntry(aItem.aType); 676 aTypeBox.GetSelectHdl().Call(&aTypeBox); 677 } 678 if (aDatabaseLB.GetEntryPos(sDBName) != LISTBOX_ENTRY_NOTFOUND) 679 { 680 aDatabaseLB.SelectEntry(sDBName); 681 aDatabaseLB.GetSelectHdl().Call(&aDatabaseLB); 682 } 683 684 if (aItem.bCont) 685 aContButton .Check(); 686 else 687 aSheetButton.Check(); 688 } 689 690 /*-- 08.07.99 14:00:02--------------------------------------------------- 691 692 -----------------------------------------------------------------------*/ 693 //----------------------------------------------------------------------------- 694 void SwVisitingCardPage::ClearUserData() 695 { 696 SvLBoxEntry* pEntry = aAutoTextLB.First(); 697 while(pEntry) 698 { 699 delete (String*)pEntry->GetUserData(); 700 pEntry = aAutoTextLB.Next(pEntry); 701 } 702 } 703 704 //----------------------------------------------------------------------------- 705 706 void SwVisitingCardPage::SetUserData( sal_uInt32 nCnt, 707 const rtl::OUString* pNames, const rtl::OUString* pValues ) 708 { 709 for( sal_uInt32 i = 0; i < nCnt; ++i ) 710 { 711 SvLBoxEntry* pEntry = aAutoTextLB.InsertEntry( pNames[ i ] ); 712 pEntry->SetUserData( new String( pValues[ i ] )); 713 } 714 } 715 716 //----------------------------------------------------------------------------- 717 718 SwVisitingCardPage::SwVisitingCardPage(Window* pParent, const SfxItemSet& rSet) : 719 SfxTabPage(pParent, SW_RES(TP_VISITING_CARDS), rSet), 720 aContentFL(this, SW_RES( FL_CONTENT )), 721 aAutoTextLB(this, SW_RES( LB_AUTO_TEXT )), 722 aAutoTextGroupFT(this, SW_RES( FT_AUTO_TEXT_GROUP )), 723 aAutoTextGroupLB(this, SW_RES( LB_AUTO_TEXT_GROUP )), 724 aExampleWIN(this, SW_RES( WIN_EXAMPLE )), 725 sVisCardGroup(SW_RES(ST_VISCARD_GROUP)), 726 pExampleFrame(0) 727 { 728 FreeResource(); 729 aAutoTextLB.SetStyle( aAutoTextLB.GetStyle() | WB_HSCROLL ); 730 aAutoTextLB.SetSpaceBetweenEntries(0); 731 aAutoTextLB.SetSelectionMode( SINGLE_SELECTION ); 732 aAutoTextLB.SetHelpId(HID_BUSINESS_CARD_CONTENT); 733 734 SetExchangeSupport(); 735 aAutoTextLB.SetSelectHdl(LINK(this, SwVisitingCardPage, AutoTextSelectHdl)); 736 aAutoTextGroupLB.SetSelectHdl(LINK(this, SwVisitingCardPage, AutoTextSelectHdl)); 737 738 aExampleWIN.Hide(); 739 740 aAutoTextLB.Show(); 741 aAutoTextGroupFT.Show(); 742 aAutoTextGroupLB.Show(); 743 InitFrameControl(); 744 } 745 /*-- 08.07.99 14:00:03--------------------------------------------------- 746 747 -----------------------------------------------------------------------*/ 748 SwVisitingCardPage::~SwVisitingCardPage() 749 { 750 for(sal_uInt16 i = 0; i < aAutoTextGroupLB.GetEntryCount(); i++) 751 delete (String*)aAutoTextGroupLB.GetEntryData( i ); 752 _xAutoText = 0; 753 754 ClearUserData(); 755 delete pExampleFrame; 756 } 757 /*-- 08.07.99 14:00:03--------------------------------------------------- 758 759 -----------------------------------------------------------------------*/ 760 SfxTabPage* SwVisitingCardPage::Create(Window* pParent, const SfxItemSet& rSet) 761 { 762 return new SwVisitingCardPage(pParent, rSet); 763 } 764 /*-- 08.07.99 14:00:03--------------------------------------------------- 765 766 -----------------------------------------------------------------------*/ 767 void SwVisitingCardPage::ActivatePage(const SfxItemSet& rSet) 768 { 769 Reset( rSet ); 770 UpdateFields(); 771 } 772 /*-- 08.07.99 14:00:04--------------------------------------------------- 773 774 -----------------------------------------------------------------------*/ 775 int SwVisitingCardPage::DeactivatePage(SfxItemSet* _pSet) 776 { 777 if (_pSet) 778 FillItemSet(*_pSet); 779 return LEAVE_PAGE; 780 } 781 /*-- 08.07.99 14:00:04--------------------------------------------------- 782 783 -----------------------------------------------------------------------*/ 784 sal_Bool SwVisitingCardPage::FillItemSet(SfxItemSet& rSet) 785 { 786 String* pGroup = (String*)aAutoTextGroupLB.GetEntryData( 787 aAutoTextGroupLB.GetSelectEntryPos()); 788 DBG_ASSERT(pGroup, "no group selected?"); 789 if(pGroup) 790 aLabItem.sGlossaryGroup = *pGroup; 791 792 SvLBoxEntry* pSelEntry = aAutoTextLB.FirstSelected(); 793 if(pSelEntry) 794 aLabItem.sGlossaryBlockName = *(String*)pSelEntry->GetUserData(); 795 rSet.Put(aLabItem); 796 return sal_True; 797 } 798 /*-- 08.07.99 14:00:05--------------------------------------------------- 799 800 -----------------------------------------------------------------------*/ 801 void lcl_SelectBlock(SvTreeListBox& rAutoTextLB, const String& rBlockName) 802 { 803 SvLBoxEntry* pEntry = rAutoTextLB.First(); 804 while(pEntry) 805 { 806 if(*(String*)pEntry->GetUserData() == rBlockName) 807 { 808 rAutoTextLB.Select(pEntry); 809 rAutoTextLB.MakeVisible(pEntry); 810 break; 811 } 812 pEntry = rAutoTextLB.Next(pEntry); 813 } 814 } 815 //----------------------------------------------------------------------------- 816 sal_Bool lcl_FindBlock(SvTreeListBox& rAutoTextLB, const String& rBlockName) 817 { 818 SvLBoxEntry* pEntry = rAutoTextLB.First(); 819 while(pEntry) 820 { 821 if(*(String*)pEntry->GetUserData() == rBlockName) 822 { 823 rAutoTextLB.Select(pEntry); 824 return sal_True; 825 } 826 pEntry = rAutoTextLB.Next(pEntry); 827 } 828 return sal_False; 829 } 830 831 //----------------------------------------------------------------------------- 832 void SwVisitingCardPage::Reset(const SfxItemSet& rSet) 833 { 834 aLabItem = (const SwLabItem&) rSet.Get(FN_LABEL); 835 836 sal_Bool bFound = sal_False; 837 sal_uInt16 i; 838 for(i = 0; i < aAutoTextGroupLB.GetEntryCount() && !bFound; i++) 839 if( String(aLabItem.sGlossaryGroup) == 840 *(String*)aAutoTextGroupLB.GetEntryData( i )) 841 { 842 bFound = sal_True; 843 break; 844 } 845 846 if(!bFound) 847 { 848 // initially search for a group starting with "crd" which is the name of the 849 // business card AutoTexts 850 for(i = 0; i < aAutoTextGroupLB.GetEntryCount() && !bFound; i++) 851 if(0 == (*(String*)aAutoTextGroupLB.GetEntryData( i )).SearchAscii( "crd") ) 852 { 853 bFound = sal_True; 854 break; 855 } 856 } 857 if(bFound) 858 { 859 if(aAutoTextGroupLB.GetSelectEntryPos() != i) 860 { 861 aAutoTextGroupLB.SelectEntryPos(i); 862 AutoTextSelectHdl(&aAutoTextGroupLB); 863 } 864 if(lcl_FindBlock(aAutoTextLB, aLabItem.sGlossaryBlockName)) 865 { 866 SvLBoxEntry* pSelEntry = aAutoTextLB.FirstSelected(); 867 if( pSelEntry && 868 *(String*)pSelEntry->GetUserData() != String(aLabItem.sGlossaryBlockName)) 869 { 870 lcl_SelectBlock(aAutoTextLB, aLabItem.sGlossaryBlockName); 871 AutoTextSelectHdl(&aAutoTextLB); 872 } 873 } 874 } 875 } 876 877 /* -----------------29.09.99 08:55------------------- 878 879 --------------------------------------------------*/ 880 SwPrivateDataPage::SwPrivateDataPage(Window* pParent, const SfxItemSet& rSet) : 881 SfxTabPage(pParent, SW_RES(TP_PRIVATE_DATA), rSet), 882 aDataFL (this, SW_RES( FL_DATA )), 883 884 aNameFT (this, SW_RES( FT_NAME )), 885 aFirstNameED (this, SW_RES( ED_FIRSTNAME )), 886 aNameED (this, SW_RES( ED_NAME )), 887 aShortCutED (this, SW_RES( ED_SHORTCUT )), 888 889 aName2FT (this, SW_RES( FT_NAME_2 )), 890 aFirstName2ED (this, SW_RES( ED_FIRSTNAME_2)), 891 aName2ED (this, SW_RES( ED_NAME_2 )), 892 aShortCut2ED (this, SW_RES( ED_SHORTCUT_2 )), 893 894 aStreetFT (this, SW_RES( FT_STREET )), 895 aStreetED (this, SW_RES( ED_STREET )), 896 aZipCityFT (this, SW_RES( FT_ZIPCITY )), 897 aZipED (this, SW_RES( ED_ZIP )), 898 aCityED (this, SW_RES( ED_CITY )), 899 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE )), 900 aCountryED (this, SW_RES( ED_COUNTRY )), 901 aStateED (this, SW_RES( ED_STATE )), 902 aTitleProfessionFT (this, SW_RES( FT_TITLEPROF )), 903 aTitleED (this, SW_RES( ED_TITLE )), 904 aProfessionED (this, SW_RES( ED_PROFESSION )), 905 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE )), 906 aPhoneED (this, SW_RES( ED_PHONE )), 907 aMobilePhoneED (this, SW_RES( ED_MOBILE )), 908 aFaxFT (this, SW_RES( FT_FAX )), 909 aFaxED (this, SW_RES( ED_FAX )), 910 aWWWMailFT (this, SW_RES( FT_WWWMAIL )), 911 aHomePageED (this, SW_RES( ED_WWW )), 912 aMailED (this, SW_RES( ED_MAIL )) 913 { 914 FreeResource(); 915 SetExchangeSupport(); 916 } 917 918 /*-- 29.09.99 08:55:57--------------------------------------------------- 919 920 -----------------------------------------------------------------------*/ 921 SwPrivateDataPage::~SwPrivateDataPage() 922 { 923 } 924 /*-- 29.09.99 08:55:57--------------------------------------------------- 925 926 -----------------------------------------------------------------------*/ 927 SfxTabPage* SwPrivateDataPage::Create(Window* pParent, const SfxItemSet& rSet) 928 { 929 return new SwPrivateDataPage(pParent, rSet); 930 } 931 /*-- 29.09.99 08:55:57--------------------------------------------------- 932 933 -----------------------------------------------------------------------*/ 934 void SwPrivateDataPage::ActivatePage(const SfxItemSet& rSet) 935 { 936 Reset(rSet); 937 } 938 /*-- 29.09.99 08:55:58--------------------------------------------------- 939 940 -----------------------------------------------------------------------*/ 941 int SwPrivateDataPage::DeactivatePage(SfxItemSet* _pSet) 942 { 943 if (_pSet) 944 FillItemSet(*_pSet); 945 return LEAVE_PAGE; 946 } 947 /*-- 29.09.99 08:55:58--------------------------------------------------- 948 949 -----------------------------------------------------------------------*/ 950 sal_Bool SwPrivateDataPage::FillItemSet(SfxItemSet& rSet) 951 { 952 953 SwLabItem aItem = (const SwLabItem&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL); 954 aItem.aPrivFirstName = aFirstNameED .GetText(); 955 aItem.aPrivName = aNameED .GetText( ); 956 aItem.aPrivShortCut = aShortCutED .GetText( ); 957 aItem.aPrivFirstName2 = aFirstName2ED .GetText(); 958 aItem.aPrivName2 = aName2ED .GetText( ); 959 aItem.aPrivShortCut2 = aShortCut2ED .GetText( ); 960 aItem.aPrivStreet = aStreetED .GetText( ); 961 aItem.aPrivZip = aZipED .GetText( ); 962 aItem.aPrivCity = aCityED .GetText( ); 963 aItem.aPrivCountry = aCountryED .GetText( ); 964 aItem.aPrivState = aStateED .GetText( ); 965 aItem.aPrivTitle = aTitleED .GetText( ); 966 aItem.aPrivProfession= aProfessionED.GetText( ); 967 aItem.aPrivPhone = aPhoneED .GetText( ); 968 aItem.aPrivMobile = aMobilePhoneED.GetText( ); 969 aItem.aPrivFax = aFaxED .GetText( ); 970 aItem.aPrivWWW = aHomePageED .GetText( ); 971 aItem.aPrivMail = aMailED .GetText( ); 972 973 rSet.Put(aItem); 974 return sal_True; 975 } 976 /*-- 29.09.99 08:55:59--------------------------------------------------- 977 978 -----------------------------------------------------------------------*/ 979 void SwPrivateDataPage::Reset(const SfxItemSet& rSet) 980 { 981 const SwLabItem& aItem = (const SwLabItem&) rSet.Get(FN_LABEL); 982 aFirstNameED.SetText(aItem.aPrivFirstName); 983 aNameED .SetText(aItem.aPrivName); 984 aShortCutED .SetText(aItem.aPrivShortCut); 985 aFirstName2ED.SetText(aItem.aPrivFirstName2); 986 aName2ED .SetText(aItem.aPrivName2); 987 aShortCut2ED .SetText(aItem.aPrivShortCut2); 988 aStreetED .SetText(aItem.aPrivStreet); 989 aZipED .SetText(aItem.aPrivZip); 990 aCityED .SetText(aItem.aPrivCity); 991 aCountryED .SetText(aItem.aPrivCountry); 992 aStateED .SetText(aItem.aPrivState); 993 aTitleED .SetText(aItem.aPrivTitle); 994 aProfessionED.SetText(aItem.aPrivProfession); 995 aPhoneED .SetText(aItem.aPrivPhone); 996 aMobilePhoneED.SetText(aItem.aPrivMobile); 997 aFaxED .SetText(aItem.aPrivFax); 998 aHomePageED .SetText(aItem.aPrivWWW); 999 aMailED .SetText(aItem.aPrivMail); 1000 } 1001 /* -----------------29.09.99 08:56------------------- 1002 1003 --------------------------------------------------*/ 1004 SwBusinessDataPage::SwBusinessDataPage(Window* pParent, const SfxItemSet& rSet) : 1005 SfxTabPage(pParent, SW_RES(TP_BUSINESS_DATA), rSet), 1006 aDataFL (this, SW_RES( FL_DATA )), 1007 aCompanyFT (this, SW_RES( FT_COMP )), 1008 aCompanyED (this, SW_RES( ED_COMP )), 1009 aCompanyExtFT (this, SW_RES( FT_COMP_EXT )), 1010 aCompanyExtED (this, SW_RES( ED_COMP_EXT )), 1011 aSloganFT (this, SW_RES( FT_SLOGAN )), 1012 aSloganED (this, SW_RES( ED_SLOGAN )), 1013 aStreetFT (this, SW_RES( FT_STREET )), 1014 aStreetED (this, SW_RES( ED_STREET )), 1015 aZipCityFT (this, SW_RES( FT_ZIPCITY )), 1016 aZipED (this, SW_RES( ED_ZIP )), 1017 aCityED (this, SW_RES( ED_CITY )), 1018 aCountryStateFT (this, SW_RES( FT_COUNTRYSTATE )), 1019 aCountryED (this, SW_RES( ED_COUNTRY )), 1020 aStateED (this, SW_RES( ED_STATE )), 1021 aPositionFT (this, SW_RES( FT_POSITION )), 1022 aPositionED (this, SW_RES( ED_POSITION )), 1023 aPhoneFT (this, SW_RES( FT_PHONE_MOBILE )), 1024 aPhoneED (this, SW_RES( ED_PHONE )), 1025 aMobilePhoneED (this, SW_RES( ED_MOBILE )), 1026 aFaxFT (this, SW_RES( FT_FAX )), 1027 aFaxED (this, SW_RES( ED_FAX )), 1028 aWWWMailFT (this, SW_RES( FT_WWWMAIL )), 1029 aHomePageED (this, SW_RES( ED_WWW )), 1030 aMailED (this, SW_RES( ED_MAIL )) 1031 { 1032 FreeResource(); 1033 SetExchangeSupport(); 1034 } 1035 1036 /*-- 29.09.99 08:56:06--------------------------------------------------- 1037 1038 -----------------------------------------------------------------------*/ 1039 SwBusinessDataPage::~SwBusinessDataPage() 1040 { 1041 } 1042 /*-- 29.09.99 08:56:06--------------------------------------------------- 1043 1044 -----------------------------------------------------------------------*/ 1045 SfxTabPage* SwBusinessDataPage::Create(Window* pParent, const SfxItemSet& rSet) 1046 { 1047 return new SwBusinessDataPage(pParent, rSet); 1048 } 1049 /*-- 29.09.99 08:56:06--------------------------------------------------- 1050 1051 -----------------------------------------------------------------------*/ 1052 void SwBusinessDataPage::ActivatePage(const SfxItemSet& rSet) 1053 { 1054 Reset(rSet); 1055 } 1056 /*-- 29.09.99 08:56:06--------------------------------------------------- 1057 1058 -----------------------------------------------------------------------*/ 1059 int SwBusinessDataPage::DeactivatePage(SfxItemSet* _pSet) 1060 { 1061 if (_pSet) 1062 FillItemSet(*_pSet); 1063 return LEAVE_PAGE; 1064 } 1065 /*-- 29.09.99 08:56:06--------------------------------------------------- 1066 1067 -----------------------------------------------------------------------*/ 1068 sal_Bool SwBusinessDataPage::FillItemSet(SfxItemSet& rSet) 1069 { 1070 SwLabItem aItem = (const SwLabItem&) GetTabDialog()->GetExampleSet()->Get(FN_LABEL); 1071 1072 aItem.aCompCompany = aCompanyED .GetText(); 1073 aItem.aCompCompanyExt= aCompanyExtED .GetText(); 1074 aItem.aCompSlogan = aSloganED .GetText(); 1075 aItem.aCompStreet = aStreetED .GetText(); 1076 aItem.aCompZip = aZipED .GetText(); 1077 aItem.aCompCity = aCityED .GetText(); 1078 aItem.aCompCountry = aCountryED .GetText(); 1079 aItem.aCompState = aStateED .GetText(); 1080 aItem.aCompPosition = aPositionED .GetText(); 1081 aItem.aCompPhone = aPhoneED .GetText(); 1082 aItem.aCompMobile = aMobilePhoneED .GetText(); 1083 aItem.aCompFax = aFaxED .GetText(); 1084 aItem.aCompWWW = aHomePageED .GetText(); 1085 aItem.aCompMail = aMailED .GetText(); 1086 1087 rSet.Put(aItem); 1088 return sal_True; 1089 } 1090 /*-- 29.09.99 08:56:07--------------------------------------------------- 1091 1092 -----------------------------------------------------------------------*/ 1093 void SwBusinessDataPage::Reset(const SfxItemSet& rSet) 1094 { 1095 const SwLabItem& aItem = (const SwLabItem&) rSet.Get(FN_LABEL); 1096 aCompanyED .SetText(aItem.aCompCompany); 1097 aCompanyExtED .SetText(aItem.aCompCompanyExt); 1098 aSloganED .SetText(aItem.aCompSlogan); 1099 aStreetED .SetText(aItem.aCompStreet); 1100 aZipED .SetText(aItem.aCompZip); 1101 aCityED .SetText(aItem.aCompCity); 1102 aCountryED .SetText(aItem.aCompCountry); 1103 aStateED .SetText(aItem.aCompState); 1104 aPositionED .SetText(aItem.aCompPosition); 1105 aPhoneED .SetText(aItem.aCompPhone); 1106 aMobilePhoneED .SetText(aItem.aCompMobile); 1107 aFaxED .SetText(aItem.aCompFax); 1108 aHomePageED .SetText(aItem.aCompWWW); 1109 aMailED .SetText(aItem.aCompMail); 1110 } 1111