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