diff options
Diffstat (limited to 'basctl/source/basicide/macrodlg.cxx')
-rw-r--r-- | basctl/source/basicide/macrodlg.cxx | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx index 24cb210ea7e3..6b4afb79f772 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -31,7 +31,7 @@ #include <basic/sbmeth.hxx> #include <basic/sbmod.hxx> #include <com/sun/star/script/XLibraryContainer2.hpp> - +#include <sal/log.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/frame.hxx> @@ -122,7 +122,8 @@ MacroChooser::~MacroChooser() void MacroChooser::StoreMacroDescription() { - m_xBasicBox->get_selected(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_selected(m_xBasicBoxIter.get())) + return; EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); OUString aMethodName; if (m_xMacroBox->get_selected(m_xMacroBoxIter.get())) @@ -141,6 +142,9 @@ void MacroChooser::StoreMacroDescription() void MacroChooser::RestoreMacroDescription() { + // The following call is a workaround to ensure the last used macro is scrolled to in kf5 + m_xDialog->resize_to_request(); + EntryDescriptor aDesc; if (Shell* pShell = GetShell()) { @@ -291,7 +295,11 @@ void MacroChooser::DeleteMacro() SbMethod* MacroChooser::CreateMacro() { SbMethod* pMethod = nullptr; - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return nullptr; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" ); @@ -470,8 +478,9 @@ IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void) IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); - SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get()); + SbModule* pModule = nullptr; + if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get())) + pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get()); m_xMacroBox->clear(); if (pModule) { @@ -479,10 +488,10 @@ IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void) m_xMacroBox->freeze(); - sal_uInt32 nMacroCount = pModule->GetMethods()->Count32(); + sal_uInt32 nMacroCount = pModule->GetMethods()->Count(); for ( sal_uInt32 iMeth = 0; iMeth < nMacroCount; iMeth++ ) { - SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Get32( iMeth )); + SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Get(iMeth)); assert(pMethod && "Method not found!"); if (pMethod->IsHidden()) continue; @@ -610,7 +619,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) } else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get()) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" ); @@ -693,7 +706,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) } else if (&rButton == m_xAssignButton.get()) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" ); @@ -714,20 +731,28 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void) if (m_xDocumentFrame.is()) aInternalSet.Put(SfxUnoFrameItem(SID_FILLFRAME, m_xDocumentFrame)); - SfxRequest aRequest(SID_CONFIG, SfxCallMode::SYNCHRON, Args, aInternalSet); + SfxRequest aRequest(SID_CONFIGACCEL, SfxCallMode::SYNCHRON, Args, aInternalSet); aRequest.AppendItem( aItem ); SfxGetpApp()->ExecuteSlot( aRequest ); } else if (&rButton == m_xNewLibButton.get()) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); createLibImpl(m_xDialog.get(), aDocument, nullptr, m_xBasicBox.get()); } else if (&rButton == m_xNewModButton.get()) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); const OUString& aLibName( aDesc.GetLibName() ); @@ -738,7 +763,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 { @@ -766,7 +791,7 @@ IMPL_LINK(MacroChooser, ContextMenuHdl, const CommandEvent&, rCEvt, bool) xDropMenu->set_active("alphabetically", m_xMacroBox->get_sort_order()); xDropMenu->set_active("properorder", !m_xMacroBox->get_sort_order()); - OString sCommand(xPopup->popup_at_rect(m_xMacroBox.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); + OUString sCommand(xPopup->popup_at_rect(m_xMacroBox.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); if (sCommand == "alphabetically") { m_xMacroBox->make_sorted(); |