bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / component / Columns.hxx
blobecfa7899c7fded74a72a108ff885403e053d5173
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 INCLUDED_FORMS_SOURCE_COMPONENT_COLUMNS_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_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/propagg.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <cppuhelper/compbase2.hxx>
36 #include <cppuhelper/component.hxx>
38 using namespace comphelper;
41 namespace frm
44 typedef ::cppu::WeakAggComponentImplHelper2 < ::com::sun::star::lang::XUnoTunnel
45 , ::com::sun::star::util::XCloneable > OGridColumn_BASE;
46 class OGridColumn :public ::comphelper::OBaseMutex
47 ,public OGridColumn_BASE
48 ,public OPropertySetAggregationHelper
49 ,public OCloneableAggregation
51 protected:
52 // [properties]
53 ::com::sun::star::uno::Any m_aWidth; // column width
54 ::com::sun::star::uno::Any m_aAlign; // column alignment
55 ::com::sun::star::uno::Any m_aHidden; // column hidden?
56 // [properties]
58 OUString m_aModelName;
60 // [properties]
61 OUString m_aLabel; // Column name
62 // [properties]
64 public:
65 OGridColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext, const OUString& _sModelName = OUString());
66 OGridColumn(const OGridColumn* _pOriginal );
67 virtual ~OGridColumn();
69 // UNO binding
70 DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OGridColumn_BASE)
71 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
74 // XUnoTunnel
75 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<sal_Int8>& _rIdentifier) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 // XTypeProvider
78 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
81 // OComponentHelper
82 virtual void SAL_CALL disposing() SAL_OVERRIDE;
84 // XEventListener
85 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 // XPersistObject
88 void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
89 void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
91 // XPropertySet
92 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE = 0;
93 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
94 virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
95 sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
96 throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
97 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
99 using OPropertySetAggregationHelper::getFastPropertyValue;
101 // ::com::sun::star::beans::XPropertyState
102 virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const SAL_OVERRIDE;
104 // XCloneable
105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 const OUString& getModelName() const { return m_aModelName; }
109 protected:
110 static void clearAggregateProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps, bool bAllowDropDown);
111 static void setOwnProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps);
113 virtual OGridColumn* createCloneColumn() const = 0;
116 #define DECL_COLUMN(ClassName) \
117 class ClassName \
118 :public OGridColumn \
119 ,public OAggregationArrayUsageHelper< ClassName > \
121 public: \
122 ClassName(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); \
123 ClassName(const ClassName* _pCloneFrom); \
125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; \
126 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE; \
128 virtual void fillProperties( \
129 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
130 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
131 ) const SAL_OVERRIDE; \
133 virtual OGridColumn* createCloneColumn() const SAL_OVERRIDE; \
137 #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \
138 ClassName::ClassName( const css::uno::Reference<css::uno::XComponentContext>& _rContext ) \
139 :OGridColumn(_rContext, Model) \
142 ClassName::ClassName( const ClassName* _pCloneFrom ) \
143 :OGridColumn( _pCloneFrom ) \
146 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) \
148 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \
149 return xInfo; \
151 ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
153 return *getArrayHelper(); \
155 void ClassName::fillProperties( \
156 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
157 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
158 ) const \
160 if (m_xAggregateSet.is()) \
162 _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
163 clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
164 setOwnProperties(_rProps); \
167 OGridColumn* ClassName::createCloneColumn() const \
169 return new ClassName( this ); \
172 // column type ids
173 #define TYPE_CHECKBOX 0
174 #define TYPE_COMBOBOX 1
175 #define TYPE_CURRENCYFIELD 2
176 #define TYPE_DATEFIELD 3
177 #define TYPE_FORMATTEDFIELD 4
178 #define TYPE_LISTBOX 5
179 #define TYPE_NUMERICFIELD 6
180 #define TYPE_PATTERNFIELD 7
181 #define TYPE_TEXTFIELD 8
182 #define TYPE_TIMEFIELD 9
184 // List of all known columns
185 const StringSequence& getColumnTypes();
186 sal_Int32 getColumnTypeByModelName(const OUString& aModelName);
188 // Columns
189 DECL_COLUMN(TextFieldColumn)
190 DECL_COLUMN(PatternFieldColumn)
191 DECL_COLUMN(DateFieldColumn)
192 DECL_COLUMN(TimeFieldColumn)
193 DECL_COLUMN(NumericFieldColumn)
194 DECL_COLUMN(CurrencyFieldColumn)
195 DECL_COLUMN(CheckBoxColumn)
196 DECL_COLUMN(ComboBoxColumn)
197 DECL_COLUMN(ListBoxColumn)
198 DECL_COLUMN(FormattedFieldColumn)
200 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COLUMNS_HXX
203 } // namespace frm
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */