25 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
27 #include <strings.hrc>
42 #include <svx/strings.hrc>
43 #include <svx/svxids.hrc>
47 #define XOUT_WIDTH 150
53 :
SfxTabPage(pPage, pController,
"cui/ui/linestyletabpage.ui",
"LineStylePage", &rInAttrs)
55 , aXLineAttr(rInAttrs.GetPool())
57 , pnDashListState(nullptr)
61 , m_xLbLineStyles(new
SvxLineLB(m_xBuilder->weld_combo_box(
"LB_LINESTYLES")))
62 , m_xLbType1(m_xBuilder->weld_combo_box(
"LB_TYPE_1"))
63 , m_xLbType2(m_xBuilder->weld_combo_box(
"LB_TYPE_2"))
64 , m_xNumFldNumber1(m_xBuilder->weld_spin_button(
"NUM_FLD_1"))
65 , m_xNumFldNumber2(m_xBuilder->weld_spin_button(
"NUM_FLD_2"))
66 , m_xMtrLength1(m_xBuilder->weld_metric_spin_button(
"MTR_FLD_LENGTH_1",
FieldUnit::
CM))
67 , m_xMtrLength2(m_xBuilder->weld_metric_spin_button(
"MTR_FLD_LENGTH_2",
FieldUnit::
CM))
68 , m_xMtrDistance(m_xBuilder->weld_metric_spin_button(
"MTR_FLD_DISTANCE",
FieldUnit::
CM))
69 , m_xCbxSynchronize(m_xBuilder->weld_check_button(
"CBX_SYNCHRONIZE"))
70 , m_xBtnAdd(m_xBuilder->weld_button(
"BTN_ADD"))
71 , m_xBtnModify(m_xBuilder->weld_button(
"BTN_MODIFY"))
72 , m_xBtnDelete(m_xBuilder->weld_button(
"BTN_DELETE"))
73 , m_xBtnLoad(m_xBuilder->weld_button(
"BTN_LOAD"))
74 , m_xBtnSave(m_xBuilder->weld_button(
"BTN_SAVE"))
75 , m_xCtlPreview(new
weld::CustomWeld(*m_xBuilder,
"CTL_PREVIEW", m_aCtlPreview))
173 DBG_ASSERT(
aURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL" );
187 return DeactivateRC::LeavePage;
204 VclMessageType::Warning, VclButtonsType::Cancel,
205 CuiResId(RID_SVXSTR_ASK_CHANGE_LINESTYLE)));
206 xMessDlg->set_title(
SvxResId(RID_SVXSTR_LINESTYLE));
210 short nRet = xMessDlg->run();
264 case drawing::LineStyle_NONE:
265 case drawing::LineStyle_SOLID:
268 case drawing::LineStyle_DASH:
300 return std::make_unique<SvxLineDefTabPage>(pPage, pController, *
rOutAttrs);
305 SelectLinestyleHdl_Impl(&rListBox);
316 OSL_ENSURE(
false,
"OOps, non-existent LineDash selected (!)");
340 m_aCtlPreview.Invalidate();
345 if (m_xNumFldNumber1->get_value() == 0)
347 m_xNumFldNumber2->set_min(1);
351 m_xNumFldNumber2->set_min(0);
354 ChangePreviewHdl_Impl(*m_xMtrLength1);
359 if (m_xNumFldNumber2->get_value() == 0)
361 m_xNumFldNumber1->set_min(1);
365 m_xNumFldNumber1->set_min(0);
368 ChangePreviewHdl_Impl(*m_xMtrLength1);
373 ChangeMetricHdl_Impl(&r);
453 SelectTypeHdl_Impl(&rListBox);
490 OUString aNewName(
SvxResId(RID_SVXSTR_LINESTYLE));
491 OUString aDesc(
CuiResId(RID_SVXSTR_DESC_LINESTYLE));
496 bool bDifferent =
false;
498 while ( !bDifferent )
500 aName = aNewName +
" " + OUString::number( j++ );
504 if ( aName == pDashList->GetDash(
i )->GetName() )
512 while ( bLoop && pDlg->Execute() ==
RET_OK )
514 pDlg->GetName( aName );
519 if( aName == pDashList->GetDash(
i )->GetName() )
529 pDashList->Insert( std::make_unique<XDashEntry>(aDash, aName), nDashCount );
530 m_xLbLineStyles->Append( *pDashList->GetDash(nDashCount), pDashList->GetUiBitmap(nDashCount) );
532 m_xLbLineStyles->set_active(m_xLbLineStyles->get_count() - 1);
534 *pnDashListState |= ChangeType::MODIFIED;
539 m_xNumFldNumber1->save_value();
540 m_xMtrLength1->save_value();
541 m_xLbType1->save_value();
542 m_xNumFldNumber2->save_value();
543 m_xMtrLength2->save_value();
544 m_xLbType2->save_value();
545 m_xMtrDistance->save_value();
550 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
554 pDlg.disposeAndClear();
557 if ( pDashList->Count() )
559 m_xBtnModify->set_sensitive(
true);
560 m_xBtnDelete->set_sensitive(
true);
561 m_xBtnSave->set_sensitive(
true);
567 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;
581 while ( bLoop && pDlg->Execute() ==
RET_OK )
583 pDlg->GetName(
aName );
584 bool bDifferent =
true;
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;
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();
619 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
627 int nPos = m_xLbLineStyles->get_active();
631 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelLineStyleDialog"));
632 if (xQueryBox->run() ==
RET_YES)
634 pDashList->Remove(nPos);
635 m_xLbLineStyles->remove(nPos);
636 m_xLbLineStyles->set_active(0);
638 SelectLinestyleHdl_Impl(
nullptr );
641 *pnDashListState |= ChangeType::MODIFIED;
643 ChangePreviewHdl_Impl( *m_xMtrLength1 );
648 if ( !pDashList->Count() )
650 m_xBtnModify->set_sensitive(
false);
651 m_xBtnDelete->set_sensitive(
false);
652 m_xBtnSave->set_sensitive(
false);
660 if ( *pnDashListState & ChangeType::MODIFIED )
663 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"AskSaveList"));
665 nReturn = xBox->run();
675 OUString aStrFilterType(
"*.sod" );
676 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
682 aLastDir = aPalettePath.getToken(0,
';', nIndex);
694 aPathURL.removeSegment();
695 aPathURL.removeFinalSlash();
698 pDshLst->SetName(
aURL.getName() );
700 if( pDshLst->Load() )
703 static_cast<SvxLineTabDialog*
>(GetDialogController())->SetNewDashList( pDashList );
705 m_xLbLineStyles->clear();
706 m_xLbLineStyles->Fill( pDashList );
709 pDashList->SetName(
aURL.getName() );
711 *pnDashListState |= ChangeType::CHANGED;
717 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoLoadedFileDialog"));
724 if ( pDashList->Count() )
726 m_xBtnModify->set_sensitive(
true);
727 m_xBtnDelete->set_sensitive(
true);
728 m_xBtnSave->set_sensitive(
true);
732 m_xBtnModify->set_sensitive(
false);
733 m_xBtnDelete->set_sensitive(
false);
734 m_xBtnSave->set_sensitive(
false);
741 OUString aStrFilterType(
"*.sod" );
742 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
749 aLastDir = aPalettePath.getToken(0,
';', nIndex);
756 if( !pDashList->GetName().isEmpty() )
758 aFile.
Append( pDashList->GetName() );
771 aPathURL.removeSegment();
772 aPathURL.removeFinalSlash();
774 pDashList->SetName(
aURL.getName() );
777 if( pDashList->Save() )
784 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoSaveFileDialog"));
791 css::drawing::DashStyle eXDS;
794 eXDS = css::drawing::DashStyle_RECTRELATIVE;
796 eXDS = css::drawing::DashStyle_RECT;
814 if( eXDS == css::drawing::DashStyle_RECTRELATIVE )
#define LINK(Instance, Class, Member)
void ChangeMetricHdl_Impl(const weld::ToggleButton *)
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
SvxLineDefTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
std::unique_ptr< weld::Button > m_xBtnModify
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
virtual void ActivatePage(const SfxItemSet &rSet) override
void SetDotLen(sal_uInt32 nNewDotLen)
static SvxAbstractDialogFactory * Create()
void SetDots(sal_uInt16 nNewDots)
sal_uInt32 GetDistance() const
IMPL_LINK_NOARG(SvxLineDefTabPage, ChangePreviewHdl_Impl, weld::MetricSpinButton &, void)
std::unique_ptr< weld::SpinButton > m_xNumFldNumber2
void SetDashLen(sal_uInt32 nNewDashLen)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
std::unique_ptr< weld::MetricSpinButton > m_xMtrDistance
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
void SetLineAttributes(const SfxItemSet &rItemSet)
void SetDisplayDirectory(const OUString &rPath)
std::unique_ptr< weld::Button > m_xBtnLoad
void SetDistance(sal_uInt32 nNewDistance)
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
std::unique_ptr< weld::ComboBox > m_xLbType2
void SelectTypeHdl_Impl(const weld::ComboBox *)
OUString SvxResId(const char *pId)
std::unique_ptr< weld::ComboBox > m_xLbType1
void SetExchangeSupport()
void SetExtension(OUString const &rTheExtension)
sal_uInt16 GetDots() const
css::drawing::DashStyle GetDashStyle() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< SvxLineLB > m_xLbLineStyles
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
bool Append(OUString const &rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SfxItemSet & rOutAttrs
virtual void Reset(const SfxItemSet *) override
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
void SetDashStyle(css::drawing::DashStyle eNewStyle)
virtual bool FillItemSet(SfxItemSet *) override
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
const XDash & GetDashValue() const
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
SfxItemPool * GetPool() const
OUString CuiResId(const char *pKey)
SvxXLinePreview m_aCtlPreview
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual ~SvxLineDefTabPage() override
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetDashes(sal_uInt16 nNewDashes)
std::unique_ptr< weld::MetricSpinButton > m_xMtrLength1
weld::Window * GetFrameWeld() const
std::unique_ptr< weld::Button > m_xBtnAdd
sal_uInt32 GetDotLen() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
XLineAttrSetItem aXLineAttr
INetProtocol GetProtocol() const
IMPL_LINK(SvxLineDefTabPage, SelectLinestyleListBoxHdl_Impl, weld::ComboBox &, rListBox, void)
std::unique_ptr< weld::MetricSpinButton > m_xMtrLength2
std::unique_ptr< weld::Button > m_xBtnSave
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
static XDashListRef AsDashList(rtl::Reference< XPropertyList > const &plist)
void SelectLinestyleHdl_Impl(const weld::ComboBox *)
OUString const & GetName() const
std::unique_ptr< weld::Button > m_xBtnDelete
sal_uInt32 GetDashLen() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
std::unique_ptr< weld::CheckButton > m_xCbxSynchronize
sal_uInt16 GetDashes() const
std::unique_ptr< weld::SpinButton > m_xNumFldNumber1