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_cui.hxx" 26 27 // include --------------------------------------------------------------- 28 #include <tools/shl.hxx> 29 #include <tools/urlobj.hxx> 30 #include <vcl/msgbox.hxx> 31 #include <unotools/pathoptions.hxx> 32 #include <sfx2/app.hxx> 33 #include <sfx2/module.hxx> 34 #include <sfx2/filedlghelper.hxx> 35 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" 36 37 #define _SVX_TPLNEDEF_CXX 38 39 #include <cuires.hrc> 40 #include "tabline.hrc" 41 //#include "dlgname.hrc" 42 #include "helpid.hrc" 43 44 #include "svx/xattr.hxx" 45 #include <svx/xpool.hxx> 46 #include <svx/xtable.hxx> 47 48 #include "svx/drawitem.hxx" 49 #include "cuitabline.hxx" 50 #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx" 51 #include <svx/svxdlg.hxx> //CHINA001 52 #include <dialmgr.hxx> 53 #include "svx/dlgutil.hxx" 54 #include <svx/dialmgr.hxx> 55 #include <svx/dialogs.hrc> 56 57 #define DLGWIN this->GetParent()->GetParent() 58 59 #define BITMAP_WIDTH 32 60 #define BITMAP_HEIGHT 12 61 #define XOUT_WIDTH 150 62 63 /************************************************************************* 64 |* 65 |* Dialog zum Definieren von Linienstilen 66 |* 67 \************************************************************************/ 68 69 SvxLineDefTabPage::SvxLineDefTabPage 70 ( 71 Window* pParent, 72 const SfxItemSet& rInAttrs 73 ) : 74 75 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_LINE_DEF ), rInAttrs ), 76 77 aFlDefinition ( this, CUI_RES( FL_DEFINITION ) ), 78 aFTLinestyle ( this, CUI_RES( FT_LINESTYLE ) ), 79 aLbLineStyles ( this, CUI_RES( LB_LINESTYLES ) ), 80 aFtType ( this, CUI_RES( FT_TYPE ) ), 81 aLbType1 ( this, CUI_RES( LB_TYPE_1 ) ), 82 aLbType2 ( this, CUI_RES( LB_TYPE_2 ) ), 83 aFtNumber ( this, CUI_RES( FT_NUMBER ) ), 84 aNumFldNumber1 ( this, CUI_RES( NUM_FLD_1 ) ), 85 aNumFldNumber2 ( this, CUI_RES( NUM_FLD_2 ) ), 86 aFtLength ( this, CUI_RES( FT_LENGTH ) ), 87 aMtrLength1 ( this, CUI_RES( MTR_FLD_LENGTH_1 ) ), 88 aMtrLength2 ( this, CUI_RES( MTR_FLD_LENGTH_2 ) ), 89 aFtDistance ( this, CUI_RES( FT_DISTANCE ) ), 90 aMtrDistance ( this, CUI_RES( MTR_FLD_DISTANCE ) ), 91 aCbxSynchronize ( this, CUI_RES( CBX_SYNCHRONIZE ) ), 92 aBtnAdd ( this, CUI_RES( BTN_ADD ) ), 93 aBtnModify ( this, CUI_RES( BTN_MODIFY ) ), 94 aBtnDelete ( this, CUI_RES( BTN_DELETE ) ), 95 aBtnLoad ( this, CUI_RES( BTN_LOAD ) ), 96 aBtnSave ( this, CUI_RES( BTN_SAVE ) ), 97 aCtlPreview ( this, CUI_RES( CTL_PREVIEW ) ), 98 99 rOutAttrs ( rInAttrs ), 100 101 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ), 102 aXLStyle ( XLINE_DASH ), 103 aXWidth ( XOUT_WIDTH ), 104 aXDash ( String(), XDash( XDASH_RECT, 3, 7, 2, 40, 15 ) ), 105 aXColor ( String(), COL_BLACK ), 106 aXLineAttr ( pXPool ), 107 rXLSet ( aXLineAttr.GetItemSet() ) 108 { 109 aBtnLoad.SetModeImage( Image( CUI_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST ); 110 aBtnSave.SetModeImage( Image( CUI_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST ); 111 112 aLbType1.SetAccessibleName(String(CUI_RES( STR_START_TYPE ) ) ); 113 aLbType2.SetAccessibleName(String(CUI_RES( STR_END_TYPE ) ) ); 114 aNumFldNumber1.SetAccessibleName(String(CUI_RES( STR_START_NUM ) ) ); 115 aNumFldNumber2.SetAccessibleName(String(CUI_RES( STR_END_NUM ) ) ); 116 aMtrLength1.SetAccessibleName(String(CUI_RES( STR_START_LENGTH ) ) ); 117 aMtrLength2.SetAccessibleName(String(CUI_RES( STR_END_LENGTH ) ) ); 118 119 FreeResource(); 120 121 // diese Page braucht ExchangeSupport 122 SetExchangeSupport(); 123 124 // Metrik einstellen 125 eFUnit = GetModuleFieldUnit( rInAttrs ); 126 127 switch ( eFUnit ) 128 { 129 case FUNIT_M: 130 case FUNIT_KM: 131 eFUnit = FUNIT_MM; 132 break; 133 default: ; //prevent warning 134 } 135 SetFieldUnit( aMtrDistance, eFUnit ); 136 SetFieldUnit( aMtrLength1, eFUnit ); 137 SetFieldUnit( aMtrLength2, eFUnit ); 138 139 // PoolUnit ermitteln 140 SfxItemPool* pPool = rOutAttrs.GetPool(); 141 DBG_ASSERT( pPool, "Wo ist der Pool?" ); 142 ePoolUnit = pPool->GetMetric( SID_ATTR_LINE_WIDTH ); 143 144 rXLSet.Put( aXLStyle ); 145 rXLSet.Put( aXWidth ); 146 rXLSet.Put( aXDash ); 147 rXLSet.Put( aXColor ); 148 149 // #i34740# 150 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 151 152 aBtnAdd.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickAddHdl_Impl ) ); 153 aBtnModify.SetClickHdl( 154 LINK( this, SvxLineDefTabPage, ClickModifyHdl_Impl ) ); 155 aBtnDelete.SetClickHdl( 156 LINK( this, SvxLineDefTabPage, ClickDeleteHdl_Impl ) ); 157 aBtnLoad.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickLoadHdl_Impl ) ); 158 aBtnSave.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickSaveHdl_Impl ) ); 159 160 aNumFldNumber1.SetModifyHdl( 161 LINK( this, SvxLineDefTabPage, ChangeNumber1Hdl_Impl ) ); 162 aNumFldNumber2.SetModifyHdl( 163 LINK( this, SvxLineDefTabPage, ChangeNumber2Hdl_Impl ) ); 164 aLbLineStyles.SetSelectHdl( 165 LINK( this, SvxLineDefTabPage, SelectLinestyleHdl_Impl ) ); 166 167 // Absolut (in mm) oder Relativ (in %) 168 aCbxSynchronize.SetClickHdl( 169 LINK( this, SvxLineDefTabPage, ChangeMetricHdl_Impl ) ); 170 171 // Wenn sich etwas aendert, muss Preview upgedatet werden werden 172 Link aLink = LINK( this, SvxLineDefTabPage, SelectTypeHdl_Impl ); 173 aLbType1.SetSelectHdl( aLink ); 174 aLbType2.SetSelectHdl( aLink ); 175 aLink = LINK( this, SvxLineDefTabPage, ChangePreviewHdl_Impl ); 176 aMtrLength1.SetModifyHdl( aLink ); 177 aMtrLength2.SetModifyHdl( aLink ); 178 aMtrDistance.SetModifyHdl( aLink ); 179 180 pDashList = NULL; 181 182 aBtnAdd.SetAccessibleRelationMemberOf( &aFlDefinition ); 183 aBtnModify.SetAccessibleRelationMemberOf( &aFlDefinition ); 184 aBtnDelete.SetAccessibleRelationMemberOf( &aFlDefinition ); 185 aBtnLoad.SetAccessibleRelationMemberOf( &aFlDefinition ); 186 aBtnSave.SetAccessibleRelationMemberOf( &aFlDefinition ); 187 } 188 189 190 // ----------------------------------------------------------------------- 191 192 void SvxLineDefTabPage::Construct() 193 { 194 // Linienstile 195 aLbLineStyles.Fill( pDashList ); 196 } 197 198 // ----------------------------------------------------------------------- 199 200 void SvxLineDefTabPage::ActivatePage( const SfxItemSet& ) 201 { 202 if( *pDlgType == 0 ) // Flaechen-Dialog 203 { 204 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!! 205 if( pDashList ) 206 { 207 if( *pPageType == 1 && 208 *pPosDashLb != LISTBOX_ENTRY_NOTFOUND ) 209 { 210 aLbLineStyles.SelectEntryPos( *pPosDashLb ); 211 } 212 // Damit evtl. vorhandener Linestyle verworfen wird 213 SelectLinestyleHdl_Impl( this ); 214 215 // Ermitteln (evtl. abschneiden) des Namens und in 216 // der GroupBox darstellen 217 String aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 218 INetURLObject aURL( pDashList->GetPath() ); 219 220 aURL.Append( pDashList->GetName() ); 221 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); 222 223 /* if ( aURL.getBase().Len() > 18 ) 224 { 225 aString += aURL.getBase().Copy( 0, 15 ); 226 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 227 } 228 else 229 aString += aURL.getBase(); 230 231 aFTLinestyle.SetText( aString ); 232 */ 233 *pPageType = 0; // 2 234 *pPosDashLb = LISTBOX_ENTRY_NOTFOUND; 235 } 236 } 237 } 238 239 // ----------------------------------------------------------------------- 240 241 int SvxLineDefTabPage::DeactivatePage( SfxItemSet* _pSet ) 242 { 243 CheckChanges_Impl(); 244 245 if( _pSet ) 246 FillItemSet( *_pSet ); 247 248 return( LEAVE_PAGE ); 249 } 250 251 // ----------------------------------------------------------------------- 252 253 void SvxLineDefTabPage::CheckChanges_Impl() 254 { 255 // wird hier benutzt, um Aenderungen NICHT zu verlieren 256 //XDashStyle eXDS; 257 258 if( aNumFldNumber1.GetText() != aNumFldNumber1.GetSavedValue() || 259 aMtrLength1.GetText() != aMtrLength1.GetSavedValue() || 260 aLbType1.GetSelectEntryPos() != aLbType1.GetSavedValue() || 261 aNumFldNumber2.GetText() != aNumFldNumber2.GetSavedValue() || 262 aMtrLength2.GetText() != aMtrLength2.GetSavedValue() || 263 aLbType2.GetSelectEntryPos() != aLbType2.GetSavedValue() || 264 aMtrDistance.GetText() != aMtrDistance.GetSavedValue() ) 265 { 266 ResMgr& rMgr = CUI_MGR(); 267 Image aWarningBoxImage = WarningBox::GetStandardImage(); 268 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 269 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001 270 AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX, 271 SVX_RESSTR( RID_SVXSTR_LINESTYLE ), 272 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE, rMgr ) ), 273 &aWarningBoxImage ); 274 DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001 275 aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1, 276 String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) ); 277 aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2, 278 String( ResId( RID_SVXSTR_ADD, rMgr ) ) ); 279 280 short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute(); 281 282 switch( nRet ) 283 { 284 case RET_BTN_1: // Aendern 285 { 286 ClickModifyHdl_Impl( this ); 287 //aXDash = pDashList->Get( nPos )->GetDash(); 288 } 289 break; 290 291 case RET_BTN_2: // Hinzufuegen 292 { 293 ClickAddHdl_Impl( this ); 294 //nPos = aLbLineStyles.GetSelectEntryPos(); 295 //aXDash = pDashList->Get( nPos )->GetDash(); 296 } 297 break; 298 299 case RET_CANCEL: 300 break; 301 // return( sal_True ); // Abbruch 302 } 303 delete aMessDlg; //add by CHINA001 304 } 305 306 307 308 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos(); 309 if( nPos != LISTBOX_ENTRY_NOTFOUND ) 310 { 311 *pPosDashLb = nPos; 312 } 313 } 314 315 // ----------------------------------------------------------------------- 316 317 sal_Bool SvxLineDefTabPage::FillItemSet( SfxItemSet& rAttrs ) 318 { 319 if( *pDlgType == 0 ) // Linien-Dialog 320 { 321 if( *pPageType == 2 ) 322 { 323 //CheckChanges_Impl(); 324 325 FillDash_Impl(); 326 327 String aString( aLbLineStyles.GetSelectEntry() ); 328 rAttrs.Put( XLineStyleItem( XLINE_DASH ) ); 329 rAttrs.Put( XLineDashItem( aString, aDash ) ); 330 } 331 } 332 return( sal_True ); 333 } 334 335 // ----------------------------------------------------------------------- 336 337 void SvxLineDefTabPage::Reset( const SfxItemSet& rAttrs ) 338 { 339 if( rAttrs.GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SFX_ITEM_DONTCARE ) 340 { 341 XLineStyle eXLS = (XLineStyle) ( ( const XLineStyleItem& ) rAttrs.Get( GetWhich( XATTR_LINESTYLE ) ) ).GetValue(); 342 343 switch( eXLS ) 344 { 345 case XLINE_NONE: 346 case XLINE_SOLID: 347 aLbLineStyles.SelectEntryPos( 0 ); 348 break; 349 350 case XLINE_DASH: 351 { 352 const XLineDashItem& rDashItem = ( const XLineDashItem& ) rAttrs.Get( XATTR_LINEDASH ); 353 aDash = rDashItem.GetDashValue(); 354 355 aLbLineStyles.SetNoSelection(); 356 aLbLineStyles.SelectEntry( rDashItem.GetName() ); 357 } 358 break; 359 360 default: 361 break; 362 } 363 } 364 SelectLinestyleHdl_Impl( NULL ); 365 366 // Status der Buttons ermitteln 367 if( pDashList->Count() ) 368 { 369 aBtnModify.Enable(); 370 aBtnDelete.Enable(); 371 aBtnSave.Enable(); 372 } 373 else 374 { 375 aBtnModify.Disable(); 376 aBtnDelete.Disable(); 377 aBtnSave.Disable(); 378 } 379 } 380 381 // ----------------------------------------------------------------------- 382 383 SfxTabPage* SvxLineDefTabPage::Create( Window* pWindow, 384 const SfxItemSet& rOutAttrs ) 385 { 386 return( new SvxLineDefTabPage( pWindow, rOutAttrs ) ); 387 } 388 389 //------------------------------------------------------------------------ 390 391 IMPL_LINK( SvxLineDefTabPage, SelectLinestyleHdl_Impl, void *, p ) 392 { 393 if( pDashList->Count() > 0 ) 394 { 395 int nTmp = aLbLineStyles.GetSelectEntryPos(); 396 if( nTmp == LISTBOX_ENTRY_NOTFOUND ) 397 { 398 } 399 else 400 aDash = pDashList->GetDash( nTmp )->GetDash(); 401 402 FillDialog_Impl(); 403 404 rXLSet.Put( XLineDashItem( String(), aDash ) ); 405 406 // #i34740# 407 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 408 409 aCtlPreview.Invalidate(); 410 411 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen, 412 // wenn in der ListBox ein Eintrag ausgewaehlt wurde 413 // Wenn ueber Reset() gerufen wurde ist p == NULL 414 if( p ) 415 *pPageType = 2; 416 } 417 return( 0L ); 418 } 419 420 //------------------------------------------------------------------------ 421 422 IMPL_LINK_INLINE_START( SvxLineDefTabPage, ChangePreviewHdl_Impl, void *, EMPTYARG ) 423 { 424 FillDash_Impl(); 425 aCtlPreview.Invalidate(); 426 427 return( 0L ); 428 } 429 IMPL_LINK_INLINE_END( SvxLineDefTabPage, ChangePreviewHdl_Impl, void *, EMPTYARG ) 430 431 //------------------------------------------------------------------------ 432 433 IMPL_LINK( SvxLineDefTabPage, ChangeNumber1Hdl_Impl, void *, EMPTYARG ) 434 { 435 if( aNumFldNumber1.GetValue() == 0L ) 436 { 437 aNumFldNumber2.SetMin( 1L ); 438 aNumFldNumber2.SetFirst( 1L ); 439 } 440 else 441 { 442 aNumFldNumber2.SetMin( 0L ); 443 aNumFldNumber2.SetFirst( 0L ); 444 } 445 446 ChangePreviewHdl_Impl( this ); 447 448 return( 0L ); 449 } 450 451 //------------------------------------------------------------------------ 452 453 IMPL_LINK( SvxLineDefTabPage, ChangeNumber2Hdl_Impl, void *, EMPTYARG ) 454 { 455 if( aNumFldNumber2.GetValue() == 0L ) 456 { 457 aNumFldNumber1.SetMin( 1L ); 458 aNumFldNumber1.SetFirst( 1L ); 459 } 460 else 461 { 462 aNumFldNumber1.SetMin( 0L ); 463 aNumFldNumber1.SetFirst( 0L ); 464 } 465 466 ChangePreviewHdl_Impl( this ); 467 468 return( 0L ); 469 } 470 471 472 //------------------------------------------------------------------------ 473 474 IMPL_LINK( SvxLineDefTabPage, ChangeMetricHdl_Impl, void *, p ) 475 { 476 if( !aCbxSynchronize.IsChecked() && aMtrLength1.GetUnit() != eFUnit ) 477 { 478 long nTmp1, nTmp2, nTmp3; 479 480 // Wurde ueber Control geaendert 481 if( p ) 482 { 483 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ) * XOUT_WIDTH / 100; 484 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ) * XOUT_WIDTH / 100; 485 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ) * XOUT_WIDTH / 100; 486 } 487 else 488 { 489 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ); 490 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ); 491 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ); 492 } 493 aMtrLength1.SetDecimalDigits( 2 ); 494 aMtrLength2.SetDecimalDigits( 2 ); 495 aMtrDistance.SetDecimalDigits( 2 ); 496 497 // Metrik einstellen 498 aMtrLength1.SetUnit( eFUnit ); 499 aMtrLength2.SetUnit( eFUnit ); 500 aMtrDistance.SetUnit( eFUnit ); 501 502 SetMetricValue( aMtrLength1, nTmp1, ePoolUnit ); 503 SetMetricValue( aMtrLength2, nTmp2, ePoolUnit ); 504 SetMetricValue( aMtrDistance, nTmp3, ePoolUnit ); 505 } 506 else if( aCbxSynchronize.IsChecked() && aMtrLength1.GetUnit() != FUNIT_CUSTOM ) 507 { 508 long nTmp1, nTmp2, nTmp3; 509 510 // Wurde ueber Control geaendert 511 if( p ) 512 { 513 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ) * 100 / XOUT_WIDTH; 514 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ) * 100 / XOUT_WIDTH; 515 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ) * 100 / XOUT_WIDTH; 516 } 517 else 518 { 519 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ); 520 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ); 521 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ); 522 } 523 524 aMtrLength1.SetDecimalDigits( 0 ); 525 aMtrLength2.SetDecimalDigits( 0 ); 526 aMtrDistance.SetDecimalDigits( 0 ); 527 528 aMtrLength1.SetUnit( FUNIT_CUSTOM ); 529 aMtrLength2.SetUnit( FUNIT_CUSTOM ); 530 aMtrDistance.SetUnit( FUNIT_CUSTOM ); 531 532 533 SetMetricValue( aMtrLength1, nTmp1, ePoolUnit ); 534 SetMetricValue( aMtrLength2, nTmp2, ePoolUnit ); 535 SetMetricValue( aMtrDistance, nTmp3, ePoolUnit ); 536 } 537 SelectTypeHdl_Impl( NULL ); 538 539 return( 0L ); 540 } 541 542 //------------------------------------------------------------------------ 543 544 IMPL_LINK( SvxLineDefTabPage, SelectTypeHdl_Impl, void *, p ) 545 { 546 if ( p == &aLbType1 || !p ) 547 { 548 if ( aLbType1.GetSelectEntryPos() == 0 ) 549 { 550 aMtrLength1.Disable(); 551 aMtrLength1.SetText( String() ); 552 } 553 else if ( !aMtrLength1.IsEnabled() ) 554 { 555 aMtrLength1.Enable(); 556 aMtrLength1.Reformat(); 557 } 558 } 559 560 if ( p == &aLbType2 || !p ) 561 { 562 if ( aLbType2.GetSelectEntryPos() == 0 ) 563 { 564 aMtrLength2.Disable(); 565 aMtrLength2.SetText( String() ); 566 } 567 else if ( !aMtrLength2.IsEnabled() ) 568 { 569 aMtrLength2.Enable(); 570 aMtrLength2.Reformat(); 571 } 572 } 573 ChangePreviewHdl_Impl( p ); 574 return( 0L ); 575 } 576 577 //------------------------------------------------------------------------ 578 579 IMPL_LINK( SvxLineDefTabPage, ClickAddHdl_Impl, void *, EMPTYARG ) 580 { 581 ResMgr& rMgr = CUI_MGR(); 582 String aNewName( SVX_RES( RID_SVXSTR_LINESTYLE ) ); 583 String aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE, rMgr ) ); 584 String aName; 585 XDashEntry* pEntry; 586 587 long nCount = pDashList->Count(); 588 long j = 1; 589 sal_Bool bDifferent = sal_False; 590 591 while ( !bDifferent ) 592 { 593 aName = aNewName; 594 aName += sal_Unicode(' '); 595 aName += UniString::CreateFromInt32( j++ ); 596 bDifferent = sal_True; 597 598 for ( long i = 0; i < nCount && bDifferent; i++ ) 599 if ( aName == pDashList->GetDash( i )->GetName() ) 600 bDifferent = sal_False; 601 } 602 603 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 604 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001 605 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc ); 606 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 607 sal_Bool bLoop = sal_True; 608 609 while ( bLoop && pDlg->Execute() == RET_OK ) 610 { 611 pDlg->GetName( aName ); 612 bDifferent = sal_True; 613 614 for( long i = 0; i < nCount && bDifferent; i++ ) 615 { 616 if( aName == pDashList->GetDash( i )->GetName() ) 617 bDifferent = sal_False; 618 } 619 620 if( bDifferent ) 621 { 622 bLoop = sal_False; 623 FillDash_Impl(); 624 625 pEntry = new XDashEntry( aDash, aName ); 626 627 long nDashCount = pDashList->Count(); 628 pDashList->Insert( pEntry, nDashCount ); 629 Bitmap* pBitmap = pDashList->GetBitmap( nDashCount ); 630 aLbLineStyles.Append( pEntry, pBitmap ); 631 632 aLbLineStyles.SelectEntryPos( aLbLineStyles.GetEntryCount() - 1 ); 633 634 // Flag fuer modifiziert setzen 635 *pnDashListState |= CT_MODIFIED; 636 637 *pPageType = 2; 638 639 // Werte sichern fuer Changes-Erkennung ( -> Methode ) 640 aNumFldNumber1.SaveValue(); 641 aMtrLength1.SaveValue(); 642 aLbType1.SaveValue(); 643 aNumFldNumber2.SaveValue(); 644 aMtrLength2.SaveValue(); 645 aLbType2.SaveValue(); 646 aMtrDistance.SaveValue(); 647 } 648 else 649 { 650 WarningBox aBox( DLGWIN, WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) ); 651 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE ); 652 aBox.Execute(); 653 } 654 } 655 delete( pDlg ); 656 657 // Status der Buttons ermitteln 658 if ( pDashList->Count() ) 659 { 660 aBtnModify.Enable(); 661 aBtnDelete.Enable(); 662 aBtnSave.Enable(); 663 } 664 return( 0L ); 665 } 666 667 //------------------------------------------------------------------------ 668 669 IMPL_LINK( SvxLineDefTabPage, ClickModifyHdl_Impl, void *, EMPTYARG ) 670 { 671 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos(); 672 673 if( nPos != LISTBOX_ENTRY_NOTFOUND ) 674 { 675 ResMgr& rMgr = CUI_MGR(); 676 String aNewName( SVX_RES( RID_SVXSTR_LINESTYLE ) ); 677 String aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE, rMgr ) ); 678 String aName( pDashList->GetDash( nPos )->GetName() ); 679 String aOldName = aName; 680 681 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 682 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001 683 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc ); 684 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 685 686 long nCount = pDashList->Count(); 687 sal_Bool bDifferent = sal_False; 688 sal_Bool bLoop = sal_True; 689 690 while ( bLoop && pDlg->Execute() == RET_OK ) 691 { 692 pDlg->GetName( aName ); 693 bDifferent = sal_True; 694 695 for( long i = 0; i < nCount && bDifferent; i++ ) 696 { 697 if( aName == pDashList->GetDash( i )->GetName() && 698 aName != aOldName ) 699 bDifferent = sal_False; 700 } 701 702 if ( bDifferent ) 703 { 704 bLoop = sal_False; 705 FillDash_Impl(); 706 707 XDashEntry* pEntry = new XDashEntry( aDash, aName ); 708 709 delete pDashList->Replace( pEntry, nPos ); 710 Bitmap* pBitmap = pDashList->GetBitmap( nPos ); 711 aLbLineStyles.Modify( pEntry, nPos, pBitmap ); 712 713 aLbLineStyles.SelectEntryPos( nPos ); 714 715 // Flag fuer modifiziert setzen 716 *pnDashListState |= CT_MODIFIED; 717 718 *pPageType = 2; 719 720 // Werte sichern fuer Changes-Erkennung ( -> Methode ) 721 aNumFldNumber1.SaveValue(); 722 aMtrLength1.SaveValue(); 723 aLbType1.SaveValue(); 724 aNumFldNumber2.SaveValue(); 725 aMtrLength2.SaveValue(); 726 aLbType2.SaveValue(); 727 aMtrDistance.SaveValue(); 728 } 729 else 730 { 731 WarningBox aBox( DLGWIN, WinBits( WB_OK ), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) ); 732 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE ); 733 aBox.Execute(); 734 } 735 } 736 delete( pDlg ); 737 } 738 return( 0L ); 739 } 740 741 //------------------------------------------------------------------------ 742 743 IMPL_LINK( SvxLineDefTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG ) 744 { 745 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos(); 746 747 if ( nPos != LISTBOX_ENTRY_NOTFOUND ) 748 { 749 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ), 750 String( CUI_RES( RID_SVXSTR_ASK_DEL_LINESTYLE ) ) ); 751 752 if ( aQueryBox.Execute() == RET_YES ) 753 { 754 delete pDashList->Remove( nPos ); 755 aLbLineStyles.RemoveEntry( nPos ); 756 aLbLineStyles.SelectEntryPos( 0 ); 757 758 SelectLinestyleHdl_Impl( this ); 759 *pPageType = 0; // Style soll nicht uebernommen werden 760 761 // Flag fuer modifiziert setzen 762 *pnDashListState |= CT_MODIFIED; 763 764 ChangePreviewHdl_Impl( this ); 765 } 766 } 767 768 // Status der Buttons ermitteln 769 if ( !pDashList->Count() ) 770 { 771 aBtnModify.Disable(); 772 aBtnDelete.Disable(); 773 aBtnSave.Disable(); 774 } 775 return( 0L ); 776 } 777 778 // ----------------------------------------------------------------------- 779 780 IMPL_LINK( SvxLineDefTabPage, ClickLoadHdl_Impl, void *, EMPTYARG ) 781 { 782 ResMgr& rMgr = CUI_MGR(); 783 sal_uInt16 nReturn = RET_YES; 784 785 if ( *pnDashListState & CT_MODIFIED ) 786 { 787 nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ), 788 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute(); 789 790 if ( nReturn == RET_YES ) 791 pDashList->Save(); 792 } 793 794 if ( nReturn != RET_CANCEL ) 795 { 796 ::sfx2::FileDialogHelper aDlg( 797 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 798 0 ); 799 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) ); 800 aDlg.AddFilter( aStrFilterType, aStrFilterType ); 801 INetURLObject aFile( SvtPathOptions().GetPalettePath() ); 802 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); 803 804 if( aDlg.Execute() == ERRCODE_NONE ) 805 { 806 INetURLObject aURL( aDlg.GetPath() ); 807 INetURLObject aPathURL( aURL ); 808 809 aPathURL.removeSegment(); 810 aPathURL.removeFinalSlash(); 811 812 // Liste speichern 813 XDashList* pDshLst = new XDashList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool ); 814 pDshLst->SetName( aURL.getName() ); 815 816 if( pDshLst->Load() ) 817 { 818 if( pDshLst ) 819 { 820 // Pruefen, ob Tabelle geloescht werden darf: 821 if( pDashList != ( (SvxLineTabDialog*) DLGWIN )->GetDashList() ) 822 delete pDashList; 823 824 pDashList = pDshLst; 825 ( (SvxLineTabDialog*) DLGWIN )->SetNewDashList( pDashList ); 826 827 aLbLineStyles.Clear(); 828 aLbLineStyles.Fill( pDashList ); 829 Reset( rOutAttrs ); 830 831 pDashList->SetName( aURL.getName() ); 832 833 /* // Ermitteln (evtl. abschneiden) des Namens und in 834 // der GroupBox darstellen 835 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) ); 836 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 837 838 if ( aURL.getBase().Len() > 18 ) 839 { 840 aString += aURL.getBase().Copy( 0, 15 ); 841 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 842 } 843 else 844 aString += aURL.getBase(); 845 846 aGrpLinestyles.SetText( aString ); 847 */ 848 // Flag fuer gewechselt setzen 849 *pnDashListState |= CT_CHANGED; 850 // Flag fuer modifiziert entfernen 851 *pnDashListState &= ~CT_MODIFIED; 852 } 853 } 854 else 855 //aIStream.Close(); 856 ErrorBox( DLGWIN, WinBits( WB_OK ), 857 String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute(); 858 } 859 } 860 861 // Status der Buttons ermitteln 862 if ( pDashList->Count() ) 863 { 864 aBtnModify.Enable(); 865 aBtnDelete.Enable(); 866 aBtnSave.Enable(); 867 } 868 else 869 { 870 aBtnModify.Disable(); 871 aBtnDelete.Disable(); 872 aBtnSave.Disable(); 873 } 874 return( 0L ); 875 } 876 877 // ----------------------------------------------------------------------- 878 879 IMPL_LINK( SvxLineDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG ) 880 { 881 ::sfx2::FileDialogHelper aDlg( 882 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 ); 883 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) ); 884 aDlg.AddFilter( aStrFilterType, aStrFilterType ); 885 886 INetURLObject aFile( SvtPathOptions().GetPalettePath() ); 887 DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); 888 889 if( pDashList->GetName().Len() ) 890 { 891 aFile.Append( pDashList->GetName() ); 892 893 if( !aFile.getExtension().getLength() ) 894 aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sod" ) ) ); 895 } 896 897 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); 898 if ( aDlg.Execute() == ERRCODE_NONE ) 899 { 900 INetURLObject aURL( aDlg.GetPath() ); 901 INetURLObject aPathURL( aURL ); 902 903 aPathURL.removeSegment(); 904 aPathURL.removeFinalSlash(); 905 906 pDashList->SetName( aURL.getName() ); 907 pDashList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) ); 908 909 if( pDashList->Save() ) 910 { 911 /* // Ermitteln (evtl. abschneiden) des Namens und in 912 // der GroupBox darstellen 913 String aString( CUI_RES( RID_SVXSTR_TABLE ) ); 914 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 915 916 if ( aURL.getBase().Len() > 18 ) 917 { 918 aString += aURL.getBase().Copy( 0, 15 ); 919 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 920 } 921 else 922 aString += aURL.getBase(); 923 924 aGrpLinestyles.SetText( aString ); 925 */ 926 // Flag fuer gespeichert setzen 927 *pnDashListState |= CT_SAVED; 928 // Flag fuer modifiziert entfernen 929 *pnDashListState &= ~CT_MODIFIED; 930 } 931 else 932 { 933 ErrorBox( DLGWIN, WinBits( WB_OK ), 934 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute(); 935 } 936 } 937 938 return( 0L ); 939 } 940 941 //------------------------------------------------------------------------ 942 943 void SvxLineDefTabPage::FillDash_Impl() 944 { 945 XDashStyle eXDS; 946 947 /* Alle Stile werden z.Z. nicht benutzt 948 if( aRbtEnds1.IsChecked() ) 949 eXDS = XDASH_ROUND; 950 else if( aRbtEnds2.IsChecked() ) 951 eXDS = XDASH_RECT; 952 else 953 eXDS = XDASH_RECT; 954 */ 955 if( aCbxSynchronize.IsChecked() ) 956 eXDS = XDASH_RECTRELATIVE; 957 else 958 eXDS = XDASH_RECT; 959 960 aDash.SetDashStyle( eXDS ); 961 aDash.SetDots( (sal_uInt8) aNumFldNumber1.GetValue() ); 962 aDash.SetDotLen( aLbType1.GetSelectEntryPos() == 0 ? 0 : 963 GetCoreValue( aMtrLength1, ePoolUnit ) ); 964 aDash.SetDashes( (sal_uInt8) aNumFldNumber2.GetValue() ); 965 aDash.SetDashLen( aLbType2.GetSelectEntryPos() == 0 ? 0 : 966 GetCoreValue( aMtrLength2, ePoolUnit ) ); 967 aDash.SetDistance( GetCoreValue( aMtrDistance, ePoolUnit ) ); 968 969 rXLSet.Put( XLineDashItem( String(), aDash ) ); 970 971 // #i34740# 972 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 973 } 974 975 //------------------------------------------------------------------------ 976 977 void SvxLineDefTabPage::FillDialog_Impl() 978 { 979 XDashStyle eXDS = aDash.GetDashStyle(); // XDASH_RECT, XDASH_ROUND 980 if( eXDS == XDASH_RECTRELATIVE ) 981 aCbxSynchronize.Check(); 982 else 983 aCbxSynchronize.Check( sal_False ); 984 985 aNumFldNumber1.SetValue( aDash.GetDots() ); 986 //aMtrLength1.SetValue( aDash.GetDotLen() ); 987 SetMetricValue( aMtrLength1, aDash.GetDotLen(), ePoolUnit ); 988 aLbType1.SelectEntryPos( aDash.GetDotLen() == 0 ? 0 : 1 ); 989 aNumFldNumber2.SetValue( aDash.GetDashes() ); 990 //aMtrLength2.SetValue( aDash.GetDashLen() ); 991 SetMetricValue( aMtrLength2, aDash.GetDashLen(), ePoolUnit ); 992 aLbType2.SelectEntryPos( aDash.GetDashLen() == 0 ? 0 : 1 ); 993 //aMtrDistance.SetValue( aDash.GetDistance() ); 994 SetMetricValue( aMtrDistance, aDash.GetDistance(), ePoolUnit ); 995 996 ChangeMetricHdl_Impl( NULL ); 997 998 // Werte sichern fuer Changes-Erkennung ( -> Methode ) 999 aNumFldNumber1.SaveValue(); 1000 aMtrLength1.SaveValue(); 1001 aLbType1.SaveValue(); 1002 aNumFldNumber2.SaveValue(); 1003 aMtrLength2.SaveValue(); 1004 aLbType2.SaveValue(); 1005 aMtrDistance.SaveValue(); 1006 } 1007 1008 1009 void SvxLineDefTabPage::DataChanged( const DataChangedEvent& rDCEvt ) 1010 { 1011 SfxTabPage::DataChanged( rDCEvt ); 1012 1013 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1014 { 1015 sal_uInt16 nOldSelect = aLbLineStyles.GetSelectEntryPos(); 1016 aLbLineStyles.Clear(); 1017 aLbLineStyles.Fill( pDashList ); 1018 aLbLineStyles.SelectEntryPos( nOldSelect ); 1019 } 1020 } 1021 1022