Tag: cws_dev300_dba30d User: fs Date: 2008-05-28 19:19:19+0000 Modified: dba/dbaccess/source/ui/browser/unodatbr.cxx
Log: some code re-arrangement during #i87514# File Changes: Directory: /dba/dbaccess/source/ui/browser/ =========================================== File [changed]: unodatbr.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/unodatbr.cxx?r1=1.200&r2=1.200.8.1 Delta lines: +30 -27 --------------------- --- unodatbr.cxx 2008-05-05 15:53:50+0000 1.200 +++ unodatbr.cxx 2008-05-28 19:19:15+0000 1.200.8.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: unodatbr.cxx,v $ - * $Revision: 1.200 $ + * $Revision: 1.200.8.1 $ * * This file is part of OpenOffice.org. * @@ -556,7 +556,8 @@ Reference<XChild> xChild(xConnection,UNO_QUERY); Reference<XPropertySet> xDataSourceProp(xChild->getParent(),UNO_QUERY); - sal_Bool bSupress = ::cppu::any2bool(xDataSourceProp->getPropertyValue(PROPERTY_SUPPRESSVERSIONCL)); + sal_Bool bSuppressVersionCol = sal_False; + OSL_VERIFY( xDataSourceProp->getPropertyValue( PROPERTY_SUPPRESSVERSIONCL ) >>= bSuppressVersionCol ); // insert the column into the gridcontrol so that we see something :-) ::rtl::OUString aCurrentModelType; @@ -566,21 +567,24 @@ const ::rtl::OUString* pIter = aNames.getConstArray(); const ::rtl::OUString* pEnd = pIter + aNames.getLength(); - ::rtl::OUString sPropertyName; - Reference<XPropertySet> xColumn; + ::rtl::OUString sDefaultProperty; + Reference< XPropertySet > xColumn; + Reference< XPropertySetInfo > xColPSI; for (sal_uInt16 i=0; pIter != pEnd; ++i,++pIter) { - // Typ - // first get type to determine wich control we need - ::cppu::extractInterface(xColumn,xColumns->getByName(*pIter)); + xColumn.set( xColumns->getByName( *pIter ), UNO_QUERY_THROW ); + xColPSI.set( xColumn->getPropertySetInfo(), UNO_SET_THROW ); // ignore the column when it is a rowversion one - if(bSupress && xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWVERSION) - && ::cppu::any2bool(xColumn->getPropertyValue(PROPERTY_ISROWVERSION))) + if ( bSuppressVersionCol + && xColPSI->hasPropertyByName( PROPERTY_ISROWVERSION ) + && ::cppu::any2bool( xColumn->getPropertyValue( PROPERTY_ISROWVERSION ) ) + ) continue; + // use the result set column's type to determine the type of grid column to create sal_Bool bFormattedIsNumeric = sal_True; - sal_Int32 nType = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_TYPE)); + sal_Int32 nType = ::comphelper::getINT32( xColumn->getPropertyValue( PROPERTY_TYPE ) ); ::std::vector< NamedValue > aInitialValues; ::std::vector< ::rtl::OUString > aCopyProperties; @@ -591,7 +595,7 @@ case DataType::BOOLEAN: aCurrentModelType = ::rtl::OUString::createFromAscii("CheckBox"); aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualEffect" ) ), makeAny( VisualEffect::FLAT ) ) ); - sPropertyName = PROPERTY_DEFAULTSTATE; + sDefaultProperty = PROPERTY_DEFAULTSTATE; break; case DataType::LONGVARCHAR: @@ -601,7 +605,7 @@ case DataType::VARBINARY: case DataType::LONGVARBINARY: aCurrentModelType = ::rtl::OUString::createFromAscii("TextField"); - sPropertyName = PROPERTY_DEFAULTTEXT; + sDefaultProperty = PROPERTY_DEFAULTTEXT; break; case DataType::VARCHAR: @@ -610,7 +614,7 @@ // NO break! default: aCurrentModelType = ::rtl::OUString::createFromAscii("FormattedField"); - sPropertyName = PROPERTY_EFFECTIVEDEFAULT; + sDefaultProperty = PROPERTY_EFFECTIVEDEFAULT; if ( xSupplier.is() ) aInitialValues.push_back( NamedValue( ::rtl::OUString::createFromAscii( "FormatsSupplier" ), makeAny( xSupplier ) ) ); @@ -622,19 +626,18 @@ aInitialValues.push_back( NamedValue( PROPERTY_CONTROLSOURCE, makeAny( *pIter ) ) ); aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( *pIter ) ) ); - Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(aCurrentModelType); - Reference< XPropertySetInfo > xColumnPropertyInfo = xCurrentCol->getPropertySetInfo(); + Reference< XPropertySet > xGridCol( xColFactory->createColumn( aCurrentModelType ), UNO_SET_THROW ); + Reference< XPropertySetInfo > xGridColPSI( xGridCol->getPropertySetInfo(), UNO_SET_THROW ); // calculate the default Any aDefault; - sal_Bool bDefault = xColumnPropertyInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT); - if ( bDefault ) - aDefault = xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT); + if ( xGridColPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) ) + aDefault = xColumn->getPropertyValue( PROPERTY_CONTROLDEFAULT ); // default value if ( nType == DataType::BIT || nType == DataType::BOOLEAN ) { - if(bDefault && aDefault.hasValue()) + if ( aDefault.hasValue() ) aDefault <<= (comphelper::getString(aDefault).toInt32() == 0) ? (sal_Int16)STATE_NOCHECK : (sal_Int16)STATE_CHECK; else aDefault <<= ((sal_Int16)STATE_DONTKNOW); @@ -642,14 +645,15 @@ } if ( aDefault.hasValue() ) - aInitialValues.push_back( NamedValue( sPropertyName, aDefault ) ); + aInitialValues.push_back( NamedValue( sDefaultProperty, aDefault ) ); // transfer properties from the definition to the UNO-model : aCopyProperties.push_back( PROPERTY_HIDDEN ); aCopyProperties.push_back( PROPERTY_WIDTH ); + // help text to display for the column Any aDescription; aDescription <<= ::rtl::OUString(); - if ( xColumn->getPropertySetInfo()->hasPropertyByName( PROPERTY_HELPTEXT ) ) + if ( xColPSI->hasPropertyByName( PROPERTY_HELPTEXT ) ) aDescription <<= ::comphelper::getString( xColumn->getPropertyValue( PROPERTY_HELPTEXT ) ); aInitialValues.push_back( NamedValue( PROPERTY_HELPTEXT, aDescription ) ); @@ -662,25 +666,24 @@ ++property ) { - xCurrentCol->setPropertyValue( property->Name, property->Value ); + xGridCol->setPropertyValue( property->Name, property->Value ); } for ( ::std::vector< ::rtl::OUString >::const_iterator copyPropertyName = aCopyProperties.begin(); copyPropertyName != aCopyProperties.end(); ++copyPropertyName ) - xCurrentCol->setPropertyValue( *copyPropertyName, xColumn->getPropertyValue( *copyPropertyName ) ); + xGridCol->setPropertyValue( *copyPropertyName, xColumn->getPropertyValue( *copyPropertyName ) ); - xColContainer->insertByName(*pIter, makeAny(xCurrentCol)); + xColContainer->insertByName(*pIter, makeAny(xGridCol)); } } } catch(Exception&) { - DBG_ERROR("SbaTableQueryBrowser::InitializeGridModel : something went wrong !"); + DBG_UNHANDLED_EXCEPTION(); return sal_False; } - return sal_True; } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
