LibreOffice Module toolkit (master) 1
unocontroltablemodel.cxx
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
22
25
26#include <com/sun/star/awt/grid/XSortableGridData.hpp>
27#include <com/sun/star/util/Color.hpp>
28#include <o3tl/safeint.hxx>
29#include <sal/log.hxx>
31#include <tools/debug.hxx>
33
34
35namespace svt::table
36{
37
38
39 using css::uno::Reference;
40 using css::uno::Sequence;
41 using css::uno::UNO_QUERY_THROW;
42 using css::uno::UNO_QUERY;
43 using css::awt::grid::XGridColumn;
44 using css::uno::Exception;
45 using css::awt::grid::XGridDataModel;
46 using css::awt::grid::XGridColumnModel;
47 using css::uno::Any;
48 using css::style::VerticalAlignment_TOP;
49 using css::style::VerticalAlignment;
50 using css::awt::grid::GridDataEvent;
51 using css::awt::grid::XSortableGridData;
52 using css::beans::Pair;
53
54
55 //= UnoControlTableModel
56#define DBG_CHECK_ME() \
57 DBG_TESTSOLARMUTEX(); \
58
60 :aColumns ( )
61 ,bHasColumnHeaders ( true )
62 ,bHasRowHeaders ( false )
63 ,eVScrollMode ( ScrollbarShowNever )
64 ,eHScrollMode ( ScrollbarShowNever )
65 ,pRenderer ( )
66 ,pInputHandler ( )
67 ,nRowHeight ( 10 )
68 ,nColumnHeaderHeight ( 10 )
69 ,nRowHeaderWidth ( 10 )
70 ,m_aGridLineColor ( )
71 ,m_aHeaderBackgroundColor ( )
72 ,m_aHeaderTextColor ( )
73 ,m_aActiveSelectionBackColor ( )
74 ,m_aInactiveSelectionBackColor ( )
75 ,m_aActiveSelectionTextColor ( )
76 ,m_aInactiveSelectionTextColor ( )
77 ,m_aTextColor ( )
78 ,m_aTextLineColor ( )
79 ,m_aRowColors ( )
80 ,m_eVerticalAlign ( VerticalAlignment_TOP )
81 ,bEnabled ( true )
82 {
83 pRenderer = std::make_shared<GridTableRenderer>( *this );
84 pInputHandler = std::make_shared<DefaultInputHandler>();
85 }
86
87
89 {
90 }
91
92
94 {
96 return static_cast<TableSize>(aColumns.size());
97 }
98
99
101 {
102 DBG_CHECK_ME();
103
104 TableSize nRowCount = 0;
105 try
106 {
107 Reference< XGridDataModel > const xDataModel( m_aDataModel );
108 ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
109 nRowCount = xDataModel->getRowCount();
110 }
111 catch( const Exception& )
112 {
113 DBG_UNHANDLED_EXCEPTION("svtools.uno");
114 }
115 return nRowCount;
116 }
117
118
120 {
121 DBG_CHECK_ME();
122 return bHasColumnHeaders;
123 }
124
125
127 {
128 DBG_CHECK_ME();
129 return bHasRowHeaders;
130 }
131
132
134 {
135 DBG_CHECK_ME();
136 if ( bHasRowHeaders == _bRowHeaders )
137 return;
138
139 bHasRowHeaders = _bRowHeaders;
141 }
142
143
144 void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders)
145 {
146 DBG_CHECK_ME();
147 if ( bHasColumnHeaders == _bColumnHeaders )
148 return;
149
150 bHasColumnHeaders = _bColumnHeaders;
152 }
153
154
156 {
157 DBG_CHECK_ME();
158 ENSURE_OR_RETURN( ( column >= 0 ) && ( column < getColumnCount() ),
159 "DefaultTableModel::getColumnModel: invalid index!", PColumnModel() );
160 return aColumns[ column ];
161 }
162
163
164 void UnoControlTableModel::appendColumn( Reference< XGridColumn > const & i_column )
165 {
166 DBG_CHECK_ME();
167 insertColumn( aColumns.size(), i_column );
168 }
169
170
171 void UnoControlTableModel::insertColumn( ColPos const i_position, Reference< XGridColumn > const & i_column )
172 {
173 DBG_CHECK_ME();
174 ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( o3tl::make_unsigned( i_position ) <= aColumns.size() ),
175 "UnoControlTableModel::insertColumn: illegal position!" );
176
177 const PColumnModel pColumn = std::make_shared<UnoGridColumnFacade>( *this, i_column );
178 aColumns.insert( aColumns.begin() + i_position, pColumn );
179
180 // notify listeners
182 for (auto const& listener : aListeners)
183 {
184 listener->columnInserted();
185 }
186 }
187
188
190 {
191 DBG_CHECK_ME();
192 ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( o3tl::make_unsigned( i_position ) <= aColumns.size() ),
193 "UnoControlTableModel::removeColumn: illegal position!" );
194
195 // remove the column
196 ColumnModels::iterator pos = aColumns.begin() + i_position;
197 const PColumnModel pColumn = *pos;
198 aColumns.erase( pos );
199
200 // notify listeners
202 for (auto const& listener : aListeners)
203 {
204 listener->columnRemoved();
205 }
206
207 // dispose the column
208 UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
209 OSL_ENSURE( pColumnImpl != nullptr, "UnoControlTableModel::removeColumn: illegal column implementation!" );
210 if ( pColumnImpl )
211 pColumnImpl->dispose();
212 }
213
214
216 {
217 DBG_CHECK_ME();
218 if ( aColumns.empty() )
219 return;
220
221 // dispose the column instances
222 for (auto const& col : aColumns)
223 {
224 UnoGridColumnFacade* pColumn = dynamic_cast< UnoGridColumnFacade* >( col.get() );
225 if ( !pColumn )
226 {
227 SAL_WARN( "svtools.uno", "UnoControlTableModel::removeAllColumns: illegal column implementation!" );
228 continue;
229 }
230
231 pColumn->dispose();
232 }
233 aColumns.clear();
234
235 // notify listeners
237 for (auto const& listener : aListeners)
238 {
239 listener->allColumnsRemoved();
240 }
241 }
242
243
245 {
247 for (auto const& listener : aListeners)
248 {
249 listener->tableMetricsChanged();
250 }
251 }
252
253
255 {
256 DBG_CHECK_ME();
257 return pRenderer;
258 }
259
260
262 {
263 DBG_CHECK_ME();
264 return pInputHandler;
265 }
266
267
269 {
270 DBG_CHECK_ME();
271 return nRowHeight;
272 }
273
274
276 {
277 DBG_CHECK_ME();
278 if ( nRowHeight == _nRowHeight )
279 return;
280
281 nRowHeight = _nRowHeight;
283 }
284
285
287 {
288 DBG_CHECK_ME();
289 DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" );
290 return nColumnHeaderHeight;
291 }
292
293
295 {
296 DBG_CHECK_ME();
297 DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
298 return nRowHeaderWidth;
299 }
300
302 {
303 DBG_CHECK_ME();
304 if ( nColumnHeaderHeight == _nHeight )
305 return;
306
307 nColumnHeaderHeight = _nHeight;
309 }
310
311
313 {
314 DBG_CHECK_ME();
315 if ( nRowHeaderWidth == _nWidth )
316 return;
317
318 nRowHeaderWidth = _nWidth;
320 }
321
322
324 {
325 DBG_CHECK_ME();
326 return eVScrollMode;
327 }
328
329
331 {
332 DBG_CHECK_ME();
333 return eHScrollMode;
334 }
335
336
338 {
339 DBG_CHECK_ME();
340 ENSURE_OR_RETURN_VOID( !!i_listener, "illegal NULL listener" );
341 m_aListeners.push_back( i_listener );
342 }
343
344
346 {
347 DBG_CHECK_ME();
348 auto lookup = std::find(m_aListeners.begin(), m_aListeners.end(), i_listener);
349 if (lookup != m_aListeners.end())
350 {
351 m_aListeners.erase( lookup );
352 return;
353 }
354 OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" );
355 }
356
357
359 {
360 DBG_CHECK_ME();
361 eVScrollMode = i_visibility;
362 }
363
364
366 {
367 DBG_CHECK_ME();
368 eHScrollMode = i_visibility;
369 }
370
371
372 void UnoControlTableModel::setDataModel( Reference< XGridDataModel > const & i_gridDataModel )
373 {
374 DBG_CHECK_ME();
375 m_aDataModel = i_gridDataModel;
376 // TODO: register as listener, so we're notified of row/data changes, and can multiplex them to our
377 // own listeners
378 }
379
380
381 Reference< XGridDataModel > UnoControlTableModel::getDataModel() const
382 {
383 Reference< XGridDataModel > const xDataModel( m_aDataModel );
384 return xDataModel;
385 }
386
387
389 {
390 return getDataModel().is();
391 }
392
393
394 void UnoControlTableModel::setColumnModel( Reference< XGridColumnModel > const & i_gridColumnModel )
395 {
396 DBG_CHECK_ME();
397 m_aColumnModel = i_gridColumnModel;
398 }
399
400
401 Reference< XGridColumnModel > UnoControlTableModel::getColumnModel() const
402 {
403 Reference< XGridColumnModel > const xColumnModel( m_aColumnModel );
404 return xColumnModel;
405 }
406
407
409 {
410 return getColumnModel().is();
411 }
412
413
414 void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent )
415 {
416 DBG_CHECK_ME();
417
418 o_cellContent.clear();
419 try
420 {
421 Reference< XGridDataModel > const xDataModel( m_aDataModel );
422 ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::getCellContent: no data model anymore!" );
423
424 PColumnModel const pColumn = getColumnModel( i_col );
425 UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
426 ENSURE_OR_RETURN_VOID( pColumnImpl != nullptr, "UnoControlTableModel::getCellContent: no (valid) column at this position!" );
427 sal_Int32 const nDataColumnIndex = pColumnImpl->getDataColumnIndex() >= 0 ? pColumnImpl->getDataColumnIndex() : i_col;
428
429 if ( nDataColumnIndex >= xDataModel->getColumnCount() )
430 {
431 // this is allowed, in case the column model has been dynamically extended, but the data model does
432 // not (yet?) know about it.
433 // So, handle it gracefully.
434 #if OSL_DEBUG_LEVEL > 0
435 Reference< XGridColumnModel > const xColumnModel( m_aColumnModel );
436 OSL_ENSURE( xColumnModel.is() && i_col < xColumnModel->getColumnCount(),
437 "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" );
438 #endif
439 }
440 else
441 {
442 o_cellContent = xDataModel->getCellData( nDataColumnIndex, i_row );
443 }
444 }
445 catch( const Exception& )
446 {
447 DBG_UNHANDLED_EXCEPTION("svtools.uno");
448 }
449 }
450
451
452 void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip )
453 {
454 DBG_CHECK_ME();
455 try
456 {
457 Reference< XGridDataModel > const xDataModel( m_aDataModel );
458 ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
459
460 o_cellToolTip = xDataModel->getCellToolTip( i_col, i_row );
461 }
462 catch( const Exception& )
463 {
464 DBG_UNHANDLED_EXCEPTION("svtools.uno");
465 }
466 }
467
468
470 {
471 DBG_CHECK_ME();
472
473 Any aRowHeading;
474
475 Reference< XGridDataModel > const xDataModel( m_aDataModel );
476 ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeading: no data model anymore!", aRowHeading );
477
478 try
479 {
480 aRowHeading = xDataModel->getRowHeading( i_rowPos );
481 }
482 catch( const Exception& )
483 {
484 DBG_UNHANDLED_EXCEPTION("svtools.uno");
485 }
486 return aRowHeading;
487 }
488
489
490 namespace
491 {
492 void lcl_setColor( Any const & i_color, ::std::optional< ::Color > & o_convertedColor )
493 {
494 if ( !i_color.hasValue() )
495 o_convertedColor.reset();
496 else
497 {
498 Color nColor = COL_TRANSPARENT;
499 if ( i_color >>= nColor )
500 {
501 o_convertedColor = nColor;
502 }
503 else
504 {
505 OSL_ENSURE( false, "lcl_setColor: could not extract color value!" );
506 }
507 }
508 }
509 }
510
511
512 ::std::optional< ::Color > UnoControlTableModel::getLineColor() const
513 {
514 DBG_CHECK_ME();
515 return m_aGridLineColor;
516 }
517
518
519 void UnoControlTableModel::setLineColor( Any const & i_color )
520 {
521 DBG_CHECK_ME();
522 lcl_setColor( i_color, m_aGridLineColor );
523 }
524
525
526 ::std::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const
527 {
528 DBG_CHECK_ME();
530 }
531
532
534 {
535 DBG_CHECK_ME();
536 lcl_setColor( i_color, m_aHeaderBackgroundColor );
537 }
538
539
540 ::std::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const
541 {
542 DBG_CHECK_ME();
543 return m_aHeaderTextColor;
544 }
545
546
547 ::std::optional< ::Color > UnoControlTableModel::getActiveSelectionBackColor() const
548 {
549 DBG_CHECK_ME();
551 }
552
553
555 {
556 DBG_CHECK_ME();
558 }
559
560
561 ::std::optional< ::Color > UnoControlTableModel::getActiveSelectionTextColor() const
562 {
563 DBG_CHECK_ME();
565 }
566
567
569 {
570 DBG_CHECK_ME();
572 }
573
574
576 {
577 DBG_CHECK_ME();
578 lcl_setColor( i_color, m_aHeaderTextColor );
579 }
580
581
583 {
584 DBG_CHECK_ME();
585 lcl_setColor( i_color, m_aActiveSelectionBackColor );
586 }
587
588
590 {
591 DBG_CHECK_ME();
592 lcl_setColor( i_color, m_aInactiveSelectionBackColor );
593 }
594
595
597 {
598 DBG_CHECK_ME();
599 lcl_setColor( i_color, m_aActiveSelectionTextColor );
600 }
601
602
604 {
605 DBG_CHECK_ME();
606 lcl_setColor( i_color, m_aInactiveSelectionTextColor );
607 }
608
609
610 ::std::optional< ::Color > UnoControlTableModel::getTextColor() const
611 {
612 DBG_CHECK_ME();
613 return m_aTextColor;
614 }
615
616
617 void UnoControlTableModel::setTextColor( Any const & i_color )
618 {
619 DBG_CHECK_ME();
620 lcl_setColor( i_color, m_aTextColor );
621 }
622
623
624 ::std::optional< ::Color > UnoControlTableModel::getTextLineColor() const
625 {
626 DBG_CHECK_ME();
627 return m_aTextColor;
628 }
629
630
631 void UnoControlTableModel::setTextLineColor( Any const & i_color )
632 {
633 DBG_CHECK_ME();
634 lcl_setColor( i_color, m_aTextLineColor );
635 }
636
637
638 ::std::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const
639 {
640 DBG_CHECK_ME();
641 return m_aRowColors;
642 }
643
644
645 void UnoControlTableModel::setRowBackgroundColors( css::uno::Any const & i_APIValue )
646 {
647 DBG_CHECK_ME();
648 Sequence< css::util::Color > aAPIColors;
649 if ( !( i_APIValue >>= aAPIColors ) )
650 m_aRowColors.reset();
651 else
652 {
653 ::std::vector< ::Color > aColors( aAPIColors.getLength() );
654 std::transform(std::cbegin(aAPIColors), std::cend(aAPIColors), aColors.begin(),
655 [](const css::util::Color& rAPIColor) -> ::Color { return Color(ColorTransparency, rAPIColor); });
656 m_aRowColors = aColors;
657 }
658 }
659
660
662 {
663 DBG_CHECK_ME();
664 return m_eVerticalAlign;
665 }
666
667
668 void UnoControlTableModel::setVerticalAlign( VerticalAlignment _xAlign )
669 {
670 DBG_CHECK_ME();
671 m_eVerticalAlign = _xAlign;
672 }
673
674
676 {
677 DBG_CHECK_ME();
678 ColPos nPos = 0;
679 for (auto const& col : aColumns)
680 {
681 if ( &i_column == col.get() )
682 return nPos;
683 ++nPos;
684 }
685 OSL_ENSURE( false, "UnoControlTableModel::getColumnPos: column not found!" );
686 return COL_INVALID;
687 }
688
689
691 {
692 DBG_CHECK_ME();
693
694 Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY );
695 if ( xSortAccess.is() )
696 return this;
697 return nullptr;
698 }
699
700
702 {
703 DBG_CHECK_ME();
704 return bEnabled;
705 }
706
707
708 void UnoControlTableModel::setEnabled( bool _bEnabled )
709 {
710 DBG_CHECK_ME();
711 bEnabled = _bEnabled;
712 }
713
714
715 void UnoControlTableModel::sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection )
716 {
717 DBG_CHECK_ME();
718
719 try
720 {
721 Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
722 xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending );
723 }
724 catch( const Exception& )
725 {
726 DBG_UNHANDLED_EXCEPTION("svtools.uno");
727 }
728 }
729
730
732 {
733 DBG_CHECK_ME();
734
735 ColumnSort currentSort;
736 try
737 {
738 Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
739 Pair< ::sal_Int32, sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() );
740 currentSort.nColumnPos = aCurrentSortOrder.First;
741 currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending;
742 }
743 catch( const Exception& )
744 {
745 DBG_UNHANDLED_EXCEPTION("svtools.uno");
746 }
747 return currentSort;
748 }
749
750
751 void UnoControlTableModel::notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const
752 {
753 DBG_CHECK_ME();
754 ENSURE_OR_RETURN_VOID( ( i_columnPos >= 0 ) && ( i_columnPos < getColumnCount() ),
755 "UnoControlTableModel::notifyColumnChange: invalid column index!" );
756
758 for (auto const& listener : aListeners)
759 {
760 listener->columnChanged( i_columnPos, i_attributeGroup );
761 }
762 }
763
764
765 void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) const
766 {
767 // check sanity of the event
768 ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" );
769 ENSURE_OR_RETURN_VOID( i_event.LastRow >= i_event.FirstRow, "UnoControlTableModel::notifyRowsInserted: invalid row indexes!" );
770
771 // check own sanity
772 Reference< XGridColumnModel > const xColumnModel( m_aColumnModel );
773 ENSURE_OR_RETURN_VOID( xColumnModel.is(), "UnoControlTableModel::notifyRowsInserted: no column model anymore!" );
774
775 Reference< XGridDataModel > const xDataModel( m_aDataModel );
776 ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::notifyRowsInserted: no data model anymore!" );
777
778 // implicitly add columns to the column model
779 // TODO: is this really a good idea?
780 sal_Int32 const dataColumnCount = xDataModel->getColumnCount();
781 OSL_ENSURE( dataColumnCount > 0, "UnoControlTableModel::notifyRowsInserted: no columns at all?" );
782
783 sal_Int32 const modelColumnCount = xColumnModel->getColumnCount();
784 if ( ( modelColumnCount == 0 ) && ( dataColumnCount > 0 ) )
785 {
786 // TODO: shouldn't we clear the mutexes guard for this call?
787 xColumnModel->setDefaultColumns( dataColumnCount );
788 }
789
790 // multiplex the event to our own listeners
792 for (auto const& listener : aListeners)
793 {
794 listener->rowsInserted( i_event.FirstRow, i_event.LastRow );
795 }
796 }
797
798
799 void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) const
800 {
802 for (auto const& listener : aListeners)
803 {
804 listener->rowsRemoved( i_event.FirstRow, i_event.LastRow );
805 }
806 }
807
808
809 void UnoControlTableModel::notifyDataChanged( css::awt::grid::GridDataEvent const & i_event ) const
810 {
811 RowPos const firstRow = i_event.FirstRow == -1 ? 0 : i_event.FirstRow;
812 RowPos const lastRow = i_event.FirstRow == -1 ? getRowCount() - 1 : i_event.LastRow;
813
815 for (auto const& listener : aListeners)
816 {
817 listener->cellsUpdated( firstRow, lastRow );
818 }
819 }
820
821
823 {
825 for (auto const& listener : aListeners)
826 {
827 listener->cellsUpdated( 0, getRowCount() - 1 );
828 }
829 }
830
831
832} // svt::table
833
834/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
provides sorting functionality for the data underlying an ITableModel
Definition: tablesort.hxx:58
virtual PTableInputHandler getInputHandler() const override
returns the component handling input in a view associated with the model
void notifyRowsInserted(css::awt::grid::GridDataEvent const &i_event) const
::std::optional< ::std::vector< ::Color > > m_aRowColors
virtual ScrollbarVisibility getVerticalScrollbarVisibility() const override
returns the visibility mode of the vertical scrollbar
void setActiveSelectionTextColor(css::uno::Any const &i_color)
virtual TableMetrics getRowHeight() const override
determines the height of rows in the table.
virtual void addTableModelListener(const PTableModelListener &i_listener) override
adds a listener to be notified of changes in the table model
virtual ::std::optional< ::Color > getHeaderBackgroundColor() const override
returns the color to be used for rendering the header background.
virtual bool hasColumnHeaders() const override
determines whether the table has column headers
void setVerticalAlign(css::style::VerticalAlignment _rAlign)
virtual ::std::optional< ::Color > getActiveSelectionTextColor() const override
returns the color to be used for the text of selected cells, when the control has the focus
::std::optional< ::Color > m_aActiveSelectionTextColor
virtual ::std::optional< ::std::vector< ::Color > > getRowBackgroundColors() const override
returns the colors to be used for the row backgrounds.
::std::optional< ::Color > m_aGridLineColor
virtual TableSize getColumnCount() const override
returns the number of columns in the table
void setVerticalScrollbarVisibility(ScrollbarVisibility const i_visibility)
void notifyRowsRemoved(css::awt::grid::GridDataEvent const &i_event) const
void setTextColor(css::uno::Any const &i_color)
void setTextLineColor(css::uno::Any const &i_color)
virtual TableSize getRowCount() const override
returns the number of rows in the table
::std::optional< ::Color > m_aHeaderBackgroundColor
void setHeaderBackgroundColor(css::uno::Any const &i_color)
virtual void removeTableModelListener(const PTableModelListener &i_listener) override
remove a listener to be notified of changes in the table model
virtual void getCellToolTip(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellToolTip) override
returns an object which should be displayed as tooltip for the given cell
virtual css::uno::Any getRowHeading(RowPos const i_rowPos) const override
retrieves title of a given row
virtual ::std::optional< ::Color > getInactiveSelectionBackColor() const override
returns the color to be used for the background of selected cells, when the control does not have the...
::std::optional< ::Color > m_aHeaderTextColor
virtual ::std::optional< ::Color > getHeaderTextColor() const override
returns the color to be used for rendering the header text.
void setRowHeaderWidth(TableMetrics _nWidth)
virtual TableMetrics getColumnHeaderHeight() const override
determines the height of the column header row
ColPos getColumnPos(UnoGridColumnFacade const &i_column) const
retrieves the index of a column within the model
::std::optional< ::Color > m_aInactiveSelectionBackColor
void setColumnHeaderHeight(TableMetrics _nHeight)
void setDataModel(css::uno::Reference< css::awt::grid::XGridDataModel > const &i_gridDataModel)
void setInactiveSelectionBackColor(css::uno::Any const &i_color)
virtual TableMetrics getRowHeaderWidth() const override
determines the width of the row header column
void notifyAllDataChanged() const
notifies a change in all data represented by the model.
virtual ::std::optional< ::Color > getActiveSelectionBackColor() const override
returns the color to be used for the background of selected cells, when the control has the focus
virtual css::style::VerticalAlignment getVerticalAlign() const override
determines the vertical alignment of content within a cell
void setHeaderTextColor(css::uno::Any const &i_color)
::std::optional< ::Color > m_aInactiveSelectionTextColor
css::uno::Reference< css::awt::grid::XGridColumnModel > getColumnModel() const
::std::optional< ::Color > m_aActiveSelectionBackColor
void setRowHeight(TableMetrics _nHeight)
::std::optional< ::Color > m_aTextLineColor
virtual ::std::optional< ::Color > getInactiveSelectionTextColor() const override
returns the color to be used for the text of selected cells, when the control does not have the focus
::std::optional< ::Color > m_aTextColor
css::style::VerticalAlignment m_eVerticalAlign
::std::vector< PTableModelListener > ModellListeners
void setColumnModel(css::uno::Reference< css::awt::grid::XGridColumnModel > const &i_gridColumnModel)
void setActiveSelectionBackColor(css::uno::Any const &i_color)
virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const override
returns the visibility mode of the horizontal scrollbar
css::uno::WeakReference< css::awt::grid::XGridDataModel > m_aDataModel
void insertColumn(ColPos const i_position, css::uno::Reference< css::awt::grid::XGridColumn > const &i_column)
void setInactiveSelectionTextColor(css::uno::Any const &i_color)
void setRowBackgroundColors(css::uno::Any const &i_APIValue)
void setHorizontalScrollbarVisibility(ScrollbarVisibility const i_visibility)
css::uno::Reference< css::awt::grid::XGridDataModel > getDataModel() const
virtual ::std::optional< ::Color > getLineColor() const override
returns the color to be used for rendering the grid lines.
virtual ::std::optional< ::Color > getTextLineColor() const override
returns the color to be used for text lines (underline, strikethrough) when rendering cell text.
void setLineColor(css::uno::Any const &i_color)
virtual void sortByColumn(ColPos const i_column, ColumnSortDirection const i_sortDirection) override
sorts the rows in the model by the given column's data, in the given direction.
virtual PTableRenderer getRenderer() const override
returns a renderer which is able to paint the table represented by this table model
void notifyDataChanged(css::awt::grid::GridDataEvent const &i_event) const
virtual ColumnSort getCurrentSortOrder() const override
retrieves the current sort order of the data
virtual ITableDataSort * getSortAdapter() override
returns an adapter to the sorting functionality of the model
virtual ::std::optional< ::Color > getTextColor() const override
returns the color to be used for rendering cell texts.
virtual bool isEnabled() const override
returns enabled state.
css::uno::WeakReference< css::awt::grid::XGridColumnModel > m_aColumnModel
void appendColumn(css::uno::Reference< css::awt::grid::XGridColumn > const &i_column)
virtual bool hasRowHeaders() const override
determines whether the table has row headers
void removeColumn(ColPos const i_position)
void setColumnHeaders(bool _bColumnHeaders)
void notifyColumnChange(ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup) const
notifies a change in a column belonging to the model
virtual void getCellContent(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellContent) override
retrieves the content of the given cell
void dispose()
disposes the column wrapper
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr sal_uInt16 nRowHeaderWidth
#define DBG_ASSERT(sCon, aError)
Listeners aListeners
#define ENSURE_OR_THROW(c, m)
#define ENSURE_OR_RETURN(c, m, r)
#define DBG_UNHANDLED_EXCEPTION(...)
#define ENSURE_OR_RETURN_VOID(c, m)
sal_uInt16 nPos
#define SAL_WARN(area, stream)
RttiCompleteObjectLocator col
@ Exception
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 TableSize
a value denoting the size of a table
Definition: tabletypes.hxx:29
@ ColumnSortDescending
Definition: tablesort.hxx:33
@ ColumnSortAscending
Definition: tablesort.hxx:32
sal_Int32 RowPos
a value denoting a row position within a table
Definition: tabletypes.hxx:34
std::shared_ptr< ITableRenderer > PTableRenderer
@ ScrollbarShowNever
enumeration value denoting that a scrollbar should never be visible, even if needed normally
Definition: tablemodel.hxx:65
sal_Int32 ColPos
a value denoting a column position within a table
Definition: tabletypes.hxx:32
std::shared_ptr< ITableInputHandler > PTableInputHandler
sal_Int32 TableMetrics
Definition: tabletypes.hxx:36
std::shared_ptr< IColumnModel > PColumnModel
Definition: tablemodel.hxx:234
std::shared_ptr< ITableModelListener > PTableModelListener
Definition: tablemodel.hxx:150
ColumnSortDirection eSortDirection
Definition: tablesort.hxx:42
ColumnAttributeGroup
Definition: tablemodel.hxx:42
#define COL_INVALID
denotes an invalid column index
Definition: tabletypes.hxx:44
#define DBG_CHECK_ME()
size_t pos