LibreOffice Module accessibility (master) 1
listboxhelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
23#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
24#include <tools/gen.hxx>
25
26
27// globals
28
29
30const sal_Int32 DEFAULT_INDEX_IN_PARENT = -1;
31
32
33
34
35template< class T > class VCLListBoxHelper final : public ::accessibility::IComboListBoxHelper
36{
37private:
39
40public:
41 VCLListBoxHelper( T& _pListBox ) :
42 m_aComboListBox( _pListBox ){}
43
44
45 virtual OUString GetEntry( sal_Int32 nPos ) const override
46 {
47 return m_aComboListBox.GetEntry( nPos );
48 }
49
51 {
52 tools::Rectangle aTemp = m_aComboListBox.GetWindowExtentsAbsolute();
53 tools::Rectangle aRet = m_aComboListBox.GetDropDownPosSizePixel();
54 aRet.Move(aTemp.Left(), aTemp.Top());
55 return aRet;
56 }
57
58 virtual tools::Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const override
59 {
60 tools::Rectangle aRect;
61 if ( m_aComboListBox.IsInDropDown() && IsEntryVisible( nItem ) )
62 {
63 tools::Rectangle aTemp = m_aComboListBox.GetDropDownPosSizePixel();
64 Size aSize = aTemp.GetSize();
65 sal_uInt16 nLineCount = m_aComboListBox.GetDisplayLineCount();
66 assert(nLineCount && "div-by-zero");
67 aSize.setHeight( aSize.Height() / nLineCount );
68 Point aTopLeft = aTemp.TopLeft();
69 aTopLeft.AdjustY( aSize.Height() * ( nItem - m_aComboListBox.GetTopEntry() ) );
70 aRect = tools::Rectangle( aTopLeft, aSize );
71 }
72 else
73 aRect = m_aComboListBox.GetBoundingRectangle( nItem );
74 return aRect;
75 }
76
78 {
79 return m_aComboListBox.GetWindowExtentsAbsolute();
80 }
81
82 virtual bool IsEnabled() const override
83 {
84 return m_aComboListBox.IsEnabled();
85 }
86
87 virtual bool IsEntryVisible( sal_Int32 nPos ) const override
88 {
89 sal_Int32 nTopEntry = m_aComboListBox.GetTopEntry();
90 sal_uInt16 nLines = m_aComboListBox.GetDisplayLineCount();
91 return ( nPos >= nTopEntry && nPos < ( nTopEntry + nLines ) );
92 }
93
94 virtual sal_uInt16 GetDisplayLineCount() const override
95 {
96 return m_aComboListBox.GetDisplayLineCount();
97 }
98
99 virtual void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const override
100 {
101 m_aComboListBox.GetMaxVisColumnsAndLines(rnCols,rnLines);
102 }
103
104 virtual WinBits GetStyle() const override
105 {
106 return m_aComboListBox.GetStyle();
107 }
108
109 virtual bool IsMultiSelectionEnabled() const override
110 {
111 return m_aComboListBox.IsMultiSelectionEnabled();
112 }
113
114 virtual sal_Int32 GetTopEntry() const override
115 {
116 return m_aComboListBox.GetTopEntry();
117 }
118
119 virtual bool IsEntryPosSelected( sal_Int32 nPos ) const override
120 {
121 return m_aComboListBox.IsEntryPosSelected(nPos);
122 }
123
124 virtual sal_Int32 GetEntryCount() const override
125 {
126 return m_aComboListBox.GetEntryCount();
127 }
128
129 virtual void Select() override
130 {
131 m_aComboListBox.Select();
132 }
133
134 virtual void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ) override
135 {
136 m_aComboListBox.SelectEntryPos(nPos,bSelect);
137 }
138
139 virtual sal_Int32 GetSelectedEntryCount() const override
140 {
141 return m_aComboListBox.GetSelectedEntryCount();
142 }
143
144 virtual void SetNoSelection() override
145 {
146 m_aComboListBox.SetNoSelection();
147 }
148
149 virtual sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex = 0 ) const override
150 {
151 return m_aComboListBox.GetSelectedEntryPos(nSelIndex);
152 }
153
154 virtual bool IsInDropDown() const override
155 {
156 return m_aComboListBox.IsInDropDown();
157 }
158
159 virtual tools::Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const override
160 {
161 tools::Rectangle aRect;
162
163 Pair aEntryCharacterRange = m_aComboListBox.GetLineStartEnd( _nEntryPos );
164 if ( aEntryCharacterRange.A() + _nCharacterIndex <= aEntryCharacterRange.B() )
165 {
166 tools::Long nIndex = aEntryCharacterRange.A() + _nCharacterIndex;
167 aRect = m_aComboListBox.GetCharacterBounds( nIndex );
168 }
169 return aRect;
170 }
171
172 tools::Long GetIndexForPoint( const Point& rPoint, sal_Int32& nPos ) const override
173 {
174 return m_aComboListBox.GetIndexForPoint( rPoint, nPos );
175 }
176
177 css::uno::Reference< css::datatransfer::clipboard::XClipboard >
178 GetClipboard() override
179 {
180 return m_aComboListBox.GetClipboard();
181 }
182
183};
184
185
186/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long A() const
tools::Long B() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long Height() const
void setHeight(tools::Long nHeight)
virtual sal_Int32 GetSelectedEntryCount() const override
virtual void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const override
virtual tools::Rectangle GetEntryCharacterBounds(const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex) const override
virtual tools::Rectangle GetWindowExtentsAbsolute() override
virtual OUString GetEntry(sal_Int32 nPos) const override
virtual sal_Int32 GetTopEntry() const override
virtual tools::Rectangle GetDropDownPosSizePixel() const override
virtual bool IsMultiSelectionEnabled() const override
virtual void SetNoSelection() override
virtual bool IsEntryPosSelected(sal_Int32 nPos) const override
virtual sal_Int32 GetEntryCount() const override
VCLListBoxHelper(T &_pListBox)
virtual void SelectEntryPos(sal_Int32 nPos, bool bSelect=true) override
virtual tools::Rectangle GetBoundingRectangle(sal_uInt16 nItem) const override
virtual void Select() override
virtual bool IsEnabled() const override
virtual sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const override
tools::Long GetIndexForPoint(const Point &rPoint, sal_Int32 &nPos) const override
virtual bool IsEntryVisible(sal_Int32 nPos) const override
virtual WinBits GetStyle() const override
virtual bool IsInDropDown() const override
virtual sal_uInt16 GetDisplayLineCount() const override
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() override
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Left() const
sal_Int32 nIndex
sal_uInt16 nPos
const sal_Int32 DEFAULT_INDEX_IN_PARENT
long Long
sal_Int64 WinBits