LCOV - code coverage report
Current view: top level - forms/source/component - Grid.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 483 584 82.7 %
Date: 2014-04-11 Functions: 41 45 91.1 %
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             : #include "Columns.hxx"
      20             : #include "findpos.hxx"
      21             : #include "Grid.hxx"
      22             : #include "property.hrc"
      23             : #include "property.hxx"
      24             : #include "services.hxx"
      25             : #include <com/sun/star/form/FormComponentType.hpp>
      26             : #include <com/sun/star/form/XForm.hpp>
      27             : #include <com/sun/star/form/XLoadable.hpp>
      28             : #include <com/sun/star/text/WritingMode2.hpp>
      29             : #include <comphelper/basicio.hxx>
      30             : #include <comphelper/container.hxx>
      31             : #include <comphelper/processfactory.hxx>
      32             : #include <cppuhelper/queryinterface.hxx>
      33             : #include <toolkit/helper/vclunohelper.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : using namespace ::com::sun::star::uno;
      36             : namespace frm
      37             : {
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::sdb;
      41             : using namespace ::com::sun::star::sdbc;
      42             : using namespace ::com::sun::star::sdbcx;
      43             : using namespace ::com::sun::star::beans;
      44             : using namespace ::com::sun::star::container;
      45             : using namespace ::com::sun::star::form;
      46             : using namespace ::com::sun::star::awt;
      47             : using namespace ::com::sun::star::io;
      48             : using namespace ::com::sun::star::lang;
      49             : using namespace ::com::sun::star::util;
      50             : using namespace ::com::sun::star::view;
      51             : namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
      52             : const sal_uInt16 ROWHEIGHT          =   0x0001;
      53             : const sal_uInt16 FONTTYPE           =   0x0002;
      54             : const sal_uInt16 FONTSIZE           =   0x0004;
      55             : const sal_uInt16 FONTATTRIBS        =   0x0008;
      56             : const sal_uInt16 TABSTOP            =   0x0010;
      57             : const sal_uInt16 TEXTCOLOR          =   0x0020;
      58             : const sal_uInt16 FONTDESCRIPTOR     =   0x0040;
      59             : const sal_uInt16 RECORDMARKER       =   0x0080;
      60             : const sal_uInt16 BACKGROUNDCOLOR    =   0x0100;
      61          13 : InterfaceRef SAL_CALL OGridControlModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
      62             : {
      63          13 :     return *(new OGridControlModel( comphelper::getComponentContext(_rxFactory) ));
      64             : }
      65          13 : OGridControlModel::OGridControlModel(const Reference<XComponentContext>& _rxFactory)
      66             :     :OControlModel(_rxFactory, OUString())
      67          13 :     ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL)))
      68             :     ,OErrorBroadcaster( OComponentHelper::rBHelper )
      69             :     ,FontControlModel( false )
      70             :     ,m_aSelectListeners(m_aMutex)
      71             :     ,m_aResetListeners(m_aMutex)
      72             :     ,m_aRowSetChangeListeners(m_aMutex)
      73             :     ,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL )
      74             :     ,m_nBorder(1)
      75             :     ,m_nWritingMode( WritingMode2::CONTEXT )
      76             :     ,m_nContextWritingMode( WritingMode2::CONTEXT )
      77             :     ,m_bEnableVisible(sal_True)
      78             :     ,m_bEnable(sal_True)
      79             :     ,m_bNavigation(sal_True)
      80             :     ,m_bRecordMarker(sal_True)
      81             :     ,m_bPrintable(sal_True)
      82             :     ,m_bAlwaysShowCursor(sal_False)
      83          26 :     ,m_bDisplaySynchron(sal_True)
      84             : {
      85          13 :     m_nClassId = FormComponentType::GRIDCONTROL;
      86          13 : }
      87             : 
      88           1 : OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const Reference< XComponentContext >& _rxFactory )
      89             :     :OControlModel( _pOriginal, _rxFactory )
      90           1 :     ,OInterfaceContainer( _rxFactory, m_aMutex, ::getCppuType( static_cast<Reference<XPropertySet>*>( NULL ) ) )
      91             :     ,OErrorBroadcaster( OComponentHelper::rBHelper )
      92             :     ,FontControlModel( _pOriginal )
      93             :     ,m_aSelectListeners( m_aMutex )
      94             :     ,m_aResetListeners( m_aMutex )
      95           2 :     ,m_aRowSetChangeListeners( m_aMutex )
      96             : {
      97           1 :     m_aDefaultControl = _pOriginal->m_aDefaultControl;
      98           1 :     m_bEnable = _pOriginal->m_bEnable;
      99           1 :     m_bEnableVisible = _pOriginal->m_bEnableVisible;
     100           1 :     m_bNavigation = _pOriginal->m_bNavigation;
     101           1 :     m_nBorder = _pOriginal->m_nBorder;
     102           1 :     m_nWritingMode = _pOriginal->m_nWritingMode;
     103           1 :     m_nContextWritingMode = _pOriginal->m_nContextWritingMode;
     104           1 :     m_bRecordMarker = _pOriginal->m_bRecordMarker;
     105           1 :     m_bPrintable = _pOriginal->m_bPrintable;
     106           1 :     m_bAlwaysShowCursor = _pOriginal->m_bAlwaysShowCursor;
     107           1 :     m_bDisplaySynchron = _pOriginal->m_bDisplaySynchron;
     108             :     // clone the columns
     109           1 :     cloneColumns( _pOriginal );
     110             :     // TODO: clone the events?
     111           1 : }
     112             : 
     113          36 : OGridControlModel::~OGridControlModel()
     114             : {
     115          12 :     if (!OComponentHelper::rBHelper.bDisposed)
     116             :     {
     117           0 :         acquire();
     118           0 :         dispose();
     119             :     }
     120          24 : }
     121             : 
     122             : // XCloneable
     123           1 : Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException, std::exception)
     124             : {
     125           1 :     OGridControlModel* pClone = new OGridControlModel( this, getContext() );
     126           1 :     osl_atomic_increment( &pClone->m_refCount );
     127           1 :     pClone->OControlModel::clonedFrom( this );
     128             :     // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is
     129             :     // already done in the ctor
     130             :     //pClone->OInterfaceContainer::clonedFrom( *this );
     131           1 :     osl_atomic_decrement( &pClone->m_refCount );
     132           1 :     return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) );
     133             : }
     134             : 
     135           1 : void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer )
     136             : {
     137             :     try
     138             :     {
     139           1 :         Reference< XCloneable > xColCloneable;
     140           1 :         const OInterfaceArray::const_iterator pColumnStart = _pOriginalContainer->m_aItems.begin();
     141           1 :         const OInterfaceArray::const_iterator pColumnEnd = _pOriginalContainer->m_aItems.end();
     142           3 :         for ( OInterfaceArray::const_iterator pColumn = pColumnStart; pColumn != pColumnEnd; ++pColumn )
     143             :         {
     144             :             // ask the col for a factory for the clone
     145           2 :             xColCloneable = xColCloneable.query( *pColumn );
     146             :             DBG_ASSERT( xColCloneable.is(), "OGridControlModel::cloneColumns: column is not cloneable!" );
     147           2 :             if ( xColCloneable.is() )
     148             :             {
     149             :                 // create a clone of the column
     150           2 :                 Reference< XCloneable > xColClone( xColCloneable->createClone() );
     151             :                 DBG_ASSERT( xColClone.is(), "OGridControlModel::cloneColumns: invalid column clone!" );
     152           2 :                 if ( xColClone.is() )
     153             :                 {
     154             :                     // insert this clone into our own container
     155           2 :                     insertByIndex( pColumn - pColumnStart, xColClone->queryInterface( m_aElementType ) );
     156           2 :                 }
     157             :             }
     158           1 :         }
     159             :     }
     160           0 :     catch( const Exception& )
     161             :     {
     162             :         OSL_FAIL( "OGridControlModel::cloneColumns: caught an exception while cloning the columns!" );
     163             :     }
     164           1 : }
     165             : 
     166             : // XServiceInfo
     167           5 : StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException, std::exception)
     168             : {
     169           5 :     StringSequence aSupported = OControlModel::getSupportedServiceNames();
     170           5 :     aSupported.realloc(aSupported.getLength() + 2);
     171           5 :     aSupported[aSupported.getLength()-2] = "com.sun.star.awt.UnoControlModel";
     172           5 :     aSupported[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL;
     173           5 :     return aSupported;
     174             : }
     175        4712 : Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) throw (RuntimeException, std::exception)
     176             : {
     177        4712 :     Any aReturn = OGridControlModel_BASE::queryInterface(_rType);
     178        4712 :     if ( !aReturn.hasValue() )
     179             :     {
     180        1661 :         aReturn = OControlModel::queryAggregation( _rType );
     181        1661 :         if ( !aReturn.hasValue() )
     182             :         {
     183         602 :             aReturn = OInterfaceContainer::queryInterface( _rType );
     184         602 :             if ( !aReturn.hasValue() )
     185         237 :                 aReturn = OErrorBroadcaster::queryInterface( _rType );
     186             :         }
     187             :     }
     188        4712 :     return aReturn;
     189             : }
     190             : 
     191             : // XSQLErrorListener
     192           0 : void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) throw (RuntimeException, std::exception)
     193             : {
     194             :     // forward the errors which happened to my columns to my own listeners
     195           0 :     onError( _rEvent );
     196           0 : }
     197             : 
     198             : // XRowSetSupplier
     199          63 : Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet(  ) throw (RuntimeException, std::exception)
     200             : {
     201          63 :     return Reference< XRowSet >( getParent(), UNO_QUERY );
     202             : }
     203             : 
     204           0 : void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException, std::exception)
     205             : {
     206             :     OSL_FAIL( "OGridControlModel::setRowSet: not supported!" );
     207           0 : }
     208             : 
     209          63 : void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException, std::exception)
     210             : {
     211          63 :     if ( i_Listener.is() )
     212          63 :         m_aRowSetChangeListeners.addInterface( i_Listener );
     213          63 : }
     214             : 
     215          18 : void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException, std::exception)
     216             : {
     217          18 :     m_aRowSetChangeListeners.removeInterface( i_Listener );
     218          18 : }
     219             : 
     220             : // XChild
     221          45 : void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException, std::exception)
     222             : {
     223          45 :     ::osl::ClearableMutexGuard aGuard( m_aMutex );
     224          45 :     if ( i_Parent == getParent() )
     225          69 :         return;
     226          21 :     OControlModel::setParent( i_Parent );
     227          42 :     EventObject aEvent( *this );
     228          21 :     aGuard.clear();
     229          42 :     m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent );
     230             : }
     231           0 : Sequence< Type > SAL_CALL OGridControlModel::getTypes(  ) throw(RuntimeException, std::exception)
     232             : {
     233             :     return concatSequences(
     234             :         concatSequences(
     235             :             OControlModel::getTypes(),
     236             :             OInterfaceContainer::getTypes(),
     237             :             OErrorBroadcaster::getTypes()
     238             :         ),
     239             :         OGridControlModel_BASE::getTypes()
     240           0 :     );
     241             : }
     242             : 
     243             : // OComponentHelper
     244          12 : void OGridControlModel::disposing()
     245             : {
     246          12 :     OControlModel::disposing();
     247          12 :     OErrorBroadcaster::disposing();
     248          12 :     OInterfaceContainer::disposing();
     249          12 :     setParent(NULL);
     250          12 :     EventObject aEvt(static_cast<XWeak*>(this));
     251          12 :     m_aSelectListeners.disposeAndClear(aEvt);
     252          12 :     m_aResetListeners.disposeAndClear(aEvt);
     253          12 :     m_aRowSetChangeListeners.disposeAndClear(aEvt);
     254          12 : }
     255             : 
     256             : // XEventListener
     257          15 : void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeException, std::exception )
     258             : {
     259          15 :     OControlModel::disposing( _rEvent );
     260          15 :     OInterfaceContainer::disposing( _rEvent );
     261          15 : }
     262             : 
     263             : // XSelectionSupplier
     264           0 : sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException, std::exception)
     265             : {
     266           0 :     ::osl::ClearableMutexGuard aGuard( m_aMutex );
     267           0 :     Reference<XPropertySet> xSel;
     268           0 :     if (rElement.hasValue())
     269             :     {
     270           0 :         xSel.set(rElement, css::uno::UNO_QUERY);
     271           0 :         if (!xSel.is())
     272             :         {
     273           0 :             throw IllegalArgumentException();
     274             :         }
     275             :     }
     276           0 :     InterfaceRef xMe = static_cast<XWeak*>(this);
     277           0 :     if (xSel.is())
     278             :     {
     279           0 :         Reference<XChild> xAsChild(xSel, UNO_QUERY);
     280           0 :         if (!xAsChild.is() || (xAsChild->getParent() != xMe))
     281             :         {
     282           0 :             throw IllegalArgumentException();
     283           0 :         }
     284             :     }
     285           0 :     if ( xSel != m_xSelection )
     286             :     {
     287           0 :         m_xSelection = xSel;
     288           0 :         aGuard.clear();
     289           0 :         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
     290           0 :         return sal_True;
     291             :     }
     292           0 :     return sal_False;
     293             : }
     294          40 : Any SAL_CALL OGridControlModel::getSelection() throw(RuntimeException, std::exception)
     295             : {
     296          40 :     return makeAny(m_xSelection);
     297             : }
     298             : 
     299          30 : void OGridControlModel::addSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException, std::exception )
     300             : {
     301          30 :     m_aSelectListeners.addInterface(_rxListener);
     302          30 : }
     303             : 
     304          29 : void OGridControlModel::removeSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException, std::exception )
     305             : {
     306          29 :     m_aSelectListeners.removeInterface(_rxListener);
     307          29 : }
     308             : 
     309             : // XGridColumnFactory
     310          57 : Reference<XPropertySet> SAL_CALL OGridControlModel::createColumn(const OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     311             : {
     312          57 :     SolarMutexGuard g;
     313          57 :     const Sequence< OUString >& rColumnTypes = frm::getColumnTypes();
     314          57 :     return createColumn( ::detail::findPos( ColumnType, rColumnTypes ) );
     315             : }
     316          59 : Reference<XPropertySet>  OGridControlModel::createColumn(sal_Int32 nTypeId) const
     317             : {
     318          59 :     Reference<XPropertySet>  xReturn;
     319          59 :     switch (nTypeId)
     320             :     {
     321           0 :         case TYPE_CHECKBOX:         xReturn = new CheckBoxColumn( getContext() ); break;
     322           0 :         case TYPE_COMBOBOX:         xReturn = new ComboBoxColumn( getContext() ); break;
     323           0 :         case TYPE_CURRENCYFIELD:    xReturn = new CurrencyFieldColumn( getContext() ); break;
     324           6 :         case TYPE_DATEFIELD:        xReturn = new DateFieldColumn( getContext() ); break;
     325           0 :         case TYPE_LISTBOX:          xReturn = new ListBoxColumn( getContext() ); break;
     326           0 :         case TYPE_NUMERICFIELD:     xReturn = new NumericFieldColumn( getContext() ); break;
     327           0 :         case TYPE_PATTERNFIELD:     xReturn = new PatternFieldColumn( getContext() ); break;
     328          39 :         case TYPE_TEXTFIELD:        xReturn = new TextFieldColumn( getContext() ); break;
     329           0 :         case TYPE_TIMEFIELD:        xReturn = new TimeFieldColumn( getContext() ); break;
     330          14 :         case TYPE_FORMATTEDFIELD:   xReturn = new FormattedFieldColumn( getContext() ); break;
     331             :         default:
     332             :             OSL_FAIL("OGridControlModel::createColumn: Unknown Column");
     333           0 :             break;
     334             :     }
     335          59 :     return xReturn;
     336             : }
     337           1 : StringSequence SAL_CALL OGridControlModel::getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     338             : {
     339           1 :     return frm::getColumnTypes();
     340             : }
     341             : 
     342             : // XReset
     343           3 : void SAL_CALL OGridControlModel::reset() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     344             : {
     345           3 :     ::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
     346           6 :     EventObject aEvt(static_cast<XWeak*>(this));
     347           3 :     sal_Bool bContinue = sal_True;
     348          12 :     while (aIter.hasMoreElements() && bContinue)
     349           6 :         bContinue =((XResetListener*)aIter.next())->approveReset(aEvt);
     350           3 :     if (bContinue)
     351             :     {
     352           2 :         _reset();
     353           2 :         m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt );
     354           3 :     }
     355           3 : }
     356          23 : void SAL_CALL OGridControlModel::addResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     357             : {
     358          23 :     m_aResetListeners.addInterface(_rxListener);
     359          23 : }
     360          22 : void SAL_CALL OGridControlModel::removeResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     361             : {
     362          22 :     m_aResetListeners.removeInterface(_rxListener);
     363          22 : }
     364           2 : void OGridControlModel::_reset()
     365             : {
     366           2 :     Reference<XReset> xReset;
     367           2 :     sal_Int32 nCount = getCount();
     368           6 :     for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
     369             :     {
     370           4 :         getByIndex( nIndex ) >>= xReset;
     371           4 :         if (xReset.is())
     372           4 :             xReset->reset();
     373           2 :     }
     374           2 : }
     375             : 
     376             : // XPropertySet
     377          14 : void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     378             : {
     379          14 :     BEGIN_DESCRIBE_BASE_PROPERTIES( 37 )
     380          14 :         DECL_PROP1(NAME,                OUString,    BOUND);
     381          14 :         DECL_PROP2(CLASSID,             sal_Int16,          READONLY, TRANSIENT);
     382          14 :         DECL_PROP1(TAG,                 OUString,    BOUND);
     383          14 :         DECL_PROP1(TABINDEX,            sal_Int16,          BOUND);
     384          14 :         DECL_PROP3(TABSTOP,             sal_Bool,           BOUND, MAYBEDEFAULT, MAYBEVOID);
     385          14 :         DECL_PROP2(HASNAVIGATION,       sal_Bool,           BOUND, MAYBEDEFAULT);
     386          14 :         DECL_PROP1(ENABLED,             sal_Bool,           BOUND);
     387          14 :         DECL_PROP2(ENABLEVISIBLE,       sal_Bool,           BOUND, MAYBEDEFAULT);
     388          14 :         DECL_PROP1(BORDER,              sal_Int16,          BOUND);
     389          14 :         DECL_PROP2(BORDERCOLOR,         sal_Int16,          BOUND, MAYBEVOID);
     390          14 :         DECL_PROP1(DEFAULTCONTROL,      OUString,    BOUND);
     391          14 :         DECL_PROP3(TEXTCOLOR,           sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID);
     392          14 :         DECL_PROP3(BACKGROUNDCOLOR,     sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID);
     393          14 :         DECL_PROP2(FONT,                FontDescriptor,     BOUND, MAYBEDEFAULT);
     394          14 :         DECL_PROP3(ROWHEIGHT,           sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID);
     395          14 :         DECL_PROP1(HELPTEXT,            OUString,    BOUND);
     396          14 :         DECL_PROP1(FONT_NAME,           OUString,    MAYBEDEFAULT);
     397          14 :         DECL_PROP1(FONT_STYLENAME,      OUString,    MAYBEDEFAULT);
     398          14 :         DECL_PROP1(FONT_FAMILY,         sal_Int16,          MAYBEDEFAULT);
     399          14 :         DECL_PROP1(FONT_CHARSET,        sal_Int16,          MAYBEDEFAULT);
     400          14 :         DECL_PROP1(FONT_HEIGHT,         float,              MAYBEDEFAULT);
     401          14 :         DECL_PROP1(FONT_WEIGHT,         float,              MAYBEDEFAULT);
     402          14 :         DECL_PROP1(FONT_SLANT,          sal_Int16,          MAYBEDEFAULT);
     403          14 :         DECL_PROP1(FONT_UNDERLINE,      sal_Int16,          MAYBEDEFAULT);
     404          14 :         DECL_BOOL_PROP1(FONT_WORDLINEMODE,                  MAYBEDEFAULT);
     405          14 :         DECL_PROP3(TEXTLINECOLOR,       sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID);
     406          14 :         DECL_PROP2(FONTEMPHASISMARK,    sal_Int16,          BOUND, MAYBEDEFAULT);
     407          14 :         DECL_PROP2(FONTRELIEF,          sal_Int16,          BOUND, MAYBEDEFAULT);
     408          14 :         DECL_PROP1(FONT_STRIKEOUT,      sal_Int16,          MAYBEDEFAULT);
     409          14 :         DECL_PROP2(RECORDMARKER,        sal_Bool,           BOUND, MAYBEDEFAULT );
     410          14 :         DECL_PROP2(PRINTABLE,           sal_Bool,           BOUND, MAYBEDEFAULT );
     411          14 :         DECL_PROP4(CURSORCOLOR,         sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT);
     412          14 :         DECL_PROP3(ALWAYSSHOWCURSOR,    sal_Bool,           BOUND, MAYBEDEFAULT, TRANSIENT);
     413          14 :         DECL_PROP3(DISPLAYSYNCHRON,     sal_Bool,           BOUND, MAYBEDEFAULT, TRANSIENT);
     414          14 :         DECL_PROP2(HELPURL,             OUString,    BOUND, MAYBEDEFAULT);
     415          14 :         DECL_PROP2(WRITING_MODE,        sal_Int16,          BOUND, MAYBEDEFAULT);
     416          14 :         DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16,          BOUND, MAYBEDEFAULT, TRANSIENT);
     417             :     END_DESCRIBE_PROPERTIES();
     418          14 : }
     419        1913 : void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
     420             : {
     421        1913 :     switch (nHandle)
     422             :     {
     423             :         case PROPERTY_ID_CONTEXT_WRITING_MODE:
     424          58 :             rValue <<= m_nContextWritingMode;
     425          58 :             break;
     426             :         case PROPERTY_ID_WRITING_MODE:
     427          58 :             rValue <<= m_nWritingMode;
     428          58 :             break;
     429             :         case PROPERTY_ID_HELPTEXT:
     430          61 :             rValue <<= m_sHelpText;
     431          61 :             break;
     432             :         case PROPERTY_ID_HELPURL:
     433          51 :             rValue <<= m_sHelpURL;
     434          51 :             break;
     435             :         case PROPERTY_ID_DISPLAYSYNCHRON:
     436          58 :             setBOOL(rValue, m_bDisplaySynchron);
     437          58 :             break;
     438             :         case PROPERTY_ID_ALWAYSSHOWCURSOR:
     439          61 :             setBOOL(rValue, m_bAlwaysShowCursor);
     440          61 :             break;
     441             :         case PROPERTY_ID_CURSORCOLOR:
     442          25 :             rValue = m_aCursorColor;
     443          25 :             break;
     444             :         case PROPERTY_ID_PRINTABLE:
     445          58 :             setBOOL(rValue, m_bPrintable);
     446          58 :             break;
     447             :         case PROPERTY_ID_TABSTOP:
     448          26 :             rValue = m_aTabStop;
     449          26 :             break;
     450             :         case PROPERTY_ID_HASNAVIGATION:
     451          58 :             setBOOL(rValue, m_bNavigation);
     452          58 :             break;
     453             :         case PROPERTY_ID_RECORDMARKER:
     454          58 :             setBOOL(rValue, m_bRecordMarker);
     455          58 :             break;
     456             :         case PROPERTY_ID_ENABLED:
     457          60 :             setBOOL(rValue, m_bEnable);
     458          60 :             break;
     459             :         case PROPERTY_ID_ENABLEVISIBLE:
     460          58 :             setBOOL(rValue, m_bEnableVisible);
     461          58 :             break;
     462             :         case PROPERTY_ID_BORDER:
     463          80 :             rValue <<= (sal_Int16)m_nBorder;
     464          80 :             break;
     465             :         case PROPERTY_ID_BORDERCOLOR:
     466          26 :             rValue <<= m_aBorderColor;
     467          26 :             break;
     468             :         case PROPERTY_ID_DEFAULTCONTROL:
     469          70 :             rValue <<= m_aDefaultControl;
     470          70 :             break;
     471             :         case PROPERTY_ID_BACKGROUNDCOLOR:
     472          25 :             rValue = m_aBackgroundColor;
     473          25 :             break;
     474             :         case PROPERTY_ID_ROWHEIGHT:
     475          51 :             rValue = m_aRowHeight;
     476          51 :             break;
     477             :         default:
     478         971 :             if ( isFontRelatedProperty( nHandle ) )
     479         496 :                 FontControlModel::getFastPropertyValue( rValue, nHandle );
     480             :             else
     481         475 :                 OControlModel::getFastPropertyValue( rValue, nHandle );
     482             :     }
     483        1913 : }
     484         582 : sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
     485             :                                                     sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
     486             : {
     487         582 :     sal_Bool bModified(sal_False);
     488         582 :     switch (nHandle)
     489             :     {
     490             :         case PROPERTY_ID_CONTEXT_WRITING_MODE:
     491          46 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nContextWritingMode );
     492          46 :             break;
     493             :         case PROPERTY_ID_WRITING_MODE:
     494          26 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nWritingMode );
     495          26 :             break;
     496             :         case PROPERTY_ID_HELPTEXT:
     497          29 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpText);
     498          28 :             break;
     499             :         case PROPERTY_ID_HELPURL:
     500          22 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpURL);
     501          22 :             break;
     502             :         case PROPERTY_ID_DISPLAYSYNCHRON:
     503          26 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bDisplaySynchron);
     504          26 :             break;
     505             :         case PROPERTY_ID_ALWAYSSHOWCURSOR:
     506          27 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAlwaysShowCursor);
     507          27 :             break;
     508             :         case PROPERTY_ID_CURSORCOLOR:
     509           0 :             if (!rValue.hasValue() || !m_aCursorColor.hasValue())
     510             :             {
     511           0 :                 if (rValue.hasValue() && (TypeClass_LONG != rValue.getValueType().getTypeClass()))
     512             :                 {
     513           0 :                     throw IllegalArgumentException();
     514             :                 }
     515           0 :                 rOldValue = m_aCursorColor;
     516           0 :                 rConvertedValue = rValue;
     517           0 :                 bModified = (rOldValue.getValue() != rConvertedValue.getValue());
     518             :             }
     519             :             else
     520           0 :                 bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getINT32(m_aCursorColor));
     521           0 :             break;
     522             :         case PROPERTY_ID_PRINTABLE:
     523          26 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bPrintable);
     524          26 :             break;
     525             :         case PROPERTY_ID_TABSTOP:
     526           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTabStop, ::getBooleanCppuType());
     527           0 :             break;
     528             :         case PROPERTY_ID_HASNAVIGATION:
     529          26 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bNavigation);
     530          26 :             break;
     531             :         case PROPERTY_ID_RECORDMARKER:
     532          26 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRecordMarker);
     533          26 :             break;
     534             :         case PROPERTY_ID_ENABLED:
     535          27 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable);
     536          27 :             break;
     537             :         case PROPERTY_ID_ENABLEVISIBLE:
     538          26 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnableVisible);
     539          26 :             break;
     540             :         case PROPERTY_ID_BORDER:
     541          28 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder);
     542          28 :             break;
     543             :         case PROPERTY_ID_BORDERCOLOR:
     544           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBorderColor, ::getCppuType((const sal_Int32*)NULL));
     545           0 :             break;
     546             :         case PROPERTY_ID_DEFAULTCONTROL:
     547          37 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultControl);
     548          37 :             break;
     549             :         case PROPERTY_ID_BACKGROUNDCOLOR:
     550           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBackgroundColor, ::getCppuType((const sal_Int32*)NULL));
     551           0 :             break;
     552             :         case PROPERTY_ID_ROWHEIGHT:
     553             :             {
     554           1 :                 bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRowHeight, ::getCppuType((const sal_Int32*)NULL));
     555           1 :                 sal_Int32 nNewVal( 0 );
     556           1 :                 if ( ( rConvertedValue >>= nNewVal ) && ( nNewVal <= 0 ) )
     557             :                 {
     558           0 :                     rConvertedValue.clear();
     559           0 :                     bModified = m_aRowHeight.hasValue();
     560             :                 }
     561             :             }
     562           1 :             break;
     563             :         default:
     564         209 :             if ( isFontRelatedProperty( nHandle ) )
     565         112 :                 bModified = FontControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
     566             :             else
     567          97 :                 bModified = OControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue);
     568             :     }
     569         581 :     return bModified;
     570             : }
     571         213 : void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw ( ::com::sun::star::uno::Exception, std::exception)
     572             : {
     573         213 :     switch (nHandle)
     574             :     {
     575             :         case PROPERTY_ID_CONTEXT_WRITING_MODE:
     576          18 :             rValue >>= m_nContextWritingMode;
     577          18 :             break;
     578             :         case PROPERTY_ID_WRITING_MODE:
     579           8 :             rValue >>= m_nWritingMode;
     580           8 :             break;
     581             :         case PROPERTY_ID_HELPTEXT:
     582          10 :             rValue >>= m_sHelpText;
     583          10 :             break;
     584             :         case PROPERTY_ID_HELPURL:
     585           4 :             rValue >>= m_sHelpURL;
     586           4 :             break;
     587             :         case PROPERTY_ID_DISPLAYSYNCHRON:
     588           8 :             m_bDisplaySynchron = getBOOL(rValue);
     589           8 :             break;
     590             :         case PROPERTY_ID_ALWAYSSHOWCURSOR:
     591           8 :             m_bAlwaysShowCursor = getBOOL(rValue);
     592           8 :             break;
     593             :         case PROPERTY_ID_CURSORCOLOR:
     594           0 :             m_aCursorColor = rValue;
     595           0 :             break;
     596             :         case PROPERTY_ID_PRINTABLE:
     597           8 :             m_bPrintable = getBOOL(rValue);
     598           8 :             break;
     599             :         case PROPERTY_ID_TABSTOP:
     600           0 :             m_aTabStop = rValue;
     601           0 :             break;
     602             :         case PROPERTY_ID_HASNAVIGATION:
     603           8 :             m_bNavigation = getBOOL(rValue);
     604           8 :             break;
     605             :         case PROPERTY_ID_ENABLED:
     606           9 :             m_bEnable = getBOOL(rValue);
     607           9 :             break;
     608             :         case PROPERTY_ID_ENABLEVISIBLE:
     609           8 :             m_bEnableVisible = getBOOL(rValue);
     610           8 :             break;
     611             :         case PROPERTY_ID_RECORDMARKER:
     612           8 :             m_bRecordMarker = getBOOL(rValue);
     613           8 :             break;
     614             :         case PROPERTY_ID_BORDER:
     615          10 :             rValue >>= m_nBorder;
     616          10 :             break;
     617             :         case PROPERTY_ID_BORDERCOLOR:
     618           0 :             m_aBorderColor = rValue;
     619           0 :             break;
     620             :         case PROPERTY_ID_DEFAULTCONTROL:
     621           9 :             rValue >>= m_aDefaultControl;
     622           9 :             break;
     623             :         case PROPERTY_ID_BACKGROUNDCOLOR:
     624           0 :             m_aBackgroundColor = rValue;
     625           0 :             break;
     626             :         case PROPERTY_ID_ROWHEIGHT:
     627           0 :             m_aRowHeight = rValue;
     628           0 :             break;
     629             :         default:
     630          97 :             if ( isFontRelatedProperty( nHandle ) )
     631             :             {
     632             :                 FontControlModel::setFastPropertyValue_NoBroadcast_impl(
     633             :                     *this, &OGridControlModel::setDependentFastPropertyValue,
     634          54 :                     nHandle, rValue);
     635             :             }
     636             :             else
     637          43 :                 OControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     638             :     }
     639         213 : }
     640             : 
     641             : //XPropertyState
     642           4 : Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
     643             : {
     644           4 :     Any aReturn;
     645           4 :     switch (nHandle)
     646             :     {
     647             :         case PROPERTY_ID_CONTEXT_WRITING_MODE:
     648             :         case PROPERTY_ID_WRITING_MODE:
     649           0 :             aReturn <<= WritingMode2::CONTEXT;
     650           0 :             break;
     651             :         case PROPERTY_ID_DEFAULTCONTROL:
     652           0 :             aReturn <<= OUString( STARDIV_ONE_FORM_CONTROL_GRID  );
     653           0 :             break;
     654             :         case PROPERTY_ID_PRINTABLE:
     655             :         case PROPERTY_ID_HASNAVIGATION:
     656             :         case PROPERTY_ID_RECORDMARKER:
     657             :         case PROPERTY_ID_DISPLAYSYNCHRON:
     658             :         case PROPERTY_ID_ENABLED:
     659             :         case PROPERTY_ID_ENABLEVISIBLE:
     660           0 :             aReturn = makeBoolAny(true);
     661           0 :             break;
     662             :         case PROPERTY_ID_ALWAYSSHOWCURSOR:
     663           4 :             aReturn = makeBoolAny(false);
     664           4 :             break;
     665             :         case PROPERTY_ID_HELPURL:
     666             :         case PROPERTY_ID_HELPTEXT:
     667           0 :             aReturn <<= OUString();
     668           0 :             break;
     669             :         case PROPERTY_ID_BORDER:
     670           0 :             aReturn <<= (sal_Int16)1;
     671           0 :             break;
     672             :         case PROPERTY_ID_BORDERCOLOR:
     673             :         case PROPERTY_ID_TABSTOP:
     674             :         case PROPERTY_ID_BACKGROUNDCOLOR:
     675             :         case PROPERTY_ID_ROWHEIGHT:
     676             :         case PROPERTY_ID_CURSORCOLOR:
     677             :             // void
     678           0 :             break;
     679             :         default:
     680           0 :             if ( isFontRelatedProperty( nHandle ) )
     681           0 :                 aReturn = FontControlModel::getPropertyDefaultByHandle( nHandle );
     682             :             else
     683           0 :                 aReturn = OControlModel::getPropertyDefaultByHandle(nHandle);
     684             :     }
     685           4 :     return aReturn;
     686             : }
     687             : 
     688          62 : OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const
     689             : {
     690          62 :     OGridColumn* pImplementation = NULL;
     691          62 :     Reference< XUnoTunnel > xUnoTunnel( _rxIFace, UNO_QUERY );
     692          62 :     if ( xUnoTunnel.is() )
     693          59 :         pImplementation = reinterpret_cast<OGridColumn*>(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId()));
     694          62 :     return pImplementation;
     695             : }
     696             : 
     697          55 : void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn )
     698             : {
     699          55 :     Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
     700          55 :     if ( xBroadcaster.is() )
     701          14 :         xBroadcaster->addSQLErrorListener( this );
     702          55 : }
     703             : 
     704          10 : void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn)
     705             : {
     706          10 :     if ( m_xSelection == _rxColumn )
     707             :     {   // the currently selected element was replaced
     708           0 :         m_xSelection.clear();
     709           0 :         EventObject aEvt( static_cast< XWeak* >( this ) );
     710           0 :         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt );
     711             :     }
     712          10 :     Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
     713          10 :     if ( xBroadcaster.is() )
     714           0 :         xBroadcaster->removeSQLErrorListener( this );
     715          10 : }
     716             : 
     717           4 : void OGridControlModel::implRemoved(const InterfaceRef& _rxObject)
     718             : {
     719           4 :     OInterfaceContainer::implRemoved(_rxObject);
     720           4 :     lostColumn(_rxObject);
     721           4 : }
     722             : 
     723          49 : void OGridControlModel::implInserted( const ElementDescription* _pElement )
     724             : {
     725          49 :     OInterfaceContainer::implInserted( _pElement );
     726          49 :     gotColumn( _pElement->xInterface );
     727          49 : }
     728             : 
     729           6 : void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock )
     730             : {
     731           6 :     Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY );
     732          12 :     Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY );
     733           6 :     bool bNewSelection = ( xOldColumn == m_xSelection );
     734           6 :     lostColumn( xOldColumn );
     735           6 :     gotColumn( xNewColumn );
     736           6 :     if ( bNewSelection )
     737           0 :         m_xSelection.set( xNewColumn, UNO_QUERY );
     738           6 :     OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock );
     739             :     // < SYNCHRONIZED
     740           6 :     if ( bNewSelection )
     741             :     {
     742           0 :         m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
     743           6 :     }
     744           6 : }
     745             : 
     746          58 : ElementDescription* OGridControlModel::createElementMetaData( )
     747             : {
     748          58 :     return new ColumnDescription;
     749             : }
     750             : 
     751          58 : void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement )
     752             : {
     753          58 :     OGridColumn* pCol = getColumnImplementation( _rxObject );
     754          58 :     if ( !pCol )
     755           3 :         throw IllegalArgumentException();
     756          55 :     OInterfaceContainer::approveNewElement( _rxObject, _pElement );
     757             :     // if we're here, the object passed all tests
     758          55 :     if ( _pElement )
     759          55 :         static_cast< ColumnDescription* >( _pElement )->pColumn = pCol;
     760          55 : }
     761             : 
     762             : // XPersistObject
     763           1 : OUString SAL_CALL OGridControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     764             : {
     765           1 :     return OUString(FRM_COMPONENT_GRID);  // old (non-sun) name for compatibility!
     766             : }
     767             : 
     768           1 : void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
     769             : {
     770           1 :     OControlModel::write(_rxOutStream);
     771           1 :     Reference<XMarkableStream>  xMark(_rxOutStream, UNO_QUERY);
     772             :     // 1. Version
     773           1 :     _rxOutStream->writeShort(0x0008);
     774             :     // 2. Columns
     775           1 :     sal_Int32 nLen = getCount();
     776           1 :     _rxOutStream->writeLong(nLen);
     777             :     OGridColumn* pCol;
     778           3 :     for (sal_Int32 i = 0; i < nLen; i++)
     779             :     {
     780             :         // first the service name for the unerlying model
     781           2 :         pCol = getColumnImplementation(m_aItems[i]);
     782             :         DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !");
     783           2 :         _rxOutStream << pCol->getModelName();
     784             :         // then the object itself
     785           2 :         sal_Int32 nMark = xMark->createMark();
     786           2 :         sal_Int32 nObjLen = 0;
     787           2 :         _rxOutStream->writeLong(nObjLen);
     788             :         // writing the column
     789           2 :         pCol->write(_rxOutStream);
     790             :         // determining the length
     791           2 :         nObjLen = xMark->offsetToMark(nMark) - 4;
     792           2 :         xMark->jumpToMark(nMark);
     793           2 :         _rxOutStream->writeLong(nObjLen);
     794           2 :         xMark->jumpToFurthest();
     795           2 :         xMark->deleteMark(nMark);
     796             :     }
     797             :     // 3. Events
     798           1 :     writeEvents(_rxOutStream);
     799             :     // 4. Attributes
     800             :     // Masking for all 'any' types
     801           1 :     sal_uInt16 nAnyMask = 0;
     802           1 :     if (m_aRowHeight.getValueType().getTypeClass() == TypeClass_LONG)
     803           0 :         nAnyMask |= ROWHEIGHT;
     804           1 :     if ( getFont() != getDefaultFont() )
     805           1 :         nAnyMask |= FONTATTRIBS | FONTSIZE | FONTTYPE | FONTDESCRIPTOR;
     806           1 :     if (m_aTabStop.getValueType().getTypeClass() == TypeClass_BOOLEAN)
     807           0 :         nAnyMask |= TABSTOP;
     808           1 :     if ( hasTextColor() )
     809           0 :         nAnyMask |= TEXTCOLOR;
     810           1 :     if (m_aBackgroundColor.getValueType().getTypeClass() == TypeClass_LONG)
     811           0 :         nAnyMask |= BACKGROUNDCOLOR;
     812           1 :     if (!m_bRecordMarker)
     813           0 :         nAnyMask |= RECORDMARKER;
     814           1 :     _rxOutStream->writeShort(nAnyMask);
     815           1 :     if (nAnyMask & ROWHEIGHT)
     816           0 :         _rxOutStream->writeLong(getINT32(m_aRowHeight));
     817             :     // old structures
     818           1 :     const FontDescriptor& aFont = getFont();
     819           1 :     if ( nAnyMask & FONTDESCRIPTOR )
     820             :     {
     821             :         // Attrib
     822           1 :         _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWeight( aFont.Weight ) ) );
     823           1 :         _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( aFont.Slant ) );
     824           1 :         _rxOutStream->writeShort( aFont.Underline );
     825           1 :         _rxOutStream->writeShort( aFont.Strikeout );
     826           1 :         _rxOutStream->writeShort( sal_Int16(aFont.Orientation * 10) );
     827           1 :         _rxOutStream->writeBoolean( aFont.Kerning );
     828           1 :         _rxOutStream->writeBoolean( aFont.WordLineMode );
     829             :         // Size
     830           1 :         _rxOutStream->writeLong( aFont.Width );
     831           1 :         _rxOutStream->writeLong( aFont.Height );
     832           1 :         _rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWidth( aFont.CharacterWidth ) ) );
     833             :         // Type
     834           1 :         _rxOutStream->writeUTF( aFont.Name );
     835           1 :         _rxOutStream->writeUTF( aFont.StyleName );
     836           1 :         _rxOutStream->writeShort( aFont.Family );
     837           1 :         _rxOutStream->writeShort( aFont.CharSet );
     838           1 :         _rxOutStream->writeShort( aFont.Pitch );
     839             :     }
     840           1 :     _rxOutStream << m_aDefaultControl;
     841           1 :     _rxOutStream->writeShort(m_nBorder);
     842           1 :     _rxOutStream->writeBoolean(m_bEnable);
     843           1 :     if (nAnyMask & TABSTOP)
     844           0 :         _rxOutStream->writeBoolean(getBOOL(m_aTabStop));
     845           1 :     _rxOutStream->writeBoolean(m_bNavigation);
     846           1 :     if (nAnyMask & TEXTCOLOR)
     847           0 :         _rxOutStream->writeLong( getTextColor() );
     848             :     // new since version 6
     849           1 :     _rxOutStream << m_sHelpText;
     850           1 :     if (nAnyMask & FONTDESCRIPTOR)
     851           1 :         _rxOutStream << getFont();
     852           1 :     if (nAnyMask & RECORDMARKER)
     853           0 :         _rxOutStream->writeBoolean(m_bRecordMarker);
     854             :     // new since version 7
     855           1 :     _rxOutStream->writeBoolean(m_bPrintable);
     856             :     // new since version 8
     857           1 :     if (nAnyMask & BACKGROUNDCOLOR)
     858           0 :         _rxOutStream->writeLong(getINT32(m_aBackgroundColor));
     859           1 : }
     860             : 
     861           1 : void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
     862             : {
     863           1 :     SolarMutexGuard g;
     864           1 :     OControlModel::read(_rxInStream);
     865           2 :     Reference<XMarkableStream>  xMark(_rxInStream, UNO_QUERY);
     866             :     // 1. version
     867           1 :     sal_Int16 nVersion = _rxInStream->readShort();
     868             :     // 2. reading the columns
     869           1 :     sal_Int32 nLen = _rxInStream->readLong();
     870           1 :     if (nLen)
     871             :     {
     872           3 :         for (sal_Int32 i = 0; i < nLen; i++)
     873             :         {
     874             :             // reading the model names
     875           2 :             OUString sModelName;
     876           2 :             _rxInStream >> sModelName;
     877           4 :             Reference<XPropertySet>  xCol(createColumn(getColumnTypeByModelName(sModelName)));
     878             :             DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !");
     879           2 :             sal_Int32 nObjLen = _rxInStream->readLong();
     880           2 :             if (nObjLen)
     881             :             {
     882           2 :                 sal_Int32 nMark = xMark->createMark();
     883           2 :                 if (xCol.is())
     884             :                 {
     885           2 :                     OGridColumn* pCol = getColumnImplementation(xCol);
     886           2 :                     pCol->read(_rxInStream);
     887             :                 }
     888           2 :                 xMark->jumpToMark(nMark);
     889           2 :                 _rxInStream->skipBytes(nObjLen);
     890           2 :                 xMark->deleteMark(nMark);
     891             :             }
     892           2 :             if ( xCol.is() )
     893           2 :                 implInsert( i, xCol, sal_False, NULL, sal_False );
     894           2 :         }
     895             :     }
     896             :     // In the base implementation events are only read, elements in the container exist
     897             :     // but since before TF_ONE for the GridControl events were always written, so they
     898             :     // need to be read, too
     899           1 :     sal_Int32 nObjLen = _rxInStream->readLong();
     900           1 :     if (nObjLen)
     901             :     {
     902           1 :         sal_Int32 nMark = xMark->createMark();
     903           1 :         Reference<XPersistObject>  xObj(m_xEventAttacher, UNO_QUERY);
     904           1 :         if (xObj.is())
     905           1 :             xObj->read(_rxInStream);
     906           1 :         xMark->jumpToMark(nMark);
     907           1 :         _rxInStream->skipBytes(nObjLen);
     908           1 :         xMark->deleteMark(nMark);
     909             :     }
     910             :     // reading the attachement
     911           3 :     for (sal_Int32 i = 0; i < nLen; i++)
     912             :     {
     913           2 :         InterfaceRef  xIfc(m_aItems[i], UNO_QUERY);
     914           4 :         Reference<XPropertySet>  xSet(xIfc, UNO_QUERY);
     915           4 :         Any aHelper;
     916           2 :         aHelper <<= xSet;
     917           2 :         m_xEventAttacher->attach( i, xIfc, aHelper );
     918           2 :     }
     919             :     // 4. reading the attributes
     920           1 :     if (nVersion == 1)
     921           1 :         return;
     922             :     // Masking for any
     923           1 :     sal_uInt16 nAnyMask = _rxInStream->readShort();
     924           1 :     if (nAnyMask & ROWHEIGHT)
     925             :     {
     926           0 :         sal_Int32 nValue = _rxInStream->readLong();
     927           0 :         m_aRowHeight <<= (sal_Int32)nValue;
     928             :     }
     929           2 :     FontDescriptor aFont( getFont() );
     930           1 :     if ( nAnyMask & FONTATTRIBS )
     931             :     {
     932           1 :         aFont.Weight = (float)VCLUnoHelper::ConvertFontWeight( _rxInStream->readShort() );
     933           1 :         aFont.Slant = (FontSlant)_rxInStream->readShort();
     934           1 :         aFont.Underline = _rxInStream->readShort();
     935           1 :         aFont.Strikeout = _rxInStream->readShort();
     936           1 :         aFont.Orientation = ( (float)_rxInStream->readShort() ) / 10;
     937           1 :         aFont.Kerning = _rxInStream->readBoolean();
     938           1 :         aFont.WordLineMode = _rxInStream->readBoolean();
     939             :     }
     940           1 :     if ( nAnyMask & FONTSIZE )
     941             :     {
     942           1 :         aFont.Width = (sal_Int16)_rxInStream->readLong();
     943           1 :         aFont.Height = (sal_Int16)_rxInStream->readLong();
     944           1 :         aFont.CharacterWidth = (float)VCLUnoHelper::ConvertFontWidth( _rxInStream->readShort() );
     945             :     }
     946           1 :     if ( nAnyMask & FONTTYPE )
     947             :     {
     948           1 :         aFont.Name = _rxInStream->readUTF();
     949           1 :         aFont.StyleName = _rxInStream->readUTF();
     950           1 :         aFont.Family = _rxInStream->readShort();
     951           1 :         aFont.CharSet = _rxInStream->readShort();
     952           1 :         aFont.Pitch = _rxInStream->readShort();
     953             :     }
     954           1 :     if ( nAnyMask & ( FONTATTRIBS | FONTSIZE | FONTTYPE ) )
     955           1 :         setFont( aFont );
     956             :     // Name
     957           1 :     _rxInStream >> m_aDefaultControl;
     958           1 :     m_nBorder = _rxInStream->readShort();
     959           1 :     m_bEnable = _rxInStream->readBoolean();
     960           1 :     if (nAnyMask & TABSTOP)
     961             :     {
     962           0 :         m_aTabStop = makeBoolAny(_rxInStream->readBoolean() != 0);
     963             :     }
     964           1 :     if (nVersion > 3)
     965           1 :         m_bNavigation = _rxInStream->readBoolean();
     966           1 :     if (nAnyMask & TEXTCOLOR)
     967             :     {
     968           0 :         sal_Int32 nValue = _rxInStream->readLong();
     969           0 :         setTextColor( (sal_Int32)nValue );
     970             :     }
     971             :     // new since version 6
     972           1 :     if (nVersion > 5)
     973           1 :         _rxInStream >> m_sHelpText;
     974           1 :     if (nAnyMask & FONTDESCRIPTOR)
     975             :     {
     976           1 :         FontDescriptor aUNOFont;
     977           1 :         _rxInStream >> aUNOFont;
     978           1 :         setFont( aFont );
     979             :     }
     980           1 :     if (nAnyMask & RECORDMARKER)
     981           0 :         m_bRecordMarker = _rxInStream->readBoolean();
     982             :     // new since version 7
     983           1 :     if (nVersion > 6)
     984           1 :         m_bPrintable = _rxInStream->readBoolean();
     985           1 :     if (nAnyMask & BACKGROUNDCOLOR)
     986             :     {
     987           0 :         sal_Int32 nValue = _rxInStream->readLong();
     988           0 :         m_aBackgroundColor <<= (sal_Int32)nValue;
     989           1 :     }
     990             : }
     991             : }
     992             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10