Files
libreoffice/forms/source/component/Grid.cxx
Release Engineers 7d3b6d29c0 CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs  r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs  r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs  r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs  r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
  fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc  r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc  r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs  r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj  r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj  r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj  r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj  r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs  r272983 : added since tag
2009-06-15 12:11:39 +0200 oj  r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs  r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs  r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs  r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs  r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs  r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs  r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs  r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj  r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs  r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj  r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs  r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj  r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj  r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj  r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj  r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj  r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj  r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj  r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj  r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj  r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs  r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs  r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs  r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs  r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs  r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs  r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs  r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs  r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs  r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs  r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs  r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs  r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs  r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs  r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs  r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs  r272210 : grammar
2009-05-22 21:36:10 +0200 fs  r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs  r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs  r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs  r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs  r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs  r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs  r271937 : includes
2009-05-15 13:39:22 +0200 fs  r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs  r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs  r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs  r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs  r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs  r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs  r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs  r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs  r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs  r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs  r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj  r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs  r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj  r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs  r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs  r271366 : #i101308#
2009-07-03 14:21:50 +00:00

1167 lines
43 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: Grid.cxx,v $
* $Revision: 1.43 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_forms.hxx"
#include "Columns.hxx"
#include "findpos.hxx"
#include "Grid.hxx"
#include "property.hrc"
#include "property.hxx"
#include "services.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/form/FormComponentType.hpp>
#include <com/sun/star/form/XForm.hpp>
#include <com/sun/star/form/XLoadable.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
/** === end UNO includes === **/
#include <comphelper/basicio.hxx>
#include <comphelper/container.hxx>
#include <comphelper/extract.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/svapp.hxx>
using namespace ::com::sun::star::uno;
//.........................................................................
namespace frm
{
//.........................................................................
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::view;
namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
const sal_uInt16 ROWHEIGHT = 0x0001;
const sal_uInt16 FONTTYPE = 0x0002;
const sal_uInt16 FONTSIZE = 0x0004;
const sal_uInt16 FONTATTRIBS = 0x0008;
const sal_uInt16 TABSTOP = 0x0010;
const sal_uInt16 TEXTCOLOR = 0x0020;
const sal_uInt16 FONTDESCRIPTOR = 0x0040;
const sal_uInt16 RECORDMARKER = 0x0080;
const sal_uInt16 BACKGROUNDCOLOR = 0x0100;
//------------------------------------------------------------------
InterfaceRef SAL_CALL OGridControlModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
{
return *(new OGridControlModel(_rxFactory));
}
DBG_NAME(OGridControlModel);
//------------------------------------------------------------------
OGridControlModel::OGridControlModel(const Reference<XMultiServiceFactory>& _rxFactory)
:OControlModel(_rxFactory, ::rtl::OUString())
,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL)))
,OErrorBroadcaster( OComponentHelper::rBHelper )
,FontControlModel( false )
,m_aSelectListeners(m_aMutex)
,m_aResetListeners(m_aMutex)
,m_aRowSetChangeListeners(m_aMutex)
,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL )
,m_nBorder(1)
,m_nWritingMode( WritingMode2::CONTEXT )
,m_nContextWritingMode( WritingMode2::CONTEXT )
,m_bEnableVisible(sal_True)
,m_bEnable(sal_True)
,m_bNavigation(sal_True)
,m_bRecordMarker(sal_True)
,m_bPrintable(sal_True)
,m_bAlwaysShowCursor(sal_False)
,m_bDisplaySynchron(sal_True)
{
DBG_CTOR(OGridControlModel,NULL);
m_nClassId = FormComponentType::GRIDCONTROL;
}
//------------------------------------------------------------------
OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const Reference< XMultiServiceFactory >& _rxFactory )
:OControlModel( _pOriginal, _rxFactory )
,OInterfaceContainer( _rxFactory, m_aMutex, ::getCppuType( static_cast<Reference<XPropertySet>*>( NULL ) ) )
,OErrorBroadcaster( OComponentHelper::rBHelper )
,FontControlModel( _pOriginal )
,m_aSelectListeners( m_aMutex )
,m_aResetListeners( m_aMutex )
,m_aRowSetChangeListeners( m_aMutex )
{
DBG_CTOR(OGridControlModel,NULL);
m_aDefaultControl = _pOriginal->m_aDefaultControl;
m_bEnable = _pOriginal->m_bEnable;
m_bEnableVisible = _pOriginal->m_bEnableVisible;
m_bNavigation = _pOriginal->m_bNavigation;
m_nBorder = _pOriginal->m_nBorder;
m_nWritingMode = _pOriginal->m_nWritingMode;
m_nContextWritingMode = _pOriginal->m_nContextWritingMode;
m_bRecordMarker = _pOriginal->m_bRecordMarker;
m_bPrintable = _pOriginal->m_bPrintable;
m_bAlwaysShowCursor = _pOriginal->m_bAlwaysShowCursor;
m_bDisplaySynchron = _pOriginal->m_bDisplaySynchron;
// clone the columns
cloneColumns( _pOriginal );
// TODO: clone the events?
}
//------------------------------------------------------------------
OGridControlModel::~OGridControlModel()
{
if (!OComponentHelper::rBHelper.bDisposed)
{
acquire();
dispose();
}
DBG_DTOR(OGridControlModel,NULL);
}
// XCloneable
//------------------------------------------------------------------------------
Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException)
{
OGridControlModel* pClone = new OGridControlModel( this, getContext().getLegacyServiceFactory() );
osl_incrementInterlockedCount( &pClone->m_refCount );
pClone->OControlModel::clonedFrom( this );
// do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is
// already done in the ctor
//pClone->OInterfaceContainer::clonedFrom( *this );
osl_decrementInterlockedCount( &pClone->m_refCount );
return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) );
}
//------------------------------------------------------------------------------
void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer )
{
try
{
Reference< XCloneable > xColCloneable;
const OInterfaceArray::const_iterator pColumnStart = _pOriginalContainer->m_aItems.begin();
const OInterfaceArray::const_iterator pColumnEnd = _pOriginalContainer->m_aItems.end();
for ( OInterfaceArray::const_iterator pColumn = pColumnStart; pColumn != pColumnEnd; ++pColumn )
{
// ask the col for a factory for the clone
xColCloneable = xColCloneable.query( *pColumn );
DBG_ASSERT( xColCloneable.is(), "OGridControlModel::cloneColumns: column is not cloneable!" );
if ( xColCloneable.is() )
{
// create a clone of the column
Reference< XCloneable > xColClone( xColCloneable->createClone() );
DBG_ASSERT( xColClone.is(), "OGridControlModel::cloneColumns: invalid column clone!" );
if ( xColClone.is() )
{
// insert this clone into our own container
insertByIndex( pColumn - pColumnStart, xColClone->queryInterface( m_aElementType ) );
}
}
}
}
catch( const Exception& )
{
DBG_ERROR( "OGridControlModel::cloneColumns: caught an exception while cloning the columns!" );
}
}
// XServiceInfo
//------------------------------------------------------------------------------
StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException)
{
StringSequence aSupported = OControlModel::getSupportedServiceNames();
aSupported.realloc(aSupported.getLength() + 2);
::rtl::OUString*pArray = aSupported.getArray();
pArray[aSupported.getLength()-2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel"));
pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL;
return aSupported;
}
//------------------------------------------------------------------------------
Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) throw (RuntimeException)
{
Any aReturn = OGridControlModel_BASE::queryInterface(_rType);
if ( !aReturn.hasValue() )
{
aReturn = OControlModel::queryAggregation( _rType );
if ( !aReturn.hasValue() )
{
aReturn = OInterfaceContainer::queryInterface( _rType );
if ( !aReturn.hasValue() )
aReturn = OErrorBroadcaster::queryInterface( _rType );
}
}
return aReturn;
}
// XSQLErrorListener
//------------------------------------------------------------------------------
void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) throw (RuntimeException)
{
// forward the errors which happened to my columns to my own listeners
onError( _rEvent );
}
// XRowSetSupplier
//------------------------------------------------------------------------------
Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet( ) throw (RuntimeException)
{
return Reference< XRowSet >( getParent(), UNO_QUERY );
}
//------------------------------------------------------------------------------
void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException)
{
OSL_ENSURE( false, "OGridControlModel::setRowSet: not supported!" );
}
//--------------------------------------------------------------------
void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException)
{
if ( i_Listener.is() )
m_aRowSetChangeListeners.addInterface( i_Listener );
}
//--------------------------------------------------------------------
void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException)
{
m_aRowSetChangeListeners.removeInterface( i_Listener );
}
// XChild
//------------------------------------------------------------------------------
void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException)
{
::osl::ClearableMutexGuard aGuard( m_aMutex );
if ( i_Parent == getParent() )
return;
OControlModel::setParent( i_Parent );
EventObject aEvent( *this );
aGuard.clear();
m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent );
}
//------------------------------------------------------------------------------
Sequence< Type > SAL_CALL OGridControlModel::getTypes( ) throw(RuntimeException)
{
return concatSequences(
concatSequences(
OControlModel::getTypes(),
OInterfaceContainer::getTypes(),
OErrorBroadcaster::getTypes()
),
OGridControlModel_BASE::getTypes()
);
}
// OComponentHelper
//------------------------------------------------------------------------------
void OGridControlModel::disposing()
{
OControlModel::disposing();
OErrorBroadcaster::disposing();
OInterfaceContainer::disposing();
setParent(NULL);
EventObject aEvt(static_cast<XWeak*>(this));
m_aSelectListeners.disposeAndClear(aEvt);
m_aResetListeners.disposeAndClear(aEvt);
m_aRowSetChangeListeners.disposeAndClear(aEvt);
}
// XEventListener
//------------------------------------------------------------------------------
void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeException )
{
OControlModel::disposing( _rEvent );
OInterfaceContainer::disposing( _rEvent );
}
// XSelectionSupplier
//-----------------------------------------------------------------------------
sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException)
{
::osl::ClearableMutexGuard aGuard( m_aMutex );
Reference<XPropertySet> xSel;
if (rElement.hasValue() && !::cppu::extractInterface(xSel, rElement))
{
throw IllegalArgumentException();
}
InterfaceRef xMe = static_cast<XWeak*>(this);
if (xSel.is())
{
Reference<XChild> xAsChild(xSel, UNO_QUERY);
if (!xAsChild.is() || (xAsChild->getParent() != xMe))
{
throw IllegalArgumentException();
}
}
if ( xSel != m_xSelection )
{
m_xSelection = xSel;
aGuard.clear();
m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
return sal_True;
}
return sal_False;
}
//-----------------------------------------------------------------------------
Any SAL_CALL OGridControlModel::getSelection() throw(RuntimeException)
{
return makeAny(m_xSelection);
}
//-----------------------------------------------------------------------------
void OGridControlModel::addSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException )
{
m_aSelectListeners.addInterface(_rxListener);
}
//-----------------------------------------------------------------------------
void OGridControlModel::removeSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) throw( RuntimeException )
{
m_aSelectListeners.removeInterface(_rxListener);
}
// XGridColumnFactory
//------------------------------------------------------------------------------
Reference<XPropertySet> SAL_CALL OGridControlModel::createColumn(const ::rtl::OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
{
const Sequence< ::rtl::OUString >& rColumnTypes = frm::getColumnTypes();
return createColumn( detail::findPos( ColumnType, rColumnTypes ) );
}
//------------------------------------------------------------------------------
Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) const
{
Reference<XPropertySet> xReturn;
switch (nTypeId)
{
case TYPE_CHECKBOX: xReturn = new CheckBoxColumn( getContext() ); break;
case TYPE_COMBOBOX: xReturn = new ComboBoxColumn( getContext() ); break;
case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn( getContext() ); break;
case TYPE_DATEFIELD: xReturn = new DateFieldColumn( getContext() ); break;
case TYPE_LISTBOX: xReturn = new ListBoxColumn( getContext() ); break;
case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn( getContext() ); break;
case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn( getContext() ); break;
case TYPE_TEXTFIELD: xReturn = new TextFieldColumn( getContext() ); break;
case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn( getContext() ); break;
case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn( getContext() ); break;
default:
DBG_ERROR("OGridControlModel::createColumn: Unknown Column");
break;
}
return xReturn;
}
//------------------------------------------------------------------------------
StringSequence SAL_CALL OGridControlModel::getColumnTypes() throw ( ::com::sun::star::uno::RuntimeException)
{
return frm::getColumnTypes();
}
// XReset
//-----------------------------------------------------------------------------
void SAL_CALL OGridControlModel::reset() throw ( ::com::sun::star::uno::RuntimeException)
{
::cppu::OInterfaceIteratorHelper aIter(m_aResetListeners);
EventObject aEvt(static_cast<XWeak*>(this));
sal_Bool bContinue = sal_True;
while (aIter.hasMoreElements() && bContinue)
bContinue =((XResetListener*)aIter.next())->approveReset(aEvt);
if (bContinue)
{
_reset();
m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt );
}
}
//-----------------------------------------------------------------------------
void SAL_CALL OGridControlModel::addResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
{
m_aResetListeners.addInterface(_rxListener);
}
//-----------------------------------------------------------------------------
void SAL_CALL OGridControlModel::removeResetListener(const Reference<XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException)
{
m_aResetListeners.removeInterface(_rxListener);
}
//-----------------------------------------------------------------------------
void OGridControlModel::_reset()
{
Reference<XReset> xReset;
sal_Int32 nCount = getCount();
for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++)
{
getByIndex( nIndex ) >>= xReset;
if (xReset.is())
xReset->reset();
}
}
// XPropertySet
//------------------------------------------------------------------------------
void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
{
BEGIN_DESCRIBE_BASE_PROPERTIES( 37 )
DECL_PROP1(NAME, ::rtl::OUString, BOUND);
DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT);
DECL_PROP1(TAG, ::rtl::OUString, BOUND);
DECL_PROP1(TABINDEX, sal_Int16, BOUND);
DECL_PROP3(TABSTOP, sal_Bool, BOUND, MAYBEDEFAULT, MAYBEVOID);
DECL_PROP2(HASNAVIGATION, sal_Bool, BOUND, MAYBEDEFAULT);
DECL_PROP1(ENABLED, sal_Bool, BOUND);
DECL_PROP2(ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT);
DECL_PROP1(BORDER, sal_Int16, BOUND);
DECL_PROP2(BORDERCOLOR, sal_Int16, BOUND, MAYBEVOID);
DECL_PROP1(DEFAULTCONTROL, ::rtl::OUString, BOUND);
DECL_PROP3(TEXTCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
DECL_PROP3(BACKGROUNDCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
DECL_PROP2(FONT, FontDescriptor, BOUND, MAYBEDEFAULT);
DECL_PROP3(ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
DECL_PROP1(HELPTEXT, ::rtl::OUString, BOUND);
DECL_PROP1(FONT_NAME, ::rtl::OUString, MAYBEDEFAULT);
DECL_PROP1(FONT_STYLENAME, ::rtl::OUString, MAYBEDEFAULT);
DECL_PROP1(FONT_FAMILY, sal_Int16, MAYBEDEFAULT);
DECL_PROP1(FONT_CHARSET, sal_Int16, MAYBEDEFAULT);
DECL_PROP1(FONT_HEIGHT, float, MAYBEDEFAULT);
DECL_PROP1(FONT_WEIGHT, float, MAYBEDEFAULT);
DECL_PROP1(FONT_SLANT, sal_Int16, MAYBEDEFAULT);
DECL_PROP1(FONT_UNDERLINE, sal_Int16, MAYBEDEFAULT);
DECL_BOOL_PROP1(FONT_WORDLINEMODE, MAYBEDEFAULT);
DECL_PROP3(TEXTLINECOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID);
DECL_PROP2(FONTEMPHASISMARK, sal_Int16, BOUND, MAYBEDEFAULT);
DECL_PROP2(FONTRELIEF, sal_Int16, BOUND, MAYBEDEFAULT);
DECL_PROP1(FONT_STRIKEOUT, sal_Int16, MAYBEDEFAULT);
DECL_PROP2(RECORDMARKER, sal_Bool, BOUND, MAYBEDEFAULT );
DECL_PROP2(PRINTABLE, sal_Bool, BOUND, MAYBEDEFAULT );
DECL_PROP4(CURSORCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT);
DECL_PROP3(ALWAYSSHOWCURSOR, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
DECL_PROP3(DISPLAYSYNCHRON, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT);
DECL_PROP2(HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT);
DECL_PROP2(WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT);
DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT);
END_DESCRIBE_PROPERTIES();
}
//------------------------------------------------------------------------------
void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const
{
switch (nHandle)
{
case PROPERTY_ID_CONTEXT_WRITING_MODE:
rValue <<= m_nContextWritingMode;
break;
case PROPERTY_ID_WRITING_MODE:
rValue <<= m_nWritingMode;
break;
case PROPERTY_ID_HELPTEXT:
rValue <<= m_sHelpText;
break;
case PROPERTY_ID_HELPURL:
rValue <<= m_sHelpURL;
break;
case PROPERTY_ID_DISPLAYSYNCHRON:
setBOOL(rValue, m_bDisplaySynchron);
break;
case PROPERTY_ID_ALWAYSSHOWCURSOR:
setBOOL(rValue, m_bAlwaysShowCursor);
break;
case PROPERTY_ID_CURSORCOLOR:
rValue = m_aCursorColor;
break;
case PROPERTY_ID_PRINTABLE:
setBOOL(rValue, m_bPrintable);
break;
case PROPERTY_ID_TABSTOP:
rValue = m_aTabStop;
break;
case PROPERTY_ID_HASNAVIGATION:
setBOOL(rValue, m_bNavigation);
break;
case PROPERTY_ID_RECORDMARKER:
setBOOL(rValue, m_bRecordMarker);
break;
case PROPERTY_ID_ENABLED:
setBOOL(rValue, m_bEnable);
break;
case PROPERTY_ID_ENABLEVISIBLE:
setBOOL(rValue, m_bEnableVisible);
break;
case PROPERTY_ID_BORDER:
rValue <<= (sal_Int16)m_nBorder;
break;
case PROPERTY_ID_BORDERCOLOR:
rValue <<= m_aBorderColor;
break;
case PROPERTY_ID_DEFAULTCONTROL:
rValue <<= m_aDefaultControl;
break;
case PROPERTY_ID_BACKGROUNDCOLOR:
rValue = m_aBackgroundColor;
break;
case PROPERTY_ID_ROWHEIGHT:
rValue = m_aRowHeight;
break;
default:
if ( isFontRelatedProperty( nHandle ) )
FontControlModel::getFastPropertyValue( rValue, nHandle );
else
OControlModel::getFastPropertyValue( rValue, nHandle );
}
}
//------------------------------------------------------------------------------
sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException )
{
sal_Bool bModified(sal_False);
switch (nHandle)
{
case PROPERTY_ID_CONTEXT_WRITING_MODE:
bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nContextWritingMode );
break;
case PROPERTY_ID_WRITING_MODE:
bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_nWritingMode );
break;
case PROPERTY_ID_HELPTEXT:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpText);
break;
case PROPERTY_ID_HELPURL:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sHelpURL);
break;
case PROPERTY_ID_DISPLAYSYNCHRON:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bDisplaySynchron);
break;
case PROPERTY_ID_ALWAYSSHOWCURSOR:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAlwaysShowCursor);
break;
case PROPERTY_ID_CURSORCOLOR:
if (!rValue.hasValue() || !m_aCursorColor.hasValue())
{
if (rValue.hasValue() && (TypeClass_LONG != rValue.getValueType().getTypeClass()))
{
throw IllegalArgumentException();
}
rOldValue = m_aCursorColor;
rConvertedValue = rValue;
bModified = (rOldValue.getValue() != rConvertedValue.getValue());
}
else
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, getINT32(m_aCursorColor));
break;
case PROPERTY_ID_PRINTABLE:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bPrintable);
break;
case PROPERTY_ID_TABSTOP:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTabStop, ::getBooleanCppuType());
break;
case PROPERTY_ID_HASNAVIGATION:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bNavigation);
break;
case PROPERTY_ID_RECORDMARKER:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRecordMarker);
break;
case PROPERTY_ID_ENABLED:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable);
break;
case PROPERTY_ID_ENABLEVISIBLE:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnableVisible);
break;
case PROPERTY_ID_BORDER:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder);
break;
case PROPERTY_ID_BORDERCOLOR:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBorderColor, ::getCppuType((const sal_Int32*)NULL));
break;
case PROPERTY_ID_DEFAULTCONTROL:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultControl);
break;
case PROPERTY_ID_BACKGROUNDCOLOR:
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aBackgroundColor, ::getCppuType((const sal_Int32*)NULL));
break;
case PROPERTY_ID_ROWHEIGHT:
{
bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRowHeight, ::getCppuType((const sal_Int32*)NULL));
sal_Int32 nNewVal( 0 );
if ( ( rConvertedValue >>= nNewVal ) && ( nNewVal <= 0 ) )
{
rConvertedValue.clear();
bModified = m_aRowHeight.hasValue();
}
}
break;
default:
if ( isFontRelatedProperty( nHandle ) )
bModified = FontControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
else
bModified = OControlModel::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue);
}
return bModified;
}
//------------------------------------------------------------------------------
void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw ( ::com::sun::star::uno::Exception)
{
switch (nHandle)
{
case PROPERTY_ID_CONTEXT_WRITING_MODE:
rValue >>= m_nContextWritingMode;
break;
case PROPERTY_ID_WRITING_MODE:
rValue >>= m_nWritingMode;
break;
case PROPERTY_ID_HELPTEXT:
rValue >>= m_sHelpText;
break;
case PROPERTY_ID_HELPURL:
rValue >>= m_sHelpURL;
break;
case PROPERTY_ID_DISPLAYSYNCHRON:
m_bDisplaySynchron = getBOOL(rValue);
break;
case PROPERTY_ID_ALWAYSSHOWCURSOR:
m_bAlwaysShowCursor = getBOOL(rValue);
break;
case PROPERTY_ID_CURSORCOLOR:
m_aCursorColor = rValue;
break;
case PROPERTY_ID_PRINTABLE:
m_bPrintable = getBOOL(rValue);
break;
case PROPERTY_ID_TABSTOP:
m_aTabStop = rValue;
break;
case PROPERTY_ID_HASNAVIGATION:
m_bNavigation = getBOOL(rValue);
break;
case PROPERTY_ID_ENABLED:
m_bEnable = getBOOL(rValue);
break;
case PROPERTY_ID_ENABLEVISIBLE:
m_bEnableVisible = getBOOL(rValue);
break;
case PROPERTY_ID_RECORDMARKER:
m_bRecordMarker = getBOOL(rValue);
break;
case PROPERTY_ID_BORDER:
rValue >>= m_nBorder;
break;
case PROPERTY_ID_BORDERCOLOR:
m_aBorderColor = rValue;
break;
case PROPERTY_ID_DEFAULTCONTROL:
rValue >>= m_aDefaultControl;
break;
case PROPERTY_ID_BACKGROUNDCOLOR:
m_aBackgroundColor = rValue;
break;
case PROPERTY_ID_ROWHEIGHT:
m_aRowHeight = rValue;
break;
default:
if ( isFontRelatedProperty( nHandle ) )
{
FontDescriptor aOldFont( getFont() );
FontControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
if ( isFontAggregateProperty( nHandle ) )
firePropertyChange( PROPERTY_ID_FONT, makeAny( getFont() ), makeAny( aOldFont ) );
}
else
OControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
}
}
//XPropertyState
//------------------------------------------------------------------------------
Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
{
Any aReturn;
switch (nHandle)
{
case PROPERTY_ID_CONTEXT_WRITING_MODE:
case PROPERTY_ID_WRITING_MODE:
aReturn <<= WritingMode2::CONTEXT;
break;
case PROPERTY_ID_DEFAULTCONTROL:
aReturn <<= ::rtl::OUString( STARDIV_ONE_FORM_CONTROL_GRID );
break;
case PROPERTY_ID_PRINTABLE:
case PROPERTY_ID_HASNAVIGATION:
case PROPERTY_ID_RECORDMARKER:
case PROPERTY_ID_DISPLAYSYNCHRON:
case PROPERTY_ID_ENABLED:
case PROPERTY_ID_ENABLEVISIBLE:
aReturn = makeBoolAny(sal_True);
break;
case PROPERTY_ID_ALWAYSSHOWCURSOR:
aReturn = makeBoolAny(sal_False);
break;
case PROPERTY_ID_HELPURL:
case PROPERTY_ID_HELPTEXT:
aReturn <<= ::rtl::OUString();
break;
case PROPERTY_ID_BORDER:
aReturn <<= (sal_Int16)1;
break;
case PROPERTY_ID_BORDERCOLOR:
case PROPERTY_ID_TABSTOP:
case PROPERTY_ID_BACKGROUNDCOLOR:
case PROPERTY_ID_ROWHEIGHT:
case PROPERTY_ID_CURSORCOLOR:
// void
break;
default:
if ( isFontRelatedProperty( nHandle ) )
aReturn = FontControlModel::getPropertyDefaultByHandle( nHandle );
else
aReturn = OControlModel::getPropertyDefaultByHandle(nHandle);
}
return aReturn;
}
//------------------------------------------------------------------------------
OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const
{
OGridColumn* pImplementation = NULL;
Reference< XUnoTunnel > xUnoTunnel( _rxIFace, UNO_QUERY );
if ( xUnoTunnel.is() )
pImplementation = reinterpret_cast<OGridColumn*>(xUnoTunnel->getSomething(OGridColumn::getUnoTunnelImplementationId()));
return pImplementation;
}
//------------------------------------------------------------------------------
void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn )
{
Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
if ( xBroadcaster.is() )
xBroadcaster->addSQLErrorListener( this );
}
//------------------------------------------------------------------------------
void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn)
{
if ( m_xSelection == _rxColumn )
{ // the currently selected element was replaced
m_xSelection.clear();
EventObject aEvt( static_cast< XWeak* >( this ) );
m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt );
}
Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY );
if ( xBroadcaster.is() )
xBroadcaster->removeSQLErrorListener( this );
}
//------------------------------------------------------------------------------
void OGridControlModel::implRemoved(const InterfaceRef& _rxObject)
{
OInterfaceContainer::implRemoved(_rxObject);
lostColumn(_rxObject);
}
//------------------------------------------------------------------------------
void OGridControlModel::implInserted( const ElementDescription* _pElement )
{
OInterfaceContainer::implInserted( _pElement );
gotColumn( _pElement->xInterface );
}
//------------------------------------------------------------------------------
void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock )
{
Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY );
Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY );
bool bNewSelection = ( xOldColumn == m_xSelection );
lostColumn( xOldColumn );
gotColumn( xNewColumn );
if ( bNewSelection )
m_xSelection.set( xNewColumn, UNO_QUERY );
OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock );
// <<---- SYNCHRONIZED
if ( bNewSelection )
{
m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) );
}
}
//------------------------------------------------------------------------------
ElementDescription* OGridControlModel::createElementMetaData( )
{
return new ColumnDescription;
}
//------------------------------------------------------------------------------
void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement )
{
OGridColumn* pCol = getColumnImplementation( _rxObject );
if ( !pCol )
throw IllegalArgumentException();
OInterfaceContainer::approveNewElement( _rxObject, _pElement );
// if we're here, the object passed all tests
if ( _pElement )
static_cast< ColumnDescription* >( _pElement )->pColumn = pCol;
}
// XPersistObject
//------------------------------------------------------------------------------
::rtl::OUString SAL_CALL OGridControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
{
return FRM_COMPONENT_GRID; // old (non-sun) name for compatibility !
}
//------------------------------------------------------------------------------
void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
OControlModel::write(_rxOutStream);
Reference<XMarkableStream> xMark(_rxOutStream, UNO_QUERY);
// 1. Version
_rxOutStream->writeShort(0x0008);
// 2. Columns
sal_Int32 nLen = getCount();
_rxOutStream->writeLong(nLen);
OGridColumn* pCol;
for (sal_Int32 i = 0; i < nLen; i++)
{
// zuerst den Servicenamen fuer das darunterliegende Model
pCol = getColumnImplementation(m_aItems[i]);
DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !");
_rxOutStream << pCol->getModelName();
// dann das Object selbst
sal_Int32 nMark = xMark->createMark();
sal_Int32 nObjLen = 0;
_rxOutStream->writeLong(nObjLen);
// schreiben der Col
pCol->write(_rxOutStream);
// feststellen der Laenge
nObjLen = xMark->offsetToMark(nMark) - 4;
xMark->jumpToMark(nMark);
_rxOutStream->writeLong(nObjLen);
xMark->jumpToFurthest();
xMark->deleteMark(nMark);
}
// 3. Events
writeEvents(_rxOutStream);
// 4. Attribute
// Maskierung fuer alle any Typen
sal_uInt16 nAnyMask = 0;
if (m_aRowHeight.getValueType().getTypeClass() == TypeClass_LONG)
nAnyMask |= ROWHEIGHT;
if ( getFont() != getDefaultFont() )
nAnyMask |= FONTATTRIBS | FONTSIZE | FONTTYPE | FONTDESCRIPTOR;
if (m_aTabStop.getValueType().getTypeClass() == TypeClass_BOOLEAN)
nAnyMask |= TABSTOP;
if ( hasTextColor() )
nAnyMask |= TEXTCOLOR;
if (m_aBackgroundColor.getValueType().getTypeClass() == TypeClass_LONG)
nAnyMask |= BACKGROUNDCOLOR;
if (!m_bRecordMarker)
nAnyMask |= RECORDMARKER;
_rxOutStream->writeShort(nAnyMask);
if (nAnyMask & ROWHEIGHT)
_rxOutStream->writeLong(getINT32(m_aRowHeight));
// old structures
const FontDescriptor& aFont = getFont();
if ( nAnyMask & FONTDESCRIPTOR )
{
// Attrib
_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWeight( aFont.Weight ) ) );
_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( aFont.Slant ) );
_rxOutStream->writeShort( aFont.Underline );
_rxOutStream->writeShort( aFont.Strikeout );
_rxOutStream->writeShort( sal_Int16(aFont.Orientation * 10) );
_rxOutStream->writeBoolean( aFont.Kerning );
_rxOutStream->writeBoolean( aFont.WordLineMode );
// Size
_rxOutStream->writeLong( aFont.Width );
_rxOutStream->writeLong( aFont.Height );
_rxOutStream->writeShort( sal::static_int_cast< sal_Int16 >( VCLUnoHelper::ConvertFontWidth( aFont.CharacterWidth ) ) );
// Type
_rxOutStream->writeUTF( aFont.Name );
_rxOutStream->writeUTF( aFont.StyleName );
_rxOutStream->writeShort( aFont.Family );
_rxOutStream->writeShort( aFont.CharSet );
_rxOutStream->writeShort( aFont.Pitch );
}
_rxOutStream << m_aDefaultControl;
_rxOutStream->writeShort(m_nBorder);
_rxOutStream->writeBoolean(m_bEnable);
if (nAnyMask & TABSTOP)
_rxOutStream->writeBoolean(getBOOL(m_aTabStop));
_rxOutStream->writeBoolean(m_bNavigation);
if (nAnyMask & TEXTCOLOR)
_rxOutStream->writeLong( getTextColor() );
// neu ab Version 6
_rxOutStream << m_sHelpText;
if (nAnyMask & FONTDESCRIPTOR)
_rxOutStream << getFont();
if (nAnyMask & RECORDMARKER)
_rxOutStream->writeBoolean(m_bRecordMarker);
// neu ab Version 7
_rxOutStream->writeBoolean(m_bPrintable);
// new since 8
if (nAnyMask & BACKGROUNDCOLOR)
_rxOutStream->writeLong(getINT32(m_aBackgroundColor));
}
//------------------------------------------------------------------------------
void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
OControlModel::read(_rxInStream);
Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY);
// 1. Version
sal_Int16 nVersion = _rxInStream->readShort();
// 2. Einlesen der Spalten
sal_Int32 nLen = _rxInStream->readLong();
if (nLen)
{
for (sal_Int32 i = 0; i < nLen; i++)
{
// Lesen des Modelnamen
::rtl::OUString sModelName;
_rxInStream >> sModelName;
Reference<XPropertySet> xCol(createColumn(getColumnTypeByModelName(sModelName)));
DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !");
sal_Int32 nObjLen = _rxInStream->readLong();
if (nObjLen)
{
sal_Int32 nMark = xMark->createMark();
if (xCol.is())
{
OGridColumn* pCol = getColumnImplementation(xCol);
pCol->read(_rxInStream);
}
xMark->jumpToMark(nMark);
_rxInStream->skipBytes(nObjLen);
xMark->deleteMark(nMark);
}
if ( xCol.is() )
implInsert( i, xCol, sal_False, NULL, sal_False );
}
}
// In der Basisimplementierung werden die Events nur gelesen, Elemente im Container existieren
// da aber vor TF_ONE fuer das GridControl immer Events geschrieben wurden, muessen sie auch immer
// mit gelesen werden
sal_Int32 nObjLen = _rxInStream->readLong();
if (nObjLen)
{
sal_Int32 nMark = xMark->createMark();
Reference<XPersistObject> xObj(m_xEventAttacher, UNO_QUERY);
if (xObj.is())
xObj->read(_rxInStream);
xMark->jumpToMark(nMark);
_rxInStream->skipBytes(nObjLen);
xMark->deleteMark(nMark);
}
// Attachement lesen
for (sal_Int32 i = 0; i < nLen; i++)
{
InterfaceRef xIfc(m_aItems[i], UNO_QUERY);
Reference<XPropertySet> xSet(xIfc, UNO_QUERY);
Any aHelper;
aHelper <<= xSet;
m_xEventAttacher->attach( i, xIfc, aHelper );
}
// 4. Einlesen der Attribute
if (nVersion == 1)
return;
// Maskierung fuer any
sal_uInt16 nAnyMask = _rxInStream->readShort();
if (nAnyMask & ROWHEIGHT)
{
sal_Int32 nValue = _rxInStream->readLong();
m_aRowHeight <<= (sal_Int32)nValue;
}
FontDescriptor aFont( getFont() );
if ( nAnyMask & FONTATTRIBS )
{
aFont.Weight = (float)VCLUnoHelper::ConvertFontWeight( _rxInStream->readShort() );
aFont.Slant = (FontSlant)_rxInStream->readShort();
aFont.Underline = _rxInStream->readShort();
aFont.Strikeout = _rxInStream->readShort();
aFont.Orientation = ( (float)_rxInStream->readShort() ) / 10;
aFont.Kerning = _rxInStream->readBoolean();
aFont.WordLineMode = _rxInStream->readBoolean();
}
if ( nAnyMask & FONTSIZE )
{
aFont.Width = (sal_Int16)_rxInStream->readLong();
aFont.Height = (sal_Int16)_rxInStream->readLong();
aFont.CharacterWidth = (float)VCLUnoHelper::ConvertFontWidth( _rxInStream->readShort() );
}
if ( nAnyMask & FONTTYPE )
{
aFont.Name = _rxInStream->readUTF();
aFont.StyleName = _rxInStream->readUTF();
aFont.Family = _rxInStream->readShort();
aFont.CharSet = _rxInStream->readShort();
aFont.Pitch = _rxInStream->readShort();
}
if ( nAnyMask & ( FONTATTRIBS | FONTSIZE | FONTTYPE ) )
setFont( aFont );
// Name
_rxInStream >> m_aDefaultControl;
m_nBorder = _rxInStream->readShort();
m_bEnable = _rxInStream->readBoolean();
if (nAnyMask & TABSTOP)
{
m_aTabStop = makeBoolAny(_rxInStream->readBoolean());
}
if (nVersion > 3)
m_bNavigation = _rxInStream->readBoolean();
if (nAnyMask & TEXTCOLOR)
{
sal_Int32 nValue = _rxInStream->readLong();
setTextColor( (sal_Int32)nValue );
}
// neu ab Version 6
if (nVersion > 5)
_rxInStream >> m_sHelpText;
if (nAnyMask & FONTDESCRIPTOR)
{
FontDescriptor aUNOFont;
_rxInStream >> aUNOFont;
setFont( aFont );
}
if (nAnyMask & RECORDMARKER)
m_bRecordMarker = _rxInStream->readBoolean();
// neu ab Version 7
if (nVersion > 6)
m_bPrintable = _rxInStream->readBoolean();
if (nAnyMask & BACKGROUNDCOLOR)
{
sal_Int32 nValue = _rxInStream->readLong();
m_aBackgroundColor <<= (sal_Int32)nValue;
}
}
//.........................................................................
} // namespace frm
//.........................................................................