gridsort: removed XGridControl::setTooltip. It had a rather strange semantics, seems to be unused in the current

OOo code base, and would belong to the model, if at all.
Still one thing to do: do not unconditionally display the cell content as tooltip, but make this dependent on
whether or not the cell content fits into the cell.
This commit is contained in:
Frank Schoenheit [fs] 2011-01-11 10:58:26 +01:00
parent 858b82e990
commit 5a256f4486
15 changed files with 98 additions and 147 deletions

View file

@ -116,8 +116,6 @@ namespace svt { namespace table
/** returns selection engine*/
virtual SelectionEngine* getSelEngine() = 0;
virtual void activateCellAt( const Point& rPoint ) = 0;
virtual bool isTooltipActive() = 0;
virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0;
virtual RowPos getRowAtPoint( const Point& rPoint ) = 0;
virtual ColPos getColAtPoint( const Point& rPoint ) = 0;
virtual void resizeColumn(const Point& rPoint ) = 0;

View file

@ -77,11 +77,8 @@ namespace svt { namespace table
DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
::boost::shared_ptr< 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;
bool m_bTooltip;
public:
::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable;
@ -110,8 +107,8 @@ namespace svt { namespace table
*/
sal_Int32 GetCurrentRow() const;
/** returns the row, which contains the input point*/
ColPos GetRowAtPoint( const Point& rPoint );
IAbstractTableControl&
getTableControlInterface();
/** retrieves the current column
@ -194,6 +191,7 @@ namespace svt { namespace table
virtual void FillAccessibleStateSet(
::utl::AccessibleStateSetHelper& rStateSet,
AccessibleTableControlObjType eObjType ) const;
//// Window
virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const;
virtual void GrabFocus();
@ -224,12 +222,9 @@ namespace svt { namespace table
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) const;
::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 clearSelection();
void selectionChanged(bool _bChanged);
bool isTooltip();
protected:
::svt::IAccessibleFactory& getAccessibleFactory();

View file

@ -75,6 +75,7 @@ namespace svt { namespace table
virtual long Notify(NotifyEvent& rNEvt);
virtual void SetControlBackground(const Color& rColor);
virtual void SetControlBackground();
virtual void RequestHelp( const HelpEvent& rHEvt );
void SetBackground(const Wallpaper& rColor);
void SetBackground();

View file

@ -432,6 +432,23 @@ namespace svt { namespace table
*/
virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) = 0;
/** returns an object which should be displayed as tooltip for the given cell
At the moment, only string-convertible values are supported here. In the future, one might imagine displaying
scaled-down versions of a graphic in a cell, and a larger version of that very graphic as tooltip.
If no tooltip object is provided, then the cell content is used, and displayed as tooltip for the cell
if and only if it doesn't fit into the cell's space itself.
@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.
@param o_cellToolTip
takes the tooltip object upon return.
*/
virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ) = 0;
/** retrieves title of a given row
*/
virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const = 0;

View file

@ -46,12 +46,16 @@ namespace svt
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString CellValueConversion::convertToString( const Any& i_value )
{
::rtl::OUString sConvertString;
if ( !i_value.hasValue() )
return sConvertString;
// TODO: use css.script.XTypeConverter?
sal_Int32 nInt = 0;
sal_Bool bBool = false;
double fDouble = 0;
::rtl::OUString sConvertString;
::rtl::OUString sStringValue;
if ( i_value >>= sConvertString )

View file

@ -70,7 +70,6 @@ namespace svt { namespace table
:Control( _pParent, _nStyle )
,m_pImpl( new TableControl_Impl( *this ) )
,m_bSelectionChanged(false)
,m_bTooltip(false)
{
TableDataWindow* aTableData = m_pImpl->getDataWindow();
aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
@ -245,9 +244,9 @@ namespace svt { namespace table
}
//--------------------------------------------------------------------
RowPos TableControl::GetRowAtPoint( const Point& rPoint )
IAbstractTableControl& TableControl::getTableControlInterface()
{
return m_pImpl->getRowAtPoint( rPoint );
return *m_pImpl;
}
//--------------------------------------------------------------------
@ -574,34 +573,12 @@ Rectangle TableControl::calcTableRect(BOOL _bOnScreen)
(void)_bOnScreen;
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;
m_bTooltip = true;
}
// -----------------------------------------------------------------------
void TableControl::selectionChanged(bool _bChanged)
{
m_bSelectionChanged = _bChanged;
}
// -----------------------------------------------------------------------
bool TableControl::isTooltip()
{
return m_bTooltip;
}
// -----------------------------------------------------------------------
IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG )
{
Select();

View file

@ -185,6 +185,9 @@ namespace svt { namespace table
(void)i_col;
o_cellContent.clear();
}
virtual void getCellToolTip( ColPos const, RowPos const, ::com::sun::star::uno::Any& )
{
}
virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const
{
(void)i_rowPos;
@ -2071,78 +2074,6 @@ namespace svt { namespace table
}
return -1;
}
//-------------------------------------------------------------------------------
bool TableControl_Impl::isTooltipActive()
{
return m_rAntiImpl.isTooltip();
}
//-------------------------------------------------------------------------------
::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint )
{
::rtl::OUString aTooltipText;
const RowPos hitRow = getRowAtPoint( rPoint );
const ColPos hitCol = getColAtPoint( 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)
{
aTooltipText = getCellContentAsString( hitRow, hitCol );
}
else if(text.getLength() == 0)
{
for(int i=0; i<cols.getLength(); i++)
{
if(i==0)
{
aTooltipText = getCellContentAsString( hitRow, cols[i] );
}
else
{
aTooltipText += ::rtl::OUString::createFromAscii("\n");
aTooltipText += getCellContentAsString( hitRow, cols[i] );
}
}
}
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)
{
aTooltipText = text[i] + getCellContentAsString( hitRow, cols[i] );
}
else
{
aTooltipText+= ::rtl::OUString::createFromAscii("\n");
aTooltipText+= text[i];
if(nCols > i)
{
aTooltipText += getCellContentAsString( hitRow, cols[i] );
}
}
}
}
return m_aTooltipText = aTooltipText;
}
//--------------------------------------------------------------------
ColPos TableControl_Impl::impl_getColumnForOrdinate( long const i_ordinate ) const

View file

@ -159,7 +159,6 @@ namespace svt { namespace table
ColPos m_nResizingColumn;
bool m_bResizingGrid;
bool m_bUpdatingColWidths;
rtl::OUString m_aTooltipText;
#if DBG_UTIL
#define INV_SCROLL_POSITION 1
@ -255,8 +254,6 @@ namespace svt { namespace table
virtual bool dispatchAction( TableControlAction _eAction );
virtual SelectionEngine* getSelEngine();
virtual void activateCellAt( const Point& rPoint );
virtual bool isTooltipActive();
virtual rtl::OUString& setTooltip(const Point& rPoint );
virtual RowPos getRowAtPoint( const Point& rPoint );
virtual ColPos getColAtPoint( const Point& rPoint );
virtual void resizeColumn(const Point& rPoint);

View file

@ -29,15 +29,22 @@
#include "svtools/table/tablecontrol.hxx"
#include "svtools/table/tabledatawindow.hxx"
#include "tablecontrol_impl.hxx"
#include "tablegeometry.hxx"
#include "cellvalueconversion.hxx"
#include <vcl/help.hxx>
//........................................................................
namespace svt { namespace table
{
class TableControl_Impl;
//........................................................................
/** === begin UNO using === **/
using ::com::sun::star::uno::Any;
/** === end UNO using === **/
//====================================================================
//= TableDataWindow
//====================================================================
@ -77,29 +84,62 @@ namespace svt { namespace table
{
Window::SetControlBackground();
}
//--------------------------------------------------------------------
void TableDataWindow::RequestHelp( const HelpEvent& rHEvt )
{
USHORT const nHelpMode = rHEvt.GetMode();
if ( ( nHelpMode & HELPMODE_QUICK ) != 0 )
{
Point const aMousePos( m_rTableControl.getAntiImpl().ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
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() )
)
{
PTableModel const pTableModel( m_rTableControl.getAntiImpl().GetModel() );
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.
}
::rtl::OUString const sHelpText( CellValueConversion::convertToString( aCellToolTip ) );
if ( sHelpText.getLength() > 0 )
{
Rectangle const aControlScreenRect(
m_rTableControl.getAntiImpl().OutputToScreenPixel( Point( 0, 0 ) ),
m_rTableControl.getAntiImpl().GetOutputSizePixel()
);
Help::ShowQuickHelp( &m_rTableControl.getAntiImpl(), aControlScreenRect, sHelpText );
}
}
}
else
{
Window::RequestHelp( rHEvt );
}
}
//--------------------------------------------------------------------
void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
{
Point aPoint = rMEvt.GetPosPixel();
if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
{
if ( m_rTableControl.isTooltipActive() && m_rTableControl.getRowAtPoint( aPoint ) >= 0 )
if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS )
{
SetPointer(POINTER_ARROW);
const ::rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint);
Help::EnableBalloonHelp();
Window::SetHelpText( rHelpText );
}
else if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS )
{
if(Help::IsBalloonHelpEnabled())
Help::DisableBalloonHelp();
m_rTableControl.resizeColumn(aPoint);
m_rTableControl.resizeColumn( aPoint );
}
else
{
if(Help::IsBalloonHelpEnabled())
Help::DisableBalloonHelp();
Window::MouseMove( rMEvt );
}
}

View file

@ -30,8 +30,7 @@
#include "svtxgridcontrol.hxx"
#include "accessibletableimp.hxx"
#include <com/sun/star/view/SelectionType.hpp>
#include "svtools/table/gridtablerenderer.hxx"
#include "svtools/table/defaultinputhandler.hxx"
#include "svtools/table/abstracttablecontrol.hxx"
#include "svtools/table/tablecontrol.hxx"
#include "unocontroltablemodel.hxx"
#include <comphelper/sequence.hxx>
@ -93,17 +92,7 @@ sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int
TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getItemIndexAtPoint: no control (anymore)!", -1 );
return pTable->GetRowAtPoint( 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)
{
::vos::OGuard aGuard( GetMutex() );
TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setToolTip: no control (anymore)!" );
pTable->setTooltip(text, columns);
return pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) );
}
void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)

View file

@ -102,7 +102,6 @@ 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);

View file

@ -526,6 +526,15 @@ namespace svt { namespace table
}
}
//------------------------------------------------------------------------------------------------------------------
void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip )
{
DBG_CHECK_ME();
OSL_UNUSED( i_col );
OSL_UNUSED( i_row );
OSL_UNUSED( o_cellToolTip );
}
//------------------------------------------------------------------------------------------------------------------
::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const
{

View file

@ -103,6 +103,7 @@ namespace svt { namespace table
virtual void addTableModelListener( const PTableModelListener& i_listener );
virtual void removeTableModelListener( const PTableModelListener& i_listener );
virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent );
virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip );
virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const;
virtual ::com::sun::star::util::Color getLineColor();
virtual ::com::sun::star::util::Color getHeaderBackgroundColor();

View file

@ -339,12 +339,6 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_
return xGrid->getItemIndexAtPoint( x, y );
}
//----------------------------------------------------------------------------------------------------------------------
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 )->setToolTip( text, columns );
}
//----------------------------------------------------------------------------------------------------------------------
::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
{

View file

@ -98,7 +98,6 @@ public:
// ::com::sun::star::awt::grid::XGridControl
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);
// ::com::sun::star::awt::grid::XGridSelection
virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException);