Handle cases where last-used palette disappeared

...so PaletteManager::SetPalette(LISTBOX_ENTRY_NOTFOUND) would set
PaletteManager::mnCurrentPalette to 65535, and
PaletteManager::GetSelectedPalettePath would do out-of-bounds access into
PaletteManage::m_Palettes.

That the last-used palette (as stored under in the configuration under
/org.openoffice.Office.Common/UserColors/PaletteName) may become more common
with pending changes like <https://gerrit.libreoffice.org/#/c/31199/>
"tdf#104047 Remove dispensable palettes".

Change-Id: I5641bae04f50fea8aa69027a75de08c22394c281
This commit is contained in:
Stephan Bergmann 2016-11-25 17:29:09 +01:00
parent 086631af59
commit 8b718e3774
2 changed files with 8 additions and 3 deletions

View File

@ -220,7 +220,10 @@ void SvxColorTabPage::FillPaletteLB()
}
OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
m_pSelectPalette->SelectEntry(aPaletteName);
SelectPaletteLBHdl( *m_pSelectPalette );
if (m_pSelectPalette->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
{
SelectPaletteLBHdl( *m_pSelectPalette );
}
}
void SvxColorTabPage::Construct()
@ -228,7 +231,6 @@ void SvxColorTabPage::Construct()
if (pColorList.is())
{
FillPaletteLB();
SelectPaletteLBHdl( *m_pSelectPalette );
ImpColorCountChanged();
}
}

View File

@ -1356,7 +1356,10 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand,
}
OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
mpPaletteListBox->SelectEntry( aPaletteName );
SelectPaletteHdl( *mpPaletteListBox );
if (mpPaletteListBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
{
SelectPaletteHdl( *mpPaletteListBox );
}
mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) );
mpButtonNoneColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) );