LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/forms/source/component - Columns.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 239 287 83.3 %
Date: 2013-07-09 Functions: 34 82 41.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10