summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-12-08 16:47:32 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-12-09 13:53:38 +0000
commite1de95f72b1e6467510f7c3b32b25d7528c93a75 (patch)
tree9eb087ef9d4a034ea6790099ddaf435c1fcad6b2 /cui
parent45449e2fd20b45f9e3e04538c77b9e245a4170d4 (diff)
Related: tdf#152266 add a remove all button
Change-Id: Ibf6b749089d2d6da71a9ce00779bce8886453856 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143833 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/customize/eventdlg.cxx1
-rw-r--r--cui/source/customize/macropg.cxx64
-rw-r--r--cui/source/customize/macropg_impl.hxx1
-rw-r--r--cui/source/inc/macropg.hxx2
-rw-r--r--cui/uiconfig/ui/eventsconfigpage.ui14
-rw-r--r--cui/uiconfig/ui/macroassignpage.ui14
6 files changed, 87 insertions, 9 deletions
diff --git a/cui/source/customize/eventdlg.cxx b/cui/source/customize/eventdlg.cxx
index 7aa67e3f5a81..755fd16b416a 100644
--- a/cui/source/customize/eventdlg.cxx
+++ b/cui/source/customize/eventdlg.cxx
@@ -44,6 +44,7 @@ SvxEventConfigPage::SvxEventConfigPage(weld::Container* pPage, weld::DialogContr
mpImpl->xEventLB = m_xBuilder->weld_tree_view("events");
mpImpl->xAssignPB = m_xBuilder->weld_button("macro");
mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+ mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width() * 70,
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index 34eb44849d84..3980c8b6c3f7 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -61,21 +61,20 @@ MacroEventListBox::MacroEventListBox(std::unique_ptr<weld::TreeView> xTreeView)
// and it is not read only
void SvxMacroTabPage_::EnableButtons()
{
+ mpImpl->xDeleteAllPB->set_sensitive(m_nAssignedEvents != 0);
int nEvent = mpImpl->xEventLB->get_selected_index();
- if (nEvent != -1)
- {
- const EventPair* pEventPair = LookupEvent(mpImpl->xEventLB->get_id(nEvent));
- const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
- mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned);
- mpImpl->xAssignPB->set_sensitive( !mpImpl->bReadOnly );
- if( mpImpl->xAssignComponentPB )
- mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
- }
+ const EventPair* pEventPair = nEvent == -1 ? nullptr : LookupEvent(mpImpl->xEventLB->get_id(nEvent));
+ const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
+ mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned);
+ mpImpl->xAssignPB->set_sensitive(!mpImpl->bReadOnly);
+ if (mpImpl->xAssignComponentPB)
+ mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
}
SvxMacroTabPage_::SvxMacroTabPage_(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription,
const OString& rID, const SfxItemSet& rAttrSet)
: SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rAttrSet)
+ , m_nAssignedEvents(0)
, bDocModified(false)
, bAppEvents(false)
, bInitialized(false)
@@ -308,6 +307,7 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
mpImpl->xEventLB->freeze();
mpImpl->xEventLB->clear();
+ m_nAssignedEvents = 0;
EventsHash* eventsHash;
Reference< container::XNameReplace> nameReplace;
if(bAppEvents)
@@ -348,6 +348,9 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
mpImpl->xEventLB->append(sEventName, displayName);
mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1);
mpImpl->xEventLB->set_text(nRow, OUString(GetEventDisplayText(eventURL)), 2);
+
+ if (!eventURL.isEmpty())
+ ++m_nAssignedEvents;
}
mpImpl->xEventLB->thaw();
@@ -427,6 +430,9 @@ void SvxMacroTabPage_::GenericHandler_Impl(const weld::Button* pBtn)
sEventURL = pEventPair->second;
}
+ if (!sEventURL.isEmpty())
+ --m_nAssignedEvents;
+
bool bDoubleClick = (pBtn == nullptr);
bool bUNOAssigned = sEventURL.startsWith( aVndSunStarUNO );
if (pBtn == mpImpl->xDeletePB.get())
@@ -484,6 +490,9 @@ void SvxMacroTabPage_::GenericHandler_Impl(const weld::Button* pBtn)
h_it->second.second = sEventURL;
}
+ if (!sEventURL.isEmpty())
+ ++m_nAssignedEvents;
+
rListBox.set_image(nEntry, GetEventDisplayImage(sEventURL), 1);
rListBox.set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2);
@@ -493,6 +502,41 @@ void SvxMacroTabPage_::GenericHandler_Impl(const weld::Button* pBtn)
EnableButtons();
}
+IMPL_LINK_NOARG(SvxMacroTabPage_, DeleteAllHdl_Impl, weld::Button&, void)
+{
+ OUString sEventType = "Script" ;
+ OUString sEmptyString;
+
+ mpImpl->xEventLB->all_foreach([this, &sEventType, &sEmptyString](weld::TreeIter& rEntry) {
+ weld::TreeView& rListBox = *mpImpl->xEventLB;
+ OUString sEventName = rListBox.get_id(rEntry);
+ // update the hashes
+ if (bAppEvents)
+ {
+ EventsHash::iterator h_it = m_appEventsHash.find(sEventName);
+ h_it->second.first = sEventType;
+ h_it->second.second = sEmptyString;
+ }
+ else
+ {
+ EventsHash::iterator h_it = m_docEventsHash.find(sEventName);
+ h_it->second.first = sEventType;
+ h_it->second.second = sEmptyString;
+ }
+
+ rListBox.set_image(rEntry, sEmptyString, 1);
+ rListBox.set_text(rEntry, sEmptyString, 2);
+ return false;
+ });
+
+ if (!bAppEvents)
+ bDocModified = true;
+
+ m_nAssignedEvents = 0;
+
+ EnableButtons();
+}
+
// pass in the XNameReplace.
// can remove the 3rd arg once issue ?? is fixed
void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameReplace>& xAppEvents, const Reference< container::XNameReplace>& xDocEvents, const Reference< util::XModifiable >& xModifiable )
@@ -503,6 +547,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla
Link<weld::Button&,void> aLnk(LINK(this, SvxMacroTabPage_, AssignDeleteHdl_Impl ));
mpImpl->xDeletePB->connect_clicked(aLnk);
mpImpl->xAssignPB->connect_clicked(aLnk);
+ mpImpl->xDeleteAllPB->connect_clicked(LINK(this, SvxMacroTabPage_, DeleteAllHdl_Impl));
if( mpImpl->xAssignComponentPB )
mpImpl->xAssignComponentPB->connect_clicked( aLnk );
mpImpl->xEventLB->connect_row_activated( LINK(this, SvxMacroTabPage_, DoubleClickHdl_Impl ) );
@@ -596,6 +641,7 @@ SvxMacroTabPage::SvxMacroTabPage(weld::Container* pPage, weld::DialogController*
mpImpl->xEventLB->get_height_rows(9));
mpImpl->xAssignPB = m_xBuilder->weld_button("assign");
mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+ mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
SetFrame( _rxDocumentFrame );
diff --git a/cui/source/customize/macropg_impl.hxx b/cui/source/customize/macropg_impl.hxx
index 63d2f2ae28e6..1073e4bb36ff 100644
--- a/cui/source/customize/macropg_impl.hxx
+++ b/cui/source/customize/macropg_impl.hxx
@@ -30,6 +30,7 @@ public:
std::unique_ptr<weld::Button> xAssignPB;
std::unique_ptr<weld::Button> xAssignComponentPB;
std::unique_ptr<weld::Button> xDeletePB;
+ std::unique_ptr<weld::Button> xDeleteAllPB;
std::unique_ptr<weld::TreeView> xEventLB;
bool bReadOnly;
bool bIDEDialogMode;
diff --git a/cui/source/inc/macropg.hxx b/cui/source/inc/macropg.hxx
index 7c934e33799d..cecdf3b55224 100644
--- a/cui/source/inc/macropg.hxx
+++ b/cui/source/inc/macropg.hxx
@@ -55,6 +55,7 @@ class SvxMacroTabPage_ : public SfxTabPage
DECL_LINK( SelectEvent_Impl, weld::TreeView&, void );
DECL_LINK( AssignDeleteHdl_Impl, weld::Button&, void );
DECL_LINK( DoubleClickHdl_Impl, weld::TreeView&, bool );
+ DECL_LINK( DeleteAllHdl_Impl, weld::Button&, void );
void GenericHandler_Impl(const weld::Button* pBtn);
const EventPair* LookupEvent(const OUString& rEventName);
@@ -66,6 +67,7 @@ protected:
css::uno::Reference< css::util::XModifiable > m_xModifiable;
EventsHash m_appEventsHash;
EventsHash m_docEventsHash;
+ int m_nAssignedEvents;
bool bDocModified, bAppEvents, bInitialized;
std::vector< EventDisplayName > aDisplayNames;
diff --git a/cui/uiconfig/ui/eventsconfigpage.ui b/cui/uiconfig/ui/eventsconfigpage.ui
index c7f52321d43c..acdf91c4df48 100644
--- a/cui/uiconfig/ui/eventsconfigpage.ui
+++ b/cui/uiconfig/ui/eventsconfigpage.ui
@@ -95,6 +95,20 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="deleteall">
+ <property name="label" translatable="yes" context="eventsconfigpage|deleteall">Remove _All</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/cui/uiconfig/ui/macroassignpage.ui b/cui/uiconfig/ui/macroassignpage.ui
index 4503f24c2380..24395c840c6c 100644
--- a/cui/uiconfig/ui/macroassignpage.ui
+++ b/cui/uiconfig/ui/macroassignpage.ui
@@ -181,6 +181,20 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="deleteall">
+ <property name="label" translatable="yes" context="macroassignpage|deleteall">Remove _All</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
</child>
<child type="label">