tdf#133146 - Enable delete shortcut to remove items
Change-Id: I8d0f223f27a3de299f917467064629c205e79c57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181779 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
@@ -498,6 +498,24 @@ public:
|
||||
|
||||
class SvxBitmapTabPage : public SfxTabPage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
class SvxPresetListBoxValueSet : public SvxPresetListBox
|
||||
{
|
||||
public:
|
||||
SvxPresetListBoxValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow);
|
||||
virtual bool KeyInput(const KeyEvent& rKEvt) override;
|
||||
|
||||
void SetDialog(SvxBitmapTabPage* pSvxBitmapTabPage)
|
||||
{
|
||||
m_pSvxBitmapTabPage = pSvxBitmapTabPage;
|
||||
}
|
||||
|
||||
private:
|
||||
SvxBitmapTabPage* m_pSvxBitmapTabPage;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
const SfxItemSet& m_rOutAttrs;
|
||||
@@ -519,7 +537,7 @@ private:
|
||||
Size rZoomedSize;
|
||||
|
||||
SvxXRectPreview m_aCtlBitmapPreview;
|
||||
std::unique_ptr<SvxPresetListBox> m_xBitmapLB;
|
||||
std::unique_ptr<SvxPresetListBoxValueSet> m_xBitmapLB;
|
||||
std::unique_ptr<weld::ComboBox> m_xBitmapStyleLB;
|
||||
std::unique_ptr<weld::Container> m_xSizeBox;
|
||||
std::unique_ptr<weld::CheckButton> m_xTsbScale;
|
||||
@@ -549,6 +567,7 @@ private:
|
||||
DECL_LINK( ClickImportHdl, weld::Button&, void );
|
||||
void ClickBitmapHdl_Impl();
|
||||
void CalculateBitmapPresetSize();
|
||||
void DeleteBitmapHdl_Impl(const sal_uInt16 nId);
|
||||
sal_Int32 SearchBitmapList(std::u16string_view rBitmapName);
|
||||
sal_Int32 SearchBitmapList(const GraphicObject& rGraphicObject);
|
||||
tools::Long AddBitmap(const GraphicObject& rGraphicObject, const OUString& rName,
|
||||
|
@@ -80,7 +80,7 @@ SvxBitmapTabPage::SvxBitmapTabPage(weld::Container* pPage, weld::DialogControlle
|
||||
, m_aXFillAttr(rInAttrs.GetPool())
|
||||
, m_rXFSet(m_aXFillAttr.GetItemSet())
|
||||
, mpView(nullptr)
|
||||
, m_xBitmapLB(new SvxPresetListBox(m_xBuilder->weld_scrolled_window(u"imagewin"_ustr, true)))
|
||||
, m_xBitmapLB(new SvxPresetListBoxValueSet(m_xBuilder->weld_scrolled_window(u"imagewin"_ustr, true)))
|
||||
, m_xBitmapStyleLB(m_xBuilder->weld_combo_box(u"imagestyle"_ustr))
|
||||
, m_xSizeBox(m_xBuilder->weld_container(u"sizebox"_ustr))
|
||||
, m_xTsbScale(m_xBuilder->weld_check_button(u"scaletsb"_ustr))
|
||||
@@ -106,6 +106,7 @@ SvxBitmapTabPage::SvxBitmapTabPage(weld::Container* pPage, weld::DialogControlle
|
||||
m_xBitmapLB->SetSelectHdl( LINK(this, SvxBitmapTabPage, ModifyBitmapHdl) );
|
||||
m_xBitmapLB->SetRenameHdl( LINK(this, SvxBitmapTabPage, ClickRenameHdl) );
|
||||
m_xBitmapLB->SetDeleteHdl( LINK(this, SvxBitmapTabPage, ClickDeleteHdl) );
|
||||
m_xBitmapLB->SetDialog(this);
|
||||
m_xBitmapStyleLB->connect_changed( LINK(this, SvxBitmapTabPage, ModifyBitmapStyleHdl) );
|
||||
Link<weld::MetricSpinButton&, void> aLink1( LINK(this, SvxBitmapTabPage, ModifyBitmapSizeHdl) );
|
||||
m_xBitmapWidth->connect_value_changed( aLink1 );
|
||||
@@ -444,6 +445,39 @@ void SvxBitmapTabPage::ClickBitmapHdl_Impl()
|
||||
ModifyBitmapHdl(m_xBitmapLB.get());
|
||||
}
|
||||
|
||||
void SvxBitmapTabPage::DeleteBitmapHdl_Impl(const sal_uInt16 nId)
|
||||
{
|
||||
const size_t nPos = m_xBitmapLB->GetItemPos(nId);
|
||||
if( nPos == VALUESET_ITEM_NOTFOUND )
|
||||
return;
|
||||
|
||||
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"cui/ui/querydeletebitmapdialog.ui"_ustr));
|
||||
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(u"AskDelBitmapDialog"_ustr));
|
||||
|
||||
if (xQueryBox->run() != RET_YES)
|
||||
return;
|
||||
|
||||
sal_uInt16 nNextId = m_xBitmapLB->GetSelectedItemId();
|
||||
const bool bDeletingSelectedItem(nId == nNextId);
|
||||
if (bDeletingSelectedItem)
|
||||
{
|
||||
nNextId = m_xBitmapLB->GetItemId(nPos + 1);
|
||||
if (!nNextId)
|
||||
nNextId = m_xBitmapLB->GetItemId(nPos - 1);
|
||||
}
|
||||
|
||||
m_pBitmapList->Remove( static_cast<sal_uInt16>(nPos) );
|
||||
m_xBitmapLB->RemoveItem( nId );
|
||||
|
||||
if (bDeletingSelectedItem)
|
||||
{
|
||||
m_xBitmapLB->SelectItem(nNextId);
|
||||
m_aCtlBitmapPreview.Invalidate();
|
||||
}
|
||||
ModifyBitmapHdl(m_xBitmapLB.get());
|
||||
m_nBitmapListState |= ChangeType::MODIFIED;
|
||||
}
|
||||
|
||||
void SvxBitmapTabPage::CalculateBitmapPresetSize()
|
||||
{
|
||||
if(rBitmapSize.IsEmpty())
|
||||
@@ -570,37 +604,28 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void)
|
||||
|
||||
IMPL_LINK_NOARG(SvxBitmapTabPage, ClickDeleteHdl, SvxPresetListBox*, void)
|
||||
{
|
||||
const sal_uInt16 nId = m_xBitmapLB->GetContextMenuItemId();
|
||||
const size_t nPos = m_xBitmapLB->GetItemPos(nId);
|
||||
DeleteBitmapHdl_Impl(m_xBitmapLB->GetContextMenuItemId());
|
||||
}
|
||||
|
||||
if( nPos == VALUESET_ITEM_NOTFOUND )
|
||||
return;
|
||||
|
||||
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"cui/ui/querydeletebitmapdialog.ui"_ustr));
|
||||
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(u"AskDelBitmapDialog"_ustr));
|
||||
SvxBitmapTabPage::SvxPresetListBoxValueSet::SvxPresetListBoxValueSet(std::unique_ptr<weld::ScrolledWindow> pWindow)
|
||||
: SvxPresetListBox(std::move(pWindow))
|
||||
{
|
||||
}
|
||||
|
||||
if (xQueryBox->run() != RET_YES)
|
||||
return;
|
||||
|
||||
sal_uInt16 nNextId = m_xBitmapLB->GetSelectedItemId();
|
||||
const bool bDeletingSelectedItem(nId == nNextId);
|
||||
if (bDeletingSelectedItem)
|
||||
bool SvxBitmapTabPage::SvxPresetListBoxValueSet::KeyInput(const KeyEvent& rKEvt)
|
||||
{
|
||||
switch (rKEvt.GetKeyCode().GetCode())
|
||||
{
|
||||
nNextId = m_xBitmapLB->GetItemId(nPos + 1);
|
||||
if (!nNextId)
|
||||
nNextId = m_xBitmapLB->GetItemId(nPos - 1);
|
||||
case KEY_DELETE:
|
||||
{
|
||||
m_pSvxBitmapTabPage->DeleteBitmapHdl_Impl(GetSelectedItemId());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return SvxPresetListBox::KeyInput(rKEvt);
|
||||
}
|
||||
|
||||
m_pBitmapList->Remove( static_cast<sal_uInt16>(nPos) );
|
||||
m_xBitmapLB->RemoveItem( nId );
|
||||
|
||||
if (bDeletingSelectedItem)
|
||||
{
|
||||
m_xBitmapLB->SelectItem(nNextId);
|
||||
m_aCtlBitmapPreview.Invalidate();
|
||||
}
|
||||
ModifyBitmapHdl(m_xBitmapLB.get());
|
||||
m_nBitmapListState |= ChangeType::MODIFIED;
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG( SvxBitmapTabPage, ModifyBitmapSizeHdl, weld::MetricSpinButton&, void )
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include <svx/xtable.hxx>
|
||||
#include <tools/gen.hxx>
|
||||
|
||||
class SVXCORE_DLLPUBLIC SvxPresetListBox final : public ValueSet
|
||||
class SVXCORE_DLLPUBLIC SvxPresetListBox : public ValueSet
|
||||
{
|
||||
private:
|
||||
static constexpr sal_uInt32 nColCount = 3;
|
||||
|
Reference in New Issue
Block a user