summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2010-05-21 16:40:24 +0200
committerKurt Zenker <kz@openoffice.org>2010-05-21 16:40:24 +0200
commit8626c44b5da388deffa32d14bc36eef257868ba3 (patch)
tree5c919eee2e23f01f80be07046f2488772992f0f4
parent203ec2754ae06bfcea6e3570a8413d86ca9ace17 (diff)
parent54841bec35525663331fcc8081c316d264332277 (diff)
CWS-TOOLING: integrate CWS gridcontrol_03
Notes
Notes: split repo tag: libs-gui_ooo/DEV300_m79
-rwxr-xr-x[-rw-r--r--]svtools/inc/svtools/accessibletable.hxx9
-rw-r--r--svtools/inc/svtools/table/abstracttablecontrol.hxx18
-rw-r--r--svtools/inc/svtools/table/defaultinputhandler.hxx1
-rw-r--r--svtools/inc/svtools/table/gridtablerenderer.hxx8
-rw-r--r--svtools/inc/svtools/table/tablecontrol.hxx152
-rw-r--r--svtools/inc/svtools/table/tabledatawindow.hxx12
-rw-r--r--svtools/inc/svtools/table/tablemodel.hxx108
-rw-r--r--svtools/inc/svtools/table/tablerenderer.hxx44
-rw-r--r--svtools/inc/svtools/table/tabletypes.hxx10
-rw-r--r--svtools/prj/d.lst2
-rw-r--r--svtools/source/inc/accessibletableimp.hxx62
-rw-r--r--svtools/source/table/defaultinputhandler.cxx57
-rw-r--r--svtools/source/table/gridtablerenderer.cxx276
-rw-r--r--svtools/source/table/tablecontrol.cxx130
-rw-r--r--svtools/source/table/tablecontrol_impl.cxx1415
-rw-r--r--svtools/source/table/tablecontrol_impl.hxx161
-rw-r--r--svtools/source/table/tabledatawindow.cxx84
-rw-r--r--svtools/source/table/tablegeometry.cxx8
-rwxr-xr-x[-rw-r--r--]svtools/source/uno/svtxgridcontrol.cxx629
-rwxr-xr-x[-rw-r--r--]svtools/source/uno/svtxgridcontrol.hxx44
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx239
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx77
-rw-r--r--toolkit/inc/toolkit/helper/listenermultiplexer.hxx10
-rw-r--r--toolkit/inc/toolkit/helper/property.hxx4
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx121
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.hxx37
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx99
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.hxx23
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx148
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx29
-rw-r--r--toolkit/source/controls/grid/gridcontrol.cxx112
-rw-r--r--toolkit/source/controls/grid/gridcontrol.hxx18
-rw-r--r--toolkit/source/helper/listenermultiplexer.cxx5
-rw-r--r--toolkit/source/helper/property.cxx8
-rw-r--r--vcl/inc/vcl/vclevent.hxx1
35 files changed, 2844 insertions, 1317 deletions
diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx
index b08a7f04f1da..7098d2b0d4ef 100644..100755
--- a/svtools/inc/svtools/accessibletable.hxx
+++ b/svtools/inc/svtools/accessibletable.hxx
@@ -94,9 +94,8 @@ public:
virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const= 0;
/** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
- the accessible object), depending on the specified object type. */
- virtual void FillAccessibleStateSet(
- ::utl::AccessibleStateSetHelper& rStateSet,
+ the accessible object), depending on the specified object type. */
+ virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet,
AccessibleTableControlObjType eObjType ) const= 0;
// Window
@@ -122,8 +121,10 @@ public:
virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const = 0;
virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0;
virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0;
- virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0;
+ virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0;
virtual std::vector<sal_Int32>& GetSelectedRows() = 0;
+ virtual void RemoveSelectedRow(sal_Int32 _nRowPos) = 0;
+ virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx
index 8e92abc6c04c..2b3951f6aaf3 100644
--- a/svtools/inc/svtools/table/abstracttablecontrol.hxx
+++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx
@@ -30,6 +30,7 @@
#include <sal/types.h>
#include <vcl/event.hxx>
#include <vcl/seleng.hxx>
+#include "tabletypes.hxx"
//........................................................................
namespace svt { namespace table
{
@@ -112,14 +113,15 @@ namespace svt { namespace table
@see TableControlAction
*/
virtual bool dispatchAction( TableControlAction _eAction ) = 0;
- /** to be called on mouse button up/down
- @return
- <TRUE/> if the click was in the visible area of the table control,
- <FALSE/> otherwise.*/
- virtual bool isClickInVisibleArea( const Point& _rPoint ) = 0;
- /** returns selection engine*/
- virtual SelectionEngine* getSelEngine() = 0;
- virtual void setCursorAtCurrentCell(const Point& rPoint) = 0;
+ /** returns selection engine*/
+ virtual SelectionEngine* getSelEngine() = 0;
+ virtual void setCursorAtCurrentCell(const Point& rPoint) = 0;
+ virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0;
+ virtual RowPos getCurrentRow(const Point& rPoint ) = 0;
+ virtual void resizeColumn(const Point& rPoint ) = 0;
+ virtual bool startResizeColumn(const Point& rPoint) = 0;
+ virtual bool endResizeColumn(const Point& rPoint) = 0;
+ virtual bool isRowSelected(RowPos _nRow) = 0;
virtual ~IAbstractTableControl() {};
};
diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx
index b9e2db31ca01..ca760896d539 100644
--- a/svtools/inc/svtools/table/defaultinputhandler.hxx
+++ b/svtools/inc/svtools/table/defaultinputhandler.hxx
@@ -44,6 +44,7 @@ namespace svt { namespace table
friend class TableDataWindow;
private:
DefaultInputHandler_Impl* m_pImpl;
+ bool m_bResize;
public:
DefaultInputHandler();
diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx
index 13d44617d523..e474306c0423 100644
--- a/svtools/inc/svtools/table/gridtablerenderer.hxx
+++ b/svtools/inc/svtools/table/gridtablerenderer.hxx
@@ -90,10 +90,14 @@ namespace svt { namespace table
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle, rtl::OUString& _rText );
- virtual void PaintCell( ColPos _nColumn,
+ virtual void PaintCellImage( ColPos _nColumn,
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText );
+ const StyleSettings& _rStyle, Image* _pCellData );
+ virtual void PaintCellString( ColPos _nColumn,
+ bool _bActive, bool _bSelected,
+ OutputDevice& _rDevice, const Rectangle& _rArea,
+ const StyleSettings& _rStyle, rtl::OUString& _rText );
virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect);
virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect);
};
diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx
index c1381e3b3c0b..313b2b7b7735 100644
--- a/svtools/inc/svtools/table/tablecontrol.hxx
+++ b/svtools/inc/svtools/table/tablecontrol.hxx
@@ -27,12 +27,14 @@
#ifndef SVTOOLS_INC_TABLE_TABLECONTROL_HXX
#define SVTOOLS_INC_TABLE_TABLECONTROL_HXX
+#include "svtools/svtdllapi.h"
#include <svtools/table/tablemodel.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/seleng.hxx>
#include <svtools/table/tabledatawindow.hxx>
#include <svtools/accessibletable.hxx>
-#include "svtaccessiblefactory.hxx"
+#include <com/sun/star/util/Color.hpp>
+#include <svtools/accessiblefactory.hxx>
//........................................................................
namespace svt { namespace table
@@ -64,13 +66,19 @@ namespace svt { namespace table
// TODO: scrolling?
*/
- class TableControl : public Control, public IAccessibleTable
+ class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable
{
private:
- DECL_LINK( ImplMouseButtonDownHdl, MouseEvent* );
- DECL_LINK( ImplMouseButtonUpHdl, MouseEvent* );
+ DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* );
+ DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* );
+
+ DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
TableControl_Impl* m_pImpl;
+ ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText;
+ Link m_aSelectHdl;
+ bool m_bSelectionChanged;
public:
::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable;
@@ -78,7 +86,7 @@ namespace svt { namespace table
~TableControl();
/// sets a new table model
- void SetModel( PTableModel _pModel );
+ SVT_DLLPRIVATE void SetModel( PTableModel _pModel );
/// retrieves the current table model
PTableModel GetModel() const;
@@ -148,65 +156,72 @@ namespace svt { namespace table
{
return GoTo( GetCurrentColumn(), _nRow );
}
- virtual void Resize();
+ SVT_DLLPRIVATE virtual void Resize();
+ virtual void Select();
+ SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; }
+ const Link& GetSelectHdl() const { return m_aSelectHdl; }
- /**invalidates the table if table has been changed e.g. new row added
- */
- void InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved);
- /**gets the vector, which contains the selected rows
- */
- std::vector<sal_Int32>& GetSelectedRows();
- /**after removing a row, updates the vector which contains the selected rows
- if the row, which should be removed, is selected, it will be erased from the vector
- */
- void removeSelectedRow(RowPos _nRowPos);
- SelectionEngine* getSelEngine();
- TableDataWindow* getDataWindow();
+ /**invalidates the table if table has been changed e.g. new row added
+ */
+ void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved);
+ /**gets the vector, which contains the selected rows
+ */
+ std::vector<sal_Int32>& GetSelectedRows();
+ /**after removing a row, updates the vector which contains the selected rows
+ if the row, which should be removed, is selected, it will be erased from the vector
+ */
+ SelectionEngine* getSelEngine();
+ TableDataWindow* getDataWindow();
// Window overridables
virtual void GetFocus();
virtual void LoseFocus();
virtual void KeyInput( const KeyEvent& rKEvt );
- //virtual long Notify(NotifyEvent& rNEvt);
-
- /** Creates and returns the accessible object of the whole BrowseBox. */
- virtual XACC CreateAccessible();
- virtual XACC CreateAccessibleControl( sal_Int32 _nIndex );
- virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const;
- virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow );
- virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const;
- virtual void FillAccessibleStateSet(
- ::utl::AccessibleStateSetHelper& rStateSet,
- AccessibleTableControlObjType eObjType ) const;
-
- //// Window
- virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow );
- virtual void GrabFocus();
- virtual XACC GetAccessible( BOOL bCreate = TRUE );
- virtual Window* GetAccessibleParentWindow() const;
- virtual Window* GetWindowInstance();
- virtual sal_Int32 GetAccessibleControlCount() const;
- virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint );
- virtual long GetRowCount() const;
- virtual long GetColumnCount() const;
- virtual sal_Bool HasRowHeader() const;
- virtual sal_Int32 GetSelectedRowCount() const;
- virtual bool IsRowSelected( long _nRow ) const;
- virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint );
- virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE );
- virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE );
- virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
- virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
- virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const;
- virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const;
- virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const;
- virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const;
- virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const;
- virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const;
- virtual sal_Bool HasRowHeader();
- virtual sal_Bool HasColHeader();
- virtual sal_Bool isAccessibleAlive( ) const;
- virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue );
+ //virtual long Notify(NotifyEvent& rNEvt);
+
+ /** Creates and returns the accessible object of the whole GridControl. */
+ SVT_DLLPRIVATE virtual XACC CreateAccessible();
+ SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex );
+ SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const;
+ SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow );
+ SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const;
+ virtual void FillAccessibleStateSet(
+ ::utl::AccessibleStateSetHelper& rStateSet,
+ AccessibleTableControlObjType eObjType ) const;
+ //// Window
+ virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow );
+ virtual void GrabFocus();
+ virtual XACC GetAccessible( BOOL bCreate = TRUE );
+ virtual Window* GetAccessibleParentWindow() const;
+ virtual Window* GetWindowInstance();
+ virtual sal_Int32 GetAccessibleControlCount() const;
+ virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint );
+ virtual long GetRowCount() const;
+ virtual long GetColumnCount() const;
+ virtual sal_Bool HasRowHeader() const;
+ virtual sal_Int32 GetSelectedRowCount() const;
+ virtual bool IsRowSelected( long _nRow ) const;
+ virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint );
+ virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE );
+ virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE );
+ virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
+ virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
+ virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const;
+ virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const;
+ virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const;
+ virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const;
+ virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const;
+ virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const;
+ virtual sal_Bool HasRowHeader();
+ virtual sal_Bool HasColHeader();
+ virtual sal_Bool isAccessibleAlive( ) const;
+ virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue );
+ virtual void RemoveSelectedRow(RowPos _nRowPos);
+ virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos);
+ ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip();
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip();
+ void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols);
+ void selectionChanged(bool _bChanged);
protected:
@@ -219,27 +234,6 @@ namespace svt { namespace table
TableControl& operator=( const TableControl& ); // never implemented
};
- class AccessibleTableControl_Impl
- {
- public:
- AccessibleFactoryAccess m_aFactoryAccess;
- IAccessibleTableControl* m_pAccessible;
-
- public:
- AccessibleTableControl_Impl() : m_pAccessible(NULL)
- {
- }
-
-
- /// @see AccessibleTableControl::getTableRowHeader
- ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
- getAccessibleTableHeader( AccessibleTableControlObjType _eObjType );
- /// @see AccessibleTableControl::getTable
- ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
- getAccessibleTable( );
-
- };
-
//........................................................................
} } // namespace svt::table
//........................................................................
diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx
index d14a25289c99..c9f96483d943 100644
--- a/svtools/inc/svtools/table/tabledatawindow.hxx
+++ b/svtools/inc/svtools/table/tabledatawindow.hxx
@@ -53,21 +53,27 @@ namespace svt { namespace table
private:
TableControl_Impl& m_rTableControl;
Link m_aMouseButtonDownHdl;
- Link m_aMouseButtonUpHdl;
-
+ Link m_aMouseButtonUpHdl;
+ Link m_aSelectHdl;
+ RowPos m_nRowAlreadySelected;
public:
TableDataWindow( TableControl_Impl& _rTableControl );
inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; }
inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; }
inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; }
inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; }
+ inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; }
+ inline const Link& GetSelectHdl() const { return m_aSelectHdl; }
// Window overridables
virtual void Paint( const Rectangle& rRect );
virtual void MouseMove( const MouseEvent& rMEvt);
virtual void MouseButtonDown( const MouseEvent& rMEvt);
virtual void MouseButtonUp( const MouseEvent& rMEvt);
-
+ virtual void SetPointer( const Pointer& rPointer );
+ virtual void CaptureMouse();
+ virtual void ReleaseMouse();
+ virtual long Notify(NotifyEvent& rNEvt);
};
//........................................................................
} } // namespace svt::table
diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx
index 34a89cb03e6b..3da396d9d86c 100644
--- a/svtools/inc/svtools/table/tablemodel.hxx
+++ b/svtools/inc/svtools/table/tablemodel.hxx
@@ -27,13 +27,16 @@
#ifndef SVTOOLS_INC_TABLE_TABLEMODEL_HXX
#define SVTOOLS_INC_TABLE_TABLEMODEL_HXX
+#include "svtools/svtdllapi.h"
#include <svtools/table/tabletypes.hxx>
#include <svtools/table/tablerenderer.hxx>
#include <svtools/table/tableinputhandler.hxx>
-
+#include <rtl/ref.hxx>
#include <sal/types.h>
-
+#include <com/sun/star/util/Color.hpp>
#include <boost/shared_ptr.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/style/HorizontalAlignment.hpp>
//........................................................................
namespace svt { namespace table
@@ -44,21 +47,16 @@ namespace svt { namespace table
//====================================================================
//= cell data
//====================================================================
- struct CellEntryType
+ struct TableContentType
{
- String m_aStr;
- //Image m_aImage;
- //Control m_aControl;
- CellEntryType( const String& _rStr ) :
- m_aStr( _rStr )
- {}
+ ::rtl::OUString sContent;
+ Image* pImage;
+ TableContentType() :
+ sContent(),
+ pImage( )
+ {
+ }
};
-
- //typedef ::std::vector<CellEntryType*> CellColumnContent;
- //vector, which contains text data for each cell
- typedef ::std::vector<String> CellColumnContent;
- //vector, which contains data for rows
- typedef ::std::vector<CellColumnContent> CellContent;
//====================================================================
//= ScrollbarVisibility
//====================================================================
@@ -285,7 +283,24 @@ namespace svt { namespace table
*/
virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0;
+ /** returns the preferred width of the column, or 0 if the column
+ does not have a preferred width.
+
+ @see setMaxWidth
+ @see getMinWidth
+ @see getWidth
+ */
+ virtual TableMetrics getPreferredWidth() const = 0;
+ /** sets the preferred width of the column, to be used when user resizes column
+
+ @see getMaxWidth
+ @see setMinWidth
+ @see setWidth
+ */
+ virtual void setPreferredWidth( TableMetrics _nPrefWidth ) = 0;
+ virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0;
+ virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0;
/// deletes the column model instance
virtual ~IColumnModel() { }
};
@@ -296,7 +311,7 @@ namespace svt { namespace table
//====================================================================
/** declares the interface to implement by an abtract table model
*/
- class SAL_NO_VTABLE ITableModel
+ class SAL_NO_VTABLE SVT_DLLPUBLIC ITableModel
{
public:
/** returns the number of columns in the table
@@ -307,8 +322,8 @@ namespace svt { namespace table
*/
virtual TableSize getRowCount() const = 0;
- virtual void setColumnCount(TableSize _nColCount) = 0;
- virtual void setRowCount(TableSize _nRowCount) = 0;
+ SVT_DLLPRIVATE virtual void setColumnCount(TableSize _nColCount) = 0;
+ SVT_DLLPRIVATE virtual void setRowCount(TableSize _nRowCount) = 0;
/** determines whether the table has column headers
@@ -321,12 +336,12 @@ namespace svt { namespace table
/** sets whether the table should have row headers
@see IColumnRenderer
*/
- virtual void setRowHeaders( bool rowHeaders) = 0;
+ SVT_DLLPRIVATE virtual void setRowHeaders( bool rowHeaders) = 0;
/** sets whether the table should have column headers
@see IColumnRenderer
*/
- virtual void setColumnHeaders( bool columnHeaders) = 0;
+ SVT_DLLPRIVATE virtual void setColumnHeaders( bool columnHeaders) = 0;
/** determines whether the table has row headers
@@ -346,11 +361,11 @@ namespace svt { namespace table
/** adds the given listener to the list of ->ITableModelListener's
*/
- virtual void addTableModelListener( const PTableModelListener& listener ) = 0;
+ SVT_DLLPRIVATE virtual void addTableModelListener( const PTableModelListener& listener ) = 0;
/** revokes the given listener from the list of ->ITableModelListener's
*/
- virtual void removeTableModelListener( const PTableModelListener& listener ) = 0;
+ SVT_DLLPRIVATE virtual void removeTableModelListener( const PTableModelListener& listener ) = 0;
/** returns a model for a certain column
@@ -380,7 +395,7 @@ namespace svt { namespace table
@return the renderer to use. Must not be <NULL/>
*/
- virtual PTableRenderer getRenderer() const = 0;
+ SVT_DLLPRIVATE virtual PTableRenderer getRenderer() const = 0;
/** returns the component handling input in a view associated with the model
*/
@@ -392,9 +407,9 @@ namespace svt { namespace table
the logical height of rows in the table, in 1/100 millimeters. The height must be
greater 0.
*/
- virtual TableMetrics getRowHeight() const = 0;
+ SVT_DLLPRIVATE virtual TableMetrics getRowHeight() const = 0;
- virtual void setRowHeight(TableMetrics _nRowHeight) = 0;
+ SVT_DLLPRIVATE virtual void setRowHeight(TableMetrics _nRowHeight) = 0;
/** determines the height of the column header row
@@ -405,7 +420,7 @@ namespace svt { namespace table
the logical height of the column header row, in 1/100 millimeters.
Must be greater than 0.
*/
- virtual TableMetrics getColumnHeaderHeight() const = 0;
+ SVT_DLLPRIVATE virtual TableMetrics getColumnHeaderHeight() const = 0;
/** determines the width of the row header column
@@ -416,7 +431,7 @@ namespace svt { namespace table
the logical width of the row header column, in 1/100 millimeters.
Must be greater than 0.
*/
- virtual TableMetrics getRowHeaderWidth() const = 0;
+ SVT_DLLPRIVATE virtual TableMetrics getRowHeaderWidth() const = 0;
/** determines the visibility of the vertical scrollbar of the table control
@param overAllHeight the height of the table with all rows
@@ -429,19 +444,32 @@ namespace svt { namespace table
@param actWidth the given width of the table
*/
virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0;
-
- /** fills cells with content
- */
- virtual void setCellContent(std::vector<std::vector<rtl::OUString> > cellContent)=0;
- /** gets the content of the cells
- */
- virtual std::vector<std::vector<rtl::OUString> >& getCellContent() = 0;
- /**sets title of header rows
- */
- virtual void setRowHeaderName(std::vector<rtl::OUString> cellColumnContent)=0;
- /** gets title of header rows
- */
- virtual std::vector<rtl::OUString>& getRowHeaderName() = 0;
+ virtual bool hasVerticalScrollbar() =0;
+ virtual bool hasHorizontalScrollbar() = 0;
+ /** fills cells with content
+ */
+ virtual void setCellContent(const std::vector< std::vector< ::com::sun::star::uno::Any > >& cellContent)=0;
+ /** gets the content of the cells
+ */
+ virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0;
+ /**sets title of header rows
+ */
+ SVT_DLLPRIVATE virtual void setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent)=0;
+ /** gets title of header rows
+ */
+ virtual std::vector<rtl::OUString>& getRowHeaderName() = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0;
+ SVT_DLLPRIVATE virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0;
+ SVT_DLLPRIVATE virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0;
+ SVT_DLLPRIVATE virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0;
+ SVT_DLLPRIVATE virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0;
+ SVT_DLLPRIVATE virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
+ SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0;
+ SVT_DLLPRIVATE virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0;
/// destroys the table model instance
virtual ~ITableModel() { }
diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx
index cf8cd20680c2..f81771dd22e6 100644
--- a/svtools/inc/svtools/table/tablerenderer.hxx
+++ b/svtools/inc/svtools/table/tablerenderer.hxx
@@ -45,7 +45,7 @@ namespace svt { namespace table
*/
class SAL_NO_VTABLE ITableRenderer
{
- public:
+ public:
/** paints a (part of) header area
There are two header areas in a table control:
@@ -178,10 +178,9 @@ namespace svt { namespace table
@param _rText
the title of the header row
*/
- virtual void PaintRowHeader(
- bool _bActive, bool _bSelected,
+ virtual void PaintRowHeader( bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
+ const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
/** paints a certain cell
@@ -208,13 +207,46 @@ namespace svt { namespace table
the are into which the cell should be painted
@param _rStyle
the style to be used for drawing
+ @param _pCellData
+ the content of the cell
+ */
+ virtual void PaintCellImage( ColPos _nColumn,
+ bool _bActive, bool _bSelected,
+ OutputDevice& _rDevice, const Rectangle& _rArea,
+ const StyleSettings& _rStyle, Image* _pCellData ) = 0;
+
+ /** paints a certain cell
+
+ The row to be painted is denoted by the most recent call to
+ ->PrepareRow.
+
+ @param _bSelected
+ <TRUE/> if and only if the cell to be painted is
+ selected currently. This is the case if either
+ the row or the column of the cell is currently selected.
+ <br/>
+ Note that this flag is equal to the respective flag in the
+ previous ->PrepareRow call, it's passed here for convinience
+ only.
+ @param _bActive
+ <TRUE/> if the cell is currently active.
+ <br/>
+ Note that this flag is equal to the respective flag in the
+ previous ->PrepareRow call, it's passed here for convinience
+ only.
+ @param _rDevice
+ denotes the device to paint onto
+ @param _rArea
+ the are into which the cell should be painted
+ @param _rStyle
+ the style to be used for drawing
@param _rText
the content of the cell
*/
- virtual void PaintCell( ColPos _nColumn,
+ virtual void PaintCellString( ColPos _nColumn,
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
+ const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
/** draws a cell cursor in the given rectangle
diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx
index f423b64c2faa..645120e30d4b 100644
--- a/svtools/inc/svtools/table/tabletypes.hxx
+++ b/svtools/inc/svtools/table/tabletypes.hxx
@@ -56,17 +56,17 @@ namespace svt { namespace table
/** special column width value which indicates that the column should be
automatically resized to fit the view
*/
-#define COLWIDTH_FIT_TO_VIEW ((TableMetrics)-1)
+#define COLWIDTH_FIT_TO_VIEW ((::svt::table::TableMetrics)-1)
/// denotes the column containing the row headers
-#define COL_ROW_HEADERS ((ColPos)-1)
+#define COL_ROW_HEADERS ((::svt::table::ColPos)-1)
/// denotes the row containing the column headers
-#define ROW_COL_HEADERS ((RowPos)-1)
+#define ROW_COL_HEADERS ((::svt::table::RowPos)-1)
/// denotes an invalid column index
-#define COL_INVALID ((ColPos)-2)
+#define COL_INVALID ((::svt::table::ColPos)-2)
/// denotes an invalid row index
-#define ROW_INVALID ((RowPos)-2)
+#define ROW_INVALID ((::svt::table::RowPos)-2)
//........................................................................
diff --git a/svtools/prj/d.lst b/svtools/prj/d.lst
index 0a3ccd8a9819..4a9e8314e0d8 100644
--- a/svtools/prj/d.lst
+++ b/svtools/prj/d.lst
@@ -1,6 +1,7 @@
mkdir: %COMMON_DEST%\bin%_EXT%\hid
mkdir: %COMMON_DEST%\res%_EXT%
mkdir: %_DEST%\inc%_EXT%\svtools
+mkdir: %_DEST%\inc%_EXT%\svtools\table
..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
..\%__SRC%\srs\ehdl.srs %_DEST%\res%_EXT%\svtools.srs
@@ -25,6 +26,7 @@ mkdir: %_DEST%\inc%_EXT%\svtools
..\inc\svtools\*.hxx %_DEST%\inc%_EXT%\svtools\*.hxx
..\inc\svtools\*.h %_DEST%\inc%_EXT%\svtools\*.h
..\inc\svtools\*.hrc %_DEST%\inc%_EXT%\svtools\*.hrc
+..\inc\svtools\table\*.hxx %_DEST%\inc%_EXT%\svtools\table\*.hxx
..\inc\*.hxx %_DEST%\inc%_EXT%\svtools\*.hxx
..\inc\*.h %_DEST%\inc%_EXT%\svtools\*.h
..\inc\*.hrc %_DEST%\inc%_EXT%\svtools\*.hrc
diff --git a/svtools/source/inc/accessibletableimp.hxx b/svtools/source/inc/accessibletableimp.hxx
new file mode 100644
index 000000000000..3a01c01567d3
--- /dev/null
+++ b/svtools/source/inc/accessibletableimp.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
+#define SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
+
+#include "svtaccessiblefactory.hxx"
+
+namespace svt { namespace table
+{
+//........................................................................
+
+
+ class AccessibleTableControl_Impl
+ {
+ public:
+ AccessibleFactoryAccess m_aFactoryAccess;
+ IAccessibleTableControl* m_pAccessible;
+
+ public:
+ AccessibleTableControl_Impl() : m_pAccessible(NULL)
+ {
+ }
+
+
+ /// @see AccessibleTableControl::getTableRowHeader
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ getAccessibleTableHeader( AccessibleTableControlObjType _eObjType );
+ /// @see AccessibleTableControl::getTable
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ getAccessibleTable( );
+
+ };
+
+//........................................................................
+} } // namespace svt::table
+//........................................................................
+
+#endif // SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx
index b11357db95d1..ad8f7a7562d3 100644
--- a/svtools/source/table/defaultinputhandler.cxx
+++ b/svtools/source/table/defaultinputhandler.cxx
@@ -50,6 +50,7 @@ namespace svt { namespace table
//--------------------------------------------------------------------
DefaultInputHandler::DefaultInputHandler()
:m_pImpl( new DefaultInputHandler_Impl )
+ ,m_bResize(false)
{
}
@@ -62,8 +63,12 @@ namespace svt { namespace table
//--------------------------------------------------------------------
bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
{
- (void)_rControl;
- (void)_rMEvt;
+ Point aPoint = _rMEvt.GetPosPixel();
+ if(m_bResize)
+ {
+ _rControl.resizeColumn(aPoint);
+ return true;
+ }
return false;
}
@@ -72,41 +77,60 @@ namespace svt { namespace table
{
bool bHandled = false;
Point aPoint = _rMEvt.GetPosPixel();
- if(_rControl.isClickInVisibleArea(aPoint))
+ RowPos nRow = _rControl.getCurrentRow(aPoint);
+ if(nRow == -1)
+ {
+ m_bResize = _rControl.startResizeColumn(aPoint);
+ bHandled = true;
+ }
+ else if(nRow >= 0)
{
if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
{
- LoseFocus(_rControl);
_rControl.setCursorAtCurrentCell(aPoint);
bHandled = true;
}
else
{
- bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt);
+ if(!_rControl.isRowSelected(nRow))
+ bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt);
+ else
+ bHandled = true;
}
}
return bHandled;
}
-
//--------------------------------------------------------------------
bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
{
bool bHandled = false;
Point aPoint = _rMEvt.GetPosPixel();
- if(_rControl.isClickInVisibleArea(aPoint))
+ if(_rControl.getCurrentRow(aPoint) >= 0)
{
- if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
+ if(m_bResize)
+ {
+ m_bResize = _rControl.endResizeColumn(aPoint);
+ bHandled = true;
+ }
+ else if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
{
- GetFocus(_rControl);
- _rControl.setCursorAtCurrentCell(aPoint);
bHandled = true;
}
else
+ {
bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt);
+ }
+ }
+ else
+ {
+ if(m_bResize)
+ {
+ m_bResize = _rControl.endResizeColumn(aPoint);
+ bHandled = true;
+ }
}
return bHandled;
}
-
//--------------------------------------------------------------------
bool DefaultInputHandler::KeyInput( IAbstractTableControl& _rControl, const KeyEvent& rKEvt )
{
@@ -134,11 +158,11 @@ namespace svt { namespace table
{ KEY_PAGEDOWN, KEY_MOD1, cursorToLastLine },
{ KEY_HOME, KEY_MOD1, cursorTopLeft },
{ KEY_END, KEY_MOD1, cursorBottomRight },
- { KEY_SPACE, KEY_MOD1, cursorSelectRow },
- { KEY_UP, KEY_SHIFT, cursorSelectRowUp },
- { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown },
- { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom },
- { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop },
+ { KEY_SPACE, KEY_MOD1, cursorSelectRow },
+ { KEY_UP, KEY_SHIFT, cursorSelectRowUp },
+ { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown },
+ { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom },
+ { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop },
{ 0, 0, invalidTableControlAction }
};
@@ -205,7 +229,6 @@ namespace svt { namespace table
// TODO
return false;
}
-
//........................................................................
} } // namespace svt::table
//........................................................................
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index ada2e463c8af..a3f954e0bef5 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -31,6 +31,7 @@
#include <tools/debug.hxx>
#include <vcl/window.hxx>
+#include <vcl/image.hxx>
//........................................................................
namespace svt { namespace table
@@ -78,15 +79,15 @@ namespace svt { namespace table
OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea,
"GridTableRenderer::PaintHeaderArea: invalid area flags!" );
- // fill the rows with alternating background colors
- _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR );
-
- _rDevice.SetLineColor();
- _rDevice.SetFillColor( _rStyle.GetDialogColor() );
+ _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
+ Color background = m_pImpl->rModel.getHeaderBackgroundColor();
+ if( background != 0xFFFFFF)
+ _rDevice.SetFillColor(background);
+ else
+ _rDevice.SetFillColor(_rStyle.GetDialogColor());
+ _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
_rDevice.DrawRect( _rArea );
-
// delimiter lines at bottom/right
- _rDevice.SetLineColor( _rStyle.GetDialogTextColor() );
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
@@ -99,31 +100,38 @@ namespace svt { namespace table
void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
{
- _rDevice.Push( PUSH_LINECOLOR );
-
- _rDevice.SetLineColor( _rStyle.GetDialogTextColor() );
- _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
+ _rDevice.Push( PUSH_LINECOLOR);
+ _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
+ _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
String sHeaderText;
-
PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol );
DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" );
if ( !!pColumn )
sHeaderText = pColumn->getName();
- Color aRowBackground = _rStyle.GetFieldColor();
- if ( _bSelected )
- {
- aRowBackground = COL_BLUE;
- }
- _rDevice.DrawText( _rArea, sHeaderText, TEXT_DRAW_LEFT | TEXT_DRAW_TOP );
+ _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
+ ULONG nHorFlag = TEXT_DRAW_LEFT;
+ ULONG nVerFlag = TEXT_DRAW_TOP;
+ if(m_pImpl->rModel.getVerticalAlign() == 1)
+ nVerFlag = TEXT_DRAW_VCENTER;
+ else if(m_pImpl->rModel.getVerticalAlign() == 2)
+ nVerFlag = TEXT_DRAW_BOTTOM;
+ if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1)
+ nHorFlag = TEXT_DRAW_CENTER;
+ else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2)
+ nHorFlag = TEXT_DRAW_RIGHT;
+ Rectangle aRect(_rArea);
+ aRect.Left()+=4; aRect.Right()-=4;
+ aRect.Bottom()-=2;
+ _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
_rDevice.Pop();
(void)_bActive;
// no special painting for the active column at the moment
- //(void)_bSelected;
- // TODO: selection not yet implemented
+ (void)_bSelected;
+ //selection for column header not yet implemented
}
//--------------------------------------------------------------------
@@ -133,86 +141,218 @@ namespace svt { namespace table
// remember the row for subsequent calls to the other ->ITableRenderer methods
m_pImpl->nCurrentRow = _nRow;
- // fill the rows with alternating background colors
- _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR );
-
- _rDevice.SetLineColor();
-
- Color aRowBackground = _rStyle.GetFieldColor();
+ _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
+ Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor();
+ Color line = m_pImpl->rModel.getLineColor();
+ Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor();
+ //if row is selected background color becomes blue, and lines should be also blue
+ //if they aren't user defined
+ if(_bSelected)
+ {
+ Color aSelected(_rStyle.GetHighlightColor());
+ aRowBackground = aSelected;
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(aRowBackground);
+ else
+ _rDevice.SetLineColor(line);
+ }
+ //if row not selected, check the cases whether user defined backgrounds are set
+ //and set line color to be the same
+ else
+ {
+ if(aRowBackground2 != 0xFFFFFF && _nRow%2)
+ {
+ aRowBackground = aRowBackground2;
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(aRowBackground);
+ else
+ _rDevice.SetLineColor(line);
+ }
+ //fill the rows with alternating background colors if second background color is specified
+ else if(aRowBackground != 0xFFFFFF && line == 0xFFFFFF)
+ _rDevice.SetLineColor(aRowBackground);
+ else
+ {
+ //if Line color is set, then it was user defined and should be visible
+ //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
+ _rDevice.SetLineColor(line);
+ }
+ }
_rDevice.SetFillColor( aRowBackground );
-
_rDevice.DrawRect( _rRowArea );
- // TODO: active? selected?
+ // TODO: active?
_rDevice.Pop();
- (void) _bSelected;
(void)_bActive;
-
- // no special painting for the active row at the moment
-
- //(void)_bSelected;
- // TODO: selection not yet implemented
}
//--------------------------------------------------------------------
void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea,
const StyleSettings& _rStyle, rtl::OUString& _rText )
{
- _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR );
-
- _rDevice.SetLineColor( _rStyle.GetDialogTextColor() );
+ _rDevice.Push( PUSH_LINECOLOR);
+ _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
- _rDevice.DrawText( _rArea, _rText, TEXT_DRAW_LEFT);
+ _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
+ ULONG nHorFlag = TEXT_DRAW_LEFT;
+ ULONG nVerFlag = TEXT_DRAW_TOP;
+ if(m_pImpl->rModel.getVerticalAlign() == 1)
+ nVerFlag = TEXT_DRAW_VCENTER;
+ else if(m_pImpl->rModel.getVerticalAlign() == 2)
+ nVerFlag = TEXT_DRAW_BOTTOM;
+ if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1)
+ nHorFlag = TEXT_DRAW_CENTER;
+ else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2)
+ nHorFlag = TEXT_DRAW_RIGHT;
+ Rectangle aRect(_rArea);
+ aRect.Left()+=4; aRect.Right()-=4;
+ aRect.Bottom()-=2;
+ _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
// TODO: active? selected?
(void)_bActive;
(void)_bSelected;
-
+ //at the moment no special paint for selected row header
_rDevice.Pop();
}
//--------------------------------------------------------------------
- void GridTableRenderer::PaintCell( ColPos _nColumn, bool _bSelected, bool _bActive,
- OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText )
+ void GridTableRenderer::PaintCellImage( ColPos _nColumn, bool _bSelected, bool _bActive,
+ OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, Image* _pCellData )
{
- _rDevice.Push( PUSH_LINECOLOR );
-
- // draw the grid
- _rDevice.SetLineColor( COL_LIGHTGRAY );
- // TODO: the LIGHTGRAY should probably be a property/setting
- _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
- _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
-
+ _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION);
+ _rDevice.IntersectClipRegion( _rArea );
+ Color background1 = m_pImpl->rModel.getOddRowBackgroundColor();
+ Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor();
+ Color line = m_pImpl->rModel.getLineColor();
+ //if row is selected and line color isn't user specified, set it blue
+ if(_bSelected)
+ {
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(_rStyle.GetHighlightColor());
+ else
+ _rDevice.SetLineColor(line);
+ }
+ //else set line color to the color of row background
+ else
+ {
+ if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2)
+ {
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(background2);
+ else
+ _rDevice.SetLineColor(line);
+ }
+ else if(background1 != 0xFFFFFF && line == 0xFFFFFF)
+ _rDevice.SetLineColor(background1);
+ else
{
+ //if line color is set, then it was user defined and should be visible
+ //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
+ _rDevice.SetLineColor(line);
+ }
+ }
+ _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
+ {
// TODO: remove those temporary place holders
Rectangle aRect( _rArea );
++aRect.Left(); --aRect.Right();
- ++aRect.Top(); --aRect.Bottom();
+ aRect.Top(); aRect.Bottom();
+ Point imagePos(Point(aRect.Left(), aRect.Top()));
+ Size imageSize = _pCellData->GetSizePixel();
+ if(aRect.GetWidth() > imageSize.Width())
+ {
+ if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1)
+ imagePos.X() = aRect.Left()+((double)(aRect.GetWidth() - imageSize.Width()))/2;
+ else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2)
+ imagePos.X() = aRect.Right() - imageSize.Width();
+ }
+ else
+ imageSize.Width() = aRect.GetWidth();
+ if(aRect.GetHeight() > imageSize.Height())
+ {
+ if(m_pImpl->rModel.getVerticalAlign() == 1)
+ imagePos.Y() = aRect.Top()+((double)(aRect.GetHeight() - imageSize.Height()))/2;
+ else if(m_pImpl->rModel.getVerticalAlign() == 2)
+ imagePos.Y() = aRect.Bottom() - imageSize.Height();
+ }
+ else
+ imageSize.Height() = aRect.GetHeight()-1;
+ Image& image (*_pCellData);
+ _rDevice.DrawImage(imagePos, imageSize, image, 0);
+ }
+ _rDevice.Pop();
- String sText;
- if(_bSelected)
- {
- Color aRed(COL_BLUE);
- _rDevice.SetFillColor( aRed );
- _rDevice.SetTextColor(COL_WHITE);
- }
- _rDevice.DrawRect( _rArea );
- (void)_nColumn;
- _rDevice.DrawText( aRect, _rText, TEXT_DRAW_LEFT | TEXT_DRAW_TOP);
+ (void)_bActive;
+ // no special painting for the active cell at the moment
+ }
+
+ //--------------------------------------------------------------------
+ void GridTableRenderer::PaintCellString( ColPos _nColumn, bool _bSelected, bool _bActive,
+ OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText )
+ {
+ _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ Color background1 = m_pImpl->rModel.getOddRowBackgroundColor();
+ Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor();
+ Color line = m_pImpl->rModel.getLineColor();
+ //if row is selected and line color isn't user specified, set it blue
+ if(_bSelected)
+ {
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(_rStyle.GetHighlightColor());
+ else
+ _rDevice.SetLineColor(line);
+ }
+ //else set line color to the color of row background
+ else
+ {
+ if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2)
+ {
+ if(line == 0xFFFFFF)
+ _rDevice.SetLineColor(background2);
+ else
+ _rDevice.SetLineColor(line);
+ }
+ else if(background1 != 0xFFFFFF && line == 0xFFFFFF)
+ _rDevice.SetLineColor(background1);
+ else
+ {
+ //if Line color is set, then it was user defined and should be visible
+ //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
+ _rDevice.SetLineColor(line);
}
+ }
+ _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
+ {
+ // TODO: remove those temporary place holders
+ Rectangle aRect( _rArea );
+ ++aRect.Left(); --aRect.Right();
+ aRect.Top(); aRect.Bottom();
if(_bSelected)
{
- _rDevice.SetFillColor( _rStyle.GetFieldColor() );
- _rDevice.SetTextColor(COL_BLACK);
+ _rDevice.SetTextColor(_rStyle.GetHighlightTextColor());
+ }
+ else
+ _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
+ ULONG nHorFlag = TEXT_DRAW_LEFT;
+ ULONG nVerFlag = TEXT_DRAW_TOP;
+ if(m_pImpl->rModel.getVerticalAlign() == 1)
+ nVerFlag = TEXT_DRAW_VCENTER;
+ else if(m_pImpl->rModel.getVerticalAlign() == 2)
+ nVerFlag = TEXT_DRAW_BOTTOM;
+ if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1)
+ nHorFlag = TEXT_DRAW_CENTER;
+ else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2)
+ nHorFlag = TEXT_DRAW_RIGHT;
+ Rectangle textRect(_rArea);
+ textRect.Left()+=4; textRect.Right()-=4;
+ textRect.Bottom()-=2;
+ _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
}
-
_rDevice.Pop();
-
(void)_bActive;
-// // no special painting for the active cell at the moment
- (void)_rStyle;
-// // TODO: do we need this?
+ // no special painting for the active cell at the moment
}
//--------------------------------------------------------------------
@@ -224,7 +364,7 @@ namespace svt { namespace table
//--------------------------------------------------------------------
void GridTableRenderer::HideCellCursor( Window& _rView, const Rectangle& _rCursorRect)
{
- (void)_rCursorRect;
+ (void)_rCursorRect;
_rView.HideFocus();
}
diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx
index 71c753d3ea86..418348c81b7d 100644
--- a/svtools/source/table/tablecontrol.cxx
+++ b/svtools/source/table/tablecontrol.cxx
@@ -30,6 +30,7 @@
#include "svtools/table/tablecontrol.hxx"
#include "tablegeometry.hxx"
#include "tablecontrol_impl.hxx"
+#include "accessibletableimp.hxx"
#include "svtools/table/tabledatawindow.hxx"
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
@@ -68,15 +69,19 @@ namespace svt { namespace table
TableControl::TableControl( Window* _pParent, WinBits _nStyle )
:Control( _pParent, _nStyle )
,m_pImpl( new TableControl_Impl( *this ) )
+ ,m_bSelectionChanged(false)
{
- m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
- m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
+ TableDataWindow* aTableData = m_pImpl->getDataWindow();
+ aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
+ aTableData->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
+ aTableData->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) );
m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl());
}
//--------------------------------------------------------------------
TableControl::~TableControl()
{
+ ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
DELETEZ( m_pImpl );
if ( m_pAccessTable->m_pAccessible )
{
@@ -106,6 +111,14 @@ namespace svt { namespace table
{
if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) )
Control::KeyInput( rKEvt );
+ else
+ {
+ if(m_bSelectionChanged)
+ {
+ Select();
+ m_bSelectionChanged = false;
+ }
+ }
}
//--------------------------------------------------------------------
void TableControl::Resize()
@@ -162,13 +175,21 @@ namespace svt { namespace table
return m_pImpl->goTo( _nColPos, _nRowPos );
}
//--------------------------------------------------------------------
- void TableControl::InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved)
+ void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved)
{
Rectangle _rRect;
if(_bRemoved)
- return m_pImpl->invalidateRows(_nRowStart, _rRect);
+ m_pImpl->invalidateRows();
else
- return m_pImpl->invalidateRow(_nRowStart, _rRect);
+ {
+ if(m_bSelectionChanged)
+ {
+ m_pImpl->invalidateSelectedRegion(_nRowStart, _nRowEnd, _rRect);
+ m_bSelectionChanged = false;
+ }
+ else
+ m_pImpl->invalidateRow(_nRowStart, _rRect);
+ }
}
//--------------------------------------------------------------------
std::vector<sal_Int32>& TableControl::GetSelectedRows()
@@ -176,7 +197,7 @@ namespace svt { namespace table
return m_pImpl->getSelectedRows();
}
//--------------------------------------------------------------------
- void TableControl::removeSelectedRow(RowPos _nRowPos)
+ void TableControl::RemoveSelectedRow(RowPos _nRowPos)
{
m_pImpl->removeSelectedRow(_nRowPos);
}
@@ -187,20 +208,6 @@ namespace svt { namespace table
return m_pImpl->getCurrentRow( rPoint );
}
- //--------------------------------------------------------------------
-
- IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
- {
- CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
- return 1;
- }
-
- IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
- {
- CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
- return 1;
- }
-
SelectionEngine* TableControl::getSelEngine()
{
return m_pImpl->getSelEngine();
@@ -240,6 +247,7 @@ namespace svt { namespace table
::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const
{
::rtl::OUString aRetText;
+ //Window* pWin;
switch( eObjType )
{
case TCTYPE_GRIDCONTROL:
@@ -255,7 +263,7 @@ namespace svt { namespace table
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) );
break;
case TCTYPE_TABLECELL:
- aRetText = GetCellContent(_nRow, _nCol);
+ aRetText = GetRowName(_nRow);
break;
case TCTYPE_ROWHEADERCELL:
aRetText = GetRowName(_nRow);
@@ -328,20 +336,23 @@ namespace svt { namespace table
// -----------------------------------------------------------------------------
-::rtl::OUString TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
+::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
{
- ::rtl::OUString cellContent = ::rtl::OUString::createFromAscii("");
- std::vector<std::vector<rtl::OUString> >& aTableContent = GetModel()->getCellContent();
+ ::com::sun::star::uno::Any cellContent(::com::sun::star::uno::Any(::rtl::OUString::createFromAscii("")));
+ std::vector<std::vector< ::com::sun::star::uno::Any > >& aTableContent = GetModel()->getCellContent();
if(&aTableContent)
- {
- std::vector<rtl::OUString>& aRowContent = aTableContent[_nRowPos];
- if(&aRowContent)
- cellContent = aRowContent[_nColPos];
- }
+ cellContent = aTableContent[_nRowPos][_nColPos];
return cellContent;
}
// -----------------------------------------------------------------------------
+::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos)
+{
+ ::com::sun::star::uno::Any cellContent = GetCellContent(_nRowPos, _nColPos);
+ return m_pImpl->convertToString(cellContent);
+}
+// -----------------------------------------------------------------------------
+
void TableControl::FillAccessibleStateSet(
::utl::AccessibleStateSetHelper& rStateSet,
AccessibleTableControlObjType eObjType ) const
@@ -374,10 +385,6 @@ void TableControl::FillAccessibleStateSet(
break;
case TCTYPE_TABLECELL:
{
- //sal_Int32 nRow = GetCurRow();
- //sal_uInt16 nColumn = GetCurColumnId();
- //if ( IsFieldVisible(nRow,nColumn) )
- // rStateSet.AddState( AccessibleStateType::VISIBLE );
rStateSet.AddState( AccessibleStateType::TRANSIENT );
rStateSet.AddState( AccessibleStateType::SELECTABLE);
if( GetSelectedRowCount()>0)
@@ -516,25 +523,56 @@ void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNew
Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen)
{
(void)_bOnScreen;
- Rectangle aRectTable, aRectTableWithHeaders;
- m_pImpl->impl_getAllVisibleDataCellArea(aRectTable);
- m_pImpl->impl_getAllVisibleCellsArea(aRectTableWithHeaders);
- Size aSizeTable(aRectTable.GetSize());
- Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize());
- if(_bIsColumnBar)
- return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height()));
- else
- return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height()));
+ return m_pImpl->calcHeaderRect(_bIsColumnBar);
}
// -----------------------------------------------------------------------------
Rectangle TableControl::calcTableRect(BOOL _bOnScreen)
{
(void)_bOnScreen;
- Rectangle aRect;
- m_pImpl->impl_getAllVisibleDataCellArea(aRect);
- return aRect;
+ return m_pImpl->calcTableRect();
+}
+//--------------------------------------------------------------------
+::com::sun::star::uno::Sequence< sal_Int32 >& TableControl::getColumnsForTooltip()
+{
+ return m_nCols;
+}
+//--------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString >& TableControl::getTextForTooltip()
+{
+ return m_aText;
+}
+//--------------------------------------------------------------------
+void TableControl::setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols )
+{
+ m_aText = aText;
+ m_nCols = nCols;
+}
+// -----------------------------------------------------------------------
+void TableControl::selectionChanged(bool _bChanged)
+{
+ m_bSelectionChanged = _bChanged;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG )
+{
+ Select();
+ return 1;
+}
+IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
+{
+ CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
+ return 1;
+}
+IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
+{
+ CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
+ return 1;
+}
+// -----------------------------------------------------------------------
+void TableControl::Select()
+{
+ ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this );
}
-
//........................................................................
}} // namespace svt::table
//........................................................................
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index aacfc28d05be..1526dbdb778d 100644
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -33,9 +33,13 @@
#include "tablecontrol_impl.hxx"
#include "tablegeometry.hxx"
#include "svtools/table/tabledatawindow.hxx"
-
+#include <com/sun/star/awt/XControl.hpp>
#include <vcl/scrbar.hxx>
#include <vcl/seleng.hxx>
+#include <rtl/ref.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <vcl/image.hxx>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <functional>
#include <stdlib.h>
@@ -98,22 +102,22 @@ namespace svt { namespace table
{
return false;
}
- virtual void setRowHeaders(bool _bRowHeaders)
+ virtual void setRowHeaders(bool _bRowHeaders)
{
(void)_bRowHeaders;
}
- virtual void setColumnHeaders(bool _bColumnHeaders)
- {
- (void)_bColumnHeaders;
- }
- void setColumnCount(TableSize _nColCount)
- {
- (void) _nColCount;
- }
- void setRowCount(TableSize _nRowCount)
+ virtual void setColumnHeaders(bool _bColumnHeaders)
{
- (void)_nRowCount;
+ (void)_bColumnHeaders;
}
+ void setColumnCount(TableSize _nColCount)
+ {
+ (void) _nColCount;
+ }
+ void setRowCount(TableSize _nRowCount)
+ {
+ (void)_nRowCount;
+ }
virtual bool isCellEditable( ColPos col, RowPos row ) const
{
(void)col;
@@ -166,39 +170,83 @@ namespace svt { namespace table
{
return 0;
}
- virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const
- {
- (void)overAllHeight;
- (void)actHeight;
- return ScrollbarShowNever;
- }
- virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const
- {
- (void)overAllWidth;
- (void)actWidth;
- return ScrollbarShowNever;
- }
- virtual void setCellContent(std::vector<std::vector<rtl::OUString> > pCellEntryType)
- {
- (void)pCellEntryType;
- }
- virtual std::vector<std::vector<rtl::OUString> >& getCellContent()
+ virtual ScrollbarVisibility getVerticalScrollbarVisibility(int , int ) const
{
- return *( new std::vector<std::vector<rtl::OUString> >);
+ return ScrollbarShowNever;
}
- virtual void setRowHeaderName(std::vector<rtl::OUString> pCellEntryType)
+ virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int , int ) const
{
- (void)pCellEntryType;
+ return ScrollbarShowNever;
}
- virtual std::vector<rtl::OUString>& getRowHeaderName()
- {
- aRowHeaderNames.clear();
- aRowHeaderNames.push_back(rtl::OUString::createFromAscii(""));
- return aRowHeaderNames;
- }
-
- private:
- std::vector<rtl::OUString> aRowHeaderNames;
+ virtual bool hasVerticalScrollbar()
+ {
+ return false;
+ }
+ virtual bool hasHorizontalScrollbar()
+ {
+ return false;
+ }
+ virtual void setCellContent(const std::vector<std::vector< ::com::sun::star::uno::Any > >& )
+ {
+ }
+ virtual ::com::sun::star::util::Color getLineColor()
+ {
+ return 0;
+ }
+ virtual void setLineColor(::com::sun::star::util::Color )
+ {
+ }
+ virtual ::com::sun::star::util::Color getHeaderBackgroundColor()
+ {
+ return -1;
+ }
+ virtual void setHeaderBackgroundColor(::com::sun::star::util::Color )
+ {
+ }
+ virtual ::com::sun::star::util::Color getTextColor()
+ {
+ return 0;
+ }
+ virtual void setTextColor(::com::sun::star::util::Color )
+ {
+ }
+ virtual ::com::sun::star::util::Color getOddRowBackgroundColor()
+ {
+ return -1;
+ }
+ virtual void setOddRowBackgroundColor(::com::sun::star::util::Color )
+ {
+ }
+ virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign()
+ {
+ return com::sun::star::style::VerticalAlignment(0);
+ }
+ virtual void setVerticalAlign(com::sun::star::style::VerticalAlignment )
+ {
+ }
+ virtual ::com::sun::star::util::Color getEvenRowBackgroundColor()
+ {
+ return -1;
+ }
+ virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color )
+ {
+ }
+ virtual std::vector<std::vector< ::com::sun::star::uno::Any > >& getCellContent()
+ {
+ return m_aCellContent;
+ }
+ virtual void setRowHeaderName(const std::vector<rtl::OUString>& )
+ {
+ }
+ virtual std::vector<rtl::OUString>& getRowHeaderName()
+ {
+ aRowHeaderNames.clear();
+ aRowHeaderNames.push_back(rtl::OUString::createFromAscii(""));
+ return aRowHeaderNames;
+ }
+ private:
+ std::vector<rtl::OUString> aRowHeaderNames;
+ std::vector<std::vector< ::com::sun::star::uno::Any > > m_aCellContent;
};
@@ -222,8 +270,8 @@ namespace svt { namespace table
:m_rTable( _rTable )
,m_nSuspendFlags( _nSuspendFlags )
{
- DBG_ASSERT( ( m_rTable.m_nRequiredInvariants & m_nSuspendFlags ) == m_nSuspendFlags,
- "SuspendInvariants: cannot suspend what is already suspended!" );
+ //DBG_ASSERT( ( m_rTable.m_nRequiredInvariants & m_nSuspendFlags ) == m_nSuspendFlags,
+ // "SuspendInvariants: cannot suspend what is already suspended!" );
const_cast< TableControl_Impl& >( m_rTable ).m_nRequiredInvariants &= ~m_nSuspendFlags;
}
~SuspendInvariants()
@@ -303,7 +351,7 @@ namespace svt { namespace table
// m_nColHeaderHeightPixel consistent with the model's value?
{
TableMetrics nHeaderHeight = m_pModel->hasColumnHeaders() ? m_pModel->getColumnHeaderHeight() : 0;
- nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_100TH_MM ).Height();
+ nHeaderHeight = m_rAntiImpl.LogicToPixel( Size( 0, nHeaderHeight ), MAP_APPFONT ).Height();
if ( nHeaderHeight != m_nColHeaderHeightPixel )
return "column header heights are inconsistent!";
}
@@ -312,7 +360,7 @@ namespace svt { namespace table
if ( !isDummyModel )
{
TableMetrics nRowHeight = m_pModel->getRowHeight();
- nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_100TH_MM ).Height();
+ nRowHeight = m_rAntiImpl.LogicToPixel( Size( 0, nRowHeight ), MAP_APPFONT).Height();
if ( nRowHeight != m_nRowHeightPixel )
return "row heights are inconsistent!";
}
@@ -320,13 +368,12 @@ namespace svt { namespace table
// m_nRowHeaderWidthPixel consistent with the model's value?
{
TableMetrics nHeaderWidth = m_pModel->hasRowHeaders() ? m_pModel->getRowHeaderWidth() : 0;
- nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_100TH_MM ).Width();
+ nHeaderWidth = m_rAntiImpl.LogicToPixel( Size( nHeaderWidth, 0 ), MAP_APPFONT ).Width();
if ( nHeaderWidth != m_nRowHeaderWidthPixel )
return "row header widths are inconsistent!";
}
// TODO: check m_aColumnWidthsPixel and m_aAccColumnWidthsPixel
-
if ( m_nCursorHidden < 0 )
return "invalid hidden count for the cursor!";
@@ -369,30 +416,33 @@ namespace svt { namespace table
,m_pModel ( new EmptyTableModel )
,m_pInputHandler ( )
,m_nRowHeightPixel ( 15 )
- ,m_nColHeaderHeightPixel( 0 )
+ ,m_nColHeaderHeightPixel( 0 )
,m_nRowHeaderWidthPixel ( 0 )
,m_nColumnCount ( 0 )
,m_nRowCount ( 0 )
,m_nCurColumn ( COL_INVALID )
,m_nCurRow ( ROW_INVALID )
,m_nLeftColumn ( 0 )
- ,m_nTopRow ( 0 )
+ ,m_nTopRow ( 0 )
,m_nCursorHidden ( 1 )
,m_pDataWindow ( new TableDataWindow( *this ) )
- ,m_pVScroll ( NULL )
+ ,m_pVScroll ( NULL )
,m_pHScroll ( NULL )
,m_pScrollCorner ( NULL )
- ,m_pSelEngine ( )
- ,m_nRowSelected ( )
- ,m_pTableFunctionSet ( new TableFunctionSet(this ) )
- ,m_nAnchor (-1 )
+ ,m_pSelEngine ( )
+ ,m_nRowSelected ( )
+ ,m_pTableFunctionSet ( new TableFunctionSet(this ) )
+ ,m_nAnchor (-1 )
+ ,m_bResizing ( false )
+ ,m_nResizingColumn ( 0 )
+ ,m_bResizingGrid ( false )
#if DBG_UTIL
,m_nRequiredInvariants ( INV_SCROLL_POSITION )
#endif
{
DBG_CTOR( TableControl_Impl, TableControl_Impl_checkInvariants );
- m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet);
- m_pSelEngine->SetSelectionMode(SINGLE_SELECTION);
+ m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet);
+ m_pSelEngine->SetSelectionMode(SINGLE_SELECTION);
m_pDataWindow->SetPosPixel( Point( 0, 0 ) );
m_pDataWindow->Show();
}
@@ -427,14 +477,10 @@ namespace svt { namespace table
TempHideCursor aHideCursor( *this );
- // TODO: revoke as table listener from the model
-
m_pModel = _pModel;
- if ( !m_pModel )
+ if ( !m_pModel)
m_pModel.reset( new EmptyTableModel );
- // TODO: register as table listener
- //m_pModel->addTableModelListener(PTableModelListener(m_pTableModelListener));
m_nCurRow = ROW_INVALID;
m_nCurColumn = COL_INVALID;
@@ -504,11 +550,11 @@ namespace svt { namespace table
m_pInputHandler.reset();
m_nColumnCount = m_nRowCount = 0;
- m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_100TH_MM ).Height();
- if ( m_pModel->hasColumnHeaders() )
- m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_100TH_MM ).Height();
+ m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height();
+ if ( m_pModel->hasColumnHeaders() )
+ m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height();
if ( m_pModel->hasRowHeaders() )
- m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_100TH_MM ).Width();
+ m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width();
impl_ni_updateColumnWidths();
@@ -529,34 +575,116 @@ namespace svt { namespace table
return;
TableSize colCount = m_pModel->getColumnCount();
+
m_aColumnWidthsPixel.reserve( colCount );
m_aAccColumnWidthsPixel.reserve( colCount );
- long accumulatedPixelWidth = 0;
- for ( ColPos col = 0; col < colCount; ++col )
+ if(colCount>0)
{
- PColumnModel pColumn = m_pModel->getColumnModel( col );
- DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" );
- if ( !pColumn )
- continue;
-
- TableMetrics colWidth = pColumn->getWidth();
- DBG_ASSERT( ( colWidth == COLWIDTH_FIT_TO_VIEW ) || ( colWidth > 0 ),
- "TableControl_Impl::impl_ni_updateColumnWidths: invalid column width!" );
-
- long pixelWidth = 0;
- if ( colWidth == COLWIDTH_FIT_TO_VIEW )
+ std::vector<sal_Int32> aPrePixelWidths(0);
+ long accumulatedPixelWidth = 0;
+ int lastResizableCol = -1;
+ double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width();
+ if(m_pModel->hasRowHeaders())
+ {
+ TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth();
+ gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width();
+ }
+ if(m_pModel->hasVerticalScrollbar())
{
- // TODO
- DBG_ERROR( "TableControl_Impl::impl_ni_updateColumnWidths: COLWIDTH_FIT_TO_VIEW not implemented, yet!" );
+ sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
+ gridWidth-=scrollbarWidth;
+ }
+ double colWidthsSum = 0.0;
+ double colWithoutFixedWidthsSum = 0.0;
+ double minColWithoutFixedSum = 0.0;
+ for ( ColPos col = 0; col < colCount; ++col )
+ {
+ PColumnModel pColumn = m_pModel->getColumnModel( col );
+ DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" );
+ if ( !pColumn )
+ continue;
+ TableMetrics colWidth = 0;
+ TableMetrics colPrefWidth = pColumn->getPreferredWidth();
+ bool bResizable = pColumn->isResizable();
+ if(pColumn->getMinWidth() == 0 && bResizable)
+ {
+ pColumn->setMinWidth(1);
+ minColWithoutFixedSum+=m_rAntiImpl.LogicToPixel( Size( 1, 0 ), MAP_APPFONT ).Width();
+ }
+ if(pColumn->getMaxWidth() == 0 && bResizable)
+ pColumn->setMaxWidth(m_rAntiImpl.LogicToPixel( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width());
+ if( colPrefWidth != 0)
+ {
+ if(m_bResizingGrid)
+ {
+ colWidth = pColumn->getWidth();
+ pColumn->setPreferredWidth(0);
+ }
+ else
+ {
+ colWidth = colPrefWidth;
+ pColumn->setWidth(colPrefWidth);
+ }
+ }
+ else
+ colWidth = pColumn->getWidth();
+ long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width();
+ if(bResizable && colPrefWidth == 0)
+ {
+ colWithoutFixedWidthsSum+=pixelWidth;
+ lastResizableCol = col;
+ }
+ colWidthsSum+=pixelWidth;
+ aPrePixelWidths.push_back(pixelWidth);
+ }
+ double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum;
+ double scalingFactor = 1.0;
+ if(m_bResizingGrid)
+ {
+ if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum))
+ scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum;
}
else
{
- pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_100TH_MM ).Width();
+ if(colWidthsSum < gridWidthWithoutFixed)
+ {
+ if(colWithoutFixedWidthsSum>0)
+ scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum;
+ }
+ }
+ for ( ColPos i = 0; i < colCount; ++i )
+ {
+ PColumnModel pColumn = m_pModel->getColumnModel( i );
+ DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" );
+ if ( !pColumn )
+ continue;
+ if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0)
+ {
+ aPrePixelWidths[i]*=scalingFactor;
+ TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width();
+ pColumn->setWidth(logicColWidth);
+ }
+ m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] );
+ m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] );
+ }
+ if(gridWidth > m_aAccColumnWidthsPixel[colCount-1])
+ {
+ if(lastResizableCol >= 0)
+ {
+ PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol);
+ m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1];
+ TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width();
+ pColumn->setWidth(logicColWidth1);
+ while(lastResizableCol < colCount)
+ {
+ if(lastResizableCol == 0)
+ m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol];
+ else
+ m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol];
+ ++lastResizableCol;
+ }
+ }
}
-
- m_aColumnWidthsPixel.push_back( pixelWidth );
-
- m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += pixelWidth );
}
}
@@ -678,6 +806,13 @@ namespace svt { namespace table
Rectangle aDataCellPlayground( Point( 0, 0 ), m_rAntiImpl.GetOutputSizePixel() );
aDataCellPlayground.Left() = m_nRowHeaderWidthPixel;
aDataCellPlayground.Top() = m_nColHeaderHeightPixel;
+ m_nRowCount = m_pModel->getRowCount();
+ m_nColumnCount = m_pModel->getColumnCount();
+
+ if(m_aAccColumnWidthsPixel.empty())
+ {
+ impl_ni_updateColumnWidths();
+ }
// do we need a vertical scrollbar?
bool bFirstRoundVScrollNeed = false;
@@ -709,15 +844,6 @@ namespace svt { namespace table
aDataCellPlayground.Right() -= nScrollbarMetrics;
}
}
- else
- {
- Size regionWithoutHeader = m_rAntiImpl.PixelToLogic(Size(aDataCellPlayground.Right() - aDataCellPlayground.Left(),0),MAP_100TH_MM);
- TableMetrics nColWidth = regionWithoutHeader.Width()/m_nColumnCount;
- for ( ColPos col = 0; col < m_nColumnCount; ++col )
- m_pModel->getColumnModel(col)->setWidth(nColWidth);
- m_rAntiImpl.SetModel(m_pModel);
- }
-
// create or destroy the vertical scrollbar, as needed
lcl_updateScrollbar(
m_rAntiImpl,
@@ -780,6 +906,11 @@ namespace svt { namespace table
m_pScrollCorner->SetPosPixel( Point( aDataCellPlayground.Right() + 1, aDataCellPlayground.Bottom() + 1 ) );
m_pScrollCorner->Show();
}
+ else if(bHaveScrollCorner && bNeedScrollCorner)
+ {
+ m_pScrollCorner->SetPosPixel( Point( aDataCellPlayground.Right() + 1, aDataCellPlayground.Bottom() + 1 ) );
+ m_pScrollCorner->Show();
+ }
// resize the data window
m_pDataWindow->SetSizePixel( Size(
@@ -792,10 +923,26 @@ namespace svt { namespace table
void TableControl_Impl::onResize()
{
DBG_CHECK_ME();
- impl_ni_updateScrollbars();
- //Rectangle aAllCells;
- // impl_getAllVisibleCellsArea( aAllCells );
- //m_pSelEngine->SetVisibleArea(aAllCells);
+ if(m_nRowCount != 0)
+ {
+ if(m_nColumnCount != 0)
+ {
+ if(m_bResizingGrid)
+ impl_ni_updateColumnWidths();
+ invalidateRows();
+ m_bResizingGrid = true;
+ }
+ }
+ else
+ {
+ //In the case that column headers are defined but data hasn't yet been set,
+ //only column headers will be shown
+ if(m_pModel->hasColumnHeaders())
+ if(m_nColHeaderHeightPixel>1)
+ m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel());
+ if(m_nColumnCount != 0)
+ impl_ni_updateScrollbars();
+ }
}
//--------------------------------------------------------------------
@@ -805,7 +952,6 @@ namespace svt { namespace table
if ( !getModel() )
return;
-
PTableRenderer pRenderer = getModel()->getRenderer();
DBG_ASSERT( !!pRenderer, "TableDataWindow::Paint: invalid renderer!" );
if ( !pRenderer )
@@ -813,21 +959,28 @@ namespace svt { namespace table
// our current style settings, to be passed to the renderer
const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings();
-
+ m_nRowCount = m_pModel->getRowCount();
+ TableSize nVisibleRows = impl_getVisibleRows(true);
+ TableSize nActualRows = m_nRowCount;
+ if(m_nRowCount>nVisibleRows)
+ nActualRows = nVisibleRows;
// the area occupied by all (at least partially) visible cells, including
// headers
Rectangle aAllCellsWithHeaders;
impl_getAllVisibleCellsArea( aAllCellsWithHeaders );
- m_nRowCount = m_pModel->getRowCount();
// ............................
// draw the header column area
- if ( getModel()->hasColumnHeaders() )
+ if ( m_pModel->hasColumnHeaders() )
{
TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ),
aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS );
+ Rectangle aColRect(aHeaderRow.getRect());
+ //to avoid double lines when scrolling horizontally
+ if(m_nLeftColumn != 0)
+ --aColRect.Left();
pRenderer->PaintHeaderArea(
- *m_pDataWindow, aHeaderRow.getRect(), true, false, rStyle
+ *m_pDataWindow, aColRect, true, false, rStyle
);
// Note that strictly, aHeaderRow.getRect() also contains the intersection between column
// and row header area. However, below we go to paint this intersection, again,
@@ -850,14 +1003,18 @@ namespace svt { namespace table
// the area occupied by the row header, if any
Rectangle aRowHeaderArea;
- if ( getModel()->hasRowHeaders() )
+ if ( m_pModel->hasRowHeaders() )
{
aRowHeaderArea = aAllCellsWithHeaders;
aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1;
- aRowHeaderArea.Bottom() = m_nRowHeightPixel * m_nRowCount + m_nColHeaderHeightPixel - 1;
- pRenderer->PaintHeaderArea(
- *m_pDataWindow, aRowHeaderArea, false, true, rStyle
- );
+ if(m_nTopRow+nActualRows>m_nRowCount)
+ aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1;
+ else
+ aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1;
+ //to avoid double lines when scrolling vertically
+ if(m_nTopRow != 0)
+ --aRowHeaderArea.Top();
+ pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle);
// Note that strictly, aRowHeaderArea also contains the intersection between column
// and row header area. However, below we go to paint this intersection, again,
// so this hopefully doesn't hurt if we already paint it here.
@@ -866,8 +1023,15 @@ namespace svt { namespace table
{
TableCellGeometry aIntersection( *this, Rectangle( Point( 0, 0 ),
aAllCellsWithHeaders.BottomRight() ), COL_ROW_HEADERS, ROW_COL_HEADERS );
+ Rectangle aInters(aIntersection.getRect());
+ //to avoid double line when scrolling vertically
+ if( m_nTopRow != 0 )
+ {
+ --aInters.Top();
+ --aInters.Bottom();
+ }
pRenderer->PaintHeaderArea(
- *m_pDataWindow, aIntersection.getRect(), true, true, rStyle
+ *m_pDataWindow, aInters, true, true, rStyle
);
}
}
@@ -880,113 +1044,69 @@ namespace svt { namespace table
// paint all rows
Rectangle aAllDataCellsArea;
impl_getAllVisibleDataCellArea( aAllDataCellsArea );
-
- //get the vector, which contains row vectors, each containing the data for the cells in this row
- std::vector<std::vector<rtl::OUString> >& aCellContent = m_pModel->getCellContent();
- //if the vector is empty, fill it with empty data, so the table can be painted
- if(aCellContent.empty())
- {
- std::vector<rtl::OUString> emptyCells;
- while(m_nRowCount!=0)
- {
- aCellContent.push_back(emptyCells);
- --m_nRowCount;
- }
- }
- std::vector<std::vector<rtl::OUString> >::iterator it = aCellContent.begin()+m_nTopRow;
- //get the vector, which contains the row header titles
- std::vector<rtl::OUString>& aRowHeaderContent = m_pModel->getRowHeaderName();
- ::std::vector<rtl::OUString>::iterator itRowName = aRowHeaderContent.begin();
-
- if(m_pModel->hasRowHeaders())
- {
- aRowHeaderContent = m_pModel->getRowHeaderName();
- //if the vector is empty, fill it with empty strings, so the table can be painted
- if(aRowHeaderContent.empty())
- {
- while(m_nRowCount!=0)
- {
- aRowHeaderContent.push_back(rtl::OUString::createFromAscii(""));
- --m_nRowCount;
- }
- }
- itRowName = aRowHeaderContent.begin()+m_nTopRow;
- }
+ ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent();
for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() );
aRowIterator.isValid();
aRowIterator.moveDown() )
{
if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() )
- {
- if(m_pModel->hasRowHeaders())
- ++itRowName;
- ++it;
continue;
- }
bool isActiveRow = ( aRowIterator.getRow() == getCurRow() );
bool isSelectedRow = false;
if(!m_nRowSelected.empty())
{
for(std::vector<RowPos>::iterator itSel=m_nRowSelected.begin();
- itSel!=m_nRowSelected.end();++itSel)
+ itSel!=m_nRowSelected.end();++itSel)
{
if(*itSel == aRowIterator.getRow())
isSelectedRow = true;
}
}
- std::vector<rtl::OUString> aCellData;
- if(it != aCellContent.end())
- {
- aCellData = *it;
- ++it;
- }
- ::std::vector<rtl::OUString>::iterator iter = aCellData.begin()+m_nLeftColumn;
-
+ Rectangle aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea );
+ //to avoid double lines
+ if( aRowIterator.getRow() != 0 )
+ --aRect.Top();
+ if(m_nLeftColumn != 0)
+ --aRect.Left();
// give the redenderer a chance to prepare the row
pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow,
- *m_pDataWindow, aRowIterator.getRect().GetIntersection( aAllDataCellsArea ), rStyle );
+ *m_pDataWindow, aRect, rStyle );
// paint the row header
if ( m_pModel->hasRowHeaders() )
{
- rtl::OUString rowHeaderName;
- if(itRowName != aRowHeaderContent.end())
- {
- rowHeaderName = *itRowName;
- ++itRowName;
- }
Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) );
+ rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()];
pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader,
rStyle, rowHeaderName );
}
if ( !colCount )
continue;
-
// paint all cells in this row
for ( TableCellGeometry aCell( aRowIterator, m_nLeftColumn );
aCell.isValid();
aCell.moveRight()
)
{
- // if ( _rUpdateRect.GetIntersection( aCell.getRect() ).IsEmpty() )
- // continue;
-
- //bool isActiveCell = isActiveRow && ( aCell.getColumn() == getCurColumn() );
bool isSelectedColumn = false;
- rtl::OUString cellData;
- if(aCellData.empty())
- cellData=rtl::OUString::createFromAscii("");
- else if(iter != aCellData.end())
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic;
+ ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()];
+ if(rCellData>>=xGraphic)
+ {
+ Image* pImage = new Image(xGraphic);
+ if(pImage!=NULL)
+ pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
+ *m_pDataWindow, aCell.getRect(), rStyle, pImage );
+ }
+ else
{
- cellData = *iter;
- ++iter;
+ ::rtl::OUString sContent = convertToString(rCellData);
+ pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
+ *m_pDataWindow, aCell.getRect(), rStyle, sContent );
}
- pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
- *m_pDataWindow, aCell.getRect(), rStyle, cellData );
- }
+ }
}
}
-
//--------------------------------------------------------------------
void TableControl_Impl::hideCursor()
{
@@ -1016,70 +1136,70 @@ namespace svt { namespace table
switch ( _eAction )
{
case cursorDown:
- if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ {
+ //if other rows already selected, deselect them
+ if(m_nRowSelected.size()>0)
{
- //if other rows already selected, deselect them
- if(m_nRowSelected.size()>0)
- {
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- it!=m_nRowSelected.end();++it)
- {
- invalidateSelectedRow(*it,rCells);
- m_pDataWindow->Invalidate(rCells);
- }
- m_nRowSelected.clear();
- }
- if(m_nCurRow < m_nRowCount-1)
+ for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
+ it!=m_nRowSelected.end();++it)
{
- ++m_nCurRow;
- m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(*it, *it, rCells);
}
- else
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- ensureVisible(m_nCurColumn,m_nCurRow,false);
- bSuccess = true;
+ m_nRowSelected.clear();
}
- else
+ if(m_nCurRow < m_nRowCount-1)
{
- if ( m_nCurRow < m_nRowCount - 1 )
- bSuccess = goTo( m_nCurColumn, m_nCurRow + 1 );
+ ++m_nCurRow;
+ m_nRowSelected.push_back(m_nCurRow);
}
+ else
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ ensureVisible(m_nCurColumn,m_nCurRow,false);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
+ }
+ else
+ {
+ if ( m_nCurRow < m_nRowCount - 1 )
+ bSuccess = goTo( m_nCurColumn, m_nCurRow + 1 );
+ }
break;
case cursorUp:
- if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ {
+ if(m_nRowSelected.size()>0)
{
- if(m_nRowSelected.size()>0)
- {
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
+ for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
it!=m_nRowSelected.end();++it)
- {
- invalidateSelectedRow(*it,rCells);
- m_pDataWindow->Invalidate(rCells);
- }
- m_nRowSelected.clear();
- }
- if(m_nCurRow>0)
{
- --m_nCurRow;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
+ invalidateSelectedRegion(*it, *it, rCells);
}
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- }
- ensureVisible(m_nCurColumn,m_nCurRow,false);
- bSuccess = true;
+ m_nRowSelected.clear();
+ }
+ if(m_nCurRow>0)
+ {
+ --m_nCurRow;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
else
{
- if ( m_nCurRow > 0 )
- bSuccess = goTo( m_nCurColumn, m_nCurRow - 1 );
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
- break;
+ ensureVisible(m_nCurColumn,m_nCurRow,false);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
+ }
+ else
+ {
+ if ( m_nCurRow > 0 )
+ bSuccess = goTo( m_nCurColumn, m_nCurRow - 1 );
+ }
+ break;
case cursorLeft:
if ( m_nCurColumn > 0 )
bSuccess = goTo( m_nCurColumn - 1, m_nCurRow );
@@ -1133,225 +1253,251 @@ namespace svt { namespace table
case cursorBottomRight:
bSuccess = goTo( m_nColumnCount - 1, m_nRowCount - 1 );
break;
-
- case cursorSelectRow:
+ case cursorSelectRow:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ //pos is the position of the current row in the vector of selected rows, if current row is selected
+ int pos = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
+ //if current row is selected, it should be deselected, when ALT+SPACE are pressed
+ if(pos>-1)
+ {
+ m_nRowSelected.erase(m_nRowSelected.begin()+pos);
+ if(m_nRowSelected.empty() && m_nAnchor != -1)
+ m_nAnchor = -1;
+ }
+ //else select the row->put it in the vector
+ else
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
+ }
+ break;
+ case cursorSelectRowUp:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
{
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- //pos is the position of the current row in the vector of selected rows, if current row is selected
- int pos = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- //if current row is selected, it should be deselected, when ALT+SPACE are pressed
- if(pos>-1)
- m_nRowSelected.erase(m_nRowSelected.begin()+pos);
- //else select the row->put it in the vector
- else
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- bSuccess = true;
+ //if there are other selected rows, deselect them
+ return false;
}
- break;
- case cursorSelectRowUp:
+ else
{
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ //there are other selected rows
+ if(m_nRowSelected.size()>0)
{
- //if there are other selected rows, deselect them
- return false;
- }
- else
- {
- //there are other selected rows
- if(m_nRowSelected.size()>0)
+ //the anchor wasn't set -> a region is not selected, that's why clear all selection
+ //and select the current row
+ if(m_nAnchor==-1)
{
- //the anchor wasn't set -> a region is not selected, that's why clear all selection
- //and select the current row
- if(m_nAnchor==-1)
- {
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
+ for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
it!=m_nRowSelected.end();++it)
- {
- invalidateSelectedRow(*it,rCells);
- m_pDataWindow->Invalidate(rCells);
- }
- m_nRowSelected.clear();
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
+ {
+ invalidateSelectedRegion(*it, *it, rCells);
}
+ m_nRowSelected.clear();
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
+ else
+ {
+ //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected
+ int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
+ int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow-1);
+ if(prevRow>-1)
+ {
+ //if m_nCurRow isn't the upper one, can move up, otherwise not
+ if(m_nCurRow>0)
+ m_nCurRow--;
+ else
+ return bSuccess = true;
+ //if nextRow already selected, deselect it, otherwise select it
+ if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow)
+ {
+ m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells);
+ }
+ else
+ {
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
+ }
else
{
- //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected
- int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow-1);
- if(prevRow>-1)
+ if(m_nCurRow>0)
{
- //if m_nCurRow isn't the upper one, can move up, otherwise not
- if(m_nCurRow>0)
- m_nCurRow--;
- else
- return bSuccess = true;
- //if nextRow already selected, deselect it, otherwise select it
- if(m_nRowSelected[nextRow] == m_nCurRow)
- {
- m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
- invalidateSelectedRow(m_nCurRow+1, rCells);
- }
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- }
+ m_nRowSelected.push_back(m_nCurRow);
+ m_nCurRow--;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
}
}
}
+ }
+ else
+ {
+ //if nothing is selected and the current row isn't the upper one
+ //select the current and one row above
+ //otherwise select only the upper row
+ if(m_nCurRow>0)
+ {
+ m_nRowSelected.push_back(m_nCurRow);
+ m_nCurRow--;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
+ }
else
{
- //if nothing is selected and the current row isn't the upper one
- //select the current and one row above
- //otherwise select only the upper row
- if(m_nCurRow>0)
- {
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow--;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
- }
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- }
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
- m_pSelEngine->SetAnchor(TRUE);
- m_nAnchor = m_nCurRow;
- ensureVisible(m_nCurColumn, m_nCurRow, false);
- bSuccess = true;
}
+ m_pSelEngine->SetAnchor(TRUE);
+ m_nAnchor = m_nCurRow;
+ ensureVisible(m_nCurColumn, m_nCurRow, false);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
}
- break;
- case cursorSelectRowDown:
+ }
+ break;
+ case cursorSelectRowDown:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
{
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- {
- bSuccess = false;
- }
- else
+ bSuccess = false;
+ }
+ else
+ {
+ if(m_nRowSelected.size()>0)
{
- if(m_nRowSelected.size()>0)
+ //the anchor wasn't set -> a region is not selected, that's why clear all selection
+ //and select the current row
+ if(m_nAnchor==-1)
{
- //the anchor wasn't set -> a region is not selected, that's why clear all selection
- //and select the current row
- if(m_nAnchor==-1)
- {
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
+ for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
it!=m_nRowSelected.end();++it)
- {
- invalidateSelectedRow(*it,rCells);
- m_pDataWindow->Invalidate(rCells);
- }
- m_nRowSelected.clear();
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- }
- else
{
- //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected
- int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow+1);
- if(prevRow>-1)
- {
- //if m_nCurRow isn't the last one, can move down, otherwise not
- if(m_nCurRow<m_nRowCount)
- m_nCurRow++;
- else
- return bSuccess = true;
- //if net row already selected, deselect it, otherwise select it
- if(m_nRowSelected[nextRow] == m_nCurRow)
- {
- m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
- invalidateSelectedRow(m_nCurRow-1, rCells);
- }
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
- }
- }
+ invalidateSelectedRegion(*it, *it, rCells);
+ }
+ m_nRowSelected.clear();
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
- }
else
{
- //there wasn't any selection, select curennt and row beneath, otherwise onlyrow beneath
- if(m_nCurRow<m_nRowCount-1)
- {
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow++;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
+ //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected
+ int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
+ int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow+1);
+ if(prevRow>-1)
+ {
+ //if m_nCurRow isn't the last one, can move down, otherwise not
+ if(m_nCurRow<m_nRowCount-1)
+ m_nCurRow++;
+ else
+ return bSuccess = true;
+ //if next row already selected, deselect it, otherwise select it
+ if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow)
+ {
+ m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells);
+ }
+ else
+ {
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
}
else
{
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRow(m_nCurRow, rCells);
+ if(m_nCurRow<m_nRowCount-1)
+ {
+ m_nRowSelected.push_back(m_nCurRow);
+ m_nCurRow++;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
+ }
}
}
- m_pSelEngine->SetAnchor(TRUE);
- m_nAnchor = m_nCurRow;
- ensureVisible(m_nCurColumn, m_nCurRow, false);
- bSuccess = true;
}
- }
- break;
- case cursorSelectRowAreaTop:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- bSuccess = false;
else
{
- //select the region between the current and the upper row
- RowPos iter = m_nCurRow;
- invalidateSelectedRegion(m_nCurRow, 0, rCells);
- //put the rows in vector
- while(iter>=0)
+ //there wasn't any selection, select current and row beneath, otherwise only row beneath
+ if(m_nCurRow<m_nRowCount-1)
+ {
+ m_nRowSelected.push_back(m_nCurRow);
+ m_nCurRow++;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
+ }
+ else
{
- if(!isRowSelected(m_nRowSelected, iter))
- m_nRowSelected.push_back(iter);
- --iter;
+ m_nRowSelected.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
- m_nCurRow = 0;
- m_nAnchor = m_nCurRow;
- m_pSelEngine->SetAnchor(TRUE);
- ensureVisible(m_nCurColumn, 0, false);
- bSuccess = true;
}
+ m_pSelEngine->SetAnchor(TRUE);
+ m_nAnchor = m_nCurRow;
+ ensureVisible(m_nCurColumn, m_nCurRow, false);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
}
+ }
break;
- case cursorSelectRowAreaBottom:
+ case cursorSelectRowAreaTop:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ bSuccess = false;
+ else
{
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- return bSuccess = false;
- //select the region between the current and the last row
+ //select the region between the current and the upper row
RowPos iter = m_nCurRow;
- invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells);
- //put the rows in the vector
- while(iter<=m_nRowCount)
+ invalidateSelectedRegion(m_nCurRow, 0, rCells);
+ //put the rows in vector
+ while(iter>=0)
{
if(!isRowSelected(m_nRowSelected, iter))
m_nRowSelected.push_back(iter);
- ++iter;
+ --iter;
}
- m_nCurRow = m_nRowCount-1;
+ m_nCurRow = 0;
m_nAnchor = m_nCurRow;
m_pSelEngine->SetAnchor(TRUE);
- ensureVisible(m_nCurColumn, m_nRowCount, false);
+ ensureVisible(m_nCurColumn, 0, false);
+ m_rAntiImpl.selectionChanged(true);
bSuccess = true;
}
+ }
+ break;
+ case cursorSelectRowAreaBottom:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ return bSuccess = false;
+ //select the region between the current and the last row
+ RowPos iter = m_nCurRow;
+ invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells);
+ //put the rows in the vector
+ while(iter<=m_nRowCount)
+ {
+ if(!isRowSelected(m_nRowSelected, iter))
+ m_nRowSelected.push_back(iter);
+ ++iter;
+ }
+ m_nCurRow = m_nRowCount-1;
+ m_nAnchor = m_nCurRow;
+ m_pSelEngine->SetAnchor(TRUE);
+ ensureVisible(m_nCurColumn, m_nRowCount-1, false);
+ m_rAntiImpl.selectionChanged(true);
+ bSuccess = true;
+ }
break;
default:
DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" );
@@ -1367,16 +1513,12 @@ namespace svt { namespace table
{
Rectangle aCellRect;
impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect );
-
- // const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings();
+ if(!m_pModel->hasRowHeaders() && m_nCurColumn == 0)
+ aCellRect.Left()++;
if ( _bShow )
- {
pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect);
- }
else
- {
pRenderer->HideCellCursor( *m_pDataWindow, aCellRect);
- }
}
}
@@ -1394,16 +1536,12 @@ namespace svt { namespace table
return;
}
- DBG_ASSERT( ( _nColumn >= 0 ) && ( _nColumn < m_pModel->getColumnCount() ),
- "TableControl_Impl::impl_getCellRect: invalid column index!" );
- DBG_ASSERT( ( _nRow >= 0 ) && ( _nRow < m_pModel->getRowCount() ),
- "TableControl_Impl::impl_getCellRect: invalid row index!" );
-
Rectangle aAllCells;
impl_getAllVisibleCellsArea( aAllCells );
TableCellGeometry aCell( *this, aAllCells, _nColumn, _nRow );
_rCellRect = aCell.getRect();
+ _rCellRect.Top()--;_rCellRect.Left()--;
}
//-------------------------------------------------------------------------------
RowPos TableControl_Impl::getCurrentRow(const Point& rPoint)
@@ -1412,8 +1550,7 @@ namespace svt { namespace table
Rectangle rCellRect;
RowPos newRowPos = -2;//-1 is HeaderRow
ColPos newColPos = 0;
- //To Do: when only row position needed, the second loop isn't necessary, Please proove this!!!
- for(int i=0;i<m_nRowCount;i++)
+ for(int i=-1;i<m_nRowCount;i++)
{
for(int j=-1;j<m_nColumnCount;j++)
{
@@ -1422,9 +1559,7 @@ namespace svt { namespace table
{
newRowPos = i;
newColPos = j;
- if(newColPos == -1)
- m_nCurColumn = 0;
- else
+ if(newColPos != -1)
m_nCurColumn = newColPos;
return newRowPos;
}
@@ -1432,7 +1567,7 @@ namespace svt { namespace table
}
return newRowPos;
}
- //-------------------------------------------------------------------------------
+ //-------------------------------------------------------------------------------
void TableControl_Impl::setCursorAtCurrentCell(const Point& rPoint)
{
DBG_CHECK_ME();
@@ -1440,7 +1575,6 @@ namespace svt { namespace table
Rectangle rCellRect;
RowPos newRowPos = -2;//-1 is HeaderRow
ColPos newColPos = 0;
- //To Do: when only row position needed, the second loop isn't necessary, Please proove this!!!
for(int i=0;i<m_nRowCount;i++)
{
for(int j=-1;j<m_nColumnCount;j++)
@@ -1460,7 +1594,6 @@ namespace svt { namespace table
}
showCursor();
}
-
//-------------------------------------------------------------------------------
void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect)
{
@@ -1475,14 +1608,14 @@ namespace svt { namespace table
if(_nPrevRow == _nCurRow)
{
impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Top()=rCells.Top();
+ _rCellRect.Top()=--rCells.Top();
_rCellRect.Bottom()=rCells.Bottom();
}
//if the region is above the current row
else if(_nPrevRow < _nCurRow )
{
impl_getCellRect(m_nCurColumn,_nPrevRow,rCells);
- _rCellRect.Top()=rCells.Top();
+ _rCellRect.Top()= --rCells.Top();
impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
_rCellRect.Bottom()=rCells.Bottom();
}
@@ -1490,46 +1623,31 @@ namespace svt { namespace table
else
{
impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Top()=rCells.Top();
+ _rCellRect.Top()= --rCells.Top();
impl_getCellRect(m_nCurColumn,_nPrevRow,rCells);
_rCellRect.Bottom()=rCells.Bottom();
}
m_pDataWindow->Invalidate(_rCellRect);
}
-
- //-------------------------------------------------------------------------------
- //To Do: not really needed, because in method above one row can be invalidate. Please Prove this!!!
- void TableControl_Impl::invalidateSelectedRow(RowPos _nCurRow, Rectangle& _rCellRect)
- {
- DBG_CHECK_ME();
- Rectangle aAllCells;
- impl_getAllVisibleCellsArea( aAllCells );
- _rCellRect.Left() = aAllCells.Left();
- _rCellRect.Right() = aAllCells.Right();
- Rectangle rCells;
- impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Top()=rCells.Top();
- _rCellRect.Bottom()=rCells.Bottom();
- m_pDataWindow->Invalidate(_rCellRect);
- }
//-------------------------------------------------------------------------------
//this method is to be called, when a new row is added
void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect)
{
- //DBG_CHECK_ME();
- TempHideCursor aHideCursor( *this );
+ if(m_nCurRow < 0)
+ m_nCurRow = 0;
+ if(m_nCursorHidden == 2)
+ --m_nCursorHidden;
impl_getAllVisibleCellsArea( _rCellRect );
TableRowGeometry _rRow( *this, _rCellRect, _nRowPos);
impl_ni_updateScrollbars();
m_pDataWindow->Invalidate(_rRow.getRect());
}
-
//-------------------------------------------------------------------------------
std::vector<RowPos>& TableControl_Impl::getSelectedRows()
{
return m_nRowSelected;
}
-
+ //-------------------------------------------------------------------------------
void TableControl_Impl::removeSelectedRow(RowPos _nRowPos)
{
int i =0;
@@ -1556,57 +1674,23 @@ namespace svt { namespace table
else
m_nCurRow = _nRowPos-1;
}
- //-------------------------------------------------------------------------------
- void TableControl_Impl::invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect)
+ //------------------------------------------------------------------------------
+ void TableControl_Impl::invalidateRows()
{
- //DBG_CHECK_ME();
- (void)_nRowStart;
- (void)_rCellRect;
- /*TempHideCursor aHideCursor(*this);
- Rectangle aAllCells;
- impl_getAllVisibleCellsArea( aAllCells );
- TableRowGeometry _rRow( *this, aAllCells, _nRowStart);
- _rCellRect = _rRow.getRect();
- Rectangle rCells1;
- impl_getCellRect(m_nCurColumn,m_nRowCount,rCells1);
- _rCellRect.Bottom() = rCells1.Bottom();*/
- /*if(_nRowStart != _nRowEnd)
- {
- TableRowGeometry _rRow( *this, aAllCells, _nRowEnd);
- _rCellRect.Bottom() = _rRow.getRect().Bottom();
- }
- */
- //_rCellRect.Right() = aAllCells.Right();
- //_rCellRect.Left() = aAllCells.Left();
- //Rectangle rCells1;
- //impl_getCellRect(m_nCurColumn,_nRowStart,rCells1);
- //_rCellRect.Top()=rCells1.Top();
- //Rectangle rCells2;
- //impl_getCellRect(m_nCurColumn,_nRowEnd,rCells2);
- //_rCellRect.Bottom()=rCells2.Bottom();
impl_ni_updateScrollbars();
- //m_pDataWindow->Invalidate(_rCellRect);
+ TableSize nVisibleRows = impl_getVisibleRows(true);
+ TableSize nVisibleCols = impl_getVisibleColumns(true);
+ if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows)
+ m_nTopRow--;
+ else
+ m_nTopRow = 0;
+ if(m_nLeftColumn+nVisibleCols>m_nColumnCount && m_nColumnCount>=nVisibleCols)
+ m_nLeftColumn--;
+ else
+ m_nLeftColumn = 0;
m_pDataWindow->Invalidate();
}
-
- //-------------------------------------------------------------------------------
- bool TableControl_Impl::isClickInVisibleArea(const Point& rPoint)
- {
- DBG_CHECK_ME();
- long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
- //clickable area is in the visible table control area without the scrollbars
- Rectangle aDataCellPlayground( Point( 0, 0 ), m_rAntiImpl.GetOutputSizePixel() );
- aDataCellPlayground.Top() = m_nColHeaderHeightPixel;
- aDataCellPlayground.Right() -= nScrollbarMetrics;
- aDataCellPlayground.Bottom() -= nScrollbarMetrics;
- if((rPoint.X() >= aDataCellPlayground.Left() && rPoint.X() <= aDataCellPlayground.Right()) && rPoint.Y() >= aDataCellPlayground.Top() && rPoint.Y() <= aDataCellPlayground.Bottom())
- {
- return true;
- }
- else
- return false;
- }
//--------------------------------------------------------------------
TableSize TableControl_Impl::impl_getVisibleRows( bool _bAcceptPartialRow ) const
{
@@ -1654,20 +1738,6 @@ namespace svt { namespace table
// ensure that the new cell is visible
ensureVisible( m_nCurColumn, m_nCurRow, false );
-
- // TODO: invalidate all and new column/row header, if present, to enforce
- // re-painting them
- //if(!m_nRowSelected.empty())
- //{
- // Rectangle rCells;
- // for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- // it!=m_nRowSelected.end();++it)
- // {
- // invalidateSelectedRow(*it,rCells);
- // }
- // m_nRowSelected.clear();
- //}
- // TODO: notify listeners about new position
return true;
}
@@ -1735,7 +1805,7 @@ namespace svt { namespace table
&& abs( nPixelDelta ) < aDataArea.GetHeight()
)
{
- m_pDataWindow->Scroll( 0, (long)-nPixelDelta, aDataArea, SCROLL_CLIP | SCROLL_UPDATE );
+ m_pDataWindow->Scroll( 0, (long)-nPixelDelta, aDataArea, SCROLL_CLIP | SCROLL_UPDATE | SCROLL_CHILDREN);
}
else
m_pDataWindow->Invalidate( INVALIDATE_UPDATE );
@@ -1791,42 +1861,310 @@ namespace svt { namespace table
return (TableSize)( m_nLeftColumn - nOldLeftColumn );
}
-
+ //-------------------------------------------------------------------------------
SelectionEngine* TableControl_Impl::getSelEngine()
{
return m_pSelEngine;
}
+ //-------------------------------------------------------------------------------
TableDataWindow* TableControl_Impl::getDataWindow()
{
return m_pDataWindow;
}
- BOOL TableControl_Impl::isRowSelected(::std::vector<RowPos> selectedRows, RowPos current)
+ //-------------------------------------------------------------------------------
+ ScrollBar* TableControl_Impl::getHorzScrollbar()
+ {
+ return m_pHScroll;
+ }
+ //-------------------------------------------------------------------------------
+ ScrollBar* TableControl_Impl::getVertScrollbar()
+ {
+ return m_pVScroll;
+ }
+ //-------------------------------------------------------------------------------
+ BOOL TableControl_Impl::isRowSelected(const ::std::vector<RowPos>& selectedRows, RowPos current)
+ {
+ return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end();
+ }
+ //-------------------------------------------------------------------------------
+ bool TableControl_Impl::isRowSelected(RowPos current)
+ {
+ return ::std::find(m_nRowSelected.begin(),m_nRowSelected.end(),current) != m_nRowSelected.end();
+ }
+ //-------------------------------------------------------------------------------
+ int TableControl_Impl::getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current)
{
- for(::std::vector<RowPos>::iterator it=selectedRows.begin();
- it!=selectedRows.end();++it)
+ std::vector<RowPos>::const_iterator it = ::std::find(selectedRows.begin(),selectedRows.end(),current);
+ if ( it != selectedRows.end() )
{
- if(*it == current)
- return TRUE;
+ return it - selectedRows.begin();
}
- return FALSE;
+ return -1;
}
-
- int TableControl_Impl::getRowSelectedNumber(::std::vector<RowPos> selectedRows, RowPos current)
+ //-------------------------------------------------------------------------------
+ ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint )
{
- int pos = -1;
- int i = 0;
- for(std::vector<RowPos>::iterator it=selectedRows.begin();it!=selectedRows.end();++it)
+ ::rtl::OUString aTooltipText;
+ RowPos current = getCurrentRow(rPoint);
+ com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip();
+ com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip();
+ if(text.getLength()==0 && cols.getLength()==0)
{
- if(*it == current)
- return pos = i;
- ++i;
+ ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][m_nCurColumn];
+ aTooltipText = convertToString(content);
+ }
+ else if(text.getLength() == 0)
+ {
+ for(int i=0; i<cols.getLength(); i++)
+ {
+ if(i==0)
+ {
+ ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
+ aTooltipText = convertToString(content);
+ }
+ else
+ {
+ aTooltipText+= ::rtl::OUString::createFromAscii("\n");
+ ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
+ aTooltipText += convertToString(content);
+ }
+ }
}
- return pos;
+ else if(cols.getLength() == 0)
+ {
+ for(int i=0; i<text.getLength(); i++)
+ {
+ if(i==0)
+ aTooltipText = text[i];
+ else
+ {
+ aTooltipText+= ::rtl::OUString::createFromAscii("\n");
+ aTooltipText+= text[i];
+ }
+ }
+ }
+ else
+ {
+ int nCols = cols.getLength();
+ int mText = text.getLength();
+ if(nCols < mText )
+ cols.realloc(mText);
+ else if(mText < nCols)
+ text.realloc(nCols);
+ for(int i=0; i<cols.getLength(); i++)
+ {
+ if(i==0)
+ {
+ ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
+ aTooltipText = text[i] + convertToString(content);
+ }
+ else
+ {
+ aTooltipText+= ::rtl::OUString::createFromAscii("\n");
+ aTooltipText+= text[i];
+ if(nCols > i)
+ {
+ ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic;
+ aTooltipText += convertToString(content);
+ }
+ }
+ }
+ }
+ return m_aTooltipText = aTooltipText;
}
-
- void TableControl_Impl::setCellContent(CellEntryType* pCellEntryType)
+ //--------------------------------------------------------------------
+ void TableControl_Impl::resizeColumn(const Point& rPoint)
+ {
+ Pointer aNewPointer(POINTER_ARROW);
+ int headerRowWidth = 0;
+ if(m_pModel->hasRowHeaders())
+ headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
+ int resizingColumn=m_nCurColumn-m_nLeftColumn;
+ PColumnModel pColumn = m_pModel->getColumnModel(m_nCurColumn);
+ impl_ni_getAccVisibleColWidths();
+ int newColWidth = m_aColumnWidthsPixel[m_nCurColumn];
+ //subtract 1 from m_aAccColumnWidthPixel because right border should be part of the current cell
+ if(m_aVisibleColumnWidthsPixel[resizingColumn]-1 == rPoint.X() && pColumn->isResizable())
+ aNewPointer = Pointer( POINTER_HSPLIT );
+ //MouseButton was pressed but not yet released, mouse is moving
+ if(m_bResizing)
+ {
+ if(rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth)
+ aNewPointer = Pointer( POINTER_NOTALLOWED);
+ else
+ aNewPointer = Pointer( POINTER_HSPLIT );
+ m_pDataWindow->HideTracking();
+ int lineHeight = 0;
+ if(m_pModel->hasColumnHeaders())
+ lineHeight+= m_nColHeaderHeightPixel;
+ lineHeight+=m_nRowHeightPixel*m_nRowCount;
+ int gridHeight = m_pDataWindow->GetOutputSizePixel().Height();
+ if(lineHeight >= gridHeight)
+ lineHeight = gridHeight;
+ m_pDataWindow->ShowTracking(Rectangle(Point(rPoint.X(),0), Size(1, lineHeight )),
+ SHOWTRACK_SPLIT | SHOWTRACK_WINDOW);
+ }
+ m_pDataWindow->SetPointer(aNewPointer);
+ }
+ //--------------------------------------------------------------------
+ bool TableControl_Impl::startResizeColumn(const Point& rPoint)
+ {
+ m_bResizingGrid = false;
+ m_nResizingColumn = m_nCurColumn;
+ PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn);
+ if(m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1 == rPoint.X() && pColumn->isResizable())
+ {
+ m_pDataWindow->CaptureMouse();
+ m_bResizing = true;
+ }
+ return m_bResizing;
+ }
+ //--------------------------------------------------------------------
+ bool TableControl_Impl::endResizeColumn(const Point& rPoint)
{
- (void)pCellEntryType;
+ if(m_bResizing)
+ {
+ m_pDataWindow->HideTracking();
+ PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn);
+ int maxWidth = pColumn->getMaxWidth();
+ int minWidth = pColumn->getMinWidth();
+ int resizeCol = m_nResizingColumn-m_nLeftColumn;
+ //new position of mouse
+ int actX = rPoint.X();
+ //old position of right border
+ int oldX = m_aVisibleColumnWidthsPixel[resizeCol];
+ //position of left border if cursor in the first cell
+ int leftX = 0;
+ if(m_nResizingColumn > m_nLeftColumn)
+ leftX = m_aVisibleColumnWidthsPixel[resizeCol-1];
+ else if(m_nResizingColumn == 0 && m_pModel->hasRowHeaders())
+ leftX = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
+ int actWidth = actX - leftX;
+ int newActWidth = 0;
+ //minimize the column width
+ if(oldX > actX && actX >= leftX)
+ {
+ if(minWidth < actWidth)
+ {
+ newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width();
+ pColumn->setPreferredWidth(newActWidth);
+ }
+ else
+ pColumn->setPreferredWidth(minWidth);
+ if(m_nLeftColumn != 0)
+ impl_updateLeftColumn();
+ }
+ else if(oldX < actX)
+ {
+ if(actWidth < maxWidth)
+ {
+ newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width();
+ pColumn->setPreferredWidth(newActWidth);
+ }
+ else
+ pColumn->setPreferredWidth(maxWidth);
+ }
+ m_nCurColumn = m_nResizingColumn;
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+ m_pDataWindow->Invalidate(INVALIDATE_UPDATE);
+ m_pDataWindow->SetPointer(Pointer());
+ m_bResizing = false;
+ m_bResizingGrid = true;
+ }
+ m_pDataWindow->ReleaseMouse();
+ return m_bResizing;
+ }
+ //-------------------------------------------------------------------------------
+ void TableControl_Impl::impl_ni_getAccVisibleColWidths()
+ {
+ TableSize nVisCols = impl_getVisibleColumns(true);
+ int widthsPixel = 0;
+ m_aVisibleColumnWidthsPixel.resize(0);
+ m_aVisibleColumnWidthsPixel.reserve(nVisCols);
+ int headerRowWidth = 0;
+ if(m_pModel->hasRowHeaders())
+ {
+ headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
+ widthsPixel+=headerRowWidth;
+ }
+ int col = m_nLeftColumn;
+ while(nVisCols)
+ {
+ m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=m_aColumnWidthsPixel[col]);
+ col++;
+ nVisCols--;
+ }
+ }
+ //-------------------------------------------------------------------------------
+ void TableControl_Impl::impl_updateLeftColumn()
+ {
+ int nVisCols = m_aVisibleColumnWidthsPixel.size();
+ int headerRowWidth = 0;
+ //sum of currently visible columns
+ int widthsPixel = 0;
+ //header pixel should be added, because header doesn't vanish when scrolling
+ if(m_pModel->hasRowHeaders())
+ {
+ headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
+ widthsPixel+=headerRowWidth;
+ }
+ int col = m_nLeftColumn;
+ //add column width of the neighbour of the left column
+ widthsPixel+=m_aColumnWidthsPixel[col-1];
+ //compute the sum of the new column widths
+ while(nVisCols)
+ {
+ PColumnModel pColumn = m_pModel->getColumnModel(col);
+ int colWidth = pColumn->getWidth();
+ int colPrefWidth = pColumn->getPreferredWidth();
+ if(colPrefWidth!=0)
+ colWidth = colPrefWidth;
+ widthsPixel += m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width();
+ col++;
+ nVisCols--;
+ }
+ //when the sum of all visible columns and the next to the left column is smaller than
+ //window width, then update m_nLeftColumn
+ if(widthsPixel<m_pDataWindow->GetOutputSizePixel().Width())
+ m_nLeftColumn--;
+ }
+ //--------------------------------------------------------------------
+ rtl::OUString TableControl_Impl::convertToString(const ::com::sun::star::uno::Any& value)
+ {
+ sal_Int32 nInt = 0;
+ sal_Bool bBool = false;
+ double fDouble = 0;
+ ::rtl::OUString sNewString;
+ ::rtl::OUString sConvertString;
+ if(value >>= sConvertString)
+ sNewString = sConvertString;
+ else if(value >>= nInt)
+ sNewString = sConvertString.valueOf(nInt);
+ else if(value >>= bBool)
+ sNewString = sConvertString.valueOf(bBool);
+ else if(value >>= fDouble)
+ sNewString = sConvertString.valueOf(fDouble);
+ return sNewString;
+ }
+ Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader)
+ {
+ Rectangle aRectTable, aRectTableWithHeaders;
+ impl_getAllVisibleDataCellArea(aRectTable);
+ impl_getAllVisibleCellsArea(aRectTableWithHeaders);
+ Size aSizeTable(aRectTable.GetSize());
+ Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize());
+ if(bColHeader)
+ return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height()));
+ else
+ return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height()));
+ }
+ Rectangle TableControl_Impl::calcTableRect()
+ {
+ Rectangle aRect;
+ impl_getAllVisibleDataCellArea(aRect);
+ return aRect;
}
//--------------------------------------------------------------------
@@ -1842,34 +2180,33 @@ namespace svt { namespace table
return 0L;
}
-
//---------------------------------------------------------------------------------------
- TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl):
- m_pTableControl( _pTableControl)
- ,m_nCurrentRow (-2)
+ TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl)
+ :m_pTableControl( _pTableControl)
+ ,m_nCurrentRow (-2)
{
}
-
+ //-------------------------------------------------------------------------------
TableFunctionSet::~TableFunctionSet()
{
}
-
+ //-------------------------------------------------------------------------------
void TableFunctionSet::BeginDrag()
{
}
-
+ //-------------------------------------------------------------------------------
void TableFunctionSet::CreateAnchor()
{
m_pTableControl->m_nAnchor = m_pTableControl->m_nCurRow;
}
-
- void TableFunctionSet::DestroyAnchor()
- {
+ //-------------------------------------------------------------------------------
+ void TableFunctionSet::DestroyAnchor()
+ {
m_pTableControl->m_nAnchor = -1;
- }
-
- BOOL TableFunctionSet::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor)
- {
+ }
+ //-------------------------------------------------------------------------------
+ BOOL TableFunctionSet::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor)
+ {
BOOL bHandled = FALSE;
Rectangle rCells;
//curRow is the row where the mouse click happened, m_nCurRow is the last selected row, before the mouse click
@@ -1886,9 +2223,6 @@ namespace svt { namespace table
{
//selecting region,
int diff = m_pTableControl->m_nCurRow - curRow;
- //bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor);
- /* if(!isAlreadySelected && m_nCurrentRow != m_pTableControl->m_nCurRow)
- m_pTableControl->m_nRowSelected.push_back(m_nAnchor);*/
//selected region lies above the last selection
if( diff >= 0)
{
@@ -1924,9 +2258,7 @@ namespace svt { namespace table
else
{
if(m_pTableControl->m_nRowSelected.empty())
- {
m_pTableControl->m_nRowSelected.push_back(curRow);
- }
else
{
if(m_pTableControl->m_pSelEngine->GetSelectionMode()==SINGLE_SELECTION)
@@ -1943,14 +2275,14 @@ namespace svt { namespace table
}
if(m_pTableControl->m_nRowSelected.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION)
m_pTableControl->m_pSelEngine->AddAlways(TRUE);
- m_pTableControl->invalidateSelectedRow(curRow,rCells);
+ m_pTableControl->invalidateSelectedRegion(curRow, curRow, rCells);
bHandled = TRUE;
}
m_pTableControl->m_nCurRow = curRow;
m_pTableControl->ensureVisible(m_pTableControl->m_nCurColumn,m_pTableControl->m_nCurRow,false);
return bHandled;
}
-
+ //-------------------------------------------------------------------------------
BOOL TableFunctionSet::IsSelectionAtPoint( const Point& rPoint )
{
m_pTableControl->m_pSelEngine->AddAlways(FALSE);
@@ -1965,7 +2297,7 @@ namespace svt { namespace table
return selected;
}
}
-
+ //-------------------------------------------------------------------------------
void TableFunctionSet::DeselectAtPoint( const Point& rPoint )
{
(void)rPoint;
@@ -1978,21 +2310,22 @@ namespace svt { namespace table
if(*it == m_nCurrentRow)
{
pos = i;
- m_pTableControl->invalidateSelectedRow(*it,rCells);
+ m_pTableControl->invalidateSelectedRegion(*it, *it, rCells);
}
++i;
}
m_pTableControl->m_nRowSelected.erase(m_pTableControl->m_nRowSelected.begin()+pos);
}
+ //-------------------------------------------------------------------------------
void TableFunctionSet::DeselectAll()
{
if(!m_pTableControl->m_nRowSelected.empty())
{
Rectangle rCells;
for(std::vector<RowPos>::iterator it=m_pTableControl->m_nRowSelected.begin();
- it!=m_pTableControl->m_nRowSelected.end();++it)
+ it!=m_pTableControl->m_nRowSelected.end();++it)
{
- m_pTableControl->invalidateSelectedRow(*it,rCells);
+ m_pTableControl->invalidateSelectedRegion(*it, *it, rCells);
}
m_pTableControl->m_nRowSelected.clear();
}
diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx
index dc875cd137fe..0a487c77c76c 100644
--- a/svtools/source/table/tablecontrol_impl.hxx
+++ b/svtools/source/table/tablecontrol_impl.hxx
@@ -39,6 +39,7 @@
#include <vector>
#include <vcl/seleng.hxx>
+
class ScrollBar;
class ScrollBarBox;
@@ -62,60 +63,64 @@ namespace svt { namespace table
friend class TableRowGeometry;
friend class TableColumnGeometry;
friend class SuspendInvariants;
- friend class TableFunctionSet;
+ friend class TableFunctionSet;
private:
/// the control whose impl-instance we implemnt
- TableControl& m_rAntiImpl;
+ TableControl& m_rAntiImpl;
/// the model of the table control
- PTableModel m_pModel;
+ PTableModel m_pModel;
/// the input handler to use, usually the input handler as provided by ->m_pModel
- PTableInputHandler m_pInputHandler;
+ PTableInputHandler m_pInputHandler;
/// the widths of the single columns, measured in pixel
- ArrayOfLong m_aColumnWidthsPixel;
+ ArrayOfLong m_aColumnWidthsPixel;
/** the accumulated widths of the single columns, i.e. their exclusive right borders,
<strong<not</strong> counting the space for a possible row header column
*/
- ArrayOfLong m_aAccColumnWidthsPixel;
+ ArrayOfLong m_aAccColumnWidthsPixel;
+
+ ArrayOfLong m_aVisibleColumnWidthsPixel;
/// the height of a single row in the table, measured in pixels
- long m_nRowHeightPixel;
+ long m_nRowHeightPixel;
/// the height of the column header row in the table, measured in pixels
- long m_nColHeaderHeightPixel;
+ long m_nColHeaderHeightPixel;
/// the width of the row header column in the table, measured in pixels
- long m_nRowHeaderWidthPixel;
+ long m_nRowHeaderWidthPixel;
/// the number of columns in the table control. Cached model value.
- TableSize m_nColumnCount;
+ TableSize m_nColumnCount;
/// the number of rows in the table control. Cached model value.
- TableSize m_nRowCount;
+ TableSize m_nRowCount;
- ColPos m_nCurColumn;
- RowPos m_nCurRow;
- ColPos m_nLeftColumn;
- RowPos m_nTopRow;
+ ColPos m_nCurColumn;
+ RowPos m_nCurRow;
+ ColPos m_nLeftColumn;
+ RowPos m_nTopRow;
- sal_Int32 m_nCursorHidden;
+ sal_Int32 m_nCursorHidden;
/** the window to contain all data content, including header bars
The window's upper left corner is at position (0,0), relative to the
table control, which is the direct parent of the data window.
*/
- TableDataWindow* m_pDataWindow;
+ TableDataWindow* m_pDataWindow;
/// the vertical scrollbar, if any
- ScrollBar* m_pVScroll;
+ ScrollBar* m_pVScroll;
/// the horizontal scrollbar, if any
ScrollBar* m_pHScroll;
- ScrollBarBox* m_pScrollCorner;
- //selection engine - for determining selection range, e.g. single, multiple
- SelectionEngine* m_pSelEngine;
- //vector which contains the selected rows
- std::vector<RowPos> m_nRowSelected;
- //part of selection engine
- TableFunctionSet* m_pTableFunctionSet;
- //part of selection engine
- RowPos m_nAnchor;
-
-
+ ScrollBarBox* m_pScrollCorner;
+ //selection engine - for determining selection range, e.g. single, multiple
+ SelectionEngine* m_pSelEngine;
+ //vector which contains the selected rows
+ std::vector<RowPos> m_nRowSelected;
+ //part of selection engine
+ TableFunctionSet* m_pTableFunctionSet;
+ //part of selection engine
+ RowPos m_nAnchor;
+ bool m_bResizing;
+ ColPos m_nResizingColumn;
+ bool m_bResizingGrid;
+ rtl::OUString m_aTooltipText;
#if DBG_UTIL
#define INV_SCROLL_POSITION 1
@@ -146,7 +151,6 @@ namespace svt { namespace table
inline const TableControl& getAntiImpl() const { return m_rAntiImpl; }
inline TableControl& getAntiImpl() { return m_rAntiImpl; }
- void setCellContent(CellEntryType* pCellEntryType);
public:
TableControl_Impl( TableControl& _rAntiImpl );
@@ -181,53 +185,42 @@ namespace svt { namespace table
<TRUE/> if it's okay that the given cooordinate is only partially visible
*/
void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility );
- /** returns the row, which contains the input point*/
- RowPos getCurrentRow (const Point& rPoint);
-
- void setCursorAtCurrentCell(const Point& rPoint);
- /** proves whether the vector with the selected rows contains the current row*/
- BOOL isRowSelected(::std::vector<RowPos> selectedRows, RowPos current);
- /** returns the position of the current row in the selecttion vector */
- int getRowSelectedNumber(::std::vector<RowPos> selectedRows, RowPos current);
- /** _rCellRect contains the region, which should be invalidate after some action e.g. selectiong row*/
- void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect );
- /** _rCellRect contains the region, which should be invalidate after some action e.g. selectiong row*/
- //vielleicht kann man mit den anderen verschmelzen, mit einer Überprüfung ob prev==curr?
- void invalidateSelectedRow( RowPos _nCurRow, Rectangle& _rCellRect );
- /** to be called when a new row is added to the control*/
- void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect );
- /** returns the vector, which contains the selected rows*/
- std::vector<RowPos>& getSelectedRows();
- /** updates the vector, which contains the selected rows after removing the row nRowPos*/
- void removeSelectedRow(RowPos _nRowPos);
- void invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect );
- //virtual void DoubleClick();
-
+ /** returns the row, which contains the input point*/
+ virtual RowPos getCurrentRow (const Point& rPoint);
+
+ void setCursorAtCurrentCell(const Point& rPoint);
+ /** checks whether the vector with the selected rows contains the current row*/
+ BOOL isRowSelected(const ::std::vector<RowPos>& selectedRows, RowPos current);
+
+ bool isRowSelected(RowPos current);
+ /** returns the position of the current row in the selection vector */
+ int getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current);
+ /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/
+ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect );
+ /** to be called when a new row is added to the control*/
+ void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect );
+ /** returns the vector, which contains the selected rows*/
+ std::vector<RowPos>& getSelectedRows();
+ /** updates the vector, which contains the selected rows after removing the row nRowPos*/
+ void removeSelectedRow(RowPos _nRowPos);
+ void invalidateRows();
// IAbstractTableControl
virtual void hideCursor();
virtual void showCursor();
virtual bool dispatchAction( TableControlAction _eAction );
- virtual bool isClickInVisibleArea(const Point& rPoint);
- virtual SelectionEngine* getSelEngine();
-
- TableDataWindow* getDataWindow();
- /** retrieves the area occupied by the totality of (at least partially) visible cells
-
- The returned area includes row and column headers. Also, it takes into
- account the the fact that there might be less columns than would normally
- find room in the control.
-
- As a result of respecting the partial visibility of rows and columns,
- the returned area might be larger than the data window's output size.
- */
- void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const;
-
- /** retrieves the area occupied by all (at least partially) visible data cells.
-
- Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea,
- minus the row and column header areas.
- */
- void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const;
+ virtual SelectionEngine* getSelEngine();
+ virtual rtl::OUString& setTooltip(const Point& rPoint );
+ virtual void resizeColumn(const Point& rPoint);
+ virtual bool startResizeColumn(const Point& rPoint);
+ virtual bool endResizeColumn(const Point& rPoint);
+
+ TableDataWindow* getDataWindow();
+ ScrollBar* getHorzScrollbar();
+ ScrollBar* getVertScrollbar();
+
+ ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value);
+ Rectangle calcHeaderRect(bool bColHeader);
+ Rectangle calcTableRect();
private:
/** toggles the cursor visibility
@@ -312,10 +305,30 @@ namespace svt { namespace table
column range were reached.
*/
TableSize impl_ni_ScrollColumns( TableSize _nRowDelta );
+ /** retrieves the area occupied by the totality of (at least partially) visible cells
+
+ The returned area includes row and column headers. Also, it takes into
+ account the the fact that there might be less columns than would normally
+ find room in the control.
+
+ As a result of respecting the partial visibility of rows and columns,
+ the returned area might be larger than the data window's output size.
+ */
+ void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const;
+
+ /** retrieves the area occupied by all (at least partially) visible data cells.
+
+ Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea,
+ minus the row and column header areas.
+ */
+ void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const;
+
+ void impl_ni_getAccVisibleColWidths();
+ void impl_updateLeftColumn();
DECL_LINK( OnScroll, ScrollBar* );
};
- //see seleng.hxx, seleng.cxx, FunctionSet overwritables, part of selection engine
+ //see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine
class TableFunctionSet : public FunctionSet
{
friend class TableDataWindow;
diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx
index 246710488b42..e307071e2699 100644
--- a/svtools/source/table/tabledatawindow.cxx
+++ b/svtools/source/table/tabledatawindow.cxx
@@ -30,6 +30,7 @@
#include "svtools/table/tablecontrol.hxx"
#include "svtools/table/tabledatawindow.hxx"
#include "tablecontrol_impl.hxx"
+#include <vcl/help.hxx>
//........................................................................
namespace svt { namespace table
@@ -44,10 +45,8 @@ namespace svt { namespace table
TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
:Window( &_rTableControl.getAntiImpl() )
,m_rTableControl ( _rTableControl )
+ ,m_nRowAlreadySelected( -1 )
{
- Color backgroundColor = m_rTableControl.getAntiImpl().GetSettings().GetStyleSettings().GetFieldColor();
- SetBackground( backgroundColor );
- SetControlBackground( backgroundColor );
}
//--------------------------------------------------------------------
@@ -55,28 +54,99 @@ namespace svt { namespace table
{
m_rTableControl.doPaintContent( rUpdateRect );
}
+ //--------------------------------------------------------------------
void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
{
+ Point aPoint = rMEvt.GetPosPixel();
if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
- Window::MouseMove( rMEvt );
+ {
+ if(m_rTableControl.getCurrentRow(aPoint)>=0 )
+ {
+ SetPointer(POINTER_ARROW);
+ rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint);
+ Help::EnableBalloonHelp();
+ Window::SetHelpText( rHelpText.getStr());
+ }
+ else if(m_rTableControl.getCurrentRow(aPoint) == -1)
+ {
+ if(Help::IsBalloonHelpEnabled())
+ Help::DisableBalloonHelp();
+ m_rTableControl.resizeColumn(aPoint);
+ }
+ else
+ {
+ if(Help::IsBalloonHelpEnabled())
+ Help::DisableBalloonHelp();
+ Window::MouseMove( rMEvt );
+ }
+ }
}
+ //--------------------------------------------------------------------
void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
+ Point aPoint = rMEvt.GetPosPixel();
+ RowPos nCurRow = m_rTableControl.getCurrentRow(aPoint);
if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) )
Window::MouseButtonDown( rMEvt );
else
- m_aMouseButtonDownHdl.Call( (MouseEvent*) &rMEvt);
+ {
+ if(nCurRow >= 0 && m_rTableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION)
+ {
+ if( m_nRowAlreadySelected != nCurRow )
+ {
+ m_nRowAlreadySelected = nCurRow;
+ m_aSelectHdl.Call( NULL );
+ }
+ else
+ m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt);
+ }
+ else
+ m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt);
+ }
m_rTableControl.getAntiImpl().LoseFocus();
}
+ //--------------------------------------------------------------------
void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) )
Window::MouseButtonUp( rMEvt );
else
- m_aMouseButtonUpHdl.Call( (MouseEvent*) &rMEvt);
+ m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt);
m_rTableControl.getAntiImpl().GetFocus();
}
-
+ //--------------------------------------------------------------------
+ void TableDataWindow::SetPointer( const Pointer& rPointer )
+ {
+ Window::SetPointer(rPointer);
+ }
+ //--------------------------------------------------------------------
+ void TableDataWindow::CaptureMouse()
+ {
+ Window::CaptureMouse();
+ }
+ //--------------------------------------------------------------------
+ void TableDataWindow::ReleaseMouse( )
+ {
+ Window::ReleaseMouse();
+ }
+ // -----------------------------------------------------------------------
+ long TableDataWindow::Notify(NotifyEvent& rNEvt )
+ {
+ long nDone = 0;
+ if ( rNEvt.GetType() == EVENT_COMMAND )
+ {
+ const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
+ if ( rCEvt.GetCommand() == COMMAND_WHEEL )
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
+ {
+ nDone = HandleScrollCommand( rCEvt, m_rTableControl.getHorzScrollbar(), m_rTableControl.getVertScrollbar() );
+ }
+ }
+ }
+ return nDone ? nDone : Window::Notify( rNEvt );
+ }
//........................................................................
} } // namespace svt::table
//........................................................................
diff --git a/svtools/source/table/tablegeometry.cxx b/svtools/source/table/tablegeometry.cxx
index 58bdb531c921..d60de9e6438f 100644
--- a/svtools/source/table/tablegeometry.cxx
+++ b/svtools/source/table/tablegeometry.cxx
@@ -49,8 +49,8 @@ namespace svt { namespace table
{
if ( m_nRowPos == ROW_COL_HEADERS )
{
- DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(),
- "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" );
+ //DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(),
+ // "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" );
m_aRect.Top() = 0;
m_aRect.Bottom() = m_rControl.m_nColHeaderHeightPixel - 1;
}
@@ -87,8 +87,8 @@ namespace svt { namespace table
{
if ( m_nColPos == COL_ROW_HEADERS )
{
- DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(),
- "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" );
+/* DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(),
+ "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" )*/;
m_aRect.Left() = 0;
m_aRect.Right() = m_rControl.m_nRowHeaderWidthPixel - 1;
}
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index 80c31e65d4f1..b411181c2aab 100644..100755
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -28,6 +28,7 @@
#include "precompiled_svtools.hxx"
#include "svtxgridcontrol.hxx"
+#include "accessibletableimp.hxx"
#include <com/sun/star/view/SelectionType.hpp>
#include "svtools/table/gridtablerenderer.hxx"
#include "svtools/table/defaultinputhandler.hxx"
@@ -37,12 +38,17 @@
#include <rtl/ref.hxx>
#include <tools/debug.hxx>
#include <toolkit/helper/property.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
-
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/grid/GridInvalidDataException.hpp>
+#include <com/sun/star/awt/grid/GridInvalidModelException.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
using ::rtl::OUString;
using namespace ::svt::table;
@@ -63,7 +69,10 @@ SVTXGridControl::SVTXGridControl()
m_bHasColumnHeaders(false),
m_bHasRowHeaders(false),
m_bVScroll(false),
- m_bHScroll(false)
+ m_bHScroll(false),
+ m_bUpdate(false),
+ m_nSelectedRowCount(0),
+ m_aSelectionListeners( *this )
{
}
@@ -76,9 +85,10 @@ SVTXGridControl::~SVTXGridControl()
::com::sun::star::uno::Any SVTXGridControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
{
::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
- SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ),
- SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ),
- SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
+ SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ),
+ SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ),
+ SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridColumnListener*, this ),
+ SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
}
@@ -90,36 +100,26 @@ IMPL_XTYPEPROVIDER_START( SVTXGridControl )
VCLXWindow::getTypes()
IMPL_XTYPEPROVIDER_END
-::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL SVTXGridControl::getColumnModel( ) throw (::com::sun::star::uno::RuntimeException)
-{
- return NULL;
-}
-void SAL_CALL SVTXGridControl::setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException)
-{
- (void)model;
-}
-::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL SVTXGridControl::getDataModel( ) throw (::com::sun::star::uno::RuntimeException)
-{
- return NULL;
-}
-void SAL_CALL SVTXGridControl::setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException)
-{
- (void)model;
-}
sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
{
TableControl* pTable = (TableControl*)GetWindow();
return pTable->GetCurrentRow( Point(x,y) );
}
+void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException)
+{
+ TableControl* pTable = (TableControl*)GetWindow();
+ pTable->setTooltip(text, columns);
+}
+
void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- (void)listener;
+ m_aSelectionListeners.addInterface(listener);
}
void SAL_CALL SVTXGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- (void) listener;
+ m_aSelectionListeners.removeInterface(listener);
}
void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException)
@@ -127,7 +127,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
::vos::OGuard aGuard( GetMutex() );
TableControl* pTable = (TableControl*)GetWindow();
-
switch( GetPropertyId( PropertyName ) )
{
case BASEPROPERTY_GRID_SELECTIONMODE:
@@ -155,6 +154,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
if( aValue >>= bHScroll )
{
m_bHScroll = bHScroll;
+ m_pTableModel->setHorizontalScrollbarVisibility(bHScroll);
}
break;
}
@@ -164,9 +164,11 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
if( aValue >>= bVScroll )
{
m_bVScroll = bVScroll;
+ m_pTableModel->setVerticalScrollbarVisibility(bVScroll);
}
break;
}
+
case BASEPROPERTY_GRID_SHOWROWHEADER:
{
sal_Bool rowHeader = true;
@@ -176,6 +178,66 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
}
break;
}
+ case BASEPROPERTY_GRID_HEADER_BACKGROUND:
+ {
+ sal_Int32 colorHeader = 0x000000;
+ if( aValue >>= colorHeader )
+ {
+ m_pTableModel->setHeaderBackgroundColor(colorHeader);
+ }
+ break;
+ }
+ case BASEPROPERTY_GRID_LINE_COLOR:
+ {
+ sal_Int32 colorLine = 0x000000;
+ if( aValue >>= colorLine )
+ {
+ m_pTableModel->setLineColor(colorLine);
+ }
+ break;
+ }
+ case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND:
+ {
+ sal_Int32 colorEvenRow = 0x000000;
+ if( aValue >>= colorEvenRow )
+ {
+ m_pTableModel->setEvenRowBackgroundColor(colorEvenRow);
+ }
+ break;
+ }
+ case BASEPROPERTY_GRID_ROW_BACKGROUND:
+ {
+ sal_Int32 colorBackground = 0x000000;
+ if( aValue >>= colorBackground )
+ {
+ m_pTableModel->setOddRowBackgroundColor(colorBackground);
+ }
+ break;
+ }
+ case BASEPROPERTY_TEXTCOLOR:
+ {
+ sal_Int32 colorText = 0xFFFFFF;
+ if( aValue >>= colorText )
+ {
+ m_pTableModel->setTextColor(colorText);
+ }
+ break;
+ }
+ case BASEPROPERTY_VERTICALALIGN:
+ {
+ com::sun::star::style::VerticalAlignment vAlign(com::sun::star::style::VerticalAlignment(0));
+ if( aValue >>= vAlign )
+ {
+ switch( vAlign )
+ {
+ case com::sun::star::style::VerticalAlignment_TOP: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break;
+ case com::sun::star::style::VerticalAlignment_MIDDLE: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(1)); break;
+ case com::sun::star::style::VerticalAlignment_BOTTOM: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(2)); break;
+ default: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break;
+ }
+ }
+ break;
+ }
case BASEPROPERTY_GRID_SHOWCOLUMNHEADER:
{
@@ -188,40 +250,97 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
}
case BASEPROPERTY_GRID_DATAMODEL:
{
- m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY );
- Sequence<Sequence< ::rtl::OUString > > cellData = m_xDataModel->getData();
- Sequence<rtl::OUString> rowData(0);
- std::vector< std::vector< rtl::OUString > > aCellContent(0);
- for(int i = 0; i< m_xDataModel->getRowCount();++i)
{
- rowData = cellData[i];
- std::vector<rtl::OUString> newRow(
- comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowData));
- if(newRow.size() < (unsigned)m_pTableModel->getColumnCount())
- newRow.resize( m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii(""));
- aCellContent.push_back(newRow);
+ m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY );
+ if(m_xDataModel != NULL)
+ {
+ Sequence<Sequence< Any > > cellData = m_xDataModel->getData();
+ if(cellData.getLength()!= 0)
+ {
+ for (int i = 0; i < cellData.getLength(); i++)
+ {
+ std::vector< Any > newRow;
+ Sequence< Any > rawRowData = cellData[i];
+ //check whether the data row vector length matches with the column count
+ if(m_xColumnModel->getColumnCount() == 0)
+ {
+ for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col )
+ {
+ UnoControlTableColumn* tableColumn = new UnoControlTableColumn();
+ m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
+ }
+ m_xColumnModel->setDefaultColumns(rawRowData.getLength());
+ }
+ else
+ if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount())
+ throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel);
+
+ for ( int k = 0; k < rawRowData.getLength(); k++)
+ {
+ newRow.push_back(rawRowData[k]);
+ }
+ m_pTableModel->getCellContent().push_back(newRow);
+ }
+
+ Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders();
+ std::vector< rtl::OUString > newRow(
+ comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowHeaders));
+ m_pTableModel->setRowCount(m_xDataModel->getRowCount());
+ m_pTableModel->setRowHeaderName(newRow);
+ }
+ }
+ else
+ throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel);
+ sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height();
+ if(m_xDataModel->getRowHeight() == 0)
+ {
+ m_pTableModel->setRowHeight(fontHeight);
+ m_xDataModel->setRowHeight(fontHeight);
+ }
+ else
+ m_pTableModel->setRowHeight(m_xDataModel->getRowHeight());
+ m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth());
}
- m_pTableModel->setCellContent(aCellContent);
- Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders();
- std::vector< rtl::OUString > newRow(
- comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowHeaders));
- m_pTableModel->setRowCount(m_xDataModel->getRowCount());
- m_pTableModel->setRowHeaderName(newRow);
break;
}
case BASEPROPERTY_GRID_COLUMNMODEL:
{
m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY );
- Sequence<Reference< XGridColumn > > columns = m_xColumnModel->getColumns();
- std::vector<Reference< XGridColumn > > aNewColumns(
- comphelper::sequenceToContainer<std::vector<Reference< XGridColumn > > >(columns));
- /* if(m_pTable->GetColumnCount().size()>0)
- m_pTable->GetColumnName.clear();*/
- for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col )
+ if(m_xColumnModel != NULL)
{
- UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]);
- m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
+ if(m_xColumnModel->getColumnCount() != 0)
+ {
+ Sequence<Reference< XGridColumn > > columns = m_xColumnModel->getColumns();
+ std::vector<Reference< XGridColumn > > aNewColumns(
+ comphelper::sequenceToContainer<std::vector<Reference< XGridColumn > > >(columns));
+ sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height();
+ if(m_xColumnModel->getColumnHeaderHeight() == 0)
+ {
+ m_pTableModel->setColumnHeaderHeight(fontHeight);
+ m_xColumnModel->setColumnHeaderHeight(fontHeight);
+ }
+ else
+ m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight());
+ for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col )
+ {
+ UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]);
+ Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col);
+ m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
+ tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign());
+ tableColumn->setWidth(xGridColumn->getColumnWidth());
+ if(xGridColumn->getPreferredWidth() != 0)
+ tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth());
+ if(xGridColumn->getMaxWidth() != 0)
+ tableColumn->setMaxWidth(xGridColumn->getMaxWidth());
+ if(xGridColumn->getMinWidth() != 0)
+ tableColumn->setMinWidth(xGridColumn->getMinWidth());
+ tableColumn->setResizable(xGridColumn->getResizeable());
+ }
+ }
}
+ else
+ throw GridInvalidModelException(rtl::OUString::createFromAscii("The column model isn't set!"), m_xColumnModel);
+
break;
}
default:
@@ -281,7 +400,11 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
BASEPROPERTY_GRID_SHOWCOLUMNHEADER,
BASEPROPERTY_GRID_DATAMODEL,
BASEPROPERTY_GRID_COLUMNMODEL,
- BASEPROPERTY_GRID_SELECTIONMODE,
+ BASEPROPERTY_GRID_SELECTIONMODE,
+ BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND,
+ BASEPROPERTY_GRID_HEADER_BACKGROUND,
+ BASEPROPERTY_GRID_LINE_COLOR,
+ BASEPROPERTY_GRID_ROW_BACKGROUND,
0);
VCLXWindow::ImplGetPropertyIds( rIds, true );
}
@@ -291,7 +414,6 @@ void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun:
if ( pTable )
{
pTable->SetModel(PTableModel(m_pTableModel));
- //m_pTable->SetPosSizePixel( Point( nPosX, nPosY ), Size(nWidth, nHeight) );
pTable->Show( bVisible );
}
}
@@ -303,17 +425,32 @@ void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeEx
}
void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
{
- std::vector<OUString> aNewRow(
- comphelper::sequenceToContainer< std::vector<rtl::OUString > >(Event.rowData));
- if(aNewRow.size()< (unsigned)m_pTableModel->getColumnCount())
- aNewRow.resize(m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii(""));
- m_pTableModel->getCellContent().push_back(aNewRow);
+ std::vector< Any > newRow;
+ Sequence< Any > rawRowData = Event.rowData;
+ int colCount = m_xColumnModel->getColumnCount();
+ if(colCount == 0)
+ {
+ Reference<XGridColumnListener> listener(*this,UNO_QUERY_THROW);
+ m_xColumnModel->setDefaultColumns(rawRowData.getLength());
+ for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col )
+ {
+ UnoControlTableColumn* tableColumn = new UnoControlTableColumn();
+ m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
+ m_xColumnModel->getColumn(col)->addColumnListener(listener);
+ }
+
+ }
+ else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount)
+ throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel);
+
+ for ( int k = 0; k < rawRowData.getLength(); k++)
+ newRow.push_back(rawRowData[k]);
+ m_pTableModel->getCellContent().push_back(newRow);
if(m_pTableModel->hasRowHeaders())
m_pTableModel->getRowHeaderName().push_back(Event.headerName);
- m_pTableModel->setRowCount(m_pTableModel->getRowHeaderName().size());
+ m_pTableModel->setRowCount(m_pTableModel->getCellContent().size());
TableControl* pTable = (TableControl*)GetWindow();
- pTable->InvalidateDataWindow(m_pTableModel->getRowHeaderName().size()-1, false);
- //pTable->GrabFocus();
+ pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, 0, false);
if(pTable->isAccessibleAlive())
{
pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
@@ -335,9 +472,10 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD
void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
{
TableControl* pTable = (TableControl*)GetWindow();
- //unsigned int rows =m_pImpl->aCellContent.size()-1;
if(Event.index == -1)
{
+ if(!isSelectionEmpty())
+ deselectAllRows();
if(m_pTableModel->hasRowHeaders())
m_pTableModel->getRowHeaderName().clear();
m_pTableModel->getCellContent().clear();
@@ -348,76 +486,242 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri
Any());
}
}
- else
+ else if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount())
{
- pTable->removeSelectedRow(Event.index);
- if(m_pTableModel->getCellContent().size()>1)
+ if(isSelectedIndex(Event.index))
{
- if(m_pTableModel->hasRowHeaders())
- m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index);
- m_pTableModel->getCellContent().erase(m_pTableModel->getCellContent().begin()+Event.index);
-
- }
- else
- {
- if(m_pTableModel->hasRowHeaders())
- m_pTableModel->getRowHeaderName().clear();
- m_pTableModel->getCellContent().clear();
- //m_pImpl->nRowCount=0;
+ Sequence<sal_Int32> selected(1);
+ selected[0]=Event.index;
+ deselectRows(selected);
}
+ if(m_pTableModel->hasRowHeaders())
+ m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index);
+ std::vector<std::vector<Any> >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index;
+ m_pTableModel->getCellContent().erase( rowPos );
}
- //pTable->InvalidateDataWindow(Event.index, true);
m_pTableModel->setRowCount(m_pTableModel->getCellContent().size());
- pTable->InvalidateDataWindow(Event.index, true);
+ pTable->InvalidateDataWindow(Event.index, Event.index, true);
if(pTable->isAccessibleAlive())
{
pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())),
Any());
- //pTable->commitGridControlEvent(CHILD,
- // makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)),
- // Any());
- //for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i)
- //{
- // pTable->commitGridControlEvent(
- // CHILD,
- // makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ),
- // Any());
- //}
}
- //pTable->Invalidate();
}
+void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+{
+ TableControl* pTable = (TableControl*)GetWindow();
+ if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize"))
+ {
+ bool resizable = m_pTableModel->getColumnModel()[Event.index]->isResizable();
+ Event.newValue>>=resizable;
+ m_pTableModel->getColumnModel()[Event.index]->setResizable(resizable);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("ColWidth"))
+ {
+ sal_Int32 colWidth = m_pTableModel->getColumnModel()[Event.index]->getWidth();
+ Event.newValue>>=colWidth;
+ m_pTableModel->getColumnModel()[Event.index]->setWidth(colWidth);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("MaxWidth"))
+ {
+ sal_Int32 maxWidth = m_pTableModel->getColumnModel()[Event.index]->getMaxWidth();
+ Event.newValue>>=maxWidth;
+ m_pTableModel->getColumnModel()[Event.index]->setMaxWidth(maxWidth);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("MinWidth"))
+ {
+ sal_Int32 minWidth = m_pTableModel->getColumnModel()[Event.index]->getMinWidth();
+ Event.newValue>>=minWidth;
+ m_pTableModel->getColumnModel()[Event.index]->setMinWidth(minWidth);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("PrefWidth"))
+ {
+ sal_Int32 prefWidth = m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth();
+ Event.newValue>>=prefWidth;
+ m_pTableModel->getColumnModel()[Event.index]->setPreferredWidth(prefWidth);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("HAlign"))
+ {
+ ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel()[Event.index]->getHorizontalAlign();
+ Event.newValue>>=hAlign;
+ m_pTableModel->getColumnModel()[Event.index]->setHorizontalAlign(hAlign);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("UpdateWidth"))
+ {
+ if(m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth() != 0)
+ m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth());
+ m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("ColWidth"), m_pTableModel->getColumnModel()[Event.index]->getWidth());
+ }
+ pTable->Invalidate();
+}
void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
{
- (void) Event;
+ TableControl* pTable = (TableControl*)GetWindow();
+ if(Event.valueName == rtl::OUString::createFromAscii("RowHeight"))
+ {
+ sal_Int32 rowHeight = m_pTableModel->getRowHeight();
+ Event.newValue>>=rowHeight;
+ m_pTableModel->setRowHeight(rowHeight);
+ pTable->Invalidate();
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaderWidth"))
+ {
+ sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth();
+ Event.newValue>>=rowHeaderWidth;
+ m_pTableModel->setRowHeaderWidth(rowHeaderWidth);
+ pTable->Invalidate();
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaders"))
+ {
+ Sequence< rtl::OUString > headers(0);
+ Event.newValue>>=headers;
+ std::vector< rtl::OUString > headerNames( comphelper::sequenceToContainer <std::vector< rtl::OUString > >(headers) );
+ m_pTableModel->setRowHeaderName(headerNames);
+ pTable->Invalidate();
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("CellUpdated"))
+ {
+ std::vector< std::vector< Any > >& rowContent = m_pTableModel->getCellContent();
+ sal_Int32 col = -1;
+ Event.oldValue>>=col;
+ rowContent[Event.index][col] = Event.newValue;
+ pTable->InvalidateDataWindow(Event.index, Event.index, false);
+ }
+ else if(Event.valueName == rtl::OUString::createFromAscii("RowUpdated"))
+ {
+ std::vector<std::vector< Any > >& rowContent = m_pTableModel->getCellContent();
+ Sequence< sal_Int32 > cols(0);
+ Sequence< Any > values(0);
+ Event.oldValue>>=cols;
+ Event.newValue>>=values;
+ for(int i = 0; i< cols.getLength(); i++)
+ {
+ if(cols[i]>=0 && cols[i]<m_pTableModel->getColumnCount())
+ rowContent[Event.index][cols[i]]=values[i];
+ else
+ break;
+ }
+ pTable->InvalidateDataWindow(Event.index, Event.index, false);
+ }
}
- void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
- {
+void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
+{
VCLXWindow::disposing( Source );
- }
+}
::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
{
- return 0;
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(selectedRows.empty())
+ return -1;
+ else
+ {
+ std::vector<RowPos>::iterator itStart = selectedRows.begin();
+ std::vector<RowPos>::iterator itEnd = selectedRows.end();
+ return *(std::min_element(itStart, itEnd));
+ }
}
::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
{
- return 0;
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(selectedRows.empty())
+ return -1;
+ else
+ {
+ std::vector<RowPos>::iterator itStart = selectedRows.begin();
+ std::vector<RowPos>::iterator itEnd = selectedRows.end();
+ return *(std::max_element(itStart, itEnd));
+ }
+}
+
+void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
+{
+ TableControl* pTable = (TableControl*)GetWindow();
+ SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
+ if(eSelMode != NO_SELECTION)
+ {
+ sal_Int32 start = rangeOfRows[0];
+ int seqSize = rangeOfRows.getLength();
+ sal_Int32 end = rangeOfRows[seqSize-1];
+ if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount()))
+ {
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(!selectedRows.empty())
+ selectedRows.clear();
+ if(eSelMode == SINGLE_SELECTION)
+ {
+ if(rangeOfRows.getLength() == 1)
+ selectedRows.push_back(start);
+ else
+ return;
+ }
+ else
+ {
+ for(int i=0;i<seqSize;i++)
+ selectedRows.push_back(rangeOfRows[i]);
+ }
+ pTable->selectionChanged(true);
+ pTable->InvalidateDataWindow(start, end, false);
+ SetSynthesizingVCLEvent( sal_True );
+ pTable->Select();
+ SetSynthesizingVCLEvent( sal_False );
+ }
+ }
}
-void SAL_CALL SVTXGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException)
{
- (void)length;
- (void)start;
+ TableControl* pTable = (TableControl*)GetWindow();
+ SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
+ if(eSelMode != NO_SELECTION)
+ {
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(!selectedRows.empty())
+ selectedRows.clear();
+ for(int i=0;i<m_pTableModel->getRowCount();i++)
+ selectedRows.push_back(i);
+ pTable->Invalidate();
+ SetSynthesizingVCLEvent( sal_True );
+ pTable->Select();
+ SetSynthesizingVCLEvent( sal_False );
+ }
+}
+void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
+{
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ std::vector<RowPos>::iterator itStart = selectedRows.begin();
+ std::vector<RowPos>::iterator itEnd = selectedRows.end();
+ sal_Int32 start = rangeOfRows[0];
+ sal_Int32 end = rangeOfRows[rangeOfRows.getLength()-1];
+ if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount()))
+ {
+ std::vector<RowPos>::iterator iter = std::find(itStart, itEnd, start);
+ selectedRows.erase(iter, iter+(end-start)+1);
+ pTable->selectionChanged(true);
+ pTable->InvalidateDataWindow(start, end, false);
+ SetSynthesizingVCLEvent( sal_True );
+ pTable->Select();
+ SetSynthesizingVCLEvent( sal_False );
+ }
}
-void SAL_CALL SVTXGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException)
{
- (void)end;
- (void)start;
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(!selectedRows.empty())
+ selectedRows.clear();
+ pTable->Invalidate();
+ SetSynthesizingVCLEvent( sal_True );
+ pTable->Select();
+ SetSynthesizingVCLEvent( sal_False );
}
::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException)
@@ -435,21 +739,138 @@ void SAL_CALL SVTXGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int
::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException)
{
- return sal_False;
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(selectedRows.empty())
+ return sal_True;
+ else
+ return sal_False;
}
::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
{
- (void)index;
- return sal_False;
+ TableControl* pTable = (TableControl*)GetWindow();
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ return std::find(selectedRows.begin(),selectedRows.end(), index) != selectedRows.end();
}
-void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
{
- (void)y;
+ if(index<0 || index>=m_pTableModel->getRowCount())
+ return;
+ TableControl* pTable = (TableControl*)GetWindow();
+ SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
+ if(eSelMode != NO_SELECTION)
+ {
+ std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
+ if(eSelMode == MULTIPLE_SELECTION)
+ {
+ if(!isSelectedIndex(index))
+ selectedRows.push_back(index);
+ else
+ return;
+ }
+ else if(eSelMode == SINGLE_SELECTION)
+ {
+ if(!selectedRows.empty())
+ {
+ if(!isSelectedIndex(index))
+ deselectRows(getSelection());
+ else
+ return;
+ }
+ selectedRows.push_back(index);
+ }
+ pTable->selectionChanged(true);
+ pTable->InvalidateDataWindow(index, index, false);
+ SetSynthesizingVCLEvent( sal_True );
+ pTable->Select();
+ SetSynthesizingVCLEvent( sal_False );
+ }
}
void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException)
{
(void)x;
}
+void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ ::com::sun::star::lang::EventObject aObj;
+ aObj.Source = (::cppu::OWeakObject*)this;
+ m_aSelectionListeners.disposeAndClear( aObj );
+ VCLXWindow::dispose();
+}
+
+void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_TABLEROW_SELECT:
+ {
+ TableControl* pTable = (TableControl*)GetWindow();
+
+ if( pTable )
+ {
+ if ( m_aSelectionListeners.getLength() )
+ {
+ ImplCallItemListeners();
+ }
+ }
+ }
+ break;
+
+ default:
+ VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
+ break;
+ }
+}
+
+void SVTXGridControl::ImplCallItemListeners()
+{
+ TableControl* pTable = (TableControl*) GetWindow();
+ if ( pTable && m_aSelectionListeners.getLength() )
+ {
+ ::std::vector<sal_Int32> selRows = pTable->GetSelectedRows();
+ ::com::sun::star::awt::grid::GridSelectionEvent aEvent;
+ aEvent.Source = (::cppu::OWeakObject*)this;
+ aEvent.Column = 0;
+ sal_Int32 actSelRowCount = selRows.size();
+ sal_Int32 diff = actSelRowCount - m_nSelectedRowCount;
+ //row added to selection
+ if(diff >= 1)
+ {
+ aEvent.Action = com::sun::star::awt::grid::SelectionEventType(0);
+ aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Range = diff;
+ }
+ //selected row changed
+ else if(diff == 0)
+ {
+ aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2);
+ aEvent.Range = 0;
+ }
+ else
+ {
+ //selection changed: multiple row deselected, only 1 row is selected
+ if(actSelRowCount == 1)
+ {
+ aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2);
+ }
+ //row is deselected
+ else
+ {
+ aEvent.Row = pTable->GetCurrentRow();
+ aEvent.Action = com::sun::star::awt::grid::SelectionEventType(1);
+ }
+ aEvent.Range = 0;
+ }
+ m_nSelectedRowCount=actSelRowCount;
+ m_aSelectionListeners.selectionChanged( aEvent );
+ }
+}
diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx
index 8e6931d0d805..bcb8badf72e5 100644..100755
--- a/svtools/source/uno/svtxgridcontrol.hxx
+++ b/svtools/source/uno/svtxgridcontrol.hxx
@@ -32,21 +32,23 @@
#include <svtools/table/tablecontrol.hxx>
#include <com/sun/star/awt/grid/XGridControl.hpp>
#include <com/sun/star/awt/grid/XGridDataListener.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
#include <com/sun/star/awt/grid/GridDataEvent.hpp>
+#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridDataModel.hpp>
#include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/awt/vclxwindows.hxx>
#include <cppuhelper/typeprovider.hxx>
-#include <cppuhelper/implbase2.hxx>
-//#include <toolkit/helper/listenermultiplexer.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <toolkit/helper/listenermultiplexer.hxx>
using namespace ::svt::table;
-class SVTXGridControl : public ::cppu::ImplInheritanceHelper2< VCLXWindow, ::com::sun::star::awt::grid::XGridControl,
- ::com::sun::star::awt::grid::XGridDataListener>
+class SVTXGridControl : public ::cppu::ImplInheritanceHelper3< VCLXWindow, ::com::sun::star::awt::grid::XGridControl,
+ ::com::sun::star::awt::grid::XGridDataListener, ::com::sun::star::awt::grid::XGridColumnListener>
{
private:
UnoControlTableModel* m_pTableModel;
@@ -56,34 +58,42 @@ private:
bool m_bHasRowHeaders;
bool m_bVScroll;
bool m_bHScroll;
+ bool m_bUpdate;
+ sal_Int32 m_nSelectedRowCount;
+ SelectionListenerMultiplexer m_aSelectionListeners;
+
+protected:
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+ void ImplCallItemListeners();
public:
- SVTXGridControl();
+ SVTXGridControl();
~SVTXGridControl();
//XGridDataListener overridables
virtual void SAL_CALL rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException);
+
+ //XGridColumnListener overridables
+ virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException);
+
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
- ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
- void SAL_CALL acquire() throw() { VCLXWindow::acquire(); }
- void SAL_CALL release() throw() { VCLXWindow::release(); }
+ ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL acquire() throw() { VCLXWindow::acquire(); }
+ void SAL_CALL release() throw() { VCLXWindow::release(); }
// ::com::sun::star::lang::XTypeProvider
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
//::com::sun::star::awt::grid::XGridControl
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel( ) throw (::com::sun::star::uno::RuntimeException);
- void SAL_CALL setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException);
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel( ) throw (::com::sun::star::uno::RuntimeException);
- void SAL_CALL setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException);
-
virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isCellEditable() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException);
@@ -93,11 +103,15 @@ public:
virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException);
void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException);
static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds );
void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException);
void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XComponent
+ void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
};
#endif // _SVT_GRIDCONTROL_HXX_
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index febb187fb289..d239ee3c740d 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -42,21 +42,32 @@
using ::rtl::OUString;
using namespace ::svt::table;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::awt::grid;
//--------------------------------------------------------------------
UnoControlTableColumn::UnoControlTableColumn(Reference<XGridColumn> m_xGridColumn)
:m_nID( 0 )
,m_sName()
- ,m_bIsResizable( false )
- ,m_nWidth( 10 * 100 ) // 1 cm
- ,m_nMinWidth( 0 ) // no min width
- ,m_nMaxWidth( 0 ) // no max width
+ ,m_bIsResizable( true )
+ ,m_nWidth( 4 )
+ ,m_nMinWidth( 0 )
+ ,m_nMaxWidth( 0 )
+ ,m_nPrefWidth ( 0 )
+ ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0))
+ {
+ m_sName = m_xGridColumn->getTitle();
+ }
+ //--------------------------------------------------------------------
+ UnoControlTableColumn::UnoControlTableColumn()
+ :m_nID( 0 )
+ ,m_sName()
+ ,m_bIsResizable( true )
+ ,m_nWidth( 4 )
+ ,m_nMinWidth( 0 )
+ ,m_nMaxWidth( 0 )
+ ,m_nPrefWidth ( 0 )
+ ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0))
{
- //m_nID = m_xGridColumn->getIdentifier();
- //m_nWidth = m_xGridColumn->getColumnWidth();
- m_sName = m_xGridColumn->getTitle();
}
//--------------------------------------------------------------------
@@ -68,11 +79,7 @@ using namespace ::com::sun::star::awt::grid;
//--------------------------------------------------------------------
bool UnoControlTableColumn::setID( const ColumnID _nID )
{
- // TODO: conflict check
-
m_nID = _nID;
- // TODO: notifications?
-
return true;
}
@@ -86,9 +93,7 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableColumn::setName( const String& _rName )
{
m_sName = _rName;
- // TODO: notifications?
}
-
//--------------------------------------------------------------------
bool UnoControlTableColumn::isResizable() const
{
@@ -99,7 +104,6 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableColumn::setResizable( bool _bResizable )
{
m_bIsResizable = _bResizable;
- // TODO: notifications?
}
//--------------------------------------------------------------------
@@ -112,7 +116,6 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableColumn::setWidth( TableMetrics _nWidth )
{
m_nWidth = _nWidth;
- // TODO: notifications?
}
//--------------------------------------------------------------------
@@ -125,7 +128,6 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth )
{
m_nMinWidth = _nMinWidth;
- // TODO: notifications?
}
//--------------------------------------------------------------------
@@ -138,7 +140,28 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth )
{
m_nMaxWidth = _nMaxWidth;
- // TODO: notifications?
+ }
+ //--------------------------------------------------------------------
+ TableMetrics UnoControlTableColumn::getPreferredWidth() const
+ {
+ return m_nPrefWidth;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth )
+ {
+ m_nPrefWidth = _nPrefWidth;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign()
+ {
+ return m_xHorizontalAlign;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align )
+ {
+ m_xHorizontalAlign = _align;
}
//====================================================================
@@ -146,30 +169,46 @@ using namespace ::com::sun::star::awt::grid;
//====================================================================
struct UnoControlTableModel_Impl
{
- ::std::vector< PColumnModel >& aColumns;
+ ::std::vector< PColumnModel > aColumns;
TableSize nRowCount;
bool bHasColumnHeaders;
bool bHasRowHeaders;
+ bool bVScroll;
+ bool bHScroll;
PTableRenderer pRenderer;
PTableInputHandler pInputHandler;
TableMetrics nRowHeight;
TableMetrics nColumnHeaderHeight;
TableMetrics nRowHeaderWidth;
- std::vector<rtl::OUString>& aRowHeadersTitle;
- std::vector<std::vector<rtl::OUString> >& aCellContent;
+ std::vector<rtl::OUString> aRowHeadersTitle;
+ std::vector<std::vector< Any > > aCellContent;
+ ::com::sun::star::util::Color m_xLineColor;
+ ::com::sun::star::util::Color m_xHeaderColor;
+ ::com::sun::star::util::Color m_xTextColor;
+ ::com::sun::star::util::Color m_xRowColor1;
+ ::com::sun::star::util::Color m_xRowColor2;
+ ::com::sun::star::style::VerticalAlignment m_xVerticalAlign;
UnoControlTableModel_Impl()
- :aColumns ( *(new std::vector< PColumnModel> (0)))
- ,nRowCount ( 0 )
+ :aColumns ( )
+ ,nRowCount ( 0 )
,bHasColumnHeaders ( false )
,bHasRowHeaders ( false )
+ ,bVScroll ( false )
+ ,bHScroll ( false )
,pRenderer ( )
,pInputHandler ( )
- ,nRowHeight ( 4 * 100 ) // 40 mm
- ,nColumnHeaderHeight( 5 * 100 ) // 50 mm
- ,nRowHeaderWidth ( 10 * 100 ) // 50 mm
- ,aRowHeadersTitle ( *(new std::vector<rtl::OUString>(0)))
- ,aCellContent ( *(new std::vector<std::vector<OUString> >(0)))
+ ,nRowHeight ( 0 )
+ ,nColumnHeaderHeight( 0 )
+ ,nRowHeaderWidth ( 10 )
+ ,aRowHeadersTitle ( )
+ ,aCellContent ( )
+ ,m_xLineColor ( 0xFFFFFF )
+ ,m_xHeaderColor ( 0xFFFFFF )
+ ,m_xTextColor ( 0 )//black as default
+ ,m_xRowColor1 ( 0xFFFFFF )
+ ,m_xRowColor2 ( 0xFFFFFF )
+ ,m_xVerticalAlign (com::sun::star::style::VerticalAlignment(0))
{
}
};
@@ -196,7 +235,6 @@ using namespace ::com::sun::star::awt::grid;
//--------------------------------------------------------------------
TableSize UnoControlTableModel::getColumnCount() const
{
- //m_pImpl->aColumns.resize( m_xColumnModel->getColumnCount());
return (TableSize)m_pImpl->aColumns.size();
}
@@ -250,7 +288,6 @@ using namespace ::com::sun::star::awt::grid;
void UnoControlTableModel::addTableModelListener( const PTableModelListener& listener )
{
(void) listener;
- //listener->onTableModelChanged(PTableModel(this));
// TODO
DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" );
}
@@ -321,6 +358,17 @@ using namespace ::com::sun::star::awt::grid;
DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
return m_pImpl->nRowHeaderWidth;
}
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight)
+ {
+ m_pImpl->nColumnHeaderHeight = _nHeight;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth)
+ {
+ m_pImpl->nRowHeaderWidth = _nWidth;
+ }
//--------------------------------------------------------------------
void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight )
@@ -341,7 +389,7 @@ using namespace ::com::sun::star::awt::grid;
//--------------------------------------------------------------------
ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const
{
- if(overAllHeight>=actHeight)// && !m_bVScroll)
+ if(overAllHeight>=actHeight && !m_pImpl->bVScroll)
return ScrollbarShowNever;
else
return ScrollbarShowAlways;
@@ -350,59 +398,116 @@ using namespace ::com::sun::star::awt::grid;
//--------------------------------------------------------------------
ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const
{
- if(overAllWidth>=actWidth)// && !m_bHScroll)
+ if(overAllWidth>=actWidth && !m_pImpl->bHScroll)
return ScrollbarShowNever;
else
return ScrollbarShowAlways;
}
//--------------------------------------------------------------------
- void UnoControlTableModel::setCellContent(std::vector<std::vector<rtl::OUString> > cellContent)
+ void UnoControlTableModel::setVerticalScrollbarVisibility(bool _bVScroll) const
{
- //if(cellContent.empty())
- //{
- // unsigned int i = m_pImpl->aColumns.size();
- // std::vector<rtl::OUString>& emptyCells;
- // while(i!=0)
- // {
- // cellContent.push_back(emptyCells);
- // --i;
- // }
- //}
- //std::vector<rtl::OUString> cCC;
- //for(::std::vector<std::vector<rtl::OUString> >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter)
- //{
- // cCC = *iter;
- // m_pImpl->aCellContent.push_back(cCC);
- //}
- m_pImpl->aCellContent.swap( cellContent );
+ m_pImpl->bVScroll = _bVScroll;
}
- std::vector<std::vector<rtl::OUString> >& UnoControlTableModel::getCellContent()
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setHorizontalScrollbarVisibility(bool _bHScroll) const
{
- return m_pImpl->aCellContent;
+ m_pImpl->bHScroll = _bHScroll;
+ }
+ //--------------------------------------------------------------------
+ bool UnoControlTableModel::hasVerticalScrollbar()
+ {
+ return m_pImpl->bVScroll;
+ }
+ //--------------------------------------------------------------------
+ bool UnoControlTableModel::hasHorizontalScrollbar()
+ {
+ return m_pImpl->bHScroll;
+ }
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setCellContent(const std::vector<std::vector< Any > >& cellContent)
+ {
+ m_pImpl->aCellContent = cellContent;
}
+ std::vector<std::vector< Any > >& UnoControlTableModel::getCellContent()
+ {
+ return m_pImpl->aCellContent;
+ }
//--------------------------------------------------------------------
- void UnoControlTableModel::setRowHeaderName(std::vector<rtl::OUString> cellColumnContent)
+ void UnoControlTableModel::setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent)
{
- if(cellColumnContent.empty())
- {
- unsigned int i = m_pImpl->aColumns.size();
- while(i!=0)
- {
- cellColumnContent.push_back(rtl::OUString::createFromAscii(""));
- --i;
- }
- }
- for(::std::vector<rtl::OUString>::iterator iter = cellColumnContent.begin(); iter!= cellColumnContent.end();++iter)
- {
- rtl::OUString s = *iter;
- m_pImpl->aRowHeadersTitle.push_back(*iter);
- }
+ m_pImpl->aRowHeadersTitle = cellColumnContent;
}
std::vector<rtl::OUString>& UnoControlTableModel::getRowHeaderName()
{
return m_pImpl->aRowHeadersTitle;
}
+ //--------------------------------------------------------------------
+ ::com::sun::star::util::Color UnoControlTableModel::getLineColor()
+ {
+ return m_pImpl->m_xLineColor;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor )
+ {
+ m_pImpl->m_xLineColor = _rColor;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor()
+ {
+ return m_pImpl->m_xHeaderColor;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor )
+ {
+ m_pImpl->m_xHeaderColor = _rColor;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::util::Color UnoControlTableModel::getTextColor()
+ {
+ return m_pImpl->m_xTextColor;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor )
+ {
+ m_pImpl->m_xTextColor = _rColor;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor()
+ {
+ return m_pImpl->m_xRowColor1;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor )
+ {
+ m_pImpl->m_xRowColor1 = _rColor;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor()
+ {
+ return m_pImpl->m_xRowColor2;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor )
+ {
+ m_pImpl->m_xRowColor2 = _rColor;
+ }
+ //--------------------------------------------------------------------
+ ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign()
+ {
+ return m_pImpl->m_xVerticalAlign;
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign )
+ {
+ m_pImpl->m_xVerticalAlign = _xAlign;
+ }
diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx
index 5be4ff2a16f7..c00642448f79 100644
--- a/svtools/source/uno/unocontroltablemodel.hxx
+++ b/svtools/source/uno/unocontroltablemodel.hxx
@@ -41,7 +41,9 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/implbase2.hxx>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
-//#include <toolkit/helper/listenermultiplexer.hxx>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/style/HorizontalAlignment.hpp>
using namespace ::svt::table;
@@ -49,7 +51,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt::grid;
class UnoControlTableColumn : public IColumnModel
- {
+{
private:
ColumnID m_nID;
String m_sName;
@@ -57,9 +59,12 @@ class UnoControlTableColumn : public IColumnModel
TableMetrics m_nWidth;
TableMetrics m_nMinWidth;
TableMetrics m_nMaxWidth;
+ TableMetrics m_nPrefWidth;
+ ::com::sun::star::style::HorizontalAlignment m_xHorizontalAlign;
public:
UnoControlTableColumn(Reference<XGridColumn>);
+ UnoControlTableColumn();
// IColumnModel overridables
virtual ColumnID getID() const;
@@ -74,12 +79,16 @@ class UnoControlTableColumn : public IColumnModel
virtual void setMinWidth( TableMetrics _nMinWidth );
virtual TableMetrics getMaxWidth() const;
virtual void setMaxWidth( TableMetrics _nMaxWidth );
- };
+ virtual TableMetrics getPreferredWidth() const;
+ virtual void setPreferredWidth( TableMetrics _nPrefWidth );
+ virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign();
+ virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign);
+};
- struct UnoControlTableModel_Impl;
+struct UnoControlTableModel_Impl;
- class UnoControlTableModel : public ITableModel
- {
+class UnoControlTableModel : public ITableModel
+{
private:
UnoControlTableModel_Impl* m_pImpl;
@@ -91,6 +100,10 @@ class UnoControlTableColumn : public IColumnModel
inline TableMetrics GetRowHeight() const { return getRowHeight(); }
/// sets a new row height.
void setRowHeight( TableMetrics _nHeight );
+ /// sets a new row header width.
+ void setRowHeaderWidth( TableMetrics _nWidth );
+ /// sets a new column header height.
+ void setColumnHeaderHeight( TableMetrics _nHeight );
/// returns the height of the title row (containing the column headers)
inline TableMetrics GetTitleHeight() const { return getColumnHeaderHeight(); }
@@ -107,23 +120,21 @@ class UnoControlTableColumn : public IColumnModel
/// retrieves the width of a column, in 1/100th millimeters
inline TableMetrics GetColumnWidth( ColPos _nColumn );
- // TODO: setters and getters for ID, Name, Resizable, MinWidth, MaxWidth
-
public:
// ITableModel overridables
virtual TableSize getColumnCount() const;
virtual TableSize getRowCount() const;
- virtual void setColumnCount(TableSize _nColCount);
+ virtual void setColumnCount(TableSize _nColCount);
virtual void setRowCount(TableSize _nRowCount);
virtual bool hasColumnHeaders() const;
virtual bool hasRowHeaders() const;
- virtual void setRowHeaders(bool _bRowHeaders);
- virtual void setColumnHeaders(bool _bColumnHeaders);
+ virtual void setRowHeaders(bool _bRowHeaders);
+ virtual void setColumnHeaders(bool _bColumnHeaders);
virtual bool isCellEditable( ColPos col, RowPos row ) const;
virtual void addTableModelListener( const PTableModelListener& listener );
virtual void removeTableModelListener( const PTableModelListener& listener );
virtual PColumnModel getColumnModel( ColPos column );
- virtual std::vector<PColumnModel>& getColumnModel();
+ virtual std::vector<PColumnModel>& getColumnModel();
virtual PColumnModel getColumnModelByID( ColumnID id );
virtual PTableRenderer getRenderer() const;
virtual PTableInputHandler getInputHandler() const;
@@ -132,19 +143,35 @@ class UnoControlTableColumn : public IColumnModel
virtual TableMetrics getRowHeaderWidth() const;
virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const;
virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const;
- virtual void setCellContent(std::vector<std::vector<rtl::OUString> > cellContent);
- virtual std::vector<std::vector<rtl::OUString> >& getCellContent();
- virtual void setRowHeaderName(std::vector<rtl::OUString> cellColumnContent);
- virtual std::vector<rtl::OUString>& getRowHeaderName();
- };
-
- inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM )
- {
+ virtual void setVerticalScrollbarVisibility(bool _bVScroll) const;
+ virtual void setHorizontalScrollbarVisibility(bool _bHScroll) const;
+ virtual void setCellContent(const std::vector<std::vector< Any > >& cellContent);
+ virtual std::vector<std::vector< Any > >& getCellContent();
+ virtual void setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent);
+ virtual std::vector<rtl::OUString>& getRowHeaderName();
+ virtual ::com::sun::star::util::Color getLineColor();
+ virtual void setLineColor(::com::sun::star::util::Color _rColor);
+ virtual ::com::sun::star::util::Color getHeaderBackgroundColor();
+ virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor);
+ virtual ::com::sun::star::util::Color getTextColor();
+ virtual void setTextColor(::com::sun::star::util::Color _rColor);
+ virtual ::com::sun::star::util::Color getOddRowBackgroundColor();
+ virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor);
+ virtual ::com::sun::star::util::Color getEvenRowBackgroundColor();
+ virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor);
+ virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign();
+ virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign);
+ virtual bool hasVerticalScrollbar();
+ virtual bool hasHorizontalScrollbar();
+};
+
+inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM )
+{
getColumnModel( _nColumn )->setWidth( _nWidth100thMM );
- }
+}
- inline TableMetrics UnoControlTableModel::GetColumnWidth( ColPos _nColumn )
- {
- return getColumnModel( _nColumn )->getWidth();
- }
+inline TableMetrics UnoControlTableModel::GetColumnWidth( ColPos _nColumn )
+{
+ return getColumnModel( _nColumn )->getWidth();
+}
#endif // _UNOCONTROL_TABLEMODEL_HXX_
diff --git a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx
index 65e555f9d799..b9fb82c3d4bb 100644
--- a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx
+++ b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx
@@ -54,7 +54,7 @@
#include <osl/mutex.hxx>
#include <toolkit/helper/mutexhelper.hxx>
#include <toolkit/helper/macros.hxx>
-
+#include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
// ----------------------------------------------------
// class ListenerMultiplexerBase
// ----------------------------------------------------
@@ -244,8 +244,12 @@ DECL_LISTENERMULTIPLEXER_START_DLLPUB( TreeEditListenerMultiplexer, ::com::sun::
virtual void SAL_CALL nodeEdited( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node, const ::rtl::OUString& NewText ) throw (::com::sun::star::uno::RuntimeException);
DECL_LISTENERMULTIPLEXER_END
-
-
+// ----------------------------------------------------
+// class SelectionListenerMultiplexer
+// ----------------------------------------------------
+DECL_LISTENERMULTIPLEXER_START_DLLPUB( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener )
+ void SAL_CALL selectionChanged( const ::com::sun::star::awt::grid::GridSelectionEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+DECL_LISTENERMULTIPLEXER_END
#endif // _TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX_
diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx
index d9adc182f4d7..d5f484145316 100644
--- a/toolkit/inc/toolkit/helper/property.hxx
+++ b/toolkit/inc/toolkit/helper/property.hxx
@@ -196,6 +196,10 @@ namespace rtl {
#define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool
#define BASEPROPERTY_REFERENCE_DEVICE 146
#define BASEPROPERTY_HIGHCONTRASTMODE 147
+#define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 148
+#define BASEPROPERTY_GRID_HEADER_BACKGROUND 149
+#define BASEPROPERTY_GRID_LINE_COLOR 150
+#define BASEPROPERTY_GRID_ROW_BACKGROUND 151
// Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen.
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
index fdf91d6a6593..011f3502cdd8 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
@@ -30,6 +30,7 @@
#include "defaultgridcolumnmodel.hxx"
#include <comphelper/sequence.hxx>
#include <toolkit/helper/servicenames.hxx>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <rtl/ref.hxx>
using ::rtl::OUString;
@@ -38,8 +39,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::awt::grid;
using namespace ::com::sun::star::lang;
-
-#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" ))
+using namespace ::com::sun::star::style;
namespace toolkit
{
@@ -48,8 +48,10 @@ namespace toolkit
// class DefaultGridColumnModel
///////////////////////////////////////////////////////////////////////
-DefaultGridColumnModel::DefaultGridColumnModel()
+DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory)
: columns(std::vector< Reference< XGridColumn > >())
+ ,m_nColumnHeaderHeight(0)
+ ,m_xFactory(xFactory)
{
}
@@ -61,71 +63,6 @@ DefaultGridColumnModel::~DefaultGridColumnModel()
//---------------------------------------------------------------------
-void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent )
-{
- ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() );
- if( pIter )
- {
- ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
- while(aListIter.hasMoreElements())
- {
- XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
- switch( eType )
- {
- case column_added: pListener->columnAdded(aEvent); break;
- case column_removed: pListener->columnRemoved(aEvent); break;
- case column_changed: pListener->columnChanged(aEvent); break;
- }
- }
- }
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL );
- broadcast( column_changed, aEvent);
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
- broadcast( column_added, aEvent);
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
- broadcast( column_changed, aEvent);
-}
-
-//---------------------------------------------------------------------
-// XDefaultGridColumnModel
-//---------------------------------------------------------------------
-::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException)
-{
- return selectionAllowed;
-}
-
-//---------------------------------------------------------------------
-
-void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
-{
- sal_Bool oldValue = selectionAllowed;
- selectionAllowed = value;
- broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed));
-}
-
-//---------------------------------------------------------------------
-
::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException)
{
return columns.size();
@@ -136,11 +73,10 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value
::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
- columns.push_back(column);
-
+ Reference<XGridColumn> xColumn(column);
+ columns.push_back(xColumn);
sal_Int32 index = columns.size() - 1;
- broadcast_add(index, column );
+ xColumn->setIndex(index);
return index;
}
@@ -156,23 +92,48 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value
::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
{
if ( index >=0 && index < ((sal_Int32)columns.size()))
+ {
return columns[index];
+ }
else
return Reference< XGridColumn >();
}
-
-void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+//---------------------------------------------------------------------
+void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException)
+{
+ m_nColumnHeaderHeight = _value;
+}
+//---------------------------------------------------------------------
+sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (::com::sun::star::uno::RuntimeException)
{
- BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener );
+ return m_nColumnHeaderHeight;
}
//---------------------------------------------------------------------
+void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+ for(sal_Int32 i=0;i<rowElements;i++)
+ {
+ Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY );
+ columns.push_back(xColumn);
+ xColumn->setIndex(i);
+ }
+}
+::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException)
{
- BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener );
+ Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY );
+ xColumn->setColumnWidth(column->getColumnWidth());
+ xColumn->setPreferredWidth(column->getPreferredWidth());
+ xColumn->setMaxWidth(column->getMaxWidth());
+ xColumn->setMinWidth(column->getMinWidth());
+ xColumn->setPreferredWidth(column->getPreferredWidth());
+ xColumn->setResizeable(column->getResizeable());
+ xColumn->setTitle(column->getTitle());
+ xColumn->setHorizontalAlign(column->getHorizontalAlign());
+ return xColumn;
}
-
//---------------------------------------------------------------------
// XComponent
//---------------------------------------------------------------------
@@ -232,8 +193,8 @@ sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString
}
-Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& )
+Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& _rFactory)
{
- return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel );
+ return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) );
}
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
index 896427ce3e2b..8b8c8bfc795c 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
@@ -29,7 +29,7 @@
#include "precompiled_toolkit.hxx"
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
-#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
+//#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -38,6 +38,9 @@
#include <rtl/ref.hxx>
#include <vector>
#include <toolkit/helper/mutexandbroadcasthelper.hxx>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -49,45 +52,49 @@ using namespace ::com::sun::star::lang;
namespace toolkit
{
-enum broadcast_type { column_added, column_removed, column_changed};
+//enum broadcast_type { column_added, column_removed, column_changed};
class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >,
public MutexAndBroadcastHelper
{
public:
- DefaultGridColumnModel();
+ DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory);
virtual ~DefaultGridColumnModel();
// XGridColumnModel
- virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
+ //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException);
+ //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
- virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
-
+ //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
+ //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (RuntimeException);
virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
// XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
- virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
-
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
private:
- void broadcast( broadcast_type eType, const GridColumnEvent& aEvent );
- void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue );
+ /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent );
+ void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
- void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
+ void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/
std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns;
sal_Bool selectionAllowed;
+ sal_Int32 m_nColumnHeaderHeight;
+ Reference< XMultiServiceFactory > m_xFactory;
};
}
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index 70c79e0bcbfa..7ffafdf0ddb6 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -41,6 +41,9 @@ using namespace ::com::sun::star::lang;
#define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" ))
#define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" ))
+#define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" ))
+#define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" ))
+#define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" ))
namespace toolkit
{
@@ -51,7 +54,8 @@ namespace toolkit
DefaultGridDataModel::DefaultGridDataModel()
: rowHeight(0),
- rowHeaders(std::vector< ::rtl::OUString >())
+ rowHeaders(std::vector< ::rtl::OUString >()),
+ m_nRowHeaderWidth(10)
{
}
@@ -61,7 +65,7 @@ DefaultGridDataModel::~DefaultGridDataModel()
{
}
-void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent )
+void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException)
{
::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() );
if( pIter )
@@ -82,25 +86,27 @@ void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent&
//---------------------------------------------------------------------
-void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue )
+void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException)
{
Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridDataEvent aEvent( xSource, name, oldValue, newValue, 0, ::rtl::OUString(), Sequence< ::rtl::OUString>() );
+ GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >());
broadcast( data_changed, aEvent);
}
//---------------------------------------------------------------------
-void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData )
+void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName,
+ ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException)
{
Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData );
+ GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData );
broadcast( row_added, aEvent);
}
//---------------------------------------------------------------------
-void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData )
+void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName,
+ ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException)
{
Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData );
@@ -124,7 +130,7 @@ void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com
sal_Int32 oldValue = rowHeight;
rowHeight = value;
- broadcast_changed( ROWHEIGHT, Any(oldValue), Any(value) );
+ broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value));
}
//---------------------------------------------------------------------
@@ -160,24 +166,26 @@ void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::S
i++;
}
- broadcast_changed( ROWHEADERS, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) );
+ broadcast_changed( ROWHEADERS, 0, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) );
}
//---------------------------------------------------------------------
-void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rRowdata) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException)
{
// store header name
rowHeaders.push_back(headername);
-
// store row data
- std::vector< rtl::OUString > newRow(
- comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rRowdata));
+ std::vector< Any > newRow;
+ for ( int i = 0; i < rRowdata.getLength();i++)
+ {
+ newRow.push_back(rRowdata[i]);
+ }
data.push_back( newRow );
- broadcast_add( data.size()-1, headername, rRowdata);
+ broadcast_add( data.size()-1, headername, comphelper::containerToSequence(newRow));
}
@@ -187,16 +195,10 @@ void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::s
{
if ( index >= 0 && index <= getRowCount()-1)
{
- /* if(Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ))
- {
- ::com::sun::star::uno::Sequence<::sal_Int32> selectedRows = Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection();
- selectedRow.erase(selectedRows.begin()+index);
- }*/
-
::rtl::OUString headerName( (::rtl::OUString) rowHeaders[index] );
rowHeaders.erase(rowHeaders.begin() + index);
- Sequence< ::rtl::OUString >& rowData ( (Sequence< ::rtl::OUString >&)data[index] );
+ Sequence< Any >& rowData ( (Sequence< Any >&)data[index] );
data.erase(data.begin() + index);
broadcast_remove( index, headerName, rowData);
}
@@ -204,19 +206,19 @@ void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::s
return;
}
//---------------------------------------------------------------------
-::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException)
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException)
{
- std::vector< std::vector< ::rtl::OUString > >::iterator iterator;
- std::vector< Sequence< ::rtl::OUString > > dummyContainer(0);
+ std::vector< std::vector< Any > >::iterator iterator;
+ std::vector< Sequence< Any > > dummyContainer(0);
for(iterator = data.begin(); iterator != data.end(); iterator++)
{
- Sequence< ::rtl::OUString > cols(comphelper::containerToSequence(*iterator));
+ Sequence< Any > cols(comphelper::containerToSequence(*iterator));
dummyContainer.push_back( cols );
}
- Sequence< Sequence< ::rtl::OUString > > dataSequence(comphelper::containerToSequence(dummyContainer));
+ Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer));
return dataSequence;
}
@@ -234,14 +236,52 @@ void SAL_CALL DefaultGridDataModel::removeDataListener( const Reference< XGridDa
{
BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener );
}
-
+//---------------------------------------------------------------------
void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException)
{
rowHeaders.clear();
data.clear();
broadcast_remove( -1, ::rtl::OUString(), 0);
}
-
+//---------------------------------------------------------------------
+void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 oldValue = m_nRowHeaderWidth;
+ m_nRowHeaderWidth = _value;
+ broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) );
+}
+//---------------------------------------------------------------------
+sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_nRowHeaderWidth;
+}
+//---------------------------------------------------------------------
+void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(row >= 0 && row < (signed)data.size())
+ {
+ if(column >= 0 && column < (signed)data[0].size())
+ {
+ data[row][column] = value;
+ Sequence< Any >dataSeq(comphelper::containerToSequence(data[row]));
+ broadcast_changed( CELLUPDATED, row, Any(column), value );
+ }
+ }
+}
+//---------------------------------------------------------------------
+void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(row >= 0 && row < (signed)data.size())
+ {
+ if(columns.getLength() == values.getLength())
+ {
+ for(int i = 0; i < columns.getLength(); i++)
+ data[row][i] = values[i];
+ Sequence< Any >dataSeq(comphelper::containerToSequence(data[row]));
+ broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) );
+ }
+ }
+}
//---------------------------------------------------------------------
// XComponent
//---------------------------------------------------------------------
@@ -302,6 +342,5 @@ sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString&
Reference< XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const Reference< XMultiServiceFactory >& )
{
- return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridDataModel );
+ return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridDataModel() );
}
-
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx
index 1aebc07bc2a8..ea11a8a9a00a 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx
@@ -30,6 +30,7 @@
#include <com/sun/star/awt/grid/XGridDataModel.hpp>
#include <com/sun/star/awt/grid/GridDataEvent.hpp>
#include <com/sun/star/awt/grid/XGridDataListener.hpp>
+#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -64,13 +65,16 @@ public:
virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & data) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & data) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException);
virtual void SAL_CALL removeDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException);
virtual void SAL_CALL removeAll() throw (RuntimeException);
-
+ virtual void SAL_CALL setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (RuntimeException);
virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
@@ -83,14 +87,15 @@ public:
private:
- void broadcast( broadcast_type eType, const GridDataEvent& aEvent );
- void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue );
- void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData );
- void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rowData );
+ void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ void broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException);
+ void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException);
+ void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException);
sal_Int32 rowHeight;
- std::vector< std::vector < ::rtl::OUString > > data;
+ std::vector< std::vector < Any > > data;
std::vector< ::rtl::OUString > rowHeaders;
+ sal_Int32 m_nRowHeaderWidth;
};
}
diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx
index 39c4960351d3..6720d639f5c1 100644
--- a/toolkit/source/controls/grid/gridcolumn.cxx
+++ b/toolkit/source/controls/grid/gridcolumn.cxx
@@ -38,6 +38,16 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::awt::grid;
using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::style;
+
+#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" ))
+#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" ))
+#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" ))
+#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" ))
+#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" ))
+#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" ))
+#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" ))
+#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" ))
namespace toolkit
{
@@ -48,6 +58,13 @@ namespace toolkit
GridColumn::GridColumn()
: identifier(Any())
+,index(0)
+,columnWidth(4)
+,preferredWidth(0)
+,maxWidth(0)
+,minWidth(0)
+,bResizeable(true)
+,horizontalAlign(HorizontalAlignment(0))
{
}
@@ -59,6 +76,39 @@ GridColumn::~GridColumn()
//---------------------------------------------------------------------
+void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent )
+{
+ ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() );
+ if( pIter )
+ {
+ ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
+ while(aListIter.hasMoreElements())
+ {
+ XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
+ switch( eType )
+ {
+ case column_attribute_changed: pListener->columnChanged(aEvent); break;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------
+
+void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue)
+{
+ Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ GridColumnEvent aEvent( xSource, name, oldValue, newValue, index);
+ broadcast( column_attribute_changed, aEvent);
+}
+
+void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(PREFWIDTH == name)
+ preferredWidth = width;
+ else if (COLWIDTH == name)
+ columnWidth = width;
+}
//---------------------------------------------------------------------
// XGridColumn
//---------------------------------------------------------------------
@@ -79,6 +129,7 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value
::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException)
{
+ broadcast_changed(UPDATE, Any(columnWidth), Any());
return columnWidth;
}
@@ -87,6 +138,50 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value
void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
{
columnWidth = value;
+ broadcast_changed(COLWIDTH, Any(columnWidth),Any(value));
+}
+//--------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException)
+{
+ broadcast_changed(UPDATE, Any(preferredWidth), Any());
+ return preferredWidth;
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
+{
+ preferredWidth = value;
+ broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value));
+}
+//--------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException)
+{
+ return maxWidth;
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
+{
+ maxWidth = value;
+ broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value));
+}
+//--------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException)
+{
+ return minWidth;
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
+{
+ minWidth = value;
+ broadcast_changed(MINWIDTH, Any(minWidth),Any(value));
}
//--------------------------------------------------------------------
@@ -101,6 +196,45 @@ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::s
void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException)
{
title = value;
+ broadcast_changed(TITLE, Any(title),Any(value));
+}
+//--------------------------------------------------------------------
+
+sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException)
+{
+ return bResizeable;
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
+{
+ bResizeable = value;
+ broadcast_changed(COLRESIZE, Any(bResizeable),Any(value));
+}
+//---------------------------------------------------------------------
+HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException)
+{
+ return horizontalAlign;
+}
+//---------------------------------------------------------------------
+
+void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException)
+{
+ horizontalAlign = align;
+ broadcast_changed(HALIGN, Any(horizontalAlign),Any(align));
+}
+//---------------------------------------------------------------------
+void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+{
+ BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener );
+}
+
+//---------------------------------------------------------------------
+
+void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+{
+ BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener );
}
//---------------------------------------------------------------------
@@ -109,22 +243,30 @@ void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::
void SAL_CALL GridColumn::dispose() throw (RuntimeException)
{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ::com::sun::star::lang::EventObject aEvent;
+ aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) );
+ BrdcstHelper.aLC.disposeAndClear( aEvent );
}
//---------------------------------------------------------------------
void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
{
- (void) xListener;
+ BrdcstHelper.addListener( XEventListener::static_type(), xListener );
}
//---------------------------------------------------------------------
void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
{
- (void) xListener;
+ BrdcstHelper.removeListener( XEventListener::static_type(), xListener );
+}
+void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException)
+{
+ index = _nIndex;
}
-
//---------------------------------------------------------------------
// XServiceInfo
//---------------------------------------------------------------------
diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx
index 7f6d104127ec..38d43d55a07b 100644
--- a/toolkit/source/controls/grid/gridcolumn.hxx
+++ b/toolkit/source/controls/grid/gridcolumn.hxx
@@ -28,6 +28,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_toolkit.hxx"
#include <com/sun/star/awt/grid/XGridColumn.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
+#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -36,6 +38,7 @@
#include <rtl/ref.hxx>
#include <vector>
#include <toolkit/helper/mutexandbroadcasthelper.hxx>
+#include <com/sun/star/style/HorizontalAlignment.hpp>
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -47,6 +50,7 @@ using namespace ::com::sun::star::lang;
namespace toolkit
{
+enum broadcast_column_type { column_attribute_changed};
class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >,
public MutexAndBroadcastHelper
{
@@ -59,9 +63,21 @@ public:
virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setColumnWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPreferredWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPreferredWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMaxWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMaxWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMinWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMinWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getResizeable() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException);
-
+ virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (RuntimeException);
virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
@@ -72,11 +88,20 @@ public:
virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
-
+ virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException);
private:
+ void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent );
+ void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue);
+
Any identifier;
+ sal_Int32 index;
sal_Int32 columnWidth;
+ sal_Int32 preferredWidth;
+ sal_Int32 maxWidth;
+ sal_Int32 minWidth;
+ sal_Bool bResizeable;
::rtl::OUString title;
+ ::com::sun::star::style::HorizontalAlignment horizontalAlign;
};
}
diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx
index f19648ab0af2..5125c1349ade 100644
--- a/toolkit/source/controls/grid/gridcontrol.cxx
+++ b/toolkit/source/controls/grid/gridcontrol.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/view/SelectionType.hpp>
#include <com/sun/star/awt/grid/XGridDataModel.hpp>
+#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/ScrollBarMode.hpp>
#include <toolkit/helper/unopropertyarrayhelper.hxx>
#include <toolkit/helper/property.hxx>
@@ -68,12 +69,21 @@ UnoGridModel::UnoGridModel()
ImplRegisterProperty( BASEPROPERTY_SIZEABLE ); // resizeable
ImplRegisterProperty( BASEPROPERTY_HSCROLL );
ImplRegisterProperty( BASEPROPERTY_VSCROLL );
+ ImplRegisterProperty( BASEPROPERTY_TABSTOP );
ImplRegisterProperty( BASEPROPERTY_GRID_SHOWROWHEADER );
ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER );
ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL );
ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL );
ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE );
-
+ ImplRegisterProperty( BASEPROPERTY_FONTRELIEF );
+ ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK );
+ ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
+ ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR );
+ ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN );
+ ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND );
+ ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND );
+ ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR );
+ ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND );
}
UnoGridModel::UnoGridModel( const UnoGridModel& rModel )
@@ -99,6 +109,22 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_GridControl ) );
case BASEPROPERTY_GRID_SELECTIONMODE:
return uno::makeAny( SelectionType(1) );
+ case BASEPROPERTY_GRID_SHOWROWHEADER:
+ return uno::makeAny( (sal_Bool)sal_False );
+ case BASEPROPERTY_GRID_SHOWCOLUMNHEADER:
+ return uno::makeAny( (sal_Bool)sal_False );
+ case BASEPROPERTY_GRID_DATAMODEL:
+ return uno::makeAny( Reference<XGridDataModel> ());
+ case BASEPROPERTY_GRID_COLUMNMODEL:
+ return uno::makeAny(Reference<XGridColumnModel>() );
+ case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_HEADER_BACKGROUND:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_LINE_COLOR:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_ROW_BACKGROUND:
+ return uno::makeAny(com::sun::star::util::Color(0xFFFFFF) );
default:
return UnoControlModel::ImplGetDefaultValue( nPropId );
}
@@ -128,7 +154,8 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime
// class UnoGridControl
// ----------------------------------------------------
UnoGridControl::UnoGridControl()
-: mSelectionMode(SelectionType(1))
+: mSelectionMode(SelectionType(1)),
+ m_aSelectionListeners( *this )
{
}
@@ -139,6 +166,9 @@ OUString UnoGridControl::GetComponentServiceName()
void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException)
{
+ lang::EventObject aEvt;
+ aEvt.Source = (::cppu::OWeakObject*)this;
+ m_aSelectionListeners.disposeAndClear( aEvt );
UnoControl::dispose();
}
@@ -147,63 +177,39 @@ void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk
UnoControlBase::createPeer( rxToolkit, rParentPeer );
Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW );
+ xGrid->addSelectionListener(&m_aSelectionListeners);
Reference<XGridDataListener> xListener ( getPeer(), UNO_QUERY_THROW );
+ Reference<XGridColumnListener> xColListener ( getPeer(), UNO_QUERY_THROW );
Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
Reference<XGridDataModel> xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW );
- xGridDataModel->addDataListener(xListener);
+ if(xGridDataModel != NULL)
+ xGridDataModel->addDataListener(xListener);
+ Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW );
+ if(xGridColumnModel != NULL)
+ {
+ for(int i = 0;i<xGridColumnModel->getColumnCount();i++)
+ {
+ xGridColumnModel->getColumn(i)->addColumnListener(xColListener);
+ }
+ }
}
// -------------------------------------------------------------------
// XGridControl
-// -------------------------------------------------------------------
-
-::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL UnoGridControl::getColumnModel() throw (::com::sun::star::uno::RuntimeException)
-{
- Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
- Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW );
-
- return xGridColumnModel;
-}
-
-void SAL_CALL UnoGridControl::setColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > & model) throw (::com::sun::star::uno::RuntimeException)
-{
- Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
- xPropSet->setPropertyValue(OUString::createFromAscii( "ColumnModel" ), Any (model));
-}
-
-::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL UnoGridControl::getDataModel() throw (::com::sun::star::uno::RuntimeException)
-{
- Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
- Reference<XGridDataModel> xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW );
-
- return xGridDataModel;
-}
-
-void SAL_CALL UnoGridControl::setDataModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > & model) throw (::com::sun::star::uno::RuntimeException)
-{
- Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
- xPropSet->setPropertyValue(OUString::createFromAscii( "GridDataModel" ), Any(model));
-}
::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
{
- return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getItemIndexAtPoint( x, y );
+ Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW );
+ return xGrid->getItemIndexAtPoint( x, y );
}
-/*
-void SAL_CALL UnoGridControl::addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->addMouseListener( listener );
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns );
}
-
-void SAL_CALL UnoGridControl::removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException)
-{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeMouseListener( listener );
-}
-*/
// -------------------------------------------------------------------
// XGridSelection
// -------------------------------------------------------------------
@@ -218,16 +224,24 @@ void SAL_CALL UnoGridControl::removeMouseListener(const ::com::sun::star::uno::R
return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex();
}
-void SAL_CALL UnoGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->insertIndexIntervall( start, length);
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows);
}
-void SAL_CALL UnoGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows();
+}
+void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeIndexIntervall( start, length );
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows);
}
+void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows();
+}
::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException)
{
return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection();
@@ -250,14 +264,14 @@ void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::
void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->addSelectionListener( listener );
+ m_aSelectionListeners.addInterface( listener );
}
void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeSelectionListener( listener );
-}
+ m_aSelectionListeners.removeInterface( listener );
}
+}//namespace toolkit
Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& )
{
diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx
index 4195a1f624e5..0c8ddb1c02b6 100644
--- a/toolkit/source/controls/grid/gridcontrol.hxx
+++ b/toolkit/source/controls/grid/gridcontrol.hxx
@@ -30,10 +30,11 @@
#include <com/sun/star/awt/grid/XGridControl.hpp>
#include <com/sun/star/view/SelectionType.hpp>
-#include <toolkit/controls/unocontrols.hxx>
+#include <toolkit/controls/unocontrolbase.hxx>
#include <toolkit/controls/unocontrolmodel.hxx>
#include <toolkit/helper/servicenames.hxx>
#include <cppuhelper/implbase1.hxx>
+#include <comphelper/sequence.hxx>
#include <toolkit/helper/listenermultiplexer.hxx>
@@ -87,20 +88,18 @@ public:
void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException);
// ::com::sun::star::awt::grid::XGridControl
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > & model) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDataModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > & model) throw (::com::sun::star::uno::RuntimeException);
+
virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
- //virtual void SAL_CALL addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException);
- //virtual void SAL_CALL removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException);
// ::com::sun::star::awt::grid::XGridSelection
virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
@@ -114,6 +113,7 @@ public:
using UnoControl::getPeer;
private:
::com::sun::star::view::SelectionType mSelectionMode;
+ SelectionListenerMultiplexer m_aSelectionListeners;
};
} // toolkit
diff --git a/toolkit/source/helper/listenermultiplexer.cxx b/toolkit/source/helper/listenermultiplexer.cxx
index fcfd6214780e..9b8df60521ae 100644
--- a/toolkit/source/helper/listenermultiplexer.cxx
+++ b/toolkit/source/helper/listenermultiplexer.cxx
@@ -206,3 +206,8 @@ IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer, ::com
// ----------------------------------------------------
IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer, ::com::sun::star::awt::tree::XTreeEditListener )
+// ----------------------------------------------------
+// class SelectionListenerMultiplexer
+// ----------------------------------------------------
+IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener )
+IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent )
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index 7ede81d485d7..6711e4503511 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -281,8 +281,12 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
DECL_PROP_3 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ),
DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ),
DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ),
- DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT )
- };
+ DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ),
+ DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
+ DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
+ DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
+ DECL_PROP_3 ( "RowBackgroundColor", GRID_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID )
+ };
pPropertyInfos = aImplPropertyInfos;
nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo );
}
diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx
index 048eb1d5a670..fcf1d2ee0387 100644
--- a/vcl/inc/vcl/vclevent.hxx
+++ b/vcl/inc/vcl/vclevent.hxx
@@ -192,6 +192,7 @@ namespace com { namespace sun { namespace star {
#define VCLEVENT_TOOLBOX_BUTTONSTATECHANGED 1223 // pData = itempos
#define VCLEVENT_TABLECELL_NAMECHANGED 1224 // pData = struct(Entry, Column, oldText)
+#define VCLEVENT_TABLEROW_SELECT 1225
class VCL_DLLPUBLIC VclSimpleEvent
{