1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: griddatamodel.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
33 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
34 #include <com/sun/star/awt/grid/GridDataEvent.hpp>
35 #include <com/sun/star/awt/grid/XGridDataListener.hpp>
36 #include <com/sun/star/lang/XEventListener.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XUnoTunnel.hpp>
39 #include <cppuhelper/implbase2.hxx>
40 #include <cppuhelper/implbase3.hxx>
41 #include <rtl/ref.hxx>
43 #include <toolkit/helper/mutexandbroadcasthelper.hxx>
45 using ::rtl::OUString
;
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::awt
;
49 using namespace ::com::sun::star::awt::grid
;
50 using namespace ::com::sun::star::lang
;
55 enum broadcast_type
{ row_added
, row_removed
, data_changed
};
57 class DefaultGridDataModel
: public ::cppu::WeakImplHelper2
< XGridDataModel
, XServiceInfo
>,
58 public MutexAndBroadcastHelper
61 DefaultGridDataModel();
62 virtual ~DefaultGridDataModel();
65 virtual ::sal_Int32 SAL_CALL
getRowHeight() throw (::com::sun::star::uno::RuntimeException
);
66 virtual void SAL_CALL
setRowHeight(::sal_Int32 the_value
) throw (::com::sun::star::uno::RuntimeException
);
67 virtual ::sal_Int32 SAL_CALL
getRowCount() throw (::com::sun::star::uno::RuntimeException
);
68 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getRowHeaders() throw (::com::sun::star::uno::RuntimeException
);
69 virtual void SAL_CALL
setRowHeaders(const ::com::sun::star::uno::Sequence
< ::rtl::OUString
> & value
) throw (::com::sun::star::uno::RuntimeException
);
70 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::rtl::OUString
> > SAL_CALL
getData() throw (::com::sun::star::uno::RuntimeException
);
71 virtual void SAL_CALL
addRow(const ::rtl::OUString
& headername
, const ::com::sun::star::uno::Sequence
< ::rtl::OUString
> & data
) throw (::com::sun::star::uno::RuntimeException
);
72 virtual void SAL_CALL
removeRow(::sal_Int32 index
) throw (::com::sun::star::uno::RuntimeException
);
73 virtual void SAL_CALL
addDataListener( const Reference
< XGridDataListener
>& xListener
) throw (RuntimeException
);
74 virtual void SAL_CALL
removeDataListener( const Reference
< XGridDataListener
>& xListener
) throw (RuntimeException
);
75 virtual void SAL_CALL
removeAll() throw (RuntimeException
);
78 virtual void SAL_CALL
dispose( ) throw (RuntimeException
);
79 virtual void SAL_CALL
addEventListener( const Reference
< XEventListener
>& xListener
) throw (RuntimeException
);
80 virtual void SAL_CALL
removeEventListener( const Reference
< XEventListener
>& aListener
) throw (RuntimeException
);
83 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw (RuntimeException
);
84 virtual ::sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw (RuntimeException
);
85 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw (RuntimeException
);
89 void broadcast( broadcast_type eType
, const GridDataEvent
& aEvent
);
90 void broadcast_changed( ::rtl::OUString name
, Any oldValue
, Any newValue
);
91 void broadcast_add( sal_Int32 index
, const ::rtl::OUString
& headerName
, const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& rowData
);
92 void broadcast_remove( sal_Int32 index
, const ::rtl::OUString
& headerName
, const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& rowData
);
95 std::vector
< std::vector
< ::rtl::OUString
> > data
;
96 std::vector
< ::rtl::OUString
> rowHeaders
;