LCOV - code coverage report
Current view: top level - forms/source/component - Columns.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 239 287 83.3 %
Date: 2015-06-13 12:38:46 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          60 : const StringSequence& getColumnTypes()
      67             : {
      68          60 :     static StringSequence aColumnTypes(10);
      69          60 :     if (aColumnTypes.getConstArray()[0].isEmpty())
      70             :     {
      71           2 :         OUString* pNames = aColumnTypes.getArray();
      72           2 :         pNames[TYPE_CHECKBOX]       = "CheckBox";
      73           2 :         pNames[TYPE_COMBOBOX]       = "ComboBox";
      74           2 :         pNames[TYPE_CURRENCYFIELD]  = "CurrencyField";
      75           2 :         pNames[TYPE_DATEFIELD]      = "DateField";
      76           2 :         pNames[TYPE_FORMATTEDFIELD] = "FormattedField";
      77           2 :         pNames[TYPE_LISTBOX]        = "ListBox";
      78           2 :         pNames[TYPE_NUMERICFIELD]   = "NumericField";
      79           2 :         pNames[TYPE_PATTERNFIELD]   = "PatternField";
      80           2 :         pNames[TYPE_TEXTFIELD]      = "TextField";
      81           2 :         pNames[TYPE_TIMEFIELD]      = "TimeField";
      82             :     }
      83          60 :     return aColumnTypes;
      84             : }
      85             : 
      86             : 
      87           2 : sal_Int32 getColumnTypeByModelName(const OUString& aModelName)
      88             : {
      89           2 :     const OUString aModelPrefix ("com.sun.star.form.component.");
      90           4 :     const OUString aCompatibleModelPrefix ("stardiv.one.form.component.");
      91             : 
      92           2 :     sal_Int32 nTypeId = -1;
      93           2 :     if (aModelName == FRM_COMPONENT_EDIT)
      94           0 :         nTypeId = TYPE_TEXTFIELD;
      95             :     else
      96             :     {
      97           2 :         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           2 :             : aModelName.copy(aCompatibleModelPrefix.getLength());
     107             : 
     108           2 :         const StringSequence& rColumnTypes = getColumnTypes();
     109           2 :         nTypeId = ::detail::findPos(aColumnType, rColumnTypes);
     110             :     }
     111           4 :     return nTypeId;
     112             : }
     113             : 
     114             : namespace
     115             : {
     116             :     class theOGridColumnImplementationId : public rtl::Static< UnoTunnelIdInit, theOGridColumnImplementationId > {};
     117             : }
     118             : 
     119         118 : const Sequence<sal_Int8>& OGridColumn::getUnoTunnelImplementationId()
     120             : {
     121         118 :     return theOGridColumnImplementationId::get().getSeq();
     122             : }
     123             : 
     124             : 
     125          59 : sal_Int64 SAL_CALL OGridColumn::getSomething( const Sequence<sal_Int8>& _rIdentifier) throw(RuntimeException, std::exception)
     126             : {
     127          59 :     sal_Int64 nReturn(0);
     128             : 
     129         118 :     if  (   (_rIdentifier.getLength() == 16)
     130          59 :         &&  (0 == memcmp( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
     131             :         )
     132             :     {
     133          59 :         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          59 :     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        5332 : Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) throw (RuntimeException, std::exception)
     176             : {
     177        5332 :     Any aReturn;
     178             :     // some functionality at our aggregate cannot be reasonably fulfilled here.
     179       10664 :     if  (   _rType.equals(cppu::UnoType<XFormComponent>::get())
     180        5332 :         ||  _rType.equals(cppu::UnoType<XServiceInfo>::get())
     181        5332 :         ||  _rType.equals(cppu::UnoType<XBindableValue>::get())
     182        5332 :         ||  _rType.equals(cppu::UnoType<XPropertyContainer>::get())
     183       10664 :         ||  comphelper::isAssignableFrom(cppu::UnoType<XTextRange>::get(),_rType)
     184             :         )
     185           0 :         return aReturn;
     186             : 
     187        5332 :     aReturn = OGridColumn_BASE::queryAggregation(_rType);
     188        5332 :     if (!aReturn.hasValue())
     189             :     {
     190        2969 :         aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
     191        2969 :         if (!aReturn.hasValue() && m_xAggregate.is())
     192         688 :             aReturn = m_xAggregate->queryAggregation(_rType);
     193             :     }
     194             : 
     195        5332 :     return aReturn;
     196             : }
     197             : 
     198             : 
     199          59 : 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          59 :     ,m_aModelName(_sModelName)
     204             : {
     205             : 
     206             :     // Create the UnoControlModel
     207          59 :     if ( !m_aModelName.isEmpty() ) // is there a to-be-aggregated model?
     208             :     {
     209          59 :         osl_atomic_increment( &m_refCount );
     210             : 
     211             :         {
     212          59 :             m_xAggregate.set( _rContext->getServiceManager()->createInstanceWithContext( m_aModelName, _rContext ), UNO_QUERY );
     213          59 :             setAggregation( m_xAggregate );
     214             :         }
     215             : 
     216          59 :         if ( m_xAggregate.is() )
     217             :         {   // don't omit those brackets - they ensure that the following temporary is properly deleted
     218          59 :             m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
     219             :         }
     220             : 
     221             :         // Set refcount back to zero
     222          59 :         osl_atomic_decrement( &m_refCount );
     223             :     }
     224          59 : }
     225             : 
     226             : 
     227           2 : OGridColumn::OGridColumn( const OGridColumn* _pOriginal )
     228             :     :OGridColumn_BASE( m_aMutex )
     229           2 :     ,OPropertySetAggregationHelper( OGridColumn_BASE::rBHelper )
     230             : {
     231             : 
     232           2 :     m_aWidth = _pOriginal->m_aWidth;
     233           2 :     m_aAlign = _pOriginal->m_aAlign;
     234           2 :     m_aHidden = _pOriginal->m_aHidden;
     235           2 :     m_aModelName = _pOriginal->m_aModelName;
     236           2 :     m_aLabel = _pOriginal->m_aLabel;
     237             : 
     238           2 :     osl_atomic_increment( &m_refCount );
     239             :     {
     240             :         {
     241           2 :             m_xAggregate = createAggregateClone( _pOriginal );
     242           2 :             setAggregation( m_xAggregate );
     243             :         }
     244             : 
     245           2 :         if ( m_xAggregate.is() )
     246             :         {   // don't omit this brackets - they ensure that the following temporary is properly deleted
     247           2 :             m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) );
     248             :         }
     249             :     }
     250           2 :     osl_atomic_decrement( &m_refCount );
     251           2 : }
     252             : 
     253             : 
     254         104 : OGridColumn::~OGridColumn()
     255             : {
     256          52 :     if (!OGridColumn_BASE::rBHelper.bDisposed)
     257             :     {
     258           0 :         acquire();
     259           0 :         dispose();
     260             :     }
     261             : 
     262             :     // Free the aggregate
     263          52 :     if (m_xAggregate.is())
     264             :     {
     265          52 :         InterfaceRef  xIface;
     266          52 :         m_xAggregate->setDelegator(xIface);
     267             :     }
     268             : 
     269          52 : }
     270             : 
     271             : // XEventListener
     272             : 
     273         144 : void SAL_CALL OGridColumn::disposing(const EventObject& _rSource) throw(RuntimeException, std::exception)
     274             : {
     275         144 :     OPropertySetAggregationHelper::disposing(_rSource);
     276             : 
     277         144 :     Reference<XEventListener>  xEvtLstner;
     278         144 :     if (query_aggregation(m_xAggregate, xEvtLstner))
     279         144 :         xEvtLstner->disposing(_rSource);
     280         144 : }
     281             : 
     282             : // OGridColumn_BASE
     283             : 
     284          52 : void OGridColumn::disposing()
     285             : {
     286          52 :     OGridColumn_BASE::disposing();
     287          52 :     OPropertySetAggregationHelper::disposing();
     288             : 
     289          52 :     Reference<XComponent>  xComp;
     290          52 :     if (query_aggregation(m_xAggregate, xComp))
     291          52 :         xComp->dispose();
     292          52 : }
     293             : 
     294             : 
     295           4 : void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, bool bAllowDropDown )
     296             : {
     297             :     // some properties are not to be exposed to the outer world
     298           4 :     ::std::set< OUString > aForbiddenProperties;
     299           4 :     aForbiddenProperties.insert( PROPERTY_ALIGN );
     300           4 :     aForbiddenProperties.insert( PROPERTY_AUTOCOMPLETE );
     301           4 :     aForbiddenProperties.insert( PROPERTY_BACKGROUNDCOLOR );
     302           4 :     aForbiddenProperties.insert( PROPERTY_BORDER );
     303           4 :     aForbiddenProperties.insert( PROPERTY_BORDERCOLOR );
     304           4 :     aForbiddenProperties.insert( PROPERTY_ECHO_CHAR );
     305           4 :     aForbiddenProperties.insert( PROPERTY_FILLCOLOR );
     306           4 :     aForbiddenProperties.insert( PROPERTY_FONT );
     307           4 :     aForbiddenProperties.insert( PROPERTY_FONT_NAME );
     308           4 :     aForbiddenProperties.insert( PROPERTY_FONT_STYLENAME );
     309           4 :     aForbiddenProperties.insert( PROPERTY_FONT_FAMILY );
     310           4 :     aForbiddenProperties.insert( PROPERTY_FONT_CHARSET );
     311           4 :     aForbiddenProperties.insert( PROPERTY_FONT_HEIGHT );
     312           4 :     aForbiddenProperties.insert( PROPERTY_FONT_WEIGHT );
     313           4 :     aForbiddenProperties.insert( PROPERTY_FONT_SLANT );
     314           4 :     aForbiddenProperties.insert( PROPERTY_FONT_UNDERLINE );
     315           4 :     aForbiddenProperties.insert( PROPERTY_FONT_STRIKEOUT );
     316           4 :     aForbiddenProperties.insert( PROPERTY_FONT_WORDLINEMODE );
     317           4 :     aForbiddenProperties.insert( PROPERTY_TEXTLINECOLOR );
     318           4 :     aForbiddenProperties.insert( PROPERTY_FONTEMPHASISMARK );
     319           4 :     aForbiddenProperties.insert( PROPERTY_FONTRELIEF );
     320           4 :     aForbiddenProperties.insert( PROPERTY_HARDLINEBREAKS );
     321           4 :     aForbiddenProperties.insert( PROPERTY_HSCROLL );
     322           4 :     aForbiddenProperties.insert( PROPERTY_LABEL );
     323           4 :     aForbiddenProperties.insert( PROPERTY_LINECOLOR );
     324           4 :     aForbiddenProperties.insert( PROPERTY_MULTISELECTION );
     325           4 :     aForbiddenProperties.insert( PROPERTY_PRINTABLE );
     326           4 :     aForbiddenProperties.insert( PROPERTY_TABINDEX );
     327           4 :     aForbiddenProperties.insert( PROPERTY_TABSTOP );
     328           4 :     aForbiddenProperties.insert( PROPERTY_TEXTCOLOR );
     329           4 :     aForbiddenProperties.insert( PROPERTY_VSCROLL );
     330           4 :     aForbiddenProperties.insert( PROPERTY_CONTROLLABEL );
     331           4 :     aForbiddenProperties.insert( PROPERTY_RICH_TEXT );
     332           4 :     aForbiddenProperties.insert( PROPERTY_VERTICAL_ALIGN );
     333           4 :     aForbiddenProperties.insert( PROPERTY_IMAGE_URL );
     334           4 :     aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION );
     335           4 :     aForbiddenProperties.insert( OUString( "EnableVisible" ) );
     336           4 :     if ( !bAllowDropDown )
     337           3 :         aForbiddenProperties.insert( PROPERTY_DROPDOWN );
     338             : 
     339           8 :     Sequence< Property > aNewProps( _rProps.getLength() );
     340           4 :     Property* pNewProps = aNewProps.getArray();
     341             : 
     342           4 :     const Property* pProps = _rProps.getConstArray();
     343           4 :     const Property* pPropsEnd = pProps + _rProps.getLength();
     344         394 :     for ( ; pProps != pPropsEnd; ++pProps )
     345             :     {
     346         390 :         if ( aForbiddenProperties.find( pProps->Name ) == aForbiddenProperties.end() )
     347         280 :             *pNewProps++ = *pProps;
     348             :     }
     349             : 
     350           4 :     aNewProps.realloc( pNewProps - aNewProps.getArray() );
     351           8 :     _rProps = aNewProps;
     352           4 : }
     353             : 
     354             : 
     355           4 : void OGridColumn::setOwnProperties(Sequence<Property>& aDescriptor)
     356             : {
     357           4 :     aDescriptor.realloc(5);
     358           4 :     Property* pProperties = aDescriptor.getArray();
     359           4 :     DECL_PROP1(LABEL,               OUString,    BOUND);
     360           4 :     DECL_PROP3(WIDTH,               sal_Int32,          BOUND, MAYBEVOID, MAYBEDEFAULT);
     361           4 :     DECL_PROP3(ALIGN,               sal_Int16,          BOUND, MAYBEVOID, MAYBEDEFAULT);
     362           4 :     DECL_BOOL_PROP2(HIDDEN,                             BOUND, MAYBEDEFAULT);
     363           4 :     DECL_PROP1(COLUMNSERVICENAME,   OUString,    READONLY);
     364           4 : }
     365             : 
     366             : // Reference<XPropertySet>
     367             : 
     368         263 : void OGridColumn::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
     369             : {
     370         263 :     switch (nHandle)
     371             :     {
     372             :         case PROPERTY_ID_COLUMNSERVICENAME:
     373          31 :             rValue <<= m_aModelName;
     374          31 :             break;
     375             :         case PROPERTY_ID_LABEL:
     376          69 :             rValue <<= m_aLabel;
     377          69 :             break;
     378             :         case PROPERTY_ID_WIDTH:
     379          69 :             rValue = m_aWidth;
     380          69 :             break;
     381             :         case PROPERTY_ID_ALIGN:
     382          31 :             rValue = m_aAlign;
     383          31 :             break;
     384             :         case PROPERTY_ID_HIDDEN:
     385          63 :             rValue = m_aHidden;
     386          63 :             break;
     387             :         default:
     388           0 :             OPropertySetAggregationHelper::getFastPropertyValue(rValue, nHandle);
     389             :     }
     390         263 : }
     391             : 
     392             : 
     393         124 : sal_Bool OGridColumn::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
     394             :                                             sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
     395             : {
     396         124 :     bool bModified(false);
     397         124 :     switch (nHandle)
     398             :     {
     399             :         case PROPERTY_ID_LABEL:
     400          31 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aLabel);
     401          31 :             break;
     402             :         case PROPERTY_ID_WIDTH:
     403          31 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, cppu::UnoType<sal_Int32>::get());
     404          31 :             break;
     405             :         case PROPERTY_ID_ALIGN:
     406          31 :             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          31 :             if ( bModified )
     410             :             {
     411          31 :                 sal_Int32 nAlign( 0 );
     412          31 :                 if ( rConvertedValue >>= nAlign )
     413          31 :                     rConvertedValue <<= (sal_Int16)nAlign;
     414             :             }
     415          31 :             break;
     416             :         case PROPERTY_ID_HIDDEN:
     417          31 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getBOOL(m_aHidden));
     418          31 :             break;
     419             :     }
     420         124 :     return bModified;
     421             : }
     422             : 
     423             : 
     424          72 : void OGridColumn::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (::com::sun::star::uno::Exception, std::exception)
     425             : {
     426          72 :     switch (nHandle)
     427             :     {
     428             :         case PROPERTY_ID_LABEL:
     429             :             DBG_ASSERT(rValue.getValueType().getTypeClass() == TypeClass_STRING, "invalid type" );
     430          31 :             rValue >>= m_aLabel;
     431          31 :             break;
     432             :         case PROPERTY_ID_WIDTH:
     433          10 :             m_aWidth = rValue;
     434          10 :             break;
     435             :         case PROPERTY_ID_ALIGN:
     436          31 :             m_aAlign = rValue;
     437          31 :             break;
     438             :         case PROPERTY_ID_HIDDEN:
     439           0 :             m_aHidden = rValue;
     440           0 :             break;
     441             :     }
     442          72 : }
     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           2 : Reference< XCloneable > SAL_CALL OGridColumn::createClone(  ) throw (RuntimeException, std::exception)
     464             : {
     465           2 :     OGridColumn* pNewColumn = createCloneColumn();
     466           2 :     return pNewColumn;
     467             : }
     468             : 
     469             : // XPersistObject
     470             : 
     471           2 : void SAL_CALL OGridColumn::write(const Reference<XObjectOutputStream>& _rxOutStream)
     472             : {
     473             :     // 1. Write the UnoControl
     474           2 :     Reference<XMarkableStream>  xMark(_rxOutStream, UNO_QUERY);
     475           2 :     sal_Int32 nMark = xMark->createMark();
     476             : 
     477           2 :     sal_Int32 nLen = 0;
     478           2 :     _rxOutStream->writeLong(nLen);
     479             : 
     480           4 :     Reference<XPersistObject>  xPersist;
     481           2 :     if (query_aggregation(m_xAggregate, xPersist))
     482           2 :         xPersist->write(_rxOutStream);
     483             : 
     484             :     // Calculate the length
     485           2 :     nLen = xMark->offsetToMark(nMark) - 4;
     486           2 :     xMark->jumpToMark(nMark);
     487           2 :     _rxOutStream->writeLong(nLen);
     488           2 :     xMark->jumpToFurthest();
     489           2 :     xMark->deleteMark(nMark);
     490             : 
     491             :     // 2. Write a version number
     492           2 :     _rxOutStream->writeShort(0x0002);
     493             : 
     494           2 :     sal_uInt16 nAnyMask = 0;
     495           2 :     if (m_aWidth.getValueType().getTypeClass() == TypeClass_LONG)
     496           0 :         nAnyMask |= WIDTH;
     497             : 
     498           2 :     if (m_aAlign.getValueTypeClass() == TypeClass_SHORT)
     499           0 :         nAnyMask |= ALIGN;
     500             : 
     501           2 :     nAnyMask |= COMPATIBLE_HIDDEN;
     502             : 
     503           2 :     _rxOutStream->writeShort(nAnyMask);
     504             : 
     505           2 :     if (nAnyMask & WIDTH)
     506           0 :         _rxOutStream->writeLong(getINT32(m_aWidth));
     507           2 :     if (nAnyMask & ALIGN)
     508           0 :         _rxOutStream->writeShort(getINT16(m_aAlign));
     509             : 
     510             :     // Name
     511           2 :     _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           2 :     if (nAnyMask & COMPATIBLE_HIDDEN)
     515           4 :         _rxOutStream->writeBoolean(getBOOL(m_aHidden));
     516           2 : }
     517             : 
     518             : 
     519           2 : void SAL_CALL OGridColumn::read(const Reference<XObjectInputStream>& _rxInStream)
     520             : {
     521             :     // 1. Read the UnoControl
     522           2 :     sal_Int32 nLen = _rxInStream->readLong();
     523           2 :     if (nLen)
     524             :     {
     525           2 :         Reference<XMarkableStream>  xMark(_rxInStream, UNO_QUERY);
     526           2 :         sal_Int32 nMark = xMark->createMark();
     527           4 :         Reference<XPersistObject>  xPersist;
     528           2 :         if (query_aggregation(m_xAggregate, xPersist))
     529           2 :             xPersist->read(_rxInStream);
     530             : 
     531           2 :         xMark->jumpToMark(nMark);
     532           2 :         _rxInStream->skipBytes(nLen);
     533           4 :         xMark->deleteMark(nMark);
     534             :     }
     535             : 
     536             :     // 2. Write a version number
     537           2 :     sal_uInt16 nVersion = _rxInStream->readShort(); (void)nVersion;
     538           2 :     sal_uInt16 nAnyMask = _rxInStream->readShort();
     539             : 
     540           2 :     if (nAnyMask & WIDTH)
     541             :     {
     542           0 :         sal_Int32 nValue = _rxInStream->readLong();
     543           0 :         m_aWidth <<= (sal_Int32)nValue;
     544             :     }
     545             : 
     546           2 :     if (nAnyMask & ALIGN)
     547             :     {
     548           0 :         sal_Int16 nValue = _rxInStream->readShort();
     549           0 :         m_aAlign <<= nValue;
     550             :     }
     551           2 :     if (nAnyMask & OLD_HIDDEN)
     552             :     {
     553           0 :         bool bValue = _rxInStream->readBoolean();
     554           0 :         m_aHidden <<= bValue;
     555             :     }
     556             : 
     557             :     // Name
     558           2 :     _rxInStream >> m_aLabel;
     559             : 
     560           2 :     if (nAnyMask & COMPATIBLE_HIDDEN)
     561             :     {
     562           2 :         bool bValue = _rxInStream->readBoolean();
     563           2 :         m_aHidden <<= bValue;
     564             :     }
     565           2 : }
     566             : 
     567             : 
     568        2847 : IMPL_COLUMN(TextFieldColumn,        FRM_SUN_COMPONENT_TEXTFIELD,        false);
     569           0 : IMPL_COLUMN(PatternFieldColumn,     FRM_SUN_COMPONENT_PATTERNFIELD,     false);
     570         322 : 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        2254 : 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.11