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

Generated by: LCOV version 1.10