xref: /aoo41x/main/forms/source/component/Columns.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_forms.hxx"
30*cdf0e10cSrcweir #include "Columns.hxx"
31*cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HRC_
32*cdf0e10cSrcweir #include "property.hrc"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include "property.hxx"
35*cdf0e10cSrcweir #include "componenttools.hxx"
36*cdf0e10cSrcweir #include "ids.hxx"
37*cdf0e10cSrcweir #include "findpos.hxx"
38*cdf0e10cSrcweir #include <com/sun/star/io/XPersistObject.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/io/XObjectOutputStream.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/io/XObjectInputStream.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/io/XMarkableStream.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/form/XFormComponent.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/form/binding/XBindableValue.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
47*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
48*cdf0e10cSrcweir #include <comphelper/property.hxx>
49*cdf0e10cSrcweir #include <comphelper/basicio.hxx>
50*cdf0e10cSrcweir #include <comphelper/types.hxx>
51*cdf0e10cSrcweir #include "services.hxx"
52*cdf0e10cSrcweir #ifndef _FRM_RESOURCE_HRC_
53*cdf0e10cSrcweir #include "frm_resource.hrc"
54*cdf0e10cSrcweir #endif
55*cdf0e10cSrcweir #include <tools/debug.hxx>
56*cdf0e10cSrcweir #include <rtl/uuid.h>
57*cdf0e10cSrcweir #include <rtl/memory.h>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir //.........................................................................
60*cdf0e10cSrcweir namespace frm
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir //.........................................................................
63*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
64*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
65*cdf0e10cSrcweir using namespace ::com::sun::star::container;
66*cdf0e10cSrcweir using namespace ::com::sun::star::form;
67*cdf0e10cSrcweir using namespace ::com::sun::star::awt;
68*cdf0e10cSrcweir using namespace ::com::sun::star::io;
69*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
70*cdf0e10cSrcweir using namespace ::com::sun::star::util;
71*cdf0e10cSrcweir using namespace ::com::sun::star::text;
72*cdf0e10cSrcweir using namespace ::com::sun::star::form::binding;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir const sal_uInt16 WIDTH              = 0x0001;
75*cdf0e10cSrcweir const sal_uInt16 ALIGN              = 0x0002;
76*cdf0e10cSrcweir const sal_uInt16 OLD_HIDDEN         = 0x0004;
77*cdf0e10cSrcweir const sal_uInt16 COMPATIBLE_HIDDEN  = 0x0008;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir //------------------------------------------------------------------------------
80*cdf0e10cSrcweir const StringSequence& getColumnTypes()
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     static StringSequence aColumnTypes(10);
83*cdf0e10cSrcweir     if (!aColumnTypes.getConstArray()[0].getLength())
84*cdf0e10cSrcweir     {
85*cdf0e10cSrcweir         ::rtl::OUString* pNames = aColumnTypes.getArray();
86*cdf0e10cSrcweir         pNames[TYPE_CHECKBOX]       = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckBox" ) );
87*cdf0e10cSrcweir         pNames[TYPE_COMBOBOX]       = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ComboBox" ) );
88*cdf0e10cSrcweir         pNames[TYPE_CURRENCYFIELD]  = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrencyField" ) );
89*cdf0e10cSrcweir         pNames[TYPE_DATEFIELD]      = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateField" ) );
90*cdf0e10cSrcweir         pNames[TYPE_FORMATTEDFIELD] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormattedField" ) );
91*cdf0e10cSrcweir         pNames[TYPE_LISTBOX]        = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListBox" ) );
92*cdf0e10cSrcweir         pNames[TYPE_NUMERICFIELD]   = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumericField" ) );
93*cdf0e10cSrcweir         pNames[TYPE_PATTERNFIELD]   = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PatternField" ) );
94*cdf0e10cSrcweir         pNames[TYPE_TEXTFIELD]      = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextField" ) );
95*cdf0e10cSrcweir         pNames[TYPE_TIMEFIELD]      = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeField" ) );
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir     return aColumnTypes;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir //------------------------------------------------------------------------------
101*cdf0e10cSrcweir sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName)
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     const ::rtl::OUString aModelPrefix = ::rtl::OUString::createFromAscii("com.sun.star.form.component.");
104*cdf0e10cSrcweir     const ::rtl::OUString aCompatibleModelPrefix = ::rtl::OUString::createFromAscii("stardiv.one.form.component.");
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     sal_Int32 nTypeId = -1;
107*cdf0e10cSrcweir     if (aModelName == FRM_COMPONENT_EDIT)
108*cdf0e10cSrcweir         nTypeId = TYPE_TEXTFIELD;
109*cdf0e10cSrcweir     else
110*cdf0e10cSrcweir     {
111*cdf0e10cSrcweir         sal_Int32 nPrefixPos = aModelName.indexOf(aModelPrefix);
112*cdf0e10cSrcweir #ifdef DBG_UTIL
113*cdf0e10cSrcweir         sal_Int32 nCompatiblePrefixPos = aModelName.indexOf(aCompatibleModelPrefix);
114*cdf0e10cSrcweir #endif
115*cdf0e10cSrcweir         DBG_ASSERT( (nPrefixPos != -1) ||   (nCompatiblePrefixPos != -1),
116*cdf0e10cSrcweir                 "::getColumnTypeByModelName() : wrong servivce !");
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         ::rtl::OUString aColumnType = (nPrefixPos != -1)
119*cdf0e10cSrcweir             ? aModelName.copy(aModelPrefix.getLength())
120*cdf0e10cSrcweir             : aModelName.copy(aCompatibleModelPrefix.getLength());
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         const StringSequence& rColumnTypes = getColumnTypes();
123*cdf0e10cSrcweir         nTypeId = ::detail::findPos(aColumnType, rColumnTypes);
124*cdf0e10cSrcweir     }
125*cdf0e10cSrcweir     return nTypeId;
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir /*************************************************************************/
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir //------------------------------------------------------------------
131*cdf0e10cSrcweir const Sequence<sal_Int8>& OGridColumn::getUnoTunnelImplementationId()
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     static Sequence< sal_Int8 > * pSeq = 0;
134*cdf0e10cSrcweir     if( !pSeq )
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
137*cdf0e10cSrcweir         if( !pSeq )
138*cdf0e10cSrcweir         {
139*cdf0e10cSrcweir             static Sequence< sal_Int8 > aSeq( 16 );
140*cdf0e10cSrcweir             rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
141*cdf0e10cSrcweir             pSeq = &aSeq;
142*cdf0e10cSrcweir         }
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir     return *pSeq;
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir //------------------------------------------------------------------
148*cdf0e10cSrcweir sal_Int64 SAL_CALL OGridColumn::getSomething( const Sequence<sal_Int8>& _rIdentifier) throw(RuntimeException)
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir     sal_Int64 nReturn(0);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     if  (   (_rIdentifier.getLength() == 16)
153*cdf0e10cSrcweir         &&  (0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
154*cdf0e10cSrcweir         )
155*cdf0e10cSrcweir     {
156*cdf0e10cSrcweir         nReturn = reinterpret_cast<sal_Int64>(this);
157*cdf0e10cSrcweir     }
158*cdf0e10cSrcweir     else
159*cdf0e10cSrcweir     {
160*cdf0e10cSrcweir         Reference< XUnoTunnel > xAggTunnel;
161*cdf0e10cSrcweir         if ( query_aggregation( m_xAggregate, xAggTunnel ) )
162*cdf0e10cSrcweir             return xAggTunnel->getSomething( _rIdentifier );
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir     return nReturn;
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir //------------------------------------------------------------------
168*cdf0e10cSrcweir Sequence<sal_Int8> SAL_CALL OGridColumn::getImplementationId() throw(RuntimeException)
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     return OImplementationIds::getImplementationId(getTypes());
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir //------------------------------------------------------------------
174*cdf0e10cSrcweir Sequence<Type> SAL_CALL OGridColumn::getTypes() throw(RuntimeException)
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     TypeBag aTypes( OGridColumn_BASE::getTypes() );
177*cdf0e10cSrcweir     // erase the types which we do not support
178*cdf0e10cSrcweir     aTypes.removeType( XFormComponent::static_type() );
179*cdf0e10cSrcweir     aTypes.removeType( XServiceInfo::static_type() );
180*cdf0e10cSrcweir     aTypes.removeType( XBindableValue::static_type() );
181*cdf0e10cSrcweir     aTypes.removeType( XPropertyContainer::static_type() );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     // but re-add their base class(es)
184*cdf0e10cSrcweir     aTypes.addType( XChild::static_type() );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     Reference< XTypeProvider > xProv;
187*cdf0e10cSrcweir     if ( query_aggregation( m_xAggregate, xProv ))
188*cdf0e10cSrcweir         aTypes.addTypes( xProv->getTypes() );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     aTypes.removeType( XTextRange::static_type() );
191*cdf0e10cSrcweir     aTypes.removeType( XSimpleText::static_type() );
192*cdf0e10cSrcweir     aTypes.removeType( XText::static_type() );
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     return aTypes.getTypes();
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir //------------------------------------------------------------------
198*cdf0e10cSrcweir Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) throw (RuntimeException)
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir     Any aReturn;
201*cdf0e10cSrcweir     // some functionality at our aggregate cannot be reasonably fullfilled here.
202*cdf0e10cSrcweir     if  (   _rType.equals(::getCppuType(static_cast< Reference< XFormComponent >* >(NULL)))
203*cdf0e10cSrcweir         ||  _rType.equals(::getCppuType(static_cast< Reference< XServiceInfo >* >(NULL)))
204*cdf0e10cSrcweir         ||  _rType.equals(::getCppuType(static_cast< Reference< XBindableValue >* >(NULL)))
205*cdf0e10cSrcweir         ||  _rType.equals(::getCppuType(static_cast< Reference< XPropertyContainer >* >(NULL)))
206*cdf0e10cSrcweir         ||  comphelper::isAssignableFrom(::getCppuType(static_cast< Reference< XTextRange >* >(NULL)),_rType)
207*cdf0e10cSrcweir         )
208*cdf0e10cSrcweir         return aReturn;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     aReturn = OGridColumn_BASE::queryAggregation(_rType);
211*cdf0e10cSrcweir     if (!aReturn.hasValue())
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir         aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
214*cdf0e10cSrcweir         if (!aReturn.hasValue() && m_xAggregate.is())
215*cdf0e10cSrcweir             aReturn = m_xAggregate->queryAggregation(_rType);
216*cdf0e10cSrcweir     }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     return aReturn;
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir DBG_NAME(OGridColumn);
222*cdf0e10cSrcweir //------------------------------------------------------------------------------
223*cdf0e10cSrcweir OGridColumn::OGridColumn( const comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName )
224*cdf0e10cSrcweir 	:OGridColumn_BASE(m_aMutex)
225*cdf0e10cSrcweir 	,OPropertySetAggregationHelper(OGridColumn_BASE::rBHelper)
226*cdf0e10cSrcweir 	,m_aHidden( makeAny( sal_False ) )
227*cdf0e10cSrcweir     ,m_aContext( _rContext )
228*cdf0e10cSrcweir 	,m_aModelName(_sModelName)
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     DBG_CTOR(OGridColumn,NULL);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     // Anlegen des UnoControlModels
233*cdf0e10cSrcweir     if ( m_aModelName.getLength() )    // is there a to-be-aggregated model?
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         increment( m_refCount );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir         {
238*cdf0e10cSrcweir             m_xAggregate.set( m_aContext.createComponent( m_aModelName ), UNO_QUERY );
239*cdf0e10cSrcweir             setAggregation( m_xAggregate );
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir         if ( m_xAggregate.is() )
243*cdf0e10cSrcweir         {   // don't omit those brackets - they ensure that the following temporary is properly deleted
244*cdf0e10cSrcweir             m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
245*cdf0e10cSrcweir         }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir         // Refcount wieder bei NULL
248*cdf0e10cSrcweir         decrement( m_refCount );
249*cdf0e10cSrcweir     }
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir //------------------------------------------------------------------------------
253*cdf0e10cSrcweir OGridColumn::OGridColumn( const OGridColumn* _pOriginal )
254*cdf0e10cSrcweir 	:OGridColumn_BASE( m_aMutex )
255*cdf0e10cSrcweir 	,OPropertySetAggregationHelper( OGridColumn_BASE::rBHelper )
256*cdf0e10cSrcweir     ,m_aContext( _pOriginal->m_aContext )
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     DBG_CTOR(OGridColumn,NULL);
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	m_aWidth = _pOriginal->m_aWidth;
261*cdf0e10cSrcweir 	m_aAlign = _pOriginal->m_aAlign;
262*cdf0e10cSrcweir 	m_aHidden = _pOriginal->m_aHidden;
263*cdf0e10cSrcweir 	m_aModelName = _pOriginal->m_aModelName;
264*cdf0e10cSrcweir 	m_aLabel = _pOriginal->m_aLabel;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 	increment( m_refCount );
267*cdf0e10cSrcweir 	{
268*cdf0e10cSrcweir 		{
269*cdf0e10cSrcweir 			m_xAggregate = createAggregateClone( _pOriginal );
270*cdf0e10cSrcweir 			setAggregation( m_xAggregate );
271*cdf0e10cSrcweir 		}
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 		if ( m_xAggregate.is() )
274*cdf0e10cSrcweir 		{	// don't omit this brackets - they ensure that the following temporary is properly deleted
275*cdf0e10cSrcweir 			m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
276*cdf0e10cSrcweir 		}
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir 	decrement( m_refCount );
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir //------------------------------------------------------------------------------
282*cdf0e10cSrcweir OGridColumn::~OGridColumn()
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir     if (!OGridColumn_BASE::rBHelper.bDisposed)
285*cdf0e10cSrcweir     {
286*cdf0e10cSrcweir         acquire();
287*cdf0e10cSrcweir         dispose();
288*cdf0e10cSrcweir     }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     // freigeben der Agg
291*cdf0e10cSrcweir     if (m_xAggregate.is())
292*cdf0e10cSrcweir     {
293*cdf0e10cSrcweir         InterfaceRef  xIface;
294*cdf0e10cSrcweir         m_xAggregate->setDelegator(xIface);
295*cdf0e10cSrcweir     }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir     DBG_DTOR(OGridColumn,NULL);
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir // XEventListener
301*cdf0e10cSrcweir //------------------------------------------------------------------------------
302*cdf0e10cSrcweir void SAL_CALL OGridColumn::disposing(const EventObject& _rSource) throw(RuntimeException)
303*cdf0e10cSrcweir {
304*cdf0e10cSrcweir     OPropertySetAggregationHelper::disposing(_rSource);
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     Reference<XEventListener>  xEvtLstner;
307*cdf0e10cSrcweir     if (query_aggregation(m_xAggregate, xEvtLstner))
308*cdf0e10cSrcweir         xEvtLstner->disposing(_rSource);
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir // OGridColumn_BASE
312*cdf0e10cSrcweir //-----------------------------------------------------------------------------
313*cdf0e10cSrcweir void OGridColumn::disposing()
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir     OGridColumn_BASE::disposing();
316*cdf0e10cSrcweir     OPropertySetAggregationHelper::disposing();
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     Reference<XComponent>  xComp;
319*cdf0e10cSrcweir     if (query_aggregation(m_xAggregate, xComp))
320*cdf0e10cSrcweir         xComp->dispose();
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir //------------------------------------------------------------------------------
324*cdf0e10cSrcweir void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, sal_Bool bAllowDropDown )
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir     // some properties are not to be exposed to the outer world
327*cdf0e10cSrcweir     ::std::set< ::rtl::OUString > aForbiddenProperties;
328*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_ALIGN );
329*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_AUTOCOMPLETE );
330*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_BACKGROUNDCOLOR );
331*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_BORDER );
332*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_BORDERCOLOR );
333*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_ECHO_CHAR );
334*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FILLCOLOR );
335*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT );
336*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_NAME );
337*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_STYLENAME );
338*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_FAMILY );
339*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_CHARSET );
340*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_HEIGHT );
341*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_WEIGHT );
342*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_SLANT );
343*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_UNDERLINE );
344*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_STRIKEOUT );
345*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONT_WORDLINEMODE );
346*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_TEXTLINECOLOR );
347*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONTEMPHASISMARK );
348*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_FONTRELIEF );
349*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_HARDLINEBREAKS );
350*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_HSCROLL );
351*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_LABEL );
352*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_LINECOLOR );
353*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_MULTISELECTION );
354*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_PRINTABLE );
355*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_TABINDEX );
356*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_TABSTOP );
357*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_TEXTCOLOR );
358*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_VSCROLL );
359*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_CONTROLLABEL );
360*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_RICH_TEXT );
361*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_VERTICAL_ALIGN );
362*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_IMAGE_URL );
363*cdf0e10cSrcweir     aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION );
364*cdf0e10cSrcweir     aForbiddenProperties.insert( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) );
365*cdf0e10cSrcweir     if ( !bAllowDropDown )
366*cdf0e10cSrcweir         aForbiddenProperties.insert( PROPERTY_DROPDOWN );
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     Sequence< Property > aNewProps( _rProps.getLength() );
369*cdf0e10cSrcweir     Property* pNewProps = aNewProps.getArray();
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     const Property* pProps = _rProps.getConstArray();
372*cdf0e10cSrcweir     const Property* pPropsEnd = pProps + _rProps.getLength();
373*cdf0e10cSrcweir     for ( ; pProps != pPropsEnd; ++pProps )
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         if ( aForbiddenProperties.find( pProps->Name ) == aForbiddenProperties.end() )
376*cdf0e10cSrcweir             *pNewProps++ = *pProps;
377*cdf0e10cSrcweir     }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     aNewProps.realloc( pNewProps - aNewProps.getArray() );
380*cdf0e10cSrcweir     _rProps = aNewProps;
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir //------------------------------------------------------------------------------
384*cdf0e10cSrcweir void OGridColumn::setOwnProperties(Sequence<Property>& aDescriptor)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     aDescriptor.realloc(5);
387*cdf0e10cSrcweir     Property* pProperties = aDescriptor.getArray();
388*cdf0e10cSrcweir     DECL_PROP1(LABEL,               ::rtl::OUString,    BOUND);
389*cdf0e10cSrcweir     DECL_PROP3(WIDTH,               sal_Int32,          BOUND, MAYBEVOID, MAYBEDEFAULT);
390*cdf0e10cSrcweir     DECL_PROP3(ALIGN,               sal_Int16,          BOUND, MAYBEVOID, MAYBEDEFAULT);
391*cdf0e10cSrcweir     DECL_BOOL_PROP2(HIDDEN,                             BOUND, MAYBEDEFAULT);
392*cdf0e10cSrcweir     DECL_PROP1(COLUMNSERVICENAME,   ::rtl::OUString,    READONLY);
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir // Reference<XPropertySet>
396*cdf0e10cSrcweir //------------------------------------------------------------------------------
397*cdf0e10cSrcweir void OGridColumn::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
398*cdf0e10cSrcweir {
399*cdf0e10cSrcweir     switch (nHandle)
400*cdf0e10cSrcweir     {
401*cdf0e10cSrcweir         case PROPERTY_ID_COLUMNSERVICENAME:
402*cdf0e10cSrcweir             rValue <<= m_aModelName;
403*cdf0e10cSrcweir             break;
404*cdf0e10cSrcweir         case PROPERTY_ID_LABEL:
405*cdf0e10cSrcweir             rValue <<= m_aLabel;
406*cdf0e10cSrcweir             break;
407*cdf0e10cSrcweir         case PROPERTY_ID_WIDTH:
408*cdf0e10cSrcweir             rValue = m_aWidth;
409*cdf0e10cSrcweir             break;
410*cdf0e10cSrcweir         case PROPERTY_ID_ALIGN:
411*cdf0e10cSrcweir             rValue = m_aAlign;
412*cdf0e10cSrcweir             break;
413*cdf0e10cSrcweir         case PROPERTY_ID_HIDDEN:
414*cdf0e10cSrcweir             rValue = m_aHidden;
415*cdf0e10cSrcweir             break;
416*cdf0e10cSrcweir         default:
417*cdf0e10cSrcweir             OPropertySetAggregationHelper::getFastPropertyValue(rValue, nHandle);
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir //------------------------------------------------------------------------------
422*cdf0e10cSrcweir sal_Bool OGridColumn::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
423*cdf0e10cSrcweir                                             sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir     sal_Bool bModified(sal_False);
426*cdf0e10cSrcweir     switch (nHandle)
427*cdf0e10cSrcweir     {
428*cdf0e10cSrcweir         case PROPERTY_ID_LABEL:
429*cdf0e10cSrcweir             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aLabel);
430*cdf0e10cSrcweir             break;
431*cdf0e10cSrcweir         case PROPERTY_ID_WIDTH:
432*cdf0e10cSrcweir             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, ::getCppuType((const sal_Int32*)NULL));
433*cdf0e10cSrcweir             break;
434*cdf0e10cSrcweir         case PROPERTY_ID_ALIGN:
435*cdf0e10cSrcweir             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType( (const sal_Int32*)NULL ) );
436*cdf0e10cSrcweir             // strange enough, css.awt.TextAlign is a 32-bit integer, while the Align property (both here for grid controls
437*cdf0e10cSrcweir             // and for ordinary toolkit controls) is a 16-bit integer. So, allow for 32 bit, but normalize it to 16 bit
438*cdf0e10cSrcweir             if ( bModified )
439*cdf0e10cSrcweir             {
440*cdf0e10cSrcweir                 sal_Int32 nAlign( 0 );
441*cdf0e10cSrcweir                 if ( rConvertedValue >>= nAlign )
442*cdf0e10cSrcweir                     rConvertedValue <<= (sal_Int16)nAlign;
443*cdf0e10cSrcweir             }
444*cdf0e10cSrcweir             break;
445*cdf0e10cSrcweir         case PROPERTY_ID_HIDDEN:
446*cdf0e10cSrcweir             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getBOOL(m_aHidden));
447*cdf0e10cSrcweir             break;
448*cdf0e10cSrcweir     }
449*cdf0e10cSrcweir     return bModified;
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir //------------------------------------------------------------------------------
453*cdf0e10cSrcweir void OGridColumn::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (::com::sun::star::uno::Exception)
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir     switch (nHandle)
456*cdf0e10cSrcweir     {
457*cdf0e10cSrcweir         case PROPERTY_ID_LABEL:
458*cdf0e10cSrcweir             DBG_ASSERT(rValue.getValueType().getTypeClass() == TypeClass_STRING, "invalid type" );
459*cdf0e10cSrcweir             rValue >>= m_aLabel;
460*cdf0e10cSrcweir             break;
461*cdf0e10cSrcweir         case PROPERTY_ID_WIDTH:
462*cdf0e10cSrcweir             m_aWidth = rValue;
463*cdf0e10cSrcweir             break;
464*cdf0e10cSrcweir         case PROPERTY_ID_ALIGN:
465*cdf0e10cSrcweir             m_aAlign = rValue;
466*cdf0e10cSrcweir             break;
467*cdf0e10cSrcweir         case PROPERTY_ID_HIDDEN:
468*cdf0e10cSrcweir             m_aHidden = rValue;
469*cdf0e10cSrcweir             break;
470*cdf0e10cSrcweir     }
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir // XPropertyState
475*cdf0e10cSrcweir //------------------------------------------------------------------------------
476*cdf0e10cSrcweir Any OGridColumn::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir     switch (nHandle)
479*cdf0e10cSrcweir     {
480*cdf0e10cSrcweir         case PROPERTY_ID_WIDTH:
481*cdf0e10cSrcweir         case PROPERTY_ID_ALIGN:
482*cdf0e10cSrcweir             return Any();
483*cdf0e10cSrcweir         case PROPERTY_ID_HIDDEN:
484*cdf0e10cSrcweir             return makeAny((sal_Bool)sal_False);
485*cdf0e10cSrcweir         default:
486*cdf0e10cSrcweir             return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle);
487*cdf0e10cSrcweir     }
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir // XCloneable
491*cdf0e10cSrcweir //------------------------------------------------------------------------------
492*cdf0e10cSrcweir Reference< XCloneable > SAL_CALL OGridColumn::createClone(  ) throw (RuntimeException)
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir     OGridColumn* pNewColumn = createCloneColumn();
495*cdf0e10cSrcweir     return pNewColumn;
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir //XPersistObject
499*cdf0e10cSrcweir //------------------------------------------------------------------------------
500*cdf0e10cSrcweir void SAL_CALL OGridColumn::write(const Reference<XObjectOutputStream>& _rxOutStream)
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir     // 1. Schreiben des UnoControls
503*cdf0e10cSrcweir     Reference<XMarkableStream>  xMark(_rxOutStream, UNO_QUERY);
504*cdf0e10cSrcweir     sal_Int32 nMark = xMark->createMark();
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     sal_Int32 nLen = 0;
507*cdf0e10cSrcweir     _rxOutStream->writeLong(nLen);
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir     Reference<XPersistObject>  xPersist;
510*cdf0e10cSrcweir     if (query_aggregation(m_xAggregate, xPersist))
511*cdf0e10cSrcweir         xPersist->write(_rxOutStream);
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir     // feststellen der Laenge
514*cdf0e10cSrcweir     nLen = xMark->offsetToMark(nMark) - 4;
515*cdf0e10cSrcweir     xMark->jumpToMark(nMark);
516*cdf0e10cSrcweir     _rxOutStream->writeLong(nLen);
517*cdf0e10cSrcweir     xMark->jumpToFurthest();
518*cdf0e10cSrcweir     xMark->deleteMark(nMark);
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir     // 2. Schreiben einer VersionsNummer
521*cdf0e10cSrcweir     _rxOutStream->writeShort(0x0002);
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir     sal_uInt16 nAnyMask = 0;
524*cdf0e10cSrcweir     if (m_aWidth.getValueType().getTypeClass() == TypeClass_LONG)
525*cdf0e10cSrcweir         nAnyMask |= WIDTH;
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     if (m_aAlign.getValueTypeClass() == TypeClass_SHORT)
528*cdf0e10cSrcweir         nAnyMask |= ALIGN;
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     nAnyMask |= COMPATIBLE_HIDDEN;
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir     _rxOutStream->writeShort(nAnyMask);
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir     if (nAnyMask & WIDTH)
535*cdf0e10cSrcweir         _rxOutStream->writeLong(getINT32(m_aWidth));
536*cdf0e10cSrcweir     if (nAnyMask & ALIGN)
537*cdf0e10cSrcweir         _rxOutStream->writeShort(getINT16(m_aAlign));
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir     // Name
540*cdf0e10cSrcweir     _rxOutStream << m_aLabel;
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir     // the new place for the hidden flag : after m_aLabel, so older office version read the correct label, too
543*cdf0e10cSrcweir     if (nAnyMask & COMPATIBLE_HIDDEN)
544*cdf0e10cSrcweir         _rxOutStream->writeBoolean(getBOOL(m_aHidden));
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir //------------------------------------------------------------------------------
548*cdf0e10cSrcweir void SAL_CALL OGridColumn::read(const Reference<XObjectInputStream>& _rxInStream)
549*cdf0e10cSrcweir {
550*cdf0e10cSrcweir     // 1. Lesen des UnoControls
551*cdf0e10cSrcweir     sal_Int32 nLen = _rxInStream->readLong();
552*cdf0e10cSrcweir     if (nLen)
553*cdf0e10cSrcweir     {
554*cdf0e10cSrcweir         Reference<XMarkableStream>  xMark(_rxInStream, UNO_QUERY);
555*cdf0e10cSrcweir         sal_Int32 nMark = xMark->createMark();
556*cdf0e10cSrcweir         Reference<XPersistObject>  xPersist;
557*cdf0e10cSrcweir         if (query_aggregation(m_xAggregate, xPersist))
558*cdf0e10cSrcweir             xPersist->read(_rxInStream);
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir         xMark->jumpToMark(nMark);
561*cdf0e10cSrcweir         _rxInStream->skipBytes(nLen);
562*cdf0e10cSrcweir         xMark->deleteMark(nMark);
563*cdf0e10cSrcweir     }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir     // 2. Lesen des Versionsnummer
566*cdf0e10cSrcweir     sal_uInt16 nVersion = _rxInStream->readShort(); (void)nVersion;
567*cdf0e10cSrcweir     sal_uInt16 nAnyMask = _rxInStream->readShort();
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir     if (nAnyMask & WIDTH)
570*cdf0e10cSrcweir     {
571*cdf0e10cSrcweir         sal_Int32 nValue = _rxInStream->readLong();
572*cdf0e10cSrcweir         m_aWidth <<= (sal_Int32)nValue;
573*cdf0e10cSrcweir     }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     if (nAnyMask & ALIGN)
576*cdf0e10cSrcweir     {
577*cdf0e10cSrcweir         sal_Int16 nValue = _rxInStream->readShort();
578*cdf0e10cSrcweir         m_aAlign <<= nValue;
579*cdf0e10cSrcweir     }
580*cdf0e10cSrcweir     if (nAnyMask & OLD_HIDDEN)
581*cdf0e10cSrcweir     {
582*cdf0e10cSrcweir         sal_Bool bValue = _rxInStream->readBoolean();
583*cdf0e10cSrcweir         m_aHidden <<= (sal_Bool)bValue;
584*cdf0e10cSrcweir     }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir     // Name
587*cdf0e10cSrcweir     _rxInStream >> m_aLabel;
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir     if (nAnyMask & COMPATIBLE_HIDDEN)
590*cdf0e10cSrcweir     {
591*cdf0e10cSrcweir         sal_Bool bValue = _rxInStream->readBoolean();
592*cdf0e10cSrcweir         m_aHidden <<= (sal_Bool)bValue;
593*cdf0e10cSrcweir     }
594*cdf0e10cSrcweir }
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir //------------------------------------------------------------------------------
597*cdf0e10cSrcweir IMPL_COLUMN(TextFieldColumn,        FRM_SUN_COMPONENT_TEXTFIELD,        sal_False);
598*cdf0e10cSrcweir IMPL_COLUMN(PatternFieldColumn,     FRM_SUN_COMPONENT_PATTERNFIELD,     sal_False);
599*cdf0e10cSrcweir IMPL_COLUMN(DateFieldColumn,        FRM_SUN_COMPONENT_DATEFIELD,        sal_True);
600*cdf0e10cSrcweir IMPL_COLUMN(TimeFieldColumn,        FRM_SUN_COMPONENT_TIMEFIELD,        sal_False);
601*cdf0e10cSrcweir IMPL_COLUMN(NumericFieldColumn,     FRM_SUN_COMPONENT_NUMERICFIELD,     sal_False);
602*cdf0e10cSrcweir IMPL_COLUMN(CurrencyFieldColumn,    FRM_SUN_COMPONENT_CURRENCYFIELD,    sal_False);
603*cdf0e10cSrcweir IMPL_COLUMN(CheckBoxColumn,         FRM_SUN_COMPONENT_CHECKBOX,         sal_False);
604*cdf0e10cSrcweir IMPL_COLUMN(ComboBoxColumn,         FRM_SUN_COMPONENT_COMBOBOX,         sal_False);
605*cdf0e10cSrcweir IMPL_COLUMN(ListBoxColumn,          FRM_SUN_COMPONENT_LISTBOX,          sal_False);
606*cdf0e10cSrcweir IMPL_COLUMN(FormattedFieldColumn,   FRM_SUN_COMPONENT_FORMATTEDFIELD,   sal_False);
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir //.........................................................................
609*cdf0e10cSrcweir }   // namespace frm
610*cdf0e10cSrcweir //.........................................................................
611*cdf0e10cSrcweir 
612