xref: /aoo42x/main/forms/source/component/Columns.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 #ifndef _FRM_COLUMNS_HXX
29 #define _FRM_COLUMNS_HXX
30 
31 #include "cloneable.hxx"
32 #include "frm_strings.hxx"
33 
34 /** === begin UNO includes === **/
35 #include <com/sun/star/io/XObjectInputStream.hpp>
36 #include <com/sun/star/io/XObjectOutputStream.hpp>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/util/XCloneable.hpp>
39 /** === end UNO includes === **/
40 
41 #include <comphelper/broadcasthelper.hxx>
42 #include <comphelper/componentcontext.hxx>
43 #include <comphelper/propagg.hxx>
44 #include <comphelper/proparrhlp.hxx>
45 #include <comphelper/uno3.hxx>
46 #include <cppuhelper/compbase2.hxx>
47 #include <cppuhelper/component.hxx>
48 
49 using namespace comphelper;
50 
51 //.........................................................................
52 namespace frm
53 {
54 //.........................................................................
55 
56 //==================================================================
57 // OGridColumn
58 //==================================================================
59 typedef ::cppu::WeakAggComponentImplHelper2 <   ::com::sun::star::lang::XUnoTunnel
60                                             ,   ::com::sun::star::util::XCloneable > OGridColumn_BASE;
61 class OGridColumn	:public ::comphelper::OBaseMutex
62 					,public OGridColumn_BASE
63 					,public OPropertySetAggregationHelper
64 					,public OCloneableAggregation
65 {
66 protected:
67 // [properties]
68 	::com::sun::star::uno::Any	m_aWidth;					// column width
69 	::com::sun::star::uno::Any	m_aAlign;					// column alignment
70 	::com::sun::star::uno::Any	m_aHidden;					// column hidden?
71 // [properties]
72 
73     ::comphelper::ComponentContext  m_aContext;
74 	::rtl::OUString				    m_aModelName;
75 
76 // [properties]
77 	::rtl::OUString				m_aLabel;					// Name der Spalte
78 // [properties]
79 
80 public:
81 	OGridColumn(const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName = ::rtl::OUString());
82 	OGridColumn(const OGridColumn* _pOriginal );
83 	virtual ~OGridColumn();
84 
85 	// UNO Anbindung
86 	DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OGridColumn_BASE);
87 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
88 
89 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
90 	// XUnoTunnel
91     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<sal_Int8>& _rIdentifier) throw(::com::sun::star::uno::RuntimeException);
92 
93     // XTypeProvider
94 	virtual ::com::sun::star::uno::Sequence<sal_Int8>			SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
95     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type>	SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
96 
97     // OComponentHelper
98 	virtual void SAL_CALL disposing();
99 
100     // XEventListener
101 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
102 
103     // XPersistObject
104 	virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
105 	virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
106 
107     // XPropertySet
108 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() = 0;
109 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
110 	virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
111 										  sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
112 										throw(::com::sun::star::lang::IllegalArgumentException);
113 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
114 
115     using OPropertySetAggregationHelper::getFastPropertyValue;
116 
117     // ::com::sun::star::beans::XPropertyState
118 	virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
119 
120     // XCloneable
121 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone(  ) throw (::com::sun::star::uno::RuntimeException);
122 
123     const ::rtl::OUString& getModelName() const { return m_aModelName; }
124 
125 protected:
126 	static void clearAggregateProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps, sal_Bool bAllowDropDown);
127 	static void setOwnProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps);
128 
129     virtual OGridColumn* createCloneColumn() const = 0;
130 };
131 
132 #define DECL_COLUMN(ClassName)										                                        \
133 class ClassName														                                        \
134     :public OGridColumn												                                        \
135     ,public OAggregationArrayUsageHelper< ClassName >				                                        \
136 {																	                                        \
137 public:																                                        \
138     ClassName(const ::comphelper::ComponentContext& _rContext );                                            \
139     ClassName(const ClassName* _pCloneFrom);                                                                \
140                                                                                                             \
141     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);	\
142     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();	                                        \
143                                                                                                             \
144     virtual void fillProperties(	                                                                        \
145         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps,	        \
146         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps	\
147         ) const;	                                                                                        \
148                                                                                                             \
149     virtual OGridColumn* createCloneColumn() const;                                                         \
150 };
151 
152 
153 #define IMPL_COLUMN(ClassName, Model, bAllowDropDown)								\
154     ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \
155 	:OGridColumn(_rContext, Model) \
156 { \
157 } \
158 ClassName::ClassName( const ClassName* _pCloneFrom ) \
159     :OGridColumn( _pCloneFrom ) \
160 { \
161 } \
162 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo>  ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException) \
163 { \
164 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo>  xInfo( createPropertySetInfo( getInfoHelper() ) ); \
165 	return xInfo; \
166 } \
167 ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
168 { \
169 	return *const_cast<ClassName*>(this)->getArrayHelper(); \
170 } \
171 void ClassName::fillProperties( \
172 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
173 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
174 	) const \
175 { \
176 	if (m_xAggregateSet.is()) \
177 	{ \
178 		_rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
179 		clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
180 		setOwnProperties(_rProps); \
181 	} \
182 } \
183 OGridColumn* ClassName::createCloneColumn() const \
184 { \
185     return new ClassName( this ); \
186 } \
187  \
188 // column type ids
189 #define TYPE_CHECKBOX		0
190 #define TYPE_COMBOBOX		1
191 #define TYPE_CURRENCYFIELD  2
192 #define TYPE_DATEFIELD		3
193 #define TYPE_FORMATTEDFIELD	4
194 #define TYPE_LISTBOX		5
195 #define TYPE_NUMERICFIELD	6
196 #define TYPE_PATTERNFIELD	7
197 #define TYPE_TEXTFIELD		8
198 #define TYPE_TIMEFIELD		9
199 
200 // liste aller bekannten columns
201 const StringSequence& getColumnTypes();
202 sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName);
203 
204 // Columns
205 DECL_COLUMN(TextFieldColumn)
206 DECL_COLUMN(PatternFieldColumn)
207 DECL_COLUMN(DateFieldColumn)
208 DECL_COLUMN(TimeFieldColumn)
209 DECL_COLUMN(NumericFieldColumn)
210 DECL_COLUMN(CurrencyFieldColumn)
211 DECL_COLUMN(CheckBoxColumn)
212 DECL_COLUMN(ComboBoxColumn)
213 DECL_COLUMN(ListBoxColumn)
214 DECL_COLUMN(FormattedFieldColumn)
215 
216 #endif // _FRM_COLUMNS_HXX
217 
218 //.........................................................................
219 }	// namespace frm
220 //.........................................................................
221 
222