xref: /aoo42x/main/forms/source/component/Columns.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _FRM_COLUMNS_HXX
29*cdf0e10cSrcweir #define _FRM_COLUMNS_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "cloneable.hxx"
32*cdf0e10cSrcweir #include "frm_strings.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /** === begin UNO includes === **/
35*cdf0e10cSrcweir #include <com/sun/star/io/XObjectInputStream.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/io/XObjectOutputStream.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp>
39*cdf0e10cSrcweir /** === end UNO includes === **/
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
42*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
43*cdf0e10cSrcweir #include <comphelper/propagg.hxx>
44*cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
45*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
46*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
47*cdf0e10cSrcweir #include <cppuhelper/component.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir using namespace comphelper;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //.........................................................................
52*cdf0e10cSrcweir namespace frm
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir //.........................................................................
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //==================================================================
57*cdf0e10cSrcweir // OGridColumn
58*cdf0e10cSrcweir //==================================================================
59*cdf0e10cSrcweir typedef ::cppu::WeakAggComponentImplHelper2 <   ::com::sun::star::lang::XUnoTunnel
60*cdf0e10cSrcweir                                             ,   ::com::sun::star::util::XCloneable > OGridColumn_BASE;
61*cdf0e10cSrcweir class OGridColumn	:public ::comphelper::OBaseMutex
62*cdf0e10cSrcweir 					,public OGridColumn_BASE
63*cdf0e10cSrcweir 					,public OPropertySetAggregationHelper
64*cdf0e10cSrcweir 					,public OCloneableAggregation
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir protected:
67*cdf0e10cSrcweir // [properties]
68*cdf0e10cSrcweir 	::com::sun::star::uno::Any	m_aWidth;					// column width
69*cdf0e10cSrcweir 	::com::sun::star::uno::Any	m_aAlign;					// column alignment
70*cdf0e10cSrcweir 	::com::sun::star::uno::Any	m_aHidden;					// column hidden?
71*cdf0e10cSrcweir // [properties]
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     ::comphelper::ComponentContext  m_aContext;
74*cdf0e10cSrcweir 	::rtl::OUString				    m_aModelName;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir // [properties]
77*cdf0e10cSrcweir 	::rtl::OUString				m_aLabel;					// Name der Spalte
78*cdf0e10cSrcweir // [properties]
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir public:
81*cdf0e10cSrcweir 	OGridColumn(const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName = ::rtl::OUString());
82*cdf0e10cSrcweir 	OGridColumn(const OGridColumn* _pOriginal );
83*cdf0e10cSrcweir 	virtual ~OGridColumn();
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	// UNO Anbindung
86*cdf0e10cSrcweir 	DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OGridColumn_BASE);
87*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
90*cdf0e10cSrcweir 	// XUnoTunnel
91*cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<sal_Int8>& _rIdentifier) throw(::com::sun::star::uno::RuntimeException);
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     // XTypeProvider
94*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence<sal_Int8>			SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
95*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type>	SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     // OComponentHelper
98*cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     // XEventListener
101*cdf0e10cSrcweir 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     // XPersistObject
104*cdf0e10cSrcweir 	virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
105*cdf0e10cSrcweir 	virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     // XPropertySet
108*cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() = 0;
109*cdf0e10cSrcweir 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
110*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
111*cdf0e10cSrcweir 										  sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
112*cdf0e10cSrcweir 										throw(::com::sun::star::lang::IllegalArgumentException);
113*cdf0e10cSrcweir 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     using OPropertySetAggregationHelper::getFastPropertyValue;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     // ::com::sun::star::beans::XPropertyState
118*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     // XCloneable
121*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone(  ) throw (::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     const ::rtl::OUString& getModelName() const { return m_aModelName; }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir protected:
126*cdf0e10cSrcweir 	static void clearAggregateProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps, sal_Bool bAllowDropDown);
127*cdf0e10cSrcweir 	static void setOwnProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps);
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     virtual OGridColumn* createCloneColumn() const = 0;
130*cdf0e10cSrcweir };
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir #define DECL_COLUMN(ClassName)										                                        \
133*cdf0e10cSrcweir class ClassName														                                        \
134*cdf0e10cSrcweir     :public OGridColumn												                                        \
135*cdf0e10cSrcweir     ,public OAggregationArrayUsageHelper< ClassName >				                                        \
136*cdf0e10cSrcweir {																	                                        \
137*cdf0e10cSrcweir public:																                                        \
138*cdf0e10cSrcweir     ClassName(const ::comphelper::ComponentContext& _rContext );                                            \
139*cdf0e10cSrcweir     ClassName(const ClassName* _pCloneFrom);                                                                \
140*cdf0e10cSrcweir                                                                                                             \
141*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);	\
142*cdf0e10cSrcweir     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();	                                        \
143*cdf0e10cSrcweir                                                                                                             \
144*cdf0e10cSrcweir     virtual void fillProperties(	                                                                        \
145*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps,	        \
146*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps	\
147*cdf0e10cSrcweir         ) const;	                                                                                        \
148*cdf0e10cSrcweir                                                                                                             \
149*cdf0e10cSrcweir     virtual OGridColumn* createCloneColumn() const;                                                         \
150*cdf0e10cSrcweir };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir #define IMPL_COLUMN(ClassName, Model, bAllowDropDown)								\
154*cdf0e10cSrcweir     ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \
155*cdf0e10cSrcweir 	:OGridColumn(_rContext, Model) \
156*cdf0e10cSrcweir { \
157*cdf0e10cSrcweir } \
158*cdf0e10cSrcweir ClassName::ClassName( const ClassName* _pCloneFrom ) \
159*cdf0e10cSrcweir     :OGridColumn( _pCloneFrom ) \
160*cdf0e10cSrcweir { \
161*cdf0e10cSrcweir } \
162*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo>  ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException) \
163*cdf0e10cSrcweir { \
164*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo>  xInfo( createPropertySetInfo( getInfoHelper() ) ); \
165*cdf0e10cSrcweir 	return xInfo; \
166*cdf0e10cSrcweir } \
167*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
168*cdf0e10cSrcweir { \
169*cdf0e10cSrcweir 	return *const_cast<ClassName*>(this)->getArrayHelper(); \
170*cdf0e10cSrcweir } \
171*cdf0e10cSrcweir void ClassName::fillProperties( \
172*cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
173*cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
174*cdf0e10cSrcweir 	) const \
175*cdf0e10cSrcweir { \
176*cdf0e10cSrcweir 	if (m_xAggregateSet.is()) \
177*cdf0e10cSrcweir 	{ \
178*cdf0e10cSrcweir 		_rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
179*cdf0e10cSrcweir 		clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
180*cdf0e10cSrcweir 		setOwnProperties(_rProps); \
181*cdf0e10cSrcweir 	} \
182*cdf0e10cSrcweir } \
183*cdf0e10cSrcweir OGridColumn* ClassName::createCloneColumn() const \
184*cdf0e10cSrcweir { \
185*cdf0e10cSrcweir     return new ClassName( this ); \
186*cdf0e10cSrcweir } \
187*cdf0e10cSrcweir  \
188*cdf0e10cSrcweir // column type ids
189*cdf0e10cSrcweir #define TYPE_CHECKBOX		0
190*cdf0e10cSrcweir #define TYPE_COMBOBOX		1
191*cdf0e10cSrcweir #define TYPE_CURRENCYFIELD  2
192*cdf0e10cSrcweir #define TYPE_DATEFIELD		3
193*cdf0e10cSrcweir #define TYPE_FORMATTEDFIELD	4
194*cdf0e10cSrcweir #define TYPE_LISTBOX		5
195*cdf0e10cSrcweir #define TYPE_NUMERICFIELD	6
196*cdf0e10cSrcweir #define TYPE_PATTERNFIELD	7
197*cdf0e10cSrcweir #define TYPE_TEXTFIELD		8
198*cdf0e10cSrcweir #define TYPE_TIMEFIELD		9
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir // liste aller bekannten columns
201*cdf0e10cSrcweir const StringSequence& getColumnTypes();
202*cdf0e10cSrcweir sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir // Columns
205*cdf0e10cSrcweir DECL_COLUMN(TextFieldColumn)
206*cdf0e10cSrcweir DECL_COLUMN(PatternFieldColumn)
207*cdf0e10cSrcweir DECL_COLUMN(DateFieldColumn)
208*cdf0e10cSrcweir DECL_COLUMN(TimeFieldColumn)
209*cdf0e10cSrcweir DECL_COLUMN(NumericFieldColumn)
210*cdf0e10cSrcweir DECL_COLUMN(CurrencyFieldColumn)
211*cdf0e10cSrcweir DECL_COLUMN(CheckBoxColumn)
212*cdf0e10cSrcweir DECL_COLUMN(ComboBoxColumn)
213*cdf0e10cSrcweir DECL_COLUMN(ListBoxColumn)
214*cdf0e10cSrcweir DECL_COLUMN(FormattedFieldColumn)
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir #endif // _FRM_COLUMNS_HXX
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir //.........................................................................
219*cdf0e10cSrcweir }	// namespace frm
220*cdf0e10cSrcweir //.........................................................................
221*cdf0e10cSrcweir 
222