1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif
#include <sfx2/app.hxx>
#include <basic/basmgr.hxx>
#include <basic/sbmod.hxx>
#include <docsh.hxx>
#include <swtypes.hxx>
#include <globals.hrc>
#include <fldbas.hxx>
#include <docufld.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
#include <swmodule.hxx>
#include <fldfunc.hxx>
#include <flddropdown.hxx>
#include <fldui.hrc>
#include <fldtdlg.hrc>
#define USER_DATA_VERSION_1 "1"
#define USER_DATA_VERSION USER_DATA_VERSION_1
using namespace ::com::sun::star;
using rtl::OUString;
SwFldFuncPage::SwFldFuncPage(Window* pParent, const SfxItemSet& rCoreSet ) :
SwFldPage( pParent, SW_RES( TP_FLD_FUNC ), rCoreSet ),
aTypeFT (this, SW_RES(FT_FUNCTYPE)),
aTypeLB (this, SW_RES(LB_FUNCTYPE)),
aSelectionFT(this, SW_RES(FT_FUNCSELECTION)),
aSelectionLB(this, SW_RES(LB_FUNCSELECTION)),
aFormatFT (this, SW_RES(FT_FUNCFORMAT)),
aFormatLB (this, SW_RES(LB_FUNCFORMAT)),
aNameFT (this, SW_RES(FT_FUNCNAME)),
aNameED (this, SW_RES(ED_FUNCNAME)),
aValueFT (this, SW_RES(FT_FUNCVALUE)),
aValueED (this, SW_RES(ED_FUNCVALUE)),
aCond1FT (this, SW_RES(FT_FUNCCOND1)),
aCond1ED (this, SW_RES(ED_FUNCCOND1)),
aCond2FT (this, SW_RES(FT_FUNCCOND2)),
aCond2ED (this, SW_RES(ED_FUNCCOND2)),
aMacroBT (this, SW_RES(BT_FUNCMACRO)),
aListItemFT( this, SW_RES( FT_LISTITEM )),
aListItemED( this, SW_RES( ED_LISTITEM )),
aListAddPB( this, SW_RES( PB_LISTADD )),
aListItemsFT( this, SW_RES( FT_LISTITEMS )),
aListItemsLB( this, SW_RES( LB_LISTITEMS )),
aListRemovePB( this, SW_RES( PB_LISTREMOVE )),
aListUpPB( this, SW_RES( PB_LISTUP )),
aListDownPB( this, SW_RES( PB_LISTDOWN )),
aListNameFT( this, SW_RES( FT_LISTNAME )),
aListNameED( this, SW_RES( ED_LISTNAME )),
bDropDownLBChanged(false)
{
FreeResource();
aNameED.SetPosPixel(Point(aNameED.GetPosPixel().X(), aFormatLB.GetPosPixel().Y()));
aNameED.SetModifyHdl(LINK(this, SwFldFuncPage, ModifyHdl));
sOldValueFT = aValueFT.GetText();
sOldNameFT = aNameFT.GetText();
aCond1ED.ShowBrackets(sal_False);
aCond2ED.ShowBrackets(sal_False);
}
SwFldFuncPage::~SwFldFuncPage()
{
}
void SwFldFuncPage::Reset(const SfxItemSet& )
{
SavePos(&aTypeLB);
Init(); // general initialisation
aTypeLB.SetUpdateMode(sal_False);
aTypeLB.Clear();
sal_uInt16 nPos, nTypeId;
if (!IsFldEdit())
{
// initialise TypeListBox
const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
// fill Typ-Listbox
for(short i = rRg.nStart; i < rRg.nEnd; ++i)
{
nTypeId = GetFldMgr().GetTypeId(i);
nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
}
}
else
{
nTypeId = GetCurField()->GetTypeId();
nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
if (nTypeId == TYP_MACROFLD)
{
String sName(GetCurField()->GetPar1());
GetFldMgr().SetMacroPath(sName);
}
}
// select old Pos
RestorePos(&aTypeLB);
aTypeLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertHdl));
aTypeLB.SetSelectHdl (LINK(this, SwFldFuncPage, TypeHdl));
aSelectionLB.SetSelectHdl (LINK(this, SwFldFuncPage, SelectHdl));
aSelectionLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertMacroHdl));
aFormatLB.SetDoubleClickHdl (LINK(this, SwFldFuncPage, InsertHdl));
aMacroBT.SetClickHdl (LINK(this, SwFldFuncPage, MacroHdl));
Link aListModifyLk( LINK(this, SwFldFuncPage, ListModifyHdl));
aListAddPB.SetClickHdl(aListModifyLk);
aListRemovePB.SetClickHdl(aListModifyLk);
aListUpPB.SetClickHdl(aListModifyLk);
aListDownPB.SetClickHdl(aListModifyLk);
aListItemED.SetReturnActionLink(aListModifyLk);
Link aListEnableLk = LINK(this, SwFldFuncPage, ListEnableHdl);
aListItemED.SetModifyHdl(aListEnableLk);
aListItemsLB.SetSelectHdl(aListEnableLk);
if( !IsRefresh() )
{
String sUserData = GetUserData();
if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
{
String sVal = sUserData.GetToken(1, ';');
sal_uInt16 nVal = static_cast< sal_uInt16 >(sVal.ToInt32());
if(nVal != USHRT_MAX)
{
for(sal_uInt16 i = 0; i < aTypeLB.GetEntryCount(); i++)
if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
{
aTypeLB.SelectEntryPos(i);
break;
}
}
}
}
TypeHdl(0);
aTypeLB.SetUpdateMode(sal_True);
if (IsFldEdit())
{
aNameED.SaveValue();
aValueED.SaveValue();
aCond1ED.SaveValue();
aCond2ED.SaveValue();
nOldFormat = GetCurField()->GetFormat();
}
}
IMPL_LINK( SwFldFuncPage, TypeHdl, ListBox *, EMPTYARG )
{
// save old ListBoxPos
const sal_uInt16 nOld = GetTypeSel();
// current ListBoxPos
SetTypeSel(aTypeLB.GetSelectEntryPos());
if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
{
SetTypeSel(0);
aTypeLB.SelectEntryPos(0);
}
if (nOld != GetTypeSel())
{
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
// fill Selection-Listbox
UpdateSubType();
// fill Format-Listbox
aFormatLB.Clear();
sal_uInt16 nSize = GetFldMgr().GetFormatCount(nTypeId, sal_False, IsFldDlgHtmlMode());
for (sal_uInt16 i = 0; i < nSize; i++)
{
sal_uInt16 nPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(nTypeId, i));
aFormatLB.SetEntryData( nPos, reinterpret_cast<void*>(GetFldMgr().GetFormatId( nTypeId, i )) );
}
if (nSize)
{
if (IsFldEdit() && nTypeId == TYP_JUMPEDITFLD)
aFormatLB.SelectEntry(SW_RESSTR(FMT_MARK_BEGIN + (sal_uInt16)GetCurField()->GetFormat()));
if (!aFormatLB.GetSelectEntryCount())
aFormatLB.SelectEntryPos(0);
}
sal_Bool bValue = sal_False, bName = sal_False, bMacro = sal_False, bInsert = sal_True;
sal_Bool bShowSelection = sal_False;
sal_Bool bFormat = nSize != 0;
// two controls for conditional text
sal_Bool bDropDown = TYP_DROPDOWN == nTypeId;
sal_Bool bCondTxtFld = TYP_CONDTXTFLD == nTypeId;
aCond1FT.Show(!bDropDown && bCondTxtFld);
aCond1ED.Show(!bDropDown && bCondTxtFld);
aCond2FT.Show(!bDropDown && bCondTxtFld);
aCond2ED.Show(!bDropDown && bCondTxtFld);
aValueFT.Show(!bDropDown && !bCondTxtFld);
aValueED.Show(!bDropDown && !bCondTxtFld);
aMacroBT.Show(!bDropDown);
aNameED.Show(!bDropDown);
aNameFT.Show(!bDropDown);
aListItemFT.Show(bDropDown);
aListItemED.Show(bDropDown);
aListAddPB.Show(bDropDown);
aListItemsFT.Show(bDropDown);
aListItemsLB.Show(bDropDown);
aListRemovePB.Show(bDropDown);
aListUpPB.Show(bDropDown);
aListDownPB.Show(bDropDown);
aListNameFT.Show(bDropDown);
aListNameED.Show(bDropDown);
aNameED.SetDropEnable(sal_False);
if (IsFldEdit())
{
if(bDropDown)
{
const SwDropDownField* pDrop = (const SwDropDownField*)GetCurField();
uno::Sequence<OUString> aItems = pDrop->GetItemSequence();
const OUString* pArray = aItems.getConstArray();
aListItemsLB.Clear();
for(sal_Int32 i = 0; i < aItems.getLength(); i++)
aListItemsLB.InsertEntry(pArray[i]);
aListItemsLB.SelectEntry(pDrop->GetSelectedItem());
aListNameED.SetText(pDrop->GetPar2());
aListNameED.SaveValue();
bDropDownLBChanged = false;
}
else
{
aNameED.SetText(GetCurField()->GetPar1());
aValueED.SetText(GetCurField()->GetPar2());
}
}
else
{
aNameED.SetText(aEmptyStr);
aValueED.SetText(aEmptyStr);
}
if(bDropDown)
ListEnableHdl(0);
if( aNameFT.GetText() != sOldNameFT )
aNameFT.SetText(sOldNameFT);
if (aValueFT.GetText() != sOldValueFT)
aValueFT.SetText(sOldValueFT);
switch (nTypeId)
{
case TYP_MACROFLD:
bMacro = sal_True;
if (GetFldMgr().GetMacroPath().Len())
bValue = sal_True;
else
bInsert = sal_False;
aNameFT.SetText(SW_RESSTR(STR_MACNAME));
aValueFT.SetText(SW_RESSTR(STR_PROMPT));
aNameED.SetText(GetFldMgr().GetMacroName());
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
break;
case TYP_HIDDENPARAFLD:
aNameFT.SetText(SW_RESSTR(STR_COND));
aNameED.SetDropEnable(sal_True);
bName = sal_True;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
break;
case TYP_HIDDENTXTFLD:
{
aNameFT.SetText(SW_RESSTR(STR_COND));
aNameED.SetDropEnable(sal_True);
aValueFT.SetText(SW_RESSTR(STR_INSTEXT));
SwWrtShell* pSh = GetActiveWrtShell();
if (!IsFldEdit() && pSh )
aValueED.SetText(pSh->GetSelTxt());
bName = bValue = sal_True;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
}
break;
case TYP_CONDTXTFLD:
aNameFT.SetText(SW_RESSTR(STR_COND));
aNameED.SetDropEnable(sal_True);
if (IsFldEdit())
{
aCond1ED.SetText(GetCurField()->GetPar2().GetToken(0, '|'));
aCond2ED.SetText(GetCurField()->GetPar2().GetToken(1, '|'));
}
bName = bValue = sal_True;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
break;
case TYP_JUMPEDITFLD:
aNameFT.SetText(SW_RESSTR(STR_JUMPEDITFLD));
aValueFT.SetText(SW_RESSTR(STR_PROMPT));
bName = bValue = sal_True;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
break;
case TYP_INPUTFLD:
aValueFT.SetText(SW_RESSTR(STR_PROMPT));
bValue = sal_True;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
break;
case TYP_COMBINED_CHARS:
{
aNameFT.SetText(SW_RESSTR(STR_COMBCHRS_FT));
aNameED.SetDropEnable(sal_True);
bName = sal_True;
const sal_uInt16 nLen = aNameED.GetText().Len();
if( !nLen || nLen > MAX_COMBINED_CHARACTERS )
bInsert = sal_False;
aNameED.SetAccessibleName(aNameFT.GetText());
aValueED.SetAccessibleName(aValueFT.GetText());
}
break;
case TYP_DROPDOWN :
break;
default:
break;
}
if (bShowSelection)
{
aSelectionLB.Show();
aSelectionFT.Show();
aFormatLB.Hide();
aFormatFT.Hide();
}
else
{
aFormatLB.Show();
aFormatFT.Show();
aSelectionLB.Hide();
aSelectionFT.Hide();
}
aFormatLB.Enable(bFormat);
aFormatFT.Enable(bFormat);
aNameFT.Enable(bName);
aNameED.Enable(bName);
aValueFT.Enable(bValue);
aValueED.Enable(bValue);
aMacroBT.Enable(bMacro);
EnableInsert( bInsert );
}
return 0;
}
IMPL_LINK( SwFldFuncPage, SelectHdl, ListBox *, EMPTYARG )
{
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
if( TYP_MACROFLD == nTypeId )
aNameED.SetText( aSelectionLB.GetSelectEntry() );
return 0;
}
IMPL_LINK( SwFldFuncPage, InsertMacroHdl, ListBox *, EMPTYARG )
{
SelectHdl();
InsertHdl();
return 0;
}
IMPL_LINK( SwFldFuncPage, ListModifyHdl, Control*, pControl)
{
aListItemsLB.SetUpdateMode(sal_False);
if(pControl == &aListAddPB ||
(pControl == &aListItemED && aListAddPB.IsEnabled()))
{
String sEntry(aListItemED.GetText());
aListItemsLB.InsertEntry(sEntry);
aListItemsLB.SelectEntry(sEntry);
}
else if(aListItemsLB.GetSelectEntryCount())
{
sal_uInt16 nSelPos = aListItemsLB.GetSelectEntryPos();
if(pControl == &aListRemovePB)
{
aListItemsLB.RemoveEntry(nSelPos);
aListItemsLB.SelectEntryPos(nSelPos ? nSelPos - 1 : 0);
}
else if(pControl == &aListUpPB)
{
if(nSelPos)
{
String sEntry = aListItemsLB.GetSelectEntry();
aListItemsLB.RemoveEntry(nSelPos);
nSelPos--;
aListItemsLB.InsertEntry(sEntry, nSelPos);
aListItemsLB.SelectEntryPos(nSelPos);
}
}
else if(pControl == &aListDownPB)
{
if(nSelPos < aListItemsLB.GetEntryCount() - 1)
{
String sEntry = aListItemsLB.GetSelectEntry();
aListItemsLB.RemoveEntry(nSelPos);
nSelPos++;
aListItemsLB.InsertEntry(sEntry, nSelPos);
aListItemsLB.SelectEntryPos(nSelPos);
}
}
}
bDropDownLBChanged = true;
aListItemsLB.SetUpdateMode(sal_True);
ListEnableHdl(0);
return 0;
}
IMPL_LINK( SwFldFuncPage, ListEnableHdl, void*, EMPTYARG)
{
//enable "Add" button when text is in the Edit that's not already member of the box
aListAddPB.Enable(aListItemED.GetText().Len() &&
LISTBOX_ENTRY_NOTFOUND == aListItemsLB.GetEntryPos(aListItemED.GetText()));
sal_Bool bEnableButtons = aListItemsLB.GetSelectEntryCount() > 0;
aListRemovePB.Enable(bEnableButtons);
aListUpPB.Enable(bEnableButtons && (aListItemsLB.GetSelectEntryPos() > 0));
aListDownPB.Enable(bEnableButtons &&
(aListItemsLB.GetSelectEntryPos() < (aListItemsLB.GetEntryCount() - 1)));
return 0;
}
/*--------------------------------------------------------------------
Description: renew types in SelectionBox
--------------------------------------------------------------------*/
void SwFldFuncPage::UpdateSubType()
{
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
// fill Selction-Listbox
aSelectionLB.SetUpdateMode(sal_False);
aSelectionLB.Clear();
SvStringsDtor aLst;
GetFldMgr().GetSubTypes(nTypeId, aLst);
sal_uInt16 nCount = aLst.Count();
for (sal_uInt16 i = 0; i < nCount; ++i)
{
sal_uInt16 nPos = aSelectionLB.InsertEntry(*aLst[i]);
aSelectionLB.SetEntryData(nPos, reinterpret_cast<void*>(i));
}
sal_Bool bEnable = nCount != 0;
aSelectionLB.Enable( bEnable );
aSelectionFT.Enable( bEnable );
if (bEnable)
{
aSelectionLB.SelectEntryPos(0);
}
if (nTypeId == TYP_MACROFLD)
{
sal_Bool bHasMacro = GetFldMgr().GetMacroPath().Len() != 0;
if (bHasMacro)
{
aNameED.SetText(GetFldMgr().GetMacroName());
aValueFT.Enable();
aValueED.Enable();
}
EnableInsert(bHasMacro);
}
aSelectionLB.SetUpdateMode(sal_True);
}
/*--------------------------------------------------------------------
Description: call MacroBrowser, fill Listbox with Macros
--------------------------------------------------------------------*/
IMPL_LINK( SwFldFuncPage, MacroHdl, Button *, pBtn )
{
Window* pDefModalDlgParent = Application::GetDefDialogParent();
Application::SetDefDialogParent( pBtn );
String sMacro(TurnMacroString(aNameED.GetText()));
while (sMacro.SearchAndReplace('.', ';') != STRING_NOTFOUND) ;
if (GetFldMgr().ChooseMacro(sMacro))
UpdateSubType();
Application::SetDefDialogParent( pDefModalDlgParent );
return 0;
}
sal_Bool SwFldFuncPage::FillItemSet(SfxItemSet& )
{
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
sal_uInt16 nSubType = 0;
sal_uLong nFormat = aFormatLB.GetSelectEntryPos();
if(nFormat == LISTBOX_ENTRY_NOTFOUND)
nFormat = 0;
else
nFormat = (sal_uLong)aFormatLB.GetEntryData((sal_uInt16)nFormat);
String aVal(aValueED.GetText());
String aName(aNameED.GetText());
switch(nTypeId)
{
case TYP_INPUTFLD:
nSubType = INP_TXT;
// to prevent removal of CR/LF restore old content
if(!aNameED.IsModified() && IsFldEdit())
aName = GetCurField()->GetPar1();
break;
case TYP_MACROFLD:
// use the full script URL, not the name in the Edit control
aName = GetFldMgr().GetMacroPath();
break;
case TYP_CONDTXTFLD:
aVal = aCond1ED.GetText();
aVal += '|';
aVal += aCond2ED.GetText();
break;
case TYP_DROPDOWN :
{
aName = aListNameED.GetText();
for(sal_uInt16 i = 0; i < aListItemsLB.GetEntryCount(); i++)
{
if(i)
aVal += DB_DELIM;
aVal += aListItemsLB.GetEntry(i);
}
}
break;
default:
break;
}
if (!IsFldEdit() ||
aNameED.GetSavedValue() != aNameED.GetText() ||
aValueED.GetSavedValue() != aValueED.GetText() ||
aCond1ED.GetSavedValue() != aCond1ED.GetText() ||
aCond2ED.GetSavedValue() != aCond2ED.GetText() ||
aListNameED.GetSavedValue() != aListNameED.GetText() ||
bDropDownLBChanged ||
nOldFormat != nFormat)
{
InsertFld( nTypeId, nSubType, aName, aVal, nFormat );
}
ModifyHdl(); // enable/disable Insert if applicable
return sal_False;
}
String SwFldFuncPage::TurnMacroString(const String &rMacro)
{
if (rMacro.Len())
{
// reverse content of aName
String sTmp, sBuf;
sal_uInt16 nPos = 0;
for (sal_uInt16 i = 0; i < 4 && nPos != STRING_NOTFOUND; i++)
{
if (i == 3)
sTmp = rMacro.Copy(nPos);
else
sTmp = rMacro.GetToken(0, '.', nPos);
if( sBuf.Len() )
sTmp += '.';
sBuf.Insert( sTmp, 0 );
}
return sBuf;
}
return rMacro;
}
SfxTabPage* SwFldFuncPage::Create( Window* pParent,
const SfxItemSet& rAttrSet )
{
return ( new SwFldFuncPage( pParent, rAttrSet ) );
}
sal_uInt16 SwFldFuncPage::GetGroup()
{
return GRP_FKT;
}
void SwFldFuncPage::FillUserData()
{
String sData( String::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION )));
sData += ';';
sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
nTypeSel = USHRT_MAX;
else
nTypeSel = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(aTypeLB.GetEntryData( nTypeSel )));
sData += String::CreateFromInt32( nTypeSel );
SetUserData(sData);
}
IMPL_LINK( SwFldFuncPage, ModifyHdl, Edit *, EMPTYARG )
{
String aName(aNameED.GetText());
const sal_uInt16 nLen = aName.Len();
sal_Bool bEnable = sal_True;
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
if( TYP_COMBINED_CHARS == nTypeId &&
(!nLen || nLen > MAX_COMBINED_CHARACTERS ))
bEnable = sal_False;
EnableInsert( bEnable );
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|