2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2009-08-26 13:11:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-08-26 13:11:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
#include <com/sun/star/awt/grid/XMutableGridDataModel.hpp>
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2011-01-16 20:59:30 +01:00
|
|
|
|
|
|
|
#include <cppuhelper/basemutex.hxx>
|
|
|
|
#include <cppuhelper/compbase2.hxx>
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <toolkit/helper/mutexandbroadcasthelper.hxx>
|
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::awt::grid;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
namespace comphelper
|
|
|
|
{
|
|
|
|
class ComponentGuard;
|
|
|
|
}
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
namespace toolkit
|
|
|
|
{
|
|
|
|
|
|
|
|
enum broadcast_type { row_added, row_removed, data_changed};
|
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
typedef ::cppu::WeakComponentImplHelper2 < XMutableGridDataModel
|
|
|
|
, XServiceInfo
|
|
|
|
> DefaultGridDataModel_Base;
|
|
|
|
|
|
|
|
class DefaultGridDataModel :public ::cppu::BaseMutex
|
|
|
|
,public DefaultGridDataModel_Base
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DefaultGridDataModel();
|
2011-01-03 23:14:55 +01:00
|
|
|
DefaultGridDataModel( DefaultGridDataModel const & i_copySource );
|
2009-08-26 13:11:27 +00:00
|
|
|
virtual ~DefaultGridDataModel();
|
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
// XMutableGridDataModel
|
2011-01-16 22:18:58 +01:00
|
|
|
virtual void SAL_CALL addRow( const Any& i_heading, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& Headings, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
|
2011-01-10 15:47:51 +01:00
|
|
|
virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException);
|
2011-01-14 15:13:23 +01:00
|
|
|
virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
|
2011-01-27 08:17:57 +01:00
|
|
|
virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
2011-01-14 15:13:23 +01:00
|
|
|
virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
2011-01-10 15:47:51 +01:00
|
|
|
virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
// XGridDataModel
|
|
|
|
virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException);
|
2011-01-06 16:28:45 +01:00
|
|
|
virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException);
|
2011-01-10 15:47:51 +01:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
2011-01-14 13:19:09 +01:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
2011-01-16 22:18:58 +01:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
|
2011-01-03 23:14:55 +01:00
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
// OComponentHelper
|
|
|
|
virtual void SAL_CALL disposing();
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
// XCloneable
|
|
|
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException);
|
2009-08-26 13:11:27 +00:00
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
|
|
|
|
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);
|
|
|
|
|
|
|
|
private:
|
2011-01-14 13:19:09 +01:00
|
|
|
typedef ::std::pair< Any, Any > CellData;
|
|
|
|
typedef ::std::vector< CellData > RowData;
|
|
|
|
typedef ::std::vector< RowData > GridData;
|
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
void broadcast(
|
|
|
|
GridDataEvent const & i_event,
|
|
|
|
void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( ::com::sun::star::awt::grid::GridDataEvent const & ),
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard & i_instanceLock
|
2011-01-10 15:47:51 +01:00
|
|
|
);
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
void impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount = -1 );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
CellData const & impl_getCellData_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ) const;
|
|
|
|
CellData& impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex );
|
|
|
|
RowData& impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 22:18:58 +01:00
|
|
|
GridData m_aData;
|
|
|
|
::std::vector< ::com::sun::star::uno::Any > m_aRowHeaders;
|
|
|
|
sal_Int32 m_nColumnCount;
|
2009-08-26 13:11:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|