1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Columns.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FRM_COLUMNS_HXX
32 #define _FRM_COLUMNS_HXX
34 #include "cloneable.hxx"
35 #include "frm_strings.hxx"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/io/XObjectInputStream.hpp>
39 #include <com/sun/star/io/XObjectOutputStream.hpp>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <com/sun/star/util/XCloneable.hpp>
42 /** === end UNO includes === **/
44 #include <comphelper/broadcasthelper.hxx>
45 #include <comphelper/componentcontext.hxx>
46 #include <comphelper/propagg.hxx>
47 #include <comphelper/proparrhlp.hxx>
48 #include <comphelper/uno3.hxx>
49 #include <cppuhelper/compbase2.hxx>
50 #include <cppuhelper/component.hxx>
52 using namespace comphelper
;
54 //.........................................................................
57 //.........................................................................
59 //==================================================================
61 //==================================================================
62 typedef ::cppu::WeakAggComponentImplHelper2
< ::com::sun::star::lang::XUnoTunnel
63 , ::com::sun::star::util::XCloneable
> OGridColumn_BASE
;
64 class OGridColumn
:public ::comphelper::OBaseMutex
65 ,public OGridColumn_BASE
66 ,public OPropertySetAggregationHelper
67 ,public OCloneableAggregation
71 ::com::sun::star::uno::Any m_aWidth
; // column width
72 ::com::sun::star::uno::Any m_aAlign
; // column alignment
73 ::com::sun::star::uno::Any m_aHidden
; // column hidden?
76 ::comphelper::ComponentContext m_aContext
;
77 ::rtl::OUString m_aModelName
;
80 ::rtl::OUString m_aLabel
; // Name der Spalte
84 OGridColumn(const ::comphelper::ComponentContext
& _rContext
, const ::rtl::OUString
& _sModelName
= ::rtl::OUString());
85 OGridColumn(const OGridColumn
* _pOriginal
);
86 virtual ~OGridColumn();
89 DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel
, OGridColumn_BASE
);
90 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
92 static const ::com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelImplementationId();
94 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<sal_Int8
>& _rIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
97 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId() throw(::com::sun::star::uno::RuntimeException
);
98 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes() throw(::com::sun::star::uno::RuntimeException
);
101 virtual void SAL_CALL
disposing();
104 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
107 virtual void SAL_CALL
write(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
);
108 virtual void SAL_CALL
read(const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
);
111 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() = 0;
112 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
113 virtual sal_Bool SAL_CALL
convertFastPropertyValue(::com::sun::star::uno::Any
& rConvertedValue
, ::com::sun::star::uno::Any
& rOldValue
,
114 sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
115 throw(::com::sun::star::lang::IllegalArgumentException
);
116 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
);
118 using OPropertySetAggregationHelper::getFastPropertyValue
;
120 // ::com::sun::star::beans::XPropertyState
121 virtual ::com::sun::star::uno::Any
getPropertyDefaultByHandle( sal_Int32 nHandle
) const;
124 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
> SAL_CALL
createClone( ) throw (::com::sun::star::uno::RuntimeException
);
126 const ::rtl::OUString
& getModelName() const { return m_aModelName
; }
129 static void clearAggregateProperties(::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& seqProps
, sal_Bool bAllowDropDown
);
130 static void setOwnProperties(::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& seqProps
);
132 virtual OGridColumn
* createCloneColumn() const = 0;
135 #define DECL_COLUMN(ClassName) \
137 :public OGridColumn \
138 ,public OAggregationArrayUsageHelper< ClassName > \
141 ClassName(const ::comphelper::ComponentContext& _rContext ); \
142 ClassName(const ClassName* _pCloneFrom); \
144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); \
145 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \
147 virtual void fillProperties( \
148 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
149 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
152 virtual OGridColumn* createCloneColumn() const; \
156 #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \
157 ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \
158 :OGridColumn(_rContext, Model) \
161 ClassName::ClassName( const ClassName* _pCloneFrom ) \
162 :OGridColumn( _pCloneFrom ) \
165 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> ClassName::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException) \
167 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \
170 ::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \
172 return *const_cast<ClassName*>(this)->getArrayHelper(); \
174 void ClassName::fillProperties( \
175 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \
176 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \
179 if (m_xAggregateSet.is()) \
181 _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \
182 clearAggregateProperties(_rAggregateProps, bAllowDropDown); \
183 setOwnProperties(_rProps); \
186 OGridColumn* ClassName::createCloneColumn() const \
188 return new ClassName( this ); \
192 #define TYPE_CHECKBOX 0
193 #define TYPE_COMBOBOX 1
194 #define TYPE_CURRENCYFIELD 2
195 #define TYPE_DATEFIELD 3
196 #define TYPE_FORMATTEDFIELD 4
197 #define TYPE_LISTBOX 5
198 #define TYPE_NUMERICFIELD 6
199 #define TYPE_PATTERNFIELD 7
200 #define TYPE_TEXTFIELD 8
201 #define TYPE_TIMEFIELD 9
203 // liste aller bekannten columns
204 const StringSequence
& getColumnTypes();
205 sal_Int32
getColumnTypeByModelName(const ::rtl::OUString
& aModelName
);
208 DECL_COLUMN(TextFieldColumn
)
209 DECL_COLUMN(PatternFieldColumn
)
210 DECL_COLUMN(DateFieldColumn
)
211 DECL_COLUMN(TimeFieldColumn
)
212 DECL_COLUMN(NumericFieldColumn
)
213 DECL_COLUMN(CurrencyFieldColumn
)
214 DECL_COLUMN(CheckBoxColumn
)
215 DECL_COLUMN(ComboBoxColumn
)
216 DECL_COLUMN(ListBoxColumn
)
217 DECL_COLUMN(FormattedFieldColumn
)
219 #endif // _FRM_COLUMNS_HXX
221 //.........................................................................
223 //.........................................................................