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

Generated by: LCOV version 1.11