xref: /AOO41X/main/cui/source/tabpages/tplneend.cxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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             aLbLineEnds.Modify( pEntry, nPos, pLineEndList->GetBitmap( nPos ) );
411             aLbLineEnds.SelectEntryPos( nPos );
412 
413             // Flag fuer modifiziert setzen
414             *pnLineEndListState |= CT_MODIFIED;
415 
416             *pPageType = 3;
417         }
418     }
419     return( 0L );
420 }
421 
422 //------------------------------------------------------------------------
423 
424 IMPL_LINK( SvxLineEndDefTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
425 {
426     if( pPolyObj )
427     {
428         const SdrObject* pNewObj;
429         SdrObject* pConvPolyObj = NULL;
430 
431         if( pPolyObj->ISA( SdrPathObj ) )
432         {
433             pNewObj = pPolyObj;
434         }
435         else
436         {
437             SdrObjTransformInfoRec aInfoRec;
438             pPolyObj->TakeObjInfo( aInfoRec );
439 
440             if( aInfoRec.bCanConvToPath )
441             {
442                 pNewObj = pConvPolyObj = pPolyObj->ConvertToPolyObj( sal_True, sal_False );
443 
444                 if( !pNewObj || !pNewObj->ISA( SdrPathObj ) )
445                     return( 0L ); // Abbruch, zusaetzliche Sicherheit, die bei
446                             // Gruppenobjekten aber nichts bringt.
447             }
448             else return( 0L ); // Abbruch
449         }
450 
451         basegfx::B2DPolyPolygon aNewPolyPolygon(((SdrPathObj*)pNewObj)->GetPathPoly());
452         basegfx::B2DRange aNewRange(basegfx::tools::getRange(aNewPolyPolygon));
453 
454         // Normalisieren
455         aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(
456             -aNewRange.getMinX(), -aNewRange.getMinY()));
457 
458         // Loeschen des angelegten PolyObjektes
459         SdrObject::Free( pConvPolyObj );
460 
461         XLineEndEntry* pEntry;
462 
463         ResMgr& rMgr = CUI_MGR();
464         String aNewName( SVX_RES( RID_SVXSTR_LINEEND ) );
465         String aDesc( ResId( RID_SVXSTR_DESC_LINEEND, rMgr ) );
466         String aName;
467 
468         long nCount = pLineEndList->Count();
469         long j = 1;
470         sal_Bool bDifferent = sal_False;
471 
472         while ( !bDifferent )
473         {
474             aName = aNewName;
475             aName += sal_Unicode(' ');
476             aName += UniString::CreateFromInt32( j++ );
477             bDifferent = sal_True;
478 
479             for( long i = 0; i < nCount && bDifferent; i++ )
480                 if ( aName == pLineEndList->GetLineEnd( i )->GetName() )
481                     bDifferent = sal_False;
482         }
483 
484         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
485         DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
486         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
487         DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
488         sal_Bool bLoop = sal_True;
489 
490         while ( bLoop && pDlg->Execute() == RET_OK )
491         {
492             pDlg->GetName( aName );
493             bDifferent = sal_True;
494 
495             for( long i = 0; i < nCount && bDifferent; i++ )
496             {
497                 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
498                     bDifferent = sal_False;
499             }
500 
501             if( bDifferent )
502             {
503                 bLoop = sal_False;
504                 pEntry = new XLineEndEntry( aNewPolyPolygon, aName );
505 
506                 long nLineEndCount = pLineEndList->Count();
507                 pLineEndList->Insert( pEntry, nLineEndCount );
508                 Bitmap* pBitmap = pLineEndList->GetBitmap( nLineEndCount );
509 
510                 // Zur ListBox hinzufuegen
511                 aLbLineEnds.Append( pEntry, pBitmap );
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 ( pLineEndList->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 pLineEndList->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( !pLineEndList->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             pLineEndList->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             XLineEndList* pLeList = new XLineEndList( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool );
613             pLeList->SetName( aURL.getName() );
614             if( pLeList->Load() )
615             {
616                 if( pLeList )
617                 {
618                     // Pruefen, ob Tabelle geloescht werden darf:
619                     if( pLineEndList != ( (SvxLineTabDialog*) DLGWIN )->GetLineEndList() )
620                         delete pLineEndList;
621 
622                     pLineEndList = pLeList;
623                     ( (SvxLineTabDialog*) DLGWIN )->SetNewLineEndList( pLineEndList );
624                     aLbLineEnds.Clear();
625                     aLbLineEnds.Fill( pLineEndList );
626                     Reset( rOutAttrs );
627 
628                     pLineEndList->SetName( aURL.getName() );
629 
630 /*                  // Ermitteln (evtl. abschneiden) des Namens und in
631                     // der GroupBox darstellen
632                     String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
633                     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
634                     if( aURL.getBase().Len() > 18 )
635                     {
636                         aString += aURL.getBase().Copy( 0, 15 );
637                         aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
638                     }
639                     else
640                         aString += aURL.getBase();
641 
642                     aGrpLineEnds.SetText( aString );
643 */
644                     // Flag fuer gewechselt setzen
645                     *pnLineEndListState |= CT_CHANGED;
646                     // Flag fuer modifiziert entfernen
647                     *pnLineEndListState &= ~CT_MODIFIED;
648                 }
649             }
650             else
651                 ErrorBox( DLGWIN, WinBits( WB_OK ),
652                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
653         }
654     }
655 
656     // Status der Buttons ermitteln
657     if ( pLineEndList->Count() )
658     {
659         aBtnModify.Enable();
660         aBtnDelete.Enable();
661         aBtnSave.Enable();
662     }
663     else
664     {
665         aBtnModify.Disable();
666         aBtnDelete.Disable();
667         aBtnSave.Disable();
668     }
669     return( 0L );
670 }
671 
672 //------------------------------------------------------------------------
673 
674 IMPL_LINK( SvxLineEndDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
675 {
676     ::sfx2::FileDialogHelper aDlg(
677         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
678     String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soe" ) );
679     aDlg.AddFilter( aStrFilterType, aStrFilterType );
680 
681     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
682     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
683 
684     if( pLineEndList->GetName().Len() )
685     {
686         aFile.Append( pLineEndList->GetName() );
687 
688         if( !aFile.getExtension().getLength() )
689             aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soe" ) ) );
690     }
691 
692     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
693     if ( aDlg.Execute() == ERRCODE_NONE )
694     {
695         INetURLObject   aURL( aDlg.GetPath() );
696         INetURLObject   aPathURL( aURL );
697 
698         aPathURL.removeSegment();
699         aPathURL.removeFinalSlash();
700 
701         pLineEndList->SetName( aURL.getName() );
702         pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
703 
704         if( pLineEndList->Save() )
705         {
706 /*          // Ermitteln (evtl. abschneiden) des Namens und in
707             // der GroupBox darstellen
708             String aString( CUI_RES( RID_SVXSTR_TABLE ) );
709             aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
710 
711             if ( aURL.getBase().Len() > 18 )
712             {
713                 aString += aURL.getBase().Copy( 0, 15 );
714                 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
715             }
716             else
717                 aString += aURL.getBase();
718             aGrpLineEnds.SetText( aString );
719 */
720             // Flag fuer gespeichert setzen
721             *pnLineEndListState |= CT_SAVED;
722             // Flag fuer modifiziert entfernen
723             *pnLineEndListState &= ~CT_MODIFIED;
724         }
725         else
726         {
727             ErrorBox( DLGWIN, WinBits( WB_OK ),
728                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
729         }
730     }
731     return( 0L );
732 }
733 
734 void SvxLineEndDefTabPage::DataChanged( const DataChangedEvent& rDCEvt )
735 {
736     SfxTabPage::DataChanged( rDCEvt );
737 
738     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
739     {
740         sal_uInt16 nOldSelect = aLbLineEnds.GetSelectEntryPos();
741         aLbLineEnds.Clear();
742         aLbLineEnds.Fill( pLineEndList );
743         aLbLineEnds.SelectEntryPos( nOldSelect );
744     }
745 }
746 
747