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.hxx,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 ************************************************************************/
31 #ifndef _UNOCONTROL_TABLEMODEL_HXX_
32 #define _UNOCONTROL_TABLEMODEL_HXX_
34 #include <svtools/table/tablemodel.hxx>
35 #include <svtools/table/tablecontrol.hxx>
36 #include <com/sun/star/awt/grid/XGridControl.hpp>
37 #include <com/sun/star/awt/grid/XGridDataListener.hpp>
38 #include <com/sun/star/awt/grid/GridDataEvent.hpp>
39 #include <com/sun/star/awt/grid/XGridColumnModel.hpp>
40 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
41 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
42 #include <toolkit/awt/vclxwindow.hxx>
43 #include <toolkit/awt/vclxwindows.hxx>
44 #include <cppuhelper/typeprovider.hxx>
45 #include <cppuhelper/implbase2.hxx>
46 //#include <toolkit/helper/listenermultiplexer.hxx>
49 using namespace ::svt::table
;
51 struct UnoControlTableModel_Impl
;
53 class UnoControlTableModel
: public ITableModel
, public ::cppu::ImplInheritanceHelper2
< VCLXWindow
, ::com::sun::star::awt::grid::XGridControl
,
54 ::com::sun::star::awt::grid::XGridDataListener
>
57 UnoControlTableModel_Impl
* m_pImpl
;
58 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
>m_xDataModel
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
>m_xColumnModel
;
60 bool m_bHasColumnHeaders
;
61 bool m_bHasRowHeaders
;
64 //MouseListenerMultiplexer m_aMouseListeners;
67 UnoControlTableModel();
68 ~UnoControlTableModel();
70 /// returns the current row height, in 1/100 millimeters
71 inline TableMetrics
GetRowHeight() const { return getRowHeight(); }
72 /// sets a new row height.
73 void setRowHeight( TableMetrics _nHeight
);
75 /// returns the height of the title row (containing the column headers)
76 inline TableMetrics
GetTitleHeight() const { return getColumnHeaderHeight(); }
77 /// sets a new height for the title row (containing the column headers)
78 void SetTitleHeight( TableMetrics _nHeight
);
80 /// returns the width of the handle column (containing the row headers)
81 inline TableMetrics
GetHandleWidth() const { return getRowHeaderWidth(); }
82 /// sets a new width for the handle column (containing the row headers)
83 void SetHandleWidth( TableMetrics _nWidth
);
85 /// sets the width of a column
86 inline void SetColumnWidth( ColPos _nColumn
, TableMetrics _nWidth100thMM
);
87 /// retrieves the width of a column, in 1/100th millimeters
88 inline TableMetrics
GetColumnWidth( ColPos _nColumn
);
90 // TODO: setters and getters for ID, Name, Resizable, MinWidth, MaxWidth
93 // ITableModel overridables
94 virtual TableSize
getColumnCount() const;
95 virtual TableSize
getRowCount() const;
96 virtual void setColumnCount(TableSize _nColCount
);
97 virtual void setRowCount(TableSize _nRowCount
);
98 virtual bool hasColumnHeaders() const;
99 virtual bool hasRowHeaders() const;
100 virtual void setRowHeaders(bool _bRowHeaders
);
101 virtual void setColumnHeaders(bool _bColumnHeaders
);
102 virtual bool isCellEditable( ColPos col
, RowPos row
) const;
103 virtual void addTableModelListener( const PTableModelListener
& listener
);
104 virtual void removeTableModelListener( const PTableModelListener
& listener
);
105 virtual PColumnModel
getColumnModel( ColPos column
);
106 virtual PColumnModel
getColumnModelByID( ColumnID id
);
107 virtual PTableRenderer
getRenderer() const;
108 virtual PTableInputHandler
getInputHandler() const;
109 virtual TableMetrics
getRowHeight() const;
110 virtual TableMetrics
getColumnHeaderHeight() const;
111 virtual TableMetrics
getRowHeaderWidth() const;
112 virtual ScrollbarVisibility
getVerticalScrollbarVisibility(int overAllHeight
, int actHeight
) const;
113 virtual ScrollbarVisibility
getHorizontalScrollbarVisibility(int overAllWidth
, int actWidth
) const;
114 virtual void setCellContent(std::vector
<std::vector
<rtl::OUString
> > cellContent
);
115 virtual std::vector
<std::vector
<rtl::OUString
> > getCellContent();
116 virtual void setRowHeaderName(std::vector
<rtl::OUString
> cellColumnContent
);
117 virtual std::vector
<rtl::OUString
> getRowHeaderName();
119 //XGridDataListener overridables
120 virtual void SAL_CALL
rowAdded(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
121 virtual void SAL_CALL
rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
122 virtual void SAL_CALL
dataChanged(const ::com::sun::star::awt::grid::GridDataEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
123 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
125 ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
126 void SAL_CALL
acquire() throw() { VCLXWindow::acquire(); }
127 void SAL_CALL
release() throw() { VCLXWindow::release(); }
129 // ::com::sun::star::lang::XTypeProvider
130 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes() throw(::com::sun::star::uno::RuntimeException
);
131 ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw(::com::sun::star::uno::RuntimeException
);
133 //::com::sun::star::awt::grid::XGridControl
134 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
> SAL_CALL
getColumnModel( ) throw (::com::sun::star::uno::RuntimeException
);
135 void SAL_CALL
setColumnModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
>& model
) throw (::com::sun::star::uno::RuntimeException
);
136 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
> SAL_CALL
getDataModel( ) throw (::com::sun::star::uno::RuntimeException
);
137 void SAL_CALL
setDataModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
>& model
) throw (::com::sun::star::uno::RuntimeException
);
139 virtual ::sal_Int32 SAL_CALL
getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException
);
140 virtual ::sal_Int32 SAL_CALL
getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
insertIndexIntervall(::sal_Int32 start
, ::sal_Int32 length
) throw (::com::sun::star::uno::RuntimeException
);
142 virtual void SAL_CALL
removeIndexIntervall(::sal_Int32 start
, ::sal_Int32 end
) throw (::com::sun::star::uno::RuntimeException
);
143 virtual ::com::sun::star::uno::Sequence
< ::sal_Int32
> SAL_CALL
getSelection() throw (::com::sun::star::uno::RuntimeException
);
144 virtual ::sal_Bool SAL_CALL
isCellEditable() throw (::com::sun::star::uno::RuntimeException
);
145 virtual ::sal_Bool SAL_CALL
isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException
);
146 virtual ::sal_Bool SAL_CALL
isSelectedIndex(::sal_Int32 index
) throw (::com::sun::star::uno::RuntimeException
);
147 virtual void SAL_CALL
selectRow(::sal_Int32 y
) throw (::com::sun::star::uno::RuntimeException
);
148 virtual void SAL_CALL
selectColumn(::sal_Int32 x
) throw (::com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
addSelectionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridSelectionListener
> & listener
) throw (::com::sun::star::uno::RuntimeException
);
150 virtual void SAL_CALL
removeSelectionListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridSelectionListener
> & listener
) throw (::com::sun::star::uno::RuntimeException
);
151 virtual ::sal_Int32 SAL_CALL
getItemIndexAtPoint(::sal_Int32 x
, ::sal_Int32 y
) throw (::com::sun::star::uno::RuntimeException
);
153 //void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException);
154 //void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException);
155 //::com::sun::star::awt::XMouseListener
157 virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException);
159 virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException);
160 virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException);
163 void SAL_CALL
setProperty( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
) throw(::com::sun::star::uno::RuntimeException
);
164 ::com::sun::star::uno::Any SAL_CALL
getProperty( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
);
165 static void ImplGetPropertyIds( std::list
< sal_uInt16
> &aIds
);
166 void SAL_CALL
setVisible(sal_Bool bVisible
) throw(::com::sun::star::uno::RuntimeException
);
167 void SAL_CALL
setFocus() throw(::com::sun::star::uno::RuntimeException
);
170 inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn
, TableMetrics _nWidth100thMM
)
172 getColumnModel( _nColumn
)->setWidth( _nWidth100thMM
);
175 inline TableMetrics
UnoControlTableModel::GetColumnWidth( ColPos _nColumn
)
177 return getColumnModel( _nColumn
)->getWidth();
179 #endif // _UNOCONTROL_TABLEMODEL_HXX_