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/urlobj.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <vcl/settings.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"
32 #include "svx/xattr.hxx"
33 #include <svx/xpool.hxx>
34 #include <svx/xtable.hxx>
36 #include "svx/drawitem.hxx"
37 #include "cuitabline.hxx"
38 #include "dlgname.hxx"
39 #include "defdlgname.hxx"
40 #include <svx/svxdlg.hxx>
41 #include <dialmgr.hxx>
42 #include "svx/dlgutil.hxx"
43 #include <svx/dialmgr.hxx>
44 #include <svx/dialogs.hrc>
45 #include <boost/scoped_ptr.hpp>
47 #define XOUT_WIDTH 150
49 using namespace com::sun::star
;
52 SvxLineDefTabPage::SvxLineDefTabPage
55 const SfxItemSet
& rInAttrs
60 , "cui/ui/linestyletabpage.ui"
62 rOutAttrs ( rInAttrs
),
63 bObjSelected ( false ),
65 pXPool ( static_cast<XOutdevItemPool
*>(rInAttrs
.GetPool()) ),
66 aXLStyle ( drawing::LineStyle_DASH
),
67 aXWidth ( XOUT_WIDTH
),
68 aXDash ( OUString(), XDash( css::drawing::DashStyle_RECT
, 3, 7, 2, 40, 15 ) ),
69 aXColor ( OUString(), COL_BLACK
),
70 aXLineAttr ( pXPool
),
71 rXLSet ( aXLineAttr
.GetItemSet() ),
78 get(m_pLbLineStyles
,"LB_LINESTYLES");
79 get(m_pLbType1
,"LB_TYPE_1");
80 get(m_pLbType2
,"LB_TYPE_2");
81 get(m_pNumFldNumber1
,"NUM_FLD_1");
82 get(m_pNumFldNumber2
,"NUM_FLD_2");
83 get(m_pMtrLength1
,"MTR_FLD_LENGTH_1");
84 m_pMtrLength1
->SetCustomUnitText("%");
85 get(m_pMtrLength2
,"MTR_FLD_LENGTH_2");
86 m_pMtrLength2
->SetCustomUnitText("%");
87 get(m_pMtrDistance
,"MTR_FLD_DISTANCE");
88 m_pMtrDistance
->SetCustomUnitText("%");
89 get(m_pCbxSynchronize
,"CBX_SYNCHRONIZE");
90 get(m_pBtnAdd
,"BTN_ADD");
91 get(m_pBtnModify
,"BTN_MODIFY");
92 get(m_pBtnDelete
,"BTN_DELETE");
93 get(m_pBtnLoad
,"BTN_LOAD");
94 get(m_pBtnSave
,"BTN_SAVE");
95 get(m_pCtlPreview
,"CTL_PREVIEW");
97 // this page needs ExchangeSupport
101 eFUnit
= GetModuleFieldUnit( rInAttrs
);
109 default: ; //prevent warning
111 SetFieldUnit( *m_pMtrDistance
, eFUnit
);
112 SetFieldUnit( *m_pMtrLength1
, eFUnit
);
113 SetFieldUnit( *m_pMtrLength2
, eFUnit
);
115 // determine PoolUnit
116 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
117 DBG_ASSERT( pPool
, "Wo ist der Pool?" );
118 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
120 rXLSet
.Put( aXLStyle
);
121 rXLSet
.Put( aXWidth
);
122 rXLSet
.Put( aXDash
);
123 rXLSet
.Put( aXColor
);
126 m_pCtlPreview
->SetLineAttributes(aXLineAttr
.GetItemSet());
128 m_pBtnAdd
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickAddHdl_Impl
) );
129 m_pBtnModify
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickModifyHdl_Impl
) );
130 m_pBtnDelete
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickDeleteHdl_Impl
) );
131 m_pBtnLoad
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickLoadHdl_Impl
) );
132 m_pBtnSave
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ClickSaveHdl_Impl
) );
134 m_pNumFldNumber1
->SetModifyHdl( LINK( this, SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
) );
135 m_pNumFldNumber2
->SetModifyHdl( LINK( this, SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
) );
136 m_pLbLineStyles
->SetSelectHdl( LINK( this, SvxLineDefTabPage
, SelectLinestyleHdl_Impl
) );
138 // #i122042# switch off default adding of 'none' and 'solid' entries
139 // for this ListBox; we want to select only editable/dashed styles
140 m_pLbLineStyles
->setAddStandardFields(false);
142 // absolute (in mm) or relative (in %)
143 m_pCbxSynchronize
->SetClickHdl( LINK( this, SvxLineDefTabPage
, ChangeMetricHdl_Impl
) );
145 // preview must be updated when there's something changed
146 Link
<> aLink
= LINK( this, SvxLineDefTabPage
, SelectTypeHdl_Impl
);
147 m_pLbType1
->SetSelectHdl( aLink
);
148 m_pLbType2
->SetSelectHdl( aLink
);
149 aLink
= LINK( this, SvxLineDefTabPage
, ChangePreviewHdl_Impl
);
150 m_pMtrLength1
->SetModifyHdl( aLink
);
151 m_pMtrLength2
->SetModifyHdl( aLink
);
152 m_pMtrDistance
->SetModifyHdl( aLink
);
157 SvxLineDefTabPage::~SvxLineDefTabPage()
162 void SvxLineDefTabPage::dispose()
164 m_pLbLineStyles
.clear();
167 m_pNumFldNumber1
.clear();
168 m_pNumFldNumber2
.clear();
169 m_pMtrLength1
.clear();
170 m_pMtrLength2
.clear();
171 m_pMtrDistance
.clear();
172 m_pCbxSynchronize
.clear();
174 m_pBtnModify
.clear();
175 m_pBtnDelete
.clear();
178 m_pCtlPreview
.clear();
179 SfxTabPage::dispose();
182 void SvxLineDefTabPage::Construct()
184 // Line style fill; do *not* add default fields here
185 m_pLbLineStyles
->Fill( pDashList
);
190 void SvxLineDefTabPage::ActivatePage( const SfxItemSet
& )
192 if( nDlgType
== 0 ) // area dialog
194 // ActivatePage() is called before the dialog receives PageCreated() !!!
197 if( *pPageType
== 1 &&
198 *pPosDashLb
!= LISTBOX_ENTRY_NOTFOUND
)
200 m_pLbLineStyles
->SelectEntryPos( *pPosDashLb
);
202 // so that a possibly existing line style is discarded
203 SelectLinestyleHdl_Impl( this );
205 // determining (and possibly cutting) the name
206 // and displaying it in the GroupBox
207 // OUString aString( CUI_RES( RID_SVXSTR_TABLE ) );
209 INetURLObject
aURL( pDashList
->GetPath() );
211 aURL
.Append( pDashList
->GetName() );
212 DBG_ASSERT( aURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
215 *pPosDashLb
= LISTBOX_ENTRY_NOTFOUND
;
222 SfxTabPage::sfxpg
SvxLineDefTabPage::DeactivatePage( SfxItemSet
* _pSet
)
227 FillItemSet( _pSet
);
234 void SvxLineDefTabPage::CheckChanges_Impl()
236 // is here used to NOT lose changes
237 //css::drawing::DashStyle eXDS;
239 if( m_pNumFldNumber1
->IsValueChangedFromSaved() ||
240 m_pMtrLength1
->IsValueChangedFromSaved() ||
241 m_pLbType1
->IsValueChangedFromSaved() ||
242 m_pNumFldNumber2
->IsValueChangedFromSaved() ||
243 m_pMtrLength2
->IsValueChangedFromSaved() ||
244 m_pLbType2
->IsValueChangedFromSaved() ||
245 m_pMtrDistance
->IsValueChangedFromSaved() )
247 ResMgr
& rMgr
= CUI_MGR();
248 Image aWarningBoxImage
= WarningBox::GetStandardImage();
249 ScopedVclPtrInstance
<SvxMessDialog
> aMessDlg( GetParentDialog(),
250 SVX_RESSTR( RID_SVXSTR_LINESTYLE
),
251 OUString( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE
, rMgr
) ),
253 DBG_ASSERT(aMessDlg
, "Dialog creation failed!");
254 aMessDlg
->SetButtonText( MESS_BTN_1
, OUString( ResId( RID_SVXSTR_CHANGE
, rMgr
) ) );
255 aMessDlg
->SetButtonText( MESS_BTN_2
, OUString( ResId( RID_SVXSTR_ADD
, rMgr
) ) );
257 short nRet
= aMessDlg
->Execute();
263 ClickModifyHdl_Impl( this );
269 ClickAddHdl_Impl( this );
280 sal_Int32 nPos
= m_pLbLineStyles
->GetSelectEntryPos();
281 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
289 bool SvxLineDefTabPage::FillItemSet( SfxItemSet
* rAttrs
)
291 if( nDlgType
== 0 ) // line dialog
293 if( *pPageType
== 2 )
297 OUString
aString( m_pLbLineStyles
->GetSelectEntry() );
298 rAttrs
->Put( XLineStyleItem( drawing::LineStyle_DASH
) );
299 rAttrs
->Put( XLineDashItem( aString
, aDash
) );
307 void SvxLineDefTabPage::Reset( const SfxItemSet
* rAttrs
)
309 if( rAttrs
->GetItemState( GetWhich( XATTR_LINESTYLE
) ) != SfxItemState::DONTCARE
)
311 drawing::LineStyle eXLS
= (drawing::LineStyle
) static_cast<const XLineStyleItem
&>( rAttrs
->Get( GetWhich( XATTR_LINESTYLE
) ) ).GetValue();
315 case drawing::LineStyle_NONE
:
316 case drawing::LineStyle_SOLID
:
317 m_pLbLineStyles
->SelectEntryPos( 0 );
320 case drawing::LineStyle_DASH
:
322 const XLineDashItem
& rDashItem
= static_cast<const XLineDashItem
&>( rAttrs
->Get( XATTR_LINEDASH
) );
323 aDash
= rDashItem
.GetDashValue();
325 m_pLbLineStyles
->SetNoSelection();
326 m_pLbLineStyles
->SelectEntry( rDashItem
.GetName() );
334 SelectLinestyleHdl_Impl( NULL
);
336 // determine button state
337 if( pDashList
->Count() )
339 m_pBtnModify
->Enable();
340 m_pBtnDelete
->Enable();
341 m_pBtnSave
->Enable();
345 m_pBtnModify
->Disable();
346 m_pBtnDelete
->Disable();
347 m_pBtnSave
->Disable();
353 VclPtr
<SfxTabPage
> SvxLineDefTabPage::Create( vcl::Window
* pWindow
, const SfxItemSet
* rOutAttrs
)
355 return VclPtr
<SvxLineDefTabPage
>::Create( pWindow
, *rOutAttrs
);
360 IMPL_LINK( SvxLineDefTabPage
, SelectLinestyleHdl_Impl
, void *, p
)
362 if(pDashList
->Count())
364 int nTmp
= m_pLbLineStyles
->GetSelectEntryPos();
366 if(LISTBOX_ENTRY_NOTFOUND
== nTmp
)
368 OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)");
372 aDash
= pDashList
->GetDash( nTmp
)->GetDash();
376 rXLSet
.Put( XLineDashItem( OUString(), aDash
) );
379 m_pCtlPreview
->SetLineAttributes(aXLineAttr
.GetItemSet());
381 m_pCtlPreview
->Invalidate();
383 // Is not set before, in order to take the new style
384 // only if there was an entry selected in the ListBox.
385 // If it was called via Reset(), then p is == NULL
394 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangePreviewHdl_Impl
)
397 m_pCtlPreview
->Invalidate();
402 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
)
404 if( m_pNumFldNumber1
->GetValue() == 0L )
406 m_pNumFldNumber2
->SetMin( 1L );
407 m_pNumFldNumber2
->SetFirst( 1L );
411 m_pNumFldNumber2
->SetMin( 0L );
412 m_pNumFldNumber2
->SetFirst( 0L );
415 ChangePreviewHdl_Impl( this );
422 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
)
424 if( m_pNumFldNumber2
->GetValue() == 0L )
426 m_pNumFldNumber1
->SetMin( 1L );
427 m_pNumFldNumber1
->SetFirst( 1L );
431 m_pNumFldNumber1
->SetMin( 0L );
432 m_pNumFldNumber1
->SetFirst( 0L );
435 ChangePreviewHdl_Impl( this );
443 IMPL_LINK( SvxLineDefTabPage
, ChangeMetricHdl_Impl
, void *, p
)
445 if( !m_pCbxSynchronize
->IsChecked() && m_pMtrLength1
->GetUnit() != eFUnit
)
447 long nTmp1
, nTmp2
, nTmp3
;
449 // was changed with Control
452 nTmp1
= GetCoreValue( *m_pMtrLength1
, ePoolUnit
) * XOUT_WIDTH
/ 100;
453 nTmp2
= GetCoreValue( *m_pMtrLength2
, ePoolUnit
) * XOUT_WIDTH
/ 100;
454 nTmp3
= GetCoreValue( *m_pMtrDistance
, ePoolUnit
) * XOUT_WIDTH
/ 100;
458 nTmp1
= GetCoreValue( *m_pMtrLength1
, ePoolUnit
);
459 nTmp2
= GetCoreValue( *m_pMtrLength2
, ePoolUnit
);
460 nTmp3
= GetCoreValue( *m_pMtrDistance
, ePoolUnit
);
462 m_pMtrLength1
->SetDecimalDigits( 2 );
463 m_pMtrLength2
->SetDecimalDigits( 2 );
464 m_pMtrDistance
->SetDecimalDigits( 2 );
467 m_pMtrLength1
->SetUnit( eFUnit
);
468 m_pMtrLength2
->SetUnit( eFUnit
);
469 m_pMtrDistance
->SetUnit( eFUnit
);
471 SetMetricValue( *m_pMtrLength1
, nTmp1
, ePoolUnit
);
472 SetMetricValue( *m_pMtrLength2
, nTmp2
, ePoolUnit
);
473 SetMetricValue( *m_pMtrDistance
, nTmp3
, ePoolUnit
);
475 else if( m_pCbxSynchronize
->IsChecked() && m_pMtrLength1
->GetUnit() != FUNIT_PERCENT
)
477 long nTmp1
, nTmp2
, nTmp3
;
479 // was changed with Control
482 nTmp1
= GetCoreValue( *m_pMtrLength1
, ePoolUnit
) * 100 / XOUT_WIDTH
;
483 nTmp2
= GetCoreValue( *m_pMtrLength2
, ePoolUnit
) * 100 / XOUT_WIDTH
;
484 nTmp3
= GetCoreValue( *m_pMtrDistance
, ePoolUnit
) * 100 / XOUT_WIDTH
;
488 nTmp1
= GetCoreValue( *m_pMtrLength1
, ePoolUnit
);
489 nTmp2
= GetCoreValue( *m_pMtrLength2
, ePoolUnit
);
490 nTmp3
= GetCoreValue( *m_pMtrDistance
, ePoolUnit
);
493 m_pMtrLength1
->SetDecimalDigits( 0 );
494 m_pMtrLength2
->SetDecimalDigits( 0 );
495 m_pMtrDistance
->SetDecimalDigits( 0 );
497 m_pMtrLength1
->SetUnit( FUNIT_PERCENT
);
498 m_pMtrLength2
->SetUnit( FUNIT_PERCENT
);
499 m_pMtrDistance
->SetUnit( FUNIT_PERCENT
);
501 SetMetricValue( *m_pMtrLength1
, nTmp1
, ePoolUnit
);
502 SetMetricValue( *m_pMtrLength2
, nTmp2
, ePoolUnit
);
503 SetMetricValue( *m_pMtrDistance
, nTmp3
, ePoolUnit
);
506 SelectTypeHdl_Impl( NULL
);
513 IMPL_LINK( SvxLineDefTabPage
, SelectTypeHdl_Impl
, void *, p
)
515 if ( p
== m_pLbType1
|| !p
)
517 if ( m_pLbType1
->GetSelectEntryPos() == 0 )
519 m_pMtrLength1
->Disable();
520 m_pMtrLength1
->SetText( "" );
522 else if ( !m_pMtrLength1
->IsEnabled() )
524 m_pMtrLength1
->Enable();
525 m_pMtrLength1
->Reformat();
529 if ( p
== m_pLbType2
|| !p
)
531 if ( m_pLbType2
->GetSelectEntryPos() == 0 )
533 m_pMtrLength2
->Disable();
534 m_pMtrLength2
->SetText( "" );
536 else if ( !m_pMtrLength2
->IsEnabled() )
538 m_pMtrLength2
->Enable();
539 m_pMtrLength2
->Reformat();
542 ChangePreviewHdl_Impl( p
);
548 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickAddHdl_Impl
)
550 ResMgr
& rMgr
= CUI_MGR();
551 OUString
aNewName( SVX_RES( RID_SVXSTR_LINESTYLE
) );
552 OUString
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
556 long nCount
= pDashList
->Count();
558 bool bDifferent
= false;
560 while ( !bDifferent
)
564 aName
+= OUString::number( j
++ );
567 for ( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
568 if ( aName
== pDashList
->GetDash( i
)->GetName() )
572 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
573 DBG_ASSERT(pFact
, "Dialog creation failed!");
574 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
));
575 DBG_ASSERT(pDlg
, "Dialog creation failed!");
578 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
580 pDlg
->GetName( aName
);
583 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
585 if( aName
== pDashList
->GetDash( i
)->GetName() )
594 pEntry
= new XDashEntry( aDash
, aName
);
596 long nDashCount
= pDashList
->Count();
597 pDashList
->Insert( pEntry
, nDashCount
);
598 const Bitmap aBitmap
= pDashList
->GetUiBitmap( nDashCount
);
599 m_pLbLineStyles
->Append( *pEntry
, pDashList
->GetUiBitmap( nDashCount
) );
601 m_pLbLineStyles
->SelectEntryPos( m_pLbLineStyles
->GetEntryCount() - 1 );
603 *pnDashListState
|= ChangeType::MODIFIED
;
607 // save values for changes recognition (-> method)
608 m_pNumFldNumber1
->SaveValue();
609 m_pMtrLength1
->SaveValue();
610 m_pLbType1
->SaveValue();
611 m_pNumFldNumber2
->SaveValue();
612 m_pMtrLength2
->SaveValue();
613 m_pLbType2
->SaveValue();
614 m_pMtrDistance
->SaveValue();
618 ScopedVclPtrInstance
<MessageDialog
> aBox( GetParentDialog()
619 ,"DuplicateNameDialog"
620 ,"cui/ui/queryduplicatedialog.ui" );
626 // determine button state
627 if ( pDashList
->Count() )
629 m_pBtnModify
->Enable();
630 m_pBtnDelete
->Enable();
631 m_pBtnSave
->Enable();
638 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickModifyHdl_Impl
)
640 sal_Int32 nPos
= m_pLbLineStyles
->GetSelectEntryPos();
642 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
644 ResMgr
& rMgr
= CUI_MGR();
645 OUString
aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE
, rMgr
) );
646 OUString
aName( pDashList
->GetDash( nPos
)->GetName() );
647 OUString aOldName
= aName
;
649 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
650 DBG_ASSERT(pFact
, "Dialog creation failed!");
651 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
));
652 DBG_ASSERT(pDlg
, "Dialog creation failed!");
654 long nCount
= pDashList
->Count();
657 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
659 pDlg
->GetName( aName
);
660 bool bDifferent
= true;
662 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
664 if( aName
== pDashList
->GetDash( i
)->GetName() &&
674 XDashEntry
* pEntry
= new XDashEntry( aDash
, aName
);
676 delete pDashList
->Replace( pEntry
, nPos
);
677 m_pLbLineStyles
->Modify( *pEntry
, nPos
, pDashList
->GetUiBitmap( nPos
) );
679 m_pLbLineStyles
->SelectEntryPos( nPos
);
681 *pnDashListState
|= ChangeType::MODIFIED
;
685 // save values for changes recognition (-> method)
686 m_pNumFldNumber1
->SaveValue();
687 m_pMtrLength1
->SaveValue();
688 m_pLbType1
->SaveValue();
689 m_pNumFldNumber2
->SaveValue();
690 m_pMtrLength2
->SaveValue();
691 m_pLbType2
->SaveValue();
692 m_pMtrDistance
->SaveValue();
696 ScopedVclPtrInstance
<MessageDialog
> aBox( GetParentDialog()
697 ,"DuplicateNameDialog"
698 ,"cui/ui/queryduplicatedialog.ui" );
708 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickDeleteHdl_Impl
)
710 sal_Int32 nPos
= m_pLbLineStyles
->GetSelectEntryPos();
712 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
714 ScopedVclPtrInstance
<MessageDialog
> aQueryBox( GetParentDialog()
715 ,"AskDelLineStyleDialog"
716 ,"cui/ui/querydeletelinestyledialog.ui" );
718 if ( aQueryBox
->Execute() == RET_YES
)
720 delete pDashList
->Remove( nPos
);
721 m_pLbLineStyles
->RemoveEntry( nPos
);
722 m_pLbLineStyles
->SelectEntryPos( 0 );
724 SelectLinestyleHdl_Impl( this );
725 *pPageType
= 0; // style should not be taken
727 *pnDashListState
|= ChangeType::MODIFIED
;
729 ChangePreviewHdl_Impl( this );
733 // determine button state
734 if ( !pDashList
->Count() )
736 m_pBtnModify
->Disable();
737 m_pBtnDelete
->Disable();
738 m_pBtnSave
->Disable();
745 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickLoadHdl_Impl
)
747 sal_uInt16 nReturn
= RET_YES
;
749 if ( *pnDashListState
& ChangeType::MODIFIED
)
751 nReturn
= ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
753 ,"cui/ui/querysavelistdialog.ui")->Execute();
755 if ( nReturn
== RET_YES
)
759 if ( nReturn
!= RET_CANCEL
)
761 ::sfx2::FileDialogHelper
aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
, 0 );
762 OUString
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::AsDashList(XPropertyList::CreatePropertyList( XDASH_LIST
, aPathURL
.GetMainURL( INetURLObject::NO_DECODE
), "" ));
776 pDshLst
->SetName( aURL
.getName() );
778 if( pDshLst
->Load() )
781 static_cast<SvxLineTabDialog
*>( GetParentDialog() )->SetNewDashList( pDashList
);
783 m_pLbLineStyles
->Clear();
784 m_pLbLineStyles
->Fill( pDashList
);
787 pDashList
->SetName( aURL
.getName() );
789 *pnDashListState
|= ChangeType::CHANGED
;
790 *pnDashListState
&= ~ChangeType::MODIFIED
;
794 ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
795 ,"NoLoadedFileDialog"
796 ,"cui/ui/querynoloadedfiledialog.ui")->Execute();
800 // determine button state
801 if ( pDashList
->Count() )
803 m_pBtnModify
->Enable();
804 m_pBtnDelete
->Enable();
805 m_pBtnSave
->Enable();
809 m_pBtnModify
->Disable();
810 m_pBtnDelete
->Disable();
811 m_pBtnSave
->Disable();
818 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickSaveHdl_Impl
)
820 ::sfx2::FileDialogHelper
aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
821 OUString
aStrFilterType( "*.sod" );
822 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
824 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
825 DBG_ASSERT( aFile
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
827 if( !pDashList
->GetName().isEmpty() )
829 aFile
.Append( pDashList
->GetName() );
831 if( aFile
.getExtension().isEmpty() )
832 aFile
.SetExtension( OUString("sod") );
835 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
836 if ( aDlg
.Execute() == ERRCODE_NONE
)
838 INetURLObject
aURL( aDlg
.GetPath() );
839 INetURLObject
aPathURL( aURL
);
841 aPathURL
.removeSegment();
842 aPathURL
.removeFinalSlash();
844 pDashList
->SetName( aURL
.getName() );
845 pDashList
->SetPath( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
) );
847 if( pDashList
->Save() )
849 *pnDashListState
|= ChangeType::SAVED
;
850 *pnDashListState
&= ~ChangeType::MODIFIED
;
854 ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
856 ,"cui/ui/querynosavefiledialog.ui")->Execute();
865 void SvxLineDefTabPage::FillDash_Impl()
867 css::drawing::DashStyle eXDS
;
869 if( m_pCbxSynchronize
->IsChecked() )
870 eXDS
= css::drawing::DashStyle_RECTRELATIVE
;
872 eXDS
= css::drawing::DashStyle_RECT
;
874 aDash
.SetDashStyle( eXDS
);
875 aDash
.SetDots( (sal_uInt8
) m_pNumFldNumber1
->GetValue() );
876 aDash
.SetDotLen( m_pLbType1
->GetSelectEntryPos() == 0 ? 0 : GetCoreValue( *m_pMtrLength1
, ePoolUnit
) );
877 aDash
.SetDashes( (sal_uInt8
) m_pNumFldNumber2
->GetValue() );
878 aDash
.SetDashLen( m_pLbType2
->GetSelectEntryPos() == 0 ? 0 : GetCoreValue( *m_pMtrLength2
, ePoolUnit
) );
879 aDash
.SetDistance( GetCoreValue( *m_pMtrDistance
, ePoolUnit
) );
881 rXLSet
.Put( XLineDashItem( OUString(), aDash
) );
884 m_pCtlPreview
->SetLineAttributes(aXLineAttr
.GetItemSet());
889 void SvxLineDefTabPage::FillDialog_Impl()
891 css::drawing::DashStyle eXDS
= aDash
.GetDashStyle(); // css::drawing::DashStyle_RECT, css::drawing::DashStyle_ROUND
892 if( eXDS
== css::drawing::DashStyle_RECTRELATIVE
)
893 m_pCbxSynchronize
->Check();
895 m_pCbxSynchronize
->Check( false );
897 m_pNumFldNumber1
->SetValue( aDash
.GetDots() );
898 SetMetricValue( *m_pMtrLength1
, aDash
.GetDotLen(), ePoolUnit
);
899 m_pLbType1
->SelectEntryPos( aDash
.GetDotLen() == 0 ? 0 : 1 );
900 m_pNumFldNumber2
->SetValue( aDash
.GetDashes() );
901 SetMetricValue( *m_pMtrLength2
, aDash
.GetDashLen(), ePoolUnit
);
902 m_pLbType2
->SelectEntryPos( aDash
.GetDashLen() == 0 ? 0 : 1 );
903 SetMetricValue( *m_pMtrDistance
, aDash
.GetDistance(), ePoolUnit
);
905 ChangeMetricHdl_Impl( NULL
);
907 // save values for changes recognition (-> method)
908 m_pNumFldNumber1
->SaveValue();
909 m_pMtrLength1
->SaveValue();
910 m_pLbType1
->SaveValue();
911 m_pNumFldNumber2
->SaveValue();
912 m_pMtrLength2
->SaveValue();
913 m_pLbType2
->SaveValue();
914 m_pMtrDistance
->SaveValue();
918 void SvxLineDefTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
920 SfxTabPage::DataChanged( rDCEvt
);
922 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
924 sal_Int32 nOldSelect
= m_pLbLineStyles
->GetSelectEntryPos();
925 m_pLbLineStyles
->Clear();
926 m_pLbLineStyles
->Fill( pDashList
);
927 m_pLbLineStyles
->SelectEntryPos( nOldSelect
);
931 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */