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

Generated by: LCOV version 1.10