Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svtools/svtabbx.hxx>
30 : : #include <svtools/headbar.hxx>
31 : : #include <svtools/svtresid.hxx>
32 : : #include <svtools/svtools.hrc>
33 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35 : : #include "svtaccessiblefactory.hxx"
36 : :
37 : : using namespace ::com::sun::star::uno;
38 : : using namespace ::com::sun::star::accessibility;
39 : :
40 : : #define MYTABMASK \
41 : : ( SV_LBOXTAB_ADJUST_RIGHT | SV_LBOXTAB_ADJUST_LEFT | SV_LBOXTAB_ADJUST_CENTER | SV_LBOXTAB_ADJUST_NUMERIC )
42 : :
43 : : // SvTreeListBox callback
44 : :
45 : 0 : void SvTabListBox::SetTabs()
46 : : {
47 : 0 : SvTreeListBox::SetTabs();
48 [ # # ]: 0 : if( nTabCount )
49 : : {
50 : : DBG_ASSERT(pTabList,"TabList ?");
51 : :
52 : : // The tree listbox has now inserted its tabs into the list. Now we
53 : : // fluff up the list with additional tabs and adjust the rightmost tab
54 : : // of the tree listbox.
55 : :
56 : : // Picking the rightmost tab.
57 : : // HACK for the explorer! If ViewParent != 0, the first tab of the tree
58 : : // listbox is calculated by the tre listbox itself! This behavior is
59 : : // necessary for ButtonsOnRoot, as the explorer does not know in this
60 : : // case, which additional offset it need to add to the tabs in this mode
61 : : // -- the tree listbox knows that, though!
62 : : /*
63 : : if( !pViewParent )
64 : : {
65 : : SvLBoxTab* pFirstTab = (SvLBoxTab*)aTabs.GetObject( aTabs.Count()-1 );
66 : : pFirstTab->SetPos( pTabList[0].GetPos() );
67 : : pFirstTab->nFlags &= ~MYTABMASK;
68 : : pFirstTab->nFlags |= pTabList[0].nFlags;
69 : : }
70 : : */
71 : :
72 : : // append all other tabs to the list
73 [ # # ]: 0 : for( sal_uInt16 nCurTab = 1; nCurTab < nTabCount; nCurTab++ )
74 : : {
75 : 0 : SvLBoxTab* pTab = pTabList+nCurTab;
76 : 0 : AddTab( pTab->GetPos(), pTab->nFlags );
77 : : }
78 : : }
79 : 0 : }
80 : :
81 : 0 : void SvTabListBox::InitEntry( SvLBoxEntry* pEntry, const XubString& rStr,
82 : : const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind )
83 : : {
84 [ # # ]: 0 : SvTreeListBox::InitEntry( pEntry, rStr, rColl, rExp, eButtonKind );
85 [ # # ]: 0 : XubString aToken;
86 : :
87 : 0 : const xub_Unicode* pCurToken = aCurEntry.GetBuffer();
88 : : sal_uInt16 nCurTokenLen;
89 [ # # ]: 0 : const xub_Unicode* pNextToken = GetToken( pCurToken, nCurTokenLen );
90 : 0 : sal_uInt16 nCount = nTabCount; nCount--;
91 [ # # ]: 0 : for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
92 : : {
93 [ # # ][ # # ]: 0 : if( pCurToken && nCurTokenLen )
94 [ # # ]: 0 : aToken = rtl::OUString(pCurToken, nCurTokenLen);
95 : : else
96 [ # # ]: 0 : aToken.Erase();
97 [ # # ][ # # ]: 0 : SvLBoxString* pStr = new SvLBoxString( pEntry, 0, aToken );
[ # # ]
98 [ # # ]: 0 : pEntry->AddItem( pStr );
99 : 0 : pCurToken = pNextToken;
100 [ # # ]: 0 : if( pCurToken )
101 [ # # ]: 0 : pNextToken = GetToken( pCurToken, nCurTokenLen );
102 : : else
103 : 0 : nCurTokenLen = 0;
104 [ # # ]: 0 : }
105 : 0 : }
106 : :
107 : :
108 : 0 : SvTabListBox::SvTabListBox( Window* pParent, WinBits nBits )
109 [ # # ]: 0 : : SvTreeListBox( pParent, nBits )
110 : : {
111 : 0 : pTabList = 0;
112 : 0 : nTabCount = 0;
113 : 0 : pViewParent = 0;
114 [ # # ]: 0 : SetHighlightRange(); // select full width
115 : 0 : }
116 : :
117 : 0 : SvTabListBox::SvTabListBox( Window* pParent, const ResId& rResId )
118 [ # # ]: 0 : : SvTreeListBox( pParent, rResId )
119 : : {
120 : 0 : pTabList = 0;
121 : 0 : nTabCount = 0;
122 : 0 : pViewParent = 0;
123 [ # # ]: 0 : SvTabListBox::Resize();
124 [ # # ]: 0 : SetHighlightRange();
125 : 0 : }
126 : :
127 [ # # ]: 0 : SvTabListBox::~SvTabListBox()
128 : : {
129 : : // delete array
130 [ # # ][ # # ]: 0 : delete [] pTabList;
[ # # ]
131 : : #ifdef DBG_UTIL
132 : : pTabList = 0;
133 : : nTabCount = 0;
134 : : #endif
135 [ # # ]: 0 : }
136 : :
137 : 0 : void SvTabListBox::SetTabs( long* pTabs, MapUnit eMapUnit )
138 : : {
139 : : DBG_ASSERT(pTabs,"SetTabs:NULL-Ptr");
140 [ # # ]: 0 : if( !pTabs )
141 : 0 : return;
142 : :
143 [ # # ][ # # ]: 0 : delete [] pTabList;
[ # # ]
144 : 0 : sal_uInt16 nCount = (sal_uInt16)(*pTabs);
145 [ # # ][ # # ]: 0 : pTabList = new SvLBoxTab[ nCount ];
[ # # # #
# # ]
146 : 0 : nTabCount = nCount;
147 : :
148 [ # # ]: 0 : MapMode aMMSource( eMapUnit );
149 [ # # ]: 0 : MapMode aMMDest( MAP_PIXEL );
150 : :
151 : 0 : pTabs++;
152 [ # # ]: 0 : for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++, pTabs++ )
153 : : {
154 : 0 : Size aSize( *pTabs, 0 );
155 [ # # ]: 0 : aSize = LogicToLogic( aSize, &aMMSource, &aMMDest );
156 : 0 : long nNewTab = aSize.Width();
157 : 0 : pTabList[nIdx].SetPos( nNewTab );
158 : 0 : pTabList[nIdx].nFlags=(SV_LBOXTAB_ADJUST_LEFT| SV_LBOXTAB_INV_ALWAYS);
159 : : }
160 : 0 : SvTreeListBox::nTreeFlags |= TREEFLAG_RECALCTABS;
161 [ # # ][ # # ]: 0 : if( IsUpdateMode() )
162 [ # # ][ # # ]: 0 : Invalidate();
[ # # ]
163 : : }
164 : :
165 : 0 : void SvTabListBox::SetTab( sal_uInt16 nTab,long nValue,MapUnit eMapUnit )
166 : : {
167 : : DBG_ASSERT(nTab<nTabCount,"Invalid Tab-Pos");
168 [ # # ]: 0 : if( nTab < nTabCount )
169 : : {
170 : : DBG_ASSERT(pTabList,"TabList?");
171 [ # # ]: 0 : MapMode aMMSource( eMapUnit );
172 [ # # ]: 0 : MapMode aMMDest( MAP_PIXEL );
173 : 0 : Size aSize( nValue, 0 );
174 [ # # ]: 0 : aSize = LogicToLogic( aSize, &aMMSource, &aMMDest );
175 : 0 : nValue = aSize.Width();
176 : 0 : pTabList[ nTab ].SetPos( nValue );
177 : 0 : SvTreeListBox::nTreeFlags |= TREEFLAG_RECALCTABS;
178 [ # # ][ # # ]: 0 : if( IsUpdateMode() )
179 [ # # ][ # # ]: 0 : Invalidate();
[ # # ]
180 : : }
181 : 0 : }
182 : :
183 : 0 : SvLBoxEntry* SvTabListBox::InsertEntry( const XubString& rText, SvLBoxEntry* pParent,
184 : : sal_Bool /*bChildrenOnDemand*/,
185 : : sal_uLong nPos, void* pUserData,
186 : : SvLBoxButtonKind )
187 : : {
188 : 0 : return InsertEntryToColumn( rText, pParent, nPos, 0xffff, pUserData );
189 : : }
190 : :
191 : 0 : SvLBoxEntry* SvTabListBox::InsertEntry( const XubString& rText,
192 : : const Image& rExpandedEntryBmp,
193 : : const Image& rCollapsedEntryBmp,
194 : : SvLBoxEntry* pParent,
195 : : sal_Bool /*bChildrenOnDemand*/,
196 : : sal_uLong nPos, void* pUserData,
197 : : SvLBoxButtonKind )
198 : : {
199 : : return InsertEntryToColumn( rText, rExpandedEntryBmp, rCollapsedEntryBmp,
200 : 0 : pParent, nPos, 0xffff, pUserData );
201 : : }
202 : :
203 : 0 : SvLBoxEntry* SvTabListBox::InsertEntryToColumn(const XubString& rStr,SvLBoxEntry* pParent,sal_uLong nPos,sal_uInt16 nCol,
204 : : void* pUser )
205 : : {
206 [ # # ]: 0 : XubString aStr;
207 [ # # ]: 0 : if( nCol != 0xffff )
208 : : {
209 [ # # ]: 0 : while( nCol )
210 : : {
211 [ # # ]: 0 : aStr += '\t';
212 : 0 : nCol--;
213 : : }
214 : : }
215 [ # # ]: 0 : aStr += rStr;
216 [ # # ]: 0 : XubString aFirstStr( aStr );
217 [ # # ]: 0 : sal_uInt16 nEnd = aFirstStr.Search( '\t' );
218 [ # # ]: 0 : if( nEnd != STRING_NOTFOUND )
219 : : {
220 [ # # ]: 0 : aFirstStr.Erase( nEnd );
221 [ # # ]: 0 : aCurEntry = aStr;
222 [ # # ]: 0 : aCurEntry.Erase( 0, ++nEnd );
223 : : }
224 : : else
225 [ # # ]: 0 : aCurEntry.Erase();
226 [ # # ][ # # ]: 0 : return SvTreeListBox::InsertEntry( aFirstStr, pParent, sal_False, nPos, pUser );
[ # # ]
227 : : }
228 : :
229 : 0 : SvLBoxEntry* SvTabListBox::InsertEntryToColumn( const XubString& rStr,
230 : : const Image& rExpandedEntryBmp, const Image& rCollapsedEntryBmp,
231 : : SvLBoxEntry* pParent,sal_uLong nPos,sal_uInt16 nCol, void* pUser )
232 : : {
233 [ # # ]: 0 : XubString aStr;
234 [ # # ]: 0 : if( nCol != 0xffff )
235 : : {
236 [ # # ]: 0 : while( nCol )
237 : : {
238 [ # # ]: 0 : aStr += '\t';
239 : 0 : nCol--;
240 : : }
241 : : }
242 [ # # ]: 0 : aStr += rStr;
243 [ # # ]: 0 : XubString aFirstStr( aStr );
244 [ # # ]: 0 : sal_uInt16 nEnd = aFirstStr.Search( '\t' );
245 [ # # ]: 0 : if( nEnd != STRING_NOTFOUND )
246 : : {
247 [ # # ]: 0 : aFirstStr.Erase( nEnd );
248 [ # # ]: 0 : aCurEntry = aStr;
249 [ # # ]: 0 : aCurEntry.Erase( 0, ++nEnd );
250 : : }
251 : : else
252 [ # # ]: 0 : aCurEntry.Erase();
253 : :
254 : : return SvTreeListBox::InsertEntry(
255 : : aFirstStr,
256 : : rExpandedEntryBmp, rCollapsedEntryBmp,
257 [ # # ][ # # ]: 0 : pParent, sal_False, nPos, pUser );
[ # # ]
258 : : }
259 : :
260 : 0 : SvLBoxEntry* SvTabListBox::InsertEntryToColumn( const XubString& rStr, sal_uLong nPos,
261 : : sal_uInt16 nCol, void* pUser )
262 : : {
263 : 0 : return InsertEntryToColumn( rStr,0,nPos, nCol, pUser );
264 : : }
265 : :
266 : 0 : String SvTabListBox::GetEntryText( SvLBoxEntry* pEntry ) const
267 : : {
268 : 0 : return GetEntryText( pEntry, 0xffff );
269 : : }
270 : :
271 : 0 : String SvTabListBox::GetEntryText( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const
272 : : {
273 : : DBG_ASSERT(pEntry,"GetEntryText:Invalid Entry");
274 [ # # ]: 0 : XubString aResult;
275 [ # # ]: 0 : if( pEntry )
276 : : {
277 : 0 : sal_uInt16 nCount = pEntry->ItemCount();
278 : 0 : sal_uInt16 nCur = 0;
279 [ # # ]: 0 : while( nCur < nCount )
280 : : {
281 [ # # ]: 0 : SvLBoxItem* pStr = pEntry->GetItem( nCur );
282 [ # # ][ # # ]: 0 : if( pStr->IsA() == SV_ITEM_ID_LBOXSTRING )
283 : : {
284 [ # # ]: 0 : if( nCol == 0xffff )
285 : : {
286 [ # # ]: 0 : if( aResult.Len() )
287 [ # # ]: 0 : aResult += '\t';
288 [ # # ]: 0 : aResult += static_cast<SvLBoxString*>( pStr )->GetText();
289 : : }
290 : : else
291 : : {
292 [ # # ]: 0 : if( nCol == 0 )
293 [ # # ]: 0 : return static_cast<SvLBoxString*>( pStr )->GetText();
294 : 0 : nCol--;
295 : : }
296 : : }
297 : 0 : nCur++;
298 : : }
299 : : }
300 [ # # ][ # # ]: 0 : return aResult;
301 : : }
302 : :
303 : 0 : String SvTabListBox::GetEntryText( sal_uLong nPos, sal_uInt16 nCol ) const
304 : : {
305 : 0 : SvLBoxEntry* pEntry = GetEntryOnPos( nPos );
306 : 0 : return GetEntryText( pEntry, nCol );
307 : : }
308 : :
309 : 0 : void SvTabListBox::SetEntryText( const XubString& rStr, sal_uLong nPos, sal_uInt16 nCol )
310 : : {
311 : 0 : SvLBoxEntry* pEntry = SvTreeListBox::GetEntry( nPos );
312 : 0 : SetEntryText( rStr, pEntry, nCol );
313 : 0 : }
314 : :
315 : 0 : void SvTabListBox::SetEntryText( const XubString& rStr, SvLBoxEntry* pEntry, sal_uInt16 nCol )
316 : : {
317 : : DBG_ASSERT(pEntry,"SetEntryText:Invalid Entry");
318 [ # # ]: 0 : if( !pEntry )
319 : : return;
320 : :
321 [ # # ]: 0 : String sOldText = GetEntryText( pEntry, nCol );
322 [ # # ][ # # ]: 0 : if ( sOldText == rStr )
323 : : return;
324 : :
325 : 0 : sal_uInt16 nTextColumn = nCol;
326 : 0 : const xub_Unicode* pCurToken = rStr.GetBuffer();
327 : : sal_uInt16 nCurTokenLen;
328 [ # # ]: 0 : const xub_Unicode* pNextToken = GetToken( pCurToken, nCurTokenLen );
329 : :
330 [ # # ]: 0 : XubString aTemp;
331 : 0 : sal_uInt16 nCount = pEntry->ItemCount();
332 : 0 : sal_uInt16 nCur = 0;
333 [ # # ]: 0 : while( nCur < nCount )
334 : : {
335 [ # # ]: 0 : SvLBoxItem* pStr = pEntry->GetItem( nCur );
336 [ # # ][ # # ]: 0 : if( pStr && pStr->IsA() == SV_ITEM_ID_LBOXSTRING )
[ # # ][ # # ]
337 : : {
338 [ # # ]: 0 : if( nCol == 0xffff )
339 : : {
340 [ # # ]: 0 : if( pCurToken )
341 [ # # ]: 0 : aTemp = rtl::OUString(pCurToken, nCurTokenLen);
342 : : else
343 [ # # ]: 0 : aTemp.Erase(); // delete all columns without a token
344 [ # # ]: 0 : ((SvLBoxString*)pStr)->SetText( aTemp );
345 : 0 : pCurToken = pNextToken;
346 [ # # ]: 0 : pNextToken = GetToken( pCurToken, nCurTokenLen );
347 : : }
348 : : else
349 : : {
350 [ # # ]: 0 : if( !nCol )
351 : : {
352 [ # # ]: 0 : aTemp = rtl::OUString(pCurToken, nCurTokenLen);
353 [ # # ]: 0 : ((SvLBoxString*)pStr)->SetText( aTemp );
354 [ # # ]: 0 : if( !pNextToken )
355 : 0 : break;
356 : 0 : pCurToken = pNextToken;
357 [ # # ]: 0 : pNextToken = GetToken( pCurToken, nCurTokenLen );
358 : : }
359 : : else
360 : 0 : nCol--;
361 : : }
362 : : }
363 : 0 : nCur++;
364 : : }
365 [ # # ]: 0 : GetModel()->InvalidateEntry( pEntry );
366 : :
367 [ # # ][ # # ]: 0 : TabListBoxEventData* pData = new TabListBoxEventData( pEntry, nTextColumn, sOldText );
368 [ # # ]: 0 : ImplCallEventListeners( VCLEVENT_TABLECELL_NAMECHANGED, pData );
369 [ # # ][ # # ]: 0 : delete pData;
[ # # ][ # # ]
[ # # ]
370 : : }
371 : :
372 : 0 : String SvTabListBox::GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const
373 : : {
374 : 0 : SvLBoxEntry* pEntry = GetEntryOnPos( nPos );
375 : : DBG_ASSERT( pEntry, "SvTabListBox::GetCellText(): Invalid Entry" );
376 : 0 : XubString aResult;
377 [ # # ][ # # ]: 0 : if ( pEntry && pEntry->ItemCount() > ( nCol + 1 ) )
[ # # ]
378 : : {
379 [ # # ]: 0 : SvLBoxItem* pStr = pEntry->GetItem( nCol + 1 );
380 [ # # ][ # # ]: 0 : if ( pStr && pStr->IsA() == SV_ITEM_ID_LBOXSTRING )
[ # # ][ # # ]
381 [ # # ]: 0 : aResult = static_cast< SvLBoxString* >( pStr )->GetText();
382 : : }
383 : 0 : return aResult;
384 : : }
385 : :
386 : 0 : sal_uLong SvTabListBox::GetEntryPos( const XubString& rStr, sal_uInt16 nCol )
387 : : {
388 : 0 : sal_uLong nPos = 0;
389 : 0 : SvLBoxEntry* pEntry = First();
390 [ # # ]: 0 : while( pEntry )
391 : : {
392 [ # # ]: 0 : XubString aStr( GetEntryText( pEntry, nCol ));
393 [ # # ][ # # ]: 0 : if( aStr == rStr )
394 : 0 : return nPos;
395 [ # # ]: 0 : pEntry = Next( pEntry );
396 [ # # ]: 0 : nPos++;
397 [ # # ]: 0 : }
398 : 0 : return 0xffffffff;
399 : : }
400 : :
401 : 0 : sal_uLong SvTabListBox::GetEntryPos( const SvLBoxEntry* pEntry ) const
402 : : {
403 : 0 : sal_uLong nPos = 0;
404 : 0 : SvLBoxEntry* pTmpEntry = First();
405 [ # # ]: 0 : while( pTmpEntry )
406 : : {
407 [ # # ]: 0 : if ( pTmpEntry == pEntry )
408 : 0 : return nPos;
409 : 0 : pTmpEntry = Next( pTmpEntry );
410 : 0 : ++nPos;
411 : : }
412 : 0 : return 0xffffffff;
413 : : }
414 : :
415 : 0 : void SvTabListBox::Resize()
416 : : {
417 : 0 : SvTreeListBox::Resize();
418 : 0 : }
419 : :
420 : : // static
421 : 0 : const xub_Unicode* SvTabListBox::GetToken( const xub_Unicode* pPtr, sal_uInt16& rLen )
422 : : {
423 [ # # ][ # # ]: 0 : if( !pPtr || *pPtr == 0 )
424 : : {
425 : 0 : rLen = 0;
426 : 0 : return 0;
427 : : }
428 : 0 : xub_Unicode c = *pPtr;
429 : 0 : sal_uInt16 nLen = 0;
430 [ # # ][ # # ]: 0 : while( c != '\t' && c != 0 )
[ # # ]
431 : : {
432 : 0 : pPtr++;
433 : 0 : nLen++;
434 : 0 : c = *pPtr;
435 : : }
436 [ # # ]: 0 : if( c )
437 : 0 : pPtr++; // skip tab
438 : : else
439 : 0 : pPtr = 0;
440 : 0 : rLen = nLen;
441 : 0 : return pPtr;
442 : : }
443 : :
444 : 0 : String SvTabListBox::GetTabEntryText( sal_uLong nPos, sal_uInt16 nCol ) const
445 : : {
446 [ # # ]: 0 : SvLBoxEntry* pEntry = SvTreeListBox::GetEntry( nPos );
447 : : DBG_ASSERT( pEntry, "GetTabEntryText(): Invalid entry " );
448 [ # # ]: 0 : XubString aResult;
449 [ # # ]: 0 : if ( pEntry )
450 : : {
451 : 0 : sal_uInt16 nCount = pEntry->ItemCount();
452 [ # # ][ # # ]: 0 : sal_uInt16 nCur = ( 0 == nCol && IsCellFocusEnabled() ) ? GetCurrentTabPos() : 0;
[ # # ][ # # ]
453 [ # # ]: 0 : while( nCur < nCount )
454 : : {
455 [ # # ]: 0 : SvLBoxItem* pStr = pEntry->GetItem( nCur );
456 [ # # ][ # # ]: 0 : if ( pStr->IsA() == SV_ITEM_ID_LBOXSTRING )
457 : : {
458 [ # # ]: 0 : if ( nCol == 0xffff )
459 : : {
460 [ # # ]: 0 : if ( aResult.Len() )
461 [ # # ]: 0 : aResult += '\t';
462 [ # # ]: 0 : aResult += static_cast<SvLBoxString*>( pStr )->GetText();
463 : : }
464 : : else
465 : : {
466 [ # # ]: 0 : if ( nCol == 0 )
467 : : {
468 [ # # ]: 0 : String sRet = static_cast<SvLBoxString*>( pStr )->GetText();
469 [ # # ]: 0 : if ( sRet.Len() == 0 )
470 [ # # ][ # # ]: 0 : sRet = SVT_RESSTR( STR_SVT_ACC_EMPTY_FIELD );
[ # # ]
471 [ # # ][ # # ]: 0 : return sRet;
472 : : }
473 : 0 : --nCol;
474 : : }
475 : : }
476 : 0 : ++nCur;
477 : : }
478 : : }
479 [ # # ][ # # ]: 0 : return aResult;
480 : : }
481 : :
482 : 0 : SvLBoxEntry* SvTabListBox::GetEntryOnPos( sal_uLong _nEntryPos ) const
483 : : {
484 : 0 : SvLBoxEntry* pEntry = NULL;
485 [ # # ]: 0 : sal_uLong i, nPos = 0, nCount = GetLevelChildCount( NULL );
486 [ # # ]: 0 : for ( i = 0; i < nCount; ++i )
487 : : {
488 [ # # ]: 0 : SvLBoxEntry* pParent = GetEntry(i);
489 [ # # ]: 0 : if ( nPos == _nEntryPos )
490 : : {
491 : 0 : pEntry = pParent;
492 : 0 : break;
493 : : }
494 : : else
495 : : {
496 : 0 : nPos++;
497 [ # # ]: 0 : pEntry = GetChildOnPos( pParent, _nEntryPos, nPos );
498 [ # # ]: 0 : if ( pEntry )
499 : 0 : break;
500 : : }
501 : : }
502 : :
503 : 0 : return pEntry;
504 : : }
505 : :
506 : 0 : SvLBoxEntry* SvTabListBox::GetChildOnPos( SvLBoxEntry* _pParent, sal_uLong _nEntryPos, sal_uLong& _rPos ) const
507 : : {
508 : 0 : sal_uLong i, nCount = GetLevelChildCount( _pParent );
509 [ # # ]: 0 : for ( i = 0; i < nCount; ++i )
510 : : {
511 : 0 : SvLBoxEntry* pParent = GetEntry( _pParent, i );
512 [ # # ]: 0 : if ( _rPos == _nEntryPos )
513 : 0 : return pParent;
514 : : else
515 : : {
516 : 0 : _rPos++;
517 : 0 : SvLBoxEntry* pEntry = GetChildOnPos( pParent, _nEntryPos, _rPos );
518 [ # # ]: 0 : if ( pEntry )
519 : 0 : return pEntry;
520 : : }
521 : : }
522 : :
523 : 0 : return NULL;
524 : : }
525 : :
526 : 0 : void SvTabListBox::SetTabJustify( sal_uInt16 nTab, SvTabJustify eJustify)
527 : : {
528 [ # # ]: 0 : if( nTab >= nTabCount )
529 : 0 : return;
530 : 0 : SvLBoxTab* pTab = &(pTabList[ nTab ]);
531 : 0 : sal_uInt16 nFlags = pTab->nFlags;
532 : 0 : nFlags &= (~MYTABMASK);
533 : 0 : nFlags |= (sal_uInt16)eJustify;
534 : 0 : pTab->nFlags = nFlags;
535 : 0 : SvTreeListBox::nTreeFlags |= TREEFLAG_RECALCTABS;
536 [ # # ]: 0 : if( IsUpdateMode() )
537 : 0 : Invalidate();
538 : : }
539 : :
540 : 0 : long SvTabListBox::GetLogicTab( sal_uInt16 nTab )
541 : : {
542 [ # # ]: 0 : if( SvTreeListBox::nTreeFlags & TREEFLAG_RECALCTABS )
543 : 0 : ((SvTabListBox*)this)->SetTabs();
544 : :
545 : : DBG_ASSERT(nTab<nTabCount,"GetTabPos:Invalid Tab");
546 : 0 : return aTabs[ nTab ]->GetPos();
547 : : }
548 : :
549 : : // class SvHeaderTabListBoxImpl ------------------------------------------
550 : :
551 : : namespace svt
552 : : {
553 : 0 : struct SvHeaderTabListBoxImpl
554 : : {
555 : : HeaderBar* m_pHeaderBar;
556 : : AccessibleFactoryAccess m_aFactoryAccess;
557 : :
558 : 0 : SvHeaderTabListBoxImpl() : m_pHeaderBar( NULL ) { }
559 : : };
560 : : }
561 : :
562 : : // class SvHeaderTabListBox ----------------------------------------------
563 : :
564 : 0 : SvHeaderTabListBox::SvHeaderTabListBox( Window* pParent, WinBits nWinStyle ) :
565 : :
566 : : SvTabListBox( pParent, nWinStyle ),
567 : :
568 : : m_bFirstPaint ( sal_True ),
569 [ # # ]: 0 : m_pImpl ( new ::svt::SvHeaderTabListBoxImpl ),
570 [ # # ][ # # ]: 0 : m_pAccessible ( NULL )
571 : : {
572 : 0 : }
573 : :
574 : : // -----------------------------------------------------------------------
575 : :
576 : 0 : SvHeaderTabListBox::SvHeaderTabListBox( Window* pParent, const ResId& rResId ) :
577 : :
578 : : SvTabListBox( pParent, rResId ),
579 : :
580 : : m_bFirstPaint ( sal_True ),
581 [ # # ]: 0 : m_pImpl ( new ::svt::SvHeaderTabListBoxImpl ),
582 [ # # ][ # # ]: 0 : m_pAccessible ( NULL )
583 : : {
584 : 0 : }
585 : :
586 : : // -----------------------------------------------------------------------
587 : :
588 : 0 : SvHeaderTabListBox::~SvHeaderTabListBox()
589 : : {
590 [ # # ][ # # ]: 0 : delete m_pImpl;
591 [ # # ]: 0 : }
592 : :
593 : : // -----------------------------------------------------------------------
594 : :
595 : 0 : void SvHeaderTabListBox::Paint( const Rectangle& rRect )
596 : : {
597 [ # # ]: 0 : if ( m_bFirstPaint )
598 : : {
599 : 0 : m_bFirstPaint = sal_False;
600 : 0 : RepaintScrollBars();
601 : : }
602 : 0 : SvTabListBox::Paint( rRect );
603 : 0 : }
604 : :
605 : : // -----------------------------------------------------------------------
606 : :
607 : 0 : void SvHeaderTabListBox::InitHeaderBar( HeaderBar* pHeaderBar )
608 : : {
609 : : DBG_ASSERT( !m_pImpl->m_pHeaderBar, "header bar already initialized" );
610 : : DBG_ASSERT( pHeaderBar, "invalid header bar initialization" );
611 : 0 : m_pImpl->m_pHeaderBar = pHeaderBar;
612 : 0 : SetScrolledHdl( LINK( this, SvHeaderTabListBox, ScrollHdl_Impl ) );
613 : 0 : m_pImpl->m_pHeaderBar->SetCreateAccessibleHdl( LINK( this, SvHeaderTabListBox, CreateAccessibleHdl_Impl ) );
614 : 0 : }
615 : :
616 : : // -----------------------------------------------------------------------
617 : :
618 : 0 : sal_Bool SvHeaderTabListBox::IsItemChecked( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const
619 : : {
620 : 0 : SvButtonState eState = SV_BUTTON_UNCHECKED;
621 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)( pEntry->GetItem( nCol + 1 ) );
622 : :
623 [ # # ][ # # ]: 0 : if ( pItem && ( (SvLBoxItem*)pItem )->IsA() == SV_ITEM_ID_LBOXBUTTON )
[ # # ]
624 : : {
625 : 0 : sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
626 : 0 : eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
627 : : }
628 : :
629 : 0 : return ( eState == SV_BUTTON_CHECKED );
630 : : }
631 : :
632 : : // -----------------------------------------------------------------------
633 : :
634 : 0 : SvLBoxEntry* SvHeaderTabListBox::InsertEntryToColumn(
635 : : const XubString& rStr, sal_uLong nPos, sal_uInt16 nCol, void* pUserData )
636 : : {
637 : 0 : SvLBoxEntry* pEntry = SvTabListBox::InsertEntryToColumn( rStr, nPos, nCol, pUserData );
638 : 0 : RecalculateAccessibleChildren();
639 : 0 : return pEntry;
640 : : }
641 : :
642 : : // -----------------------------------------------------------------------
643 : :
644 : 0 : SvLBoxEntry* SvHeaderTabListBox::InsertEntryToColumn(
645 : : const XubString& rStr, SvLBoxEntry* pParent, sal_uLong nPos, sal_uInt16 nCol, void* pUserData )
646 : : {
647 : 0 : SvLBoxEntry* pEntry = SvTabListBox::InsertEntryToColumn( rStr, pParent, nPos, nCol, pUserData );
648 : 0 : RecalculateAccessibleChildren();
649 : 0 : return pEntry;
650 : : }
651 : :
652 : : // -----------------------------------------------------------------------
653 : :
654 : 0 : SvLBoxEntry* SvHeaderTabListBox::InsertEntryToColumn(
655 : : const XubString& rStr, const Image& rExpandedEntryBmp, const Image& rCollapsedEntryBmp,
656 : : SvLBoxEntry* pParent, sal_uLong nPos, sal_uInt16 nCol, void* pUserData )
657 : : {
658 : : SvLBoxEntry* pEntry = SvTabListBox::InsertEntryToColumn(
659 : 0 : rStr, rExpandedEntryBmp, rCollapsedEntryBmp, pParent, nPos, nCol, pUserData );
660 : 0 : RecalculateAccessibleChildren();
661 : 0 : return pEntry;
662 : : }
663 : :
664 : : // -----------------------------------------------------------------------
665 : :
666 : 0 : sal_uLong SvHeaderTabListBox::Insert(
667 : : SvLBoxEntry* pEnt, SvLBoxEntry* pPar, sal_uLong nPos )
668 : : {
669 : 0 : sal_uLong n = SvTabListBox::Insert( pEnt, pPar, nPos );
670 : 0 : RecalculateAccessibleChildren();
671 : 0 : return n;
672 : : }
673 : :
674 : : // -----------------------------------------------------------------------
675 : :
676 : 0 : sal_uLong SvHeaderTabListBox::Insert( SvLBoxEntry* pEntry, sal_uLong nRootPos )
677 : : {
678 : 0 : sal_uLong nPos = SvTabListBox::Insert( pEntry, nRootPos );
679 : 0 : RecalculateAccessibleChildren();
680 : 0 : return nPos;
681 : : }
682 : :
683 : : // -----------------------------------------------------------------------
684 : :
685 : 0 : void SvHeaderTabListBox::RemoveEntry( SvLBoxEntry* _pEntry )
686 : : {
687 : 0 : GetModel()->Remove( _pEntry );
688 : 0 : m_aAccessibleChildren.clear();
689 : 0 : }
690 : :
691 : : // -----------------------------------------------------------------------
692 : :
693 : 0 : void SvHeaderTabListBox::Clear()
694 : : {
695 : 0 : SvTabListBox::Clear();
696 : 0 : m_aAccessibleChildren.clear();
697 : 0 : }
698 : :
699 : : // -----------------------------------------------------------------------
700 : :
701 : 0 : IMPL_LINK_NOARG(SvHeaderTabListBox, ScrollHdl_Impl)
702 : : {
703 : 0 : m_pImpl->m_pHeaderBar->SetOffset( -GetXOffset() );
704 : 0 : return 0;
705 : : }
706 : :
707 : : // -----------------------------------------------------------------------
708 : :
709 : 0 : IMPL_LINK_NOARG(SvHeaderTabListBox, CreateAccessibleHdl_Impl)
710 : : {
711 : 0 : Window* pParent = m_pImpl->m_pHeaderBar->GetAccessibleParentWindow();
712 : : DBG_ASSERT( pParent, "SvHeaderTabListBox..CreateAccessibleHdl_Impl - accessible parent not found" );
713 [ # # ]: 0 : if ( pParent )
714 : : {
715 [ # # ]: 0 : ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
716 [ # # ]: 0 : if ( xAccParent.is() )
717 : : {
718 [ # # ]: 0 : Reference< XAccessible > xAccessible = m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxHeaderBar(
719 [ # # ]: 0 : xAccParent, *this, ::svt::BBTYPE_COLUMNHEADERBAR );
720 [ # # ]: 0 : m_pImpl->m_pHeaderBar->SetAccessible( xAccessible );
721 : 0 : }
722 : : }
723 : 0 : return 0;
724 : : }
725 : :
726 : : // -----------------------------------------------------------------------
727 : :
728 : 0 : void SvHeaderTabListBox::RecalculateAccessibleChildren()
729 : : {
730 [ # # ]: 0 : if ( !m_aAccessibleChildren.empty() )
731 : : {
732 : 0 : sal_uInt32 nCount = ( GetRowCount() + 1 ) * GetColumnCount();
733 [ # # ]: 0 : if ( m_aAccessibleChildren.size() < nCount )
734 : 0 : m_aAccessibleChildren.resize( nCount );
735 : : else
736 : : {
737 : : DBG_ASSERT( m_aAccessibleChildren.size() == nCount, "wrong children count" );
738 : : }
739 : : }
740 : 0 : }
741 : :
742 : : // -----------------------------------------------------------------------
743 : :
744 : 0 : sal_Bool SvHeaderTabListBox::IsCellCheckBox( long _nRow, sal_uInt16 _nColumn, TriState& _rState )
745 : : {
746 : 0 : sal_Bool bRet = sal_False;
747 : 0 : SvLBoxEntry* pEntry = GetEntry( _nRow );
748 [ # # ]: 0 : if ( pEntry )
749 : : {
750 : 0 : sal_uInt16 nItemCount = pEntry->ItemCount();
751 [ # # ]: 0 : if ( nItemCount > ( _nColumn + 1 ) )
752 : : {
753 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)( pEntry->GetItem( _nColumn + 1 ) );
754 [ # # ][ # # ]: 0 : if ( pItem && ( (SvLBoxItem*)pItem )->IsA() == SV_ITEM_ID_LBOXBUTTON )
[ # # ]
755 : : {
756 : 0 : bRet = sal_True;
757 : 0 : _rState = ( ( pItem->GetButtonFlags() & SV_ITEMSTATE_UNCHECKED ) == 0 )
758 [ # # ]: 0 : ? STATE_CHECK : STATE_NOCHECK;
759 : : }
760 : : }
761 : : else
762 : : {
763 : : SAL_WARN( "svtools.contnr", "SvHeaderTabListBox::IsCellCheckBox(): column out of range" );
764 : : }
765 : : }
766 : 0 : return bRet;
767 : : }
768 : :
769 : : // -----------------------------------------------------------------------
770 : 0 : long SvHeaderTabListBox::GetRowCount() const
771 : : {
772 : 0 : return GetEntryCount();
773 : : }
774 : : // -----------------------------------------------------------------------
775 : 0 : sal_uInt16 SvHeaderTabListBox::GetColumnCount() const
776 : : {
777 : 0 : return m_pImpl->m_pHeaderBar->GetItemCount();
778 : : }
779 : : // -----------------------------------------------------------------------
780 : 0 : sal_Int32 SvHeaderTabListBox::GetCurrRow() const
781 : : {
782 : 0 : sal_Int32 nRet = -1;
783 : 0 : SvLBoxEntry* pEntry = GetCurEntry();
784 [ # # ]: 0 : if ( pEntry )
785 : : {
786 : 0 : sal_uLong nCount = GetEntryCount();
787 [ # # ]: 0 : for ( sal_uLong i = 0; i < nCount; ++i )
788 : : {
789 [ # # ]: 0 : if ( pEntry == GetEntry(i) )
790 : : {
791 : 0 : nRet = i;
792 : 0 : break;
793 : : }
794 : : }
795 : : }
796 : :
797 : 0 : return nRet;
798 : : }
799 : : // -----------------------------------------------------------------------
800 : 0 : sal_uInt16 SvHeaderTabListBox::GetCurrColumn() const
801 : : {
802 : 0 : sal_uInt16 nPos = GetCurrentTabPos() - 1;
803 : 0 : return nPos;
804 : : }
805 : : // -----------------------------------------------------------------------
806 : 0 : ::rtl::OUString SvHeaderTabListBox::GetRowDescription( sal_Int32 _nRow ) const
807 : : {
808 [ # # ]: 0 : return ::rtl::OUString( GetEntryText( _nRow ) );
809 : : }
810 : : // -----------------------------------------------------------------------
811 : 0 : ::rtl::OUString SvHeaderTabListBox::GetColumnDescription( sal_uInt16 _nColumn ) const
812 : : {
813 [ # # ]: 0 : return ::rtl::OUString( m_pImpl->m_pHeaderBar->GetItemText( m_pImpl->m_pHeaderBar->GetItemId( _nColumn ) ) );
814 : : }
815 : : // -----------------------------------------------------------------------
816 : 0 : sal_Bool SvHeaderTabListBox::HasRowHeader() const
817 : : {
818 : 0 : return sal_False;
819 : : }
820 : : // -----------------------------------------------------------------------
821 : 0 : sal_Bool SvHeaderTabListBox::IsCellFocusable() const
822 : : {
823 : 0 : return IsCellFocusEnabled();
824 : : }
825 : : // -----------------------------------------------------------------------
826 : 0 : sal_Bool SvHeaderTabListBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn )
827 : : {
828 : 0 : sal_Bool bRet = ( IsCellFocusEnabled() == sal_True );
829 [ # # ]: 0 : if ( bRet )
830 : : {
831 : : // first set cursor to _nRow
832 : 0 : SetCursor( GetEntry( _nRow ), sal_True );
833 : : // then set the focus into _nColumn
834 : 0 : bRet = ( SetCurrentTabPos( _nColumn ) == true );
835 : : }
836 : 0 : return bRet;
837 : : }
838 : : // -----------------------------------------------------------------------
839 : 0 : void SvHeaderTabListBox::SetNoSelection()
840 : : {
841 : 0 : SvLBox::SelectAll( sal_False );
842 : 0 : }
843 : : // -----------------------------------------------------------------------
844 : 0 : void SvHeaderTabListBox::SelectAll()
845 : : {
846 : 0 : SvLBox::SelectAll( sal_True );
847 : 0 : }
848 : : // -----------------------------------------------------------------------
849 : 0 : void SvHeaderTabListBox::SelectAll( sal_Bool bSelect, sal_Bool bPaint )
850 : : {
851 : : // overwritten just to disambiguate the SelectAll() from the base' class SelectAll( BOOl, sal_Bool )
852 : 0 : SvTabListBox::SelectAll( bSelect, bPaint );
853 : 0 : }
854 : :
855 : : // -----------------------------------------------------------------------
856 : 0 : void SvHeaderTabListBox::SelectRow( long _nRow, sal_Bool _bSelect, sal_Bool )
857 : : {
858 : 0 : Select( GetEntry( _nRow ), _bSelect );
859 : 0 : }
860 : : // -----------------------------------------------------------------------
861 : 0 : void SvHeaderTabListBox::SelectColumn( sal_uInt16, sal_Bool )
862 : : {
863 : 0 : }
864 : : // -----------------------------------------------------------------------
865 : 0 : sal_Int32 SvHeaderTabListBox::GetSelectedRowCount() const
866 : : {
867 : 0 : return GetSelectionCount();
868 : : }
869 : : // -----------------------------------------------------------------------
870 : 0 : sal_Int32 SvHeaderTabListBox::GetSelectedColumnCount() const
871 : : {
872 : 0 : return 0;
873 : : }
874 : : // -----------------------------------------------------------------------
875 : 0 : bool SvHeaderTabListBox::IsRowSelected( long _nRow ) const
876 : : {
877 : 0 : SvLBoxEntry* pEntry = GetEntry( _nRow );
878 [ # # ][ # # ]: 0 : return ( pEntry && IsSelected( pEntry ) );
879 : : }
880 : : // -----------------------------------------------------------------------
881 : 0 : sal_Bool SvHeaderTabListBox::IsColumnSelected( long ) const
882 : : {
883 : 0 : return sal_False;
884 : : }
885 : : // -----------------------------------------------------------------------
886 : 0 : void SvHeaderTabListBox::GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& ) const
887 : : {
888 : 0 : }
889 : : // -----------------------------------------------------------------------
890 : 0 : void SvHeaderTabListBox::GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& ) const
891 : : {
892 : 0 : }
893 : : // -----------------------------------------------------------------------
894 : 0 : sal_Bool SvHeaderTabListBox::IsCellVisible( sal_Int32, sal_uInt16 ) const
895 : : {
896 : 0 : return sal_True;
897 : : }
898 : : // -----------------------------------------------------------------------
899 : 0 : String SvHeaderTabListBox::GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const
900 : : {
901 [ # # ][ # # ]: 0 : return ::rtl::OUString( GetTabEntryText( _nRow, _nColumnPos ) );
902 : : }
903 : : // -----------------------------------------------------------------------
904 : 0 : Rectangle SvHeaderTabListBox::calcHeaderRect( sal_Bool _bIsColumnBar, sal_Bool _bOnScreen )
905 : : {
906 : 0 : Rectangle aRect;
907 [ # # ]: 0 : if ( _bIsColumnBar )
908 : : {
909 : 0 : Window* pParent = NULL;
910 [ # # ]: 0 : if ( !_bOnScreen )
911 : 0 : pParent = m_pImpl->m_pHeaderBar->GetAccessibleParentWindow();
912 : :
913 : 0 : aRect = m_pImpl->m_pHeaderBar->GetWindowExtentsRelative( pParent );
914 : : }
915 : 0 : return aRect;
916 : : }
917 : : // -----------------------------------------------------------------------
918 : 0 : Rectangle SvHeaderTabListBox::calcTableRect( sal_Bool _bOnScreen )
919 : : {
920 : 0 : Window* pParent = NULL;
921 [ # # ]: 0 : if ( !_bOnScreen )
922 : 0 : pParent = GetAccessibleParentWindow();
923 : :
924 : 0 : Rectangle aRect( GetWindowExtentsRelative( pParent ) );
925 : 0 : return aRect;
926 : : }
927 : : // -----------------------------------------------------------------------
928 : 0 : Rectangle SvHeaderTabListBox::GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_Bool _bIsHeader, sal_Bool _bOnScreen )
929 : : {
930 : : DBG_ASSERT( !_bIsHeader || 0 == _nRow, "invalid parameters" );
931 : 0 : Rectangle aRect;
932 : 0 : SvLBoxEntry* pEntry = GetEntry( _nRow );
933 [ # # ]: 0 : if ( pEntry )
934 : : {
935 [ # # ][ # # ]: 0 : aRect = _bIsHeader ? calcHeaderRect( sal_True, sal_False ) : GetBoundingRect( pEntry );
[ # # ]
936 : 0 : Point aTopLeft = aRect.TopLeft();
937 : : DBG_ASSERT( m_pImpl->m_pHeaderBar->GetItemCount() > _nColumn, "invalid column" );
938 [ # # ][ # # ]: 0 : Rectangle aItemRect = m_pImpl->m_pHeaderBar->GetItemRect( m_pImpl->m_pHeaderBar->GetItemId( _nColumn ) );
939 : 0 : aTopLeft.X() = aItemRect.Left();
940 [ # # ]: 0 : Size aSize = aItemRect.GetSize();
941 [ # # ]: 0 : aRect = Rectangle( aTopLeft, aSize );
942 : 0 : Window* pParent = NULL;
943 [ # # ]: 0 : if ( !_bOnScreen )
944 [ # # ]: 0 : pParent = GetAccessibleParentWindow();
945 : 0 : aTopLeft = aRect.TopLeft();
946 [ # # ]: 0 : aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft();
947 [ # # ][ # # ]: 0 : aRect = Rectangle( aTopLeft, aRect.GetSize() );
948 : : }
949 : :
950 : 0 : return aRect;
951 : : }
952 : : // -----------------------------------------------------------------------
953 : 0 : Reference< XAccessible > SvHeaderTabListBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
954 : : {
955 : : OSL_ENSURE( m_pAccessible, "Invalid call: Accessible is null" );
956 : :
957 : 0 : Reference< XAccessible > xChild;
958 : 0 : sal_Int32 nIndex = -1;
959 : :
960 [ # # ][ # # ]: 0 : if ( !AreChildrenTransient() )
961 : : {
962 [ # # ]: 0 : const sal_uInt16 nColumnCount = GetColumnCount();
963 : :
964 : : // first call? -> initial list
965 [ # # ]: 0 : if ( m_aAccessibleChildren.empty() )
966 : : {
967 [ # # ]: 0 : sal_Int32 nCount = ( GetRowCount() + 1 ) * nColumnCount;
968 [ # # ]: 0 : m_aAccessibleChildren.assign( nCount, Reference< XAccessible >() );
969 : : }
970 : :
971 : 0 : nIndex = ( _nRow * nColumnCount ) + _nColumnPos + nColumnCount;
972 [ # # ]: 0 : xChild = m_aAccessibleChildren[ nIndex ];
973 : : }
974 : :
975 [ # # ]: 0 : if ( !xChild.is() )
976 : : {
977 : 0 : TriState eState = STATE_DONTKNOW;
978 [ # # ]: 0 : sal_Bool bIsCheckBox = IsCellCheckBox( _nRow, _nColumnPos, eState );
979 [ # # ]: 0 : if ( bIsCheckBox )
980 [ # # ]: 0 : xChild = m_pImpl->m_aFactoryAccess.getFactory().createAccessibleCheckBoxCell(
981 [ # # ][ # # ]: 0 : m_pAccessible->getAccessibleChild( 0 ), *this, NULL, _nRow, _nColumnPos, eState, sal_True, sal_False );
[ # # ][ # # ]
982 : : else
983 [ # # ]: 0 : xChild = m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell(
984 [ # # ][ # # ]: 0 : m_pAccessible->getAccessibleChild( 0 ), *this, NULL, _nRow, _nColumnPos, OFFSET_NONE );
[ # # ][ # # ]
985 : :
986 : : // insert into list
987 [ # # ][ # # ]: 0 : if ( !AreChildrenTransient() )
988 [ # # ]: 0 : m_aAccessibleChildren[ nIndex ] = xChild;
989 : : }
990 : :
991 : 0 : return xChild;
992 : : }
993 : : // -----------------------------------------------------------------------
994 : 0 : Reference< XAccessible > SvHeaderTabListBox::CreateAccessibleRowHeader( sal_Int32 )
995 : : {
996 : 0 : Reference< XAccessible > xHeader;
997 : 0 : return xHeader;
998 : : }
999 : : // -----------------------------------------------------------------------
1000 : 0 : Reference< XAccessible > SvHeaderTabListBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumn )
1001 : : {
1002 : : // first call? -> initial list
1003 [ # # ]: 0 : if ( m_aAccessibleChildren.empty() )
1004 : : {
1005 : 0 : const sal_uInt16 nColumnCount = GetColumnCount();
1006 : 0 : sal_Int32 nCount = AreChildrenTransient() ?
1007 [ # # ]: 0 : nColumnCount : ( GetRowCount() + 1 ) * nColumnCount;
1008 [ # # ]: 0 : m_aAccessibleChildren.assign( nCount, Reference< XAccessible >() );
1009 : : }
1010 : :
1011 : : // get header
1012 : 0 : Reference< XAccessible > xChild = m_aAccessibleChildren[ _nColumn ];
1013 : : // already exists?
1014 [ # # ][ # # ]: 0 : if ( !xChild.is() && m_pAccessible )
[ # # ]
1015 : : {
1016 : : // no -> create new header cell
1017 [ # # ]: 0 : xChild = m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxHeaderCell(
1018 : 0 : _nColumn, m_pAccessible->getHeaderBar( ::svt::BBTYPE_COLUMNHEADERBAR ),
1019 : : *this, NULL, ::svt::BBTYPE_COLUMNHEADERCELL
1020 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
1021 : :
1022 : : // insert into list
1023 [ # # ]: 0 : m_aAccessibleChildren[ _nColumn ] = xChild;
1024 : : }
1025 : :
1026 : 0 : return xChild;
1027 : : }
1028 : : // -----------------------------------------------------------------------
1029 : 0 : sal_Int32 SvHeaderTabListBox::GetAccessibleControlCount() const
1030 : : {
1031 : 0 : return -1;
1032 : : }
1033 : : // -----------------------------------------------------------------------
1034 : 0 : Reference< XAccessible > SvHeaderTabListBox::CreateAccessibleControl( sal_Int32 )
1035 : : {
1036 : 0 : Reference< XAccessible > xControl;
1037 : 0 : return xControl;
1038 : : }
1039 : : // -----------------------------------------------------------------------
1040 : 0 : sal_Bool SvHeaderTabListBox::ConvertPointToControlIndex( sal_Int32&, const Point& )
1041 : : {
1042 : 0 : return sal_False;
1043 : : }
1044 : : // -----------------------------------------------------------------------
1045 : 0 : sal_Bool SvHeaderTabListBox::ConvertPointToCellAddress( sal_Int32&, sal_uInt16&, const Point& )
1046 : : {
1047 : 0 : return sal_False;
1048 : : }
1049 : : // -----------------------------------------------------------------------
1050 : 0 : sal_Bool SvHeaderTabListBox::ConvertPointToRowHeader( sal_Int32&, const Point& )
1051 : : {
1052 : 0 : return sal_False;
1053 : : }
1054 : : // -----------------------------------------------------------------------
1055 : 0 : sal_Bool SvHeaderTabListBox::ConvertPointToColumnHeader( sal_uInt16&, const Point& )
1056 : : {
1057 : 0 : return sal_False;
1058 : : }
1059 : : // -----------------------------------------------------------------------
1060 : 0 : ::rtl::OUString SvHeaderTabListBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos ) const
1061 : : {
1062 : 0 : ::rtl::OUString aRetText;
1063 [ # # # # : 0 : switch( _eType )
# # ]
1064 : : {
1065 : : case ::svt::BBTYPE_BROWSEBOX:
1066 : : case ::svt::BBTYPE_TABLE:
1067 : : case ::svt::BBTYPE_COLUMNHEADERBAR:
1068 : : // should be empty now (see #i63983)
1069 : 0 : aRetText = ::rtl::OUString();
1070 : 0 : break;
1071 : :
1072 : : case ::svt::BBTYPE_TABLECELL:
1073 : : {
1074 : : // here we need a valid pos, we can not handle -1
1075 [ # # ]: 0 : if ( _nPos >= 0 )
1076 : : {
1077 [ # # ]: 0 : sal_uInt16 nColumnCount = GetColumnCount();
1078 [ # # ]: 0 : if (nColumnCount > 0)
1079 : : {
1080 : 0 : sal_Int32 nRow = _nPos / nColumnCount;
1081 : 0 : sal_uInt16 nColumn = static_cast< sal_uInt16 >( _nPos % nColumnCount );
1082 [ # # ][ # # ]: 0 : aRetText = GetCellText( nRow, nColumn );
[ # # ]
1083 : : }
1084 : : }
1085 : 0 : break;
1086 : : }
1087 : : case ::svt::BBTYPE_CHECKBOXCELL:
1088 : : {
1089 : 0 : break; // checkbox cells have no name
1090 : : }
1091 : : case ::svt::BBTYPE_COLUMNHEADERCELL:
1092 : : {
1093 [ # # ][ # # ]: 0 : aRetText = m_pImpl->m_pHeaderBar->GetItemText( m_pImpl->m_pHeaderBar->GetItemId( (sal_uInt16)_nPos ) );
[ # # ][ # # ]
1094 : 0 : break;
1095 : : }
1096 : :
1097 : : case ::svt::BBTYPE_ROWHEADERBAR:
1098 : : case ::svt::BBTYPE_ROWHEADERCELL:
1099 [ # # ]: 0 : aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "error" ) );
1100 : 0 : break;
1101 : :
1102 : : default:
1103 : : OSL_FAIL("BrowseBox::GetAccessibleName: invalid enum!");
1104 : : }
1105 : 0 : return aRetText;
1106 : : }
1107 : : // -----------------------------------------------------------------------
1108 : 0 : ::rtl::OUString SvHeaderTabListBox::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos ) const
1109 : : {
1110 : 0 : ::rtl::OUString aRetText;
1111 : :
1112 [ # # ][ # # ]: 0 : if( _eType == ::svt::BBTYPE_TABLECELL && _nPos != -1 )
1113 : : {
1114 [ # # ]: 0 : const String sVar1( RTL_CONSTASCII_USTRINGPARAM( "%1" ) );
1115 [ # # ]: 0 : const String sVar2( RTL_CONSTASCII_USTRINGPARAM( "%2" ) );
1116 : :
1117 [ # # ]: 0 : sal_uInt16 nColumnCount = GetColumnCount();
1118 [ # # ]: 0 : if (nColumnCount > 0)
1119 : : {
1120 : 0 : sal_Int32 nRow = _nPos / nColumnCount;
1121 : 0 : sal_uInt16 nColumn = static_cast< sal_uInt16 >( _nPos % nColumnCount );
1122 : :
1123 [ # # ][ # # ]: 0 : String aText( SVT_RESSTR(STR_SVT_ACC_DESC_TABLISTBOX) );
[ # # ]
1124 [ # # ][ # # ]: 0 : aText.SearchAndReplace( sVar1, String::CreateFromInt32( nRow ) );
[ # # ]
1125 [ # # ][ # # ]: 0 : String sColHeader = m_pImpl->m_pHeaderBar->GetItemText( m_pImpl->m_pHeaderBar->GetItemId( nColumn ) );
1126 [ # # ]: 0 : if ( sColHeader.Len() == 0 )
1127 [ # # ][ # # ]: 0 : sColHeader = String::CreateFromInt32( nColumn );
[ # # ]
1128 [ # # ]: 0 : aText.SearchAndReplace( sVar2, sColHeader );
1129 [ # # ][ # # ]: 0 : aRetText = aText;
[ # # ]
1130 [ # # ][ # # ]: 0 : }
1131 : : }
1132 : :
1133 : 0 : return aRetText;
1134 : : }
1135 : : // -----------------------------------------------------------------------
1136 : 0 : void SvHeaderTabListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::svt::AccessibleBrowseBoxObjType _eType ) const
1137 : : {
1138 [ # # # # ]: 0 : switch( _eType )
1139 : : {
1140 : : case ::svt::BBTYPE_BROWSEBOX:
1141 : : case ::svt::BBTYPE_TABLE:
1142 : : {
1143 : 0 : _rStateSet.AddState( AccessibleStateType::FOCUSABLE );
1144 [ # # ]: 0 : if ( HasFocus() )
1145 : 0 : _rStateSet.AddState( AccessibleStateType::FOCUSED );
1146 [ # # ]: 0 : if ( IsActive() )
1147 : 0 : _rStateSet.AddState( AccessibleStateType::ACTIVE );
1148 [ # # ]: 0 : if ( IsEnabled() )
1149 : : {
1150 : 0 : _rStateSet.AddState( AccessibleStateType::ENABLED );
1151 : 0 : _rStateSet.AddState( AccessibleStateType::SENSITIVE );
1152 : : }
1153 [ # # ]: 0 : if ( IsReallyVisible() )
1154 : 0 : _rStateSet.AddState( AccessibleStateType::VISIBLE );
1155 [ # # ]: 0 : if ( _eType == ::svt::BBTYPE_TABLE )
1156 : : {
1157 : :
1158 [ # # ]: 0 : if ( AreChildrenTransient() )
1159 : 0 : _rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
1160 : 0 : _rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
1161 : : }
1162 : 0 : break;
1163 : : }
1164 : :
1165 : : case ::svt::BBTYPE_COLUMNHEADERBAR:
1166 : : {
1167 : 0 : sal_Int32 nCurRow = GetCurrRow();
1168 : 0 : sal_uInt16 nCurColumn = GetCurrColumn();
1169 [ # # ]: 0 : if ( IsCellVisible( nCurRow, nCurColumn ) )
1170 : 0 : _rStateSet.AddState( AccessibleStateType::VISIBLE );
1171 : 0 : _rStateSet.AddState( AccessibleStateType::TRANSIENT );
1172 : 0 : break;
1173 : : }
1174 : :
1175 : : case ::svt::BBTYPE_ROWHEADERCELL:
1176 : : case ::svt::BBTYPE_COLUMNHEADERCELL:
1177 : : {
1178 : 0 : _rStateSet.AddState( AccessibleStateType::VISIBLE );
1179 : 0 : _rStateSet.AddState( AccessibleStateType::FOCUSABLE );
1180 : 0 : _rStateSet.AddState( AccessibleStateType::TRANSIENT );
1181 : 0 : break;
1182 : : }
1183 : : default:
1184 : 0 : break;
1185 : : }
1186 : 0 : }
1187 : : // -----------------------------------------------------------------------
1188 : 0 : void SvHeaderTabListBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const
1189 : : {
1190 : 0 : _rStateSet.AddState( AccessibleStateType::SELECTABLE );
1191 [ # # ]: 0 : if ( AreChildrenTransient() )
1192 : 0 : _rStateSet.AddState( AccessibleStateType::TRANSIENT );
1193 : :
1194 [ # # ]: 0 : if ( IsCellVisible( _nRow, _nColumn ) )
1195 : : {
1196 : 0 : _rStateSet.AddState( AccessibleStateType::VISIBLE );
1197 : 0 : _rStateSet.AddState( AccessibleStateType::ENABLED );
1198 : : }
1199 : :
1200 [ # # ]: 0 : if ( IsRowSelected( _nRow ) )
1201 : : {
1202 : 0 : _rStateSet.AddState( AccessibleStateType::ACTIVE );
1203 : 0 : _rStateSet.AddState( AccessibleStateType::SELECTED );
1204 : : }
1205 : 0 : }
1206 : : // -----------------------------------------------------------------------
1207 : 0 : void SvHeaderTabListBox::GrabTableFocus()
1208 : : {
1209 : 0 : GrabFocus();
1210 : 0 : }
1211 : : // -----------------------------------------------------------------------
1212 : 0 : sal_Bool SvHeaderTabListBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector )
1213 : : {
1214 : 0 : return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector );
1215 : : }
1216 : : // -----------------------------------------------------------------------
1217 : 0 : Rectangle SvHeaderTabListBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const
1218 : : {
1219 : 0 : return Control::GetWindowExtentsRelative( pRelativeWindow );
1220 : : }
1221 : : // -----------------------------------------------------------------------
1222 : 0 : void SvHeaderTabListBox::GrabFocus()
1223 : : {
1224 : 0 : Control::GrabFocus();
1225 : 0 : }
1226 : : // -----------------------------------------------------------------------
1227 : 0 : Reference< XAccessible > SvHeaderTabListBox::GetAccessible( sal_Bool bCreate )
1228 : : {
1229 : 0 : return Control::GetAccessible( bCreate );
1230 : : }
1231 : : // -----------------------------------------------------------------------
1232 : 0 : Window* SvHeaderTabListBox::GetAccessibleParentWindow() const
1233 : : {
1234 : 0 : return Control::GetAccessibleParentWindow();
1235 : : }
1236 : : // -----------------------------------------------------------------------
1237 : 0 : Window* SvHeaderTabListBox::GetWindowInstance()
1238 : : {
1239 : 0 : return this;
1240 : : }
1241 : : // -----------------------------------------------------------------------
1242 : 0 : Reference< XAccessible > SvHeaderTabListBox::CreateAccessible()
1243 : : {
1244 : 0 : Window* pParent = GetAccessibleParentWindow();
1245 : : DBG_ASSERT( pParent, "SvHeaderTabListBox::::CreateAccessible - accessible parent not found" );
1246 : :
1247 : 0 : Reference< XAccessible > xAccessible;
1248 [ # # ][ # # ]: 0 : if ( m_pAccessible ) xAccessible = m_pAccessible->getMyself();
[ # # ]
1249 : :
1250 [ # # ][ # # ]: 0 : if( pParent && !m_pAccessible )
1251 : : {
1252 [ # # ]: 0 : Reference< XAccessible > xAccParent = pParent->GetAccessible();
1253 [ # # ]: 0 : if ( xAccParent.is() )
1254 : : {
1255 [ # # ][ # # ]: 0 : m_pAccessible = m_pImpl->m_aFactoryAccess.getFactory().createAccessibleTabListBox( xAccParent, *this );
1256 [ # # ]: 0 : if ( m_pAccessible )
1257 [ # # ][ # # ]: 0 : xAccessible = m_pAccessible->getMyself();
1258 : 0 : }
1259 : : }
1260 : 0 : return xAccessible;
1261 : : }
1262 : : // -----------------------------------------------------------------------------
1263 : 0 : Rectangle SvHeaderTabListBox::GetFieldCharacterBounds(sal_Int32,sal_Int32,sal_Int32)
1264 : : {
1265 : 0 : Rectangle aRect;
1266 : 0 : return aRect;
1267 : : }
1268 : : // -----------------------------------------------------------------------------
1269 : 0 : sal_Int32 SvHeaderTabListBox::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
1270 : : {
1271 [ # # ]: 0 : String sText = GetAccessibleCellText( _nRow, static_cast< sal_uInt16 >( _nColumnPos ) );
1272 [ # # ]: 0 : MetricVector aRects;
1273 [ # # ][ # # ]: 0 : if ( GetGlyphBoundRects(Point(0,0),sText,0,STRING_LEN,0,aRects) )
1274 : : {
1275 [ # # ][ # # ]: 0 : for (MetricVector::iterator aIter = aRects.begin(); aIter != aRects.end(); ++aIter)
[ # # ]
1276 : : {
1277 [ # # ][ # # ]: 0 : if( aIter->IsInside(_rPoint) )
[ # # ]
1278 [ # # ]: 0 : return aIter - aRects.begin();
1279 : : }
1280 : : }
1281 : :
1282 [ # # ]: 0 : return -1;
1283 : : }
1284 : : // -----------------------------------------------------------------------------
1285 : :
1286 : :
1287 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|