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