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

Generated by: LCOV version 1.10