1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <tools/urlobj.hxx>
22 #include <vcl/msgbox.hxx>
23 #include <unotools/pathoptions.hxx>
24 #include <sfx2/app.hxx>
25 #include <sfx2/module.hxx>
26 #include <sfx2/filedlghelper.hxx>
27 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
30 #include "tabline.hrc"
33 #include "svx/xattr.hxx"
34 #include <svx/xpool.hxx>
35 #include <svx/xtable.hxx>
37 #include "svx/drawitem.hxx"
38 #include "cuitabline.hxx"
39 #include "dlgname.hxx"
40 #include "defdlgname.hxx"
41 #include <svx/svxdlg.hxx>
42 #include <dialmgr.hxx>
43 #include "svx/dlgutil.hxx"
44 #include <svx/dialmgr.hxx>
45 #include <svx/dialogs.hrc>
47 #define XOUT_WIDTH 150
49 SvxLineDefTabPage::SvxLineDefTabPage
52 const SfxItemSet
& rInAttrs
55 SfxTabPage( pParent
, CUI_RES( RID_SVXPAGE_LINE_DEF
), rInAttrs
),
57 aFlDefinition ( this, CUI_RES( FL_DEFINITION
) ),
58 aFTLinestyle ( this, CUI_RES( FT_LINESTYLE
) ),
59 aLbLineStyles ( this, CUI_RES( LB_LINESTYLES
) ),
60 aFtType ( this, CUI_RES( FT_TYPE
) ),
61 aLbType1 ( this, CUI_RES( LB_TYPE_1
) ),
62 aLbType2 ( this, CUI_RES( LB_TYPE_2
) ),
63 aFtNumber ( this, CUI_RES( FT_NUMBER
) ),
64 aNumFldNumber1 ( this, CUI_RES( NUM_FLD_1
) ),
65 aNumFldNumber2 ( this, CUI_RES( NUM_FLD_2
) ),
66 aFtLength ( this, CUI_RES( FT_LENGTH
) ),
67 aMtrLength1 ( this, CUI_RES( MTR_FLD_LENGTH_1
) ),
68 aMtrLength2 ( this, CUI_RES( MTR_FLD_LENGTH_2
) ),
69 aFtDistance ( this, CUI_RES( FT_DISTANCE
) ),
70 aMtrDistance ( this, CUI_RES( MTR_FLD_DISTANCE
) ),
71 aCbxSynchronize ( this, CUI_RES( CBX_SYNCHRONIZE
) ),
72 aBtnAdd ( this, CUI_RES( BTN_ADD
) ),
73 aBtnModify ( this, CUI_RES( BTN_MODIFY
) ),
74 aBtnDelete ( this, CUI_RES( BTN_DELETE
) ),
75 aBtnLoad ( this, CUI_RES( BTN_LOAD
) ),
76 aBtnSave ( this, CUI_RES( BTN_SAVE
) ),
77 aCtlPreview ( this, CUI_RES( CTL_PREVIEW
) ),
79 rOutAttrs ( rInAttrs
),
81 pXPool ( (XOutdevItemPool
*) rInAttrs
.GetPool() ),
82 aXLStyle ( XLINE_DASH
),
83 aXWidth ( XOUT_WIDTH
),
84 aXDash ( String(), XDash( XDASH_RECT
, 3, 7, 2, 40, 15 ) ),
85 aXColor ( String(), COL_BLACK
),
86 aXLineAttr ( pXPool
),
87 rXLSet ( aXLineAttr
.GetItemSet() )
89 aLbType1
.SetAccessibleName(String(CUI_RES( STR_START_TYPE
) ) );
90 aLbType2
.SetAccessibleName(String(CUI_RES( STR_END_TYPE
) ) );
91 aNumFldNumber1
.SetAccessibleName(String(CUI_RES( STR_START_NUM
) ) );
92 aNumFldNumber2
.SetAccessibleName(String(CUI_RES( STR_END_NUM
) ) );
93 aMtrLength1
.SetAccessibleName(String(CUI_RES( STR_START_LENGTH
) ) );
94 aMtrLength2
.SetAccessibleName(String(CUI_RES( STR_END_LENGTH
) ) );
98 // this page needs ExchangeSupport
102 eFUnit
= GetModuleFieldUnit( rInAttrs
);
110 default: ; //prevent warning
112 SetFieldUnit( aMtrDistance
, eFUnit
);
113 SetFieldUnit( aMtrLength1
, eFUnit
);
114 SetFieldUnit( aMtrLength2
, eFUnit
);
116 // determine PoolUnit
117 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
118 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
119 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
121 rXLSet
.Put( aXLStyle
);
122 rXLSet
.Put( aXWidth
);
123 rXLSet
.Put( aXDash
);
124 rXLSet
.Put( aXColor
);
127 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
129 aBtnAdd
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickAddHdl_Impl
) );
130 aBtnModify
.SetClickHdl(
131 LINK( this, SvxLineDefTabPage
, ClickModifyHdl_Impl
) );
132 aBtnDelete
.SetClickHdl(
133 LINK( this, SvxLineDefTabPage
, ClickDeleteHdl_Impl
) );
134 aBtnLoad
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickLoadHdl_Impl
) );
135 aBtnSave
.SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickSaveHdl_Impl
) );
137 aNumFldNumber1
.SetModifyHdl(
138 LINK( this, SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
) );
139 aNumFldNumber2
.SetModifyHdl(
140 LINK( this, SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
) );
141 aLbLineStyles
.SetSelectHdl(
142 LINK( this, SvxLineDefTabPage
, SelectLinestyleHdl_Impl
) );
144 // #i122042# switch off default adding of 'none' and 'solid' entries
145 // for this ListBox; we want to select only editable/dashed styles
146 aLbLineStyles
.setAddStandardFields(false);
148 // absolute (in mm) or relative (in %)
149 aCbxSynchronize
.SetClickHdl(
150 LINK( this, SvxLineDefTabPage
, ChangeMetricHdl_Impl
) );
152 // preview must be updated when there's something changed
153 Link aLink
= LINK( this, SvxLineDefTabPage
, SelectTypeHdl_Impl
);
154 aLbType1
.SetSelectHdl( aLink
);
155 aLbType2
.SetSelectHdl( aLink
);
156 aLink
= LINK( this, SvxLineDefTabPage
, ChangePreviewHdl_Impl
);
157 aMtrLength1
.SetModifyHdl( aLink
);
158 aMtrLength2
.SetModifyHdl( aLink
);
159 aMtrDistance
.SetModifyHdl( aLink
);
163 aBtnAdd
.SetAccessibleRelationMemberOf( &aFlDefinition
);
164 aBtnModify
.SetAccessibleRelationMemberOf( &aFlDefinition
);
165 aBtnDelete
.SetAccessibleRelationMemberOf( &aFlDefinition
);
166 aBtnLoad
.SetAccessibleRelationMemberOf( &aFlDefinition
);
167 aBtnSave
.SetAccessibleRelationMemberOf( &aFlDefinition
);
171 // -----------------------------------------------------------------------
173 void SvxLineDefTabPage::Construct()
175 // Line style fill; do *not* add default fields here
176 aLbLineStyles
.Fill( pDashList
);
179 // -----------------------------------------------------------------------
181 void SvxLineDefTabPage::ActivatePage( const SfxItemSet
& )
183 if( *pDlgType
== 0 ) // area dialog
185 // ActivatePage() is called before the dialog receives PageCreated() !!!
188 if( *pPageType
== 1 &&
189 *pPosDashLb
!= LISTBOX_ENTRY_NOTFOUND
)
191 aLbLineStyles
.SelectEntryPos( *pPosDashLb
);
193 // so that a possibly existing line style is discarded
194 SelectLinestyleHdl_Impl( this );
196 // determining (and possibly cutting) the name
197 // and displaying it in the GroupBox
198 OUString
aString( CUI_RES( RID_SVXSTR_TABLE
) );
200 INetURLObject
aURL( pDashList
->GetPath() );
202 aURL
.Append( pDashList
->GetName() );
203 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
206 *pPosDashLb
= LISTBOX_ENTRY_NOTFOUND
;
211 // -----------------------------------------------------------------------
213 int SvxLineDefTabPage::DeactivatePage( SfxItemSet
* _pSet
)
218 FillItemSet( *_pSet
);
220 return( LEAVE_PAGE
);
223 // -----------------------------------------------------------------------
225 void SvxLineDefTabPage::CheckChanges_Impl()
227 // is here used to NOT lose changes
230 if( aNumFldNumber1
.GetText() != aNumFldNumber1
.GetSavedValue() ||
231 aMtrLength1
.GetText() != aMtrLength1
.GetSavedValue() ||
232 aLbType1
.GetSelectEntryPos() != aLbType1
.GetSavedValue() ||
233 aNumFldNumber2
.GetText() != aNumFldNumber2
.GetSavedValue() ||
234 aMtrLength2
.GetText() != aMtrLength2
.GetSavedValue() ||
235 aLbType2
.GetSelectEntryPos() != aLbType2
.GetSavedValue() ||
236 aMtrDistance
.GetText() != aMtrDistance
.GetSavedValue() )
238 ResMgr
& rMgr
= CUI_MGR();
239 Image aWarningBoxImage
= WarningBox::GetStandardImage();
240 SvxMessDialog
* aMessDlg
= new SvxMessDialog(GetParentDialog(),
241 SVX_RESSTR( RID_SVXSTR_LINESTYLE
),
242 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE
, rMgr
) ),
244 DBG_ASSERT(aMessDlg
, "Dialogdiet fail!");
245 aMessDlg
->SetButtonText( MESS_BTN_1
,
246 String( ResId( RID_SVXSTR_CHANGE
, rMgr
) ) );
247 aMessDlg
->SetButtonText( MESS_BTN_2
,
248 String( ResId( RID_SVXSTR_ADD
, rMgr
) ) );
250 short nRet
= aMessDlg
->Execute();
256 ClickModifyHdl_Impl( this );
262 ClickAddHdl_Impl( this );
274 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
275 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
281 // -----------------------------------------------------------------------
283 sal_Bool
SvxLineDefTabPage::FillItemSet( SfxItemSet
& rAttrs
)
285 if( *pDlgType
== 0 ) // line dialog
287 if( *pPageType
== 2 )
291 String
aString( aLbLineStyles
.GetSelectEntry() );
292 rAttrs
.Put( XLineStyleItem( XLINE_DASH
) );
293 rAttrs
.Put( XLineDashItem( aString
, aDash
) );
299 // -----------------------------------------------------------------------
301 void SvxLineDefTabPage::Reset( const SfxItemSet
& rAttrs
)
303 if( rAttrs
.GetItemState( GetWhich( XATTR_LINESTYLE
) ) != SFX_ITEM_DONTCARE
)
305 XLineStyle eXLS
= (XLineStyle
) ( ( const XLineStyleItem
& ) rAttrs
.Get( GetWhich( XATTR_LINESTYLE
) ) ).GetValue();
311 aLbLineStyles
.SelectEntryPos( 0 );
316 const XLineDashItem
& rDashItem
= ( const XLineDashItem
& ) rAttrs
.Get( XATTR_LINEDASH
);
317 aDash
= rDashItem
.GetDashValue();
319 aLbLineStyles
.SetNoSelection();
320 aLbLineStyles
.SelectEntry( rDashItem
.GetName() );
328 SelectLinestyleHdl_Impl( NULL
);
330 // determine button state
331 if( pDashList
->Count() )
339 aBtnModify
.Disable();
340 aBtnDelete
.Disable();
345 // -----------------------------------------------------------------------
347 SfxTabPage
* SvxLineDefTabPage::Create( Window
* pWindow
,
348 const SfxItemSet
& rOutAttrs
)
350 return( new SvxLineDefTabPage( pWindow
, rOutAttrs
) );
353 //------------------------------------------------------------------------
355 IMPL_LINK( SvxLineDefTabPage
, SelectLinestyleHdl_Impl
, void *, p
)
357 if(pDashList
->Count())
359 int nTmp
= aLbLineStyles
.GetSelectEntryPos();
361 if(LISTBOX_ENTRY_NOTFOUND
== nTmp
)
363 OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)");
367 aDash
= pDashList
->GetDash( nTmp
)->GetDash();
371 rXLSet
.Put( XLineDashItem( String(), aDash
) );
374 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
376 aCtlPreview
.Invalidate();
378 // Is not set before, in order to take the new style
379 // only if there was an entry selected in the ListBox.
380 // If it was called via Reset(), then p is == NULL
387 //------------------------------------------------------------------------
389 IMPL_LINK_NOARG_INLINE_START(SvxLineDefTabPage
, ChangePreviewHdl_Impl
)
392 aCtlPreview
.Invalidate();
396 IMPL_LINK_NOARG_INLINE_END(SvxLineDefTabPage
, ChangePreviewHdl_Impl
)
398 //------------------------------------------------------------------------
400 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
)
402 if( aNumFldNumber1
.GetValue() == 0L )
404 aNumFldNumber2
.SetMin( 1L );
405 aNumFldNumber2
.SetFirst( 1L );
409 aNumFldNumber2
.SetMin( 0L );
410 aNumFldNumber2
.SetFirst( 0L );
413 ChangePreviewHdl_Impl( this );
418 //------------------------------------------------------------------------
420 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
)
422 if( aNumFldNumber2
.GetValue() == 0L )
424 aNumFldNumber1
.SetMin( 1L );
425 aNumFldNumber1
.SetFirst( 1L );
429 aNumFldNumber1
.SetMin( 0L );
430 aNumFldNumber1
.SetFirst( 0L );
433 ChangePreviewHdl_Impl( this );
439 //------------------------------------------------------------------------
441 IMPL_LINK( SvxLineDefTabPage
, ChangeMetricHdl_Impl
, void *, p
)
443 if( !aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != eFUnit
)
445 long nTmp1
, nTmp2
, nTmp3
;
447 // was changed with Control
450 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * XOUT_WIDTH
/ 100;
451 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * XOUT_WIDTH
/ 100;
452 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * XOUT_WIDTH
/ 100;
456 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
457 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
458 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
460 aMtrLength1
.SetDecimalDigits( 2 );
461 aMtrLength2
.SetDecimalDigits( 2 );
462 aMtrDistance
.SetDecimalDigits( 2 );
465 aMtrLength1
.SetUnit( eFUnit
);
466 aMtrLength2
.SetUnit( eFUnit
);
467 aMtrDistance
.SetUnit( eFUnit
);
469 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
470 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
471 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
473 else if( aCbxSynchronize
.IsChecked() && aMtrLength1
.GetUnit() != FUNIT_CUSTOM
)
475 long nTmp1
, nTmp2
, nTmp3
;
477 // was changed with Control
480 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
) * 100 / XOUT_WIDTH
;
481 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
) * 100 / XOUT_WIDTH
;
482 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
) * 100 / XOUT_WIDTH
;
486 nTmp1
= GetCoreValue( aMtrLength1
, ePoolUnit
);
487 nTmp2
= GetCoreValue( aMtrLength2
, ePoolUnit
);
488 nTmp3
= GetCoreValue( aMtrDistance
, ePoolUnit
);
491 aMtrLength1
.SetDecimalDigits( 0 );
492 aMtrLength2
.SetDecimalDigits( 0 );
493 aMtrDistance
.SetDecimalDigits( 0 );
495 aMtrLength1
.SetUnit( FUNIT_CUSTOM
);
496 aMtrLength2
.SetUnit( FUNIT_CUSTOM
);
497 aMtrDistance
.SetUnit( FUNIT_CUSTOM
);
500 SetMetricValue( aMtrLength1
, nTmp1
, ePoolUnit
);
501 SetMetricValue( aMtrLength2
, nTmp2
, ePoolUnit
);
502 SetMetricValue( aMtrDistance
, nTmp3
, ePoolUnit
);
504 SelectTypeHdl_Impl( NULL
);
509 //------------------------------------------------------------------------
511 IMPL_LINK( SvxLineDefTabPage
, SelectTypeHdl_Impl
, void *, p
)
513 if ( p
== &aLbType1
|| !p
)
515 if ( aLbType1
.GetSelectEntryPos() == 0 )
517 aMtrLength1
.Disable();
518 aMtrLength1
.SetText( String() );
520 else if ( !aMtrLength1
.IsEnabled() )
522 aMtrLength1
.Enable();
523 aMtrLength1
.Reformat();
527 if ( p
== &aLbType2
|| !p
)
529 if ( aLbType2
.GetSelectEntryPos() == 0 )
531 aMtrLength2
.Disable();
532 aMtrLength2
.SetText( String() );
534 else if ( !aMtrLength2
.IsEnabled() )
536 aMtrLength2
.Enable();
537 aMtrLength2
.Reformat();
540 ChangePreviewHdl_Impl( p
);
544 //------------------------------------------------------------------------
546 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickAddHdl_Impl
)
548 ResMgr
& rMgr
= CUI_MGR();
549 String
aNewName( SVX_RES( RID_SVXSTR_LINESTYLE
) );
550 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
554 long nCount
= pDashList
->Count();
556 sal_Bool bDifferent
= sal_False
;
558 while ( !bDifferent
)
561 aName
+= sal_Unicode(' ');
562 aName
+= OUString::valueOf( j
++ );
563 bDifferent
= sal_True
;
565 for ( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
566 if ( aName
== pDashList
->GetDash( i
)->GetName() )
567 bDifferent
= sal_False
;
570 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
571 DBG_ASSERT(pFact
, "Dialogdiet fail!");
572 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
);
573 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
574 sal_Bool bLoop
= sal_True
;
576 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
578 pDlg
->GetName( aName
);
579 bDifferent
= sal_True
;
581 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
583 if( aName
== pDashList
->GetDash( i
)->GetName() )
584 bDifferent
= sal_False
;
592 pEntry
= new XDashEntry( aDash
, aName
);
594 long nDashCount
= pDashList
->Count();
595 pDashList
->Insert( pEntry
, nDashCount
);
596 const Bitmap aBitmap
= pDashList
->GetUiBitmap( nDashCount
);
597 aLbLineStyles
.Append( pEntry
, &aBitmap
);
599 aLbLineStyles
.SelectEntryPos( aLbLineStyles
.GetEntryCount() - 1 );
601 *pnDashListState
|= CT_MODIFIED
;
605 // save values for changes recognition (-> method)
606 aNumFldNumber1
.SaveValue();
607 aMtrLength1
.SaveValue();
608 aLbType1
.SaveValue();
609 aNumFldNumber2
.SaveValue();
610 aMtrLength2
.SaveValue();
611 aLbType2
.SaveValue();
612 aMtrDistance
.SaveValue();
616 WarningBox
aBox( GetParentDialog(), WinBits( WB_OK
),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE
, rMgr
) ) );
617 aBox
.SetHelpId( HID_WARN_NAME_DUPLICATE
);
623 // determine button state
624 if ( pDashList
->Count() )
633 //------------------------------------------------------------------------
635 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickModifyHdl_Impl
)
637 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
639 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
641 ResMgr
& rMgr
= CUI_MGR();
642 String
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
643 String
aName( pDashList
->GetDash( nPos
)->GetName() );
644 String aOldName
= aName
;
646 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
647 DBG_ASSERT(pFact
, "Dialogdiet fail!");
648 AbstractSvxNameDialog
* pDlg
= pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
);
649 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
651 long nCount
= pDashList
->Count();
652 sal_Bool bDifferent
= sal_False
;
653 sal_Bool bLoop
= sal_True
;
655 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
657 pDlg
->GetName( aName
);
658 bDifferent
= sal_True
;
660 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
662 if( aName
== pDashList
->GetDash( i
)->GetName() &&
664 bDifferent
= sal_False
;
672 XDashEntry
* pEntry
= new XDashEntry( aDash
, aName
);
674 delete pDashList
->Replace( pEntry
, nPos
);
675 const Bitmap aBitmap
= pDashList
->GetUiBitmap( nPos
);
676 aLbLineStyles
.Modify( pEntry
, nPos
, &aBitmap
);
678 aLbLineStyles
.SelectEntryPos( nPos
);
680 *pnDashListState
|= CT_MODIFIED
;
684 // save values for changes recognition (-> method)
685 aNumFldNumber1
.SaveValue();
686 aMtrLength1
.SaveValue();
687 aLbType1
.SaveValue();
688 aNumFldNumber2
.SaveValue();
689 aMtrLength2
.SaveValue();
690 aLbType2
.SaveValue();
691 aMtrDistance
.SaveValue();
695 WarningBox
aBox( GetParentDialog(), WinBits( WB_OK
), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE
, rMgr
) ) );
696 aBox
.SetHelpId( HID_WARN_NAME_DUPLICATE
);
705 //------------------------------------------------------------------------
707 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickDeleteHdl_Impl
)
709 sal_uInt16 nPos
= aLbLineStyles
.GetSelectEntryPos();
711 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
713 QueryBox
aQueryBox( GetParentDialog(), WinBits( WB_YES_NO
| WB_DEF_NO
),
714 String( CUI_RES( RID_SVXSTR_ASK_DEL_LINESTYLE
) ) );
716 if ( aQueryBox
.Execute() == RET_YES
)
718 delete pDashList
->Remove( nPos
);
719 aLbLineStyles
.RemoveEntry( nPos
);
720 aLbLineStyles
.SelectEntryPos( 0 );
722 SelectLinestyleHdl_Impl( this );
723 *pPageType
= 0; // style should not be taken
725 *pnDashListState
|= CT_MODIFIED
;
727 ChangePreviewHdl_Impl( this );
731 // determine button state
732 if ( !pDashList
->Count() )
734 aBtnModify
.Disable();
735 aBtnDelete
.Disable();
741 // -----------------------------------------------------------------------
743 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickLoadHdl_Impl
)
745 ResMgr
& rMgr
= CUI_MGR();
746 sal_uInt16 nReturn
= RET_YES
;
748 if ( *pnDashListState
& CT_MODIFIED
)
750 nReturn
= WarningBox( GetParentDialog(), WinBits( WB_YES_NO_CANCEL
),
751 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE
, rMgr
) ) ).Execute();
753 if ( nReturn
== RET_YES
)
757 if ( nReturn
!= RET_CANCEL
)
759 ::sfx2::FileDialogHelper
aDlg(
760 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
762 String
aStrFilterType( "*.sod" );
763 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
764 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
765 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
767 if( aDlg
.Execute() == ERRCODE_NONE
)
769 INetURLObject
aURL( aDlg
.GetPath() );
770 INetURLObject
aPathURL( aURL
);
772 aPathURL
.removeSegment();
773 aPathURL
.removeFinalSlash();
775 XDashListRef pDshLst
= XPropertyList::CreatePropertyList(
776 XDASH_LIST
, aPathURL
.GetMainURL( INetURLObject::NO_DECODE
), pXPool
)->AsDashList();
777 pDshLst
->SetName( aURL
.getName() );
779 if( pDshLst
->Load() )
782 ( (SvxLineTabDialog
*) GetParentDialog() )->SetNewDashList( pDashList
);
784 aLbLineStyles
.Clear();
785 aLbLineStyles
.Fill( pDashList
);
788 pDashList
->SetName( aURL
.getName() );
790 *pnDashListState
|= CT_CHANGED
;
791 *pnDashListState
&= ~CT_MODIFIED
;
795 ErrorBox( GetParentDialog(), WinBits( WB_OK
),
796 String( ResId( RID_SVXSTR_READ_DATA_ERROR
, rMgr
) ) ).Execute();
800 // determine button state
801 if ( pDashList
->Count() )
809 aBtnModify
.Disable();
810 aBtnDelete
.Disable();
816 // -----------------------------------------------------------------------
818 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickSaveHdl_Impl
)
820 ::sfx2::FileDialogHelper
aDlg(
821 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
822 String
aStrFilterType( "*.sod" );
823 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
825 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
826 DBG_ASSERT( aFile
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
828 if( pDashList
->GetName().Len() )
830 aFile
.Append( pDashList
->GetName() );
832 if( aFile
.getExtension().isEmpty() )
833 aFile
.SetExtension( OUString("sod") );
836 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
837 if ( aDlg
.Execute() == ERRCODE_NONE
)
839 INetURLObject
aURL( aDlg
.GetPath() );
840 INetURLObject
aPathURL( aURL
);
842 aPathURL
.removeSegment();
843 aPathURL
.removeFinalSlash();
845 pDashList
->SetName( aURL
.getName() );
846 pDashList
->SetPath( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
) );
848 if( pDashList
->Save() )
850 *pnDashListState
|= CT_SAVED
;
851 *pnDashListState
&= ~CT_MODIFIED
;
855 ErrorBox( GetParentDialog(), WinBits( WB_OK
),
856 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR
) ) ).Execute();
863 //------------------------------------------------------------------------
865 void SvxLineDefTabPage::FillDash_Impl()
869 if( aCbxSynchronize
.IsChecked() )
870 eXDS
= XDASH_RECTRELATIVE
;
874 aDash
.SetDashStyle( eXDS
);
875 aDash
.SetDots( (sal_uInt8
) aNumFldNumber1
.GetValue() );
876 aDash
.SetDotLen( aLbType1
.GetSelectEntryPos() == 0 ? 0 :
877 GetCoreValue( aMtrLength1
, ePoolUnit
) );
878 aDash
.SetDashes( (sal_uInt8
) aNumFldNumber2
.GetValue() );
879 aDash
.SetDashLen( aLbType2
.GetSelectEntryPos() == 0 ? 0 :
880 GetCoreValue( aMtrLength2
, ePoolUnit
) );
881 aDash
.SetDistance( GetCoreValue( aMtrDistance
, ePoolUnit
) );
883 rXLSet
.Put( XLineDashItem( String(), aDash
) );
886 aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
889 //------------------------------------------------------------------------
891 void SvxLineDefTabPage::FillDialog_Impl()
893 XDashStyle eXDS
= aDash
.GetDashStyle(); // XDASH_RECT, XDASH_ROUND
894 if( eXDS
== XDASH_RECTRELATIVE
)
895 aCbxSynchronize
.Check();
897 aCbxSynchronize
.Check( sal_False
);
899 aNumFldNumber1
.SetValue( aDash
.GetDots() );
900 SetMetricValue( aMtrLength1
, aDash
.GetDotLen(), ePoolUnit
);
901 aLbType1
.SelectEntryPos( aDash
.GetDotLen() == 0 ? 0 : 1 );
902 aNumFldNumber2
.SetValue( aDash
.GetDashes() );
903 SetMetricValue( aMtrLength2
, aDash
.GetDashLen(), ePoolUnit
);
904 aLbType2
.SelectEntryPos( aDash
.GetDashLen() == 0 ? 0 : 1 );
905 SetMetricValue( aMtrDistance
, aDash
.GetDistance(), ePoolUnit
);
907 ChangeMetricHdl_Impl( NULL
);
909 // save values for changes recognition (-> method)
910 aNumFldNumber1
.SaveValue();
911 aMtrLength1
.SaveValue();
912 aLbType1
.SaveValue();
913 aNumFldNumber2
.SaveValue();
914 aMtrLength2
.SaveValue();
915 aLbType2
.SaveValue();
916 aMtrDistance
.SaveValue();
920 void SvxLineDefTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
922 SfxTabPage::DataChanged( rDCEvt
);
924 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
926 sal_uInt16 nOldSelect
= aLbLineStyles
.GetSelectEntryPos();
927 aLbLineStyles
.Clear();
928 aLbLineStyles
.Fill( pDashList
);
929 aLbLineStyles
.SelectEntryPos( nOldSelect
);
933 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */