Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_COLUMNS_HXX
21 : #define INCLUDED_FORMS_SOURCE_COMPONENT_COLUMNS_HXX
22 :
23 : #include "cloneable.hxx"
24 : #include "frm_strings.hxx"
25 :
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>
30 :
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>
37 :
38 : using namespace comphelper;
39 :
40 :
41 : namespace frm
42 : {
43 :
44 :
45 :
46 : // OGridColumn
47 :
48 : typedef ::cppu::WeakAggComponentImplHelper2 < ::com::sun::star::lang::XUnoTunnel
49 : , ::com::sun::star::util::XCloneable > OGridColumn_BASE;
50 : class OGridColumn :public ::comphelper::OBaseMutex
51 : ,public OGridColumn_BASE
52 : ,public OPropertySetAggregationHelper
53 : ,public OCloneableAggregation
54 : {
55 : protected:
56 : // [properties]
57 : ::com::sun::star::uno::Any m_aWidth; // column width
58 : ::com::sun::star::uno::Any m_aAlign; // column alignment
59 : ::com::sun::star::uno::Any m_aHidden; // column hidden?
60 : // [properties]
61 :
62 : OUString m_aModelName;
63 :
64 : // [properties]
65 : OUString m_aLabel; // Column name
66 : // [properties]
67 :
68 : public:
69 : OGridColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext, const OUString& _sModelName = OUString());
70 : OGridColumn(const OGridColumn* _pOriginal );
71 : virtual ~OGridColumn();
72 :
73 : // UNO binding
74 0 : DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OGridColumn_BASE)
75 : 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;
76 :
77 : static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelImplementationId();
78 : // XUnoTunnel
79 : 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;
80 :
81 : // XTypeProvider
82 : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 :
85 : // OComponentHelper
86 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
87 :
88 : // XEventListener
89 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 :
91 : // XPersistObject
92 : virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
93 : virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
94 :
95 : // XPropertySet
96 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE = 0;
97 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
98 : virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
99 : sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
100 : throw(::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
101 : 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;
102 :
103 : using OPropertySetAggregationHelper::getFastPropertyValue;
104 :
105 : // ::com::sun::star::beans::XPropertyState
106 : virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const SAL_OVERRIDE;
107 :
108 : // XCloneable
109 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 0 : const OUString& getModelName() const { return m_aModelName; }
112 :
113 : protected:
114 : static void clearAggregateProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps, sal_Bool bAllowDropDown);
115 : static void setOwnProperties(::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property>& seqProps);
116 :
117 : virtual OGridColumn* createCloneColumn() const = 0;
118 : };
119 :
120 : #define DECL_COLUMN(ClassName) \
121 : class ClassName \
122 : :public OGridColumn \
123 : ,public OAggregationArrayUsageHelper< ClassName > \
124 : { \
125 : public: \
126 : ClassName(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); \
127 : ClassName(const ClassName* _pCloneFrom); \
128 : \
129 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; \
130 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE; \
131 : \
132 : virtual void fillProperties( \
133 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
134 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
135 : ) const SAL_OVERRIDE; \
136 : \
137 : virtual OGridColumn* createCloneColumn() const SAL_OVERRIDE; \
138 : };
139 :
140 :
141 : #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \
142 : ClassName::ClassName( const css::uno::Reference<css::uno::XComponentContext>& _rContext ) \
143 : :OGridColumn(_rContext, Model) \
144 : { \
145 : } \
146 : ClassName::ClassName( const ClassName* _pCloneFrom ) \
147 : :OGridColumn( _pCloneFrom ) \
148 : { \
149 : } \
150 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) \
151 : { \
152 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \
153 : return xInfo; \
154 : } \
155 : ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
156 : { \
157 : return *const_cast<ClassName*>(this)->getArrayHelper(); \
158 : } \
159 : void ClassName::fillProperties( \
160 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
161 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
162 : ) const \
163 : { \
164 : if (m_xAggregateSet.is()) \
165 : { \
166 : _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
167 : clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
168 : setOwnProperties(_rProps); \
169 : } \
170 : } \
171 : OGridColumn* ClassName::createCloneColumn() const \
172 : { \
173 : return new ClassName( this ); \
174 : } \
175 : \
176 : // column type ids
177 : #define TYPE_CHECKBOX 0
178 : #define TYPE_COMBOBOX 1
179 : #define TYPE_CURRENCYFIELD 2
180 : #define TYPE_DATEFIELD 3
181 : #define TYPE_FORMATTEDFIELD 4
182 : #define TYPE_LISTBOX 5
183 : #define TYPE_NUMERICFIELD 6
184 : #define TYPE_PATTERNFIELD 7
185 : #define TYPE_TEXTFIELD 8
186 : #define TYPE_TIMEFIELD 9
187 :
188 : // List of all known columns
189 : const StringSequence& getColumnTypes();
190 : sal_Int32 getColumnTypeByModelName(const OUString& aModelName);
191 :
192 : // Columns
193 0 : DECL_COLUMN(TextFieldColumn)
194 0 : DECL_COLUMN(PatternFieldColumn)
195 0 : DECL_COLUMN(DateFieldColumn)
196 0 : DECL_COLUMN(TimeFieldColumn)
197 0 : DECL_COLUMN(NumericFieldColumn)
198 0 : DECL_COLUMN(CurrencyFieldColumn)
199 0 : DECL_COLUMN(CheckBoxColumn)
200 0 : DECL_COLUMN(ComboBoxColumn)
201 0 : DECL_COLUMN(ListBoxColumn)
202 0 : DECL_COLUMN(FormattedFieldColumn)
203 :
204 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COLUMNS_HXX
205 :
206 :
207 : } // namespace frm
208 :
209 :
210 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|