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

Generated by: LCOV version 1.10