25#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
47#include <svx/strings.hrc>
48#include <osl/diagnose.h>
53 :
SfxTabPage(pPage, pController,
"cui/ui/lineendstabpage.ui",
"LineEndPage", &rInAttrs)
56 , aXLineAttr(rInAttrs.GetPool())
58 , pnLineEndListState(nullptr)
61 , pPosLineEndLb(nullptr)
62 , m_xEdtName(m_xBuilder->weld_entry(
"EDT_NAME"))
63 , m_xLbLineEnds(new
SvxLineEndLB(m_xBuilder->weld_combo_box(
"LB_LINEENDS")))
64 , m_xBtnAdd(m_xBuilder->weld_button(
"BTN_ADD"))
65 , m_xBtnModify(m_xBuilder->weld_button(
"BTN_MODIFY"))
66 , m_xBtnDelete(m_xBuilder->weld_button(
"BTN_DELETE"))
67 , m_xBtnLoad(m_xBuilder->weld_button(
"BTN_LOAD"))
68 , m_xBtnSave(m_xBuilder->weld_button(
"BTN_SAVE"))
69 , m_xCtlPreview(new
weld::CustomWeld(*m_xBuilder,
"CTL_PREVIEW", m_aCtlPreview))
102 bool bCreateArrowPossible =
true;
106 bCreateArrowPossible =
false;
116 bCreateArrowPossible =
nullptr !=
dynamic_cast<const SdrPathObj*
>( pNewObj.get());
119 if( !bCreateArrowPossible )
140 DBG_ASSERT(
aURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL" );
153 return DeactivateRC::LeavePage;
168 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskChangeLineEndDialog"));
169 if (xQueryBox->run() ==
RET_YES)
236 return std::make_unique<SvxLineEndDefTabPage>(pPage, pController, *
rSet );
264 SelectLineEndHdl_Impl();
269 int nPos = m_xLbLineEnds->get_active();
273 OUString aDesc(
CuiResId(RID_CUISTR_DESC_LINEEND));
274 OUString
aName(m_xEdtName->get_text());
276 bool bDifferent =
true;
280 if (
aName == pLineEndList->GetLineEnd(
i )->GetName() )
287 std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
294 while( !bDifferent && bLoop && pDlg->Execute() ==
RET_OK )
296 pDlg->GetName(
aName );
301 if(
aName == pLineEndList->GetLineEnd(
i )->GetName() )
321 pLineEndList->Replace(std::make_unique<XLineEndEntry>(pOldEntry->
GetLineEnd(),
aName),
nPos);
323 m_xEdtName->set_text(
aName);
325 m_xLbLineEnds->Modify(*pLineEndList->GetLineEnd(
nPos),
nPos, pLineEndList->GetUiBitmap(
nPos));
326 m_xLbLineEnds->set_active(
nPos);
329 *pnLineEndListState |= ChangeType::MODIFIED;
335 OSL_ENSURE(
false,
"LineEnd to be modified not existing (!)");
346 if(
nullptr !=
dynamic_cast<const SdrPathObj*
>( pPolyObj) )
353 pPolyObj->TakeObjInfo( aInfoRec );
357 pConvPolyObj = pPolyObj->ConvertToPolyObj(
true,
false );
358 pNewObj = pConvPolyObj.get();
360 if( !pNewObj ||
nullptr ==
dynamic_cast<const SdrPathObj*
>( pNewObj) )
373 pConvPolyObj.clear();
375 OUString aNewName(
SvxResId(RID_SVXSTR_LINEEND));
376 OUString aDesc(
CuiResId(RID_CUISTR_DESC_LINEEND));
381 bool bDifferent =
false;
383 while ( !bDifferent )
385 aName = aNewName +
" " + OUString::number( j++ );
389 if (
aName == pLineEndList->GetLineEnd(
i )->GetName() )
397 while ( bLoop && pDlg->Execute() ==
RET_OK )
399 pDlg->GetName(
aName );
404 if(
aName == pLineEndList->GetLineEnd(
i )->GetName() )
412 auto nLineEndCount = pLineEndList->Count();
413 pLineEndList->Insert(std::make_unique<XLineEndEntry>(aNewPolyPolygon,
aName), nLineEndCount);
416 m_xLbLineEnds->Append(*pLineEndList->GetLineEnd(nLineEndCount), pLineEndList->GetUiBitmap(nLineEndCount));
417 m_xLbLineEnds->set_active(m_xLbLineEnds->get_count() - 1);
419 *pnLineEndListState |= ChangeType::MODIFIED;
421 SelectLineEndHdl_Impl();
426 std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
432 m_xBtnAdd->set_sensitive(
false);
435 if ( pLineEndList->Count() )
437 m_xBtnModify->set_sensitive(
true);
438 m_xBtnDelete->set_sensitive(
true);
439 m_xBtnSave->set_sensitive(
true);
445 int nPos = m_xLbLineEnds->get_active();
450 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelLineEndDialog"));
452 if (xQueryBox->run() ==
RET_YES)
454 pLineEndList->Remove(
nPos);
455 m_xLbLineEnds->remove(
nPos);
456 m_xLbLineEnds->set_active(0);
458 SelectLineEndHdl_Impl();
461 *pnLineEndListState |= ChangeType::MODIFIED;
463 m_aCtlPreview.Invalidate();
467 if( !pLineEndList->Count() )
469 m_xBtnModify->set_sensitive(
false);
470 m_xBtnDelete->set_sensitive(
false);
471 m_xBtnSave->set_sensitive(
false);
479 if ( *pnLineEndListState & ChangeType::MODIFIED )
482 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"AskSaveList"));
484 nReturn = xBox->run();
487 pLineEndList->Save();
494 OUString aStrFilterType(
"*.soe" );
495 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
502 aLastDir = aPalettePath.getToken(0,
';',
nIndex);
519 XPropertyListType::LineEnd,
521 pLeList->SetName(
aURL.getName() );
522 if( pLeList->Load() )
524 pLineEndList = pLeList;
525 static_cast<SvxLineTabDialog*
>(GetDialogController())->SetNewLineEndList( pLineEndList );
526 m_xLbLineEnds->clear();
527 m_xLbLineEnds->Fill( pLineEndList );
530 pLineEndList->SetName(
aURL.getName() );
532 *pnLineEndListState |= ChangeType::CHANGED;
538 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoLoadedFileDialog"));
545 if ( pLineEndList->Count() )
547 m_xBtnModify->set_sensitive(
true);
548 m_xBtnDelete->set_sensitive(
true);
549 m_xBtnSave->set_sensitive(
true);
553 m_xBtnModify->set_sensitive(
false);
554 m_xBtnDelete->set_sensitive(
false);
555 m_xBtnSave->set_sensitive(
false);
562 OUString aStrFilterType(
"*.soe" );
563 aDlg.
AddFilter( aStrFilterType, aStrFilterType );
570 aLastDir = aPalettePath.getToken(0,
';',
nIndex);
577 if( !pLineEndList->GetName().isEmpty() )
579 aFile.
Append( pLineEndList->GetName() );
595 pLineEndList->SetName(
aURL.getName() );
598 if( pLineEndList->Save() )
605 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoSaveFileDialog"));
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
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)
rtl::Reference< SdrObject > ConvertToPolyObj(bool bBezier, bool bLineToArea) const
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetExchangeSupport()
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
virtual ~SvxLineEndDefTabPage() override
std::unique_ptr< weld::Entry > m_xEdtName
XLineAttrSetItem aXLineAttr
std::unique_ptr< weld::Button > m_xBtnAdd
SvxLineEndDefTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
std::unique_ptr< SvxLineEndLB > m_xLbLineEnds
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
XLineEndListRef pLineEndList
void SelectLineEndHdl_Impl()
std::unique_ptr< weld::Button > m_xBtnLoad
std::unique_ptr< weld::Button > m_xBtnModify
SvxXLinePreview m_aCtlPreview
sal_Int32 * pPosLineEndLb
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
const SdrObject * pPolyObj
virtual void ActivatePage(const SfxItemSet &rSet) override
std::unique_ptr< weld::Button > m_xBtnSave
virtual bool FillItemSet(SfxItemSet *) override
std::unique_ptr< weld::Button > m_xBtnDelete
virtual void Reset(const SfxItemSet *) override
Size GetOutputSize() const
void SetLineAttributes(const SfxItemSet &rItemSet)
const basegfx::B2DPolyPolygon & GetLineEnd() const
const OUString & GetName() const
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
static XLineEndListRef AsLineEndList(rtl::Reference< XPropertyList > const &plist)
void transform(const basegfx::B2DHomMatrix &rMatrix)
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)
#define LINK(Instance, Class, Member)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DRange getRange(const B2DPolygon &rCandidate)
IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox &, void)