1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tplnedef.cxx,v $
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
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/module.hxx>
45 #include <sfx2/filedlghelper.hxx>
46 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
48 #define _SVX_TPLNEDEF_CXX
50 #include <svx/dialogs.hrc>
51 #include "tabline.hrc"
52 #include "dlgname.hrc"
59 #include <svx/xpool.hxx>
60 #include <svx/xtable.hxx>
62 #include "drawitem.hxx"
63 #include "cuitabline.hxx"
64 #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx"
65 #include <svx/svxdlg.hxx> //CHINA001
66 #include <svx/dialmgr.hxx>
67 #include "dlgutil.hxx"
69 #define DLGWIN this->GetParent()->GetParent()
71 #define BITMAP_WIDTH 32
72 #define BITMAP_HEIGHT 12
73 #define XOUT_WIDTH 150
75 /*************************************************************************
77 |* Dialog zum Definieren von Linienstilen
79 \************************************************************************/
81 SvxLineDefTabPage::SvxLineDefTabPage
84 const SfxItemSet
& rInAttrs
87 SfxTabPage( pParent
, SVX_RES( RID_SVXPAGE_LINE_DEF
), rInAttrs
),
89 aFlDefinition ( this, SVX_RES( FL_DEFINITION
) ),
90 aFTLinestyle ( this, SVX_RES( FT_LINESTYLE
) ),
91 aLbLineStyles ( this, SVX_RES( LB_LINESTYLES
) ),
92 aFtType ( this, SVX_RES( FT_TYPE
) ),
93 aLbType1 ( this, SVX_RES( LB_TYPE_1
) ),
94 aLbType2 ( this, SVX_RES( LB_TYPE_2
) ),
95 aFtNumber ( this, SVX_RES( FT_NUMBER
) ),
96 aNumFldNumber1 ( this, SVX_RES( NUM_FLD_1
) ),
97 aNumFldNumber2 ( this, SVX_RES( NUM_FLD_2
) ),
98 aFtLength ( this, SVX_RES( FT_LENGTH
) ),
99 aMtrLength1 ( this, SVX_RES( MTR_FLD_LENGTH_1
) ),
100 aMtrLength2 ( this, SVX_RES( MTR_FLD_LENGTH_2
) ),
101 aFtDistance ( this, SVX_RES( FT_DISTANCE
) ),
102 aMtrDistance ( this, SVX_RES( MTR_FLD_DISTANCE
) ),
103 aCbxSynchronize ( this, SVX_RES( CBX_SYNCHRONIZE
) ),
104 aBtnAdd ( this, SVX_RES( BTN_ADD
) ),
105 aBtnModify ( this, SVX_RES( BTN_MODIFY
) ),
106 aBtnDelete ( this, SVX_RES( BTN_DELETE
) ),
107 aBtnLoad ( this, SVX_RES( BTN_LOAD
) ),
108 aBtnSave ( this, SVX_RES( BTN_SAVE
) ),
109 aCtlPreview ( this, SVX_RES( CTL_PREVIEW
) ),
111 rOutAttrs ( rInAttrs
),
113 pXPool ( (XOutdevItemPool
*) rInAttrs
.GetPool() ),
114 aXLStyle ( XLINE_DASH
),
115 aXWidth ( XOUT_WIDTH
),
116 aXDash ( String(), XDash( XDASH_RECT
, 3, 7, 2, 40, 15 ) ),
117 aXColor ( String(), COL_BLACK
),
118 aXLineAttr ( pXPool
),
119 rXLSet ( aXLineAttr
.GetItemSet() )
121 aBtnLoad
.SetModeImage( Image( SVX_RES( RID_SVXIMG_LOAD_H
) ), BMP_COLOR_HIGHCONTRAST
);
122 aBtnSave
.SetModeImage( Image( SVX_RES( RID_SVXIMG_SAVE_H
) ), BMP_COLOR_HIGHCONTRAST
);
126 // diese Page braucht ExchangeSupport
127 SetExchangeSupport();
130 eFUnit
= GetModuleFieldUnit( &rInAttrs
);
138 default: ; //prevent warning
140 SetFieldUnit( aMtrDistance
, eFUnit
);
141 SetFieldUnit( aMtrLength1
, eFUnit
);
142 SetFieldUnit( aMtrLength2
, eFUnit
);
144 // PoolUnit ermitteln
145 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
146 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
147 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
149 rXLSet
.Put( aXLStyle
);
150 rXLSet
.Put( aXWidth
);
151 rXLSet
.Put( aXDash
);
152 rXLSet
.Put( aXColor
);
155 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
157 aBtnAdd
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickAddHdl_Impl
) );
158 aBtnModify
.SetClickHdl(
159 LINK( this, SvxLineDefTabPage
, ClickModifyHdl_Impl
) );
160 aBtnDelete
.SetClickHdl(
161 LINK( this, SvxLineDefTabPage
, ClickDeleteHdl_Impl
) );
162 aBtnLoad
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickLoadHdl_Impl
) );
163 aBtnSave
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickSaveHdl_Impl
) );
165 aNumFldNumber1
.SetModifyHdl(
166 LINK( this, SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
) );
167 aNumFldNumber2
.SetModifyHdl(
168 LINK( this, SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
) );
169 aLbLineStyles
.SetSelectHdl(
170 LINK( this, SvxLineDefTabPage
, SelectLinestyleHdl_Impl
) );
172 // Absolut (in mm) oder Relativ (in %)
173 aCbxSynchronize
.SetClickHdl(
174 LINK( this, SvxLineDefTabPage
, ChangeMetricHdl_Impl
) );
176 // Wenn sich etwas aendert, muss Preview upgedatet werden werden
177 Link aLink
= LINK( this, SvxLineDefTabPage
, SelectTypeHdl_Impl
);
178 aLbType1
.SetSelectHdl( aLink
);
179 aLbType2
.SetSelectHdl( aLink
);
180 aLink
= LINK( this, SvxLineDefTabPage
, ChangePreviewHdl_Impl
);
181 aMtrLength1
.SetModifyHdl( aLink
);
182 aMtrLength2
.SetModifyHdl( aLink
);
183 aMtrDistance
.SetModifyHdl( aLink
);
189 // -----------------------------------------------------------------------
191 void SvxLineDefTabPage::Construct()
194 aLbLineStyles
.Fill( pDashList
);
197 // -----------------------------------------------------------------------
199 void SvxLineDefTabPage::ActivatePage( const SfxItemSet
& )
201 if( *pDlgType
== 0 ) // Flaechen-Dialog
203 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!!
206 if( *pPageType
== 1 &&
207 *pPosDashLb
!= LISTBOX_ENTRY_NOTFOUND
)
209 aLbLineStyles
.SelectEntryPos( *pPosDashLb
);
211 // Damit evtl. vorhandener Linestyle verworfen wird
212 SelectLinestyleHdl_Impl( this );
214 // Ermitteln (evtl. abschneiden) des Namens und in
215 // der GroupBox darstellen
216 String
aString( SVX_RES( RID_SVXSTR_TABLE
) ); aString
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
217 INetURLObject
aURL( pDashList
->GetPath() );
219 aURL
.Append( pDashList
->GetName() );
220 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
222 /* if ( aURL.getBase().Len() > 18 )
224 aString += aURL.getBase().Copy( 0, 15 );
225 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
228 aString += aURL.getBase();
230 aFTLinestyle.SetText( aString );
233 *pPosDashLb
= LISTBOX_ENTRY_NOTFOUND
;
238 // -----------------------------------------------------------------------
240 int SvxLineDefTabPage::DeactivatePage( SfxItemSet
* _pSet
)
245 FillItemSet( *_pSet
);
247 return( LEAVE_PAGE
);
250 // -----------------------------------------------------------------------
252 void SvxLineDefTabPage::CheckChanges_Impl()
254 // wird hier benutzt, um Aenderungen NICHT zu verlieren
257 if( aNumFldNumber1
.GetText() != aNumFldNumber1
.GetSavedValue() ||
258 aMtrLength1
.GetText() != aMtrLength1
.GetSavedValue() ||
259 aLbType1
.GetSelectEntryPos() != aLbType1
.GetSavedValue() ||
260 aNumFldNumber2
.GetText() != aNumFldNumber2
.GetSavedValue() ||
261 aMtrLength2
.GetText() != aMtrLength2
.GetSavedValue() ||
262 aLbType2
.GetSelectEntryPos() != aLbType2
.GetSavedValue() ||
263 aMtrDistance
.GetText() != aMtrDistance
.GetSavedValue() )
265 ResMgr
& rMgr
= DIALOG_MGR();
266 Image aWarningBoxImage
= WarningBox::GetStandardImage();
267 //CHINA001 SvxMessDialog aMessDlg( DLGWIN,
268 //CHINA001 String( ResId( RID_SVXSTR_LINESTYLE, rMgr ) ),
269 //CHINA001 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE, rMgr ) ),
270 //CHINA001 &aWarningBoxImage );
271 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
272 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
273 AbstractSvxMessDialog
* aMessDlg
= pFact
->CreateSvxMessDialog( DLGWIN
, RID_SVXDLG_MESSBOX
,
274 String( ResId( RID_SVXSTR_LINESTYLE
, rMgr
) ),
275 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE
, rMgr
) ),
277 DBG_ASSERT(aMessDlg
, "Dialogdiet fail!");//CHINA001
278 aMessDlg
->SetButtonText( MESS_BTN_1
, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
279 String( ResId( RID_SVXSTR_CHANGE
, rMgr
) ) );
280 aMessDlg
->SetButtonText( MESS_BTN_2
, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
281 String( ResId( RID_SVXSTR_ADD
, rMgr
) ) );
283 short nRet
= aMessDlg
->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
287 case RET_BTN_1
: // Aendern
289 ClickModifyHdl_Impl( this );
290 //aXDash = pDashList->Get( nPos )->GetDash();
294 case RET_BTN_2
: // Hinzufuegen
296 ClickAddHdl_Impl( this );
297 //nPos = aLbLineStyles.GetSelectEntryPos();
298 //aXDash = pDashList->Get( nPos )->GetDash();
304 // return( TRUE ); // Abbruch
306 delete aMessDlg
; //add by CHINA001
311 USHORT nPos
= aLbLineStyles
.GetSelectEntryPos();
312 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
318 // -----------------------------------------------------------------------
320 BOOL
SvxLineDefTabPage::FillItemSet( SfxItemSet
& rAttrs
)
322 if( *pDlgType
== 0 ) // Linien-Dialog
324 if( *pPageType
== 2 )
326 //CheckChanges_Impl();
330 String
aString( aLbLineStyles
.GetSelectEntry() );
331 rAttrs
.Put( XLineStyleItem( XLINE_DASH
) );
332 rAttrs
.Put( XLineDashItem( aString
, aDash
) );
338 // -----------------------------------------------------------------------
340 void SvxLineDefTabPage::Reset( const SfxItemSet
& rAttrs
)
342 if( rAttrs
.GetItemState( GetWhich( XATTR_LINESTYLE
) ) != SFX_ITEM_DONTCARE
)
344 XLineStyle eXLS
= (XLineStyle
) ( ( const XLineStyleItem
& ) rAttrs
.Get( GetWhich( XATTR_LINESTYLE
) ) ).GetValue();
350 aLbLineStyles
.SelectEntryPos( 0 );
355 const XLineDashItem
& rDashItem
= ( const XLineDashItem
& ) rAttrs
.Get( XATTR_LINEDASH
);
356 aDash
= rDashItem
.GetDashValue();
358 aLbLineStyles
.SetNoSelection();
359 aLbLineStyles
.SelectEntry( rDashItem
.GetName() );
367 SelectLinestyleHdl_Impl( NULL
);
369 // Status der Buttons ermitteln
370 if( pDashList
->Count() )
378 aBtnModify
.Disable();
379 aBtnDelete
.Disable();
384 // -----------------------------------------------------------------------
386 SfxTabPage
* SvxLineDefTabPage::Create( Window
* pWindow
,
387 const SfxItemSet
& rOutAttrs
)
389 return( new SvxLineDefTabPage( pWindow
, rOutAttrs
) );
392 //------------------------------------------------------------------------
394 IMPL_LINK( SvxLineDefTabPage
, SelectLinestyleHdl_Impl
, void *, p
)
396 if( pDashList
->Count() > 0 )
398 int nTmp
= aLbLineStyles
.GetSelectEntryPos();
399 if( nTmp
== LISTBOX_ENTRY_NOTFOUND
)
403 aDash
= pDashList
->GetDash( nTmp
)->GetDash();
407 rXLSet
.Put( XLineDashItem( String(), aDash
) );
410 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
412 aCtlPreview
.Invalidate();
414 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen,
415 // wenn in der ListBox ein Eintrag ausgewaehlt wurde
416 // Wenn ueber Reset() gerufen wurde ist p == NULL
423 //------------------------------------------------------------------------
425 IMPL_LINK_INLINE_START( SvxLineDefTabPage
, ChangePreviewHdl_Impl
, void *, EMPTYARG
)
428 aCtlPreview
.Invalidate();
432 IMPL_LINK_INLINE_END( SvxLineDefTabPage
, ChangePreviewHdl_Impl
, void *, EMPTYARG
)
434 //------------------------------------------------------------------------
436 IMPL_LINK( SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
, void *, EMPTYARG
)
438 if( aNumFldNumber1
.GetValue() == 0L )
440 aNumFldNumber2
.SetMin( 1L );
441 aNumFldNumber2
.SetFirst( 1L );
445 aNumFldNumber2
.SetMin( 0L );
446 aNumFldNumber2
.SetFirst( 0L );
449 ChangePreviewHdl_Impl( this );
454 //------------------------------------------------------------------------
456 IMPL_LINK( SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
, void *, EMPTYARG
)
458 if( aNumFldNumber2
.GetValue() == 0L )
460 aNumFldNumber1
.SetMin( 1L );
461 aNumFldNumber1
.SetFirst( 1L );
465 aNumFldNumber1
.SetMin( 0L );
466 aNumFldNumber1
.SetFirst( 0L );
469 ChangePreviewHdl_Impl( this );
475 //------------------------------------------------------------------------
477 IMPL_LINK( SvxLineDefTabPage
, ChangeMetricHdl_Impl
, void *, p
)
479 if( !aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != eFUnit
)
481 long nTmp1
, nTmp2
, nTmp3
;
483 // Wurde ueber Control geaendert
486 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * XOUT_WIDTH
/ 100;
487 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * XOUT_WIDTH
/ 100;
488 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * XOUT_WIDTH
/ 100;
492 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
493 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
494 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
496 aMtrLength1
.SetDecimalDigits( 2 );
497 aMtrLength2
.SetDecimalDigits( 2 );
498 aMtrDistance
.SetDecimalDigits( 2 );
501 aMtrLength1
.SetUnit( eFUnit
);
502 aMtrLength2
.SetUnit( eFUnit
);
503 aMtrDistance
.SetUnit( eFUnit
);
505 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
506 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
507 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
509 else if( aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != FUNIT_CUSTOM
)
511 long nTmp1
, nTmp2
, nTmp3
;
513 // Wurde ueber Control geaendert
516 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * 100 / XOUT_WIDTH
;
517 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * 100 / XOUT_WIDTH
;
518 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * 100 / XOUT_WIDTH
;
522 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
523 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
524 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
527 aMtrLength1
.SetDecimalDigits( 0 );
528 aMtrLength2
.SetDecimalDigits( 0 );
529 aMtrDistance
.SetDecimalDigits( 0 );
531 aMtrLength1
.SetUnit( FUNIT_CUSTOM
);
532 aMtrLength2
.SetUnit( FUNIT_CUSTOM
);
533 aMtrDistance
.SetUnit( FUNIT_CUSTOM
);
536 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
537 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
538 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
540 SelectTypeHdl_Impl( NULL
);
545 //------------------------------------------------------------------------
547 IMPL_LINK( SvxLineDefTabPage
, SelectTypeHdl_Impl
, void *, p
)
549 if ( p
== &aLbType1
|| !p
)
551 if ( aLbType1
.GetSelectEntryPos() == 0 )
553 aMtrLength1
.Disable();
554 aMtrLength1
.SetText( String() );
556 else if ( !aMtrLength1
.IsEnabled() )
558 aMtrLength1
.Enable();
559 aMtrLength1
.Reformat();
563 if ( p
== &aLbType2
|| !p
)
565 if ( aLbType2
.GetSelectEntryPos() == 0 )
567 aMtrLength2
.Disable();
568 aMtrLength2
.SetText( String() );
570 else if ( !aMtrLength2
.IsEnabled() )
572 aMtrLength2
.Enable();
573 aMtrLength2
.Reformat();
576 ChangePreviewHdl_Impl( p
);
580 //------------------------------------------------------------------------
582 IMPL_LINK( SvxLineDefTabPage
, ClickAddHdl_Impl
, void *, EMPTYARG
)
584 ResMgr
& rMgr
= DIALOG_MGR();
585 String
aNewName( ResId( RID_SVXSTR_LINESTYLE
, rMgr
) );
586 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
590 long nCount
= pDashList
->Count();
592 BOOL bDifferent
= FALSE
;
594 while ( !bDifferent
)
597 aName
+= sal_Unicode(' ');
598 aName
+= UniString::CreateFromInt32( j
++ );
601 for ( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
602 if ( aName
== pDashList
->GetDash( i
)->GetName() )
606 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
607 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
608 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
609 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( DLGWIN
, aName
, aDesc
, RID_SVXDLG_NAME
);
610 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
613 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
615 pDlg
->GetName( aName
);
618 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
620 if( aName
== pDashList
->GetDash( i
)->GetName() )
629 pEntry
= new XDashEntry( aDash
, aName
);
631 long nDashCount
= pDashList
->Count();
632 pDashList
->Insert( pEntry
, nDashCount
);
633 Bitmap
* pBitmap
= pDashList
->GetBitmap( nDashCount
);
634 aLbLineStyles
.Append( pEntry
, pBitmap
);
636 aLbLineStyles
.SelectEntryPos( aLbLineStyles
.GetEntryCount() - 1 );
638 // Flag fuer modifiziert setzen
639 *pnDashListState
|= CT_MODIFIED
;
643 // Werte sichern fuer Changes-Erkennung ( -> Methode )
644 aNumFldNumber1
.SaveValue();
645 aMtrLength1
.SaveValue();
646 aLbType1
.SaveValue();
647 aNumFldNumber2
.SaveValue();
648 aMtrLength2
.SaveValue();
649 aLbType2
.SaveValue();
650 aMtrDistance
.SaveValue();
654 WarningBox
aBox( DLGWIN
, WinBits( WB_OK
),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE
, rMgr
) ) );
655 aBox
.SetHelpId( HID_WARN_NAME_DUPLICATE
);
661 // Status der Buttons ermitteln
662 if ( pDashList
->Count() )
671 //------------------------------------------------------------------------
673 IMPL_LINK( SvxLineDefTabPage
, ClickModifyHdl_Impl
, void *, EMPTYARG
)
675 USHORT nPos
= aLbLineStyles
.GetSelectEntryPos();
677 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
679 ResMgr
& rMgr
= DIALOG_MGR();
680 String
aNewName( ResId( RID_SVXSTR_LINESTYLE
, rMgr
) );
681 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
682 String
aName( pDashList
->GetDash( nPos
)->GetName() );
683 String aOldName
= aName
;
685 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
686 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
687 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
688 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( DLGWIN
, aName
, aDesc
, RID_SVXDLG_NAME
);
689 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
691 long nCount
= pDashList
->Count();
692 BOOL bDifferent
= FALSE
;
695 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
697 pDlg
->GetName( aName
);
700 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
702 if( aName
== pDashList
->GetDash( i
)->GetName() &&
712 XDashEntry
* pEntry
= new XDashEntry( aDash
, aName
);
714 delete pDashList
->Replace( pEntry
, nPos
);
715 Bitmap
* pBitmap
= pDashList
->GetBitmap( nPos
);
716 aLbLineStyles
.Modify( pEntry
, nPos
, pBitmap
);
718 aLbLineStyles
.SelectEntryPos( nPos
);
720 // Flag fuer modifiziert setzen
721 *pnDashListState
|= CT_MODIFIED
;
725 // Werte sichern fuer Changes-Erkennung ( -> Methode )
726 aNumFldNumber1
.SaveValue();
727 aMtrLength1
.SaveValue();
728 aLbType1
.SaveValue();
729 aNumFldNumber2
.SaveValue();
730 aMtrLength2
.SaveValue();
731 aLbType2
.SaveValue();
732 aMtrDistance
.SaveValue();
736 WarningBox
aBox( DLGWIN
, WinBits( WB_OK
), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE
, rMgr
) ) );
737 aBox
.SetHelpId( HID_WARN_NAME_DUPLICATE
);
746 //------------------------------------------------------------------------
748 IMPL_LINK( SvxLineDefTabPage
, ClickDeleteHdl_Impl
, void *, EMPTYARG
)
750 USHORT nPos
= aLbLineStyles
.GetSelectEntryPos();
752 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
754 QueryBox
aQueryBox( DLGWIN
, WinBits( WB_YES_NO
| WB_DEF_NO
),
755 //! SVX_RES( RID_SVXSTR_DEL_LINESTYLE ),
756 String( SVX_RES( RID_SVXSTR_ASK_DEL_LINESTYLE
) ) );
758 if ( aQueryBox
.Execute() == RET_YES
)
760 delete pDashList
->Remove( nPos
);
761 aLbLineStyles
.RemoveEntry( nPos
);
762 aLbLineStyles
.SelectEntryPos( 0 );
764 SelectLinestyleHdl_Impl( this );
765 *pPageType
= 0; // Style soll nicht uebernommen werden
767 // Flag fuer modifiziert setzen
768 *pnDashListState
|= CT_MODIFIED
;
770 ChangePreviewHdl_Impl( this );
774 // Status der Buttons ermitteln
775 if ( !pDashList
->Count() )
777 aBtnModify
.Disable();
778 aBtnDelete
.Disable();
784 // -----------------------------------------------------------------------
786 IMPL_LINK( SvxLineDefTabPage
, ClickLoadHdl_Impl
, void *, EMPTYARG
)
788 ResMgr
& rMgr
= DIALOG_MGR();
789 USHORT nReturn
= RET_YES
;
791 if ( *pnDashListState
& CT_MODIFIED
)
793 nReturn
= WarningBox( DLGWIN
, WinBits( WB_YES_NO_CANCEL
),
794 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE
, rMgr
) ) ).Execute();
796 if ( nReturn
== RET_YES
)
800 if ( nReturn
!= RET_CANCEL
)
802 ::sfx2::FileDialogHelper
aDlg(
803 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
805 String
aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
806 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
807 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
808 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
810 if( aDlg
.Execute() == ERRCODE_NONE
)
812 INetURLObject
aURL( aDlg
.GetPath() );
813 INetURLObject
aPathURL( aURL
);
815 aPathURL
.removeSegment();
816 aPathURL
.removeFinalSlash();
819 XDashList
* pDshLst
= new XDashList( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
), pXPool
);
820 pDshLst
->SetName( aURL
.getName() );
822 if( pDshLst
->Load() )
826 // Pruefen, ob Tabelle geloescht werden darf:
827 if( pDashList
!= ( (SvxLineTabDialog
*) DLGWIN
)->GetDashList() )
831 ( (SvxLineTabDialog
*) DLGWIN
)->SetNewDashList( pDashList
);
833 aLbLineStyles
.Clear();
834 aLbLineStyles
.Fill( pDashList
);
837 pDashList
->SetName( aURL
.getName() );
839 /* // Ermitteln (evtl. abschneiden) des Namens und in
840 // der GroupBox darstellen
841 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
842 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
844 if ( aURL.getBase().Len() > 18 )
846 aString += aURL.getBase().Copy( 0, 15 );
847 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
850 aString += aURL.getBase();
852 aGrpLinestyles.SetText( aString );
854 // Flag fuer gewechselt setzen
855 *pnDashListState
|= CT_CHANGED
;
856 // Flag fuer modifiziert entfernen
857 *pnDashListState
&= ~CT_MODIFIED
;
862 ErrorBox( DLGWIN
, WinBits( WB_OK
),
863 String( ResId( RID_SVXSTR_READ_DATA_ERROR
, rMgr
) ) ).Execute();
867 // Status der Buttons ermitteln
868 if ( pDashList
->Count() )
876 aBtnModify
.Disable();
877 aBtnDelete
.Disable();
883 // -----------------------------------------------------------------------
885 IMPL_LINK( SvxLineDefTabPage
, ClickSaveHdl_Impl
, void *, EMPTYARG
)
887 ::sfx2::FileDialogHelper
aDlg(
888 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
889 String
aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
890 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
892 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
893 DBG_ASSERT( aFile
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
895 if( pDashList
->GetName().Len() )
897 aFile
.Append( pDashList
->GetName() );
899 if( !aFile
.getExtension().getLength() )
900 aFile
.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sod" ) ) );
903 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
904 if ( aDlg
.Execute() == ERRCODE_NONE
)
906 INetURLObject
aURL( aDlg
.GetPath() );
907 INetURLObject
aPathURL( aURL
);
909 aPathURL
.removeSegment();
910 aPathURL
.removeFinalSlash();
912 pDashList
->SetName( aURL
.getName() );
913 pDashList
->SetPath( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
) );
915 if( pDashList
->Save() )
917 /* // Ermitteln (evtl. abschneiden) des Namens und in
918 // der GroupBox darstellen
919 String aString( SVX_RES( RID_SVXSTR_TABLE ) );
920 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
922 if ( aURL.getBase().Len() > 18 )
924 aString += aURL.getBase().Copy( 0, 15 );
925 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
928 aString += aURL.getBase();
930 aGrpLinestyles.SetText( aString );
932 // Flag fuer gespeichert setzen
933 *pnDashListState
|= CT_SAVED
;
934 // Flag fuer modifiziert entfernen
935 *pnDashListState
&= ~CT_MODIFIED
;
939 ErrorBox( DLGWIN
, WinBits( WB_OK
),
940 String( SVX_RES( RID_SVXSTR_WRITE_DATA_ERROR
) ) ).Execute();
947 //------------------------------------------------------------------------
949 void SvxLineDefTabPage::FillDash_Impl()
953 /* Alle Stile werden z.Z. nicht benutzt
954 if( aRbtEnds1.IsChecked() )
956 else if( aRbtEnds2.IsChecked() )
961 if( aCbxSynchronize
.IsChecked() )
962 eXDS
= XDASH_RECTRELATIVE
;
966 aDash
.SetDashStyle( eXDS
);
967 aDash
.SetDots( (BYTE
) aNumFldNumber1
.GetValue() );
968 aDash
.SetDotLen( aLbType1
.GetSelectEntryPos() == 0 ? 0 :
969 GetCoreValue( aMtrLength1
, ePoolUnit
) );
970 aDash
.SetDashes( (BYTE
) aNumFldNumber2
.GetValue() );
971 aDash
.SetDashLen( aLbType2
.GetSelectEntryPos() == 0 ? 0 :
972 GetCoreValue( aMtrLength2
, ePoolUnit
) );
973 aDash
.SetDistance( GetCoreValue( aMtrDistance
, ePoolUnit
) );
975 rXLSet
.Put( XLineDashItem( String(), aDash
) );
978 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
981 //------------------------------------------------------------------------
983 void SvxLineDefTabPage::FillDialog_Impl()
985 XDashStyle eXDS
= aDash
.GetDashStyle(); // XDASH_RECT, XDASH_ROUND
986 if( eXDS
== XDASH_RECTRELATIVE
)
987 aCbxSynchronize
.Check();
989 aCbxSynchronize
.Check( FALSE
);
991 aNumFldNumber1
.SetValue( aDash
.GetDots() );
992 //aMtrLength1.SetValue( aDash.GetDotLen() );
993 SetMetricValue( aMtrLength1
, aDash
.GetDotLen(), ePoolUnit
);
994 aLbType1
.SelectEntryPos( aDash
.GetDotLen() == 0 ? 0 : 1 );
995 aNumFldNumber2
.SetValue( aDash
.GetDashes() );
996 //aMtrLength2.SetValue( aDash.GetDashLen() );
997 SetMetricValue( aMtrLength2
, aDash
.GetDashLen(), ePoolUnit
);
998 aLbType2
.SelectEntryPos( aDash
.GetDashLen() == 0 ? 0 : 1 );
999 //aMtrDistance.SetValue( aDash.GetDistance() );
1000 SetMetricValue( aMtrDistance
, aDash
.GetDistance(), ePoolUnit
);
1002 ChangeMetricHdl_Impl( NULL
);
1004 // Werte sichern fuer Changes-Erkennung ( -> Methode )
1005 aNumFldNumber1
.SaveValue();
1006 aMtrLength1
.SaveValue();
1007 aLbType1
.SaveValue();
1008 aNumFldNumber2
.SaveValue();
1009 aMtrLength2
.SaveValue();
1010 aLbType2
.SaveValue();
1011 aMtrDistance
.SaveValue();
1015 void SvxLineDefTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
1017 SfxTabPage::DataChanged( rDCEvt
);
1019 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1021 USHORT nOldSelect
= aLbLineStyles
.GetSelectEntryPos();
1022 aLbLineStyles
.Clear();
1023 aLbLineStyles
.Fill( pDashList
);
1024 aLbLineStyles
.SelectEntryPos( nOldSelect
);