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 36 #ifndef _VIEW_HXX 37 #include <view.hxx> 38 #endif 39 #include <wrtsh.hxx> 40 #include <cption.hxx> 41 #include <fldmgr.hxx> 42 #include <expfld.hxx> 43 #include <numrule.hxx> 44 #include <poolfmt.hxx> 45 #include <docsh.hxx> 46 #include <frmfmt.hxx> 47 #include <calc.hxx> 48 #include <uitool.hxx> 49 #include <doc.hxx> 50 #include <modcfg.hxx> 51 #include <swmodule.hxx> 52 #include <com/sun/star/frame/XStorable.hpp> 53 #include <com/sun/star/text/GraphicCrop.hpp> 54 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> 55 #include <com/sun/star/text/XTextTableCursor.hpp> 56 #include <com/sun/star/text/XTextTablesSupplier.hpp> 57 #include <com/sun/star/text/TableColumnSeparator.hpp> 58 #include <com/sun/star/text/XTextTable.hpp> 59 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> 60 #include <com/sun/star/text/XTextEmbeddedObject.hpp> 61 #include <com/sun/star/text/XTextFramesSupplier.hpp> 62 #include <com/sun/star/text/XTextFrame.hpp> 63 64 #ifndef _FRMUI_HRC 65 #include <frmui.hrc> 66 #endif 67 #ifndef _CPTION_HRC 68 #include <cption.hrc> 69 #endif 70 #include <SwStyleNameMapper.hxx> 71 using namespace ::com::sun::star; 72 73 extern String* GetOldGrfCat(); 74 extern String* GetOldTabCat(); 75 extern String* GetOldFrmCat(); 76 extern String* GetOldDrwCat(); 77 78 class SwSequenceOptionDialog : public SvxStandardDialog 79 { 80 FixedLine aFlHeader; 81 FixedText aFtLevel; 82 ListBox aLbLevel; 83 FixedText aFtDelim; 84 Edit aEdDelim; 85 86 FixedLine aFlCatAndFrame; 87 FixedText aFtCharStyle; 88 ListBox aLbCharStyle; 89 CheckBox aApplyBorderAndShadowCB; 90 91 //#i61007# order of captions 92 FixedLine aFlCaptionOrder; 93 FixedText aFtCaptionOrder; 94 ListBox aLbCaptionOrder; 95 96 OKButton aOKButton; 97 CancelButton aCancelButton; 98 HelpButton aHelpButton; 99 100 SwView& rView; 101 String aFldTypeName; 102 103 public: 104 SwSequenceOptionDialog( Window *pParent, SwView &rV, 105 const String& rSeqFldType ); 106 virtual ~SwSequenceOptionDialog(); 107 virtual void Apply(); 108 109 bool IsApplyBorderAndShadow( void ) { return aApplyBorderAndShadowCB.IsChecked(); } 110 void SetApplyBorderAndShadow( bool bSet ) { aApplyBorderAndShadowCB.Check(bSet); } 111 112 //#i61007# order of captions 113 bool IsOrderNumberingFirst() const {return aLbCaptionOrder.GetSelectEntryPos() == 1;} 114 void SetOrderNumberingFirst(bool bSet) { aLbCaptionOrder.SelectEntryPos( bSet ? 1 : 0 ); } 115 116 void SetCharacterStyle(const String& rStyle); 117 String GetCharacterStyle() const; 118 }; 119 120 SwCaptionDialog::SwCaptionDialog( Window *pParent, SwView &rV ) : 121 122 SvxStandardDialog( pParent, SW_RES(DLG_CAPTION) ), 123 124 aTextText (this, SW_RES(TXT_TEXT )), 125 aTextEdit (this, SW_RES(EDT_TEXT )), 126 aSettingsFL (this, SW_RES(FL_SETTINGS)), 127 aCategoryText (this, SW_RES(TXT_CATEGORY)), 128 aCategoryBox (this, SW_RES(BOX_CATEGORY)), 129 aFormatText (this, SW_RES(TXT_FORMAT )), 130 aFormatBox (this, SW_RES(BOX_FORMAT )), 131 aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP )), 132 aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP )), 133 aSepText (this, SW_RES(TXT_SEP )), 134 aSepEdit (this, SW_RES(EDT_SEP )), 135 aPosText (this, SW_RES(TXT_POS )), 136 aPosBox (this, SW_RES(BOX_POS )), 137 aOKButton (this, SW_RES(BTN_OK )), 138 aCancelButton (this, SW_RES(BTN_CANCEL )), 139 aHelpButton (this, SW_RES(BTN_HELP )), 140 aAutoCaptionButton(this, SW_RES(BTN_AUTOCAPTION)), 141 aOptionButton (this, SW_RES(BTN_OPTION )), 142 sNone( SW_RES( STR_CATEGORY_NONE )), 143 aPrevWin (this, SW_RES(WIN_SAMPLE )), 144 rView( rV ), 145 pMgr( new SwFldMgr(rView.GetWrtShellPtr()) ), 146 bCopyAttributes( sal_False ), 147 bOrderNumberingFirst( SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ) 148 { 149 //#i61007# order of captions 150 if( bOrderNumberingFirst ) 151 ApplyCaptionOrder(); 152 SwWrtShell &rSh = rView.GetWrtShell(); 153 uno::Reference< frame::XModel > xModel = rView.GetDocShell()->GetBaseModel(); 154 155 eType = rSh.GetSelectionType(); 156 if ( eType & nsSelectionType::SEL_OLE ) 157 { 158 eType = nsSelectionType::SEL_GRF; 159 uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); 160 xNameAccess = xObjs->getEmbeddedObjects(); 161 } 162 163 Link aLk = LINK( this, SwCaptionDialog, ModifyHdl ); 164 aCategoryBox.SetModifyHdl( aLk ); 165 aTextEdit .SetModifyHdl( aLk ); 166 aNumberingSeparatorED.SetModifyHdl ( aLk ); 167 aSepEdit .SetModifyHdl( aLk ); 168 169 aLk = LINK(this, SwCaptionDialog, SelectHdl); 170 aCategoryBox.SetSelectHdl( aLk ); 171 aFormatBox .SetSelectHdl( aLk ); 172 aOptionButton.SetClickHdl( LINK( this, SwCaptionDialog, OptionHdl ) ); 173 aAutoCaptionButton.SetClickHdl(LINK(this, SwCaptionDialog, CaptionHdl)); 174 175 aCategoryBox.InsertEntry( sNone ); 176 sal_uInt16 i, nCount = pMgr->GetFldTypeCount(); 177 for (i = 0; i < nCount; i++) 178 { 179 SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i ); 180 if( pType->Which() == RES_SETEXPFLD && 181 ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) 182 aCategoryBox.InsertEntry(pType->GetName()); 183 } 184 185 String* pString = 0; 186 sal_uInt16 nPoolId = 0; 187 if (eType & nsSelectionType::SEL_GRF) 188 { 189 nPoolId = RES_POOLCOLL_LABEL_ABB; 190 pString = ::GetOldGrfCat(); 191 bCopyAttributes = sal_True; 192 sObjectName = rSh.GetFlyName(); 193 //if not OLE 194 if(!xNameAccess.is()) 195 { 196 uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); 197 xNameAccess = xGraphics->getGraphicObjects(); 198 } 199 200 } 201 else if( eType & nsSelectionType::SEL_TBL ) 202 { 203 nPoolId = RES_POOLCOLL_LABEL_TABLE; 204 pString = ::GetOldTabCat(); 205 uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY); 206 xNameAccess = xTables->getTextTables(); 207 sObjectName = rSh.GetTableFmt()->GetName(); 208 } 209 else if( eType & nsSelectionType::SEL_FRM ) 210 { 211 nPoolId = RES_POOLCOLL_LABEL_FRAME; 212 pString = ::GetOldFrmCat(); 213 uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); 214 xNameAccess = xFrms->getTextFrames(); 215 sObjectName = rSh.GetFlyName(); 216 } 217 else if( eType == nsSelectionType::SEL_TXT ) 218 { 219 nPoolId = RES_POOLCOLL_LABEL_FRAME; 220 pString = ::GetOldFrmCat(); 221 } 222 else if( eType & nsSelectionType::SEL_DRW ) 223 { 224 nPoolId = RES_POOLCOLL_LABEL_DRAWING; 225 pString = ::GetOldDrwCat(); 226 } 227 if( nPoolId ) 228 { 229 if( pString && pString->Len()) 230 aCategoryBox.SetText( *pString ); 231 else 232 aCategoryBox.SetText( 233 SwStyleNameMapper::GetUIName( nPoolId, aEmptyStr )); 234 } 235 236 // aFormatBox 237 sal_uInt16 nSelFmt = SVX_NUM_ARABIC; 238 nCount = pMgr->GetFldTypeCount(); 239 SwFieldType* pFldType; 240 for ( i = nCount; i; ) 241 if( ( pFldType = pMgr->GetFldType(USHRT_MAX, --i))->GetName() == 242 aCategoryBox.GetText() ) 243 { 244 nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat(); 245 break; 246 } 247 248 249 nCount = pMgr->GetFormatCount(TYP_SEQFLD, sal_False); 250 for ( i = 0; i < nCount; ++i ) 251 { 252 aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) ); 253 sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i); 254 aFormatBox.SetEntryData( i, reinterpret_cast<void*>( nFmtId ) ); 255 if( nFmtId == nSelFmt ) 256 aFormatBox.SelectEntryPos( i ); 257 } 258 259 // aPosBox 260 switch (eType) 261 { 262 case nsSelectionType::SEL_GRF: 263 case nsSelectionType::SEL_TBL: 264 case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM: 265 case nsSelectionType::SEL_TBL | nsSelectionType::SEL_TXT: 266 case nsSelectionType::SEL_TBL | nsSelectionType::SEL_NUM | nsSelectionType::SEL_TXT: 267 case nsSelectionType::SEL_DRW: 268 case nsSelectionType::SEL_DRW | nsSelectionType::SEL_BEZ: 269 aPosBox.InsertEntry(SW_RESSTR(STR_ABOVE)); 270 aPosBox.InsertEntry(SW_RESSTR(STR_CP_BELOW)); 271 break; 272 case nsSelectionType::SEL_FRM: 273 case nsSelectionType::SEL_TXT: 274 aPosBox.InsertEntry(SW_RESSTR(STR_BEGINNING)); 275 aPosBox.InsertEntry(SW_RESSTR(STR_END )); 276 break; 277 } 278 aPosBox.SelectEntryPos(1); 279 if (eType & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_DRW)) 280 { 281 aPosText.Enable( sal_False ); 282 aPosBox.Enable( sal_False ); 283 } 284 285 aCategoryBox.GetModifyHdl().Call(&aCategoryBox); 286 287 FreeResource(); 288 289 CheckButtonWidth(); 290 aTextEdit.GrabFocus(); 291 DrawSample(); 292 } 293 294 void SwCaptionDialog::Apply() 295 { 296 InsCaptionOpt aOpt; 297 aOpt.UseCaption() = sal_True; 298 String aName( aCategoryBox.GetText() ); 299 if ( aName == sNone ) 300 aOpt.SetCategory( aEmptyStr ); 301 else 302 { 303 aName.EraseLeadingChars( ' ' ); 304 aName.EraseTrailingChars( ' ' ); 305 aOpt.SetCategory( aName ); 306 } 307 aOpt.SetNumType( (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData( aFormatBox.GetSelectEntryPos() ) ); 308 aOpt.SetSeparator( aSepEdit.IsEnabled() ? aSepEdit.GetText() : String() ); 309 aOpt.SetNumSeparator( aNumberingSeparatorED.GetText() ); 310 aOpt.SetCaption( aTextEdit.GetText() ); 311 aOpt.SetPos( aPosBox.GetSelectEntryPos() ); 312 aOpt.IgnoreSeqOpts() = sal_True; 313 aOpt.CopyAttributes() = bCopyAttributes; 314 aOpt.SetCharacterStyle( sCharacterStyle ); 315 rView.InsertCaption( &aOpt ); 316 } 317 318 IMPL_LINK_INLINE_START( SwCaptionDialog, OptionHdl, Button*, pButton ) 319 { 320 String sFldTypeName = aCategoryBox.GetText(); 321 if(sFldTypeName == sNone) 322 sFldTypeName = aEmptyStr; 323 SwSequenceOptionDialog aDlg( pButton, rView, sFldTypeName ); 324 aDlg.SetApplyBorderAndShadow(bCopyAttributes); 325 aDlg.SetCharacterStyle( sCharacterStyle ); 326 aDlg.SetOrderNumberingFirst( bOrderNumberingFirst ); 327 aDlg.Execute(); 328 bCopyAttributes = aDlg.IsApplyBorderAndShadow(); 329 sCharacterStyle = aDlg.GetCharacterStyle(); 330 //#i61007# order of captions 331 if( bOrderNumberingFirst != aDlg.IsOrderNumberingFirst() ) 332 { 333 bOrderNumberingFirst = aDlg.IsOrderNumberingFirst(); 334 SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(bOrderNumberingFirst); 335 ApplyCaptionOrder(); 336 } 337 DrawSample(); 338 return 0; 339 } 340 IMPL_LINK_INLINE_END( SwCaptionDialog, OptionHdl, Button*, EMPTYARG ) 341 342 IMPL_LINK_INLINE_START( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG ) 343 { 344 DrawSample(); 345 return 0; 346 } 347 IMPL_LINK_INLINE_END( SwCaptionDialog, SelectHdl, ListBox *, EMPTYARG ) 348 349 350 351 IMPL_LINK( SwCaptionDialog, ModifyHdl, Edit *, EMPTYARG ) 352 { 353 SwWrtShell &rSh = rView.GetWrtShell(); 354 String sFldTypeName = aCategoryBox.GetText(); 355 sal_Bool bCorrectFldName = sFldTypeName.Len() > 0; 356 sal_Bool bNone = sFldTypeName == sNone; 357 SwFieldType* pType = (bCorrectFldName && !bNone) 358 ? rSh.GetFldType( RES_SETEXPFLD, sFldTypeName ) 359 : 0; 360 aOKButton.Enable( bCorrectFldName && 361 (!pType || 362 ((SwSetExpFieldType*)pType)->GetType() == nsSwGetSetExpType::GSE_SEQ) 363 && 0 != sFldTypeName.Len() ); 364 aOptionButton.Enable( aOKButton.IsEnabled() && !bNone ); 365 aFormatText.Enable( !bNone ); 366 aFormatBox.Enable( !bNone ); 367 aSepText.Enable( !bNone ); 368 aSepEdit.Enable( !bNone ); 369 DrawSample(); 370 return 0; 371 } 372 373 IMPL_LINK(SwCaptionDialog, CaptionHdl, PushButton*, EMPTYARG) 374 { 375 SfxItemSet aSet( rView.GetDocShell()->GetDoc()->GetAttrPool() ); 376 SwCaptionOptDlg aDlg( this, aSet ); 377 aDlg.Execute(); 378 379 return 0; 380 } 381 382 void SwCaptionDialog::DrawSample() 383 { 384 String aStr; 385 String sCaption = aTextEdit.GetText(); 386 387 // Nummer 388 String sFldTypeName = aCategoryBox.GetText(); 389 sal_Bool bNone = sFldTypeName == sNone; 390 if( !bNone ) 391 { 392 sal_uInt16 nNumFmt = (sal_uInt16)(sal_uIntPtr)aFormatBox.GetEntryData( 393 aFormatBox.GetSelectEntryPos() ); 394 if( SVX_NUM_NUMBER_NONE != nNumFmt ) 395 { 396 // Kategorie 397 //#i61007# order of captions 398 if( !bOrderNumberingFirst ) 399 { 400 aStr += sFldTypeName; 401 if ( aStr.Len() > 0 ) 402 aStr += ' '; 403 } 404 405 SwWrtShell &rSh = rView.GetWrtShell(); 406 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 407 RES_SETEXPFLD, sFldTypeName ); 408 if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL ) 409 { 410 sal_Int8 nLvl = pFldType->GetOutlineLvl(); 411 SwNumberTree::tNumberVector aNumVector; 412 for( sal_Int8 i = 0; i <= nLvl; ++i ) 413 aNumVector.push_back(1); 414 415 String sNumber( rSh.GetOutlineNumRule()-> 416 MakeNumString(aNumVector, sal_False )); 417 if( sNumber.Len() ) 418 (aStr += sNumber) += pFldType->GetDelimiter(); 419 } 420 421 switch( nNumFmt ) 422 { 423 case SVX_NUM_CHARS_UPPER_LETTER: aStr += 'A'; break; 424 case SVX_NUM_CHARS_UPPER_LETTER_N: aStr += 'A'; break; 425 case SVX_NUM_CHARS_LOWER_LETTER: aStr += 'a'; break; 426 case SVX_NUM_CHARS_LOWER_LETTER_N: aStr += 'a'; break; 427 case SVX_NUM_ROMAN_UPPER: aStr += 'I'; break; 428 case SVX_NUM_ROMAN_LOWER: aStr += 'i'; break; 429 //case ARABIC: 430 default: aStr += '1'; break; 431 } 432 //#i61007# order of captions 433 if( bOrderNumberingFirst ) 434 { 435 aStr += aNumberingSeparatorED.GetText(); 436 aStr += sFldTypeName; 437 } 438 439 } 440 if( sCaption.Len() > 0 ) 441 { 442 aStr += aSepEdit.GetText(); 443 } 444 } 445 aStr += sCaption; 446 // do preview! 447 aPrevWin.SetPreviewText( aStr ); 448 } 449 450 void SwCaptionDialog::CheckButtonWidth() 451 { 452 // check if the text of the AutoCaption button is to wide 453 const long nOffset = 10; 454 String sText = aAutoCaptionButton.GetText(); 455 long nTxtW = aAutoCaptionButton.GetTextWidth( sText ); 456 if ( sText.Search( '~' ) == STRING_NOTFOUND ) 457 nTxtW += nOffset; 458 long nBtnW = aAutoCaptionButton.GetSizePixel().Width(); 459 if ( nTxtW > nBtnW ) 460 { 461 // then broaden all buttons 462 Size aNewSize; 463 long nDelta = Max( ( nTxtW - nBtnW ), nOffset ); 464 Button* pBtns[] = 465 { 466 &aOKButton, &aCancelButton, &aHelpButton, &aAutoCaptionButton, &aOptionButton 467 }; 468 Button** pCurrent = pBtns; 469 for ( sal_uInt32 i = 0; i < sizeof( pBtns ) / sizeof( pBtns[ 0 ] ); ++i, ++pCurrent ) 470 { 471 aNewSize = (*pCurrent)->GetSizePixel(); 472 aNewSize.Width() += nDelta; 473 (*pCurrent)->SetSizePixel( aNewSize ); 474 } 475 // and the dialog 476 aNewSize = GetOutputSizePixel(); 477 aNewSize.Width() += nDelta; 478 SetOutputSizePixel( aNewSize ); 479 } 480 } 481 482 SwCaptionDialog::~SwCaptionDialog() 483 { 484 delete pMgr; 485 } 486 /* */ 487 488 489 SwSequenceOptionDialog::SwSequenceOptionDialog( Window *pParent, SwView &rV, 490 const String& rSeqFldType ) 491 : SvxStandardDialog( pParent, SW_RES(DLG_SEQUENCE_OPTION) ), 492 aFlHeader (this, SW_RES(FL_HEADER )), 493 aFtLevel (this, SW_RES(FT_LEVEL )), 494 aLbLevel (this, SW_RES(LB_LEVEL )), 495 aFtDelim (this, SW_RES(FT_SEPARATOR )), 496 aEdDelim (this, SW_RES(ED_SEPARATOR )), 497 aFlCatAndFrame (this, SW_RES(FL_CATANDFRAME)), 498 aFtCharStyle (this, SW_RES(FT_CHARSTYLE )), 499 aLbCharStyle (this, SW_RES(LB_CHARSTYLE )), 500 aApplyBorderAndShadowCB(this, SW_RES(CB_APPLYBAS)), 501 aFlCaptionOrder(this, SW_RES( FL_ORDER )), //#i61007# order of captions 502 aFtCaptionOrder(this, SW_RES( FT_ORDER )), 503 aLbCaptionOrder(this, SW_RES( LB_ORDER )), 504 aOKButton (this, SW_RES(BTN_OK )), 505 aCancelButton (this, SW_RES(BTN_CANCEL )), 506 aHelpButton (this, SW_RES(BTN_HELP )), 507 508 rView( rV ), 509 aFldTypeName( rSeqFldType ) 510 { 511 FreeResource(); 512 SwWrtShell &rSh = rView.GetWrtShell(); 513 514 for( sal_uInt16 n = 0; n < MAXLEVEL; ++n ) 515 aLbLevel.InsertEntry( String::CreateFromInt32(n+1) ); 516 517 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 518 RES_SETEXPFLD, aFldTypeName ); 519 520 sal_Unicode nLvl = MAXLEVEL; 521 String sDelim( String::CreateFromAscii( ": " ) ); 522 if( pFldType ) 523 { 524 sDelim = pFldType->GetDelimiter(); 525 nLvl = pFldType->GetOutlineLvl(); 526 } 527 528 aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 ); 529 aEdDelim.SetText( sDelim ); 530 531 ::FillCharStyleListBox( aLbCharStyle, rView.GetDocShell(), sal_True, sal_True ); 532 aLbCharStyle.SelectEntryPos( 0 ); 533 } 534 535 SwSequenceOptionDialog::~SwSequenceOptionDialog() 536 { 537 } 538 539 void SwSequenceOptionDialog::Apply() 540 { 541 SwWrtShell &rSh = rView.GetWrtShell(); 542 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)rSh.GetFldType( 543 RES_SETEXPFLD, aFldTypeName ); 544 545 sal_Int8 nLvl = (sal_Int8)( aLbLevel.GetSelectEntryPos() - 1); 546 sal_Unicode cDelim = aEdDelim.GetText().GetChar(0); 547 548 sal_Bool bUpdate = sal_True; 549 if( pFldType ) 550 { 551 pFldType->SetDelimiter( cDelim ); 552 pFldType->SetOutlineLvl( nLvl ); 553 } 554 else if( aFldTypeName.Len() && nLvl < MAXLEVEL ) 555 { 556 // dann muessen wir das mal einfuegen 557 SwSetExpFieldType aFldType( rSh.GetDoc(), aFldTypeName, nsSwGetSetExpType::GSE_SEQ ); 558 aFldType.SetDelimiter( cDelim ); 559 aFldType.SetOutlineLvl( nLvl ); 560 rSh.InsertFldType( aFldType ); 561 } 562 else 563 bUpdate = sal_False; 564 565 if( bUpdate ) 566 rSh.UpdateExpFlds(); 567 } 568 569 /*-- 24.08.2004 16:13:53--------------------------------------------------- 570 571 -----------------------------------------------------------------------*/ 572 String SwSequenceOptionDialog::GetCharacterStyle() const 573 { 574 String sRet; 575 if(aLbCharStyle.GetSelectEntryPos()) 576 sRet = aLbCharStyle.GetSelectEntry(); 577 return sRet; 578 } 579 580 /*-- 24.08.2004 16:14:00--------------------------------------------------- 581 582 -----------------------------------------------------------------------*/ 583 void SwSequenceOptionDialog::SetCharacterStyle(const String& rStyle) 584 { 585 aLbCharStyle.SelectEntryPos(0); 586 aLbCharStyle.SelectEntry(rStyle); 587 } 588 589 long SwCaptionDialog::CategoryBox::PreNotify( NotifyEvent& rNEvt ) 590 { 591 long nHandled = 0; 592 if( rNEvt.GetType() == EVENT_KEYINPUT && 593 rNEvt.GetKeyEvent()->GetCharCode() ) 594 { 595 const KeyEvent* pEvent = rNEvt.GetKeyEvent(); 596 const KeyCode& rKeyCode = pEvent->GetKeyCode(); 597 sal_uInt16 nTmpCode = rKeyCode.GetFullCode() & ~KEY_ALLMODTYPE; 598 599 if(nTmpCode != KEY_BACKSPACE && nTmpCode != KEY_RETURN 600 && nTmpCode != KEY_TAB && nTmpCode != KEY_ESCAPE) 601 { 602 String sKey( pEvent->GetCharCode() ), sName( GetText() ); 603 Selection aSel( GetSelection() ); 604 aSel.Justify(); 605 if( aSel.Len() ) 606 sName.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() ); 607 sName.Insert( sKey, (xub_StrLen)aSel.Min() ); 608 if( !SwCalc::IsValidVarName( sName )) 609 nHandled = 1; 610 } 611 } 612 if(!nHandled) 613 nHandled = ComboBox::PreNotify( rNEvt ); 614 return nHandled; 615 } 616 /*-- 01.11.2007 10:45:51--------------------------------------------------- 617 //#i61007# order of captions 618 -----------------------------------------------------------------------*/ 619 void lcl_MoveH( Window& rWin, sal_Int32 nMove ) 620 { 621 Point aPos( rWin.GetPosPixel() ); 622 aPos.Y() += nMove; 623 rWin.SetPosPixel(aPos); 624 } 625 void SwCaptionDialog::ApplyCaptionOrder() 626 { 627 //have the settings changed? 628 bool bVisible = aNumberingSeparatorED.IsVisible() != 0; 629 if( bOrderNumberingFirst != bVisible ) 630 { 631 sal_Int32 nDiff = aPosBox.GetPosPixel().Y() - aSepEdit.GetPosPixel().Y(); 632 633 aNumberingSeparatorFT.Show( bOrderNumberingFirst ); 634 aNumberingSeparatorED.Show( bOrderNumberingFirst ); 635 if( !bOrderNumberingFirst ) 636 { 637 nDiff = -nDiff; 638 } 639 lcl_MoveH( aCategoryText, 2 * nDiff); 640 lcl_MoveH( aFormatText, -nDiff ); 641 lcl_MoveH( aFormatBox, -nDiff ); 642 lcl_MoveH( aCategoryBox, 2 * nDiff); 643 lcl_MoveH( aSepText, nDiff ); 644 lcl_MoveH( aSepEdit, nDiff ); 645 lcl_MoveH( aPosText, nDiff ); 646 lcl_MoveH( aPosBox, nDiff ); 647 lcl_MoveH( aPrevWin, nDiff ); 648 Size aDlgSize( GetSizePixel() ); 649 aDlgSize.Height() += nDiff; 650 SetSizePixel( aDlgSize ); 651 } 652 } 653