merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / controls / grid / defaultgriddatamodel.hxx
blob9f9fd8c0c3b568c3c1849297608d9e633c33ccf4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: griddatamodel.hxx,v $
10 * $Revision: 1.4 $
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>
42 #include <vector>
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;
52 namespace toolkit
55 enum broadcast_type { row_added, row_removed, data_changed};
57 class DefaultGridDataModel : public ::cppu::WeakImplHelper2< XGridDataModel, XServiceInfo >,
58 public MutexAndBroadcastHelper
60 public:
61 DefaultGridDataModel();
62 virtual ~DefaultGridDataModel();
64 // XGridDataModel
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);
77 // XComponent
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);
82 // XServiceInfo
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);
87 private:
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 );
94 sal_Int32 rowHeight;
95 std::vector< std::vector < ::rtl::OUString > > data;
96 std::vector< ::rtl::OUString > rowHeaders;