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/filedlghelper.hxx> 38 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" 39 40 #define _SVX_TPLNEEND_CXX 41 42 #include <cuires.hrc> 43 #include "tabline.hrc" 44 #include "helpid.hrc" 45 #include <svx/dialmgr.hxx> 46 #include <svx/svdobj.hxx> 47 #include <svx/svdopath.hxx> 48 #include "svx/drawitem.hxx" 49 #include <svx/xpool.hxx> 50 #include <svx/xtable.hxx> 51 #include "cuitabline.hxx" 52 #include <svx/svxdlg.hxx> //CHINA001 53 #include <dialmgr.hxx> 54 #include "svx/dlgutil.hxx" 55 #include <basegfx/range/b2drange.hxx> 56 #include <basegfx/polygon/b2dpolygontools.hxx> 57 #include <basegfx/matrix/b2dhommatrix.hxx> 58 #include <basegfx/polygon/b2dpolygon.hxx> 59 #include <basegfx/polygon/b2dpolypolygontools.hxx> 60 #include <basegfx/matrix/b2dhommatrixtools.hxx> 61 #include <svx/dialogs.hrc> 62 63 #define DLGWIN this->GetParent()->GetParent() 64 65 #define BITMAP_WIDTH 32 66 #define BITMAP_HEIGHT 12 67 #define XOUT_WIDTH 150 68 69 /************************************************************************* 70 |* 71 |* Dialog zum Definieren von Linienenden-Stilen 72 |* 73 \************************************************************************/ 74 75 SvxLineEndDefTabPage::SvxLineEndDefTabPage 76 ( 77 Window* pParent, 78 const SfxItemSet& rInAttrs 79 ) : 80 81 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_LINEEND_DEF ), rInAttrs ), 82 83 aFlTip ( this, CUI_RES( FL_TIP ) ), 84 aFTTitle ( this, CUI_RES( FT_TITLE ) ), 85 aEdtName ( this, CUI_RES( EDT_NAME ) ), 86 aFTLineEndStyle ( this, CUI_RES( FT_LINE_END_STYLE ) ), 87 aLbLineEnds ( this, CUI_RES( LB_LINEENDS ) ), 88 aBtnAdd ( this, CUI_RES( BTN_ADD ) ), 89 aBtnModify ( this, CUI_RES( BTN_MODIFY ) ), 90 aBtnDelete ( this, CUI_RES( BTN_DELETE ) ), 91 aBtnLoad ( this, CUI_RES( BTN_LOAD ) ), 92 aBtnSave ( this, CUI_RES( BTN_SAVE ) ), 93 aFiTip ( this, CUI_RES( FI_TIP ) ), 94 aCtlPreview ( this, CUI_RES( CTL_PREVIEW ) ), 95 96 rOutAttrs ( rInAttrs ), 97 pPolyObj( NULL ), 98 99 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ), 100 aXLStyle ( XLINE_SOLID ), 101 aXWidth ( XOUT_WIDTH ), 102 aXColor ( String(), COL_BLACK ), 103 aXLineAttr ( pXPool ), 104 rXLSet ( aXLineAttr.GetItemSet() ), 105 pLineEndList( NULL ) 106 { 107 aBtnLoad.SetModeImage( Image( CUI_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST ); 108 aBtnSave.SetModeImage( Image( CUI_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST ); 109 110 FreeResource(); 111 112 // diese Page braucht ExchangeSupport 113 SetExchangeSupport(); 114 115 rXLSet.Put( aXLStyle ); 116 rXLSet.Put( aXWidth ); 117 rXLSet.Put( aXColor ); 118 rXLSet.Put( XLineStartWidthItem( aCtlPreview.GetOutputSize().Height() / 2 ) ); 119 rXLSet.Put( XLineEndWidthItem( aCtlPreview.GetOutputSize().Height() / 2 ) ); 120 121 // #i34740# 122 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 123 124 aBtnAdd.SetClickHdl( 125 LINK( this, SvxLineEndDefTabPage, ClickAddHdl_Impl ) ); 126 aBtnModify.SetClickHdl( 127 LINK( this, SvxLineEndDefTabPage, ClickModifyHdl_Impl ) ); 128 aBtnDelete.SetClickHdl( 129 LINK( this, SvxLineEndDefTabPage, ClickDeleteHdl_Impl ) ); 130 aBtnLoad.SetClickHdl( 131 LINK( this, SvxLineEndDefTabPage, ClickLoadHdl_Impl ) ); 132 aBtnSave.SetClickHdl( 133 LINK( this, SvxLineEndDefTabPage, ClickSaveHdl_Impl ) ); 134 135 aLbLineEnds.SetSelectHdl( 136 LINK( this, SvxLineEndDefTabPage, SelectLineEndHdl_Impl ) ); 137 138 aBtnAdd.SetAccessibleRelationMemberOf(&aFlTip); 139 aBtnModify.SetAccessibleRelationMemberOf(&aFlTip); 140 aBtnDelete.SetAccessibleRelationMemberOf(&aFlTip); 141 } 142 143 //------------------------------------------------------------------------ 144 145 SvxLineEndDefTabPage::~SvxLineEndDefTabPage() 146 { 147 } 148 149 // ----------------------------------------------------------------------- 150 151 void SvxLineEndDefTabPage::Construct() 152 { 153 aLbLineEnds.Fill( pLineEndList ); 154 155 bool bCreateArrowPossible = true; 156 157 if( !pPolyObj ) 158 { 159 bCreateArrowPossible = false; 160 } 161 else if( !pPolyObj->ISA( SdrPathObj ) ) 162 { 163 SdrObjTransformInfoRec aInfoRec; 164 pPolyObj->TakeObjInfo( aInfoRec ); 165 SdrObject* pNewObj = 0; 166 if( aInfoRec.bCanConvToPath ) 167 pNewObj = pPolyObj->ConvertToPolyObj( sal_True, sal_False ); 168 169 bCreateArrowPossible = pNewObj && pNewObj->ISA( SdrPathObj ); 170 SdrObject::Free( pNewObj ); 171 } 172 173 if( !bCreateArrowPossible ) 174 aBtnAdd.Disable(); 175 } 176 177 // ----------------------------------------------------------------------- 178 179 void SvxLineEndDefTabPage::ActivatePage( const SfxItemSet& ) 180 { 181 if( *pDlgType == 0 ) // Flaechen-Dialog 182 { 183 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!! 184 if( pLineEndList ) 185 { 186 if( *pPosLineEndLb != LISTBOX_ENTRY_NOTFOUND ) 187 { 188 aLbLineEnds.SelectEntryPos( *pPosLineEndLb ); 189 SelectLineEndHdl_Impl( this ); 190 } 191 INetURLObject aURL( pLineEndList->GetPath() ); 192 193 aURL.Append( pLineEndList->GetName() ); 194 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); 195 /* // Ermitteln (evtl. abschneiden) des Namens und in 196 // der GroupBox darstellen 197 String aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 198 199 if ( aURL.getBase().Len() > 18 ) 200 { 201 aString += aURL.getBase().Copy( 0, 15 ); 202 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 203 } 204 else 205 aString += aURL.getBase(); 206 207 aGrpLineEnds.SetText( aString ); 208 */ 209 *pPageType = 0; // 3 210 *pPosLineEndLb = LISTBOX_ENTRY_NOTFOUND; 211 } 212 } 213 } 214 215 // ----------------------------------------------------------------------- 216 217 int SvxLineEndDefTabPage::DeactivatePage( SfxItemSet* _pSet ) 218 { 219 CheckChanges_Impl(); 220 221 if( _pSet ) 222 FillItemSet( *_pSet ); 223 224 return( LEAVE_PAGE ); 225 } 226 227 // ----------------------------------------------------------------------- 228 229 void SvxLineEndDefTabPage::CheckChanges_Impl() 230 { 231 sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos(); 232 233 if ( nPos != LISTBOX_ENTRY_NOTFOUND ) 234 { 235 String aString = aEdtName.GetText(); 236 237 if( aString != aLbLineEnds.GetSelectEntry() ) 238 { 239 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ), 240 CUI_RESSTR( RID_SVXSTR_ASK_CHANGE_LINEEND ) ); 241 242 if ( aQueryBox.Execute() == RET_YES ) 243 ClickModifyHdl_Impl( this ); 244 } 245 } 246 nPos = aLbLineEnds.GetSelectEntryPos(); 247 248 if ( nPos != LISTBOX_ENTRY_NOTFOUND ) 249 *pPosLineEndLb = nPos; 250 } 251 252 // ----------------------------------------------------------------------- 253 254 sal_Bool SvxLineEndDefTabPage::FillItemSet( SfxItemSet& rSet ) 255 { 256 if( *pDlgType == 0 ) // Linien-Dialog 257 { 258 if( *pPageType == 3 ) 259 { 260 CheckChanges_Impl(); 261 262 long nPos = aLbLineEnds.GetSelectEntryPos(); 263 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 264 265 rSet.Put( XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ) ); 266 rSet.Put( XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ) ); 267 } 268 } 269 return( sal_True ); 270 } 271 272 // ----------------------------------------------------------------------- 273 274 void SvxLineEndDefTabPage::Reset( const SfxItemSet& ) 275 { 276 aLbLineEnds.SelectEntryPos( 0 ); 277 278 // Update lineend 279 if( pLineEndList->Count() > 0 ) 280 { 281 int nPos = aLbLineEnds.GetSelectEntryPos(); 282 283 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 284 285 aEdtName.SetText( aLbLineEnds.GetSelectEntry() ); 286 287 rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) ); 288 rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) ); 289 290 // #i34740# 291 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 292 293 aCtlPreview.Invalidate(); 294 } 295 296 // Status der Buttons ermitteln 297 if( pLineEndList->Count() ) 298 { 299 aBtnModify.Enable(); 300 aBtnDelete.Enable(); 301 aBtnSave.Enable(); 302 } 303 else 304 { 305 aBtnModify.Disable(); 306 aBtnDelete.Disable(); 307 aBtnSave.Disable(); 308 } 309 } 310 311 // ----------------------------------------------------------------------- 312 313 SfxTabPage* SvxLineEndDefTabPage::Create( Window* pWindow, 314 const SfxItemSet& rSet ) 315 { 316 return( new SvxLineEndDefTabPage( pWindow, rSet ) ); 317 } 318 319 //------------------------------------------------------------------------ 320 321 IMPL_LINK( SvxLineEndDefTabPage, SelectLineEndHdl_Impl, void *, EMPTYARG ) 322 { 323 if( pLineEndList->Count() > 0 ) 324 { 325 int nPos = aLbLineEnds.GetSelectEntryPos(); 326 327 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 328 329 aEdtName.SetText( aLbLineEnds.GetSelectEntry() ); 330 331 rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) ); 332 rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) ); 333 334 // #i34740# 335 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); 336 337 aCtlPreview.Invalidate(); 338 339 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen, 340 // wenn in der ListBox ein Eintrag ausgewaehlt wurde 341 *pPageType = 3; 342 } 343 return( 0L ); 344 } 345 346 //------------------------------------------------------------------------ 347 348 long SvxLineEndDefTabPage::ChangePreviewHdl_Impl( void* ) 349 { 350 aCtlPreview.Invalidate(); 351 return( 0L ); 352 } 353 354 //------------------------------------------------------------------------ 355 356 IMPL_LINK( SvxLineEndDefTabPage, ClickModifyHdl_Impl, void *, EMPTYARG ) 357 { 358 sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos(); 359 360 if( nPos != LISTBOX_ENTRY_NOTFOUND ) 361 { 362 ResMgr& rMgr = CUI_MGR(); 363 String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) ); 364 String aName( aEdtName.GetText() ); 365 long nCount = pLineEndList->Count(); 366 sal_Bool bDifferent = sal_True; 367 368 // Pruefen, ob Name schon vorhanden ist 369 for ( long i = 0; i < nCount && bDifferent; i++ ) 370 if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) 371 bDifferent = sal_False; 372 373 // Wenn ja, wird wiederholt ein neuer Name angefordert 374 if ( !bDifferent ) 375 { 376 WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ), 377 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) ); 378 aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE ); 379 aWarningBox.Execute(); 380 381 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 382 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001 383 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc ); 384 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 385 sal_Bool bLoop = sal_True; 386 387 while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) 388 { 389 pDlg->GetName( aName ); 390 bDifferent = sal_True; 391 392 for( long i = 0; i < nCount && bDifferent; i++ ) 393 { 394 if( aName == pLineEndList->GetLineEnd( i )->GetName() ) 395 bDifferent = sal_False; 396 } 397 398 if( bDifferent ) 399 bLoop = sal_False; 400 else 401 aWarningBox.Execute(); 402 } 403 delete( pDlg ); 404 } 405 406 // Wenn nicht vorhanden, wird Eintrag aufgenommen 407 if( bDifferent ) 408 { 409 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 410 411 pEntry->SetName( aName ); 412 aEdtName.SetText( aName ); 413 414 aLbLineEnds.Modify( pEntry, nPos, pLineEndList->GetBitmap( nPos ) ); 415 aLbLineEnds.SelectEntryPos( nPos ); 416 417 // Flag fuer modifiziert setzen 418 *pnLineEndListState |= CT_MODIFIED; 419 420 *pPageType = 3; 421 } 422 } 423 return( 0L ); 424 } 425 426 //------------------------------------------------------------------------ 427 428 IMPL_LINK( SvxLineEndDefTabPage, ClickAddHdl_Impl, void *, EMPTYARG ) 429 { 430 if( pPolyObj ) 431 { 432 const SdrObject* pNewObj; 433 SdrObject* pConvPolyObj = NULL; 434 435 if( pPolyObj->ISA( SdrPathObj ) ) 436 { 437 pNewObj = pPolyObj; 438 } 439 else 440 { 441 SdrObjTransformInfoRec aInfoRec; 442 pPolyObj->TakeObjInfo( aInfoRec ); 443 444 if( aInfoRec.bCanConvToPath ) 445 { 446 pNewObj = pConvPolyObj = pPolyObj->ConvertToPolyObj( sal_True, sal_False ); 447 448 if( !pNewObj || !pNewObj->ISA( SdrPathObj ) ) 449 return( 0L ); // Abbruch, zusaetzliche Sicherheit, die bei 450 // Gruppenobjekten aber nichts bringt. 451 } 452 else return( 0L ); // Abbruch 453 } 454 455 basegfx::B2DPolyPolygon aNewPolyPolygon(((SdrPathObj*)pNewObj)->GetPathPoly()); 456 basegfx::B2DRange aNewRange(basegfx::tools::getRange(aNewPolyPolygon)); 457 458 // Normalisieren 459 aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix( 460 -aNewRange.getMinX(), -aNewRange.getMinY())); 461 462 // Loeschen des angelegten PolyObjektes 463 SdrObject::Free( pConvPolyObj ); 464 465 XLineEndEntry* pEntry; 466 467 ResMgr& rMgr = CUI_MGR(); 468 String aNewName( SVX_RES( RID_SVXSTR_LINEEND ) ); 469 String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) ); 470 String aName; 471 472 long nCount = pLineEndList->Count(); 473 long j = 1; 474 sal_Bool bDifferent = sal_False; 475 476 while ( !bDifferent ) 477 { 478 aName = aNewName; 479 aName += sal_Unicode(' '); 480 aName += UniString::CreateFromInt32( j++ ); 481 bDifferent = sal_True; 482 483 for( long i = 0; i < nCount && bDifferent; i++ ) 484 if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) 485 bDifferent = sal_False; 486 } 487 488 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 489 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001 490 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc ); 491 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 492 sal_Bool bLoop = sal_True; 493 494 while ( bLoop && pDlg->Execute() == RET_OK ) 495 { 496 pDlg->GetName( aName ); 497 bDifferent = sal_True; 498 499 for( long i = 0; i < nCount && bDifferent; i++ ) 500 { 501 if( aName == pLineEndList->GetLineEnd( i )->GetName() ) 502 bDifferent = sal_False; 503 } 504 505 if( bDifferent ) 506 { 507 bLoop = sal_False; 508 pEntry = new XLineEndEntry( aNewPolyPolygon, aName ); 509 510 long nLineEndCount = pLineEndList->Count(); 511 pLineEndList->Insert( pEntry, nLineEndCount ); 512 Bitmap* pBitmap = pLineEndList->GetBitmap( nLineEndCount ); 513 514 // Zur ListBox hinzufuegen 515 aLbLineEnds.Append( pEntry, pBitmap ); 516 aLbLineEnds.SelectEntryPos( aLbLineEnds.GetEntryCount() - 1 ); 517 518 // Flag fuer modifiziert setzen 519 *pnLineEndListState |= CT_MODIFIED; 520 521 SelectLineEndHdl_Impl( this ); 522 } 523 else 524 { 525 WarningBox aBox( DLGWIN, WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) ); 526 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE ); 527 aBox.Execute(); 528 } 529 } 530 delete pDlg; 531 } 532 else 533 aBtnAdd.Disable(); 534 535 // Status der Buttons ermitteln 536 if ( pLineEndList->Count() ) 537 { 538 aBtnModify.Enable(); 539 aBtnDelete.Enable(); 540 aBtnSave.Enable(); 541 } 542 return( 0L ); 543 } 544 545 //------------------------------------------------------------------------ 546 547 IMPL_LINK( SvxLineEndDefTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG ) 548 { 549 sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos(); 550 551 if( nPos != LISTBOX_ENTRY_NOTFOUND ) 552 { 553 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ), 554 String( CUI_RES( RID_SVXSTR_ASK_DEL_LINEEND ) ) ); 555 556 if ( aQueryBox.Execute() == RET_YES ) 557 { 558 delete pLineEndList->Remove( nPos ); 559 aLbLineEnds.RemoveEntry( nPos ); 560 aLbLineEnds.SelectEntryPos( 0 ); 561 562 SelectLineEndHdl_Impl( this ); 563 *pPageType = 0; // LineEnd soll nicht uebernommen werden 564 565 // Flag fuer modifiziert setzen 566 *pnLineEndListState |= CT_MODIFIED; 567 568 ChangePreviewHdl_Impl( this ); 569 } 570 } 571 // Status der Buttons ermitteln 572 if( !pLineEndList->Count() ) 573 { 574 aBtnModify.Disable(); 575 aBtnDelete.Disable(); 576 aBtnSave.Disable(); 577 } 578 return( 0L ); 579 } 580 581 //------------------------------------------------------------------------ 582 583 IMPL_LINK( SvxLineEndDefTabPage, ClickLoadHdl_Impl, void *, EMPTYARG ) 584 { 585 ResMgr& rMgr = CUI_MGR(); 586 sal_uInt16 nReturn = RET_YES; 587 588 if ( *pnLineEndListState & CT_MODIFIED ) 589 { 590 nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ), 591 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute(); 592 593 if ( nReturn == RET_YES ) 594 pLineEndList->Save(); 595 } 596 597 if ( nReturn != RET_CANCEL ) 598 { 599 ::sfx2::FileDialogHelper aDlg( 600 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 601 0 ); 602 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) ); 603 aDlg.AddFilter( aStrFilterType, aStrFilterType ); 604 INetURLObject aFile( SvtPathOptions().GetPalettePath() ); 605 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); 606 607 if( aDlg.Execute() == ERRCODE_NONE ) 608 { 609 INetURLObject aURL( aDlg.GetPath() ); 610 INetURLObject aPathURL( aURL ); 611 612 aPathURL.removeSegment(); 613 aPathURL.removeFinalSlash(); 614 615 // Liste speichern 616 XLineEndList* pLeList = new XLineEndList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool ); 617 pLeList->SetName( aURL.getName() ); 618 if( pLeList->Load() ) 619 { 620 if( pLeList ) 621 { 622 // Pruefen, ob Tabelle geloescht werden darf: 623 if( pLineEndList != ( (SvxLineTabDialog*) DLGWIN )->GetLineEndList() ) 624 delete pLineEndList; 625 626 pLineEndList = pLeList; 627 ( (SvxLineTabDialog*) DLGWIN )->SetNewLineEndList( pLineEndList ); 628 aLbLineEnds.Clear(); 629 aLbLineEnds.Fill( pLineEndList ); 630 Reset( rOutAttrs ); 631 632 pLineEndList->SetName( aURL.getName() ); 633 634 /* // Ermitteln (evtl. abschneiden) des Namens und in 635 // der GroupBox darstellen 636 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) ); 637 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 638 if( aURL.getBase().Len() > 18 ) 639 { 640 aString += aURL.getBase().Copy( 0, 15 ); 641 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 642 } 643 else 644 aString += aURL.getBase(); 645 646 aGrpLineEnds.SetText( aString ); 647 */ 648 // Flag fuer gewechselt setzen 649 *pnLineEndListState |= CT_CHANGED; 650 // Flag fuer modifiziert entfernen 651 *pnLineEndListState &= ~CT_MODIFIED; 652 } 653 } 654 else 655 ErrorBox( DLGWIN, WinBits( WB_OK ), 656 String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute(); 657 } 658 } 659 660 // Status der Buttons ermitteln 661 if ( pLineEndList->Count() ) 662 { 663 aBtnModify.Enable(); 664 aBtnDelete.Enable(); 665 aBtnSave.Enable(); 666 } 667 else 668 { 669 aBtnModify.Disable(); 670 aBtnDelete.Disable(); 671 aBtnSave.Disable(); 672 } 673 return( 0L ); 674 } 675 676 //------------------------------------------------------------------------ 677 678 IMPL_LINK( SvxLineEndDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG ) 679 { 680 ::sfx2::FileDialogHelper aDlg( 681 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 ); 682 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) ); 683 aDlg.AddFilter( aStrFilterType, aStrFilterType ); 684 685 INetURLObject aFile( SvtPathOptions().GetPalettePath() ); 686 DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); 687 688 if( pLineEndList->GetName().Len() ) 689 { 690 aFile.Append( pLineEndList->GetName() ); 691 692 if( !aFile.getExtension().getLength() ) 693 aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soe" ) ) ); 694 } 695 696 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); 697 if ( aDlg.Execute() == ERRCODE_NONE ) 698 { 699 INetURLObject aURL( aDlg.GetPath() ); 700 INetURLObject aPathURL( aURL ); 701 702 aPathURL.removeSegment(); 703 aPathURL.removeFinalSlash(); 704 705 pLineEndList->SetName( aURL.getName() ); 706 pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) ); 707 708 if( pLineEndList->Save() ) 709 { 710 /* // Ermitteln (evtl. abschneiden) des Namens und in 711 // der GroupBox darstellen 712 String aString( CUI_RES( RID_SVXSTR_TABLE ) ); 713 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); 714 715 if ( aURL.getBase().Len() > 18 ) 716 { 717 aString += aURL.getBase().Copy( 0, 15 ); 718 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) ); 719 } 720 else 721 aString += aURL.getBase(); 722 aGrpLineEnds.SetText( aString ); 723 */ 724 // Flag fuer gespeichert setzen 725 *pnLineEndListState |= CT_SAVED; 726 // Flag fuer modifiziert entfernen 727 *pnLineEndListState &= ~CT_MODIFIED; 728 } 729 else 730 { 731 ErrorBox( DLGWIN, WinBits( WB_OK ), 732 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute(); 733 } 734 } 735 return( 0L ); 736 } 737 738 void SvxLineEndDefTabPage::DataChanged( const DataChangedEvent& rDCEvt ) 739 { 740 SfxTabPage::DataChanged( rDCEvt ); 741 742 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 743 { 744 sal_uInt16 nOldSelect = aLbLineEnds.GetSelectEntryPos(); 745 aLbLineEnds.Clear(); 746 aLbLineEnds.Fill( pLineEndList ); 747 aLbLineEnds.SelectEntryPos( nOldSelect ); 748 } 749 } 750 751