xref: /aoo42x/main/forms/source/component/Grid.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "errorbroadcaster.hxx"
29 #include "FormComponent.hxx"
30 #include "formcontrolfont.hxx"
31 #include "InterfaceContainer.hxx"
32 
33 /** === begin UNO includes === **/
34 #include <com/sun/star/form/XGridColumnFactory.hpp>
35 #include <com/sun/star/form/XLoadable.hpp>
36 #include <com/sun/star/sdb/XRowSetSupplier.hpp>
37 #include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp>
38 #include <com/sun/star/view/XSelectionSupplier.hpp>
39 /** === end UNO includes === **/
40 
41 #include <comphelper/proparrhlp.hxx>
42 #include <cppuhelper/implbase7.hxx>
43 #include <tools/link.hxx>
44 
45 //.........................................................................
46 namespace frm
47 {
48 //.........................................................................
49 
50 class OGridColumn;
51 
52 //==================================================================
53 // ColumnDescription
54 //==================================================================
55 
56 	struct ColumnDescription : public ElementDescription
57 	{
58 	public:
59 		OGridColumn*				pColumn;		// not owned by this instance! only to prevent duplicate XUnoTunnel usage
60 	};
61 
62 //==================================================================
63 // OGridControlModel
64 //==================================================================
65 typedef ::cppu::ImplHelper7 <	::com::sun::star::awt::XControlModel
66 							,	::com::sun::star::form::XGridColumnFactory
67 							,	::com::sun::star::form::XReset
68 							,	::com::sun::star::view::XSelectionSupplier
69 							,	::com::sun::star::sdb::XSQLErrorListener
70                             ,   ::com::sun::star::sdb::XRowSetSupplier
71                             ,   ::com::sun::star::sdb::XRowSetChangeBroadcaster
72 							>	OGridControlModel_BASE;
73 
74 class OGridControlModel :public OControlModel
75 						,public OInterfaceContainer
76 						,public OErrorBroadcaster
77                         ,public FontControlModel
78 						,public OGridControlModel_BASE
79 {
80 	::cppu::OInterfaceContainerHelper		m_aSelectListeners,
81 											m_aResetListeners,
82                                             m_aRowSetChangeListeners;
83 
84 // [properties]
85 	::com::sun::star::uno::Any				m_aRowHeight;			// Zeilenhoehe
86 	::com::sun::star::uno::Any				m_aTabStop;
87 	::com::sun::star::uno::Any				m_aBackgroundColor;
88 	::com::sun::star::uno::Any				m_aCursorColor; 			// transient
89     ::com::sun::star::uno::Any              m_aBorderColor;
90 	::rtl::OUString 						m_aDefaultControl;
91 	::rtl::OUString 						m_sHelpText;
92 // [properties]
93 
94 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >		m_xSelection;
95 
96 // [properties]
97 	::rtl::OUString 			m_sHelpURL; 				// URL
98 	sal_Int16					m_nBorder;
99     sal_Int16                   m_nWritingMode;
100     sal_Int16                   m_nContextWritingMode;
101 	sal_Bool					m_bEnableVisible	: 1;
102 	sal_Bool					m_bEnable			: 1;
103 	sal_Bool					m_bNavigation		: 1;
104 	sal_Bool					m_bRecordMarker 	: 1;
105 	sal_Bool					m_bPrintable		: 1;
106 	sal_Bool					m_bAlwaysShowCursor : 1;    // transient
107 	sal_Bool					m_bDisplaySynchron	: 1;    // transient
108 // [properties]
109 
110 protected:
111 	void _reset();
112 
113 public:
114 	DECLARE_DEFAULT_LEAF_XTOR( OGridControlModel );
115 
116     // UNO Anbindung
117 	DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OControlModel);
118 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
119 
120     // XChild
121 	virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
122 
123     // XServiceInfo
124 	IMPLEMENTATION_NAME(OGridControlModel);
125 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
126 
127     // XTypeProvider
128     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
129 
130     // OComponentHelper
131 	virtual void SAL_CALL disposing();
132 
133     // XEventListener
134 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
135 
136     // XReset
137 	virtual void SAL_CALL reset() throw ( ::com::sun::star::uno::RuntimeException);
138 	virtual void SAL_CALL addResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
139 	virtual void SAL_CALL removeResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
140 
141     // XSelectionSupplier
142 	virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& aElement) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
143 	virtual ::com::sun::star::uno::Any SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
144 	virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
145 	virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
146 
147     // XGridColumnFactory
148 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> SAL_CALL createColumn(const ::rtl::OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
149 	virtual StringSequence SAL_CALL getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException);
150 
151     // XPersistObject
152 	virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
153 	virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
154 	virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
155 
156     // XPropertySet
157 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
158 	virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
159 										  sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
160 										throw(::com::sun::star::lang::IllegalArgumentException);
161 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
162 
163     // XPropertyState
164 	virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
165 
166     // XSQLErrorListener
167 	virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
168 
169     // XRowSetSupplier
170     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet(  ) throw (::com::sun::star::uno::RuntimeException);
171     virtual void SAL_CALL setRowSet( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource ) throw (::com::sun::star::uno::RuntimeException);
172 
173     // XRowSetChangeBroadcaster
174     virtual void SAL_CALL addRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException);
175     virtual void SAL_CALL removeRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException);
176 
177     // OControlModel's property handling
178 	virtual void describeFixedProperties(
179 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
180     ) const;
181 
182     // prevent method hiding
183     using OControlModel::disposing;
184     using OControlModel::getFastPropertyValue;
185 
186 protected:
187 	DECLARE_XCLONEABLE();
188 
189 protected:
190 	virtual void approveNewElement(
191 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject,
192 			ElementDescription* _pElement
193 		);
194 
195 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>  createColumn(sal_Int32 nTypeId) const;
196 
197 	OGridColumn* getColumnImplementation(const InterfaceRef& _rxIFace) const;
198 
199 	virtual ElementDescription* createElementMetaData( );
200 
201 protected:
202 	virtual void implRemoved(const InterfaceRef& _rxObject);
203 	virtual void implInserted( const ElementDescription* _pElement );
204 	virtual void impl_replacedElement(
205                     const ::com::sun::star::container::ContainerEvent& _rEvent,
206                     ::osl::ClearableMutexGuard& _rInstanceLock
207                 );
208 
209 	void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn);
210 	void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn);
211 
212 	void cloneColumns( const OGridControlModel* _pOriginalContainer );
213 };
214 
215 //.........................................................................
216 }	// namespace frm
217 //.........................................................................
218 
219 
220