From b198150a3cdb7f1f3838bf39853f2ea680bcaf6c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 22:23:17 +0100 Subject: gridsort: don't let the SVTXGridControl listen for XGridColumn changes. Instead, the non-UNO wrapper around the XGridColumn (UnoControlTableColumn, implementing IColumnModel) should do this, and then multiplex the changes to the TableControl(_Impl) instance. This way, other IColumnModel implementations also properly trigger control updates, provided they simply properly notify their changes. --- svtools/source/uno/unogridcolumnfacade.hxx | 104 +++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 svtools/source/uno/unogridcolumnfacade.hxx (limited to 'svtools/source/uno/unogridcolumnfacade.hxx') diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx new file mode 100755 index 000000000000..a49f1c8963e7 --- /dev/null +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_GRIDCOLUMNFACADE_HXX +#define SVTOOLS_GRIDCOLUMNFACADE_HXX + +#include "svtools/table/tablemodel.hxx" +#include "svtools/table/tablecontrol.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include + +#include + +// ..................................................................................................................... +namespace svt { namespace table +{ +// ..................................................................................................................... + + //================================================================================================================== + //= UnoGridColumnFacade + //================================================================================================================== + class ColumnChangeMultiplexer; + class UnoControlTableModel; + class UnoGridColumnFacade :public IColumnModel + ,public ::boost::noncopyable + { + public: + UnoGridColumnFacade( + UnoControlTableModel const & i_owner, + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_gridColumn + ); + ~UnoGridColumnFacade(); + + // IColumnModel overridables + virtual ::com::sun::star::uno::Any + getID() const; + virtual void setID( const ::com::sun::star::uno::Any& i_ID ); + virtual String getName() const; + virtual void setName( const String& _rName ); + virtual bool isResizable() const; + virtual void setResizable( bool _bResizable ); + virtual TableMetrics getWidth() const; + virtual void setWidth( TableMetrics _nWidth ); + virtual TableMetrics getMinWidth() const; + 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); + + /** disposes the column wrapper + + Note that the XGridColumn which is wrapped by the instance is not disposed, as we + do not own it. + */ + void dispose(); + + // callback for the XGridColumnListener + void columnChanged( ColumnAttributeGroup const i_attributeGroup ); + + private: + const UnoControlTableModel* m_pOwner; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn; + ::rtl::Reference< ColumnChangeMultiplexer > m_pChangeMultiplexer; + }; + +// ..................................................................................................................... +} } // svt::table +// ..................................................................................................................... + +#endif // SVTOOLS_GRIDCOLUMNFACADE_HXX -- cgit v1.2.3 From 012b72f48860433345989eedc9cd1ccb9350b455 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 11:42:27 +0100 Subject: gridsort: +XGridColumn::HelpText, to be displayed as tooltip for the column header --- svtools/inc/svtools/table/tablemodel.hxx | 10 ++- svtools/source/table/tabledatawindow.cxx | 31 ++++++--- svtools/source/uno/unogridcolumnfacade.cxx | 38 +++++++++-- svtools/source/uno/unogridcolumnfacade.hxx | 2 + .../controls/grid/defaultgridcolumnmodel.cxx | 2 +- toolkit/source/controls/grid/gridcolumn.cxx | 78 ++++++++-------------- toolkit/source/controls/grid/gridcolumn.hxx | 18 ++++- 7 files changed, 109 insertions(+), 70 deletions(-) (limited to 'svtools/source/uno/unogridcolumnfacade.hxx') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index b8c13822a460..3eb87f1eb40e 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -213,6 +213,14 @@ namespace svt { namespace table */ virtual void setName( const String& _rName ) = 0; + /** retrieves the help text to be displayed for the column. + */ + virtual String getHelpText() const = 0; + + /** sets a new the help text to be displayed for the column. + */ + virtual void setHelpText( const String& i_helpText ) = 0; + /** determines whether the column can be resized @see getMinWidth @@ -443,7 +451,7 @@ namespace svt { namespace table @param i_col The column index of the cell in question. COL_ROW_HEADERS is a valid argument here. @param i_row - The row index of the cell in question. ROW_COL_HEADERS is a valid argument. + The row index of the cell in question. @param o_cellToolTip takes the tooltip object upon return. */ diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 2fc08b13742e..2092a4bccdc9 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -95,23 +95,32 @@ namespace svt { namespace table RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos ); - if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) - && ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) - ) + + if ( ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) ) { + ::rtl::OUString sHelpText; + PTableModel const pTableModel( m_rTableControl.getAntiImpl().GetModel() ); - Any aCellToolTip; - pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); - if ( !aCellToolTip.hasValue() ) + if ( hitRow == ROW_COL_HEADERS ) { - // use the cell content - pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); - // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to - // ask the renderer for this. + sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); + } + else if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) ) + { + Any aCellToolTip; + pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); + if ( !aCellToolTip.hasValue() ) + { + // use the cell content + pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); + // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to + // ask the renderer for this. + } + + sHelpText = CellValueConversion::convertToString( aCellToolTip ); } - ::rtl::OUString const sHelpText( CellValueConversion::convertToString( aCellToolTip ) ); if ( sHelpText.getLength() > 0 ) { Rectangle const aControlScreenRect( diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 4e094bbd6523..00fa72199815 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -150,14 +150,14 @@ namespace svt { namespace table { ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); - if ( i_event.AttributeName.equalsAscii( "HAlign" ) ) + if ( i_event.AttributeName.equalsAscii( "HorizontalAlign" ) ) nChangedAttributes |= COL_ATTRS_APPEARANCE; - if ( i_event.AttributeName.equalsAscii( "ColWidth" ) + if ( i_event.AttributeName.equalsAscii( "ColumnWidth" ) || i_event.AttributeName.equalsAscii( "MaxWidth" ) || i_event.AttributeName.equalsAscii( "MinWidth" ) - || i_event.AttributeName.equalsAscii( "PrefWidth" ) - || i_event.AttributeName.equalsAscii( "ColumnResize" ) + || i_event.AttributeName.equalsAscii( "PreferredWidth" ) + || i_event.AttributeName.equalsAscii( "Resizeable" ) ) nChangedAttributes |= COL_ATTRS_WIDTH; @@ -273,6 +273,36 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + String UnoGridColumnFacade::getHelpText() const + { + ::rtl::OUString sHelpText; + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", sHelpText ); + try + { + sHelpText = m_xGridColumn->getHelpText(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sHelpText; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setHelpText( const String& i_helpText ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_xGridColumn->setHelpText( i_helpText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + //------------------------------------------------------------------------------------------------------------------ bool UnoGridColumnFacade::isResizable() const { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index a49f1c8963e7..6f606bb6f86b 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -68,6 +68,8 @@ namespace svt { namespace table virtual void setID( const ::com::sun::star::uno::Any& i_ID ); virtual String getName() const; virtual void setName( const String& _rName ); + virtual String getHelpText() const; + virtual void setHelpText( const String& i_helpText ); virtual bool isResizable() const; virtual void setResizable( bool _bResizable ); virtual TableMetrics getWidth() const; diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index d417a1432bd2..04ecf93d9bc5 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -217,7 +217,7 @@ namespace toolkit Reference< XGridColumn > const xColumn( pGridColumn.get() ); ::rtl::OUStringBuffer colTitle; colTitle.appendAscii( "Column " ); - colTitle.append( i ); + colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 711affab8017..25272f4e489a 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -32,14 +32,6 @@ #include #include -#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" )) - namespace toolkit { using namespace ::com::sun::star; @@ -88,10 +80,13 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void GridColumn::broadcast_changed( ::rtl::OUString name, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ) + void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ) { Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent const aEvent( xSource, name, i_oldValue, i_newValue, m_nIndex); + GridColumnEvent const aEvent( + xSource, ::rtl::OUString::createFromAscii( i_asciiAttributeName ), + i_oldValue, i_newValue, m_nIndex + ); ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); @@ -110,7 +105,8 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) { - value >>= m_aIdentifier; + ::osl::MutexGuard aGuard( m_aMutex ); + m_aIdentifier = value; } //------------------------------------------------------------------------------------------------------------------ @@ -123,12 +119,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nColumnWidth == value ) - return; - - m_nColumnWidth = value; - broadcast_changed( COLWIDTH, Any( m_nColumnWidth ), Any( value ), aGuard ); + impl_set( m_nColumnWidth, value, "ColumnWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -141,12 +132,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nPreferredWidth == value ) - return; - - m_nPreferredWidth = value; - broadcast_changed( PREFWIDTH, Any( m_nPreferredWidth ), Any( value ), aGuard ); + impl_set( m_nPreferredWidth, value, "PreferredWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -159,12 +145,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nMaxWidth == value ) - return; - - m_nMaxWidth = value; - broadcast_changed( MAXWIDTH, Any( m_nMaxWidth ), Any( value ), aGuard ); + impl_set( m_nMaxWidth, value, "MaxWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -177,12 +158,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nMinWidth == value ) - return; - - m_nMinWidth = value; - broadcast_changed( MINWIDTH, Any( m_nMinWidth ), Any( value ), aGuard ); + impl_set( m_nMinWidth, value, "MinWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -195,12 +171,20 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_sTitle == value ) - return; + impl_set( m_sTitle, value, "Title" ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + return m_sHelpText; + } - m_sTitle = value; - broadcast_changed( TITLE, Any( m_sTitle ), Any( value ), aGuard ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHelpText( const ::rtl::OUString & value ) throw (RuntimeException) + { + impl_set( m_sHelpText, value, "HelpText" ); } //------------------------------------------------------------------------------------------------------------------ @@ -213,12 +197,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_bResizeable == value ) - return; - - m_bResizeable = value; - broadcast_changed( COLRESIZE, Any( m_bResizeable ), Any( value ), aGuard ); + impl_set( m_bResizeable, value, "Resizeable" ); } //------------------------------------------------------------------------------------------------------------------ @@ -231,12 +210,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_eHorizontalAlign == align ) - return; - - m_eHorizontalAlign = align; - broadcast_changed( HALIGN, Any( m_eHorizontalAlign ), Any( align ), aGuard ); + impl_set( m_eHorizontalAlign, value, "HorizontalAlign" ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 89d6da0c8cd2..a46b18a84fce 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -70,6 +70,8 @@ public: 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 ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getIndex() 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); @@ -99,12 +101,25 @@ public: private: void broadcast_changed( - ::rtl::OUString name, + sal_Char const * const i_asciiAttributeName, ::com::sun::star::uno::Any i_oldValue, ::com::sun::star::uno::Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ); + template< class TYPE > + void impl_set( TYPE & io_attribute, TYPE const & i_newValue, sal_Char const * i_attributeName ) + { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( io_attribute == i_newValue ) + return; + + TYPE const aOldValue( io_attribute ); + io_attribute = i_newValue; + broadcast_changed( i_attributeName, ::com::sun::star::uno::makeAny( aOldValue ), ::com::sun::star::uno::makeAny( io_attribute ), aGuard ); + } + + ::com::sun::star::uno::Any m_aIdentifier; sal_Int32 m_nIndex; sal_Int32 m_nColumnWidth; @@ -113,6 +128,7 @@ private: sal_Int32 m_nMinWidth; sal_Bool m_bResizeable; ::rtl::OUString m_sTitle; + ::rtl::OUString m_sHelpText; ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; }; -- cgit v1.2.3 From 903ddf534a9a71cb54867d7c40eedf456acb018a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 19 Jan 2011 12:39:41 +0100 Subject: gridsort: introduce XGridColumn::DataModelIndex. this allows for column removal/insertion at the GridColumnModel, without the need to touch the GridDataModel --- svtools/inc/svtools/table/tablecontrol.hxx | 3 -- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/tablecontrol.cxx | 6 --- svtools/source/table/tablecontrol_impl.cxx | 13 +++--- svtools/source/table/tablecontrol_impl.hxx | 2 +- svtools/source/uno/svtxgridcontrol.cxx | 15 ++----- svtools/source/uno/unocontroltablemodel.cxx | 49 ++++++++++++++++++---- svtools/source/uno/unocontroltablemodel.hxx | 10 ++++- svtools/source/uno/unogridcolumnfacade.cxx | 34 +++++++++++++++ svtools/source/uno/unogridcolumnfacade.hxx | 12 +++++- .../controls/grid/defaultgridcolumnmodel.cxx | 1 + toolkit/source/controls/grid/gridcolumn.cxx | 15 +++++++ toolkit/source/controls/grid/gridcolumn.hxx | 3 ++ 13 files changed, 124 insertions(+), 41 deletions(-) (limited to 'svtools/source/uno/unogridcolumnfacade.hxx') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index a5360145bc46..a8324e0bc13d 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -151,9 +151,6 @@ namespace svt { namespace table void SetSelectHdl( const Link& rLink ); const Link& GetSelectHdl() const; - /// invalidates those areas of the data window which are covered by the given rows - void InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ); - /**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 */ diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 80ce012b05d0..b6c0c466edd0 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -142,7 +142,7 @@ namespace svt { namespace table they have about the cells in question, in particular any possibly cached cell values. */ - virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) = 0; + virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) = 0; /** notifies the listener that attributes of a given column changed diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 448da7c9395b..4cccc3843adf 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -248,12 +248,6 @@ namespace svt { namespace table Select(); } - // ----------------------------------------------------------------------------------------------------------------- - void TableControl::InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ) - { - m_pImpl->invalidateRowRange( i_firstRow, i_lastRow ); - } - // ----------------------------------------------------------------------------------------------------------------- ITableControl& TableControl::getTableControlInterface() { diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 53ff00756d98..e47419f2ea52 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -670,14 +670,12 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) + void TableControl_Impl::cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) { - OSL_ENSURE( false, "TableControl_Impl::cellsUpdated: not implemented!" ); - // there's no known implementation (yet) which calls this method - OSL_UNUSED( firstCol ); - OSL_UNUSED( lastCol ); - OSL_UNUSED( firstRow ); - OSL_UNUSED( lastRow ); + invalidateRowRange( i_firstRow, i_lastRow ); + + OSL_UNUSED( i_firstCol ); + OSL_UNUSED( i_lastCol ); } //------------------------------------------------------------------------------------------------------------------ @@ -1966,7 +1964,6 @@ namespace svt { namespace table m_pDataWindow->Invalidate(_rCellRect); } //------------------------------------------------------------------------------------------------------------------ - //this method is to be called, when a new row is added void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ) { if ( m_nCursorHidden == 2 ) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 747ffc8a36fa..dfc8141fa0e9 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -312,7 +312,7 @@ namespace svt { namespace table virtual void columnInserted( ColPos const i_colIndex ); virtual void columnRemoved( ColPos const i_colIndex ); virtual void allColumnsRemoved(); - virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); + virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ); virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); virtual void tableMetricsChanged(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 14ac857179b1..d61a983b309b 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -536,18 +536,12 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - - // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, - // so the TableControl/_Impl can react on it. - if ( i_event.FirstRow == -1 ) - pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount() ); - else - pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow ); + m_pTableModel->notifyDataChanged( i_event ); // if the data model is sortable, a dataChanged event is also fired in case the sort order changed. - // So, invalidate the column header area, too. + // So, just in case, invalidate the column header area, too. + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); pTable->getTableControlInterface().invalidate( TableAreaColumnHeaders ); } @@ -564,7 +558,6 @@ void SAL_CALL SVTXGridControl::rowHeadingChanged( const GridDataEvent& i_event ) pTable->getTableControlInterface().invalidate( TableAreaRowHeaders ); } - //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index ae4de7c36809..b6d4d0f1e451 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -523,12 +523,18 @@ namespace svt { namespace table { DBG_CHECK_ME(); + o_cellContent.clear(); try { Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); - ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); + ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::getCellContent: no data model anymore!" ); + + PColumnModel const pColumn = getColumnModel( i_col ); + UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() ); + ENSURE_OR_RETURN_VOID( pColumnImpl != NULL, "UnoControlTableModel::getCellContent: no (valid) column at this position!" ); + sal_Int32 const nDataColumnIndex = pColumnImpl->getDataColumnIndex() >= 0 ? pColumnImpl->getDataColumnIndex() : i_col; - if ( i_col >= xDataModel->getColumnCount() ) + if ( nDataColumnIndex >= xDataModel->getColumnCount() ) { // this is allowed, in case the column model has been dynamically extended, but the data model does // not (yet?) know about it. @@ -540,11 +546,10 @@ namespace svt { namespace table "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" ); } #endif - o_cellContent.clear(); } else { - o_cellContent = xDataModel->getCellData( i_col, i_row ); + o_cellContent = xDataModel->getCellData( nDataColumnIndex, i_row ); } } catch( const Exception& ) @@ -803,7 +808,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) + void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) const { // check sanity of the event ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" ); @@ -840,9 +845,8 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) + void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) const { - // multiplex the event to our own listeners ModellListeners aListeners( m_pImpl->m_aListeners ); for ( ModellListeners::const_iterator loop = aListeners.begin(); loop != aListeners.end(); @@ -853,6 +857,37 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const + { + ColPos const firstCol = i_event.FirstColumn == -1 ? 0 : i_event.FirstColumn; + ColPos const lastCol = i_event.FirstColumn == -1 ? getColumnCount() - 1 : i_event.LastColumn; + RowPos const firstRow = i_event.FirstRow == -1 ? 0 : i_event.FirstRow; + RowPos const lastRow = i_event.FirstRow == -1 ? getRowCount() - 1 : i_event.LastRow; + + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->cellsUpdated( firstCol, lastCol, firstRow, lastRow ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyAllDataChanged() const + { + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->cellsUpdated( 0, getColumnCount() - 1, 0, getRowCount() - 1 ); + } + } + // ..................................................................................................................... } } // svt::table // ..................................................................................................................... diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 32930a64326d..537c3d9a5249 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -137,8 +137,9 @@ namespace svt { namespace table void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); // multiplexing of XGridDataListener events - void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); - void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); + void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; + void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; + void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; /// retrieves the index of a column within the model ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; @@ -146,6 +147,11 @@ namespace svt { namespace table /// notifies a change in a column belonging to the model void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; + /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data + in more detail. + */ + void notifyAllDataChanged() const; + #ifdef DBG_UTIL const char* checkInvariants() const; #endif diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 00fa72199815..98078b1fb2d4 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -148,6 +148,14 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void SAL_CALL ColumnChangeMultiplexer::columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException) { + if ( i_event.AttributeName.equalsAscii( "DataColumnIndex" ) ) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( m_pColumnImplementation != NULL ) + m_pColumnImplementation->dataColumnIndexChanged(); + return; + } + ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); if ( i_event.AttributeName.equalsAscii( "HorizontalAlign" ) ) @@ -182,9 +190,11 @@ namespace svt { namespace table UnoGridColumnFacade::UnoGridColumnFacade( UnoControlTableModel const & i_owner, Reference< XGridColumn > const & i_gridColumn ) :m_pOwner( &i_owner ) ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) + ,m_nDataColumnIndex( -1 ) ,m_pChangeMultiplexer( new ColumnChangeMultiplexer( *this ) ) { m_xGridColumn->addGridColumnListener( m_pChangeMultiplexer.get() ); + impl_updateDataColumnIndex_nothrow(); } //------------------------------------------------------------------------------------------------------------------ @@ -205,6 +215,30 @@ namespace svt { namespace table m_pOwner = NULL; } + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::impl_updateDataColumnIndex_nothrow() + { + m_nDataColumnIndex = -1; + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_nDataColumnIndex = m_xGridColumn->getDataColumnIndex(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::dataColumnIndexChanged() + { + DBG_TESTSOLARMUTEX(); + impl_updateDataColumnIndex_nothrow(); + if ( m_pOwner != NULL ) + m_pOwner->notifyAllDataChanged(); + } + //------------------------------------------------------------------------------------------------------------------ void UnoGridColumnFacade::columnChanged( ColumnAttributeGroup const i_attributeGroup ) { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index 6f606bb6f86b..11d40afa2984 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -90,11 +90,19 @@ namespace svt { namespace table */ void dispose(); - // callback for the XGridColumnListener + sal_Int32 + getDataColumnIndex() const { return m_nDataColumnIndex; } + + // callbacks for the XGridColumnListener void columnChanged( ColumnAttributeGroup const i_attributeGroup ); + void dataColumnIndexChanged(); + + private: + void impl_updateDataColumnIndex_nothrow(); private: - const UnoControlTableModel* m_pOwner; + UnoControlTableModel const * m_pOwner; + sal_Int32 m_nDataColumnIndex; ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn; ::rtl::Reference< ColumnChangeMultiplexer > m_pChangeMultiplexer; }; diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 80d1c9c136d3..8c50a7e62ef7 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -234,6 +234,7 @@ namespace toolkit colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); + pGridColumn->setDataColumnIndex( i ); ContainerEvent aEvent; aEvent.Source = *this; diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 99ea4e68ce8d..60873cc1802f 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -50,6 +50,7 @@ namespace toolkit :GridColumn_Base( m_aMutex ) ,m_aIdentifier() ,m_nIndex(-1) + ,m_nDataColumnIndex(-1) ,m_nColumnWidth(4) ,m_nPreferredWidth(0) ,m_nMaxWidth(0) @@ -65,6 +66,7 @@ namespace toolkit ,GridColumn_Base( m_aMutex ) ,m_aIdentifier( i_copySource.m_aIdentifier ) ,m_nIndex( -1 ) + ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex ) ,m_nColumnWidth( i_copySource.m_nColumnWidth ) ,m_nPreferredWidth( i_copySource.m_nPreferredWidth ) ,m_nMaxWidth( i_copySource.m_nMaxWidth ) @@ -248,6 +250,19 @@ namespace toolkit m_nIndex = i_index; } + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nDataColumnIndex; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException) + { + impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" ); + } + //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 4fbaddb3151b..a28fd5824160 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -73,6 +73,8 @@ public: virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDataColumnIndex() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) 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 addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); @@ -119,6 +121,7 @@ private: ::com::sun::star::uno::Any m_aIdentifier; sal_Int32 m_nIndex; + sal_Int32 m_nDataColumnIndex; sal_Int32 m_nColumnWidth; sal_Int32 m_nPreferredWidth; sal_Int32 m_nMaxWidth; -- cgit v1.2.3 From 7406b40991a58899180e5dd20572d078d878881d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 24 Jan 2011 11:44:36 +0100 Subject: gridsort: re-did the column resizing - introduced XGridColumn.Flexibility, determining to which degree the column is resized during auto-column-resizing - removed XGridColumn.PreferredWidth - there really is no need for this anymore now - documented the relationship between XGridColumn.Flexibility and XGridColumn.Resizeable - re-implemented TableControl_Impl::impl_ni_updateColumnWidths, with (hopefully) less magic --- svtools/inc/svtools/table/tablemodel.hxx | 22 +- svtools/source/table/tablecontrol_impl.cxx | 352 +++++++++++++-------- svtools/source/table/tablecontrol_impl.hxx | 11 +- svtools/source/uno/unogridcolumnfacade.cxx | 32 +- svtools/source/uno/unogridcolumnfacade.hxx | 4 +- .../controls/grid/defaultgridcolumnmodel.cxx | 4 +- toolkit/source/controls/grid/gridcolumn.cxx | 32 +- toolkit/source/controls/grid/gridcolumn.hxx | 6 +- 8 files changed, 273 insertions(+), 190 deletions(-) (limited to 'svtools/source/uno/unogridcolumnfacade.hxx') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index b6c0c466edd0..6408efd249a8 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -223,7 +223,7 @@ namespace svt { namespace table */ virtual void setHelpText( const String& i_helpText ) = 0; - /** determines whether the column can be resized + /** determines whether the column can be interactively resized @see getMinWidth @see getMaxWidth @@ -239,6 +239,9 @@ namespace svt { namespace table */ virtual void setResizable( bool _bResizable ) = 0; + virtual sal_Int32 getFlexibility() const = 0; + virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0; + /** returns the width of the column, in 1/100 millimeters The returned value must be a positive ->TableMetrics value. @@ -306,23 +309,6 @@ 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 diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index e47419f2ea52..885974a21489 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -52,6 +52,8 @@ #include +#define MIN_COLUMN_WIDTH_PIXEL 4 + //...................................................................................................................... namespace svt { namespace table { @@ -67,21 +69,21 @@ namespace svt { namespace table namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; namespace AccessibleTableModelChangeType = ::com::sun::star::accessibility::AccessibleTableModelChangeType; - //==================================================================== - //= TempHideCursor - //==================================================================== - class TempHideCursor + //================================================================================================================== + //= SuppressCursor + //================================================================================================================== + class SuppressCursor { private: ITableControl& m_rTable; public: - TempHideCursor( ITableControl& _rTable ) + SuppressCursor( ITableControl& _rTable ) :m_rTable( _rTable ) { m_rTable.hideCursor(); } - ~TempHideCursor() + ~SuppressCursor() { m_rTable.showCursor(); } @@ -425,6 +427,7 @@ namespace svt { namespace table ,m_nRowHeaderWidthPixel ( 0 ) ,m_nColumnCount ( 0 ) ,m_nRowCount ( 0 ) + ,m_bColumnsFit ( true ) ,m_nCurColumn ( COL_INVALID ) ,m_nCurRow ( ROW_INVALID ) ,m_nLeftColumn ( 0 ) @@ -438,7 +441,6 @@ namespace svt { namespace table ,m_aSelectedRows ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) ,m_nAnchor ( -1 ) - ,m_bResizingGrid ( false ) ,m_bUpdatingColWidths ( false ) ,m_pAccessibleTable ( NULL ) #if DBG_UTIL @@ -469,7 +471,7 @@ namespace svt { namespace table { DBG_CHECK_ME(); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); if ( !!m_pModel ) m_pModel->removeTableModelListener( shared_from_this() ); @@ -681,7 +683,10 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::tableMetricsChanged() { + long const oldRowHeaderWidthPixel = m_nRowHeaderWidthPixel; impl_ni_updateCachedTableMetrics(); + if ( oldRowHeaderWidthPixel != m_nRowHeaderWidthPixel ) + impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); m_rAntiImpl.Invalidate(); } @@ -712,7 +717,7 @@ namespace svt { namespace table { if ( !m_bUpdatingColWidths ) { - impl_ni_updateColumnWidths(); + impl_ni_updateColumnWidths( i_column ); impl_ni_updateScrollbars(); } @@ -804,7 +809,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::impl_ni_updateColumnWidths() + void TableControl_Impl::impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding ) { ENSURE_OR_RETURN_VOID( !m_bUpdatingColWidths, "TableControl_Impl::impl_ni_updateColumnWidths: recursive call detected!" ); @@ -821,95 +826,223 @@ namespace svt { namespace table m_aColumnWidths.reserve( colCount ); - std::vector aPrePixelWidths(0); - long accumulatedPixelWidth = 0; - int lastResizableCol = COL_INVALID; - double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); - if ( m_pModel->hasRowHeaders() && ( gridWidth != 0 ) ) - { -#if OSL_DEBUG_LEVEL > 0 - const TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - const long rowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); - OSL_ENSURE( rowHeaderWidthPixel == m_nRowHeaderWidthPixel, - "TableControl_Impl::impl_ni_updateColumnWidths: cached row header width is not correct anymore!" ); -#endif - accumulatedPixelWidth += m_nRowHeaderWidthPixel; - gridWidth -= m_nRowHeaderWidthPixel; + // the available horizontal space + long gridWidthPixel = m_rAntiImpl.GetOutputSizePixel().Width(); + if ( m_pModel->hasRowHeaders() && ( gridWidthPixel != 0 ) ) + { + gridWidthPixel -= m_nRowHeaderWidthPixel; + } + if ( m_pModel->getVerticalScrollbarVisibility() != ScrollbarShowNever ) + { + long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidthPixel -= nScrollbarMetrics; } - double colWidthsSum = 0.0; - double colWithoutFixedWidthsSum = 0.0; - double minColWithoutFixedSum = 0.0; + // TODO: shouldn't we take the visibility of the vertical scroll bar into account here, too? + long const gridWidthAppFont = m_rAntiImpl.PixelToLogic( Size( gridWidthPixel, 0 ), MAP_APPFONT ).Width(); + // determine the accumulated current width of all columns for ( ColPos col = 0; col < colCount; ++col ) { const PColumnModel pColumn = m_pModel->getColumnModel( col ); - ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" ); + + } + + // collect some meta data for our columns: + // - their current (appt-font) metrics + long accumulatedCurrentWidth = 0; + ::std::vector< long > currentColWidths; + currentColWidths.reserve( colCount ); + // - their effective minimal and maximal width (app-font!) + typedef ::std::vector< ::std::pair< long, long > > ColumnLimits; + ColumnLimits effectiveColumnLimits; + effectiveColumnLimits.reserve( colCount ); + long accumulatedMinWidth = 0; + long accumulatedMaxWidth = 0; + // - their relative flexibility + ::std::vector< ::sal_Int32 > columnFlexibilities; + columnFlexibilities.reserve( colCount ); + long flexibilityDenominator = 0; + for ( ColPos col = 0; col < colCount; ++col ) + { + PColumnModel const pColumn = m_pModel->getColumnModel( col ); + ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" ); + + // current width + TableMetrics const currentWidth = pColumn->getWidth(); + currentColWidths.push_back( currentWidth ); - TableMetrics colWidth = 0; - const TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - const bool bResizable = pColumn->isResizable(); + // accumulated width + accumulatedCurrentWidth += currentWidth; - if ( colPrefWidth != 0) + // flexibility + ::sal_Int32 flexibility = pColumn->getFlexibility(); + OSL_ENSURE( flexibility >= 0, "TableControl_Impl::impl_ni_updateColumnWidths: a column's flexibility should be non-negative." ); + if ( ( flexibility < 0 ) // normalization + || ( !pColumn->isResizable() ) // column not resizeable => no auto-resize + || ( col <= i_assumeInflexibleColumnsUpToIncluding ) // column shall be treated as inflexible => respec this + ) + flexibility = 0; + + // min/max width + long effectiveMin = currentWidth, effectiveMax = currentWidth; + // if the column is not flexible, it will not be asked for min/max, but we assume the current width as limit then + if ( flexibility > 0 ) { - if ( m_bResizingGrid ) - { - colWidth = pColumn->getWidth(); - pColumn->setPreferredWidth(0); - } + long const minWidth = pColumn->getMinWidth(); + if ( minWidth > 0 ) + effectiveMin = minWidth; else - { - colWidth = colPrefWidth; - pColumn->setWidth( colPrefWidth ); - } - } - else - colWidth = pColumn->getWidth(); + effectiveMin = MIN_COLUMN_WIDTH_PIXEL; - const long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if ( bResizable && colPrefWidth == 0 ) - { - colWithoutFixedWidthsSum += pixelWidth; - lastResizableCol = col; + long const maxWidth = pColumn->getMaxWidth(); + OSL_ENSURE( minWidth <= maxWidth, "TableControl_Impl::impl_ni_updateColumnWidths: pretty undecided 'bout its width limits, this column!" ); + if ( ( maxWidth > 0 ) && ( maxWidth >= minWidth ) ) + effectiveMax = maxWidth; + else + effectiveMax = gridWidthAppFont; // TODO: any better guess here? + + if ( effectiveMin == effectiveMax ) + // if the min and the max are identical, this implies no flexibility at all + flexibility = 0; } - colWidthsSum += pixelWidth; - aPrePixelWidths.push_back( pixelWidth ); + + columnFlexibilities.push_back( flexibility ); + flexibilityDenominator += flexibility; + + effectiveColumnLimits.push_back( ::std::pair< long, long >( effectiveMin, effectiveMax ) ); + accumulatedMinWidth += effectiveMin; + accumulatedMaxWidth += effectiveMax; } - double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if ( m_bResizingGrid ) + ::std::vector< long > newWidths( currentColWidths ); + if ( flexibilityDenominator == 0 ) { - if ( gridWidthWithoutFixed > ( minColWithoutFixedSum + colWidthsSum - colWithoutFixedWidthsSum ) ) - scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; + // no column is flexible => don't adjust anything } - else - { - if ( colWidthsSum < gridWidthWithoutFixed ) + else if ( gridWidthAppFont > accumulatedCurrentWidth ) + { // we have space to give away ... + long distributeAppFontUnits = gridWidthAppFont - accumulatedCurrentWidth; + if ( gridWidthAppFont > accumulatedMaxWidth ) { - if ( colWithoutFixedWidthsSum > 0 ) - scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; + // ... but the column's maximal widths are still less than we have + // => set them all to max + for ( size_t i = 0; i < size_t( colCount ); ++i ) + { + newWidths[i] = effectiveColumnLimits[i].second; + } } - } - for ( ColPos i = 0; i < colCount; ++i ) - { - const PColumnModel pColumn = m_pModel->getColumnModel( i ); - ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + else + { + bool startOver = false; + do + { + startOver = false; + // distribute the remaining space amongst all columns with a positive flexibility + for ( size_t i=0; i effectiveColumnLimits[i].second ) + { // that was too much, we hit the col's maximum + // set the new width to exactly this maximum + newColWidth = effectiveColumnLimits[i].second; + // adjust the flexibility denominator ... + flexibilityDenominator -= columnFlexibility; + columnFlexibilities[i] = 0; + // ... and the remaining width ... + long const difference = newColWidth - currentColWidths[i]; + distributeAppFontUnits -= difference; + // ... this way, we ensure that the width not taken up by this column is consumed by the other + // flexible ones (if there are some) + + // and start over with the first column, since there might be earlier columns which need + // to be recalculated now + startOver = true; + } - if ( pColumn->isResizable() && ( pColumn->getPreferredWidth() == 0 ) ) + newWidths[i] = newColWidth; + } + } + while ( startOver ); + } + } + else if ( gridWidthAppFont < accumulatedCurrentWidth ) + { // we need to take away some space from the columns which allow it ... + long takeAwayAppFontUnits = accumulatedCurrentWidth - gridWidthAppFont; + if ( gridWidthAppFont < accumulatedMinWidth ) + { + // ... but the column's minimal widths are still more than we have + // => set them all to min + for ( size_t i = 0; i < size_t( colCount ); ++i ) + { + newWidths[i] = effectiveColumnLimits[i].first; + } + } + else { - aPrePixelWidths[i] *= scalingFactor; - const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth( logicColWidth ); + bool startOver = false; + do + { + startOver = false; + // take away the space we need from the columns with a positive flexibility + for ( size_t i=0; i 0 ) + && ( accumulatedWidthPixel - m_aColumnWidths[ m_nLeftColumn - 1 ].getStart() <= gridWidthPixel ) + ) + { + --m_nLeftColumn; } - // care for the horizontal scroll position (as indicated by m_nLeftColumn) + // now adjust the column metrics, since they currently ignore the horizontal scroll position if ( m_nLeftColumn > 0 ) { const long offsetPixel = m_aColumnWidths[ 0 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getStart(); @@ -921,29 +1054,6 @@ namespace svt { namespace table colPos->move( offsetPixel ); } } - - const long freeSpaceRight = gridWidth - m_aColumnWidths[ colCount-1 ].getEnd(); - if ( ( freeSpaceRight > 0 ) - && ( lastResizableCol != COL_INVALID ) - && ( lastResizableCol >= m_nLeftColumn ) - ) - { - // make the last resizable column wider - MutableColumnMetrics& rResizeColInfo( m_aColumnWidths[ lastResizableCol ] ); - rResizeColInfo.setEnd( rResizeColInfo.getEnd() + freeSpaceRight ); - - // update the column model - const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( rResizeColInfo.getWidth(), 0 ), MAP_APPFONT ).Width(); - const PColumnModel pColumn = m_pModel->getColumnModel( lastResizableCol ); - pColumn->setWidth( logicColWidth ); - - // update all other columns after the resized one - ColPos adjustColumn = lastResizableCol; - while ( ++adjustColumn < colCount ) - { - m_aColumnWidths[ adjustColumn ].move( freeSpaceRight ); - } - } } //------------------------------------------------------------------------------------------------------------------ @@ -1055,12 +1165,10 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_updateScrollbars() { - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // the width/height of a scrollbar, needed several times below - long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - if ( m_rAntiImpl.IsZoom() ) - nScrollbarMetrics = (long)( nScrollbarMetrics * (double)m_rAntiImpl.GetZoom() ); + long const nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); // determine the playground for the data cells (excluding headers) // TODO: what if the control is smaller than needed for the headers/scrollbars? @@ -1198,32 +1306,10 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - if ( m_nRowCount != 0 ) - { - if ( m_nColumnCount != 0 ) - { - impl_ni_updateColumnWidths(); - impl_ni_updateScrollbars(); - checkCursorPosition(); - 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() ); - // update column widths to fit in grid - impl_ni_updateColumnWidths(); - m_bResizingGrid = true; - } - } - impl_ni_updateScrollbars(); - } + + impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + checkCursorPosition(); } //------------------------------------------------------------------------------------------------------------------ @@ -1249,9 +1335,9 @@ namespace svt { namespace table // draw the header column area if ( m_pModel->hasColumnHeaders() ) { - TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ), + TableRowGeometry const aHeaderRow( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS ); - Rectangle aColRect(aHeaderRow.getRect()); + Rectangle const aColRect(aHeaderRow.getRect()); pRenderer->PaintHeaderArea( *m_pDataWindow, aColRect, true, false, rStyle ); @@ -2066,7 +2152,7 @@ namespace svt { namespace table return false; } - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); m_nCurColumn = _nColumn; m_nCurRow = _nRow; @@ -2083,7 +2169,7 @@ namespace svt { namespace table && ( _nRow >= 0 ) && ( _nRow < m_nRowCount ), "TableControl_Impl::ensureVisible: invalid coordinates!" ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); if ( _nColumn < m_nLeftColumn ) impl_scrollColumns( _nColumn - m_nLeftColumn ); @@ -2133,7 +2219,7 @@ namespace svt { namespace table if ( m_nTopRow != nOldTopRow ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // TODO: call a onStartScroll at our listener (or better an own onStartScroll, // which hides the cursor and then calls the listener) // Same for onEndScroll @@ -2189,7 +2275,7 @@ namespace svt { namespace table if ( m_nLeftColumn != nOldLeftColumn ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // TODO: call a onStartScroll at our listener (or better an own onStartScroll, // which hides the cursor and then calls the listener) // Same for onEndScroll diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index dfc8141fa0e9..8d370011c939 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -117,9 +117,13 @@ namespace svt { namespace table /// the number of columns in the table control. Cached model value. TableSize m_nColumnCount; + /// the number of rows in the table control. Cached model value. TableSize m_nRowCount; + /// denotes whether or not the columns fitted into the available width, last time we checked + long m_bColumnsFit; + ColPos m_nCurColumn; RowPos m_nCurRow; ColPos m_nLeftColumn; @@ -147,7 +151,6 @@ namespace svt { namespace table TableFunctionSet* m_pTableFunctionSet; //part of selection engine RowPos m_nAnchor; - bool m_bResizingGrid; bool m_bUpdatingColWidths; Link m_aSelectHdl; @@ -375,8 +378,12 @@ namespace svt { namespace table The method is not bound to the classes public invariants, as it's used in situations where the they must not necessarily be fullfilled. + + @param i_assumeInflexibleColumnsUpToIncluding + the index of a column up to which all columns should be considered as inflexible, or + COL_INVALID. */ - void impl_ni_updateColumnWidths(); + void impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding = COL_INVALID ); /** updates the scrollbars of the control diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 98078b1fb2d4..c4b21d07b526 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -345,10 +345,24 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoGridColumnFacade::setResizable( bool _bResizable ) + void UnoGridColumnFacade::setResizable( bool i_resizable ) { ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); - return lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( _bResizable ) ); + lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( i_resizable ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 UnoGridColumnFacade::getFlexibility() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 1 ); + return lcl_get( m_xGridColumn, &XGridColumn::getFlexibility ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setFlexibility( sal_Int32 const i_flexibility ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setFlexibility, i_flexibility ); } //------------------------------------------------------------------------------------------------------------------ @@ -393,20 +407,6 @@ namespace svt { namespace table lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth ); } - //------------------------------------------------------------------------------------------------------------------ - TableMetrics UnoGridColumnFacade::getPreferredWidth() const - { - ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); - return lcl_get( m_xGridColumn, &XGridColumn::getPreferredWidth ); - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoGridColumnFacade::setPreferredWidth( TableMetrics _nPrefWidth ) - { - ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); - lcl_set( m_xGridColumn, &XGridColumn::setPreferredWidth, _nPrefWidth ); - } - //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::style::HorizontalAlignment UnoGridColumnFacade::getHorizontalAlign() { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index 11d40afa2984..7499621ba8af 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -72,14 +72,14 @@ namespace svt { namespace table virtual void setHelpText( const String& i_helpText ); virtual bool isResizable() const; virtual void setResizable( bool _bResizable ); + virtual sal_Int32 getFlexibility() const; + virtual void setFlexibility( sal_Int32 const i_flexibility ); virtual TableMetrics getWidth() const; virtual void setWidth( TableMetrics _nWidth ); virtual TableMetrics getMinWidth() const; 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); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 8c50a7e62ef7..a9d808103821 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -233,7 +233,9 @@ namespace toolkit colTitle.appendAscii( "Column " ); colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); - pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); + pGridColumn->setColumnWidth( 80 /* APPFONT */ ); + pGridColumn->setFlexibility( 1 ); + pGridColumn->setResizeable( sal_True ); pGridColumn->setDataColumnIndex( i ); ContainerEvent aEvent; diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 60873cc1802f..9899b517d259 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -52,9 +52,9 @@ namespace toolkit ,m_nIndex(-1) ,m_nDataColumnIndex(-1) ,m_nColumnWidth(4) - ,m_nPreferredWidth(0) ,m_nMaxWidth(0) ,m_nMinWidth(0) + ,m_nFlexibility(1) ,m_bResizeable(true) ,m_eHorizontalAlign( HorizontalAlignment_LEFT ) { @@ -68,8 +68,8 @@ namespace toolkit ,m_nIndex( -1 ) ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex ) ,m_nColumnWidth( i_copySource.m_nColumnWidth ) - ,m_nPreferredWidth( i_copySource.m_nPreferredWidth ) ,m_nMaxWidth( i_copySource.m_nMaxWidth ) + ,m_nFlexibility( i_copySource.m_nFlexibility ) ,m_nMinWidth( i_copySource.m_nMinWidth ) ,m_bResizeable( i_copySource.m_bResizeable ) ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign ) @@ -125,19 +125,6 @@ namespace toolkit impl_set( m_nColumnWidth, value, "ColumnWidth" ); } - //------------------------------------------------------------------------------------------------------------------ - ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) - { - ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - return m_nPreferredWidth; - } - - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) - { - impl_set( m_nPreferredWidth, value, "PreferredWidth" ); - } - //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) { @@ -203,6 +190,21 @@ namespace toolkit impl_set( m_bResizeable, value, "Resizeable" ); } + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nFlexibility; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException) + { + if ( i_value < 0 ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + impl_set( m_nFlexibility, i_value, "Flexibility" ); + } + //------------------------------------------------------------------------------------------------------------------ HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index a28fd5824160..b1be836a3862 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -60,14 +60,14 @@ 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 ::sal_Int32 SAL_CALL getFlexibility() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFlexibility( ::sal_Int32 _flexibility ) throw (::com::sun::star::lang::IllegalArgumentException, ::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 ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); @@ -123,9 +123,9 @@ private: sal_Int32 m_nIndex; sal_Int32 m_nDataColumnIndex; sal_Int32 m_nColumnWidth; - sal_Int32 m_nPreferredWidth; sal_Int32 m_nMaxWidth; sal_Int32 m_nMinWidth; + sal_Int32 m_nFlexibility; sal_Bool m_bResizeable; ::rtl::OUString m_sTitle; ::rtl::OUString m_sHelpText; -- cgit v1.2.3