diff options
Diffstat (limited to 'forms/source/component/Grid.cxx')
-rw-r--r-- | forms/source/component/Grid.cxx | 204 |
1 files changed, 23 insertions, 181 deletions
diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index c524b0118aab..746583ba30f6 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -16,20 +16,16 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - - #include "Columns.hxx" #include "findpos.hxx" #include "Grid.hxx" #include "property.hrc" #include "property.hxx" #include "services.hxx" - #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> - #include <comphelper/basicio.hxx> #include <comphelper/container.hxx> #include <comphelper/extract.hxx> @@ -37,13 +33,9 @@ #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; @@ -57,9 +49,7 @@ 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; @@ -69,14 +59,10 @@ 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( comphelper::getComponentContext(_rxFactory) )); } - -//------------------------------------------------------------------ OGridControlModel::OGridControlModel(const Reference<XComponentContext>& _rxFactory) :OControlModel(_rxFactory, OUString()) ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XPropertySet>*>(NULL))) @@ -97,11 +83,9 @@ OGridControlModel::OGridControlModel(const Reference<XComponentContext>& _rxFact ,m_bAlwaysShowCursor(sal_False) ,m_bDisplaySynchron(sal_True) { - m_nClassId = FormComponentType::GRIDCONTROL; } -//------------------------------------------------------------------ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const Reference< XComponentContext >& _rxFactory ) :OControlModel( _pOriginal, _rxFactory ) ,OInterfaceContainer( _rxFactory, m_aMutex, ::getCppuType( static_cast<Reference<XPropertySet>*>( NULL ) ) ) @@ -111,7 +95,6 @@ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const ,m_aResetListeners( m_aMutex ) ,m_aRowSetChangeListeners( m_aMutex ) { - m_aDefaultControl = _pOriginal->m_aDefaultControl; m_bEnable = _pOriginal->m_bEnable; m_bEnableVisible = _pOriginal->m_bEnableVisible; @@ -123,14 +106,11 @@ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const 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) @@ -138,11 +118,9 @@ OGridControlModel::~OGridControlModel() acquire(); dispose(); } - } // XCloneable -//------------------------------------------------------------------------------ Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException) { OGridControlModel* pClone = new OGridControlModel( this, getContext() ); @@ -155,13 +133,11 @@ Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (Runtim 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 ) @@ -169,19 +145,16 @@ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContain // 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 ) ); } - } } } @@ -192,22 +165,17 @@ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContain } // XServiceInfo -//------------------------------------------------------------------------------ StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException) { StringSequence aSupported = OControlModel::getSupportedServiceNames(); aSupported.realloc(aSupported.getLength() + 2); - aSupported[aSupported.getLength()-2] = "com.sun.star.awt.UnoControlModel"; aSupported[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 ); @@ -222,7 +190,6 @@ Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) throw (Ru } // XSQLErrorListener -//------------------------------------------------------------------------------ void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) throw (RuntimeException) { // forward the errors which happened to my columns to my own listeners @@ -230,47 +197,38 @@ void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) th } // 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_FAIL( "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( @@ -284,15 +242,12 @@ Sequence< Type > SAL_CALL OGridControlModel::getTypes( ) throw(RuntimeException } // 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); @@ -300,7 +255,6 @@ void OGridControlModel::disposing() } // XEventListener -//------------------------------------------------------------------------------ void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeException ) { OControlModel::disposing( _rEvent ); @@ -308,18 +262,15 @@ void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeExce } // 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); @@ -328,7 +279,6 @@ sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalAr throw IllegalArgumentException(); } } - if ( xSel != m_xSelection ) { m_xSelection = xSel; @@ -338,35 +288,28 @@ sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalAr } 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 OUString& ColumnType) throw ( :: com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { SolarMutexGuard g; const Sequence< OUString >& rColumnTypes = frm::getColumnTypes(); return createColumn( ::detail::findPos( ColumnType, rColumnTypes ) ); } - -//------------------------------------------------------------------------------ Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) const { Reference<XPropertySet> xReturn; @@ -388,15 +331,12 @@ Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) cons } 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); @@ -404,27 +344,20 @@ void SAL_CALL OGridControlModel::reset() throw ( ::com::sun::star::uno::RuntimeE 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; @@ -438,7 +371,6 @@ void OGridControlModel::_reset() } // XPropertySet -//------------------------------------------------------------------------------ void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { BEGIN_DESCRIBE_BASE_PROPERTIES( 37 ) @@ -481,8 +413,6 @@ void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT); END_DESCRIBE_PROPERTIES(); } - -//------------------------------------------------------------------------------ void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const { switch (nHandle) @@ -541,7 +471,6 @@ void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) co case PROPERTY_ID_ROWHEIGHT: rValue = m_aRowHeight; break; - default: if ( isFontRelatedProperty( nHandle ) ) FontControlModel::getFastPropertyValue( rValue, nHandle ); @@ -549,8 +478,6 @@ void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) co OControlModel::getFastPropertyValue( rValue, nHandle ); } } - -//------------------------------------------------------------------------------ sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue )throw( IllegalArgumentException ) { @@ -622,7 +549,6 @@ sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& 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 ) ) { @@ -639,8 +565,6 @@ sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& } return bModified; } - -//------------------------------------------------------------------------------ void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw ( ::com::sun::star::uno::Exception) { switch (nHandle) @@ -699,7 +623,6 @@ void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, con case PROPERTY_ID_ROWHEIGHT: m_aRowHeight = rValue; break; - default: if ( isFontRelatedProperty( nHandle ) ) { @@ -710,12 +633,9 @@ void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, con else OControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); } - } //XPropertyState - -//------------------------------------------------------------------------------ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const { Any aReturn; @@ -725,11 +645,9 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const case PROPERTY_ID_WRITING_MODE: aReturn <<= WritingMode2::CONTEXT; break; - case PROPERTY_ID_DEFAULTCONTROL: aReturn <<= OUString( STARDIV_ONE_FORM_CONTROL_GRID ); break; - case PROPERTY_ID_PRINTABLE: case PROPERTY_ID_HASNAVIGATION: case PROPERTY_ID_RECORDMARKER: @@ -738,20 +656,16 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const case PROPERTY_ID_ENABLEVISIBLE: aReturn = makeBoolAny(true); break; - case PROPERTY_ID_ALWAYSSHOWCURSOR: aReturn = makeBoolAny(false); break; - case PROPERTY_ID_HELPURL: case PROPERTY_ID_HELPTEXT: aReturn <<= OUString(); break; - case PROPERTY_ID_BORDER: aReturn <<= (sal_Int16)1; break; - case PROPERTY_ID_BORDERCOLOR: case PROPERTY_ID_TABSTOP: case PROPERTY_ID_BACKGROUNDCOLOR: @@ -759,7 +673,6 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const case PROPERTY_ID_CURSORCOLOR: // void break; - default: if ( isFontRelatedProperty( nHandle ) ) aReturn = FontControlModel::getPropertyDefaultByHandle( nHandle ); @@ -769,18 +682,15 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const 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 ); @@ -788,7 +698,6 @@ void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn ) xBroadcaster->addSQLErrorListener( this ); } -//------------------------------------------------------------------------------ void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn) { if ( m_xSelection == _rxColumn ) @@ -797,119 +706,95 @@ void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn) 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 - + // < 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 -//------------------------------------------------------------------------------ OUString SAL_CALL OGridControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException) { - return OUString(FRM_COMPONENT_GRID); // old (non-sun) name for compatibility ! + return OUString(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 + // first the service name for the unerlying 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 + // then the object itself sal_Int32 nMark = xMark->createMark(); sal_Int32 nObjLen = 0; _rxOutStream->writeLong(nObjLen); - - // schreiben der Col + // writing the column pCol->write(_rxOutStream); - - // feststellen der Laenge + // determining the length 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 + // 4. Attributes + // Masking for all 'any' types sal_uInt16 nAnyMask = 0; if (m_aRowHeight.getValueType().getTypeClass() == TypeClass_LONG) nAnyMask |= ROWHEIGHT; @@ -923,12 +808,9 @@ void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream 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 ) @@ -941,12 +823,10 @@ void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream _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 ); @@ -954,59 +834,43 @@ void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream _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 + // new since version 6 _rxOutStream << m_sHelpText; - if (nAnyMask & FONTDESCRIPTOR) _rxOutStream << getFont(); - if (nAnyMask & RECORDMARKER) _rxOutStream->writeBoolean(m_bRecordMarker); - - // neu ab Version 7 + // new since version 7 _rxOutStream->writeBoolean(m_bPrintable); - - // new since 8 + // new since version 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) { SolarMutexGuard g; OControlModel::read(_rxInStream); - Reference<XMarkableStream> xMark(_rxInStream, UNO_QUERY); - - // 1. Version + // 1. version sal_Int16 nVersion = _rxInStream->readShort(); - - // 2. Einlesen der Spalten + // 2. reading the columns sal_Int32 nLen = _rxInStream->readLong(); if (nLen) { for (sal_Int32 i = 0; i < nLen; i++) { - // Lesen des Modelnamen - + // reading the model names OUString sModelName; _rxInStream >> sModelName; - Reference<XPropertySet> xCol(createColumn(getColumnTypeByModelName(sModelName))); DBG_ASSERT(xCol.is(), "OGridControlModel::read : unknown column type !"); sal_Int32 nObjLen = _rxInStream->readLong(); @@ -1022,15 +886,13 @@ void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) t _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 + // In the base implementation events are only read, elements in the container exist + // but since before TF_ONE for the GridControl events were always written, so they + // need to be read, too sal_Int32 nObjLen = _rxInStream->readLong(); if (nObjLen) { @@ -1042,8 +904,7 @@ void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) t _rxInStream->skipBytes(nObjLen); xMark->deleteMark(nMark); } - - // Attachement lesen + // reading the attachement for (sal_Int32 i = 0; i < nLen; i++) { InterfaceRef xIfc(m_aItems[i], UNO_QUERY); @@ -1052,25 +913,20 @@ void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) t aHelper <<= xSet; m_xEventAttacher->attach( i, xIfc, aHelper ); } - - // 4. Einlesen der Attribute + // 4. reading the attributes if (nVersion == 1) return; - - // Maskierung fuer any + // Masking for 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(); @@ -1092,56 +948,42 @@ void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) t 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 + // new since 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 + // new since version 7 if (nVersion > 6) m_bPrintable = _rxInStream->readBoolean(); - if (nAnyMask & BACKGROUNDCOLOR) { sal_Int32 nValue = _rxInStream->readLong(); m_aBackgroundColor <<= (sal_Int32)nValue; } } - -//......................................................................... -} // namespace frm -//......................................................................... - +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |