Skip to content

Commit

Permalink
no point in using a map anymore
Browse files Browse the repository at this point in the history
seeing as we want alphabetical sort now, there's no point in
calling GetLineRange and using a map

and only need to set the widget as sorted in the ctor, it remains
always sorted

Change-Id: Ieb5e5c8d9e36375a723376b0009062d6313c8779
Reviewed-on: https://gerrit.libreoffice.org/76810
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
  • Loading branch information
Caolán McNamara committed Aug 1, 2019
1 parent 68bab1d commit aee3aa2
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions basctl/source/basicide/macrodlg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@
#include <vcl/weld.hxx>
#include <osl/diagnose.h>

#include <map>

namespace basctl
{

using std::map;

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;

Expand Down Expand Up @@ -79,6 +75,8 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< frame::XFrame
{
m_xBasicBox->set_size_request(m_xBasicBox->get_approximate_digit_width() * 30, m_xBasicBox->get_height_rows(18));
m_xMacroBox->set_size_request(m_xMacroBox->get_approximate_digit_width() * 30, m_xMacroBox->get_height_rows(18));
// tdf#70813 The macros should be listed alphabetically
m_xMacroBox->make_sorted();

m_aMacrosInTxtBaseStr = m_xMacrosInTxt->get_label();

Expand Down Expand Up @@ -474,27 +472,19 @@ IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void)
{
m_xMacrosInTxt->set_label(m_aMacrosInTxtBaseStr + " " + pModule->GetName());

// The macros should be called in the same order that they
// are written down in the module.
m_xMacroBox->freeze();

map< sal_uInt16, SbMethod* > aMacros;
size_t nMacroCount = pModule->GetMethods()->Count();
for ( size_t iMeth = 0; iMeth < nMacroCount; iMeth++ )
{
SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Get( iMeth ));
if( pMethod->IsHidden() )
assert(pMethod && "Method not found!");
if (pMethod->IsHidden())
continue;
DBG_ASSERT( pMethod, "Method not found! (NULL)" );
sal_uInt16 nStart, nEnd;
pMethod->GetLineRange( nStart, nEnd );
aMacros.emplace( nStart, pMethod );
m_xMacroBox->append_text(pMethod->GetName());
}

m_xMacroBox->freeze();
for (auto const& macro : aMacros)
m_xMacroBox->append_text(macro.second->GetName());
m_xMacroBox->thaw();
m_xMacroBox->make_sorted();

if (m_xMacroBox->get_iter_first(*m_xMacroBoxIter))
m_xMacroBox->set_cursor(*m_xMacroBoxIter);
Expand Down

0 comments on commit aee3aa2

Please sign in to comment.