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