25 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
27 #include <strings.hrc>
47 #include <svx/strings.hrc>
48 #include <osl/diagnose.h>
50 #define XOUT_WIDTH 150
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;
108 else if(
nullptr == dynamic_cast<const SdrPathObj*>(
pPolyObj) )
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.reset();
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);
514 aPathURL.removeSegment();
515 aPathURL.removeFinalSlash();
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() );
592 aPathURL.removeSegment();
593 aPathURL.removeFinalSlash();
595 pLineEndList->SetName(
aURL.getName() );
598 if( pLineEndList->Save() )
605 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoSaveFileDialog"));
#define LINK(Instance, Class, Member)
std::unique_ptr< weld::Entry > m_xEdtName
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const
std::unique_ptr< weld::Button > m_xBtnDelete
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
virtual void Reset(const SfxItemSet *) override
const SdrObject * pPolyObj
static XLineEndListRef AsLineEndList(rtl::Reference< XPropertyList > const &plist)
Size GetOutputSize() const
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::Button > m_xBtnLoad
void SetLineAttributes(const SfxItemSet &rItemSet)
void SetDisplayDirectory(const OUString &rPath)
virtual bool FillItemSet(SfxItemSet *) override
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
XLineEndListRef pLineEndList
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
void SetExchangeSupport()
OUString SvxResId(TranslateId aId)
SvxLineEndDefTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
void SelectLineEndHdl_Impl()
const OUString & GetName() const
OUString CuiResId(TranslateId aKey)
std::unique_ptr< weld::Button > m_xBtnAdd
#define DBG_ASSERT(sCon, aError)
virtual ~SvxLineEndDefTabPage() override
void transform(const basegfx::B2DHomMatrix &rMatrix)
IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox &, void)
SvxXLinePreview m_aCtlPreview
std::unique_ptr< weld::Button > m_xBtnSave
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
B2DRange getRange(const B2DPolygon &rCandidate)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const basegfx::B2DPolyPolygon & GetLineEnd() const
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SdrObjectUniquePtr ConvertToPolyObj(bool bBezier, bool bLineToArea) const
weld::Window * GetFrameWeld() const
std::unique_ptr< weld::Button > m_xBtnModify
constexpr tools::Long Height() const
INetProtocol GetProtocol() const
XLineAttrSetItem aXLineAttr
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
virtual void ActivatePage(const SfxItemSet &rSet) override
sal_Int32 * pPosLineEndLb
void SetExtension(std::u16string_view rTheExtension)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
std::unique_ptr< SvxLineEndLB > m_xLbLineEnds
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const