summaryrefslogtreecommitdiff
path: root/toolkit/source/controls/grid
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-11 11:42:27 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-01-11 11:42:27 +0100
commit012b72f48860433345989eedc9cd1ccb9350b455 (patch)
treebcc5131f9951854d6b3af7ed88aa340c2720d581 /toolkit/source/controls/grid
parent5a256f4486e4b9875ea62c9a8f65ad110fda71b9 (diff)
gridsort: +XGridColumn::HelpText, to be displayed as tooltip for the column header
Diffstat (limited to 'toolkit/source/controls/grid')
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx2
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx78
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx18
3 files changed, 44 insertions, 54 deletions
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 <cppuhelper/typeprovider.hxx>
#include <toolkit/helper/servicenames.hxx>
-#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;
};