update credits
[LibreOffice.git] / forms / source / component / Columns.hxx
blobed2a1054d82fefb55753ca07d57030e72e7493a4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _FRM_COLUMNS_HXX
21 #define _FRM_COLUMNS_HXX
23 #include "cloneable.hxx"
24 #include "frm_strings.hxx"
26 #include <com/sun/star/io/XObjectInputStream.hpp>
27 #include <com/sun/star/io/XObjectOutputStream.hpp>
28 #include <com/sun/star/lang/XUnoTunnel.hpp>
29 #include <com/sun/star/util/XCloneable.hpp>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <comphelper/componentcontext.hxx>
33 #include <comphelper/propagg.hxx>
34 #include <comphelper/proparrhlp.hxx>
35 #include <comphelper/uno3.hxx>
36 #include <cppuhelper/compbase2.hxx>
37 #include <cppuhelper/component.hxx>
39 using namespace comphelper;
41 //.........................................................................
42 namespace frm
44 //.........................................................................
46 //==================================================================
47 // OGridColumn
48 //==================================================================
49 typedef ::cppu::WeakAggComponentImplHelper2 < ::com::sun::star::lang::XUnoTunnel
50 , ::com::sun::star::util::XCloneable > OGridColumn_BASE;
51 class OGridColumn :public ::comphelper::OBaseMutex
52 ,public OGridColumn_BASE
53 ,public OPropertySetAggregationHelper
54 ,public OCloneableAggregation
56 protected:
57 // [properties]
58 ::com::sun::star::uno::Any m_aWidth; // column width
59 ::com::sun::star::uno::Any m_aAlign; // column alignment
60 ::com::sun::star::uno::Any m_aHidden; // column hidden?
61 // [properties]
63 ::comphelper::ComponentContext m_aContext;
64 OUString m_aModelName;
66 // [properties]
67 OUString m_aLabel; // Column name
68 // [properties]
70 public:
71 OGridColumn(const ::comphelper::ComponentContext& _rContext, const OUString& _sModelName = OUString());
72 OGridColumn(const OGridColumn* _pOriginal );
73 virtual ~OGridColumn();
75 // UNO binding
76 DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OGridColumn_BASE);
77 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
79 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
80 // XUnoTunnel
81 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<sal_Int8>& _rIdentifier) throw(::com::sun::star::uno::RuntimeException);
83 // XTypeProvider
84 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
85 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
87 // OComponentHelper
88 virtual void SAL_CALL disposing();
90 // XEventListener
91 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
93 // XPersistObject
94 virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
95 virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
97 // XPropertySet
98 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() = 0;
99 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
100 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
101 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
102 throw(::com::sun::star::lang::IllegalArgumentException);
103 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
105 using OPropertySetAggregationHelper::getFastPropertyValue;
107 // ::com::sun::star::beans::XPropertyState
108 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
110 // XCloneable
111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException);
113 const OUString& getModelName() const { return m_aModelName; }
115 protected:
116 static void clearAggregateProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps, sal_Bool bAllowDropDown);
117 static void setOwnProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps);
119 virtual OGridColumn* createCloneColumn() const = 0;
122 #define DECL_COLUMN(ClassName) \
123 class ClassName \
124 :public OGridColumn \
125 ,public OAggregationArrayUsageHelper< ClassName > \
127 public: \
128 ClassName(const ::comphelper::ComponentContext& _rContext ); \
129 ClassName(const ClassName* _pCloneFrom); \
131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); \
132 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \
134 virtual void fillProperties( \
135 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
136 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
137 ) const; \
139 virtual OGridColumn* createCloneColumn() const; \
143 #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \
144 ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \
145 :OGridColumn(_rContext, Model) \
148 ClassName::ClassName( const ClassName* _pCloneFrom ) \
149 :OGridColumn( _pCloneFrom ) \
152 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException) \
154 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \
155 return xInfo; \
157 ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
159 return *const_cast<ClassName*>(this)->getArrayHelper(); \
161 void ClassName::fillProperties( \
162 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
163 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
164 ) const \
166 if (m_xAggregateSet.is()) \
168 _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
169 clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
170 setOwnProperties(_rProps); \
173 OGridColumn* ClassName::createCloneColumn() const \
175 return new ClassName( this ); \
178 // column type ids
179 #define TYPE_CHECKBOX 0
180 #define TYPE_COMBOBOX 1
181 #define TYPE_CURRENCYFIELD 2
182 #define TYPE_DATEFIELD 3
183 #define TYPE_FORMATTEDFIELD 4
184 #define TYPE_LISTBOX 5
185 #define TYPE_NUMERICFIELD 6
186 #define TYPE_PATTERNFIELD 7
187 #define TYPE_TEXTFIELD 8
188 #define TYPE_TIMEFIELD 9
190 // List of all known columns
191 const StringSequence& getColumnTypes();
192 sal_Int32 getColumnTypeByModelName(const OUString& aModelName);
194 // Columns
195 DECL_COLUMN(TextFieldColumn)
196 DECL_COLUMN(PatternFieldColumn)
197 DECL_COLUMN(DateFieldColumn)
198 DECL_COLUMN(TimeFieldColumn)
199 DECL_COLUMN(NumericFieldColumn)
200 DECL_COLUMN(CurrencyFieldColumn)
201 DECL_COLUMN(CheckBoxColumn)
202 DECL_COLUMN(ComboBoxColumn)
203 DECL_COLUMN(ListBoxColumn)
204 DECL_COLUMN(FormattedFieldColumn)
206 #endif // _FRM_COLUMNS_HXX
208 //.........................................................................
209 } // namespace frm
210 //.........................................................................
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */