xref: /aoo41x/main/forms/source/component/Grid.hxx (revision 2d785d7e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "errorbroadcaster.hxx"
25 #include "FormComponent.hxx"
26 #include "formcontrolfont.hxx"
27 #include "InterfaceContainer.hxx"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/form/XGridColumnFactory.hpp>
31 #include <com/sun/star/form/XLoadable.hpp>
32 #include <com/sun/star/sdb/XRowSetSupplier.hpp>
33 #include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp>
34 #include <com/sun/star/view/XSelectionSupplier.hpp>
35 /** === end UNO includes === **/
36 
37 #include <comphelper/proparrhlp.hxx>
38 #include <cppuhelper/implbase7.hxx>
39 #include <tools/link.hxx>
40 
41 //.........................................................................
42 namespace frm
43 {
44 //.........................................................................
45 
46 class OGridColumn;
47 
48 //==================================================================
49 // ColumnDescription
50 //==================================================================
51 
52 	struct ColumnDescription : public ElementDescription
53 	{
54 	public:
55 		OGridColumn*				pColumn;		// not owned by this instance! only to prevent duplicate XUnoTunnel usage
56 	};
57 
58 //==================================================================
59 // OGridControlModel
60 //==================================================================
61 typedef ::cppu::ImplHelper7 <	::com::sun::star::awt::XControlModel
62 							,	::com::sun::star::form::XGridColumnFactory
63 							,	::com::sun::star::form::XReset
64 							,	::com::sun::star::view::XSelectionSupplier
65 							,	::com::sun::star::sdb::XSQLErrorListener
66                             ,   ::com::sun::star::sdb::XRowSetSupplier
67                             ,   ::com::sun::star::sdb::XRowSetChangeBroadcaster
68 							>	OGridControlModel_BASE;
69 
70 class OGridControlModel :public OControlModel
71 						,public OInterfaceContainer
72 						,public OErrorBroadcaster
73                         ,public FontControlModel
74 						,public OGridControlModel_BASE
75 {
76 	::cppu::OInterfaceContainerHelper		m_aSelectListeners,
77 											m_aResetListeners,
78                                             m_aRowSetChangeListeners;
79 
80 // [properties]
81 	::com::sun::star::uno::Any				m_aRowHeight;			// Zeilenhoehe
82 	::com::sun::star::uno::Any				m_aTabStop;
83 	::com::sun::star::uno::Any				m_aBackgroundColor;
84 	::com::sun::star::uno::Any				m_aCursorColor; 			// transient
85     ::com::sun::star::uno::Any              m_aBorderColor;
86 	::rtl::OUString 						m_aDefaultControl;
87 	::rtl::OUString 						m_sHelpText;
88 // [properties]
89 
90 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >		m_xSelection;
91 
92 // [properties]
93 	::rtl::OUString 			m_sHelpURL; 				// URL
94 	sal_Int16					m_nBorder;
95     sal_Int16                   m_nWritingMode;
96     sal_Int16                   m_nContextWritingMode;
97 	sal_Bool					m_bEnableVisible	: 1;
98 	sal_Bool					m_bEnable			: 1;
99 	sal_Bool					m_bNavigation		: 1;
100 	sal_Bool					m_bRecordMarker 	: 1;
101 	sal_Bool					m_bPrintable		: 1;
102 	sal_Bool					m_bAlwaysShowCursor : 1;    // transient
103 	sal_Bool					m_bDisplaySynchron	: 1;    // transient
104 // [properties]
105 
106 protected:
107 	void _reset();
108 
109 public:
110 	DECLARE_DEFAULT_LEAF_XTOR( OGridControlModel );
111 
112     // UNO Anbindung
113 	DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OControlModel);
114 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
115 
116     // XChild
117 	virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
118 
119     // XServiceInfo
120 	IMPLEMENTATION_NAME(OGridControlModel);
121 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
122 
123     // XTypeProvider
124     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
125 
126     // OComponentHelper
127 	virtual void SAL_CALL disposing();
128 
129     // XEventListener
130 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
131 
132     // XReset
133 	virtual void SAL_CALL reset() throw ( ::com::sun::star::uno::RuntimeException);
134 	virtual void SAL_CALL addResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
135 	virtual void SAL_CALL removeResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
136 
137     // XSelectionSupplier
138 	virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& aElement) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
139 	virtual ::com::sun::star::uno::Any SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
140 	virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
141 	virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
142 
143     // XGridColumnFactory
144 	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);
145 	virtual StringSequence SAL_CALL getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException);
146 
147     // XPersistObject
148 	virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
149 	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);
150 	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);
151 
152     // XPropertySet
153 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
154 	virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
155 										  sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
156 										throw(::com::sun::star::lang::IllegalArgumentException);
157 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
158 
159     // XPropertyState
160 	virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
161 
162     // XSQLErrorListener
163 	virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
164 
165     // XRowSetSupplier
166     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet(  ) throw (::com::sun::star::uno::RuntimeException);
167     virtual void SAL_CALL setRowSet( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource ) throw (::com::sun::star::uno::RuntimeException);
168 
169     // XRowSetChangeBroadcaster
170     virtual void SAL_CALL addRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException);
171     virtual void SAL_CALL removeRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException);
172 
173     // OControlModel's property handling
174 	virtual void describeFixedProperties(
175 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
176     ) const;
177 
178     // prevent method hiding
179     using OControlModel::disposing;
180     using OControlModel::getFastPropertyValue;
181 
182 protected:
183 	DECLARE_XCLONEABLE();
184 
185 protected:
186 	virtual void approveNewElement(
187 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject,
188 			ElementDescription* _pElement
189 		);
190 
191 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>  createColumn(sal_Int32 nTypeId) const;
192 
193 	OGridColumn* getColumnImplementation(const InterfaceRef& _rxIFace) const;
194 
195 	virtual ElementDescription* createElementMetaData( );
196 
197 protected:
198 	virtual void implRemoved(const InterfaceRef& _rxObject);
199 	virtual void implInserted( const ElementDescription* _pElement );
200 	virtual void impl_replacedElement(
201                     const ::com::sun::star::container::ContainerEvent& _rEvent,
202                     ::osl::ClearableMutexGuard& _rInstanceLock
203                 );
204 
205 	void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn);
206 	void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn);
207 
208 	void cloneColumns( const OGridControlModel* _pOriginalContainer );
209 };
210 
211 //.........................................................................
212 }	// namespace frm
213 //.........................................................................
214 
215 
216