21#include <osl/diagnose.h>
24#define ACCELENTRY_NOTFOUND (sal_uInt16(0xFFFF))
27 sal_uInt16* pIndex =
nullptr )
32 size_t nCount = pList->size();
33 sal_uInt16 nCompareId;
48 nMid = (nLow + nHigh) / 2;
49 nCompareId = (*pList)[ nMid ]->mnId;
50 if (
nId < nCompareId )
54 if (
nId > nCompareId )
57 return static_cast<sal_uInt16
>(nMid);
60 while ( nLow <= nHigh );
64 if (
nId > nCompareId )
65 *pIndex =
static_cast<sal_uInt16
>(nMid+1);
67 *pIndex =
static_cast<sal_uInt16
>(nMid);
75 sal_uInt16 nInsIndex(0);
84 if ( nIndex < pList->
size() )
85 pTempEntry = (*pList)[
nIndex ].get();
86 if ( !pTempEntry || (pTempEntry->
mnId != pEntry->mnId) )
89 while ( nIndex < pList->
size() );
91 if ( nIndex < pList->
size() ) {
92 pList->insert( pList->begin() +
nIndex, std::move(pEntry) );
94 pList->push_back( std::move(pEntry) );
98 if ( nInsIndex < pList->
size() ) {
99 pList->insert( pList->begin() + nInsIndex, std::move(pEntry) );
101 pList->push_back( std::move(pEntry) );
124 for (
const std::unique_ptr<ImplAccelEntry>&
i : rAccelData.
maIdList)
129 if ( pEntry->mpAccel )
131 pEntry->mpAccel =
new Accelerator( *(pEntry->mpAccel) );
132 pEntry->mpAutoAccel = pEntry->mpAccel;
135 pEntry->mpAutoAccel =
nullptr;
137 maKeyMap.insert( std::make_pair( pEntry->maKeyCode.GetFullCode(), pEntry.get() ) );
138 maIdList.push_back( std::move(pEntry) );
145 for (
const std::unique_ptr<ImplAccelEntry>& pEntry :
maIdList) {
146 delete pEntry->mpAutoAccel;
154 SAL_WARN_IF( !nItemId,
"vcl",
"Accelerator::InsertItem(): ItemId == 0" );
182 pEntry->mnId = nItemId;
183 pEntry->maKeyCode = rKeyCode;
184 pEntry->mpAccel = pAutoAccel;
185 pEntry->mpAutoAccel = pAutoAccel;
186 pEntry->mbEnabled = bEnable;
192 OSL_FAIL(
"Accelerator::InsertItem(): KeyCode with KeyCode 0 not allowed" );
194 else if ( !
maKeyMap.insert( std::make_pair( nCode, pEntry.get() ) ).second )
196 SAL_WARN(
"vcl",
"Accelerator::InsertItem(): KeyCode (Key: " << nCode <<
") already exists" );
240 return static_cast<sal_uInt16
>(
maIdList.size());
static void ImplAccelEntryInsert(ImplAccelList *pList, std::unique_ptr< ImplAccelEntry > pEntry)
#define ACCELENTRY_NOTFOUND
static sal_uInt16 ImplAccelEntryGetIndex(const ImplAccelList *pList, sal_uInt16 nId, sal_uInt16 *pIndex=nullptr)
::std::vector< std::unique_ptr< ImplAccelEntry > > ImplAccelList
Link< Accelerator &, void > maSelectHdl
Accelerator * GetAccel(sal_uInt16 nItemId) const
sal_uInt16 GetItemCount() const
void InsertItem(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
void ImplCopyData(const Accelerator &rAccelData)
Link< Accelerator &, void > maActivateHdl
ImplAccelEntry * ImplGetAccelData(const vcl::KeyCode &rKeyCode) const
sal_uInt16 GetItemId(sal_uInt16 nPos) const
void ImplInsertAccel(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode, bool bEnable, Accelerator *pAutoAccel)
Accelerator & operator=(const Accelerator &rAccel)
KeyFuncType GetFunction() const
sal_uInt16 GetFullCode() const
bool ImplGetKeyCode(KeyFuncType eFunc, sal_uInt16 &rCode1, sal_uInt16 &rCode2, sal_uInt16 &rCode3, sal_uInt16 &rCode4)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)