Update ooo320-m1
[ooovba.git] / svx / source / cui / tplneend.cxx
blobe30e5b9e8db270200695ccb241646c4e61157c36
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tplneend.cxx,v $
10 * $Revision: 1.31 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
39 #include <tools/shl.hxx>
40 #include <tools/urlobj.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <svtools/pathoptions.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/filedlghelper.hxx>
45 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
47 #define _SVX_TPLNEEND_CXX
49 #include <svx/dialogs.hrc>
50 #include "dlgname.hrc"
51 #include "tabline.hrc"
52 #include "helpid.hrc"
57 #include <svx/svdobj.hxx>
58 #include <svx/svdopath.hxx>
59 #include "drawitem.hxx"
60 #include <svx/xpool.hxx>
61 #include <svx/xtable.hxx>
62 #include "cuitabline.hxx"
63 //CHINA001 #include "dlgname.hxx"
64 #include <svx/svxdlg.hxx> //CHINA001
65 #include <svx/dialmgr.hxx>
66 #include "dlgutil.hxx"
67 #include <basegfx/range/b2drange.hxx>
68 #include <basegfx/polygon/b2dpolygontools.hxx>
69 #include <basegfx/matrix/b2dhommatrix.hxx>
70 #include <basegfx/polygon/b2dpolygon.hxx>
71 #include <basegfx/polygon/b2dpolypolygontools.hxx>
73 #define DLGWIN this->GetParent()->GetParent()
75 #define BITMAP_WIDTH 32
76 #define BITMAP_HEIGHT 12
77 #define XOUT_WIDTH 150
79 /*************************************************************************
81 |* Dialog zum Definieren von Linienenden-Stilen
83 \************************************************************************/
85 SvxLineEndDefTabPage::SvxLineEndDefTabPage
87 Window* pParent,
88 const SfxItemSet& rInAttrs
89 ) :
91 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_LINEEND_DEF ), rInAttrs ),
93 aFlTip ( this, SVX_RES( FL_TIP ) ),
94 aFTTitle ( this, SVX_RES( FT_TITLE ) ),
95 aEdtName ( this, SVX_RES( EDT_NAME ) ),
96 aFTLineEndStyle ( this, SVX_RES( FT_LINE_END_STYLE ) ),
97 aLbLineEnds ( this, SVX_RES( LB_LINEENDS ) ),
98 aBtnAdd ( this, SVX_RES( BTN_ADD ) ),
99 aBtnModify ( this, SVX_RES( BTN_MODIFY ) ),
100 aBtnDelete ( this, SVX_RES( BTN_DELETE ) ),
101 aBtnLoad ( this, SVX_RES( BTN_LOAD ) ),
102 aBtnSave ( this, SVX_RES( BTN_SAVE ) ),
103 aFiTip ( this, SVX_RES( FI_TIP ) ),
104 aCtlPreview ( this, SVX_RES( CTL_PREVIEW ) ),
106 rOutAttrs ( rInAttrs ),
107 pPolyObj( NULL ),
109 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
110 aXLStyle ( XLINE_SOLID ),
111 aXWidth ( XOUT_WIDTH ),
112 aXColor ( String(), COL_BLACK ),
113 aXLineAttr ( pXPool ),
114 rXLSet ( aXLineAttr.GetItemSet() ),
115 pLineEndList( NULL )
117 aBtnLoad.SetModeImage( Image( SVX_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST );
118 aBtnSave.SetModeImage( Image( SVX_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST );
120 FreeResource();
122 // diese Page braucht ExchangeSupport
123 SetExchangeSupport();
125 rXLSet.Put( aXLStyle );
126 rXLSet.Put( aXWidth );
127 rXLSet.Put( aXColor );
128 rXLSet.Put( XLineStartWidthItem( aCtlPreview.GetOutputSize().Height() / 2 ) );
129 rXLSet.Put( XLineEndWidthItem( aCtlPreview.GetOutputSize().Height() / 2 ) );
131 // #i34740#
132 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
134 aBtnAdd.SetClickHdl(
135 LINK( this, SvxLineEndDefTabPage, ClickAddHdl_Impl ) );
136 aBtnModify.SetClickHdl(
137 LINK( this, SvxLineEndDefTabPage, ClickModifyHdl_Impl ) );
138 aBtnDelete.SetClickHdl(
139 LINK( this, SvxLineEndDefTabPage, ClickDeleteHdl_Impl ) );
140 aBtnLoad.SetClickHdl(
141 LINK( this, SvxLineEndDefTabPage, ClickLoadHdl_Impl ) );
142 aBtnSave.SetClickHdl(
143 LINK( this, SvxLineEndDefTabPage, ClickSaveHdl_Impl ) );
145 aLbLineEnds.SetSelectHdl(
146 LINK( this, SvxLineEndDefTabPage, SelectLineEndHdl_Impl ) );
150 //------------------------------------------------------------------------
152 SvxLineEndDefTabPage::~SvxLineEndDefTabPage()
156 // -----------------------------------------------------------------------
158 void SvxLineEndDefTabPage::Construct()
160 aLbLineEnds.Fill( pLineEndList );
162 bool bCreateArrowPossible = true;
164 if( !pPolyObj )
166 bCreateArrowPossible = false;
168 else if( !pPolyObj->ISA( SdrPathObj ) )
170 SdrObjTransformInfoRec aInfoRec;
171 pPolyObj->TakeObjInfo( aInfoRec );
172 SdrObject* pNewObj = 0;
173 if( aInfoRec.bCanConvToPath )
174 pNewObj = pPolyObj->ConvertToPolyObj( TRUE, FALSE );
176 bCreateArrowPossible = pNewObj && pNewObj->ISA( SdrPathObj );
177 SdrObject::Free( pNewObj );
180 if( !bCreateArrowPossible )
181 aBtnAdd.Disable();
184 // -----------------------------------------------------------------------
186 void SvxLineEndDefTabPage::ActivatePage( const SfxItemSet& )
188 if( *pDlgType == 0 ) // Flaechen-Dialog
190 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!!
191 if( pLineEndList )
193 if( *pPosLineEndLb != LISTBOX_ENTRY_NOTFOUND )
195 aLbLineEnds.SelectEntryPos( *pPosLineEndLb );
196 SelectLineEndHdl_Impl( this );
198 INetURLObject aURL( pLineEndList->GetPath() );
200 aURL.Append( pLineEndList->GetName() );
201 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
202 /* // Ermitteln (evtl. abschneiden) des Namens und in
203 // der GroupBox darstellen
204 String aString( SVX_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
206 if ( aURL.getBase().Len() > 18 )
208 aString += aURL.getBase().Copy( 0, 15 );
209 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
211 else
212 aString += aURL.getBase();
214 aGrpLineEnds.SetText( aString );
216 *pPageType = 0; // 3
217 *pPosLineEndLb = LISTBOX_ENTRY_NOTFOUND;
222 // -----------------------------------------------------------------------
224 int SvxLineEndDefTabPage::DeactivatePage( SfxItemSet* _pSet )
226 CheckChanges_Impl();
228 if( _pSet )
229 FillItemSet( *_pSet );
231 return( LEAVE_PAGE );
234 // -----------------------------------------------------------------------
236 void SvxLineEndDefTabPage::CheckChanges_Impl()
238 USHORT nPos = aLbLineEnds.GetSelectEntryPos();
240 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
242 String aString = aEdtName.GetText();
244 if( aString != aLbLineEnds.GetSelectEntry() )
246 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
247 //! SVX_RES( RID_SVXSTR_LINEEND ),
248 String( SVX_RES( RID_SVXSTR_ASK_CHANGE_LINEEND ) ) );
250 if ( aQueryBox.Execute() == RET_YES )
251 ClickModifyHdl_Impl( this );
254 nPos = aLbLineEnds.GetSelectEntryPos();
256 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
257 *pPosLineEndLb = nPos;
260 // -----------------------------------------------------------------------
262 BOOL SvxLineEndDefTabPage::FillItemSet( SfxItemSet& rSet )
264 if( *pDlgType == 0 ) // Linien-Dialog
266 if( *pPageType == 3 )
268 CheckChanges_Impl();
270 long nPos = aLbLineEnds.GetSelectEntryPos();
271 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
273 rSet.Put( XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ) );
274 rSet.Put( XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ) );
277 return( TRUE );
280 // -----------------------------------------------------------------------
282 void SvxLineEndDefTabPage::Reset( const SfxItemSet& )
284 aLbLineEnds.SelectEntryPos( 0 );
286 // Update lineend
287 if( pLineEndList->Count() > 0 )
289 int nPos = aLbLineEnds.GetSelectEntryPos();
291 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
293 aEdtName.SetText( aLbLineEnds.GetSelectEntry() );
295 rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) );
296 rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) );
298 // #i34740#
299 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
301 aCtlPreview.Invalidate();
304 // Status der Buttons ermitteln
305 if( pLineEndList->Count() )
307 aBtnModify.Enable();
308 aBtnDelete.Enable();
309 aBtnSave.Enable();
311 else
313 aBtnModify.Disable();
314 aBtnDelete.Disable();
315 aBtnSave.Disable();
319 // -----------------------------------------------------------------------
321 SfxTabPage* SvxLineEndDefTabPage::Create( Window* pWindow,
322 const SfxItemSet& rSet )
324 return( new SvxLineEndDefTabPage( pWindow, rSet ) );
327 //------------------------------------------------------------------------
329 IMPL_LINK( SvxLineEndDefTabPage, SelectLineEndHdl_Impl, void *, EMPTYARG )
331 if( pLineEndList->Count() > 0 )
333 int nPos = aLbLineEnds.GetSelectEntryPos();
335 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
337 aEdtName.SetText( aLbLineEnds.GetSelectEntry() );
339 rXLSet.Put( XLineStartItem( String(), pEntry->GetLineEnd() ) );
340 rXLSet.Put( XLineEndItem( String(), pEntry->GetLineEnd() ) );
342 // #i34740#
343 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
345 aCtlPreview.Invalidate();
347 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen,
348 // wenn in der ListBox ein Eintrag ausgewaehlt wurde
349 *pPageType = 3;
351 return( 0L );
354 //------------------------------------------------------------------------
356 long SvxLineEndDefTabPage::ChangePreviewHdl_Impl( void* )
358 aCtlPreview.Invalidate();
359 return( 0L );
362 //------------------------------------------------------------------------
364 IMPL_LINK( SvxLineEndDefTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
366 USHORT nPos = aLbLineEnds.GetSelectEntryPos();
368 if( nPos != LISTBOX_ENTRY_NOTFOUND )
370 ResMgr& rMgr = DIALOG_MGR();
371 String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) );
372 String aName( aEdtName.GetText() );
373 long nCount = pLineEndList->Count();
374 BOOL bDifferent = TRUE;
376 // Pruefen, ob Name schon vorhanden ist
377 for ( long i = 0; i < nCount && bDifferent; i++ )
378 if ( aName == pLineEndList->GetLineEnd( i )->GetName() )
379 bDifferent = FALSE;
381 // Wenn ja, wird wiederholt ein neuer Name angefordert
382 if ( !bDifferent )
384 WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ),
385 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
386 aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
387 aWarningBox.Execute();
389 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
390 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
391 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
392 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc, RID_SVXDLG_NAME );
393 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
394 BOOL bLoop = TRUE;
396 while( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
398 pDlg->GetName( aName );
399 bDifferent = TRUE;
401 for( long i = 0; i < nCount && bDifferent; i++ )
403 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
404 bDifferent = FALSE;
407 if( bDifferent )
408 bLoop = FALSE;
409 else
410 aWarningBox.Execute();
412 delete( pDlg );
415 // Wenn nicht vorhanden, wird Eintrag aufgenommen
416 if( bDifferent )
418 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
420 pEntry->SetName( aName );
421 aEdtName.SetText( aName );
423 aLbLineEnds.Modify( pEntry, nPos, pLineEndList->GetBitmap( nPos ) );
424 aLbLineEnds.SelectEntryPos( nPos );
426 // Flag fuer modifiziert setzen
427 *pnLineEndListState |= CT_MODIFIED;
429 *pPageType = 3;
432 return( 0L );
435 //------------------------------------------------------------------------
437 IMPL_LINK( SvxLineEndDefTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
439 if( pPolyObj )
441 const SdrObject* pNewObj;
442 SdrObject* pConvPolyObj = NULL;
444 if( pPolyObj->ISA( SdrPathObj ) )
446 pNewObj = pPolyObj;
448 else
450 SdrObjTransformInfoRec aInfoRec;
451 pPolyObj->TakeObjInfo( aInfoRec );
453 if( aInfoRec.bCanConvToPath )
455 pNewObj = pConvPolyObj = pPolyObj->ConvertToPolyObj( TRUE, FALSE );
457 if( !pNewObj || !pNewObj->ISA( SdrPathObj ) )
458 return( 0L ); // Abbruch, zusaetzliche Sicherheit, die bei
459 // Gruppenobjekten aber nichts bringt.
461 else return( 0L ); // Abbruch
464 basegfx::B2DPolyPolygon aNewPolyPolygon(((SdrPathObj*)pNewObj)->GetPathPoly());
465 basegfx::B2DRange aNewRange(basegfx::tools::getRange(aNewPolyPolygon));
467 // Normalisieren
468 basegfx::B2DHomMatrix aMatrix;
469 aMatrix.translate(-aNewRange.getMinX(), -aNewRange.getMinY());
470 aNewPolyPolygon.transform(aMatrix);
472 // Loeschen des angelegten PolyObjektes
473 SdrObject::Free( pConvPolyObj );
475 XLineEndEntry* pEntry;
477 ResMgr& rMgr = DIALOG_MGR();
478 String aNewName( ResId( RID_SVXSTR_LINEEND, rMgr ) );
479 String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) );
480 String aName;
482 long nCount = pLineEndList->Count();
483 long j = 1;
484 BOOL bDifferent = FALSE;
486 while ( !bDifferent )
488 aName = aNewName;
489 aName += sal_Unicode(' ');
490 aName += UniString::CreateFromInt32( j++ );
491 bDifferent = TRUE;
493 for( long i = 0; i < nCount && bDifferent; i++ )
494 if ( aName == pLineEndList->GetLineEnd( i )->GetName() )
495 bDifferent = FALSE;
498 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
499 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
500 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
501 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc, RID_SVXDLG_NAME );
502 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
503 BOOL bLoop = TRUE;
505 while ( bLoop && pDlg->Execute() == RET_OK )
507 pDlg->GetName( aName );
508 bDifferent = TRUE;
510 for( long i = 0; i < nCount && bDifferent; i++ )
512 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
513 bDifferent = FALSE;
516 if( bDifferent )
518 bLoop = FALSE;
519 pEntry = new XLineEndEntry( aNewPolyPolygon, aName );
521 long nLineEndCount = pLineEndList->Count();
522 pLineEndList->Insert( pEntry, nLineEndCount );
523 Bitmap* pBitmap = pLineEndList->GetBitmap( nLineEndCount );
525 // Zur ListBox hinzufuegen
526 aLbLineEnds.Append( pEntry, pBitmap );
527 aLbLineEnds.SelectEntryPos( aLbLineEnds.GetEntryCount() - 1 );
529 // Flag fuer modifiziert setzen
530 *pnLineEndListState |= CT_MODIFIED;
532 SelectLineEndHdl_Impl( this );
534 else
536 WarningBox aBox( DLGWIN, WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
537 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
538 aBox.Execute();
541 delete pDlg;
543 else
544 aBtnAdd.Disable();
546 // Status der Buttons ermitteln
547 if ( pLineEndList->Count() )
549 aBtnModify.Enable();
550 aBtnDelete.Enable();
551 aBtnSave.Enable();
553 return( 0L );
556 //------------------------------------------------------------------------
558 IMPL_LINK( SvxLineEndDefTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
560 USHORT nPos = aLbLineEnds.GetSelectEntryPos();
562 if( nPos != LISTBOX_ENTRY_NOTFOUND )
564 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
565 //! SVX_RES( RID_SVXSTR_DEL_LINEEND ),
566 String( SVX_RES( RID_SVXSTR_ASK_DEL_LINEEND ) ) );
568 if ( aQueryBox.Execute() == RET_YES )
570 delete pLineEndList->Remove( nPos );
571 aLbLineEnds.RemoveEntry( nPos );
572 aLbLineEnds.SelectEntryPos( 0 );
574 SelectLineEndHdl_Impl( this );
575 *pPageType = 0; // LineEnd soll nicht uebernommen werden
577 // Flag fuer modifiziert setzen
578 *pnLineEndListState |= CT_MODIFIED;
580 ChangePreviewHdl_Impl( this );
583 // Status der Buttons ermitteln
584 if( !pLineEndList->Count() )
586 aBtnModify.Disable();
587 aBtnDelete.Disable();
588 aBtnSave.Disable();
590 return( 0L );
593 //------------------------------------------------------------------------
595 IMPL_LINK( SvxLineEndDefTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
597 ResMgr& rMgr = DIALOG_MGR();
598 USHORT nReturn = RET_YES;
600 if ( *pnLineEndListState & CT_MODIFIED )
602 nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
603 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
605 if ( nReturn == RET_YES )
606 pLineEndList->Save();
609 if ( nReturn != RET_CANCEL )
611 ::sfx2::FileDialogHelper aDlg(
612 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
613 0 );
614 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
615 aDlg.AddFilter( aStrFilterType, aStrFilterType );
616 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
617 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
619 if( aDlg.Execute() == ERRCODE_NONE )
621 INetURLObject aURL( aDlg.GetPath() );
622 INetURLObject aPathURL( aURL );
624 aPathURL.removeSegment();
625 aPathURL.removeFinalSlash();
627 // Liste speichern
628 XLineEndList* pLeList = new XLineEndList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool );
629 pLeList->SetName( aURL.getName() );
630 if( pLeList->Load() )
632 if( pLeList )
634 // Pruefen, ob Tabelle geloescht werden darf:
635 if( pLineEndList != ( (SvxLineTabDialog*) DLGWIN )->GetLineEndList() )
636 delete pLineEndList;
638 pLineEndList = pLeList;
639 ( (SvxLineTabDialog*) DLGWIN )->SetNewLineEndList( pLineEndList );
640 aLbLineEnds.Clear();
641 aLbLineEnds.Fill( pLineEndList );
642 Reset( rOutAttrs );
644 pLineEndList->SetName( aURL.getName() );
646 /* // Ermitteln (evtl. abschneiden) des Namens und in
647 // der GroupBox darstellen
648 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
649 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
650 if( aURL.getBase().Len() > 18 )
652 aString += aURL.getBase().Copy( 0, 15 );
653 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
655 else
656 aString += aURL.getBase();
658 aGrpLineEnds.SetText( aString );
660 // Flag fuer gewechselt setzen
661 *pnLineEndListState |= CT_CHANGED;
662 // Flag fuer modifiziert entfernen
663 *pnLineEndListState &= ~CT_MODIFIED;
666 else
667 ErrorBox( DLGWIN, WinBits( WB_OK ),
668 String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
672 // Status der Buttons ermitteln
673 if ( pLineEndList->Count() )
675 aBtnModify.Enable();
676 aBtnDelete.Enable();
677 aBtnSave.Enable();
679 else
681 aBtnModify.Disable();
682 aBtnDelete.Disable();
683 aBtnSave.Disable();
685 return( 0L );
688 //------------------------------------------------------------------------
690 IMPL_LINK( SvxLineEndDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
692 ::sfx2::FileDialogHelper aDlg(
693 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
694 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
695 aDlg.AddFilter( aStrFilterType, aStrFilterType );
697 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
698 DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
700 if( pLineEndList->GetName().Len() )
702 aFile.Append( pLineEndList->GetName() );
704 if( !aFile.getExtension().getLength() )
705 aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soe" ) ) );
708 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
709 if ( aDlg.Execute() == ERRCODE_NONE )
711 INetURLObject aURL( aDlg.GetPath() );
712 INetURLObject aPathURL( aURL );
714 aPathURL.removeSegment();
715 aPathURL.removeFinalSlash();
717 pLineEndList->SetName( aURL.getName() );
718 pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
720 if( pLineEndList->Save() )
722 /* // Ermitteln (evtl. abschneiden) des Namens und in
723 // der GroupBox darstellen
724 String aString( SVX_RES( RID_SVXSTR_TABLE ) );
725 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
727 if ( aURL.getBase().Len() > 18 )
729 aString += aURL.getBase().Copy( 0, 15 );
730 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
732 else
733 aString += aURL.getBase();
734 aGrpLineEnds.SetText( aString );
736 // Flag fuer gespeichert setzen
737 *pnLineEndListState |= CT_SAVED;
738 // Flag fuer modifiziert entfernen
739 *pnLineEndListState &= ~CT_MODIFIED;
741 else
743 ErrorBox( DLGWIN, WinBits( WB_OK ),
744 String( SVX_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
747 return( 0L );
750 void SvxLineEndDefTabPage::DataChanged( const DataChangedEvent& rDCEvt )
752 SfxTabPage::DataChanged( rDCEvt );
754 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
756 USHORT nOldSelect = aLbLineEnds.GetSelectEntryPos();
757 aLbLineEnds.Clear();
758 aLbLineEnds.Fill( pLineEndList );
759 aLbLineEnds.SelectEntryPos( nOldSelect );