loplugin:unusedmethods

Change-Id: I58819edd0965ff52c3fc6c20d84bc5951a79bbe2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100381
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-08-08 10:39:44 +02:00
parent a5ada62f56
commit c8b7a833c8
13 changed files with 59 additions and 326 deletions

View File

@@ -124,7 +124,6 @@
#include <vcl/mapmod.hxx>
#include <vcl/menu.hxx>
#include <vcl/metaactiontypes.hxx>
#include <vcl/mnemonicengine.hxx>
#include <vcl/outdev.hxx>
#include <vcl/outdevmap.hxx>
#include <vcl/outdevstate.hxx>

View File

@@ -20,9 +20,9 @@ basic/source/inc/buffer.hxx:42
void SbiBuffer::operator+=(short)
basic/source/inc/buffer.hxx:46
void SbiBuffer::operator+=(int)
bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx:171
bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx:185
void CPPU_CURRENT_NAMESPACE::raiseException(struct _uno_Any *,struct _uno_Mapping *)
bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx:174
bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx:188
void CPPU_CURRENT_NAMESPACE::fillUnoException(struct _uno_Any *,struct _uno_Mapping *)
canvas/inc/rendering/icolorbuffer.hxx:48
unsigned char * canvas::IColorBuffer::lock() const
@@ -104,7 +104,7 @@ connectivity/source/inc/OTypeInfo.hxx:47
_Bool connectivity::OTypeInfo::operator!=(const struct connectivity::OTypeInfo &) const
cui/source/dialogs/SpellAttrib.hxx:72
_Bool svx::SpellErrorDescription::operator==(const struct svx::SpellErrorDescription &) const
cui/source/inc/AdditionsDialog.hxx:141
cui/source/inc/AdditionsDialog.hxx:150
void SearchAndParseThread::AppendAllExtensions()
cui/source/inc/cfg.hxx:336
class rtl::OUString SvxMenuEntriesListBox::get_text(int)
@@ -154,6 +154,8 @@ dbaccess/source/ui/inc/indexcollection.hxx:62
class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<const struct dbaui::OIndex *, class std::__cxx1998::vector<struct dbaui::OIndex, class std::allocator<struct dbaui::OIndex> > >, class std::__debug::vector<struct dbaui::OIndex, class std::allocator<struct dbaui::OIndex> >, struct std::random_access_iterator_tag> dbaui::OIndexCollection::find(const class rtl::OUString &) const
dbaccess/source/ui/inc/indexcollection.hxx:64
class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<const struct dbaui::OIndex *, class std::__cxx1998::vector<struct dbaui::OIndex, class std::allocator<struct dbaui::OIndex> > >, class std::__debug::vector<struct dbaui::OIndex, class std::allocator<struct dbaui::OIndex> >, struct std::random_access_iterator_tag> dbaui::OIndexCollection::findOriginal(const class rtl::OUString &) const
dbaccess/source/ui/inc/JoinExchange.hxx:55
void dbaui::OJoinExchObj::StartDrag(class vcl::Window *,signed char,class dbaui::IDragTransferableListener *)
dbaccess/source/ui/inc/opendoccontrols.hxx:45
_Bool dbaui::OpenDocumentButton::get_sensitive() const
dbaccess/source/ui/inc/opendoccontrols.hxx:68
@@ -164,6 +166,8 @@ dbaccess/source/ui/inc/sbamultiplex.hxx:385
class cppu::OInterfaceContainerHelper * dbaui::SbaXVetoableChangeMultiplexer::getContainer(const class rtl::OUString &)
dbaccess/source/ui/inc/SqlNameEdit.hxx:113
void dbaui::OSQLNameEntry::set_sensitive(_Bool)
dbaccess/source/ui/inc/TableWindow.hxx:102
_Bool dbaui::OTableWindow::HandleKeyInput(const class KeyEvent &)
dbaccess/source/ui/inc/WTypeSelect.hxx:76
void dbaui::OWizTypeSelectList::show()
desktop/source/lib/lokclipboard.hxx:96
@@ -686,7 +690,7 @@ include/svx/dlgctrl.hxx:245
_Bool SvxLineLB::get_sensitive() const
include/svx/dlgctrl.hxx:267
void SvxLineEndLB::set_active_text(const class rtl::OUString &)
include/svx/framelink.hxx:198
include/svx/framelink.hxx:170
_Bool svx::frame::operator>(const class svx::frame::Style &,const class svx::frame::Style &)
include/svx/gallery1.hxx:58
const class std::unique_ptr<class GalleryBinaryEngineEntry, struct std::default_delete<class GalleryBinaryEngineEntry> > & GalleryThemeEntry::getGalleryBinaryEngineEntry() const
@@ -866,8 +870,18 @@ include/vcl/ITiledRenderable.hxx:214
enum PointerStyle vcl::ITiledRenderable::getPointer()
include/vcl/lok.hxx:22
void vcl::lok::unregisterPollCallbacks()
include/vcl/menu.hxx:517
void PopupMenu::SetSelectedEntry(unsigned short)
include/vcl/menu.hxx:456
unsigned short MenuBar::AddMenuBarButton(const class Image &,const class Link<struct MenuBar::MenuBarButtonCallbackArg &, _Bool> &,const class rtl::OUString &)
include/vcl/menu.hxx:460
void MenuBar::SetMenuBarButtonHighlightHdl(unsigned short,const class Link<struct MenuBar::MenuBarButtonCallbackArg &, _Bool> &)
include/vcl/menu.hxx:464
class tools::Rectangle MenuBar::GetMenuBarButtonRectPixel(unsigned short)
include/vcl/menu.hxx:465
void MenuBar::RemoveMenuBarButton(unsigned short)
include/vcl/mnemonicengine.hxx:126
vcl::MnemonicEngine::MnemonicEngine(class vcl::IMnemonicEntryList &)
include/vcl/mnemonicengine.hxx:144
_Bool vcl::MnemonicEngine::HandleKeyEvent(const class KeyEvent &)
include/vcl/NotebookBarAddonsMerger.hxx:63
NotebookBarAddonsMerger::NotebookBarAddonsMerger()
include/vcl/opengl/OpenGLHelper.hxx:67
@@ -920,19 +934,19 @@ include/vcl/toolkit/longcurr.hxx:49
class BigInt LongCurrencyFormatter::GetValue() const
include/vcl/treelist.hxx:170
const class SvTreeListEntry * SvTreeList::GetParent(const class SvTreeListEntry *) const
include/vcl/treelistbox.hxx:298
_Bool SvTreeListBox::EditingCanceled() const
include/vcl/treelistbox.hxx:366
void SvTreeListBox::RemoveSelection()
include/vcl/treelistbox.hxx:673
void SvTreeListBox::ShowFocusRect(const class SvTreeListEntry *)
include/vcl/txtattr.hxx:56
_Bool TextAttrib::operator!=(const class TextAttrib &) const
include/vcl/uitest/uiobject.hxx:281
include/vcl/uitest/uiobject.hxx:282
TabPageUIObject::TabPageUIObject(const class VclPtr<class TabPage> &)
include/vcl/uitest/uiobject.hxx:289
include/vcl/uitest/uiobject.hxx:290
class std::unique_ptr<class UIObject, struct std::default_delete<class UIObject> > TabPageUIObject::create(class vcl::Window *)
include/vcl/uitest/uiobject.hxx:352
include/vcl/uitest/uiobject.hxx:353
SpinUIObject::SpinUIObject(const class VclPtr<class SpinButton> &)
include/vcl/uitest/uiobject.hxx:360
include/vcl/uitest/uiobject.hxx:361
class std::unique_ptr<class UIObject, struct std::default_delete<class UIObject> > SpinUIObject::create(class vcl::Window *)
include/vcl/weld.hxx:127
_Bool weld::Widget::get_hexpand() const
@@ -1088,9 +1102,9 @@ oox/inc/drawingml/textliststyle.hxx:49
void oox::drawingml::TextListStyle::dump() const
oox/inc/drawingml/textparagraphproperties.hxx:98
void oox::drawingml::TextParagraphProperties::setLineSpacing(const class oox::drawingml::TextSpacing &)
oox/source/drawingml/diagram/diagramlayoutatoms.hxx:278
oox/source/drawingml/diagram/diagramlayoutatoms.hxx:279
const class std::__debug::vector<class std::shared_ptr<class oox::drawingml::Shape>, class std::allocator<class std::shared_ptr<class oox::drawingml::Shape> > > & oox::drawingml::LayoutNode::getNodeShapes() const
oox/source/drawingml/diagram/diagramlayoutatoms.hxx:287
oox/source/drawingml/diagram/diagramlayoutatoms.hxx:288
const class oox::drawingml::LayoutNode * oox::drawingml::LayoutNode::getParentLayoutNode() const
sal/osl/unx/uunxapi.hxx:35
int mkdir_c(const class rtl::OString &,unsigned int)
@@ -1396,6 +1410,34 @@ slideshow/source/engine/animationfactory.cxx:538
typename type-parameter-?-?::ValueType slideshow::internal::(anonymous namespace)::GenericAnimation::getUnderlyingValue() const
slideshow/source/engine/opengl/TransitionImpl.hxx:184
void OGLTransitionImpl::cleanup()
slideshow/source/inc/box2dtools.hxx:159
box2d::utils::box2DWorld::box2DWorld(const class basegfx::B2DVector &)
slideshow/source/inc/box2dtools.hxx:162
_Bool box2d::utils::box2DWorld::initiateWorld(const class basegfx::B2DVector &)
slideshow/source/inc/box2dtools.hxx:172
double box2d::utils::box2DWorld::stepAmount(const double,const float,const int,const int)
slideshow/source/inc/box2dtools.hxx:176
_Bool box2d::utils::box2DWorld::shapesInitialized()
slideshow/source/inc/box2dtools.hxx:178
_Bool box2d::utils::box2DWorld::isInitialized()
slideshow/source/inc/box2dtools.hxx:187
class std::shared_ptr<class box2d::utils::box2DBody> box2d::utils::box2DWorld::makeShapeDynamic(const class std::shared_ptr<class slideshow::internal::Shape>)
slideshow/source/inc/box2dtools.hxx:205
class std::shared_ptr<class box2d::utils::box2DBody> box2d::utils::box2DWorld::makeShapeStatic(const class std::shared_ptr<class slideshow::internal::Shape>)
slideshow/source/inc/box2dtools.hxx:223
void box2d::utils::box2DWorld::initateAllShapesAsStaticBodies(const class std::shared_ptr<class slideshow::internal::ShapeManager>)
slideshow/source/inc/box2dtools.hxx:226
_Bool box2d::utils::box2DWorld::hasWorldStepper()
slideshow/source/inc/box2dtools.hxx:229
void box2d::utils::box2DWorld::setHasWorldStepper(const _Bool)
slideshow/source/inc/box2dtools.hxx:232
void box2d::utils::box2DWorld::queuePositionUpdate(class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>,const class basegfx::B2DPoint &)
slideshow/source/inc/box2dtools.hxx:237
void box2d::utils::box2DWorld::queueLinearVelocityUpdate(class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>,const class basegfx::B2DVector &)
slideshow/source/inc/box2dtools.hxx:241
void box2d::utils::box2DWorld::queueRotationUpdate(class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>,const double)
slideshow/source/inc/box2dtools.hxx:246
void box2d::utils::box2DWorld::queueAngularVelocityUpdate(class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>,const double)
slideshow/source/inc/listenercontainer.hxx:44
_Bool slideshow::internal::FunctionApply::apply(type-parameter-?-?,const class std::shared_ptr<class slideshow::internal::AnimationEventHandler> &)
slideshow/source/inc/listenercontainer.hxx:44
@@ -1414,10 +1456,6 @@ slideshow/source/inc/listenercontainer.hxx:54
_Bool slideshow::internal::FunctionApply::apply(type-parameter-?-?,const class std::shared_ptr<class slideshow::internal::ViewRepaintHandler> &)
slideshow/source/inc/listenercontainer.hxx:54
_Bool slideshow::internal::FunctionApply::apply(type-parameter-?-?,const class std::shared_ptr<class slideshow::internal::ViewEventHandler> &)
slideshow/source/inc/shape.hxx:212
_Bool slideshow::internal::Shape::isForeground() const
slideshow/source/inc/shapemanager.hxx:105
const class std::__debug::unordered_map<class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>, class std::shared_ptr<class slideshow::internal::Shape>, struct slideshow::internal::hash<class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape> >, struct std::equal_to<class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape> >, class std::allocator<struct std::pair<const class com::sun::star::uno::Reference<class com::sun::star::drawing::XShape>, class std::shared_ptr<class slideshow::internal::Shape> > > > & slideshow::internal::ShapeManager::getXShapeToShapeMap() const
starmath/inc/format.hxx:138
_Bool SmFormat::operator!=(const class SmFormat &) const
svgio/inc/svgstyleattributes.hxx:346
@@ -1442,8 +1480,8 @@ svl/source/misc/gridprinter.cxx:47
void rtl::mdds_mtv_append_values(struct mdds::mtv::base_element_block &,const class rtl::OUString &,const type-parameter-?-? &,const type-parameter-?-? &)
svx/inc/sdr/contact/viewcontactofgraphic.hxx:52
class SdrGrafObj & sdr::contact::ViewContactOfGraphic::GetGrafObject()
svx/source/inc/fmexch.hxx:102
void svxform::OLocalExchangeHelper::startDrag(class vcl::Window *,signed char)
svx/source/inc/fmexch.hxx:65
void svxform::OLocalExchange::startDrag(class vcl::Window *,signed char,const class svxform::OLocalExchange::GrantAccess &)
svx/source/tbxctrls/tbcontrl.cxx:151
void (anonymous namespace)::SvxStyleBox_Base::set_sensitive(_Bool)
sw/inc/calbck.hxx:307
@@ -1598,7 +1636,7 @@ sw/inc/viscrs.hxx:206
class SwShellTableCursor * SwShellTableCursor::GetPrev()
sw/inc/viscrs.hxx:207
const class SwShellTableCursor * SwShellTableCursor::GetPrev() const
sw/qa/inc/swmodeltestbase.hxx:341
sw/qa/inc/swmodeltestbase.hxx:317
class com::sun::star::uno::Reference<class com::sun::star::beans::XPropertySet> SwModelTestBase::getParagraphAnchoredObject(const int,const class com::sun::star::uno::Reference<class com::sun::star::text::XTextRange> &) const
sw/source/core/access/accportions.cxx:56
unsigned long FindBreak(const vector<type-parameter-?-?, allocator<type-parameter-?-?> > &,type-parameter-?-?)

View File

@@ -52,8 +52,6 @@ namespace dbaui
static css::uno::Sequence< sal_Int8 > getUnoTunnelId();
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& _rIdentifier ) override;
void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, IDragTransferableListener* _pListener );
static OJoinExchangeData GetSourceDescription(const css::uno::Reference< css::datatransfer::XTransferable >& _rxObject);
static bool isFormatAvailable( const DataFlavorExVector& _rFormats ,SotClipboardFormatId _nSlotID=SotClipboardFormatId::SBA_JOIN);

View File

@@ -93,14 +93,6 @@ namespace dbaui
virtual void OnEntryDoubleClicked(weld::TreeIter& /*rEntry*/) { }
// called from the DoubleClickHdl of the ListBox
/** HandleKeyInput tries to handle the KeyEvent. Movement or deletion
@param rEvt
The KeyEvent
@return
<TRUE/> when the table could handle the KeyEvent.
*/
bool HandleKeyInput( const KeyEvent& rEvt );
/** delete the user data with the equal type as created within createUserData
@param _pUserData
The user data store in the listbox entries. Created with a call to createUserData.

View File

@@ -44,12 +44,6 @@ namespace dbaui
{
}
void OJoinExchObj::StartDrag( vcl::Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
{
m_pDragListener = _pListener;
TransferDataContainer::StartDrag(_pWindow, _nDragSourceActions);
}
void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
{
if (m_pDragListener)

View File

@@ -493,23 +493,6 @@ void OTableWindow::Remove()
pTabWinCont->Invalidate();
}
bool OTableWindow::HandleKeyInput( const KeyEvent& rEvt )
{
const vcl::KeyCode& rCode = rEvt.GetKeyCode();
sal_uInt16 nCode = rCode.GetCode();
bool bShift = rCode.IsShift();
bool bCtrl = rCode.IsMod1();
bool bHandle = false;
if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
{
Remove();
bHandle = true;
}
return bHandle;
}
bool OTableWindow::ExistsAConn() const
{
return getTableView()->ExistsAConn(this);

View File

@@ -1,153 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_VCL_MNEMONICENGINE_HXX
#define INCLUDED_VCL_MNEMONICENGINE_HXX
#include <vcl/dllapi.h>
#include <sal/config.h>
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <memory>
class KeyEvent;
namespace vcl
{
//= IMnemonicEntryList
/// callback for a MnemonicEngine
class SAL_NO_VTABLE VCL_DLLPUBLIC IMnemonicEntryList
{
public:
/** returns the first list entry for the mnemonic search
@return
a pointer which can be used to unuquely identify the entry.
The MenomonicEngine itself does not use this value, it
is only passed to other methods of this callback interface.
If this value is NULL, searching stops.
*/
virtual const void* FirstSearchEntry( OUString& _rEntryText ) const = 0;
/** returns the next list entry for the mnemonic search
@return
a pointer which can be used to unuquely identify the entry.
The MenomonicEngine itself does not use this value, it
is only passed to other methods of this callback interface.
If this value is NULL, searching stops.
If this value is the same as returned by the previous call
to FirstSearchEntry (i.e. you cycled
around), then searching stops, too.
*/
virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const = 0;
/** "selects" a given entry.
Note: The semantics of "select" depends on your implementation. You
might actually really select the entry (in the sense of a selected
list box entry, for example), you might make it the current entry,
if your implementation supports this - whatever.
@param _pEntry
the entry to select. This is the return value of a previous call
to FirstSearchEntry or NextSearchEntry.
*/
virtual void SelectSearchEntry( const void* _pEntry ) = 0;
/** "executes" the current search entry, i.e. the one returned
in the previous NextSearchEntry call.
Note: The semantics of "execute" depends on your implementation. You
might even have a list of entries which cannot be executed at all.
This method is called after SelectSearchEntry,
if and only if the current entry's mnemonic is unambiguous.
For instance, imagine a list which has two entries with the same mnemonic
character, say "c". Now if the user presses <code>Alt-C</code>, the MnemonicEngine
will call SelectCurrentEntry as soon as it encounters
the first entry, but it'll never call ExecuteSearchEntry.
If, however, "c" is a unique mnemonic character in your entry list, then the
call of SelectSearchEntry will be followed by a
call to ExecuteSearchEntry.
This way, you can implement cyclic selection of entries: In
FirstSearchEntry, return the entry which was previously
selected, and in NextSearchEntry, internally cycle around
in your list. Then, multiple user inputs of <code>Alt-C</code> will
cycle through all entries with the mnemonic being "c".
@param _pEntry
the entry to select. This is the return value of a previous call
to FirstSearchEntry or NextSearchEntry.
*/
virtual void ExecuteSearchEntry( const void* _pEntry ) const = 0;
protected:
~IMnemonicEntryList() {}
};
//= MnemonicEngine
struct MnemonicEngine_Data;
class MnemonicEngine
{
::std::unique_ptr< MnemonicEngine_Data > m_pData;
public:
MnemonicEngine( IMnemonicEntryList& _rEntryList );
~MnemonicEngine();
/** handles a key event
If the key event denotes pressing an accelerator key, then the
entry list is searched for a matching entry. If such an entry is
found, IMnemonicEntryList::SelectSearchEntry
is called.
If the entry is the only one with the given mnemonic character, then
also IMnemonicEntryList::ExecuteSearchEntry
is called.
@return
if the key event has been handled, and should thus not be processed
further.
*/
bool HandleKeyEvent( const KeyEvent& _rKEvt );
};
} // namespace vcl
#endif // INCLUDED_VCL_MNEMONICENGINE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -7379,7 +7379,6 @@ include/vcl/metaact.hxx
include/vcl/metaactiontypes.hxx
include/vcl/metric.hxx
include/vcl/mnemonic.hxx
include/vcl/mnemonicengine.hxx
include/vcl/mtfxmldump.hxx
include/vcl/notebookbar.hxx
include/vcl/oldprintadaptor.hxx

View File

@@ -71,12 +71,6 @@ namespace svxform
m_aClipboardListener.Call( *this );
}
void OLocalExchange::startDrag( vcl::Window* _pWindow, sal_Int8 _nDragSourceActions, const GrantAccess& )
{
setDragging(true);
StartDrag( _pWindow, _nDragSourceActions );
}
void OLocalExchange::setDragging(bool bDragging)
{
m_bDragging = bDragging;

View File

@@ -59,7 +59,6 @@ namespace svxform
bool isClipboardOwner() const { return m_bClipboardOwner; }
void setDragging(bool bDragging);
void startDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
void copyToClipboard(const GrantAccess&);
void setClipboardListener( const Link<OLocalExchange&,void>& _rListener ) { m_aClipboardListener = _rListener; }

View File

@@ -156,7 +156,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/menuitemlist \
vcl/source/window/menuwindow \
vcl/source/window/mnemonic \
vcl/source/window/mnemonicengine \
vcl/source/window/mouse \
vcl/source/window/NotebookBarAddonsMerger \
vcl/source/window/OptionalBox \

View File

@@ -303,7 +303,6 @@
#include <vcl/menu.hxx>
#include <vcl/metaact.hxx>
#include <vcl/mnemonic.hxx>
#include <vcl/mnemonicengine.hxx>
#include <vcl/outdev.hxx>
#include <vcl/ptrstyle.hxx>
#include <vcl/quickselectionengine.hxx>

View File

@@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/mnemonicengine.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <vcl/settings.hxx>
namespace vcl
{
struct MnemonicEngine_Data
{
IMnemonicEntryList& rEntryList;
explicit MnemonicEngine_Data( IMnemonicEntryList& _rEntryList )
:rEntryList( _rEntryList )
{
}
};
namespace
{
const void* lcl_getEntryForMnemonic( IMnemonicEntryList const & _rEntryList, sal_Unicode _cMnemonic, bool& _rbAmbiguous )
{
_rbAmbiguous = false;
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
OUString sEntryText;
const void* pSearchEntry = _rEntryList.FirstSearchEntry( sEntryText );
const void* pFirstFoundEntry = nullptr;
bool bCheckingAmbiguity = false;
const void* pStartedWith = pSearchEntry;
while ( pSearchEntry )
{
if ( rI18nHelper.MatchMnemonic( sEntryText, _cMnemonic ) )
{
if ( bCheckingAmbiguity )
{
// that's the second (at least) entry with this mnemonic
_rbAmbiguous = true;
return pFirstFoundEntry;
}
pFirstFoundEntry = pSearchEntry;
bCheckingAmbiguity = true;
}
pSearchEntry = _rEntryList.NextSearchEntry( pSearchEntry, sEntryText );
if ( pSearchEntry == pStartedWith )
break;
}
return pFirstFoundEntry;
}
}
MnemonicEngine::MnemonicEngine( IMnemonicEntryList& _rEntryList )
:m_pData( new MnemonicEngine_Data( _rEntryList ) )
{
}
bool MnemonicEngine::HandleKeyEvent( const KeyEvent& _rKEvt )
{
bool bAccelKey = _rKEvt.GetKeyCode().IsMod2();
if ( !bAccelKey )
return false;
sal_Unicode cChar = _rKEvt.GetCharCode();
bool bAmbiguous = false;
const void* pEntry = lcl_getEntryForMnemonic( m_pData->rEntryList, cChar, bAmbiguous );
if ( !pEntry )
return false;
m_pData->rEntryList.SelectSearchEntry( pEntry );
if ( !bAmbiguous )
m_pData->rEntryList.ExecuteSearchEntry( pEntry );
// handled
return true;
}
MnemonicEngine::~MnemonicEngine()
{
}
} // namespace vcl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */