diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-20 20:43:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-21 11:32:55 +0200 |
commit | 976d595a0f1c5d6a4e60b408f8c0e2340339e770 (patch) | |
tree | 4fe9c1bc9bacf0bbb6d0bcf0d1e81322a90a436f /svtools | |
parent | 13d3b6e5b8323d7af686b7ade2785827b7854920 (diff) |
move AutocompleteEdit to fpicker
Change-Id: I00b1b4f21ffcb183d098b8af296e1dea64a2a482
Reviewed-on: https://gerrit.libreoffice.org/81177
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/control/autocmpledit.cxx | 107 |
2 files changed, 0 insertions, 108 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 6b0c994041c0..95486e42b328 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/contnr/templwin \ svtools/source/control/accessibleruler \ svtools/source/control/asynclink \ - svtools/source/control/autocmpledit \ svtools/source/control/calendar \ svtools/source/control/collatorres \ svtools/source/control/ctrlbox \ diff --git a/svtools/source/control/autocmpledit.cxx b/svtools/source/control/autocmpledit.cxx deleted file mode 100644 index 9c60a830c10d..000000000000 --- a/svtools/source/control/autocmpledit.cxx +++ /dev/null @@ -1,107 +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/. - */ - -#include <svtools/autocmpledit.hxx> -#include <vcl/svapp.hxx> -#include <vcl/event.hxx> - -AutocompleteEdit::AutocompleteEdit( vcl::Window* pParent ) - : Edit( pParent ) - , m_nCurrent( 0 ) -{ - SetAutocompleteHdl(LINK(this, AutocompleteEdit, AutoCompleteHdl_Impl)); -} - -void AutocompleteEdit::AddEntry( const OUString& rEntry ) -{ - m_aEntries.push_back( rEntry ); -} - -void AutocompleteEdit::ClearEntries() -{ - m_aEntries.clear(); - m_aMatching.clear(); -} - -IMPL_LINK_NOARG(AutocompleteEdit, AutoCompleteHdl_Impl, Edit&, void) -{ - if( Application::AnyInput( VclInputFlags::KEYBOARD ) ) - return; - - OUString aCurText = GetText(); - Selection aSelection( GetSelection() ); - - if( aSelection.Max() != aCurText.getLength() ) - return; - - sal_uInt16 nLen = static_cast<sal_uInt16>(aSelection.Min()); - aCurText = aCurText.copy( 0, nLen ); - if( aCurText.isEmpty() ) - return; - - if( !m_aEntries.empty() ) - { - if( Match( aCurText ) ) - { - m_nCurrent = 0; - SetText( m_aMatching[0] ); - sal_uInt16 nNewLen = m_aMatching[0].getLength(); - - Selection aSel( nLen, nNewLen ); - SetSelection( aSel ); - } - } -} - -bool AutocompleteEdit::Match( const OUString& rText ) -{ - bool bRet = false; - - m_aMatching.clear(); - - for(const OUString & rEntry : m_aEntries) - { - if( rEntry.startsWithIgnoreAsciiCase( rText ) ) - { - m_aMatching.push_back( rEntry ); - bRet = true; - } - } - - return bRet; -} - -bool AutocompleteEdit::PreNotify( NotifyEvent& rNEvt ) -{ - if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent& rEvent = *rNEvt.GetKeyEvent(); - const vcl::KeyCode& rKey = rEvent.GetKeyCode(); - vcl::KeyCode aCode( rKey.GetCode() ); - - if( ( aCode == KEY_UP || aCode == KEY_DOWN ) && !rKey.IsMod2() ) - { - Selection aSelection( GetSelection() ); - sal_uInt16 nLen = static_cast<sal_uInt16>(aSelection.Min()); - - if( !m_aMatching.empty() && - ( ( aCode == KEY_DOWN && m_nCurrent + 1 < m_aMatching.size() ) - || ( aCode == KEY_UP && m_nCurrent > 0 ) ) ) - { - SetText( m_aMatching[ aCode == KEY_DOWN ? ++m_nCurrent : --m_nCurrent ] ); - SetSelection( Selection( nLen, GetText().getLength() ) ); - return true; - } - } - } - - return Edit::PreNotify( rNEvt ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |