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/settings.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/weld.hxx>
24 #include <unotools/pathoptions.hxx>
25 #include <sfx2/filedlghelper.hxx>
26 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
28 #include <strings.hrc>
30 #include <svx/xlineit0.hxx>
31 #include <svx/xlnwtit.hxx>
32 #include <svx/xlndsit.hxx>
33 #include <svx/xlnclit.hxx>
34 #include <svx/xtable.hxx>
36 #include <svx/dlgctrl.hxx>
37 #include <cuitabline.hxx>
38 #include <defdlgname.hxx>
39 #include <svx/svxdlg.hxx>
40 #include <dialmgr.hxx>
41 #include <svx/dlgutil.hxx>
42 #include <svx/dialmgr.hxx>
43 #include <svx/strings.hrc>
44 #include <svx/svxids.hrc>
45 #include <cuitabarea.hxx>
46 #include <svtools/unitconv.hxx>
48 #define XOUT_WIDTH 150
50 using namespace com::sun::star
;
53 SvxLineDefTabPage::SvxLineDefTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rInAttrs
)
54 : SfxTabPage(pPage
, pController
, "cui/ui/linestyletabpage.ui", "LineStylePage", &rInAttrs
)
56 , aXLineAttr(rInAttrs
.GetPool())
57 , rXLSet(aXLineAttr
.GetItemSet())
58 , pnDashListState(nullptr)
62 , m_xLbLineStyles(new SvxLineLB(m_xBuilder
->weld_combo_box("LB_LINESTYLES")))
63 , m_xLbType1(m_xBuilder
->weld_combo_box("LB_TYPE_1"))
64 , m_xLbType2(m_xBuilder
->weld_combo_box("LB_TYPE_2"))
65 , m_xNumFldNumber1(m_xBuilder
->weld_spin_button("NUM_FLD_1"))
66 , m_xNumFldNumber2(m_xBuilder
->weld_spin_button("NUM_FLD_2"))
67 , m_xMtrLength1(m_xBuilder
->weld_metric_spin_button("MTR_FLD_LENGTH_1", FieldUnit::CM
))
68 , m_xMtrLength2(m_xBuilder
->weld_metric_spin_button("MTR_FLD_LENGTH_2", FieldUnit::CM
))
69 , m_xMtrDistance(m_xBuilder
->weld_metric_spin_button("MTR_FLD_DISTANCE", FieldUnit::CM
))
70 , m_xCbxSynchronize(m_xBuilder
->weld_check_button("CBX_SYNCHRONIZE"))
71 , m_xBtnAdd(m_xBuilder
->weld_button("BTN_ADD"))
72 , m_xBtnModify(m_xBuilder
->weld_button("BTN_MODIFY"))
73 , m_xBtnDelete(m_xBuilder
->weld_button("BTN_DELETE"))
74 , m_xBtnLoad(m_xBuilder
->weld_button("BTN_LOAD"))
75 , m_xBtnSave(m_xBuilder
->weld_button("BTN_SAVE"))
76 , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder
, "CTL_PREVIEW", m_aCtlPreview
))
78 // this page needs ExchangeSupport
82 eFUnit
= GetModuleFieldUnit( rInAttrs
);
88 eFUnit
= FieldUnit::MM
;
90 default: ; //prevent warning
92 SetFieldUnit(*m_xMtrDistance
, eFUnit
);
93 SetFieldUnit(*m_xMtrLength1
, eFUnit
);
94 SetFieldUnit(*m_xMtrLength2
, eFUnit
);
97 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
98 DBG_ASSERT( pPool
, "Where is the pool?" );
99 ePoolUnit
= pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
101 rXLSet
.Put( XLineStyleItem(drawing::LineStyle_DASH
) );
102 rXLSet
.Put( XLineWidthItem(XOUT_WIDTH
) );
103 rXLSet
.Put( XLineDashItem( OUString(), XDash( css::drawing::DashStyle_RECT
, 3, 7, 2, 40, 15 ) ) );
104 rXLSet
.Put( XLineColorItem(OUString(), COL_BLACK
) );
107 m_aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
109 m_xBtnAdd
->connect_clicked(LINK(this, SvxLineDefTabPage
, ClickAddHdl_Impl
));
110 m_xBtnModify
->connect_clicked(LINK(this, SvxLineDefTabPage
, ClickModifyHdl_Impl
));
111 m_xBtnDelete
->connect_clicked(LINK(this, SvxLineDefTabPage
, ClickDeleteHdl_Impl
));
112 m_xBtnLoad
->connect_clicked(LINK(this, SvxLineDefTabPage
, ClickLoadHdl_Impl
));
113 m_xBtnSave
->connect_clicked(LINK(this, SvxLineDefTabPage
, ClickSaveHdl_Impl
));
115 m_xNumFldNumber1
->connect_value_changed(LINK(this, SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
));
116 m_xNumFldNumber2
->connect_value_changed(LINK(this, SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
));
117 m_xLbLineStyles
->connect_changed(LINK(this, SvxLineDefTabPage
, SelectLinestyleListBoxHdl_Impl
));
119 // #i122042# switch off default adding of 'none' and 'solid' entries
120 // for this ListBox; we want to select only editable/dashed styles
121 m_xLbLineStyles
->setAddStandardFields(false);
123 // absolute (in mm) or relative (in %)
124 m_xCbxSynchronize
->connect_toggled(LINK(this, SvxLineDefTabPage
, ChangeMetricHdl_Impl
));
126 // preview must be updated when there's something changed
127 Link
<weld::ComboBox
&, void> aLink
= LINK(this, SvxLineDefTabPage
, SelectTypeListBoxHdl_Impl
);
128 m_xLbType1
->connect_changed(aLink
);
129 m_xLbType2
->connect_changed(aLink
);
130 Link
<weld::MetricSpinButton
&,void> aLink2
= LINK( this, SvxLineDefTabPage
, ChangePreviewHdl_Impl
);
131 m_xMtrLength1
->connect_value_changed(aLink2
);
132 m_xMtrLength2
->connect_value_changed(aLink2
);
133 m_xMtrDistance
->connect_value_changed(aLink2
);
138 SvxLineDefTabPage::~SvxLineDefTabPage()
140 m_xCtlPreview
.reset();
141 m_xLbLineStyles
.reset();
144 void SvxLineDefTabPage::Construct()
146 // Line style fill; do *not* add default fields here
147 m_xLbLineStyles
->Fill( pDashList
);
150 void SvxLineDefTabPage::ActivatePage( const SfxItemSet
& )
152 if( nDlgType
== 0 ) // area dialog
154 // ActivatePage() is called before the dialog receives PageCreated() !!!
157 if (*pPageType
== PageType::Gradient
&&
160 m_xLbLineStyles
->set_active(*pPosDashLb
);
162 // so that a possibly existing line style is discarded
163 SelectLinestyleHdl_Impl( nullptr );
165 // determining (and possibly cutting) the name
166 // and displaying it in the GroupBox
167 // OUString aString( CuiResId( RID_SVXSTR_TABLE ) );
169 INetURLObject
aURL( pDashList
->GetPath() );
171 aURL
.Append( pDashList
->GetName() );
172 DBG_ASSERT( aURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
174 *pPageType
= PageType::Area
; // 2
175 *pPosDashLb
= LISTBOX_ENTRY_NOTFOUND
;
181 DeactivateRC
SvxLineDefTabPage::DeactivatePage( SfxItemSet
* _pSet
)
186 FillItemSet( _pSet
);
188 return DeactivateRC::LeavePage
;
191 void SvxLineDefTabPage::CheckChanges_Impl()
193 // is here used to NOT lose changes
194 //css::drawing::DashStyle eXDS;
196 if( m_xNumFldNumber1
->get_value_changed_from_saved() ||
197 m_xMtrLength1
->get_value_changed_from_saved() ||
198 m_xLbType1
->get_value_changed_from_saved() ||
199 m_xNumFldNumber2
->get_value_changed_from_saved() ||
200 m_xMtrLength2
->get_value_changed_from_saved() ||
201 m_xLbType2
->get_value_changed_from_saved() ||
202 m_xMtrDistance
->get_value_changed_from_saved() )
204 std::unique_ptr
<weld::MessageDialog
> xMessDlg(Application::CreateMessageDialog(GetFrameWeld(),
205 VclMessageType::Warning
, VclButtonsType::Cancel
,
206 CuiResId(RID_SVXSTR_ASK_CHANGE_LINESTYLE
)));
207 xMessDlg
->set_title(SvxResId(RID_SVXSTR_LINESTYLE
));
208 xMessDlg
->add_button(CuiResId(RID_SVXSTR_CHANGE
), RET_BTN_1
);
209 xMessDlg
->add_button(CuiResId(RID_SVXSTR_ADD
), RET_BTN_2
);
211 short nRet
= xMessDlg
->run();
217 ClickModifyHdl_Impl(*m_xBtnModify
);
223 ClickAddHdl_Impl(*m_xBtnAdd
);
232 int nPos
= m_xLbLineStyles
->get_active();
240 bool SvxLineDefTabPage::FillItemSet( SfxItemSet
* rAttrs
)
242 if( nDlgType
== 0 ) // line dialog
244 if( *pPageType
== PageType::Hatch
)
248 OUString
aString(m_xLbLineStyles
->get_active_text());
249 rAttrs
->Put( XLineStyleItem( drawing::LineStyle_DASH
) );
250 rAttrs
->Put( XLineDashItem( aString
, aDash
) );
257 void SvxLineDefTabPage::Reset( const SfxItemSet
* rAttrs
)
259 if( rAttrs
->GetItemState( GetWhich( XATTR_LINESTYLE
) ) != SfxItemState::DONTCARE
)
261 drawing::LineStyle eXLS
= static_cast<const XLineStyleItem
&>( rAttrs
->Get( GetWhich( XATTR_LINESTYLE
) ) ).GetValue();
265 case drawing::LineStyle_NONE
:
266 case drawing::LineStyle_SOLID
:
267 m_xLbLineStyles
->set_active(0);
269 case drawing::LineStyle_DASH
:
271 const XLineDashItem
& rDashItem
= rAttrs
->Get( XATTR_LINEDASH
);
272 aDash
= rDashItem
.GetDashValue();
274 m_xLbLineStyles
->set_active(-1);
275 m_xLbLineStyles
->set_active_text(rDashItem
.GetName());
282 SelectLinestyleHdl_Impl( nullptr );
284 // determine button state
285 if( pDashList
->Count() )
287 m_xBtnModify
->set_sensitive(true);
288 m_xBtnDelete
->set_sensitive(true);
289 m_xBtnSave
->set_sensitive(true);
293 m_xBtnModify
->set_sensitive(false);
294 m_xBtnDelete
->set_sensitive(false);
295 m_xBtnSave
->set_sensitive(false);
299 std::unique_ptr
<SfxTabPage
> SvxLineDefTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rOutAttrs
)
301 return std::make_unique
<SvxLineDefTabPage
>(pPage
, pController
, *rOutAttrs
);
304 IMPL_LINK(SvxLineDefTabPage
, SelectLinestyleListBoxHdl_Impl
, weld::ComboBox
&, rListBox
, void)
306 SelectLinestyleHdl_Impl(&rListBox
);
309 void SvxLineDefTabPage::SelectLinestyleHdl_Impl(const weld::ComboBox
* p
)
311 if(pDashList
->Count())
313 int nTmp
= m_xLbLineStyles
->get_active();
316 OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)");
320 aDash
= pDashList
->GetDash( nTmp
)->GetDash();
324 rXLSet
.Put( XLineDashItem( OUString(), aDash
) );
327 m_aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
328 m_aCtlPreview
.Invalidate();
330 // Is not set before, in order to take the new style
331 // only if there was an entry selected in the ListBox.
332 // If it was called via Reset(), then p is == NULL
334 *pPageType
= PageType::Hatch
;
338 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangePreviewHdl_Impl
, weld::MetricSpinButton
&, void)
341 m_aCtlPreview
.Invalidate();
344 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber1Hdl_Impl
, weld::SpinButton
&, void)
346 if (m_xNumFldNumber1
->get_value() == 0)
348 m_xNumFldNumber2
->set_min(1);
352 m_xNumFldNumber2
->set_min(0);
355 ChangePreviewHdl_Impl(*m_xMtrLength1
);
358 IMPL_LINK_NOARG(SvxLineDefTabPage
, ChangeNumber2Hdl_Impl
, weld::SpinButton
&, void)
360 if (m_xNumFldNumber2
->get_value() == 0)
362 m_xNumFldNumber1
->set_min(1);
366 m_xNumFldNumber1
->set_min(0);
369 ChangePreviewHdl_Impl(*m_xMtrLength1
);
372 IMPL_LINK( SvxLineDefTabPage
, ChangeMetricHdl_Impl
, weld::ToggleButton
&, r
, void)
374 ChangeMetricHdl_Impl(&r
);
377 void SvxLineDefTabPage::ChangeMetricHdl_Impl(const weld::ToggleButton
* p
)
379 if( !m_xCbxSynchronize
->get_active() && m_xMtrLength1
->get_unit() != eFUnit
)
381 long nTmp1
, nTmp2
, nTmp3
;
383 // was changed with Control
386 nTmp1
= GetCoreValue( *m_xMtrLength1
, ePoolUnit
) * XOUT_WIDTH
/ 100;
387 nTmp2
= GetCoreValue( *m_xMtrLength2
, ePoolUnit
) * XOUT_WIDTH
/ 100;
388 nTmp3
= GetCoreValue( *m_xMtrDistance
, ePoolUnit
) * XOUT_WIDTH
/ 100;
392 nTmp1
= GetCoreValue( *m_xMtrLength1
, ePoolUnit
);
393 nTmp2
= GetCoreValue( *m_xMtrLength2
, ePoolUnit
);
394 nTmp3
= GetCoreValue( *m_xMtrDistance
, ePoolUnit
);
396 m_xMtrLength1
->set_digits(2);
397 m_xMtrLength2
->set_digits(2);
398 m_xMtrDistance
->set_digits(2);
401 m_xMtrLength1
->set_unit(eFUnit
);
402 m_xMtrLength2
->set_unit(eFUnit
);
403 m_xMtrDistance
->set_unit(eFUnit
);
405 // tdf#126736 max 5cm
406 m_xMtrLength1
->set_range(0, 500, FieldUnit::CM
);
407 m_xMtrLength2
->set_range(0, 500, FieldUnit::CM
);
408 m_xMtrDistance
->set_range(0, 500, FieldUnit::CM
);
410 SetMetricValue( *m_xMtrLength1
, nTmp1
, ePoolUnit
);
411 SetMetricValue( *m_xMtrLength2
, nTmp2
, ePoolUnit
);
412 SetMetricValue( *m_xMtrDistance
, nTmp3
, ePoolUnit
);
414 else if( m_xCbxSynchronize
->get_active() && m_xMtrLength1
->get_unit() != FieldUnit::PERCENT
)
416 long nTmp1
, nTmp2
, nTmp3
;
418 // was changed with Control
421 nTmp1
= GetCoreValue( *m_xMtrLength1
, ePoolUnit
) * 100 / XOUT_WIDTH
;
422 nTmp2
= GetCoreValue( *m_xMtrLength2
, ePoolUnit
) * 100 / XOUT_WIDTH
;
423 nTmp3
= GetCoreValue( *m_xMtrDistance
, ePoolUnit
) * 100 / XOUT_WIDTH
;
427 nTmp1
= GetCoreValue( *m_xMtrLength1
, ePoolUnit
);
428 nTmp2
= GetCoreValue( *m_xMtrLength2
, ePoolUnit
);
429 nTmp3
= GetCoreValue( *m_xMtrDistance
, ePoolUnit
);
432 m_xMtrLength1
->set_digits(0);
433 m_xMtrLength2
->set_digits(0);
434 m_xMtrDistance
->set_digits(0);
436 m_xMtrLength1
->set_unit(FieldUnit::PERCENT
);
437 m_xMtrLength2
->set_unit(FieldUnit::PERCENT
);
438 m_xMtrDistance
->set_unit(FieldUnit::PERCENT
);
441 m_xMtrLength1
->set_range(0, 800, FieldUnit::PERCENT
);
442 m_xMtrLength2
->set_range(0, 800, FieldUnit::PERCENT
);
443 m_xMtrDistance
->set_range(0, 800, FieldUnit::PERCENT
);
445 m_xMtrLength1
->set_value(nTmp1
, FieldUnit::PERCENT
);
446 m_xMtrLength2
->set_value(nTmp2
, FieldUnit::PERCENT
);
447 m_xMtrDistance
->set_value(nTmp3
, FieldUnit::PERCENT
);
449 SelectTypeHdl_Impl( nullptr );
452 IMPL_LINK( SvxLineDefTabPage
, SelectTypeListBoxHdl_Impl
, weld::ComboBox
&, rListBox
, void )
454 SelectTypeHdl_Impl(&rListBox
);
457 void SvxLineDefTabPage::SelectTypeHdl_Impl(const weld::ComboBox
* p
)
459 if (p
== m_xLbType1
.get() || !p
)
461 if (m_xLbType1
->get_active() == 0)
463 m_xMtrLength1
->set_sensitive(false);
464 m_xMtrLength1
->set_text("");
466 else if (!m_xMtrLength1
->get_sensitive())
468 m_xMtrLength1
->set_sensitive(true);
469 m_xMtrLength1
->reformat();
473 if (p
== m_xLbType2
.get() || !p
)
475 if (m_xLbType2
->get_active() == 0)
477 m_xMtrLength2
->set_sensitive(false);
478 m_xMtrLength2
->set_text("");
480 else if (!m_xMtrLength2
->get_sensitive())
482 m_xMtrLength2
->set_sensitive(true);
483 m_xMtrLength2
->reformat();
486 ChangePreviewHdl_Impl(*m_xMtrLength1
);
489 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickAddHdl_Impl
, weld::Button
&, void)
491 OUString
aNewName(SvxResId(RID_SVXSTR_LINESTYLE
));
492 OUString
aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE
));
495 long nCount
= pDashList
->Count();
497 bool bDifferent
= false;
499 while ( !bDifferent
)
501 aName
= aNewName
+ " " + OUString::number( j
++ );
504 for ( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
505 if ( aName
== pDashList
->GetDash( i
)->GetName() )
509 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
510 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
513 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
515 pDlg
->GetName( aName
);
518 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
520 if( aName
== pDashList
->GetDash( i
)->GetName() )
529 long nDashCount
= pDashList
->Count();
530 pDashList
->Insert( std::make_unique
<XDashEntry
>(aDash
, aName
), nDashCount
);
531 m_xLbLineStyles
->Append( *pDashList
->GetDash(nDashCount
), pDashList
->GetUiBitmap(nDashCount
) );
533 m_xLbLineStyles
->set_active(m_xLbLineStyles
->get_count() - 1);
535 *pnDashListState
|= ChangeType::MODIFIED
;
537 *pPageType
= PageType::Hatch
;
539 // save values for changes recognition (-> method)
540 m_xNumFldNumber1
->save_value();
541 m_xMtrLength1
->save_value();
542 m_xLbType1
->save_value();
543 m_xNumFldNumber2
->save_value();
544 m_xMtrLength2
->save_value();
545 m_xLbType2
->save_value();
546 m_xMtrDistance
->save_value();
550 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
551 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("DuplicateNameDialog"));
555 pDlg
.disposeAndClear();
557 // determine button state
558 if ( pDashList
->Count() )
560 m_xBtnModify
->set_sensitive(true);
561 m_xBtnDelete
->set_sensitive(true);
562 m_xBtnSave
->set_sensitive(true);
566 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickModifyHdl_Impl
, weld::Button
&, void)
568 int nPos
= m_xLbLineStyles
->get_active();
571 OUString
aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE
));
572 OUString
aName( pDashList
->GetDash( nPos
)->GetName() );
573 OUString aOldName
= aName
;
575 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
576 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
578 long nCount
= pDashList
->Count();
581 while ( bLoop
&& pDlg
->Execute() == RET_OK
)
583 pDlg
->GetName( aName
);
584 bool bDifferent
= true;
586 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
588 if( aName
== pDashList
->GetDash( i
)->GetName() &&
598 pDashList
->Replace(std::make_unique
<XDashEntry
>(aDash
, aName
), nPos
);
599 m_xLbLineStyles
->Modify(*pDashList
->GetDash(nPos
), nPos
, pDashList
->GetUiBitmap(nPos
));
601 m_xLbLineStyles
->set_active(nPos
);
603 *pnDashListState
|= ChangeType::MODIFIED
;
605 *pPageType
= PageType::Hatch
;
607 // save values for changes recognition (-> method)
608 m_xNumFldNumber1
->save_value();
609 m_xMtrLength1
->save_value();
610 m_xLbType1
->save_value();
611 m_xNumFldNumber2
->save_value();
612 m_xMtrLength2
->save_value();
613 m_xLbType2
->save_value();
614 m_xMtrDistance
->save_value();
618 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
619 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("DuplicateNameDialog"));
626 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickDeleteHdl_Impl
, weld::Button
&, void)
628 int nPos
= m_xLbLineStyles
->get_active();
631 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletelinestyledialog.ui"));
632 std::unique_ptr
<weld::MessageDialog
> xQueryBox(xBuilder
->weld_message_dialog("AskDelLineStyleDialog"));
633 if (xQueryBox
->run() == RET_YES
)
635 pDashList
->Remove(nPos
);
636 m_xLbLineStyles
->remove(nPos
);
637 m_xLbLineStyles
->set_active(0);
639 SelectLinestyleHdl_Impl( nullptr );
640 *pPageType
= PageType::Area
; // style should not be taken
642 *pnDashListState
|= ChangeType::MODIFIED
;
644 ChangePreviewHdl_Impl( *m_xMtrLength1
);
648 // determine button state
649 if ( !pDashList
->Count() )
651 m_xBtnModify
->set_sensitive(false);
652 m_xBtnDelete
->set_sensitive(false);
653 m_xBtnSave
->set_sensitive(false);
657 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickLoadHdl_Impl
, weld::Button
&, void)
659 sal_uInt16 nReturn
= RET_YES
;
661 if ( *pnDashListState
& ChangeType::MODIFIED
)
663 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querysavelistdialog.ui"));
664 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("AskSaveList"));
666 nReturn
= xBox
->run();
668 if ( nReturn
== RET_YES
)
672 if ( nReturn
!= RET_CANCEL
)
674 ::sfx2::FileDialogHelper
aDlg(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
675 FileDialogFlags::NONE
, GetFrameWeld());
676 OUString
aStrFilterType( "*.sod" );
677 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
678 OUString
aPalettePath(SvtPathOptions().GetPalettePath());
680 sal_Int32 nIndex
= 0;
683 aLastDir
= aPalettePath
.getToken(0, ';', nIndex
);
687 INetURLObject
aFile(aLastDir
);
688 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::DecodeMechanism::NONE
) );
690 if( aDlg
.Execute() == ERRCODE_NONE
)
692 INetURLObject
aURL( aDlg
.GetPath() );
693 INetURLObject
aPathURL( aURL
);
695 aPathURL
.removeSegment();
696 aPathURL
.removeFinalSlash();
698 XDashListRef pDshLst
= XPropertyList::AsDashList(XPropertyList::CreatePropertyList( XPropertyListType::Dash
, aPathURL
.GetMainURL( INetURLObject::DecodeMechanism::NONE
), "" ));
699 pDshLst
->SetName( aURL
.getName() );
701 if( pDshLst
->Load() )
704 static_cast<SvxLineTabDialog
*>(GetDialogController())->SetNewDashList( pDashList
);
706 m_xLbLineStyles
->clear();
707 m_xLbLineStyles
->Fill( pDashList
);
710 pDashList
->SetName( aURL
.getName() );
712 *pnDashListState
|= ChangeType::CHANGED
;
713 *pnDashListState
&= ~ChangeType::MODIFIED
;
717 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynoloadedfiledialog.ui"));
718 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("NoLoadedFileDialog"));
724 // determine button state
725 if ( pDashList
->Count() )
727 m_xBtnModify
->set_sensitive(true);
728 m_xBtnDelete
->set_sensitive(true);
729 m_xBtnSave
->set_sensitive(true);
733 m_xBtnModify
->set_sensitive(false);
734 m_xBtnDelete
->set_sensitive(false);
735 m_xBtnSave
->set_sensitive(false);
739 IMPL_LINK_NOARG(SvxLineDefTabPage
, ClickSaveHdl_Impl
, weld::Button
&, void)
741 ::sfx2::FileDialogHelper
aDlg(css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, FileDialogFlags::NONE
, GetFrameWeld());
742 OUString
aStrFilterType( "*.sod" );
743 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
745 OUString
aPalettePath(SvtPathOptions().GetPalettePath());
747 sal_Int32 nIndex
= 0;
750 aLastDir
= aPalettePath
.getToken(0, ';', nIndex
);
754 INetURLObject
aFile(aLastDir
);
755 DBG_ASSERT( aFile
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
757 if( !pDashList
->GetName().isEmpty() )
759 aFile
.Append( pDashList
->GetName() );
761 if( aFile
.getExtension().isEmpty() )
762 aFile
.SetExtension( "sod" );
765 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::DecodeMechanism::NONE
) );
766 if ( aDlg
.Execute() == ERRCODE_NONE
)
768 INetURLObject
aURL( aDlg
.GetPath() );
769 INetURLObject
aPathURL( aURL
);
771 aPathURL
.removeSegment();
772 aPathURL
.removeFinalSlash();
774 pDashList
->SetName( aURL
.getName() );
775 pDashList
->SetPath( aPathURL
.GetMainURL( INetURLObject::DecodeMechanism::NONE
) );
777 if( pDashList
->Save() )
779 *pnDashListState
&= ~ChangeType::MODIFIED
;
783 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui"));
784 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("NoSaveFileDialog"));
790 void SvxLineDefTabPage::FillDash_Impl()
792 css::drawing::DashStyle eXDS
;
794 if (m_xCbxSynchronize
->get_active())
795 eXDS
= css::drawing::DashStyle_RECTRELATIVE
;
797 eXDS
= css::drawing::DashStyle_RECT
;
799 aDash
.SetDashStyle( eXDS
);
800 aDash
.SetDots( static_cast<sal_uInt8
>(m_xNumFldNumber1
->get_value()) );
801 aDash
.SetDotLen( m_xLbType1
->get_active() == 0 ? 0 : GetCoreValue( *m_xMtrLength1
, ePoolUnit
) );
802 aDash
.SetDashes( static_cast<sal_uInt8
>(m_xNumFldNumber2
->get_value()) );
803 aDash
.SetDashLen( m_xLbType2
->get_active() == 0 ? 0 : GetCoreValue( *m_xMtrLength2
, ePoolUnit
) );
804 aDash
.SetDistance( GetCoreValue( *m_xMtrDistance
, ePoolUnit
) );
806 rXLSet
.Put( XLineDashItem( OUString(), aDash
) );
809 m_aCtlPreview
.SetLineAttributes(aXLineAttr
.GetItemSet());
812 void SvxLineDefTabPage::FillDialog_Impl()
814 css::drawing::DashStyle eXDS
= aDash
.GetDashStyle(); // css::drawing::DashStyle_RECT, css::drawing::DashStyle_ROUND
815 if( eXDS
== css::drawing::DashStyle_RECTRELATIVE
)
816 m_xCbxSynchronize
->set_active(true);
818 m_xCbxSynchronize
->set_active(false);
820 m_xNumFldNumber1
->set_value(aDash
.GetDots());
821 SetMetricValue( *m_xMtrLength1
, aDash
.GetDotLen(), ePoolUnit
);
822 m_xLbType1
->set_active(aDash
.GetDotLen() == 0 ? 0 : 1);
823 m_xNumFldNumber2
->set_value(aDash
.GetDashes());
824 SetMetricValue( *m_xMtrLength2
, aDash
.GetDashLen(), ePoolUnit
);
825 m_xLbType2
->set_active(aDash
.GetDashLen() == 0 ? 0 : 1);
826 SetMetricValue( *m_xMtrDistance
, aDash
.GetDistance(), ePoolUnit
);
828 ChangeMetricHdl_Impl(nullptr);
830 // save values for changes recognition (-> method)
831 m_xNumFldNumber1
->save_value();
832 m_xMtrLength1
->save_value();
833 m_xLbType1
->save_value();
834 m_xNumFldNumber2
->save_value();
835 m_xMtrLength2
->save_value();
836 m_xLbType2
->save_value();
837 m_xMtrDistance
->save_value();
840 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */