summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-11 10:58:26 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-11 10:58:26 +0100
commit5a256f4486e4b9875ea62c9a8f65ad110fda71b9 (patch)
tree0ec1d2db577a71f5bb2c3a82205cba7d43d083d9 /svtools
parent858b82e990dee4558dbe3fe3c026d806f5acd524 (diff)
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.
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/table/abstracttablecontrol.hxx2
-rw-r--r--svtools/inc/svtools/table/tablecontrol.hxx13
-rw-r--r--svtools/inc/svtools/table/tabledatawindow.hxx1
-rwxr-xr-xsvtools/inc/svtools/table/tablemodel.hxx17
-rwxr-xr-xsvtools/source/table/cellvalueconversion.cxx6
-rw-r--r--svtools/source/table/tablecontrol.cxx27
-rwxr-xr-xsvtools/source/table/tablecontrol_impl.cxx75
-rwxr-xr-xsvtools/source/table/tablecontrol_impl.hxx3
-rw-r--r--svtools/source/table/tabledatawindow.cxx68
-rw-r--r--svtools/source/uno/svtxgridcontrol.cxx15
-rw-r--r--svtools/source/uno/svtxgridcontrol.hxx1
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx9
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx1
13 files changed, 98 insertions, 140 deletions
diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx
index ac91006e42f5..eb70a6967e6f 100644
--- a/svtools/inc/svtools/table/abstracttablecontrol.hxx
+++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx
@@ -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;
diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx
index b75ebe0dcc88..d557597b6ff8 100644
--- a/svtools/inc/svtools/table/tablecontrol.hxx
+++ b/svtools/inc/svtools/table/tablecontrol.hxx
@@ -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();
diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx
index 829feecd5836..1cc030be512b 100644
--- a/svtools/inc/svtools/table/tabledatawindow.hxx
+++ b/svtools/inc/svtools/table/tabledatawindow.hxx
@@ -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();
diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx
index dc25788bc491..b8c13822a460 100755
--- a/svtools/inc/svtools/table/tablemodel.hxx
+++ b/svtools/inc/svtools/table/tablemodel.hxx
@@ -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;
diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx
index 9b36ad095203..286ca505bb30 100755
--- a/svtools/source/table/cellvalueconversion.cxx
+++ b/svtools/source/table/cellvalueconversion.cxx
@@ -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 )
diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx
index 08227b9abd91..1b6027b71324 100644
--- a/svtools/source/table/tablecontrol.cxx
+++ b/svtools/source/table/tablecontrol.cxx
@@ -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();
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index d4de4bc0d3ef..ef217527cdff 100755
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -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
diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx
index 73819327f0ae..730b00b638b8 100755
--- a/svtools/source/table/tablecontrol_impl.hxx
+++ b/svtools/source/table/tablecontrol_impl.hxx
@@ -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);
diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx
index 41bd851e6b82..2fc08b13742e 100644
--- a/svtools/source/table/tabledatawindow.cxx
+++ b/svtools/source/table/tabledatawindow.cxx
@@ -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 )
- {
- 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 ( 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 );
}
}
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index de4fe1c02e17..d4ab00868ec9 100644
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -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)
diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx
index 19b52c183295..361e7d41cad7 100644
--- a/svtools/source/uno/svtxgridcontrol.hxx
+++ b/svtools/source/uno/svtxgridcontrol.hxx
@@ -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);
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index 8a6658578569..f7b2ca07eb22 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -527,6 +527,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
{
DBG_CHECK_ME();
diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx
index 1f3f7f075264..a6cd858ed34f 100644
--- a/svtools/source/uno/unocontroltablemodel.hxx
+++ b/svtools/source/uno/unocontroltablemodel.hxx
@@ -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();