1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unocontroltablemodel.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_svtools.hxx"
33 #include "unocontroltablemodel.hxx"
34 #include <com/sun/star/view/SelectionType.hpp>
35 #include "svtools/table/gridtablerenderer.hxx"
36 #include "svtools/table/defaultinputhandler.hxx"
37 #include "svtools/table/tablecontrol.hxx"
38 #include <comphelper/sequence.hxx>
39 #include <rtl/ref.hxx>
40 #include <tools/debug.hxx>
41 #include <toolkit/helper/property.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <com/sun/star/awt/grid/XGridColumn.hpp>
45 using ::rtl::OUString
;
46 using namespace ::svt::table
;
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::awt::grid
;
50 using namespace ::svt::table
;
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::view
;
53 using namespace ::toolkit
;
55 class UnoControlTableColumn
: public IColumnModel
61 TableMetrics m_nWidth
;
62 TableMetrics m_nMinWidth
;
63 TableMetrics m_nMaxWidth
;
66 UnoControlTableColumn(Reference
<XGridColumn
>);
68 // IColumnModel overridables
69 virtual ColumnID
getID() const;
70 virtual bool setID( const ColumnID _nID
);
71 virtual String
getName() const;
72 virtual void setName( const String
& _rName
);
73 virtual bool isResizable() const;
74 virtual void setResizable( bool _bResizable
);
75 virtual TableMetrics
getWidth() const;
76 virtual void setWidth( TableMetrics _nWidth
);
77 virtual TableMetrics
getMinWidth() const;
78 virtual void setMinWidth( TableMetrics _nMinWidth
);
79 virtual TableMetrics
getMaxWidth() const;
80 virtual void setMaxWidth( TableMetrics _nMaxWidth
);
83 //--------------------------------------------------------------------
84 UnoControlTableColumn::UnoControlTableColumn(Reference
<XGridColumn
> m_xGridColumn
)
87 ,m_bIsResizable( false )
88 ,m_nWidth( 10 * 100 ) // 1 cm
89 ,m_nMinWidth( 0 ) // no min width
90 ,m_nMaxWidth( 0 ) // no max width
92 //m_nID = m_xGridColumn->getIdentifier();
93 //m_nWidth = m_xGridColumn->getColumnWidth();
94 m_sName
= m_xGridColumn
->getTitle();
97 //--------------------------------------------------------------------
98 ColumnID
UnoControlTableColumn::getID() const
103 //--------------------------------------------------------------------
104 bool UnoControlTableColumn::setID( const ColumnID _nID
)
106 // TODO: conflict check
109 // TODO: notifications?
114 //--------------------------------------------------------------------
115 String
UnoControlTableColumn::getName() const
120 //--------------------------------------------------------------------
121 void UnoControlTableColumn::setName( const String
& _rName
)
124 // TODO: notifications?
127 //--------------------------------------------------------------------
128 bool UnoControlTableColumn::isResizable() const
130 return m_bIsResizable
;
133 //--------------------------------------------------------------------
134 void UnoControlTableColumn::setResizable( bool _bResizable
)
136 m_bIsResizable
= _bResizable
;
137 // TODO: notifications?
140 //--------------------------------------------------------------------
141 TableMetrics
UnoControlTableColumn::getWidth() const
146 //--------------------------------------------------------------------
147 void UnoControlTableColumn::setWidth( TableMetrics _nWidth
)
150 // TODO: notifications?
153 //--------------------------------------------------------------------
154 TableMetrics
UnoControlTableColumn::getMinWidth() const
159 //--------------------------------------------------------------------
160 void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth
)
162 m_nMinWidth
= _nMinWidth
;
163 // TODO: notifications?
166 //--------------------------------------------------------------------
167 TableMetrics
UnoControlTableColumn::getMaxWidth() const
172 //--------------------------------------------------------------------
173 void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth
)
175 m_nMaxWidth
= _nMaxWidth
;
176 // TODO: notifications?
179 //====================================================================
180 //= DefaultTableModel_Impl
181 //====================================================================
182 struct UnoControlTableModel_Impl
184 ::std::vector
< PColumnModel
> aColumns
;
186 bool bHasColumnHeaders
;
188 PTableRenderer pRenderer
;
189 PTableInputHandler pInputHandler
;
190 TableMetrics nRowHeight
;
191 TableMetrics nColumnHeaderHeight
;
192 TableMetrics nRowHeaderWidth
;
193 std::vector
<rtl::OUString
> aRowHeadersTitle
;
194 std::vector
<std::vector
<rtl::OUString
> > aCellContent
;
196 UnoControlTableModel_Impl()
198 ,bHasColumnHeaders ( false )
199 ,bHasRowHeaders ( false )
202 ,nRowHeight ( 4 * 100 ) // 40 mm
203 ,nColumnHeaderHeight( 5 * 100 ) // 50 mm
204 ,nRowHeaderWidth ( 10 * 100 ) // 50 mm
205 ,aRowHeadersTitle ( 0 )
211 //====================================================================
212 //= UnoControlTableModel
213 //====================================================================
214 //--------------------------------------------------------------------
215 UnoControlTableModel::UnoControlTableModel()
216 :m_pImpl( new UnoControlTableModel_Impl
),
219 m_bHasColumnHeaders(false),
220 m_bHasRowHeaders(false),
224 m_pImpl
->bHasColumnHeaders
= m_bHasColumnHeaders
;
225 m_pImpl
->bHasRowHeaders
= m_bHasRowHeaders
;
226 m_pImpl
->pRenderer
.reset( new GridTableRenderer( *this ) );
227 m_pImpl
->pInputHandler
.reset( new DefaultInputHandler
);
230 //--------------------------------------------------------------------
231 UnoControlTableModel::~UnoControlTableModel()
236 //--------------------------------------------------------------------
237 TableSize
UnoControlTableModel::getColumnCount() const
239 m_pImpl
->aColumns
.resize( m_xColumnModel
->getColumnCount());
240 return (TableSize
)m_pImpl
->aColumns
.size();
243 //--------------------------------------------------------------------
244 TableSize
UnoControlTableModel::getRowCount() const
246 return m_pImpl
->nRowCount
;
249 //--------------------------------------------------------------------
250 bool UnoControlTableModel::hasColumnHeaders() const
252 return m_pImpl
->bHasColumnHeaders
;
255 //--------------------------------------------------------------------
256 bool UnoControlTableModel::hasRowHeaders() const
258 return m_pImpl
->bHasRowHeaders
;
261 //--------------------------------------------------------------------
262 void UnoControlTableModel::setRowHeaders(bool _bRowHeaders
)
264 m_pImpl
->bHasRowHeaders
= _bRowHeaders
;
266 //--------------------------------------------------------------------
267 void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders
)
269 m_pImpl
->bHasColumnHeaders
= _bColumnHeaders
;
272 void UnoControlTableModel::setColumnCount(TableSize _nColCount
)
274 m_pImpl
->aColumns
.resize( _nColCount
);
276 //--------------------------------------------------------------------
277 void UnoControlTableModel::setRowCount(TableSize _nRowCount
)
279 m_pImpl
->nRowCount
= _nRowCount
;
281 //--------------------------------------------------------------------
282 bool UnoControlTableModel::isCellEditable( ColPos col
, RowPos row
) const
289 //--------------------------------------------------------------------
290 void UnoControlTableModel::addTableModelListener( const PTableModelListener
& listener
)
293 //listener->onTableModelChanged(PTableModel(this));
295 DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" );
298 //--------------------------------------------------------------------
299 void UnoControlTableModel::removeTableModelListener( const PTableModelListener
& listener
)
303 DBG_ERROR( "DefaultTableModel::removeTableModelListener: not yet implemented!" );
306 //--------------------------------------------------------------------
307 PColumnModel
UnoControlTableModel::getColumnModel( ColPos column
)
309 DBG_ASSERT( ( column
>= 0 ) && ( column
< getColumnCount() ),
310 "DefaultTableModel::getColumnModel: invalid index!" );
311 return m_pImpl
->aColumns
[ column
];
314 //--------------------------------------------------------------------
315 PColumnModel
UnoControlTableModel::getColumnModelByID( ColumnID id
)
319 DBG_ERROR( "DefaultTableModel::getColumnModelByID: not yet implemented!" );
320 return PColumnModel();
323 //--------------------------------------------------------------------
324 PTableRenderer
UnoControlTableModel::getRenderer() const
326 return m_pImpl
->pRenderer
;
329 //--------------------------------------------------------------------
330 PTableInputHandler
UnoControlTableModel::getInputHandler() const
332 return m_pImpl
->pInputHandler
;
335 //--------------------------------------------------------------------
336 TableMetrics
UnoControlTableModel::getRowHeight() const
338 return m_pImpl
->nRowHeight
;
340 //--------------------------------------------------------------------
341 void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight
)
343 m_pImpl
->nRowHeight
= _nRowHeight
;
346 //--------------------------------------------------------------------
347 TableMetrics
UnoControlTableModel::getColumnHeaderHeight() const
349 DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" );
350 return m_pImpl
->nColumnHeaderHeight
;
353 //--------------------------------------------------------------------
354 TableMetrics
UnoControlTableModel::getRowHeaderWidth() const
356 DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
357 return m_pImpl
->nRowHeaderWidth
;
360 //--------------------------------------------------------------------
361 void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight
)
363 DBG_ASSERT( _nHeight
> 0, "DefaultTableModel::SetTitleHeight: invalid height value!" );
364 m_pImpl
->nColumnHeaderHeight
= _nHeight
;
365 // TODO: notification
368 //--------------------------------------------------------------------
369 void UnoControlTableModel::SetHandleWidth( TableMetrics _nWidth
)
371 DBG_ASSERT( _nWidth
> 0, "DefaultTableModel::SetHandleWidth: invalid width value!" );
372 m_pImpl
->nRowHeaderWidth
= _nWidth
;
373 // TODO: notification
376 //--------------------------------------------------------------------
377 ScrollbarVisibility
UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight
, int actHeight
) const
379 if(overAllHeight
>=actHeight
&& !m_bVScroll
)
380 return ScrollbarShowNever
;
382 return ScrollbarShowAlways
;
385 //--------------------------------------------------------------------
386 ScrollbarVisibility
UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth
, int actWidth
) const
388 if(overAllWidth
>=actWidth
&& !m_bHScroll
)
389 return ScrollbarShowNever
;
391 return ScrollbarShowAlways
;
393 //--------------------------------------------------------------------
394 void UnoControlTableModel::setCellContent(std::vector
<std::vector
<rtl::OUString
> > cellContent
)
396 if(cellContent
.empty())
398 unsigned int i
= m_pImpl
->aColumns
.size();
399 std::vector
<rtl::OUString
> emptyCells
;
402 cellContent
.push_back(emptyCells
);
406 std::vector
<rtl::OUString
> cCC
;
407 for(::std::vector
<std::vector
<rtl::OUString
> >::iterator iter
= cellContent
.begin(); iter
!= cellContent
.end();++iter
)
410 m_pImpl
->aCellContent
.push_back(cCC
);
414 std::vector
<std::vector
<rtl::OUString
> > UnoControlTableModel::getCellContent()
416 return m_pImpl
->aCellContent
;
419 //--------------------------------------------------------------------
420 void UnoControlTableModel::setRowHeaderName(std::vector
<rtl::OUString
> cellColumnContent
)
422 if(cellColumnContent
.empty())
424 unsigned int i
= m_pImpl
->aColumns
.size();
427 cellColumnContent
.push_back(rtl::OUString::createFromAscii(""));
431 for(::std::vector
<rtl::OUString
>::iterator iter
= cellColumnContent
.begin(); iter
!= cellColumnContent
.end();++iter
)
433 rtl::OUString s
= *iter
;
434 m_pImpl
->aRowHeadersTitle
.push_back(*iter
);
438 std::vector
<rtl::OUString
> UnoControlTableModel::getRowHeaderName()
440 return m_pImpl
->aRowHeadersTitle
;
443 ::com::sun::star::uno::Any
UnoControlTableModel::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
445 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
446 SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl
*, this ),
447 SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener
*, this ),
448 //SAL_STATIC_CAST( com::sun::star::lang::XEventListener*, this ),
449 //SAL_STATIC_CAST( com::sun::star::awt::XMouseListener*, this ),
450 SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider
*, this ) );
451 return (aRet
.hasValue() ? aRet
: VCLXWindow::queryInterface( rType
));
454 // ::com::sun::star::lang::XTypeProvider
455 IMPL_XTYPEPROVIDER_START( UnoControlTableModel
)
456 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridControl
>* ) NULL
),
457 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
>* ) NULL
),
458 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseListener
>* ) NULL
),
459 VCLXWindow::getTypes()
460 IMPL_XTYPEPROVIDER_END
462 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
> SAL_CALL
UnoControlTableModel::getColumnModel( ) throw (::com::sun::star::uno::RuntimeException
)
466 void SAL_CALL
UnoControlTableModel::setColumnModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
>& model
) throw (::com::sun::star::uno::RuntimeException
)
470 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
> SAL_CALL
UnoControlTableModel::getDataModel( ) throw (::com::sun::star::uno::RuntimeException
)
474 void SAL_CALL
UnoControlTableModel::setDataModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
>& model
) throw (::com::sun::star::uno::RuntimeException
)
478 sal_Int32 SAL_CALL
UnoControlTableModel::getItemIndexAtPoint(::sal_Int32 x
, ::sal_Int32 y
) throw (::com::sun::star::uno::RuntimeException
)
480 TableControl
* pTableControl
= (TableControl
*)GetWindow();
481 return pTableControl
->GetCurrentRow( Point(x
,y
) );
485 void SAL_CALL UnoControlTableModel::addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException)
487 VCLXWindow::addMouseListener( listener );
490 void SAL_CALL UnoControlTableModel::removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException)
492 VCLXWindow::removeMouseListener( listener );
496 void SAL_CALL UnoControlTableModel::mousePressed( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
500 void SAL_CALL UnoControlTableModel::mouseReleased( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
504 void SAL_CALL UnoControlTableModel::mouseEntered( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
508 void SAL_CALL UnoControlTableModel::mouseExited( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
513 void SAL_CALL
UnoControlTableModel::addSelectionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridSelectionListener
> & listener
) throw (::com::sun::star::uno::RuntimeException
)
518 void SAL_CALL
UnoControlTableModel::removeSelectionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridSelectionListener
> & listener
) throw (::com::sun::star::uno::RuntimeException
)
523 void UnoControlTableModel::setProperty( const ::rtl::OUString
& PropertyName
, const Any
& aValue
) throw(RuntimeException
)
525 ::vos::OGuard
aGuard( GetMutex() );
527 TableControl
* pTableControl
= (TableControl
*)GetWindow();
529 switch( GetPropertyId( PropertyName
) )
531 case BASEPROPERTY_GRID_SELECTIONMODE
:
533 SelectionType eSelectionType
;
534 if( aValue
>>= eSelectionType
)
536 SelectionMode eSelMode
;
537 switch( eSelectionType
)
539 case SelectionType_SINGLE
: eSelMode
= SINGLE_SELECTION
; break;
540 case SelectionType_RANGE
: eSelMode
= RANGE_SELECTION
; break;
541 case SelectionType_MULTI
: eSelMode
= MULTIPLE_SELECTION
; break;
542 // case SelectionType_NONE:
543 default: eSelMode
= NO_SELECTION
; break;
545 if( pTableControl
->getSelEngine()->GetSelectionMode() != eSelMode
)
546 pTableControl
->getSelEngine()->SetSelectionMode( eSelMode
);
550 case BASEPROPERTY_HSCROLL
:
552 sal_Bool bHScroll
= true;
553 if( aValue
>>= bHScroll
)
555 m_bHScroll
= bHScroll
;
559 case BASEPROPERTY_VSCROLL
:
561 sal_Bool bVScroll
= true;
562 if( aValue
>>= bVScroll
)
564 m_bVScroll
= bVScroll
;
568 case BASEPROPERTY_GRID_SHOWROWHEADER
:
570 sal_Bool rowHeader
= true;
571 if( aValue
>>= rowHeader
)
573 setRowHeaders(rowHeader
);
578 case BASEPROPERTY_GRID_SHOWCOLUMNHEADER
:
580 sal_Bool colHeader
= true;
581 if( aValue
>>= colHeader
)
583 setColumnHeaders(colHeader
);
587 case BASEPROPERTY_GRID_DATAMODEL
:
589 m_xDataModel
= Reference
< XGridDataModel
>( aValue
, UNO_QUERY
);
590 Sequence
<Sequence
< ::rtl::OUString
> > cellData
= m_xDataModel
->getData();
591 Sequence
<rtl::OUString
> rowData(0);
592 for(int i
= 0; i
< m_xDataModel
->getRowCount();++i
)
594 rowData
= cellData
[i
];
595 std::vector
<rtl::OUString
> newRow(
596 comphelper::sequenceToContainer
< std::vector
<rtl::OUString
> >(rowData
));
597 if(newRow
.size()<m_pImpl
->aColumns
.size())
598 newRow
.resize(m_pImpl
->aColumns
.size(),rtl::OUString::createFromAscii(""));
599 m_pImpl
->aCellContent
.push_back(newRow
);
601 Sequence
< ::rtl::OUString
> rowHeaders
= m_xDataModel
->getRowHeaders();
602 std::vector
< rtl::OUString
> newRow(
603 comphelper::sequenceToContainer
< std::vector
<rtl::OUString
> >(rowHeaders
));
604 m_pImpl
->nRowCount
= m_xDataModel
->getRowCount();
605 setRowHeaderName(newRow
);
608 case BASEPROPERTY_GRID_COLUMNMODEL
:
610 m_xColumnModel
= Reference
< XGridColumnModel
>( aValue
, UNO_QUERY
);
611 Sequence
<Reference
< XGridColumn
> > columns
= m_xColumnModel
->getColumns();
612 std::vector
<Reference
< XGridColumn
> > aNewColumns(
613 comphelper::sequenceToContainer
<std::vector
<Reference
< XGridColumn
> > >(columns
));
614 if(!m_pImpl
->aColumns
.empty())
615 m_pImpl
->aColumns
.clear();
616 for ( ::svt::table::ColPos col
= 0; col
< m_xColumnModel
->getColumnCount(); ++col
)
618 UnoControlTableColumn
* tableColumn
= new UnoControlTableColumn(aNewColumns
[col
]);
619 m_pImpl
->aColumns
.push_back((PColumnModel
)tableColumn
);
624 VCLXWindow::setProperty( PropertyName
, aValue
);
629 Any
UnoControlTableModel::getProperty( const ::rtl::OUString
& PropertyName
) throw(RuntimeException
)
631 ::vos::OGuard
aGuard( GetMutex() );
633 const sal_uInt16 nPropId
= GetPropertyId( PropertyName
);
634 TableControl
* pTableControl
= (TableControl
*)GetWindow();
639 case BASEPROPERTY_GRID_SELECTIONMODE
:
641 SelectionType eSelectionType
;
643 SelectionMode eSelMode
= pTableControl
->getSelEngine()->GetSelectionMode();
646 case SINGLE_SELECTION
: eSelectionType
= SelectionType_SINGLE
; break;
647 case RANGE_SELECTION
: eSelectionType
= SelectionType_RANGE
; break;
648 case MULTIPLE_SELECTION
:eSelectionType
= SelectionType_MULTI
; break;
649 // case NO_SELECTION:
650 default: eSelectionType
= SelectionType_NONE
; break;
652 return Any( eSelectionType
);
654 case BASEPROPERTY_GRID_SHOWROWHEADER
:
656 return Any ((sal_Bool
) pTableControl
->GetModel()->hasRowHeaders());
658 case BASEPROPERTY_GRID_SHOWCOLUMNHEADER
:
659 return Any ((sal_Bool
) pTableControl
->GetModel()->hasColumnHeaders());
660 case BASEPROPERTY_GRID_DATAMODEL
:
661 return Any ( m_xDataModel
);
662 case BASEPROPERTY_GRID_COLUMNMODEL
:
663 return Any ( m_xColumnModel
);
664 case BASEPROPERTY_HSCROLL
:
665 return Any ( m_bHScroll
);
666 case BASEPROPERTY_VSCROLL
:
667 return Any ( m_bVScroll
);
670 return VCLXWindow::getProperty( PropertyName
);
673 void UnoControlTableModel::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
)
675 PushPropertyIds( rIds
,
676 BASEPROPERTY_GRID_SHOWROWHEADER
,
677 BASEPROPERTY_GRID_SHOWCOLUMNHEADER
,
678 BASEPROPERTY_GRID_DATAMODEL
,
679 BASEPROPERTY_GRID_COLUMNMODEL
,
680 BASEPROPERTY_GRID_SELECTIONMODE
,
682 VCLXWindow::ImplGetPropertyIds( rIds
, true );
684 void SAL_CALL
UnoControlTableModel::setVisible( sal_Bool bVisible
) throw(::com::sun::star::uno::RuntimeException
)
686 TableControl
* pTable
= (TableControl
*)GetWindow();
689 pTable
->SetModel(PTableModel(this));
690 pTable
->Show( bVisible
);
693 void SAL_CALL
UnoControlTableModel::setFocus() throw(::com::sun::star::uno::RuntimeException
)
695 ::vos::OGuard
aGuard( GetMutex() );
697 GetWindow()->GrabFocus();
699 void SAL_CALL
UnoControlTableModel::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
701 std::vector
<OUString
> aNewRow(
702 comphelper::sequenceToContainer
< std::vector
<rtl::OUString
> >(Event
.rowData
));
703 if(aNewRow
.size()<m_pImpl
->aColumns
.size())
704 aNewRow
.resize(m_pImpl
->aColumns
.size(),rtl::OUString::createFromAscii(""));
705 m_pImpl
->aCellContent
.push_back(aNewRow
);
707 m_pImpl
->aRowHeadersTitle
.push_back(Event
.headerName
);
708 m_pImpl
->nRowCount
=m_pImpl
->aCellContent
.size();
709 TableControl
* pTable
= (TableControl
*)GetWindow();
710 pTable
->InvalidateDataWindow(m_pImpl
->nRowCount
-1, false);
711 //pTable->GrabFocus();
714 void SAL_CALL
UnoControlTableModel::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
716 TableControl
* pTable
= (TableControl
*)GetWindow();
717 //unsigned int rows =m_pImpl->aCellContent.size()-1;
718 if(Event
.index
== -1)
721 m_pImpl
->aRowHeadersTitle
.clear();
722 m_pImpl
->aCellContent
.clear();
726 pTable
->removeSelectedRow(Event
.index
);
727 if(m_pImpl
->aCellContent
.size()>1)
730 m_pImpl
->aRowHeadersTitle
.erase(m_pImpl
->aRowHeadersTitle
.begin()+Event
.index
);
731 m_pImpl
->aCellContent
.erase(m_pImpl
->aCellContent
.begin()+Event
.index
);
737 m_pImpl
->aRowHeadersTitle
.clear();
738 m_pImpl
->aCellContent
.clear();
739 //m_pImpl->nRowCount=0;
742 //pTable->InvalidateDataWindow(Event.index, true);
743 setRowCount(m_pImpl
->aCellContent
.size());
744 pTable
->InvalidateDataWindow(Event
.index
, true);
745 //pTable->Invalidate();
748 void SAL_CALL
UnoControlTableModel::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
753 void SAL_CALL
UnoControlTableModel::disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
)
755 VCLXWindow::disposing( Source
);
758 ::sal_Int32 SAL_CALL
UnoControlTableModel::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException
)
763 ::sal_Int32 SAL_CALL
UnoControlTableModel::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException
)
768 void SAL_CALL
UnoControlTableModel::insertIndexIntervall(::sal_Int32 start
, ::sal_Int32 length
) throw (::com::sun::star::uno::RuntimeException
)
774 void SAL_CALL
UnoControlTableModel::removeIndexIntervall(::sal_Int32 start
, ::sal_Int32 end
) throw (::com::sun::star::uno::RuntimeException
)
780 ::com::sun::star::uno::Sequence
< ::sal_Int32
> SAL_CALL
UnoControlTableModel::getSelection() throw (::com::sun::star::uno::RuntimeException
)
782 TableControl
* pTable
= (TableControl
*)GetWindow();
783 std::vector
<RowPos
> selectedRows
= pTable
->getSelectedRows();
784 Sequence
<sal_Int32
> selectedRowsToSequence(comphelper::containerToSequence(selectedRows
));
785 return selectedRowsToSequence
;
788 ::sal_Bool SAL_CALL
UnoControlTableModel::isCellEditable() throw (::com::sun::star::uno::RuntimeException
)
793 ::sal_Bool SAL_CALL
UnoControlTableModel::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException
)
798 ::sal_Bool SAL_CALL
UnoControlTableModel::isSelectedIndex(::sal_Int32 index
) throw (::com::sun::star::uno::RuntimeException
)
804 void SAL_CALL
UnoControlTableModel::selectRow(::sal_Int32 y
) throw (::com::sun::star::uno::RuntimeException
)
809 void SAL_CALL
UnoControlTableModel::selectColumn(::sal_Int32 x
) throw (::com::sun::star::uno::RuntimeException
)