xref: /aoo42x/main/cui/source/tabpages/tplneend.cxx (revision 3e407bd8)
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     maLineEndList()
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( maLineEndList );
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( maLineEndList.get() )
181 		{
182             if( *pPosLineEndLb != LISTBOX_ENTRY_NOTFOUND )
183 			{
184 				aLbLineEnds.SelectEntryPos( *pPosLineEndLb );
185 				SelectLineEndHdl_Impl( this );
186 			}
187 			INetURLObject	aURL( maLineEndList->GetPath() );
188 
189 			aURL.Append( maLineEndList->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 = maLineEndList->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( maLineEndList.get() && maLineEndList->Count() > 0 )
276 	{
277 		int nPos = aLbLineEnds.GetSelectEntryPos();
278 
279         XLineEndEntry* pEntry = maLineEndList->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( maLineEndList.get() && maLineEndList->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( maLineEndList.get() && maLineEndList->Count() > 0 )
320 	{
321 		int nPos = aLbLineEnds.GetSelectEntryPos();
322 
323         XLineEndEntry* pEntry = maLineEndList->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 = maLineEndList.get() ? maLineEndList->Count() : 0;
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 == maLineEndList->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 == maLineEndList->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             const XLineEndEntry* pEntry = maLineEndList->GetLineEnd( nPos );
406 
407             aEdtName.SetText( aName );
408 
409             const XLineEndEntry aEntry(pEntry->GetLineEnd(), aName);
410 
411             aLbLineEnds.Modify( aEntry, nPos, maLineEndList->GetUiBitmap( nPos ) );
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 = maLineEndList.get() ? maLineEndList->Count() : 0;
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 == maLineEndList->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 == maLineEndList->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 = maLineEndList.get() ? maLineEndList->Count() : 0;
508                 maLineEndList->Insert( pEntry, nLineEndCount );
509 
510 				// Zur ListBox hinzufuegen
511 				aLbLineEnds.Append( *pEntry, maLineEndList->GetUiBitmap( nLineEndCount ) );
512 				aLbLineEnds.SelectEntryPos( aLbLineEnds.GetEntryCount() - 1 );
513 
514 				// Flag fuer modifiziert setzen
515 				*pnLineEndListState |= CT_MODIFIED;
516 
517 				SelectLineEndHdl_Impl( this );
518 			}
519 			else
520 			{
521 				WarningBox aBox( DLGWIN, WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
522 				aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
523 				aBox.Execute();
524 			}
525 		}
526 		delete pDlg;
527 	}
528 	else
529 		aBtnAdd.Disable();
530 
531 	// Status der Buttons ermitteln
532 	if ( maLineEndList.get() && maLineEndList->Count() )
533 	{
534 		aBtnModify.Enable();
535 		aBtnDelete.Enable();
536 		aBtnSave.Enable();
537 	}
538 	return( 0L );
539 }
540 
541 //------------------------------------------------------------------------
542 
543 IMPL_LINK( SvxLineEndDefTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
544 {
545 	sal_uInt16 nPos = aLbLineEnds.GetSelectEntryPos();
546 
547 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
548 	{
549 		QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
550 			String( CUI_RES( RID_SVXSTR_ASK_DEL_LINEEND ) ) );
551 
552 		if ( aQueryBox.Execute() == RET_YES )
553 		{
554 			delete maLineEndList->Remove( nPos );
555 			aLbLineEnds.RemoveEntry( nPos );
556 			aLbLineEnds.SelectEntryPos( 0 );
557 
558 			SelectLineEndHdl_Impl( this );
559 			*pPageType = 0; // LineEnd soll nicht uebernommen werden
560 
561 			// Flag fuer modifiziert setzen
562 			*pnLineEndListState |= CT_MODIFIED;
563 
564 			ChangePreviewHdl_Impl( this );
565 		}
566 	}
567 	// Status der Buttons ermitteln
568 	if( !maLineEndList.get() || !maLineEndList->Count() )
569 	{
570 		aBtnModify.Disable();
571 		aBtnDelete.Disable();
572 		aBtnSave.Disable();
573 	}
574 	return( 0L );
575 }
576 
577 //------------------------------------------------------------------------
578 
579 IMPL_LINK( SvxLineEndDefTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
580 {
581 	ResMgr& rMgr = CUI_MGR();
582 	sal_uInt16 nReturn = RET_YES;
583 
584 	if ( *pnLineEndListState & CT_MODIFIED )
585 	{
586 		nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
587 			String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
588 
589 		if ( nReturn == RET_YES )
590 			maLineEndList->Save();
591 	}
592 
593 	if ( nReturn != RET_CANCEL )
594 	{
595     	::sfx2::FileDialogHelper aDlg(
596             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
597             0 );
598 		String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
599 		aDlg.AddFilter( aStrFilterType, aStrFilterType );
600 		INetURLObject aFile( SvtPathOptions().GetPalettePath() );
601 		aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
602 
603 		if( aDlg.Execute() == ERRCODE_NONE )
604 		{
605 			INetURLObject aURL( aDlg.GetPath() );
606 			INetURLObject aPathURL( aURL );
607 
608 			aPathURL.removeSegment();
609 			aPathURL.removeFinalSlash();
610 
611 			// Liste speichern
612 			XLineEndListSharedPtr aLeList(XPropertyListFactory::CreateSharedXLineEndList(aPathURL.GetMainURL(INetURLObject::NO_DECODE)));
613 			aLeList->SetName( aURL.getName() );
614 			if( aLeList->Load() )
615 			{
616 				if( aLeList.get() )
617 				{
618 					maLineEndList = aLeList;
619 					( (SvxLineTabDialog*) DLGWIN )->SetNewLineEndList( maLineEndList );
620 					aLbLineEnds.Clear();
621 					aLbLineEnds.Fill( maLineEndList );
622 					Reset( rOutAttrs );
623 
624 					maLineEndList->SetName( aURL.getName() );
625 
626 /*					// Ermitteln (evtl. abschneiden) des Namens und in
627 					// der GroupBox darstellen
628 					String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
629 					aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
630 					if( aURL.getBase().Len() > 18 )
631 					{
632 						aString += aURL.getBase().Copy( 0, 15 );
633 						aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
634 					}
635 					else
636 						aString += aURL.getBase();
637 
638 					aGrpLineEnds.SetText( aString );
639 */
640 					// Flag fuer gewechselt setzen
641 					*pnLineEndListState |= CT_CHANGED;
642 					// Flag fuer modifiziert entfernen
643 					*pnLineEndListState &= ~CT_MODIFIED;
644 				}
645 			}
646 			else
647 				ErrorBox( DLGWIN, WinBits( WB_OK ),
648 					String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
649 		}
650 	}
651 
652 	// Status der Buttons ermitteln
653 	if ( maLineEndList.get() && maLineEndList->Count() )
654 	{
655 		aBtnModify.Enable();
656 		aBtnDelete.Enable();
657 		aBtnSave.Enable();
658 	}
659 	else
660 	{
661 		aBtnModify.Disable();
662 		aBtnDelete.Disable();
663 		aBtnSave.Disable();
664 	}
665 	return( 0L );
666 }
667 
668 //------------------------------------------------------------------------
669 
670 IMPL_LINK( SvxLineEndDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
671 {
672    	::sfx2::FileDialogHelper aDlg(
673         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
674 	String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
675 	aDlg.AddFilter( aStrFilterType, aStrFilterType );
676 
677 	INetURLObject aFile( SvtPathOptions().GetPalettePath() );
678 	DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
679 
680 	if( maLineEndList.get() && maLineEndList->GetName().Len() )
681 	{
682 		aFile.Append( maLineEndList->GetName() );
683 
684 		if( !aFile.getExtension().getLength() )
685 			aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soe" ) ) );
686 	}
687 
688 	aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
689 	if ( aDlg.Execute() == ERRCODE_NONE )
690 	{
691 		INetURLObject	aURL( aDlg.GetPath() );
692 		INetURLObject	aPathURL( aURL );
693 
694 		aPathURL.removeSegment();
695 		aPathURL.removeFinalSlash();
696 
697 		maLineEndList->SetName( aURL.getName() );
698 		maLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
699 
700 		if( maLineEndList->Save() )
701 		{
702 /*			// Ermitteln (evtl. abschneiden) des Namens und in
703 			// der GroupBox darstellen
704 			String aString( CUI_RES( RID_SVXSTR_TABLE ) );
705 			aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
706 
707 			if ( aURL.getBase().Len() > 18 )
708 			{
709 				aString += aURL.getBase().Copy( 0, 15 );
710 				aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
711 			}
712 			else
713 				aString += aURL.getBase();
714 			aGrpLineEnds.SetText( aString );
715 */
716 			// Flag fuer gespeichert setzen
717 			*pnLineEndListState |= CT_SAVED;
718 			// Flag fuer modifiziert entfernen
719 			*pnLineEndListState &= ~CT_MODIFIED;
720 		}
721 		else
722 		{
723 			ErrorBox( DLGWIN, WinBits( WB_OK ),
724 				String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
725 		}
726 	}
727 	return( 0L );
728 }
729 
730 void SvxLineEndDefTabPage::DataChanged( const DataChangedEvent& rDCEvt )
731 {
732 	SfxTabPage::DataChanged( rDCEvt );
733 
734 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
735 	{
736 		sal_uInt16 nOldSelect = aLbLineEnds.GetSelectEntryPos();
737 		aLbLineEnds.Clear();
738 		aLbLineEnds.Fill( maLineEndList );
739 		aLbLineEnds.SelectEntryPos( nOldSelect );
740 	}
741 }
742 
743