Update ooo320-m1
[ooovba.git] / svtools / source / uno / unocontroltablemodel.cxx
blobb19aead7df9ea36d3700de551e5d2dac32ae9ae5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unocontroltablemodel.cxx,v $
10 * $Revision: 1.32 $
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
57 private:
58 ColumnID m_nID;
59 String m_sName;
60 bool m_bIsResizable;
61 TableMetrics m_nWidth;
62 TableMetrics m_nMinWidth;
63 TableMetrics m_nMaxWidth;
65 public:
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)
85 :m_nID( 0 )
86 ,m_sName()
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
100 return m_nID;
103 //--------------------------------------------------------------------
104 bool UnoControlTableColumn::setID( const ColumnID _nID )
106 // TODO: conflict check
108 m_nID = _nID;
109 // TODO: notifications?
111 return true;
114 //--------------------------------------------------------------------
115 String UnoControlTableColumn::getName() const
117 return m_sName;
120 //--------------------------------------------------------------------
121 void UnoControlTableColumn::setName( const String& _rName )
123 m_sName = _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
143 return m_nWidth;
146 //--------------------------------------------------------------------
147 void UnoControlTableColumn::setWidth( TableMetrics _nWidth )
149 m_nWidth = _nWidth;
150 // TODO: notifications?
153 //--------------------------------------------------------------------
154 TableMetrics UnoControlTableColumn::getMinWidth() const
156 return m_nMinWidth;
159 //--------------------------------------------------------------------
160 void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth )
162 m_nMinWidth = _nMinWidth;
163 // TODO: notifications?
166 //--------------------------------------------------------------------
167 TableMetrics UnoControlTableColumn::getMaxWidth() const
169 return m_nMaxWidth;
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;
185 TableSize nRowCount;
186 bool bHasColumnHeaders;
187 bool bHasRowHeaders;
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()
197 :nRowCount ( 0 )
198 ,bHasColumnHeaders ( false )
199 ,bHasRowHeaders ( false )
200 ,pRenderer ( )
201 ,pInputHandler ( )
202 ,nRowHeight ( 4 * 100 ) // 40 mm
203 ,nColumnHeaderHeight( 5 * 100 ) // 50 mm
204 ,nRowHeaderWidth ( 10 * 100 ) // 50 mm
205 ,aRowHeadersTitle ( 0 )
206 ,aCellContent ( 0 )
211 //====================================================================
212 //= UnoControlTableModel
213 //====================================================================
214 //--------------------------------------------------------------------
215 UnoControlTableModel::UnoControlTableModel()
216 :m_pImpl( new UnoControlTableModel_Impl ),
217 m_xDataModel(0),
218 m_xColumnModel(0),
219 m_bHasColumnHeaders(false),
220 m_bHasRowHeaders(false),
221 m_bVScroll(false),
222 m_bHScroll(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()
233 DELETEZ( m_pImpl );
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
284 (void)col;
285 (void)row;
286 return false;
289 //--------------------------------------------------------------------
290 void UnoControlTableModel::addTableModelListener( const PTableModelListener& listener )
292 (void) listener;
293 //listener->onTableModelChanged(PTableModel(this));
294 // TODO
295 DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" );
298 //--------------------------------------------------------------------
299 void UnoControlTableModel::removeTableModelListener( const PTableModelListener& listener )
301 (void)listener;
302 // TODO
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 )
317 (void)id;
318 // TODO
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;
381 else
382 return ScrollbarShowAlways;
385 //--------------------------------------------------------------------
386 ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const
388 if(overAllWidth>=actWidth && !m_bHScroll)
389 return ScrollbarShowNever;
390 else
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;
400 while(i!=0)
402 cellContent.push_back(emptyCells);
403 --i;
406 std::vector<rtl::OUString> cCC;
407 for(::std::vector<std::vector<rtl::OUString> >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter)
409 cCC = *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();
425 while(i!=0)
427 cellColumnContent.push_back(rtl::OUString::createFromAscii(""));
428 --i;
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)
464 return NULL;
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)
468 (void)model;
470 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL UnoControlTableModel::getDataModel( ) throw (::com::sun::star::uno::RuntimeException)
472 return NULL;
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)
476 (void)model;
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)
498 (void)rEvent;
500 void SAL_CALL UnoControlTableModel::mouseReleased( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
502 (void)rEvent;
504 void SAL_CALL UnoControlTableModel::mouseEntered( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
506 (void) rEvent;
508 void SAL_CALL UnoControlTableModel::mouseExited( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException)
510 (void) rEvent;
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)
515 (void)listener;
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)
520 (void) listener;
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 );
548 break;
550 case BASEPROPERTY_HSCROLL:
552 sal_Bool bHScroll = true;
553 if( aValue >>= bHScroll )
555 m_bHScroll = bHScroll;
557 break;
559 case BASEPROPERTY_VSCROLL:
561 sal_Bool bVScroll = true;
562 if( aValue >>= bVScroll )
564 m_bVScroll = bVScroll;
566 break;
568 case BASEPROPERTY_GRID_SHOWROWHEADER:
570 sal_Bool rowHeader = true;
571 if( aValue >>= rowHeader )
573 setRowHeaders(rowHeader);
575 break;
578 case BASEPROPERTY_GRID_SHOWCOLUMNHEADER:
580 sal_Bool colHeader = true;
581 if( aValue >>= colHeader )
583 setColumnHeaders(colHeader);
585 break;
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);
606 break;
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);
621 break;
623 default:
624 VCLXWindow::setProperty( PropertyName, aValue );
625 break;
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();
635 if(pTableControl)
637 switch(nPropId)
639 case BASEPROPERTY_GRID_SELECTIONMODE:
641 SelectionType eSelectionType;
643 SelectionMode eSelMode = pTableControl->getSelEngine()->GetSelectionMode();
644 switch( eSelMode )
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();
687 if ( pTable )
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() );
696 if ( GetWindow())
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);
706 if(hasRowHeaders())
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)
720 if(hasRowHeaders())
721 m_pImpl->aRowHeadersTitle.clear();
722 m_pImpl->aCellContent.clear();
724 else
726 pTable->removeSelectedRow(Event.index);
727 if(m_pImpl->aCellContent.size()>1)
729 if(hasRowHeaders())
730 m_pImpl->aRowHeadersTitle.erase(m_pImpl->aRowHeadersTitle.begin()+Event.index);
731 m_pImpl->aCellContent.erase(m_pImpl->aCellContent.begin()+Event.index);
734 else
736 if(hasRowHeaders())
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)
750 (void) Event;
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)
760 return 0;
763 ::sal_Int32 SAL_CALL UnoControlTableModel::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
765 return 0;
768 void SAL_CALL UnoControlTableModel::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
770 (void)length;
771 (void)start;
774 void SAL_CALL UnoControlTableModel::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException)
776 (void)end;
777 (void)start;
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)
790 return sal_False;
793 ::sal_Bool SAL_CALL UnoControlTableModel::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException)
795 return sal_False;
798 ::sal_Bool SAL_CALL UnoControlTableModel::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
800 (void)index;
801 return sal_False;
804 void SAL_CALL UnoControlTableModel::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
806 (void)y;
809 void SAL_CALL UnoControlTableModel::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException)
811 (void)x;