/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
UnoGridModel::UnoGridModel( const UnoGridModel& rModel )
:UnoControlModel( rModel )
{
osl_atomic_increment( &m_refCount );
{
Reference< XGridDataModel > xDataModel; // clone the data model const Reference< XFastPropertySet > xCloneSource( &const_cast< UnoGridModel& >( rModel ) ); try
{ const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL ), UNO_QUERY_THROW );
xDataModel.set( xCloneable->createClone(), UNO_QUERY_THROW );
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("toolkit.controls");
} if ( !xDataModel.is() )
xDataModel = lcl_getDefaultDataModel_throw( m_xContext );
std::unique_lock aGuard(m_aMutex);
UnoControlModel::setFastPropertyValue_NoBroadcast( aGuard, BASEPROPERTY_GRID_DATAMODEL, Any( xDataModel ) ); // do *not* use setFastPropertyValue here: The UnoControlModel ctor made a simple copy of all property values, // so before this call here, we share our data model with the own of the clone source. setFastPropertyValue, // then, disposes the old data model - which means the data model which in fact belongs to the clone source. // so, call the UnoControlModel's impl-method for setting the value.
// clone the column model
Reference< XGridColumnModel > xColumnModel; try
{ const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL ), UNO_QUERY_THROW );
xColumnModel.set( xCloneable->createClone(), UNO_QUERY_THROW );
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("toolkit.controls");
} if ( !xColumnModel.is() )
xColumnModel = lcl_getDefaultColumnModel_throw( m_xContext );
UnoControlModel::setFastPropertyValue_NoBroadcast( aGuard, BASEPROPERTY_GRID_COLUMNMODEL, Any( xColumnModel ) ); // same comment as above: do not use our own setPropertyValue here.
}
osl_atomic_decrement( &m_refCount );
}
Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
{ switch( nPropId )
{ case BASEPROPERTY_DEFAULTCONTROL: return uno::Any( u"com.sun.star.awt.grid.UnoControlGrid"_ustr ); case BASEPROPERTY_GRID_SELECTIONMODE: return uno::Any( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: case BASEPROPERTY_USE_GRID_LINES: return uno::Any( false ); case BASEPROPERTY_ROW_HEADER_WIDTH: return uno::Any( sal_Int32( 10 ) ); case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return uno::Any( true ); case BASEPROPERTY_COLUMN_HEADER_HEIGHT: case BASEPROPERTY_ROW_HEIGHT: case BASEPROPERTY_GRID_HEADER_BACKGROUND: case BASEPROPERTY_GRID_HEADER_TEXT_COLOR: case BASEPROPERTY_GRID_LINE_COLOR: case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS: case BASEPROPERTY_ACTIVE_SEL_BACKGROUND_COLOR: case BASEPROPERTY_INACTIVE_SEL_BACKGROUND_COLOR: case BASEPROPERTY_ACTIVE_SEL_TEXT_COLOR: case BASEPROPERTY_INACTIVE_SEL_TEXT_COLOR: return Any(); default: return UnoControlModel::ImplGetDefaultValue( nPropId );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.