diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-09 17:12:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-12 16:00:04 +0000 |
commit | 6691816fe86ef7d193fee3632c2d56debfff3fa9 (patch) | |
tree | 749eae1a7e4f25ee1c22cf8367bbcdd6118a3da4 /basctl | |
parent | 4ea9061d54ee6d2c1ce2460162a1ea5f32de1ae7 (diff) |
tdf#152266 add an infobar with indicators for macro-like content in doc
Show "macros" and "events" for now if we know that are present so
they can be investigated by the user. There are other things which
could potentially be added in the future.
Change-Id: I981ee7a8e22791cd15405894f30fee659ba0b7ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143897
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 4 | ||||
-rw-r--r-- | basctl/source/basicide/basobj2.cxx | 9 | ||||
-rw-r--r-- | basctl/source/basicide/macrodlg.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 21 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.hxx | 6 | ||||
-rw-r--r-- | basctl/source/inc/basobj.hxx | 3 |
6 files changed, 34 insertions, 11 deletions
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index fd0fb7acccff..430b795e162d 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -340,10 +340,10 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) if ( rReq.GetArgs() ) { const SfxUInt16Item &rTabId = rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID ); - Organize(rReq.GetFrameWeld(), rTabId.GetValue()); + Organize(rReq.GetFrameWeld(), nullptr, rTabId.GetValue()); } else - Organize(rReq.GetFrameWeld(), 0); + Organize(rReq.GetFrameWeld(), nullptr, 0); } break; case SID_BASICIDE_CHOOSEMACRO: diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index d145d14fb634..708b1ce035d2 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -62,18 +62,19 @@ extern "C" { return pScriptURL; } - SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer(void *pParent, sal_Int16 nTabId) + SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer(void *pParent, void* pDocFrame_AsXFrame, sal_Int16 nTabId) { SAL_INFO("basctl.basicide","in basicide_macro_organizer"); - basctl::Organize(static_cast<weld::Window*>(pParent), nTabId); + Reference< frame::XFrame > aDocFrame( static_cast< frame::XFrame* >( pDocFrame_AsXFrame ) ); + basctl::Organize(static_cast<weld::Window*>(pParent), aDocFrame, nTabId); } } -void Organize(weld::Window* pParent, sal_Int16 tabId) +void Organize(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId) { EnsureIde(); - auto xDlg(std::make_shared<OrganizeDialog>(pParent, tabId)); + auto xDlg(std::make_shared<OrganizeDialog>(pParent, xDocFrame, tabId)); weld::DialogController::runAsync(xDlg, [](int) {}); } diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index db424becb2e9..b1097b9ad8c8 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -742,7 +742,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) StoreMacroDescription(); m_xBasicBox->get_selected(m_xBasicBoxIter.get()); - auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), 0)); + auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), nullptr, 0)); weld::DialogController::runAsync(xDlg, [this](sal_Int32 nRet) { if (nRet == RET_OK) // not only closed { diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 25250526d285..617d80e7f033 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -31,6 +31,7 @@ #include <basic/basmgr.hxx> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/script/XLibraryContainer2.hpp> +#include <com/sun/star/frame/XController.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> @@ -182,8 +183,24 @@ void Shell::CopyDialogResources( io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); } +void OrganizeDialog::SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame) +{ + if (!xDocFrame) + return; + Reference<css::frame::XController> xController(xDocFrame->getController()); + if (!xController) + return; + Reference<css::frame::XModel> xModel(xController->getModel()); + if (!xModel) + return; + ScriptDocument aScriptDocument(xModel); + EntryDescriptor aDesc(aScriptDocument, LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), OBJ_TYPE_DOCUMENT); + m_xModulePage->SetCurrentEntry(aDesc); + m_xDialogPage->SetCurrentEntry(aDesc); +} + // OrganizeDialog -OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId ) +OrganizeDialog::OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId) : GenericDialogController(pParent, "modules/BasicIDE/ui/organizedialog.ui", "OrganizeDialog") , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol")) , m_xModulePage(new ObjectPage(m_xTabCtrl->get_page("modules"), "ModulePage", BrowseMode::Modules, this)) @@ -192,6 +209,8 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId ) { m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, ActivatePageHdl)); + SetCurrentEntry(xDocFrame); + OString sPage; if (tabId == 0) sPage = "modules"; diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index 7dadebcc9ebb..37e8567b5e6c 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -150,6 +150,8 @@ public: ObjectPage(weld::Container* pParent, const OString& rName, BrowseMode nMode, OrganizeDialog* pDialog); virtual ~ObjectPage() override; + void SetCurrentEntry(const EntryDescriptor& rDesc) { m_xBasicBox->SetCurrentEntry(rDesc); } + virtual void ActivatePage() override; }; @@ -206,8 +208,10 @@ private: DECL_LINK(ActivatePageHdl, const OString&, void); + void SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame); + public: - OrganizeDialog(weld::Window* pParent, sal_Int16 tabId); + OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId); virtual ~OrganizeDialog() override; }; diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx index 90cb82c13b61..70c603d4548a 100644 --- a/basctl/source/inc/basobj.hxx +++ b/basctl/source/inc/basobj.hxx @@ -32,8 +32,7 @@ namespace weld { class Widget; class Window; } namespace basctl { - void Organize(weld::Window* pParent, sal_Int16 tabId); - + void Organize(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId); // help methods for the general use: SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ); |