1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <tools/shl.hxx>
33 #include <tools/urlobj.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <unotools/pathoptions.hxx>
36 #include <sfx2/app.hxx>
37 #include <sfx2/module.hxx>
38 #include <sfx2/filedlghelper.hxx>
39 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
41 #define _SVX_TPLNEDEF_CXX
44 #include "tabline.hrc"
45 //#include "dlgname.hrc"
48 #include "svx/xattr.hxx"
49 #include <svx/xpool.hxx>
50 #include <svx/xtable.hxx>
52 #include "svx/drawitem.hxx"
53 #include "cuitabline.hxx"
54 #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx"
55 #include <svx/svxdlg.hxx> //CHINA001
56 #include <dialmgr.hxx>
57 #include "svx/dlgutil.hxx"
58 #include <svx/dialmgr.hxx>
59 #include <svx/dialogs.hrc>
61 #define DLGWIN this->GetParent()->GetParent()
63 #define BITMAP_WIDTH 32
64 #define BITMAP_HEIGHT 12
65 #define XOUT_WIDTH 150
67 /*************************************************************************
69 |* Dialog zum Definieren von Linienstilen
71 \************************************************************************/
73 SvxLineDefTabPage::SvxLineDefTabPage
76 const SfxItemSet
& rInAttrs
79 SfxTabPage( pParent
, CUI_RES( RID_SVXPAGE_LINE_DEF
), rInAttrs
),
81 aFlDefinition ( this, CUI_RES( FL_DEFINITION
) ),
82 aFTLinestyle ( this, CUI_RES( FT_LINESTYLE
) ),
83 aLbLineStyles ( this, CUI_RES( LB_LINESTYLES
) ),
84 aFtType ( this, CUI_RES( FT_TYPE
) ),
85 aLbType1 ( this, CUI_RES( LB_TYPE_1
) ),
86 aLbType2 ( this, CUI_RES( LB_TYPE_2
) ),
87 aFtNumber ( this, CUI_RES( FT_NUMBER
) ),
88 aNumFldNumber1 ( this, CUI_RES( NUM_FLD_1
) ),
89 aNumFldNumber2 ( this, CUI_RES( NUM_FLD_2
) ),
90 aFtLength ( this, CUI_RES( FT_LENGTH
) ),
91 aMtrLength1 ( this, CUI_RES( MTR_FLD_LENGTH_1
) ),
92 aMtrLength2 ( this, CUI_RES( MTR_FLD_LENGTH_2
) ),
93 aFtDistance ( this, CUI_RES( FT_DISTANCE
) ),
94 aMtrDistance ( this, CUI_RES( MTR_FLD_DISTANCE
) ),
95 aCbxSynchronize ( this, CUI_RES( CBX_SYNCHRONIZE
) ),
96 aBtnAdd ( this, CUI_RES( BTN_ADD
) ),
97 aBtnModify ( this, CUI_RES( BTN_MODIFY
) ),
98 aBtnDelete ( this, CUI_RES( BTN_DELETE
) ),
99 aBtnLoad ( this, CUI_RES( BTN_LOAD
) ),
100 aBtnSave ( this, CUI_RES( BTN_SAVE
) ),
101 aCtlPreview ( this, CUI_RES( CTL_PREVIEW
) ),
103 rOutAttrs ( rInAttrs
),
105 pXPool ( (XOutdevItemPool
*) rInAttrs
.GetPool() ),
106 aXLStyle ( XLINE_DASH
),
107 aXWidth ( XOUT_WIDTH
),
108 aXDash ( String(), XDash( XDASH_RECT
, 3, 7, 2, 40, 15 ) ),
109 aXColor ( String(), COL_BLACK
),
110 aXLineAttr ( pXPool
),
111 rXLSet ( aXLineAttr
.GetItemSet() )
113 aBtnLoad
.SetModeImage( Image( CUI_RES( RID_SVXIMG_LOAD_H
) ), BMP_COLOR_HIGHCONTRAST
);
114 aBtnSave
.SetModeImage( Image( CUI_RES( RID_SVXIMG_SAVE_H
) ), BMP_COLOR_HIGHCONTRAST
);
116 aLbType1
.SetAccessibleName(String(CUI_RES( STR_START_TYPE
) ) );
117 aLbType2
.SetAccessibleName(String(CUI_RES( STR_END_TYPE
) ) );
118 aNumFldNumber1
.SetAccessibleName(String(CUI_RES( STR_START_NUM
) ) );
119 aNumFldNumber2
.SetAccessibleName(String(CUI_RES( STR_END_NUM
) ) );
120 aMtrLength1
.SetAccessibleName(String(CUI_RES( STR_START_LENGTH
) ) );
121 aMtrLength2
.SetAccessibleName(String(CUI_RES( STR_END_LENGTH
) ) );
125 // diese Page braucht ExchangeSupport
126 SetExchangeSupport();
129 eFUnit
= GetModuleFieldUnit( rInAttrs
);
137 default: ; //prevent warning
139 SetFieldUnit( aMtrDistance
, eFUnit
);
140 SetFieldUnit( aMtrLength1
, eFUnit
);
141 SetFieldUnit( aMtrLength2
, eFUnit
);
143 // PoolUnit ermitteln
144 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
145 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
146 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
148 rXLSet
.Put( aXLStyle
);
149 rXLSet
.Put( aXWidth
);
150 rXLSet
.Put( aXDash
);
151 rXLSet
.Put( aXColor
);
154 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
156 aBtnAdd
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickAddHdl_Impl
) );
157 aBtnModify
.SetClickHdl(
158 LINK( this, SvxLineDefTabPage
, ClickModifyHdl_Impl
) );
159 aBtnDelete
.SetClickHdl(
160 LINK( this, SvxLineDefTabPage
, ClickDeleteHdl_Impl
) );
161 aBtnLoad
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickLoadHdl_Impl
) );
162 aBtnSave
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickSaveHdl_Impl
) );
164 aNumFldNumber1
.SetModifyHdl(
165 LINK( this, SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
) );
166 aNumFldNumber2
.SetModifyHdl(
167 LINK( this, SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
) );
168 aLbLineStyles
.SetSelectHdl(
169 LINK( this, SvxLineDefTabPage
, SelectLinestyleHdl_Impl
) );
171 // Absolut (in mm) oder Relativ (in %)
172 aCbxSynchronize
.SetClickHdl(
173 LINK( this, SvxLineDefTabPage
, ChangeMetricHdl_Impl
) );
175 // Wenn sich etwas aendert, muss Preview upgedatet werden werden
176 Link aLink
= LINK( this, SvxLineDefTabPage
, SelectTypeHdl_Impl
);
177 aLbType1
.SetSelectHdl( aLink
);
178 aLbType2
.SetSelectHdl( aLink
);
179 aLink
= LINK( this, SvxLineDefTabPage
, ChangePreviewHdl_Impl
);
180 aMtrLength1
.SetModifyHdl( aLink
);
181 aMtrLength2
.SetModifyHdl( aLink
);
182 aMtrDistance
.SetModifyHdl( aLink
);
186 aBtnAdd
.SetAccessibleRelationMemberOf( &aFlDefinition
);
187 aBtnModify
.SetAccessibleRelationMemberOf( &aFlDefinition
);
188 aBtnDelete
.SetAccessibleRelationMemberOf( &aFlDefinition
);
189 aBtnLoad
.SetAccessibleRelationMemberOf( &aFlDefinition
);
190 aBtnSave
.SetAccessibleRelationMemberOf( &aFlDefinition
);
194 // -----------------------------------------------------------------------
196 void SvxLineDefTabPage::Construct()
199 aLbLineStyles
.Fill( pDashList
);
202 // -----------------------------------------------------------------------
204 void SvxLineDefTabPage::ActivatePage( const SfxItemSet
& )
206 if( *pDlgType
== 0 ) // Flaechen-Dialog
208 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!!
211 if( *pPageType
== 1 &&
212 *pPosDashLb
!= LISTBOX_ENTRY_NOTFOUND
)
214 aLbLineStyles
.SelectEntryPos( *pPosDashLb
);
216 // Damit evtl. vorhandener Linestyle verworfen wird
217 SelectLinestyleHdl_Impl( this );
219 // Ermitteln (evtl. abschneiden) des Namens und in
220 // der GroupBox darstellen
221 String
aString( CUI_RES( RID_SVXSTR_TABLE
) ); aString
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
222 INetURLObject
aURL( pDashList
->GetPath() );
224 aURL
.Append( pDashList
->GetName() );
225 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
227 /* if ( aURL.getBase().Len() > 18 )
229 aString += aURL.getBase().Copy( 0, 15 );
230 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
233 aString += aURL.getBase();
235 aFTLinestyle.SetText( aString );
238 *pPosDashLb
= LISTBOX_ENTRY_NOTFOUND
;
243 // -----------------------------------------------------------------------
245 int SvxLineDefTabPage::DeactivatePage( SfxItemSet
* _pSet
)
250 FillItemSet( *_pSet
);
252 return( LEAVE_PAGE
);
255 // -----------------------------------------------------------------------
257 void SvxLineDefTabPage::CheckChanges_Impl()
259 // wird hier benutzt, um Aenderungen NICHT zu verlieren
262 if( aNumFldNumber1
.GetText() != aNumFldNumber1
.GetSavedValue() ||
263 aMtrLength1
.GetText() != aMtrLength1
.GetSavedValue() ||
264 aLbType1
.GetSelectEntryPos() != aLbType1
.GetSavedValue() ||
265 aNumFldNumber2
.GetText() != aNumFldNumber2
.GetSavedValue() ||
266 aMtrLength2
.GetText() != aMtrLength2
.GetSavedValue() ||
267 aLbType2
.GetSelectEntryPos() != aLbType2
.GetSavedValue() ||
268 aMtrDistance
.GetText() != aMtrDistance
.GetSavedValue() )
270 ResMgr
& rMgr
= CUI_MGR();
271 Image aWarningBoxImage
= WarningBox::GetStandardImage();
272 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
273 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
274 AbstractSvxMessDialog
* aMessDlg
= pFact
->CreateSvxMessDialog( DLGWIN
, RID_SVXDLG_MESSBOX
,
275 SVX_RESSTR( RID_SVXSTR_LINESTYLE
),
276 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE
, rMgr
) ),
278 DBG_ASSERT(aMessDlg
, "Dialogdiet fail!");//CHINA001
279 aMessDlg
->SetButtonText( MESS_BTN_1
, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
280 String( ResId( RID_SVXSTR_CHANGE
, rMgr
) ) );
281 aMessDlg
->SetButtonText( MESS_BTN_2
, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
282 String( ResId( RID_SVXSTR_ADD
, rMgr
) ) );
284 short nRet
= aMessDlg
->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
288 case RET_BTN_1
: // Aendern
290 ClickModifyHdl_Impl( this );
291 //aXDash = pDashList->Get( nPos )->GetDash();
295 case RET_BTN_2
: // Hinzufuegen
297 ClickAddHdl_Impl( this );
298 //nPos = aLbLineStyles.GetSelectEntryPos();
299 //aXDash = pDashList->Get( nPos )->GetDash();
305 // return( sal_True ); // Abbruch
307 delete aMessDlg
; //add by CHINA001
312 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
313 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
319 // -----------------------------------------------------------------------
321 sal_Bool
SvxLineDefTabPage::FillItemSet( SfxItemSet
& rAttrs
)
323 if( *pDlgType
== 0 ) // Linien-Dialog
325 if( *pPageType
== 2 )
327 //CheckChanges_Impl();
331 String
aString( aLbLineStyles
.GetSelectEntry() );
332 rAttrs
.Put( XLineStyleItem( XLINE_DASH
) );
333 rAttrs
.Put( XLineDashItem( aString
, aDash
) );
339 // -----------------------------------------------------------------------
341 void SvxLineDefTabPage::Reset( const SfxItemSet
& rAttrs
)
343 if( rAttrs
.GetItemState( GetWhich( XATTR_LINESTYLE
) ) != SFX_ITEM_DONTCARE
)
345 XLineStyle eXLS
= (XLineStyle
) ( ( const XLineStyleItem
& ) rAttrs
.Get( GetWhich( XATTR_LINESTYLE
) ) ).GetValue();
351 aLbLineStyles
.SelectEntryPos( 0 );
356 const XLineDashItem
& rDashItem
= ( const XLineDashItem
& ) rAttrs
.Get( XATTR_LINEDASH
);
357 aDash
= rDashItem
.GetDashValue();
359 aLbLineStyles
.SetNoSelection();
360 aLbLineStyles
.SelectEntry( rDashItem
.GetName() );
368 SelectLinestyleHdl_Impl( NULL
);
370 // Status der Buttons ermitteln
371 if( pDashList
->Count() )
379 aBtnModify
.Disable();
380 aBtnDelete
.Disable();
385 // -----------------------------------------------------------------------
387 SfxTabPage
* SvxLineDefTabPage::Create( Window
* pWindow
,
388 const SfxItemSet
& rOutAttrs
)
390 return( new SvxLineDefTabPage( pWindow
, rOutAttrs
) );
393 //------------------------------------------------------------------------
395 IMPL_LINK( SvxLineDefTabPage
, SelectLinestyleHdl_Impl
, void *, p
)
397 if( pDashList
->Count() > 0 )
399 int nTmp
= aLbLineStyles
.GetSelectEntryPos();
400 if( nTmp
== LISTBOX_ENTRY_NOTFOUND
)
404 aDash
= pDashList
->GetDash( nTmp
)->GetDash();
408 rXLSet
.Put( XLineDashItem( String(), aDash
) );
411 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
413 aCtlPreview
.Invalidate();
415 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen,
416 // wenn in der ListBox ein Eintrag ausgewaehlt wurde
417 // Wenn ueber Reset() gerufen wurde ist p == NULL
424 //------------------------------------------------------------------------
426 IMPL_LINK_INLINE_START( SvxLineDefTabPage
, ChangePreviewHdl_Impl
, void *, EMPTYARG
)
429 aCtlPreview
.Invalidate();
433 IMPL_LINK_INLINE_END( SvxLineDefTabPage
, ChangePreviewHdl_Impl
, void *, EMPTYARG
)
435 //------------------------------------------------------------------------
437 IMPL_LINK( SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
, void *, EMPTYARG
)
439 if( aNumFldNumber1
.GetValue() == 0L )
441 aNumFldNumber2
.SetMin( 1L );
442 aNumFldNumber2
.SetFirst( 1L );
446 aNumFldNumber2
.SetMin( 0L );
447 aNumFldNumber2
.SetFirst( 0L );
450 ChangePreviewHdl_Impl( this );
455 //------------------------------------------------------------------------
457 IMPL_LINK( SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
, void *, EMPTYARG
)
459 if( aNumFldNumber2
.GetValue() == 0L )
461 aNumFldNumber1
.SetMin( 1L );
462 aNumFldNumber1
.SetFirst( 1L );
466 aNumFldNumber1
.SetMin( 0L );
467 aNumFldNumber1
.SetFirst( 0L );
470 ChangePreviewHdl_Impl( this );
476 //------------------------------------------------------------------------
478 IMPL_LINK( SvxLineDefTabPage
, ChangeMetricHdl_Impl
, void *, p
)
480 if( !aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != eFUnit
)
482 long nTmp1
, nTmp2
, nTmp3
;
484 // Wurde ueber Control geaendert
487 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * XOUT_WIDTH
/ 100;
488 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * XOUT_WIDTH
/ 100;
489 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * XOUT_WIDTH
/ 100;
493 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
494 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
495 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
497 aMtrLength1
.SetDecimalDigits( 2 );
498 aMtrLength2
.SetDecimalDigits( 2 );
499 aMtrDistance
.SetDecimalDigits( 2 );
502 aMtrLength1
.SetUnit( eFUnit
);
503 aMtrLength2
.SetUnit( eFUnit
);
504 aMtrDistance
.SetUnit( eFUnit
);
506 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
507 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
508 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
510 else if( aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != FUNIT_CUSTOM
)
512 long nTmp1
, nTmp2
, nTmp3
;
514 // Wurde ueber Control geaendert
517 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * 100 / XOUT_WIDTH
;
518 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * 100 / XOUT_WIDTH
;
519 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * 100 / XOUT_WIDTH
;
523 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
524 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
525 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
528 aMtrLength1
.SetDecimalDigits( 0 );
529 aMtrLength2
.SetDecimalDigits( 0 );
530 aMtrDistance
.SetDecimalDigits( 0 );
532 aMtrLength1
.SetUnit( FUNIT_CUSTOM
);
533 aMtrLength2
.SetUnit( FUNIT_CUSTOM
);
534 aMtrDistance
.SetUnit( FUNIT_CUSTOM
);
537 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
538 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
539 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
541 SelectTypeHdl_Impl( NULL
);
546 //------------------------------------------------------------------------
548 IMPL_LINK( SvxLineDefTabPage
, SelectTypeHdl_Impl
, void *, p
)
550 if ( p
== &aLbType1
|| !p
)
552 if ( aLbType1
.GetSelectEntryPos() == 0 )
554 aMtrLength1
.Disable();
555 aMtrLength1
.SetText( String() );
557 else if ( !aMtrLength1
.IsEnabled() )
559 aMtrLength1
.Enable();
560 aMtrLength1
.Reformat();
564 if ( p
== &aLbType2
|| !p
)
566 if ( aLbType2
.GetSelectEntryPos() == 0 )
568 aMtrLength2
.Disable();
569 aMtrLength2
.SetText( String() );
571 else if ( !aMtrLength2
.IsEnabled() )
573 aMtrLength2
.Enable();
574 aMtrLength2
.Reformat();
577 ChangePreviewHdl_Impl( p
);
581 //------------------------------------------------------------------------
583 IMPL_LINK( SvxLineDefTabPage
, ClickAddHdl_Impl
, void *, EMPTYARG
)
585 ResMgr
& rMgr
= CUI_MGR();
586 String
aNewName( SVX_RES( RID_SVXSTR_LINESTYLE
) );
587 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
591 long nCount
= pDashList
->Count();
593 sal_Bool bDifferent
= sal_False
;
595 while ( !bDifferent
)
598 aName
+= sal_Unicode(' ');
599 aName
+= UniString::CreateFromInt32( j
++ );
600 bDifferent
= sal_True
;
602 for ( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
603 if ( aName
== pDashList
->GetDash( i
)->GetName() )
604 bDifferent
= sal_False
;
607 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
608 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
609 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( DLGWIN
, aName
, aDesc
);
610 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
611 sal_Bool bLoop
= sal_True
;
613 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
615 pDlg
->GetName( aName
);
616 bDifferent
= sal_True
;
618 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
620 if( aName
== pDashList
->GetDash( i
)->GetName() )
621 bDifferent
= sal_False
;
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 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
677 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
679 ResMgr
& rMgr
= CUI_MGR();
680 String
aNewName( SVX_RES( RID_SVXSTR_LINESTYLE
) );
681 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
682 String
aName( pDashList
->GetDash( nPos
)->GetName() );
683 String aOldName
= aName
;
685 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
686 DBG_ASSERT(pFact
, "Dialogdiet fail!");//CHINA001
687 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( DLGWIN
, aName
, aDesc
);
688 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
690 long nCount
= pDashList
->Count();
691 sal_Bool bDifferent
= sal_False
;
692 sal_Bool bLoop
= sal_True
;
694 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
696 pDlg
->GetName( aName
);
697 bDifferent
= sal_True
;
699 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
701 if( aName
== pDashList
->GetDash( i
)->GetName() &&
703 bDifferent
= sal_False
;
711 XDashEntry
* pEntry
= new XDashEntry( aDash
, aName
);
713 delete pDashList
->Replace( pEntry
, nPos
);
714 Bitmap
* pBitmap
= pDashList
->GetBitmap( nPos
);
715 aLbLineStyles
.Modify( pEntry
, nPos
, pBitmap
);
717 aLbLineStyles
.SelectEntryPos( nPos
);
719 // Flag fuer modifiziert setzen
720 *pnDashListState
|= CT_MODIFIED
;
724 // Werte sichern fuer Changes-Erkennung ( -> Methode )
725 aNumFldNumber1
.SaveValue();
726 aMtrLength1
.SaveValue();
727 aLbType1
.SaveValue();
728 aNumFldNumber2
.SaveValue();
729 aMtrLength2
.SaveValue();
730 aLbType2
.SaveValue();
731 aMtrDistance
.SaveValue();
735 WarningBox
aBox( DLGWIN
, WinBits( WB_OK
), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE
, rMgr
) ) );
736 aBox
.SetHelpId( HID_WARN_NAME_DUPLICATE
);
745 //------------------------------------------------------------------------
747 IMPL_LINK( SvxLineDefTabPage
, ClickDeleteHdl_Impl
, void *, EMPTYARG
)
749 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
751 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
753 QueryBox
aQueryBox( DLGWIN
, WinBits( WB_YES_NO
| WB_DEF_NO
),
754 String( CUI_RES( RID_SVXSTR_ASK_DEL_LINESTYLE
) ) );
756 if ( aQueryBox
.Execute() == RET_YES
)
758 delete pDashList
->Remove( nPos
);
759 aLbLineStyles
.RemoveEntry( nPos
);
760 aLbLineStyles
.SelectEntryPos( 0 );
762 SelectLinestyleHdl_Impl( this );
763 *pPageType
= 0; // Style soll nicht uebernommen werden
765 // Flag fuer modifiziert setzen
766 *pnDashListState
|= CT_MODIFIED
;
768 ChangePreviewHdl_Impl( this );
772 // Status der Buttons ermitteln
773 if ( !pDashList
->Count() )
775 aBtnModify
.Disable();
776 aBtnDelete
.Disable();
782 // -----------------------------------------------------------------------
784 IMPL_LINK( SvxLineDefTabPage
, ClickLoadHdl_Impl
, void *, EMPTYARG
)
786 ResMgr
& rMgr
= CUI_MGR();
787 sal_uInt16 nReturn
= RET_YES
;
789 if ( *pnDashListState
& CT_MODIFIED
)
791 nReturn
= WarningBox( DLGWIN
, WinBits( WB_YES_NO_CANCEL
),
792 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE
, rMgr
) ) ).Execute();
794 if ( nReturn
== RET_YES
)
798 if ( nReturn
!= RET_CANCEL
)
800 ::sfx2::FileDialogHelper
aDlg(
801 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
803 String
aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
804 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
805 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
806 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
808 if( aDlg
.Execute() == ERRCODE_NONE
)
810 INetURLObject
aURL( aDlg
.GetPath() );
811 INetURLObject
aPathURL( aURL
);
813 aPathURL
.removeSegment();
814 aPathURL
.removeFinalSlash();
817 XDashList
* pDshLst
= new XDashList( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
), pXPool
);
818 pDshLst
->SetName( aURL
.getName() );
820 if( pDshLst
->Load() )
824 // Pruefen, ob Tabelle geloescht werden darf:
825 if( pDashList
!= ( (SvxLineTabDialog
*) DLGWIN
)->GetDashList() )
829 ( (SvxLineTabDialog
*) DLGWIN
)->SetNewDashList( pDashList
);
831 aLbLineStyles
.Clear();
832 aLbLineStyles
.Fill( pDashList
);
835 pDashList
->SetName( aURL
.getName() );
837 /* // Ermitteln (evtl. abschneiden) des Namens und in
838 // der GroupBox darstellen
839 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
840 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
842 if ( aURL.getBase().Len() > 18 )
844 aString += aURL.getBase().Copy( 0, 15 );
845 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
848 aString += aURL.getBase();
850 aGrpLinestyles.SetText( aString );
852 // Flag fuer gewechselt setzen
853 *pnDashListState
|= CT_CHANGED
;
854 // Flag fuer modifiziert entfernen
855 *pnDashListState
&= ~CT_MODIFIED
;
860 ErrorBox( DLGWIN
, WinBits( WB_OK
),
861 String( ResId( RID_SVXSTR_READ_DATA_ERROR
, rMgr
) ) ).Execute();
865 // Status der Buttons ermitteln
866 if ( pDashList
->Count() )
874 aBtnModify
.Disable();
875 aBtnDelete
.Disable();
881 // -----------------------------------------------------------------------
883 IMPL_LINK( SvxLineDefTabPage
, ClickSaveHdl_Impl
, void *, EMPTYARG
)
885 ::sfx2::FileDialogHelper
aDlg(
886 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
887 String
aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
888 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
890 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
891 DBG_ASSERT( aFile
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
893 if( pDashList
->GetName().Len() )
895 aFile
.Append( pDashList
->GetName() );
897 if( !aFile
.getExtension().getLength() )
898 aFile
.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sod" ) ) );
901 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
902 if ( aDlg
.Execute() == ERRCODE_NONE
)
904 INetURLObject
aURL( aDlg
.GetPath() );
905 INetURLObject
aPathURL( aURL
);
907 aPathURL
.removeSegment();
908 aPathURL
.removeFinalSlash();
910 pDashList
->SetName( aURL
.getName() );
911 pDashList
->SetPath( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
) );
913 if( pDashList
->Save() )
915 /* // Ermitteln (evtl. abschneiden) des Namens und in
916 // der GroupBox darstellen
917 String aString( CUI_RES( RID_SVXSTR_TABLE ) );
918 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
920 if ( aURL.getBase().Len() > 18 )
922 aString += aURL.getBase().Copy( 0, 15 );
923 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
926 aString += aURL.getBase();
928 aGrpLinestyles.SetText( aString );
930 // Flag fuer gespeichert setzen
931 *pnDashListState
|= CT_SAVED
;
932 // Flag fuer modifiziert entfernen
933 *pnDashListState
&= ~CT_MODIFIED
;
937 ErrorBox( DLGWIN
, WinBits( WB_OK
),
938 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR
) ) ).Execute();
945 //------------------------------------------------------------------------
947 void SvxLineDefTabPage::FillDash_Impl()
951 /* Alle Stile werden z.Z. nicht benutzt
952 if( aRbtEnds1.IsChecked() )
954 else if( aRbtEnds2.IsChecked() )
959 if( aCbxSynchronize
.IsChecked() )
960 eXDS
= XDASH_RECTRELATIVE
;
964 aDash
.SetDashStyle( eXDS
);
965 aDash
.SetDots( (sal_uInt8
) aNumFldNumber1
.GetValue() );
966 aDash
.SetDotLen( aLbType1
.GetSelectEntryPos() == 0 ? 0 :
967 GetCoreValue( aMtrLength1
, ePoolUnit
) );
968 aDash
.SetDashes( (sal_uInt8
) aNumFldNumber2
.GetValue() );
969 aDash
.SetDashLen( aLbType2
.GetSelectEntryPos() == 0 ? 0 :
970 GetCoreValue( aMtrLength2
, ePoolUnit
) );
971 aDash
.SetDistance( GetCoreValue( aMtrDistance
, ePoolUnit
) );
973 rXLSet
.Put( XLineDashItem( String(), aDash
) );
976 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
979 //------------------------------------------------------------------------
981 void SvxLineDefTabPage::FillDialog_Impl()
983 XDashStyle eXDS
= aDash
.GetDashStyle(); // XDASH_RECT, XDASH_ROUND
984 if( eXDS
== XDASH_RECTRELATIVE
)
985 aCbxSynchronize
.Check();
987 aCbxSynchronize
.Check( sal_False
);
989 aNumFldNumber1
.SetValue( aDash
.GetDots() );
990 //aMtrLength1.SetValue( aDash.GetDotLen() );
991 SetMetricValue( aMtrLength1
, aDash
.GetDotLen(), ePoolUnit
);
992 aLbType1
.SelectEntryPos( aDash
.GetDotLen() == 0 ? 0 : 1 );
993 aNumFldNumber2
.SetValue( aDash
.GetDashes() );
994 //aMtrLength2.SetValue( aDash.GetDashLen() );
995 SetMetricValue( aMtrLength2
, aDash
.GetDashLen(), ePoolUnit
);
996 aLbType2
.SelectEntryPos( aDash
.GetDashLen() == 0 ? 0 : 1 );
997 //aMtrDistance.SetValue( aDash.GetDistance() );
998 SetMetricValue( aMtrDistance
, aDash
.GetDistance(), ePoolUnit
);
1000 ChangeMetricHdl_Impl( NULL
);
1002 // Werte sichern fuer Changes-Erkennung ( -> Methode )
1003 aNumFldNumber1
.SaveValue();
1004 aMtrLength1
.SaveValue();
1005 aLbType1
.SaveValue();
1006 aNumFldNumber2
.SaveValue();
1007 aMtrLength2
.SaveValue();
1008 aLbType2
.SaveValue();
1009 aMtrDistance
.SaveValue();
1013 void SvxLineDefTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
1015 SfxTabPage::DataChanged( rDCEvt
);
1017 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1019 sal_uInt16 nOldSelect
= aLbLineStyles
.GetSelectEntryPos();
1020 aLbLineStyles
.Clear();
1021 aLbLineStyles
.Fill( pDashList
);
1022 aLbLineStyles
.SelectEntryPos( nOldSelect
);