24#include <bitmaps.hlst>
32#include <svx/svxids.hrc>
45 , bIDEDialogMode(false)
48 if ( SfxItemState::SET == rAttrSet.
GetItemState( SID_ATTR_MACROITEM,
false, &pItem ) )
53 : m_xTreeView(
std::move(xTreeView))
65 int nEvent =
mpImpl->xEventLB->get_selected_index();
67 const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
68 mpImpl->xDeletePB->set_sensitive(!
mpImpl->bReadOnly && bAssigned);
70 if (
mpImpl->xAssignComponentPB)
71 mpImpl->xAssignComponentPB->set_sensitive( !
mpImpl->bReadOnly );
75 const OUString& rID,
const SfxItemSet& rAttrSet)
76 :
SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rAttrSet)
77 , m_nAssignedEvents(0)
95 aDisplayNames.emplace_back(
"OnStartApp", RID_CUISTR_EVENT_STARTAPP );
96 aDisplayNames.emplace_back(
"OnCloseApp", RID_CUISTR_EVENT_CLOSEAPP );
97 aDisplayNames.emplace_back(
"OnCreate", RID_CUISTR_EVENT_CREATEDOC );
98 aDisplayNames.emplace_back(
"OnNew", RID_CUISTR_EVENT_NEWDOC );
99 aDisplayNames.emplace_back(
"OnLoadFinished", RID_CUISTR_EVENT_LOADDOCFINISHED );
100 aDisplayNames.emplace_back(
"OnLoad", RID_CUISTR_EVENT_OPENDOC );
101 aDisplayNames.emplace_back(
"OnPrepareUnload", RID_CUISTR_EVENT_PREPARECLOSEDOC );
102 aDisplayNames.emplace_back(
"OnUnload", RID_CUISTR_EVENT_CLOSEDOC ) ;
103 aDisplayNames.emplace_back(
"OnViewCreated", RID_CUISTR_EVENT_VIEWCREATED );
104 aDisplayNames.emplace_back(
"OnPrepareViewClosing", RID_CUISTR_EVENT_PREPARECLOSEVIEW );
105 aDisplayNames.emplace_back(
"OnViewClosed", RID_CUISTR_EVENT_CLOSEVIEW ) ;
106 aDisplayNames.emplace_back(
"OnFocus", RID_CUISTR_EVENT_ACTIVATEDOC );
107 aDisplayNames.emplace_back(
"OnUnfocus", RID_CUISTR_EVENT_DEACTIVATEDOC );
108 aDisplayNames.emplace_back(
"OnSave", RID_CUISTR_EVENT_SAVEDOC );
109 aDisplayNames.emplace_back(
"OnSaveDone", RID_CUISTR_EVENT_SAVEDOCDONE );
110 aDisplayNames.emplace_back(
"OnSaveFailed", RID_CUISTR_EVENT_SAVEDOCFAILED );
111 aDisplayNames.emplace_back(
"OnSaveAs", RID_CUISTR_EVENT_SAVEASDOC );
112 aDisplayNames.emplace_back(
"OnSaveAsDone", RID_CUISTR_EVENT_SAVEASDOCDONE );
113 aDisplayNames.emplace_back(
"OnSaveAsFailed", RID_CUISTR_EVENT_SAVEASDOCFAILED );
114 aDisplayNames.emplace_back(
"OnCopyTo", RID_CUISTR_EVENT_COPYTODOC );
115 aDisplayNames.emplace_back(
"OnCopyToDone", RID_CUISTR_EVENT_COPYTODOCDONE );
116 aDisplayNames.emplace_back(
"OnCopyToFailed", RID_CUISTR_EVENT_COPYTODOCFAILED );
117 aDisplayNames.emplace_back(
"OnPrint", RID_CUISTR_EVENT_PRINTDOC );
118 aDisplayNames.emplace_back(
"OnModifyChanged", RID_CUISTR_EVENT_MODIFYCHANGED );
119 aDisplayNames.emplace_back(
"OnTitleChanged", RID_CUISTR_EVENT_TITLECHANGED );
122 aDisplayNames.emplace_back(
"OnMailMerge", RID_CUISTR_EVENT_MAILMERGE );
123 aDisplayNames.emplace_back(
"OnMailMergeFinished", RID_CUISTR_EVENT_MAILMERGE_END );
124 aDisplayNames.emplace_back(
"OnFieldMerge", RID_CUISTR_EVENT_FIELDMERGE );
125 aDisplayNames.emplace_back(
"OnFieldMergeFinished", RID_CUISTR_EVENT_FIELDMERGE_FINISHED );
126 aDisplayNames.emplace_back(
"OnPageCountChange", RID_CUISTR_EVENT_PAGECOUNTCHANGE );
127 aDisplayNames.emplace_back(
"OnSubComponentOpened", RID_CUISTR_EVENT_SUBCOMPONENT_OPENED );
128 aDisplayNames.emplace_back(
"OnSubComponentClosed", RID_CUISTR_EVENT_SUBCOMPONENT_CLOSED );
129 aDisplayNames.emplace_back(
"OnSelect", RID_CUISTR_EVENT_SELECTIONCHANGED );
130 aDisplayNames.emplace_back(
"OnDoubleClick", RID_CUISTR_EVENT_DOUBLECLICK );
131 aDisplayNames.emplace_back(
"OnRightClick", RID_CUISTR_EVENT_RIGHTCLICK );
132 aDisplayNames.emplace_back(
"OnCalculate", RID_CUISTR_EVENT_CALCULATE );
133 aDisplayNames.emplace_back(
"OnChange", RID_CUISTR_EVENT_CONTENTCHANGED );
137 aDisplayNames.emplace_back(
"approveAction", RID_CUISTR_EVENT_APPROVEACTIONPERFORMED );
138 aDisplayNames.emplace_back(
"actionPerformed", RID_CUISTR_EVENT_ACTIONPERFORMED );
139 aDisplayNames.emplace_back(
"changed", RID_CUISTR_EVENT_CHANGED );
140 aDisplayNames.emplace_back(
"textChanged", RID_CUISTR_EVENT_TEXTCHANGED );
141 aDisplayNames.emplace_back(
"itemStateChanged", RID_CUISTR_EVENT_ITEMSTATECHANGED );
142 aDisplayNames.emplace_back(
"focusGained", RID_CUISTR_EVENT_FOCUSGAINED );
143 aDisplayNames.emplace_back(
"focusLost", RID_CUISTR_EVENT_FOCUSLOST );
144 aDisplayNames.emplace_back(
"keyPressed", RID_CUISTR_EVENT_KEYTYPED );
145 aDisplayNames.emplace_back(
"keyReleased", RID_CUISTR_EVENT_KEYUP );
146 aDisplayNames.emplace_back(
"mouseEntered", RID_CUISTR_EVENT_MOUSEENTERED );
147 aDisplayNames.emplace_back(
"mouseDragged", RID_CUISTR_EVENT_MOUSEDRAGGED );
148 aDisplayNames.emplace_back(
"mouseMoved", RID_CUISTR_EVENT_MOUSEMOVED );
149 aDisplayNames.emplace_back(
"mousePressed", RID_CUISTR_EVENT_MOUSEPRESSED );
150 aDisplayNames.emplace_back(
"mouseReleased", RID_CUISTR_EVENT_MOUSERELEASED );
151 aDisplayNames.emplace_back(
"mouseExited", RID_CUISTR_EVENT_MOUSEEXITED );
152 aDisplayNames.emplace_back(
"approveReset", RID_CUISTR_EVENT_APPROVERESETTED );
153 aDisplayNames.emplace_back(
"resetted", RID_CUISTR_EVENT_RESETTED );
154 aDisplayNames.emplace_back(
"approveSubmit", RID_CUISTR_EVENT_SUBMITTED );
155 aDisplayNames.emplace_back(
"approveUpdate", RID_CUISTR_EVENT_BEFOREUPDATE );
156 aDisplayNames.emplace_back(
"updated", RID_CUISTR_EVENT_AFTERUPDATE );
157 aDisplayNames.emplace_back(
"loaded", RID_CUISTR_EVENT_LOADED );
158 aDisplayNames.emplace_back(
"reloading", RID_CUISTR_EVENT_RELOADING );
159 aDisplayNames.emplace_back(
"reloaded", RID_CUISTR_EVENT_RELOADED );
160 aDisplayNames.emplace_back(
"unloading", RID_CUISTR_EVENT_UNLOADING );
161 aDisplayNames.emplace_back(
"unloaded", RID_CUISTR_EVENT_UNLOADED );
162 aDisplayNames.emplace_back(
"confirmDelete", RID_CUISTR_EVENT_CONFIRMDELETE );
163 aDisplayNames.emplace_back(
"approveRowChange", RID_CUISTR_EVENT_APPROVEROWCHANGE );
164 aDisplayNames.emplace_back(
"rowChanged", RID_CUISTR_EVENT_ROWCHANGE );
165 aDisplayNames.emplace_back(
"approveCursorMove", RID_CUISTR_EVENT_POSITIONING );
166 aDisplayNames.emplace_back(
"cursorMoved", RID_CUISTR_EVENT_POSITIONED );
167 aDisplayNames.emplace_back(
"approveParameter", RID_CUISTR_EVENT_APPROVEPARAMETER );
168 aDisplayNames.emplace_back(
"errorOccured", RID_CUISTR_EVENT_ERROROCCURRED );
169 aDisplayNames.emplace_back(
"adjustmentValueChanged", RID_CUISTR_EVENT_ADJUSTMENTVALUECHANGED );
183 eventName = appEvent.first;
198 eventName = docEvent.first;
240 appEvent.second.second.clear();
247 docEvent.second.second.clear();
275 std::u16string_view GetEventDisplayText(std::u16string_view rURL)
278 return std::u16string_view();
280 std::u16string_view aPureMethod;
287 aPureMethod = rURL.substr(strlen(
"vnd.sun.star.script:"));
288 aPureMethod = aPureMethod.substr( 0, aPureMethod.find(
'?' ) );
293 OUString GetEventDisplayImage(std::u16string_view rURL)
299 return bUNO ? OUString(RID_SVXBMP_COMPONENT) : OUString(RID_SVXBMP_MACRO);
308 mpImpl->xEventLB->freeze();
309 mpImpl->xEventLB->clear();
312 Reference< container::XNameReplace> nameReplace;
325 if(!nameReplace.is())
333 OUString sEventName( OUString::createFromAscii( displayableEvent.pAsciiEventName ) );
334 if ( !nameReplace->hasByName( sEventName ) )
337 EventsHash::iterator h_it = eventsHash->find( sEventName );
338 if( h_it == eventsHash->end() )
340 OSL_FAIL(
"SvxMacroTabPage_::DisplayAppEvents: something's suspicious here!" );
344 OUString eventURL = h_it->second.second;
345 OUString displayName(
CuiResId(displayableEvent.pEventResourceID));
347 int nRow =
mpImpl->xEventLB->n_children();
348 mpImpl->xEventLB->append(sEventName, displayName);
349 mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1);
350 mpImpl->xEventLB->set_text(nRow, OUString(GetEventDisplayText(eventURL)), 2);
352 if (!eventURL.isEmpty())
358 if (
mpImpl->xEventLB->n_children())
360 mpImpl->xEventLB->select(0);
361 mpImpl->xEventLB->scroll_to_row(0);
370 int nEntry = mpImpl->xEventLB->get_selected_index();
374 DBG_ASSERT(
false,
"Where does the empty entry come from?" );
383 GenericHandler_Impl(&rBtn);
388 GenericHandler_Impl(
nullptr);
399 pRet = &h_it->second;
405 pRet = &h_it->second;
417 DBG_ASSERT(
false,
"Where does the empty entry come from?");
421 const bool bAssEnabled = pBtn !=
mpImpl->xDeletePB.get() &&
mpImpl->xAssignPB->get_sensitive();
423 OUString sEventName = rListBox.
get_id(nEntry);
430 sEventURL = pEventPair->second;
433 if (!sEventURL.isEmpty())
436 bool bDoubleClick = (pBtn ==
nullptr);
438 if (pBtn ==
mpImpl->xDeletePB.get())
446 else if ( ( ( pBtn !=
nullptr )
447 && ( pBtn ==
mpImpl->xAssignComponentPB.get() )
456 short ret = aAssignDlg.
run();
460 sEventURL = aAssignDlg.
getURL();
465 else if( bAssEnabled )
469 short ret = aDlg.
run();
484 h_it->second.second = sEventURL;
490 h_it->second.second = sEventURL;
493 if (!sEventURL.isEmpty())
496 rListBox.
set_image(nEntry, GetEventDisplayImage(sEventURL), 1);
497 rListBox.
set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2);
508 OUString sEmptyString;
512 OUString sEventName = rListBox.
get_id(rEntry);
516 EventsHash::iterator h_it = m_appEventsHash.find(sEventName);
518 h_it->second.second = sEmptyString;
522 EventsHash::iterator h_it = m_docEventsHash.find(sEventName);
524 h_it->second.second = sEmptyString;
527 rListBox.
set_image(rEntry, sEmptyString, 1);
528 rListBox.
set_text(rEntry, sEmptyString, 2);
535 m_nAssignedEvents = 0;
542void SvxMacroTabPage_::InitAndSetHandler(
const Reference< container::XNameReplace>& xAppEvents,
const Reference< container::XNameReplace>& xDocEvents,
const Reference< util::XModifiable >& xModifiable )
548 mpImpl->xDeletePB->connect_clicked(aLnk);
549 mpImpl->xAssignPB->connect_clicked(aLnk);
551 if(
mpImpl->xAssignComponentPB )
552 mpImpl->xAssignComponentPB->connect_clicked( aLnk );
556 std::vector<int> aWidths
558 o3tl::narrowing<int>(
mpImpl->xEventLB->get_approximate_digit_width() * 32),
559 mpImpl->xEventLB->get_checkbox_column_width()
561 mpImpl->xEventLB->set_column_fixed_widths(aWidths);
564 mpImpl->xEventLB->set_sensitive(
true);
571 sal_Int32 nEventCount = eventNames.getLength();
572 for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent )
587 nEventCount = eventNames.getLength();
588 for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent )
603 const EventPair& rAssignedEvent(eventsHash[eventName]);
607 if ( !(rAssignedEvent.first.isEmpty() || rAssignedEvent.second.isEmpty()) )
609 aProps.
put(
"EventType", rAssignedEvent.first );
610 aProps.
put(
"Script", rAssignedEvent.second );
629 return std::make_pair(
type, url );
635 Reference< container::XNameReplace >
const & xNameReplace,
636 sal_uInt16 nSelectedIndex)
639 mpImpl->xEventLB = m_xBuilder->weld_tree_view(
"assignments");
640 mpImpl->xEventLB->set_size_request(
mpImpl->xEventLB->get_approximate_digit_width() * 70,
641 mpImpl->xEventLB->get_height_rows(9));
642 mpImpl->xAssignPB = m_xBuilder->weld_button(
"assign");
643 mpImpl->xDeletePB = m_xBuilder->weld_button(
"delete");
644 mpImpl->xDeleteAllPB = m_xBuilder->weld_button(
"deleteall");
645 mpImpl->xAssignComponentPB = m_xBuilder->weld_button(
"component");
649 if( !
mpImpl->bIDEDialogMode )
651 mpImpl->xAssignComponentPB->hide();
652 mpImpl->xAssignComponentPB->set_sensitive(
false);
657 InitAndSetHandler( xNameReplace, Reference< container::XNameReplace>(
nullptr), Reference< util::XModifiable >(
nullptr));
659 mpImpl->xEventLB->select(nSelectedIndex);
663 const Reference< container::XNameReplace >& xNameReplace, sal_uInt16 nSelectedIndex)
671 OUString aMethodName = mxMethodEdit->get_text();
673 if( !aMethodName.isEmpty() )
676 maURL += aMethodName;
682 : GenericDialogController(pParent,
"cui/ui/assigncomponentdialog.ui",
"AssignComponent")
684 , mxMethodEdit(m_xBuilder->weld_entry(
"methodEntry"))
685 , mxOKButton(m_xBuilder->weld_button(
"ok"))
689 OUString aMethodName;
704 m_xSfxPage->FillItemSet(
nullptr);
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::Entry > mxMethodEdit
const OUString & getURL() const
virtual ~AssignComponentDialog() override
std::unique_ptr< weld::Button > mxOKButton
AssignComponentDialog(weld::Window *pParent, OUString aURL)
MacroEventListBox(std::unique_ptr< weld::TreeView > xTreeView)
std::unique_ptr< weld::TreeView > m_xTreeView
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
virtual weld::Button & GetOKButton() const override
weld::Container * get_content_area()
css::uno::Reference< css::frame::XFrame > GetFrame() const
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
weld::Window * GetFrameWeld() const
SvxMacroAssignDlg(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_rxDocumentFrame, const SfxItemSet &rSet, const css::uno::Reference< css::container::XNameReplace > &xNameReplace, sal_uInt16 nSelectedIndex)
SvxMacroAssignSingleTabDialog(weld::Window *pParent, const SfxItemSet &rOptionsSet)
SvxMacroTabPage_Impl(const SfxItemSet &rAttrSet)
static EventPair GetPairFromAny(const css::uno::Any &aAny)
EventsHash m_docEventsHash
EventsHash m_appEventsHash
css::uno::Reference< css::container::XNameReplace > m_xDocEvents
css::uno::Reference< css::util::XModifiable > m_xModifiable
virtual void Reset(const SfxItemSet *) override
static css::uno::Any GetPropsByName(const OUString &eventName, EventsHash &eventsHash)
void InitAndSetHandler(const css::uno::Reference< css::container::XNameReplace > &xAppEvents, const css::uno::Reference< css::container::XNameReplace > &xDocEvents, const css::uno::Reference< css::util::XModifiable > &xModifiable)
css::uno::Reference< css::container::XNameReplace > m_xAppEvents
void GenericHandler_Impl(const weld::Button *pBtn)
std::vector< EventDisplayName > aDisplayNames
SvxMacroTabPage_(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OUString &rID, const SfxItemSet &rItemSet)
bool IsReadOnly() const override
void DisplayAppEvents(bool appEvents)
std::unique_ptr< SvxMacroTabPage_Impl > mpImpl
const EventPair * LookupEvent(const OUString &rEventName)
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual ~SvxMacroTabPage_() override
void SetReadOnly(bool bSet)
SvxMacroTabPage(weld::Container *pPage, weld::DialogController *pController, const css::uno::Reference< css::frame::XFrame > &_rxDocumentFrame, const SfxItemSet &rSet, css::uno::Reference< css::container::XNameReplace > const &xNameReplace, sal_uInt16 nSelectedIndex)
OUString GetScriptURL() const
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
virtual void scroll_to_row(int row)=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual void set_image(int row, const OUString &rImage, int col=-1)=0
virtual void select(int pos)=0
virtual int get_selected_index() const=0
virtual OUString get_id(int pos) const=0
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define DBG_UNHANDLED_EXCEPTION(...)
virtual tools::Long GetValue() const override
constexpr OUStringLiteral HID_MACRO_HEADERTABLISTBOX
#define LINK(Instance, Class, Member)
IMPL_LINK(SvxMacroTabPage_, AssignDeleteHdl_Impl, weld::Button &, rBtn, void)
constexpr OUStringLiteral aVndSunStarUNO
IMPL_LINK_NOARG(SvxMacroTabPage_, SelectEvent_Impl, weld::TreeView &, void)
std::pair< OUString, OUString > EventPair
std::unordered_map< OUString, EventPair > EventsHash
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
constexpr OUStringLiteral sEventType