summaryrefslogtreecommitdiff
path: root/toolkit/source
diff options
context:
space:
mode:
authorMihaela Kedikova <misheto@openoffice.org>2010-03-22 11:17:10 +0100
committerMihaela Kedikova <misheto@openoffice.org>2010-03-22 11:17:10 +0100
commit99d003c030ec5d547c452efdc42be3a3fa6810fa (patch)
treec163017c3753cb4323f4ee058f4248bed8d0d0e8 /toolkit/source
parent9945f4ca9649f961bbc6d9f5be238771e3e2b96c (diff)
recent changes for grid control
Diffstat (limited to 'toolkit/source')
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx170
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.hxx20
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx7
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx79
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx12
-rw-r--r--toolkit/source/controls/grid/gridcontrol.cxx58
-rw-r--r--toolkit/source/controls/grid/gridcontrol.hxx7
-rw-r--r--toolkit/source/helper/listenermultiplexer.cxx5
-rw-r--r--toolkit/source/helper/property.cxx5
9 files changed, 254 insertions, 109 deletions
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
index 337076bdfaa9..f68239f9712c 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
@@ -33,6 +33,7 @@
#include "defaultgridcolumnmodel.hxx"
#include <comphelper/sequence.hxx>
#include <toolkit/helper/servicenames.hxx>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <rtl/ref.hxx>
using ::rtl::OUString;
@@ -42,7 +43,8 @@ using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::awt::grid;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::style;
-#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" ))
+//#define COLUMNSELECTIONALLOWED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnSelectionAllowed" ))
+//#define COLUMNRESIZED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResized" ))
namespace toolkit
{
@@ -53,7 +55,7 @@ namespace toolkit
DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory)
: columns(std::vector< Reference< XGridColumn > >())
- ,m_nColumnHeaderHeight(10)
+ ,m_nColumnHeaderHeight(0)
,m_xFactory(xFactory)
{
}
@@ -66,68 +68,68 @@ DefaultGridColumnModel::~DefaultGridColumnModel()
//---------------------------------------------------------------------
-void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent )
-{
- ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() );
- if( pIter )
- {
- ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
- while(aListIter.hasMoreElements())
- {
- XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
- switch( eType )
- {
- case column_added: pListener->columnAdded(aEvent); break;
- case column_removed: pListener->columnRemoved(aEvent); break;
- case column_changed: pListener->columnChanged(aEvent); break;
- }
- }
- }
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL );
- broadcast( column_changed, aEvent);
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
- broadcast( column_added, aEvent);
-}
-
-//---------------------------------------------------------------------
-
-void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
-{
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
- broadcast( column_removed, aEvent);
-}
+//void DefaultGridColumnModel::broadcast( broadcast_type eType, const GridColumnEvent& aEvent )
+//{
+// ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() );
+// if( pIter )
+// {
+// ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
+// while(aListIter.hasMoreElements())
+// {
+// XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
+// switch( eType )
+// {
+// case column_added: pListener->columnAdded(aEvent); break;
+// case column_removed: pListener->columnRemoved(aEvent); break;
+// case column_changed: pListener->columnChanged(aEvent); break;
+// }
+// }
+// }
+//}
+//
+////---------------------------------------------------------------------
+//
+//void DefaultGridColumnModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue)
+//{
+// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+// GridColumnEvent aEvent( xSource, name, oldValue, newValue, 0, NULL );
+// broadcast( column_changed, aEvent);
+//}
+//
+////---------------------------------------------------------------------
+//
+//void DefaultGridColumnModel::broadcast_add( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
+//{
+// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
+// broadcast( column_added, aEvent);
+//}
+//
+////---------------------------------------------------------------------
+//
+//void DefaultGridColumnModel::broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn )
+//{
+// Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+// GridColumnEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, rColumn );
+// broadcast( column_removed, aEvent);
+//}
//---------------------------------------------------------------------
// XDefaultGridColumnModel
//---------------------------------------------------------------------
-::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException)
-{
- return selectionAllowed;
-}
-
-//---------------------------------------------------------------------
-
-void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
-{
- sal_Bool oldValue = selectionAllowed;
- selectionAllowed = value;
- broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed));
-}
+//::sal_Bool SAL_CALL DefaultGridColumnModel::getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException)
+//{
+// return selectionAllowed;
+//}
+//
+////---------------------------------------------------------------------
+//
+//void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
+//{
+// sal_Bool oldValue = selectionAllowed;
+// selectionAllowed = value;
+// broadcast_changed( COLUMNSELECTIONALLOWED, Any(oldValue) , Any(selectionAllowed));
+//}
//---------------------------------------------------------------------
@@ -141,10 +143,10 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value
::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException)
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
-
- columns.push_back(column);
+ Reference<XGridColumn> xColumn(column);
+ columns.push_back(xColumn);
sal_Int32 index = columns.size() - 1;
- broadcast_add(index, column );
+ xColumn->setIndex(index);
return index;
}
@@ -160,22 +162,24 @@ void SAL_CALL DefaultGridColumnModel::setColumnSelectionAllowed(::sal_Bool value
::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
{
if ( index >=0 && index < ((sal_Int32)columns.size()))
+ {
return columns[index];
+ }
else
return Reference< XGridColumn >();
}
//---------------------------------------------------------------------
-void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
-{
- BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener );
-}
-
-//---------------------------------------------------------------------
-
-void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
-{
- BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener );
-}
+//void SAL_CALL DefaultGridColumnModel::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+//{
+// BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener );
+//}
+//
+////---------------------------------------------------------------------
+//
+//void SAL_CALL DefaultGridColumnModel::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+//{
+// BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener );
+//}
//---------------------------------------------------------------------
void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException)
@@ -193,9 +197,25 @@ void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) t
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY );
for(sal_Int32 i=0;i<rowElements;i++)
+ {
+ Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY );
columns.push_back(xColumn);
+ xColumn->setIndex(i);
+ }
+}
+::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY );
+ xColumn->setColumnWidth(column->getColumnWidth());
+ xColumn->setPreferredWidth(column->getPreferredWidth());
+ xColumn->setMaxWidth(column->getMaxWidth());
+ xColumn->setMinWidth(column->getMinWidth());
+ xColumn->setPreferredWidth(column->getPreferredWidth());
+ xColumn->setResizeable(column->getResizeable());
+ xColumn->setTitle(column->getTitle());
+ xColumn->setHorizontalAlign(column->getHorizontalAlign());
+ return xColumn;
}
//---------------------------------------------------------------------
// XComponent
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
index d700a6b07b5d..bfa9892b3777 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx
@@ -32,7 +32,7 @@
#include "precompiled_toolkit.hxx"
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
-#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
+//#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -43,6 +43,7 @@
#include <toolkit/helper/mutexandbroadcasthelper.hxx>
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -54,7 +55,7 @@ using namespace ::com::sun::star::lang;
namespace toolkit
{
-enum broadcast_type { column_added, column_removed, column_changed};
+//enum broadcast_type { column_added, column_removed, column_changed};
class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >,
public MutexAndBroadcastHelper
@@ -65,17 +66,18 @@ public:
// XGridColumnModel
- virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
+ //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException);
+ //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
- virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
+ //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
+ //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException);
virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (RuntimeException);
virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
@@ -87,10 +89,10 @@ public:
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
private:
- void broadcast( broadcast_type eType, const GridColumnEvent& aEvent );
- void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue );
+ /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent );
+ void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
- void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );
+ void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/
std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns;
sal_Bool selectionAllowed;
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index 2d695a9bad0a..528e0e17c3e0 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -35,9 +35,6 @@
#include <toolkit/helper/servicenames.hxx>
#include <rtl/ref.hxx>
-#include <com/sun/star/awt/XFixedText.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
using ::rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -57,9 +54,9 @@ namespace toolkit
///////////////////////////////////////////////////////////////////////
DefaultGridDataModel::DefaultGridDataModel()
-: rowHeight(10),
+: rowHeight(0),
rowHeaders(std::vector< ::rtl::OUString >()),
- m_nRowHeaderWidth(7)
+ m_nRowHeaderWidth(10)
{
}
diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx
index 40c2018c4cc5..b367ee908f3a 100644
--- a/toolkit/source/controls/grid/gridcolumn.cxx
+++ b/toolkit/source/controls/grid/gridcolumn.cxx
@@ -43,6 +43,15 @@ using namespace ::com::sun::star::awt::grid;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::style;
+#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" ))
+#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" ))
+#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" ))
+#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" ))
+#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" ))
+#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" ))
+#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" ))
+#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" ))
+
namespace toolkit
{
@@ -54,7 +63,9 @@ GridColumn::GridColumn()
: identifier(Any())
,horizontalAlign(HorizontalAlignment(0))
,columnWidth(4)
+,preferredWidth(0)
,bResizeable(true)
+,index(0)
{
}
@@ -66,6 +77,39 @@ GridColumn::~GridColumn()
//---------------------------------------------------------------------
+void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent )
+{
+ ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() );
+ if( pIter )
+ {
+ ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
+ while(aListIter.hasMoreElements())
+ {
+ XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next());
+ switch( eType )
+ {
+ case column_attribute_changed: pListener->columnChanged(aEvent); break;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------
+
+void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue)
+{
+ Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ GridColumnEvent aEvent( xSource, name, oldValue, newValue, index);
+ broadcast( column_attribute_changed, aEvent);
+}
+
+void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(PREFWIDTH == name)
+ preferredWidth = width;
+ else if (COLWIDTH == name)
+ columnWidth = width;
+}
//---------------------------------------------------------------------
// XGridColumn
//---------------------------------------------------------------------
@@ -86,6 +130,7 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value
::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException)
{
+ broadcast_changed(UPDATE, Any(columnWidth), Any());
return columnWidth;
}
@@ -94,11 +139,13 @@ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value
void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
{
columnWidth = value;
+ broadcast_changed(COLWIDTH, Any(columnWidth),Any(value));
}
//--------------------------------------------------------------------
::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException)
{
+ broadcast_changed(UPDATE, Any(preferredWidth), Any());
return preferredWidth;
}
@@ -107,6 +154,7 @@ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::s
void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
{
preferredWidth = value;
+ broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value));
}
//--------------------------------------------------------------------
@@ -120,6 +168,7 @@ void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun
void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
{
maxWidth = value;
+ broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value));
}
//--------------------------------------------------------------------
@@ -133,6 +182,7 @@ void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star
void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
{
minWidth = value;
+ broadcast_changed(MINWIDTH, Any(minWidth),Any(value));
}
//--------------------------------------------------------------------
@@ -147,6 +197,7 @@ void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star
void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException)
{
title = value;
+ broadcast_changed(TITLE, Any(title),Any(value));
}
//--------------------------------------------------------------------
@@ -160,6 +211,7 @@ sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::Runt
void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
{
bResizeable = value;
+ broadcast_changed(COLRESIZE, Any(bResizeable),Any(value));
}
//---------------------------------------------------------------------
HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException)
@@ -171,6 +223,19 @@ HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun:
void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException)
{
horizontalAlign = align;
+ broadcast_changed(HALIGN, Any(horizontalAlign),Any(align));
+}
+//---------------------------------------------------------------------
+void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+{
+ BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener );
+}
+
+//---------------------------------------------------------------------
+
+void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
+{
+ BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener );
}
//---------------------------------------------------------------------
@@ -179,22 +244,30 @@ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (:
void SAL_CALL GridColumn::dispose() throw (RuntimeException)
{
+ ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
+
+ ::com::sun::star::lang::EventObject aEvent;
+ aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) );
+ BrdcstHelper.aLC.disposeAndClear( aEvent );
}
//---------------------------------------------------------------------
void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
{
- (void) xListener;
+ BrdcstHelper.addListener( XEventListener::static_type(), xListener );
}
//---------------------------------------------------------------------
void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
{
- (void) xListener;
+ BrdcstHelper.removeListener( XEventListener::static_type(), xListener );
+}
+void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException)
+{
+ index = _nIndex;
}
-
//---------------------------------------------------------------------
// XServiceInfo
//---------------------------------------------------------------------
diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx
index a458a07ffda8..d7651a2e00ab 100644
--- a/toolkit/source/controls/grid/gridcolumn.hxx
+++ b/toolkit/source/controls/grid/gridcolumn.hxx
@@ -31,6 +31,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_toolkit.hxx"
#include <com/sun/star/awt/grid/XGridColumn.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
+#include <com/sun/star/awt/grid/GridColumnEvent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -51,6 +53,7 @@ using namespace ::com::sun::star::lang;
namespace toolkit
{
+enum broadcast_column_type { column_attribute_changed};
class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >,
public MutexAndBroadcastHelper
{
@@ -75,6 +78,9 @@ public:
virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (RuntimeException);
virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
@@ -85,9 +91,13 @@ public:
virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
-
+ virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException);
private:
+ void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent );
+ void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue);
+
Any identifier;
+ sal_Int32 index;
sal_Int32 columnWidth;
sal_Int32 preferredWidth;
sal_Int32 maxWidth;
diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx
index fa0c3de3adb3..b279ace0ef12 100644
--- a/toolkit/source/controls/grid/gridcontrol.cxx
+++ b/toolkit/source/controls/grid/gridcontrol.cxx
@@ -86,7 +86,7 @@ UnoGridModel::UnoGridModel()
ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND );
ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND );
ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR );
-
+ ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND );
}
UnoGridModel::UnoGridModel( const UnoGridModel& rModel )
@@ -112,6 +112,22 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_GridControl ) );
case BASEPROPERTY_GRID_SELECTIONMODE:
return uno::makeAny( SelectionType(1) );
+ case BASEPROPERTY_GRID_SHOWROWHEADER:
+ return uno::makeAny( (sal_Bool)sal_False );
+ case BASEPROPERTY_GRID_SHOWCOLUMNHEADER:
+ return uno::makeAny( (sal_Bool)sal_False );
+ case BASEPROPERTY_GRID_DATAMODEL:
+ return uno::makeAny( Reference<XGridDataModel> ());
+ case BASEPROPERTY_GRID_COLUMNMODEL:
+ return uno::makeAny(Reference<XGridColumnModel>() );
+ case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_HEADER_BACKGROUND:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_LINE_COLOR:
+ return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) );
+ case BASEPROPERTY_GRID_ROW_BACKGROUND:
+ return uno::makeAny(com::sun::star::util::Color(0xFFFFFF) );
default:
return UnoControlModel::ImplGetDefaultValue( nPropId );
}
@@ -141,7 +157,8 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime
// class UnoGridControl
// ----------------------------------------------------
UnoGridControl::UnoGridControl()
-: mSelectionMode(SelectionType(1))
+: mSelectionMode(SelectionType(1)),
+ m_aSelectionListeners( *this )
{
}
@@ -152,6 +169,9 @@ OUString UnoGridControl::GetComponentServiceName()
void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException)
{
+ lang::EventObject aEvt;
+ aEvt.Source = (::cppu::OWeakObject*)this;
+ m_aSelectionListeners.disposeAndClear( aEvt );
UnoControl::dispose();
}
@@ -160,17 +180,23 @@ void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk
UnoControlBase::createPeer( rxToolkit, rParentPeer );
Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW );
+ xGrid->addSelectionListener(&m_aSelectionListeners);
Reference<XGridDataListener> xListener ( getPeer(), UNO_QUERY_THROW );
- //Reference<XGridColumnListener> xColListener ( getPeer(), UNO_QUERY_THROW );
+ Reference<XGridColumnListener> xColListener ( getPeer(), UNO_QUERY_THROW );
Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW );
Reference<XGridDataModel> xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW );
if(xGridDataModel != NULL)
xGridDataModel->addDataListener(xListener);
- //Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW );
- //if(xGridColumnModel != NULL)
- // xGridColumnModel->addColumnListener(xColListener);
+ Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW );
+ if(xGridColumnModel != NULL)
+ {
+ for(int i = 0;i<xGridColumnModel->getColumnCount();i++)
+ {
+ xGridColumnModel->getColumn(i)->addColumnListener(xColListener);
+ }
+ }
}
@@ -212,16 +238,24 @@ void SAL_CALL UnoGridControl::removeMouseListener(const ::com::sun::star::uno::R
return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex();
}
-void SAL_CALL UnoGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->insertIndexIntervall( start, length);
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows);
}
-void SAL_CALL UnoGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeIndexIntervall( start, length );
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows();
+}
+void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows);
}
+void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows();
+}
::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException)
{
return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection();
@@ -244,12 +278,12 @@ void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::
void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->addSelectionListener( listener );
+ m_aSelectionListeners.addInterface( listener );
}
void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->removeSelectionListener( listener );
+ m_aSelectionListeners.removeInterface( listener );
}
}//namespace toolkit
diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx
index 8b219e70a0f2..c566569d7dbf 100644
--- a/toolkit/source/controls/grid/gridcontrol.hxx
+++ b/toolkit/source/controls/grid/gridcontrol.hxx
@@ -101,8 +101,10 @@ public:
virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException);
@@ -116,6 +118,7 @@ public:
using UnoControl::getPeer;
private:
::com::sun::star::view::SelectionType mSelectionMode;
+ SelectionListenerMultiplexer m_aSelectionListeners;
};
} // toolkit
diff --git a/toolkit/source/helper/listenermultiplexer.cxx b/toolkit/source/helper/listenermultiplexer.cxx
index cdbb156cd0f5..ee4c9bf4c144 100644
--- a/toolkit/source/helper/listenermultiplexer.cxx
+++ b/toolkit/source/helper/listenermultiplexer.cxx
@@ -209,3 +209,8 @@ IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer, ::com
// ----------------------------------------------------
IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer, ::com::sun::star::awt::tree::XTreeEditListener )
+// ----------------------------------------------------
+// class SelectionListenerMultiplexer
+// ----------------------------------------------------
+IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener )
+IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent ) \ No newline at end of file
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index 9438cb93541b..beb746e02f36 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -286,8 +286,9 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ),
DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
- DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID )
- };
+ DECL_PROP_3 ( "LineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
+ DECL_PROP_3 ( "RowBackgroundColor", GRID_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID )
+ };
pPropertyInfos = aImplPropertyInfos;
nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo );
}