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