25#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
42#include <svx/strings.hrc>
43#include <svx/svxids.hrc>
46#include <osl/diagnose.h>
54 :
SfxTabPage(pPage, pController,
"cui/ui/linestyletabpage.ui",
"LineStylePage", &rInAttrs)
56 , aXLineAttr(rInAttrs.GetPool())
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))
174 DBG_ASSERT(
aURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL" );
188 return DeactivateRC::LeavePage;
205 VclMessageType::Warning, VclButtonsType::Cancel,
206 CuiResId(RID_CUISTR_ASK_CHANGE_LINESTYLE)));
207 xMessDlg->set_title(
SvxResId(RID_SVXSTR_LINESTYLE));
211 short nRet = xMessDlg->run();
265 case drawing::LineStyle_NONE:
266 case drawing::LineStyle_SOLID:
269 case drawing::LineStyle_DASH:
301 return std::make_unique<SvxLineDefTabPage>(pPage, pController, *
rOutAttrs);
306 SelectLinestyleHdl_Impl(&rListBox);
317 OSL_ENSURE(
false,
"OOps, non-existent LineDash selected (!)");
341 m_aCtlPreview.Invalidate();
346 if (m_xNumFldNumber1->get_value() == 0)
348 m_xNumFldNumber2->set_min(1);
352 m_xNumFldNumber2->set_min(0);
355 ChangePreviewHdl_Impl(*m_xMtrLength1);
360 if (m_xNumFldNumber2->get_value() == 0)
362 m_xNumFldNumber1->set_min(1);
366 m_xNumFldNumber1->set_min(0);
369 ChangePreviewHdl_Impl(*m_xMtrLength1);
374 ChangeMetricHdl_Impl(&r);
454 SelectTypeHdl_Impl(&rListBox);
491 OUString aNewName(
SvxResId(RID_SVXSTR_LINESTYLE));
492 OUString aDesc(
CuiResId(RID_CUISTR_DESC_LINESTYLE));
497 bool bDifferent =
false;
499 while ( !bDifferent )
501 aName = aNewName +
" " + OUString::number( j++ );
505 if (
aName == pDashList->GetDash(
i )->GetName() )
513 while ( bLoop && pDlg->Execute() ==
RET_OK )
515 pDlg->GetName(
aName );
520 if(
aName == pDashList->GetDash(
i )->GetName() )
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;
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();
551 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
558 if ( pDashList->Count() )
560 m_xBtnModify->set_sensitive(
true);
561 m_xBtnDelete->set_sensitive(
true);
562 m_xBtnSave->set_sensitive(
true);
568 int nPos = m_xLbLineStyles->get_active();
572 OUString aDesc(
CuiResId(RID_CUISTR_DESC_LINESTYLE));
573 OUString
aName( pDashList->GetDash(
nPos )->GetName() );
574 OUString aOldName =
aName;
582 while ( bLoop && pDlg->Execute() ==
RET_OK )
584 pDlg->GetName(
aName );
585 bool bDifferent =
true;
589 if(
aName == pDashList->GetDash(
i )->GetName() &&
599 pDashList->Replace(std::make_unique<XDashEntry>(aDash,
aName),
nPos);
600 m_xLbLineStyles->Modify(*pDashList->GetDash(
nPos),
nPos, pDashList->GetUiBitmap(
nPos));
602 m_xLbLineStyles->set_active(
nPos);
604 *pnDashListState |= ChangeType::MODIFIED;
609 m_xNumFldNumber1->save_value();
610 m_xMtrLength1->save_value();
611 m_xLbType1->save_value();
612 m_xNumFldNumber2->save_value();
613 m_xMtrLength2->save_value();
614 m_xLbType2->save_value();
615 m_xMtrDistance->save_value();
620 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
628 int nPos = m_xLbLineStyles->get_active();
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 );
642 *pnDashListState |= ChangeType::MODIFIED;
644 ChangePreviewHdl_Impl( *m_xMtrLength1 );
649 if ( !pDashList->Count() )
651 m_xBtnModify->set_sensitive(
false);
652 m_xBtnDelete->set_sensitive(
false);
653 m_xBtnSave->set_sensitive(
false);
661 if ( *pnDashListState & ChangeType::MODIFIED )
664 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"AskSaveList"));
666 nReturn = xBox->run();
676 OUString aStrFilterType(
"*.sod" );
677 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
683 aLastDir = aPalettePath.getToken(0,
';',
nIndex);
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;
718 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoLoadedFileDialog"));
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);
742 OUString aStrFilterType(
"*.sod" );
743 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
750 aLastDir = aPalettePath.getToken(0,
';',
nIndex);
757 if( !pDashList->GetName().isEmpty() )
759 aFile.
Append( pDashList->GetName() );
775 pDashList->SetName(
aURL.getName() );
778 if( pDashList->Save() )
785 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoSaveFileDialog"));
792 css::drawing::DashStyle eXDS;
795 eXDS = css::drawing::DashStyle_RECTRELATIVE;
797 eXDS = css::drawing::DashStyle_RECT;
815 if( eXDS == css::drawing::DashStyle_RECTRELATIVE )
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetExtension(std::u16string_view rTheExtension)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
INetProtocol GetProtocol() const
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString const & GetName() const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetExchangeSupport()
weld::Window * GetFrameWeld() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::CheckButton > m_xCbxSynchronize
SvxXLinePreview m_aCtlPreview
std::unique_ptr< weld::ComboBox > m_xLbType2
std::unique_ptr< weld::Button > m_xBtnAdd
void SelectLinestyleHdl_Impl(const weld::ComboBox *)
std::unique_ptr< weld::Button > m_xBtnModify
void ChangeMetricHdl_Impl(const weld::Toggleable *)
void SelectTypeHdl_Impl(const weld::ComboBox *)
std::unique_ptr< weld::SpinButton > m_xNumFldNumber2
const SfxItemSet & rOutAttrs
std::unique_ptr< weld::Button > m_xBtnDelete
std::unique_ptr< weld::Button > m_xBtnLoad
std::unique_ptr< weld::MetricSpinButton > m_xMtrDistance
std::unique_ptr< weld::SpinButton > m_xNumFldNumber1
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
virtual bool FillItemSet(SfxItemSet *) override
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< weld::ComboBox > m_xLbType1
std::unique_ptr< weld::MetricSpinButton > m_xMtrLength2
XLineAttrSetItem aXLineAttr
std::unique_ptr< weld::MetricSpinButton > m_xMtrLength1
virtual void ActivatePage(const SfxItemSet &rSet) override
std::unique_ptr< SvxLineLB > m_xLbLineStyles
std::unique_ptr< weld::Button > m_xBtnSave
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
SvxLineDefTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
virtual ~SvxLineDefTabPage() override
void SetLineAttributes(const SfxItemSet &rItemSet)
void SetDashLen(double nNewDashLen)
void SetDots(sal_uInt16 nNewDots)
css::drawing::DashStyle GetDashStyle() const
void SetDotLen(double nNewDotLen)
double GetDashLen() const
void SetDistance(double nNewDistance)
void SetDashes(sal_uInt16 nNewDashes)
double GetDistance() const
void SetDashStyle(css::drawing::DashStyle eNewStyle)
sal_uInt16 GetDots() const
sal_uInt16 GetDashes() const
const XDash & GetDashValue() const
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
static XDashListRef AsDashList(rtl::Reference< XPropertyList > const &plist)
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
void SetDisplayDirectory(const OUString &rPath)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
SVXCORE_DLLPUBLIC FieldUnit GetModuleFieldUnit(const SfxItemSet &)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(SvxLineDefTabPage, ChangePreviewHdl_Impl, weld::MetricSpinButton &, void)
IMPL_LINK(SvxLineDefTabPage, SelectLinestyleListBoxHdl_Impl, weld::ComboBox &, rListBox, void)
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)