1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 #ifdef SW_DLLIMPLEMENTATION 31 #undef SW_DLLIMPLEMENTATION 32 #endif 33 34 35 #include <tools/shl.hxx> 36 #include <swtypes.hxx> 37 #include <helpid.h> 38 #include <uiitems.hxx> 39 #include <modcfg.hxx> 40 #include "swmodule.hxx" 41 #include "usrpref.hxx" 42 #include "wrtsh.hxx" 43 #include "linkenum.hxx" 44 #include <uitool.hxx> 45 #include <view.hxx> 46 47 #include "globals.hrc" 48 #include "cmdid.h" 49 50 #include "optload.hrc" 51 #include "optload.hxx" 52 #include <svx/dlgutil.hxx> 53 #include <svx/htmlmode.hxx> 54 #include <fldmgr.hxx> 55 #include <poolfmt.hxx> 56 #include <expfld.hxx> 57 #include <caption.hxx> 58 #include <com/sun/star/document/PrinterIndependentLayout.hpp> 59 60 #include <svtools/insdlg.hxx> 61 #include <sot/clsids.hxx> 62 #include <unotools/configmgr.hxx> 63 #include <docsh.hxx> 64 #include <config.hrc> 65 #include <SwStyleNameMapper.hxx> 66 #include <numrule.hxx> 67 #include <SwNodeNum.hxx> 68 69 #include <doc.hxx> 70 #include <svl/cjkoptions.hxx> 71 72 using namespace ::com::sun::star; 73 74 /* -----------------22.10.98 15:12------------------- 75 * 76 * --------------------------------------------------*/ 77 SwLoadOptPage::SwLoadOptPage( Window* pParent, const SfxItemSet& rSet ) : 78 79 SfxTabPage( pParent, SW_RES( TP_OPTLOAD_PAGE ), rSet ), 80 81 aUpdateFL ( this, SW_RES( FL_UPDATE ) ), 82 aLinkFT ( this, SW_RES( FT_LINK ) ), 83 aAlwaysRB ( this, SW_RES( RB_ALWAYS ) ), 84 aRequestRB ( this, SW_RES( RB_REQUEST ) ), 85 aNeverRB ( this, SW_RES( RB_NEVER ) ), 86 87 aFieldFT ( this, SW_RES( FT_FIELD ) ), 88 aAutoUpdateFields ( this, SW_RES( CB_AUTO_UPDATE_FIELDS ) ), 89 aAutoUpdateCharts ( this, SW_RES( CB_AUTO_UPDATE_CHARTS ) ), 90 91 aSettingsFL ( this, SW_RES( FL_SETTINGS ) ), 92 aMetricFT ( this, SW_RES( FT_METRIC ) ), 93 aMetricLB ( this, SW_RES( LB_METRIC ) ), 94 aTabFT ( this, SW_RES( FT_TAB ) ), 95 aTabMF ( this, SW_RES( MF_TAB ) ), 96 aUseSquaredPageMode ( this, SW_RES( CB_USE_SQUARE_PAGE_MODE ) ), 97 98 pWrtShell ( NULL ), 99 bHTMLMode ( sal_False ), 100 nLastTab ( 0 ), 101 nOldLinkMode( MANUAL ) 102 103 { 104 FreeResource(); 105 106 SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) ); 107 for ( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i ) 108 { 109 String sMetric = aMetricArr.GetStringByPos( i ); 110 FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i ); 111 112 switch ( eFUnit ) 113 { 114 case FUNIT_MM: 115 case FUNIT_CM: 116 case FUNIT_POINT: 117 case FUNIT_PICA: 118 case FUNIT_INCH: 119 { 120 // nur diese Metriken benutzen 121 sal_uInt16 nPos = aMetricLB.InsertEntry( sMetric ); 122 aMetricLB.SetEntryData( nPos, (void*)(long)eFUnit ); 123 } 124 default:; //prevent warning 125 } 126 } 127 aMetricLB.SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl)); 128 129 const SfxPoolItem* pItem; 130 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem ) 131 && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON) 132 { 133 aTabFT.Hide(); 134 aTabMF.Hide(); 135 } 136 137 SvtCJKOptions aCJKOptions; 138 if(!aCJKOptions.IsAsianTypographyEnabled()) 139 aUseSquaredPageMode.Hide(); 140 } 141 142 /*-----------------18.01.97 12.43------------------- 143 144 --------------------------------------------------*/ 145 146 SwLoadOptPage::~SwLoadOptPage() 147 { 148 } 149 150 /*-----------------18.01.97 12.43------------------- 151 152 --------------------------------------------------*/ 153 154 SfxTabPage* __EXPORT SwLoadOptPage::Create( Window* pParent, 155 const SfxItemSet& rAttrSet ) 156 { 157 return new SwLoadOptPage(pParent, rAttrSet ); 158 } 159 160 /*-----------------18.01.97 12.42------------------- 161 162 --------------------------------------------------*/ 163 164 sal_Bool __EXPORT SwLoadOptPage::FillItemSet( SfxItemSet& rSet ) 165 { 166 sal_Bool bRet = sal_False; 167 SwModule* pMod = SW_MOD(); 168 169 sal_uInt16 nNewLinkMode = AUTOMATIC; 170 if (aNeverRB.IsChecked()) 171 nNewLinkMode = NEVER; 172 else if (aRequestRB.IsChecked()) 173 nNewLinkMode = MANUAL; 174 175 SwFldUpdateFlags eFldFlags = aAutoUpdateFields.IsChecked() ? 176 aAutoUpdateCharts.IsChecked() ? AUTOUPD_FIELD_AND_CHARTS : AUTOUPD_FIELD_ONLY : AUTOUPD_OFF; 177 178 if(aAutoUpdateFields.IsChecked() != aAutoUpdateFields.GetSavedValue() || 179 aAutoUpdateCharts.IsChecked() != aAutoUpdateCharts.GetSavedValue()) 180 { 181 pMod->ApplyFldUpdateFlags(eFldFlags); 182 if(pWrtShell) 183 { 184 pWrtShell->SetFldUpdateFlags(eFldFlags); 185 pWrtShell->SetModified(); 186 } 187 } 188 189 if (nNewLinkMode != nOldLinkMode) 190 { 191 pMod->ApplyLinkMode(nNewLinkMode); 192 if (pWrtShell) 193 { 194 pWrtShell->SetLinkUpdMode( nNewLinkMode ); 195 pWrtShell->SetModified(); 196 } 197 198 bRet = sal_True; 199 } 200 201 const sal_uInt16 nMPos = aMetricLB.GetSelectEntryPos(); 202 if ( nMPos != aMetricLB.GetSavedValue() ) 203 { 204 // Doppel-Cast fuer VA3.0 205 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aMetricLB.GetEntryData( nMPos ); 206 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nFieldUnit ) ); 207 bRet = sal_True; 208 } 209 210 if(aTabMF.IsVisible() && aTabMF.GetText() != aTabMF.GetSavedValue()) 211 { 212 rSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP, 213 (sal_uInt16)aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP)))); 214 bRet = sal_True; 215 } 216 217 sal_Bool bIsSquaredPageModeFlag = aUseSquaredPageMode.IsChecked(); 218 if ( bIsSquaredPageModeFlag != aUseSquaredPageMode.GetSavedValue() ) 219 { 220 pMod->ApplyDefaultPageMode( bIsSquaredPageModeFlag ); 221 if ( pWrtShell ) 222 { 223 SwDoc* pDoc = pWrtShell->GetDoc(); 224 pDoc->SetDefaultPageMode( bIsSquaredPageModeFlag ); 225 pWrtShell->SetModified(); 226 } 227 bRet = sal_True; 228 } 229 230 return bRet; 231 } 232 /*-----------------18.01.97 12.42------------------- 233 234 --------------------------------------------------*/ 235 void __EXPORT SwLoadOptPage::Reset( const SfxItemSet& rSet) 236 { 237 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref(sal_False); 238 const SfxPoolItem* pItem; 239 240 if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_WRTSHELL, sal_False, &pItem)) 241 pWrtShell = (SwWrtShell*)((const SwPtrItem*)pItem)->GetValue(); 242 243 SwFldUpdateFlags eFldFlags = AUTOUPD_GLOBALSETTING; 244 nOldLinkMode = GLOBALSETTING; 245 if (pWrtShell) 246 { 247 eFldFlags = pWrtShell->GetFldUpdateFlags(sal_True); 248 nOldLinkMode = pWrtShell->GetLinkUpdMode(sal_True); 249 } 250 if(GLOBALSETTING == nOldLinkMode) 251 nOldLinkMode = pUsrPref->GetUpdateLinkMode(); 252 if(AUTOUPD_GLOBALSETTING == eFldFlags) 253 eFldFlags = pUsrPref->GetFldUpdateFlags(); 254 255 aAutoUpdateFields.Check(eFldFlags != AUTOUPD_OFF); 256 aAutoUpdateCharts.Check(eFldFlags == AUTOUPD_FIELD_AND_CHARTS); 257 258 switch (nOldLinkMode) 259 { 260 case NEVER: aNeverRB.Check(); break; 261 case MANUAL: aRequestRB.Check(); break; 262 case AUTOMATIC: aAlwaysRB.Check(); break; 263 } 264 265 aAutoUpdateFields.SaveValue(); 266 aAutoUpdateCharts.SaveValue(); 267 aMetricLB.SetNoSelection(); 268 if ( rSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE ) 269 { 270 const SfxUInt16Item& rItem = (SfxUInt16Item&)rSet.Get( SID_ATTR_METRIC ); 271 FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue(); 272 273 for ( sal_uInt16 i = 0; i < aMetricLB.GetEntryCount(); ++i ) 274 { 275 if ( (int)(sal_IntPtr)aMetricLB.GetEntryData( i ) == (int)eFieldUnit ) 276 { 277 aMetricLB.SelectEntryPos( i ); 278 break; 279 } 280 } 281 ::SetFieldUnit(aTabMF, eFieldUnit); 282 } 283 aMetricLB.SaveValue(); 284 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem)) 285 { 286 nLastTab = ((SfxUInt16Item*)pItem)->GetValue(); 287 aTabMF.SetValue(aTabMF.Normalize(nLastTab), FUNIT_TWIP); 288 } 289 aTabMF.SaveValue(); 290 291 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem)) 292 { 293 bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON); 294 } 295 296 //default page mode loading 297 if(pWrtShell) 298 { 299 sal_Bool bSquaredPageMode = pWrtShell->GetDoc()->IsSquaredPageMode(); 300 aUseSquaredPageMode.Check( bSquaredPageMode ); 301 aUseSquaredPageMode.SaveValue(); 302 } 303 } 304 /*-----------------13.01.97 14.44------------------- 305 Metric des Deftabstops umschalten 306 --------------------------------------------------*/ 307 308 IMPL_LINK(SwLoadOptPage, MetricHdl, ListBox*, EMPTYARG) 309 { 310 const sal_uInt16 nMPos = aMetricLB.GetSelectEntryPos(); 311 if(nMPos != USHRT_MAX) 312 { 313 // Doppel-Cast fuer VA3.0 314 FieldUnit eFieldUnit = (FieldUnit)(long)aMetricLB.GetEntryData( nMPos ); 315 sal_Bool bModified = aTabMF.IsModified(); 316 long nVal = bModified ? 317 sal::static_int_cast<sal_Int32, sal_Int64 >( aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) )) : 318 nLastTab; 319 ::SetFieldUnit( aTabMF, eFieldUnit ); 320 aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP ); 321 if(!bModified) 322 aTabMF.ClearModifyFlag(); 323 } 324 325 return 0; 326 } 327 /*********************************************************************/ 328 /* */ 329 /*********************************************************************/ 330 331 IMPL_LINK(SwLoadOptPage, CaptionHdl, PushButton*, EMPTYARG) 332 { 333 SwCaptionOptDlg aDlg(this, GetItemSet()); 334 aDlg.Execute(); 335 336 return 0; 337 } 338 339 /*-------------------------------------------------------------------- 340 Beschreibung: 341 --------------------------------------------------------------------*/ 342 343 SwCaptionOptDlg::SwCaptionOptDlg(Window* pParent, const SfxItemSet& rSet) : 344 SfxSingleTabDialog(pParent, rSet, 0) 345 { 346 // TabPage erzeugen 347 SetTabPage((SwCaptionOptPage*) SwCaptionOptPage::Create(this, rSet)); 348 } 349 350 /*-------------------------------------------------------------------- 351 Beschreibung: 352 --------------------------------------------------------------------*/ 353 354 SwCaptionOptDlg::~SwCaptionOptDlg() 355 { 356 } 357 358 /* -----------------22.10.98 15:12------------------- 359 * 360 * --------------------------------------------------*/ 361 362 SwCaptionPreview::SwCaptionPreview( Window* pParent, const ResId& rResId ) 363 : Window( pParent, rResId ) 364 { 365 maDrawPos = Point( 4, 6 ); 366 367 Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() ); 368 SetBackground( aBack ); 369 SetFillColor( aBack.GetColor() ); 370 SetLineColor( aBack.GetColor() ); 371 SetBorderStyle( WINDOW_BORDER_MONO ); 372 Font aFont(GetFont()); 373 aFont.SetHeight(aFont.GetHeight() * 120 / 100 ); 374 SetFont(aFont); 375 } 376 377 void SwCaptionPreview::SetPreviewText( const String& rText ) 378 { 379 if( rText != maText ) 380 { 381 maText = rText; 382 Invalidate(); 383 } 384 } 385 386 void SwCaptionPreview::Paint( const Rectangle& rRect ) 387 { 388 Window::Paint( rRect ); 389 390 DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); 391 DrawText( Point( 4, 6 ), maText ); 392 } 393 394 395 SwCaptionOptPage::SwCaptionOptPage( Window* pParent, const SfxItemSet& rSet ) 396 : SfxTabPage(pParent, SW_RES(TP_OPTCAPTION_PAGE), rSet), 397 aCheckFT (this, SW_RES(FT_OBJECTS )), 398 aCheckLB (this, SW_RES(CLB_OBJECTS )), 399 aFtCaptionOrder(this, SW_RES( FT_ORDER )), 400 aLbCaptionOrder(this, SW_RES( LB_ORDER )), 401 aPreview (this, SW_RES(WIN_PREVIEW )), 402 aSettingsGroupFL(this, SW_RES(FL_SETTINGS_2 )), 403 aCategoryText (this, SW_RES(TXT_CATEGORY )), 404 aCategoryBox (this, SW_RES(BOX_CATEGORY )), 405 aFormatText (this, SW_RES(TXT_FORMAT )), 406 aFormatBox (this, SW_RES(BOX_FORMAT )), 407 aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP )), 408 aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP )), 409 aTextText (this, SW_RES(TXT_TEXT )), 410 aTextEdit (this, SW_RES(EDT_TEXT )), 411 aPosText (this, SW_RES(TXT_POS )), 412 aPosBox (this, SW_RES(BOX_POS )), 413 aNumCaptFL (this, SW_RES(FL_NUMCAPT )), 414 aFtLevel (this, SW_RES(FT_LEVEL )), 415 aLbLevel (this, SW_RES(LB_LEVEL )), 416 aFtDelim (this, SW_RES(FT_SEPARATOR )), 417 aEdDelim (this, SW_RES(ED_SEPARATOR )), 418 aCategoryFL (this, SW_RES(FL_CATEGORY )), 419 aCharStyleFT (this, SW_RES(FT_CHARSTYLE )), 420 aCharStyleLB (this, SW_RES(LB_CHARSTYLE )), 421 aApplyBorderCB (this, SW_RES(CB_APPLYBORDER)), 422 423 sSWTable (SW_RES(STR_TABLE )), 424 sSWFrame (SW_RES(STR_FRAME )), 425 sSWGraphic (SW_RES(STR_GRAPHIC )), 426 sOLE (SW_RES(STR_OLE )), 427 428 sBegin (SW_RESSTR(STR_BEGINNING )), 429 sEnd (SW_RESSTR(STR_END )), 430 sAbove (SW_RESSTR(STR_ABOVE )), 431 sBelow (SW_RESSTR(STR_CP_BELOW )), 432 sNone (SW_RESSTR( STR_CATEGORY_NONE )), 433 434 pMgr (new SwFldMgr()), 435 bHTMLMode(sal_False) 436 { 437 Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() ); 438 aPreview.SetBackground( aBack ); 439 440 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_ABB, sIllustration ); 441 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_TABLE, sTable ); 442 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_FRAME, sText ); 443 SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_DRAWING, sDrawing ); 444 445 sal_uInt16 i, nCount; 446 SwWrtShell *pSh = ::GetActiveWrtShell(); 447 448 // aFormatBox 449 sal_uInt16 nSelFmt = SVX_NUM_ARABIC; 450 if (pSh) 451 { 452 nCount = pMgr->GetFldTypeCount(); 453 SwFieldType* pFldType; 454 for ( i = nCount; i; ) 455 if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() == 456 aCategoryBox.GetText() ) 457 { 458 nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat(); 459 break; 460 } 461 462 ::FillCharStyleListBox( aCharStyleLB, pSh->GetView().GetDocShell(), sal_True, sal_True ); 463 } 464 465 466 nCount = pMgr->GetFormatCount(TYP_SEQFLD, sal_False); 467 for ( i = 0; i < nCount; ++i ) 468 { 469 aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) ); 470 sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i); 471 aFormatBox.SetEntryData( i, reinterpret_cast<void*>(nFmtId) ); 472 if( nFmtId == nSelFmt ) 473 aFormatBox.SelectEntryPos( i ); 474 } 475 476 for (i = 0; i < MAXLEVEL; i++) 477 aLbLevel.InsertEntry(String::CreateFromInt32(i + 1)); 478 479 sal_Unicode nLvl = MAXLEVEL; 480 String sDelim( String::CreateFromAscii( ": " ) ); 481 482 if (pSh) 483 { 484 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType( 485 RES_SETEXPFLD, aCategoryBox.GetText() ); 486 if( pFldType ) 487 { 488 sDelim = pFldType->GetDelimiter(); 489 nLvl = pFldType->GetOutlineLvl(); 490 } 491 } 492 493 aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 ); 494 aEdDelim.SetText( sDelim ); 495 496 aCheckLB.SetHelpId(HID_OPTCAPTION_CLB); 497 498 FreeResource(); 499 500 Link aLk = LINK( this, SwCaptionOptPage, ModifyHdl ); 501 aCategoryBox.SetModifyHdl( aLk ); 502 aNumberingSeparatorED.SetModifyHdl( aLk ); 503 aTextEdit .SetModifyHdl( aLk ); 504 505 aLk = LINK(this, SwCaptionOptPage, SelectHdl); 506 aCategoryBox.SetSelectHdl( aLk ); 507 aFormatBox .SetSelectHdl( aLk ); 508 509 aLbCaptionOrder.SetSelectHdl( LINK(this, SwCaptionOptPage, OrderHdl)); 510 511 aCheckLB.SetSelectHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) ); 512 aCheckLB.SetCheckButtonHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) ); 513 aCheckLB.SetDeselectHdl( LINK(this, SwCaptionOptPage, SaveEntryHdl) ); 514 } 515 516 /*-----------------18.01.97 12.43------------------- 517 518 --------------------------------------------------*/ 519 520 SwCaptionOptPage::~SwCaptionOptPage() 521 { 522 DelUserData(); 523 delete pMgr; 524 } 525 526 /*-----------------18.01.97 12.43------------------- 527 528 --------------------------------------------------*/ 529 530 SfxTabPage* SwCaptionOptPage::Create( Window* pParent, 531 const SfxItemSet& rAttrSet ) 532 { 533 return new SwCaptionOptPage(pParent, rAttrSet ); 534 } 535 536 /*-----------------18.01.97 12.42------------------- 537 538 --------------------------------------------------*/ 539 540 sal_Bool SwCaptionOptPage::FillItemSet( SfxItemSet& ) 541 { 542 sal_Bool bRet = sal_False; 543 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); 544 545 SaveEntry(aCheckLB.FirstSelected()); // Aktuellen Eintrag uebernehmen 546 547 SvLBoxEntry* pEntry = aCheckLB.First(); 548 549 while (pEntry) 550 { 551 InsCaptionOpt* pData = (InsCaptionOpt*)pEntry->GetUserData(); 552 bRet |= pModOpt->SetCapOption(bHTMLMode, pData); 553 pEntry = aCheckLB.Next(pEntry); 554 } 555 556 sal_uInt16 nCheckCount = aCheckLB.GetCheckedEntryCount(); 557 pModOpt->SetInsWithCaption( bHTMLMode, nCheckCount > 0 ); 558 559 sal_Int32 nPos = aLbCaptionOrder.GetSelectEntryPos(); 560 pModOpt->SetCaptionOrderNumberingFirst(nPos == 1 ? sal_True : sal_False ); 561 562 return bRet; 563 } 564 565 /*-----------------18.01.97 12.42------------------- 566 567 --------------------------------------------------*/ 568 569 void SwCaptionOptPage::Reset( const SfxItemSet& rSet) 570 { 571 const SfxPoolItem* pItem; 572 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem)) 573 { 574 bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON); 575 } 576 577 DelUserData(); 578 aCheckLB.GetModel()->Clear(); // remove all entries 579 580 // Writer objects 581 sal_uInt16 nPos = 0; 582 aCheckLB.InsertEntry(sSWTable); 583 SetOptions(nPos++, TABLE_CAP); 584 aCheckLB.InsertEntry(sSWFrame); 585 SetOptions(nPos++, FRAME_CAP); 586 aCheckLB.InsertEntry(sSWGraphic); 587 SetOptions(nPos++, GRAPHIC_CAP); 588 589 // get Productname and -version 590 String sComplete, sWithoutVersion; 591 ::rtl::OUString sTemp; 592 uno::Any aAny = 593 ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ); 594 if ( aAny >>= sTemp ) 595 { 596 sComplete = sTemp; 597 sWithoutVersion = sTemp; 598 aAny = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION ); 599 if ( !( aAny >>= sTemp ) ) 600 { 601 DBG_ERRORFILE( "Couldn't get PRODUCTVERSION variable" ); 602 } 603 else 604 { 605 sComplete += ' '; 606 sComplete += String( sTemp ); 607 } 608 } 609 else 610 { 611 DBG_ERRORFILE( "Couldn't get PRODUCTNAME variable" ); 612 } 613 614 SvObjectServerList aObjS; 615 aObjS.FillInsertObjects(); 616 aObjS.Remove( SvGlobalName( SO3_SW_CLASSID ) ); // remove Writer-ID 617 618 for ( sal_uLong i = 0; i < aObjS.Count(); ++i ) 619 { 620 const SvGlobalName &rOleId = aObjS[i].GetClassName(); 621 const String* pClassName = &aObjS[i].GetHumanName(); 622 if ( rOleId == SvGlobalName( SO3_OUT_CLASSID ) ) 623 pClassName = &sOLE; 624 String sClass( *pClassName ); 625 // don't show product version 626 sClass.SearchAndReplace( sComplete, sWithoutVersion ); 627 aCheckLB.InsertEntry( sClass ); 628 SetOptions( nPos++, OLE_CAP, &rOleId ); 629 } 630 aLbCaptionOrder.SelectEntryPos( 631 SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ? 1 : 0); 632 ModifyHdl(); 633 } 634 635 /*-----------------18.01.97 12.42------------------- 636 637 --------------------------------------------------*/ 638 639 void SwCaptionOptPage::SetOptions(const sal_uInt16 nPos, 640 const SwCapObjType eObjType, const SvGlobalName *pOleId) 641 { 642 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); 643 const InsCaptionOpt* pOpt = pModOpt->GetCapOption(bHTMLMode, eObjType, pOleId); 644 645 if (pOpt) 646 { 647 aCheckLB.SetEntryData(nPos, new InsCaptionOpt(*pOpt)); 648 aCheckLB.CheckEntryPos(nPos, pOpt->UseCaption()); 649 } 650 else 651 aCheckLB.SetEntryData(nPos, new InsCaptionOpt(eObjType, pOleId)); 652 } 653 654 /*-----------------18.01.97 12.42------------------- 655 656 --------------------------------------------------*/ 657 658 void SwCaptionOptPage::DelUserData() 659 { 660 SvLBoxEntry* pEntry = aCheckLB.First(); 661 662 while (pEntry) 663 { 664 delete (InsCaptionOpt*)pEntry->GetUserData(); 665 pEntry->SetUserData(0); 666 pEntry = aCheckLB.Next(pEntry); 667 } 668 } 669 670 /* -----------------26.10.98 11:06------------------- 671 * 672 * --------------------------------------------------*/ 673 674 IMPL_LINK( SwCaptionOptPage, ShowEntryHdl, SvxCheckListBox *, EMPTYARG ) 675 { 676 SvLBoxEntry* pSelEntry = aCheckLB.FirstSelected(); 677 678 if (pSelEntry) 679 { 680 sal_Bool bChecked = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pSelEntry)); 681 682 aSettingsGroupFL.Enable( bChecked ); 683 aCategoryText.Enable( bChecked ); 684 aCategoryBox.Enable( bChecked ); 685 aFormatText.Enable( bChecked ); 686 aFormatBox.Enable( bChecked ); 687 sal_Bool bNumSep = bChecked && aLbCaptionOrder.GetSelectEntryPos() == 1; 688 aNumberingSeparatorED.Enable( bNumSep ); 689 aNumberingSeparatorFT.Enable( bNumSep ); 690 aTextText.Enable( bChecked ); 691 aTextEdit.Enable( bChecked ); 692 aPosText.Enable( bChecked ); 693 aPosBox.Enable( bChecked ); 694 aNumCaptFL.Enable( bChecked ); 695 aFtLevel.Enable( bChecked ); 696 aLbLevel.Enable( bChecked ); 697 aFtDelim.Enable( bChecked ); 698 aEdDelim.Enable( bChecked ); 699 aCategoryFL.Enable( bChecked ); 700 aCharStyleFT.Enable( bChecked ); 701 aCharStyleLB.Enable( bChecked ); 702 aApplyBorderCB.Enable( bChecked ); 703 aPreview.Enable( bChecked ); 704 705 SwWrtShell *pSh = ::GetActiveWrtShell(); 706 707 InsCaptionOpt* pOpt = (InsCaptionOpt*)pSelEntry->GetUserData(); 708 709 aCategoryBox.Clear(); 710 aCategoryBox.InsertEntry( sNone ); 711 if (pSh) 712 { 713 sal_uInt16 nCount = pMgr->GetFldTypeCount(); 714 715 for (sal_uInt16 i = 0; i < nCount; i++) 716 { 717 SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i ); 718 if( pType->Which() == RES_SETEXPFLD && 719 ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) 720 aCategoryBox.InsertEntry(SwBoxEntry(pType->GetName())); 721 } 722 } 723 else 724 { 725 aCategoryBox.InsertEntry(SwBoxEntry(sIllustration)); 726 aCategoryBox.InsertEntry(SwBoxEntry(sTable)); 727 aCategoryBox.InsertEntry(SwBoxEntry(sText)); 728 aCategoryBox.InsertEntry(SwBoxEntry(sDrawing)); 729 } 730 731 if(pOpt->GetCategory().Len()) 732 aCategoryBox.SetText(pOpt->GetCategory()); 733 else 734 aCategoryBox.SetText( sNone ); 735 if (pOpt->GetCategory().Len() && 736 aCategoryBox.GetEntryPos(pOpt->GetCategory()) == COMBOBOX_ENTRY_NOTFOUND) 737 aCategoryBox.InsertEntry(pOpt->GetCategory()); 738 if (!aCategoryBox.GetText().Len()) 739 { 740 sal_uInt16 nPos = 0; 741 switch(pOpt->GetObjType()) 742 { 743 case OLE_CAP: 744 case GRAPHIC_CAP: nPos = 1; break; 745 case TABLE_CAP: nPos = 2; break; 746 case FRAME_CAP: nPos = 3; break; 747 } 748 aCategoryBox.SetText(aCategoryBox.GetEntry(nPos).GetName()); 749 } 750 751 for (sal_uInt16 i = 0; i < aFormatBox.GetEntryCount(); i++) 752 { 753 if (pOpt->GetNumType() == (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(i)) 754 { 755 aFormatBox.SelectEntryPos(i); 756 break; 757 } 758 } 759 aTextEdit.SetText(pOpt->GetCaption()); 760 761 aPosBox.Clear(); 762 switch (pOpt->GetObjType()) 763 { 764 case GRAPHIC_CAP: 765 case TABLE_CAP: 766 case OLE_CAP: 767 aPosBox.InsertEntry(sAbove); 768 aPosBox.InsertEntry(sBelow); 769 break; 770 case FRAME_CAP: 771 aPosBox.InsertEntry(sBegin); 772 aPosBox.InsertEntry(sEnd); 773 break; 774 } 775 aPosBox.SelectEntryPos(pOpt->GetPos()); 776 aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP && 777 pOpt->GetObjType() != OLE_CAP && 778 aPosText.IsEnabled() ); 779 aPosBox.SelectEntryPos(pOpt->GetPos()); 780 781 sal_uInt16 nLevelPos = ( pOpt->GetLevel() < MAXLEVEL ) ? pOpt->GetLevel() + 1 : 0; 782 aLbLevel.SelectEntryPos( nLevelPos ); 783 aEdDelim.SetText(pOpt->GetSeparator()); 784 aNumberingSeparatorED.SetText( pOpt->GetNumSeparator() ); 785 if(pOpt->GetCharacterStyle().Len()) 786 aCharStyleLB.SelectEntry( pOpt->GetCharacterStyle() ); 787 else 788 aCharStyleLB.SelectEntryPos( 0 ); 789 aApplyBorderCB.Enable( aCategoryBox.IsEnabled() && 790 pOpt->GetObjType() != TABLE_CAP && pOpt->GetObjType() != FRAME_CAP ); 791 aApplyBorderCB.Check( pOpt->CopyAttributes() ); 792 } 793 794 ModifyHdl(); 795 796 return 0; 797 } 798 799 /* -----------------26.10.98 11:06------------------- 800 * 801 * --------------------------------------------------*/ 802 803 IMPL_LINK( SwCaptionOptPage, SaveEntryHdl, SvxCheckListBox *, EMPTYARG ) 804 { 805 SvLBoxEntry* pEntry = aCheckLB.GetHdlEntry(); 806 807 if (pEntry) // Alles speichern 808 SaveEntry(pEntry); 809 810 return 0; 811 } 812 813 /* -----------------05.11.98 16:23------------------- 814 * 815 * --------------------------------------------------*/ 816 817 void SwCaptionOptPage::SaveEntry(SvLBoxEntry* pEntry) 818 { 819 if (pEntry) 820 { 821 InsCaptionOpt* pOpt = (InsCaptionOpt*)pEntry->GetUserData(); 822 823 pOpt->UseCaption() = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pEntry)); 824 String aName( aCategoryBox.GetText() ); 825 if(aName == sNone) 826 pOpt->SetCategory(aEmptyStr); 827 else 828 { 829 aName.EraseLeadingChars (' '); 830 aName.EraseTrailingChars(' '); 831 pOpt->SetCategory(aName); 832 } 833 pOpt->SetNumType((sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(aFormatBox.GetSelectEntryPos())); 834 pOpt->SetCaption(aTextEdit.IsEnabled() ? aTextEdit.GetText() : aEmptyStr ); 835 pOpt->SetPos(aPosBox.GetSelectEntryPos()); 836 sal_uInt16 nPos = aLbLevel.GetSelectEntryPos(); 837 sal_uInt16 nLevel = ( nPos > 0 && nPos != LISTBOX_ENTRY_NOTFOUND ) ? nPos - 1 : MAXLEVEL; 838 pOpt->SetLevel(nLevel); 839 pOpt->SetSeparator(aEdDelim.GetText()); 840 pOpt->SetNumSeparator( aNumberingSeparatorED.GetText()); 841 if(!aCharStyleLB.GetSelectEntryPos()) 842 pOpt->SetCharacterStyle(aEmptyStr); 843 else 844 pOpt->SetCharacterStyle(aCharStyleLB.GetSelectEntry()); 845 pOpt->CopyAttributes() = aApplyBorderCB.IsChecked(); 846 } 847 } 848 849 /* -----------------26.10.98 11:06------------------- 850 * 851 * --------------------------------------------------*/ 852 853 IMPL_LINK( SwCaptionOptPage, ModifyHdl, Edit *, EMPTYARG ) 854 { 855 String sFldTypeName = aCategoryBox.GetText(); 856 /* 857 SwFieldType* pType = sFldTypeName.Len() ? pMgr->GetFldType(RES_SETEXPFLD, sFldTypeName) : 0; 858 859 ((SfxSingleTabDialog*)GetParent())->GetOKButton()->Enable( (!pType || ((SwSetExpFieldType*)pType)->GetType() == GSE_SEQ) 860 && sFldTypeName.Len() != 0 ); 861 */ 862 SfxSingleTabDialog *pDlg = (SfxSingleTabDialog *)GetParent(); 863 PushButton *pBtn = pDlg->GetOKButton(); 864 if (pBtn) 865 pBtn->Enable(sFldTypeName.Len() != 0); 866 sal_Bool bEnable = aCategoryBox.IsEnabled() && sFldTypeName != sNone; 867 868 aFormatText.Enable(bEnable); 869 aFormatBox.Enable(bEnable); 870 aTextText.Enable(bEnable); 871 aTextEdit.Enable(bEnable); 872 873 DrawSample(); 874 return 0; 875 } 876 877 /* -----------------26.10.98 10:58------------------- 878 * 879 * --------------------------------------------------*/ 880 881 IMPL_LINK_INLINE_START( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG ) 882 { 883 DrawSample(); 884 return 0; 885 } 886 IMPL_LINK_INLINE_END( SwCaptionOptPage, SelectHdl, ListBox *, EMPTYARG ) 887 /*-- 02.11.2007 10:00:36--------------------------------------------------- 888 889 -----------------------------------------------------------------------*/ 890 IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox ) 891 { 892 DrawSample(); 893 sal_Int32 nPos = pBox->GetSelectEntryPos(); 894 aNumberingSeparatorFT.Enable( nPos == 1 ); 895 aNumberingSeparatorED.Enable( nPos == 1 ); 896 return 0; 897 } 898 /* -----------------26.10.98 10:58------------------- 899 * 900 * --------------------------------------------------*/ 901 902 void SwCaptionOptPage::DrawSample() 903 { 904 String aStr; 905 906 if( aCategoryBox.GetText() != sNone) 907 { 908 //#i61007# order of captions 909 bool bOrderNumberingFirst = aLbCaptionOrder.GetSelectEntryPos() == 1; 910 // Nummer 911 sal_uInt16 nNumFmt = (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData( 912 aFormatBox.GetSelectEntryPos() ); 913 if( SVX_NUM_NUMBER_NONE != nNumFmt ) 914 { 915 //#i61007# order of captions 916 if( !bOrderNumberingFirst ) 917 { 918 // Kategorie 919 aStr += aCategoryBox.GetText(); 920 aStr += ' '; 921 } 922 923 SwWrtShell *pSh = ::GetActiveWrtShell(); 924 String sFldTypeName( aCategoryBox.GetText() ); 925 if (pSh) 926 { 927 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType( 928 RES_SETEXPFLD, sFldTypeName ); 929 if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL ) 930 { 931 sal_uInt8 nLvl = pFldType->GetOutlineLvl(); 932 SwNumberTree::tNumberVector aNumVector; 933 for( sal_uInt8 i = 0; i <= nLvl; ++i ) 934 aNumVector.push_back(1); 935 936 String sNumber( pSh->GetOutlineNumRule()->MakeNumString( 937 aNumVector, sal_False )); 938 if( sNumber.Len() ) 939 (aStr += sNumber) += pFldType->GetDelimiter(); 940 } 941 } 942 943 switch( nNumFmt ) 944 { 945 case SVX_NUM_CHARS_UPPER_LETTER: aStr += 'A'; break; 946 case SVX_NUM_CHARS_UPPER_LETTER_N: aStr += 'A'; break; 947 case SVX_NUM_CHARS_LOWER_LETTER: aStr += 'a'; break; 948 case SVX_NUM_CHARS_LOWER_LETTER_N: aStr += 'a'; break; 949 case SVX_NUM_ROMAN_UPPER: aStr += 'I'; break; 950 case SVX_NUM_ROMAN_LOWER: aStr += 'i'; break; 951 //case ARABIC: 952 default: aStr += '1'; break; 953 } 954 } 955 //#i61007# order of captions 956 if( bOrderNumberingFirst ) 957 { 958 aStr += aNumberingSeparatorED.GetText(); 959 aStr += aCategoryBox.GetText(); 960 } 961 aStr += aTextEdit.GetText(); 962 } 963 aPreview.SetPreviewText( aStr ); 964 } 965 966 /*------------------------------------------------------------------------ 967 Beschreibung: ComboBox ohne Spaces 968 ------------------------------------------------------------------------*/ 969 970 void CaptionComboBox::KeyInput(const KeyEvent& rEvt) 971 { 972 if( rEvt.GetKeyCode().GetCode() != KEY_SPACE ) 973 SwComboBox::KeyInput(rEvt); 974 } 975 976 977 978