diff options
author | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
commit | 84a2bad767682ba670a1bd4a8bf7e43dd21eb9b6 (patch) | |
tree | c54f93749b887848637a16ca08fa10f8c932a121 /dbaccess/source/ui/browser | |
parent | 2fffd98e29c9178c87e523454021c427e0aa4ed3 (diff) | |
parent | b98b964dc2735ca4c42a3905ef5eddcddba411c1 (diff) |
removetooltypes01: Rebase to DEV300m99
Diffstat (limited to 'dbaccess/source/ui/browser')
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 122 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dataview.cxx | 39 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/exsrcbrw.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/genericcontroller.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 340 |
5 files changed, 320 insertions, 195 deletions
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 6a2161b1c291..103267154da0 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -737,6 +737,26 @@ sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _r if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; + { + const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY ); + const Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xRowSetProps->getPropertyValue( PROPERTY_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY ); + if ( xAnalyzer.is() ) + { + const Reference< XIndexAccess > xOrderColumns( xAnalyzer->getOrderColumns(), UNO_SET_THROW ); + const sal_Int32 nOrderColumns( xOrderColumns->getCount() ); + for ( sal_Int32 c=0; c<nOrderColumns; ++c ) + { + const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW ); + ::rtl::OUString sColumnName; + OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName); + ::rtl::OUString sTableName; + OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName); + (void)sColumnName; + (void)sTableName; + } + } + } + Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY ); if ( xWarnings.is() ) { @@ -807,7 +827,8 @@ sal_Bool SbaXDataBrowserController::Construct(Window* pParent) m_xColumnsSupplier.set(m_xRowSet,UNO_QUERY); m_xLoadable.set(m_xRowSet,UNO_QUERY); - if (!InitializeForm(m_xRowSet)) + Reference< XPropertySet > xFormProperties( m_xRowSet, UNO_QUERY ); + if ( !InitializeForm( xFormProperties ) ) return sal_False; m_xGridModel = CreateGridModel(); @@ -1205,34 +1226,16 @@ void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) t } - // the filter or the sort criterias have changed ? -> update our parser - if (evt.PropertyName.equals(PROPERTY_ACTIVECOMMAND)) - { - // if (m_xParser.is()) - //DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" ); - } - else if (evt.PropertyName.equals(PROPERTY_FILTER)) + if (evt.PropertyName.equals(PROPERTY_FILTER)) { - // if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue)) - //{ - // DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); - //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE)) { - //if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue)) - //{ - // DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" ); - //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } else if (evt.PropertyName.equals(PROPERTY_ORDER)) { - //if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue)) - //{ - // DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" ); - //} InvalidateFeature(ID_BROWSER_REMOVEFILTER); } @@ -1871,25 +1874,50 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi setCurrentColumnPosition(nPos); } + //------------------------------------------------------------------------------ Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow() { - Reference< XSingleSelectQueryComposer > xRet; + Reference< XSingleSelectQueryComposer > xComposer; try { - Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY_THROW); - const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY_THROW); - xRet.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY_THROW); - xRet->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND))); - xRet->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER))); - xRet->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE))); - xRet->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); + const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); + const Reference< XMultiServiceFactory > xFactory( + xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY_THROW ); + xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); + + ::rtl::OUString sActiveCommand; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sActiveCommand ); + if ( sActiveCommand.getLength() > 0 ) + { + xComposer->setElementaryQuery( sActiveCommand ); + } + else + { + ::rtl::OUString sCommand; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand ); + sal_Int32 nCommandType = CommandType::COMMAND; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND_TYPE ) >>= nCommandType ); + xComposer->setCommand( sCommand, nCommandType ); + } + + ::rtl::OUString sFilter; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_FILTER ) >>= sFilter ); + xComposer->setFilter( sFilter ); + + ::rtl::OUString sHavingClause; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_HAVING_CLAUSE ) >>= sHavingClause ); + xComposer->setHavingClause( sHavingClause ); + + ::rtl::OUString sOrder; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ORDER ) >>= sOrder ); + xComposer->setOrder( sOrder ); } - catch(Exception&) + catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return xRet; + return xComposer; } //------------------------------------------------------------------------------ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) @@ -1911,12 +1939,8 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) { DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() ); String aFilter; - if(!aDlg.Execute()) - { - //m_xParser->setFilter(sOldVal); - //m_xParser->setHavingClause(sOldHaving); - return; // if so we don't need to actualize the grid - } + if ( !aDlg.Execute() ) + return; // if so we don't need to update the grid aDlg.BuildWherePart(); } else @@ -1925,7 +1949,6 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) String aOrder; if(!aDlg.Execute()) { - //m_xParser->setOrder(sOldVal); return; // if so we don't need to actualize the grid } aDlg.BuildOrderPart(); @@ -2707,22 +2730,7 @@ void SbaXDataBrowserController::initializeParser() const { // (only if the statement isn't native) // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid) xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; -/* - const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY); - if ( xFactory.is() ) - m_xParser.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); -*/ } -/* - // initialize the parser with the current sql-statement of the form - if ( m_xParser.is() ) - { - m_xParser->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND))); - m_xParser->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER))); - m_xParser->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE))); - m_xParser->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); - } -*/ } catch(Exception&) { @@ -2758,16 +2766,6 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R // change as a reaction on that event. as we have no chance to be notified of this change (which is // the one we're interested in) we give them time to do what they want to before invalidating our // bound-field-dependent slots .... - /* - try - { - ::comphelper::disposeComponent(m_xParser); - } - catch(Exception&) - { - OSL_ENSURE(0,"Exception thrown by dispose"); - } - */ } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx index 382aac477727..8112250ad23e 100644 --- a/dbaccess/source/ui/browser/dataview.cxx +++ b/dbaccess/source/ui/browser/dataview.cxx @@ -44,9 +44,6 @@ #ifndef _SFXIMGMGR_HXX #include <sfx2/imgmgr.hxx> #endif -#ifndef _SV_FIXED_HXX -#include <vcl/fixed.hxx> -#endif #ifndef DBAUI_ICONTROLLER_HXX #include "IController.hxx" #endif @@ -103,11 +100,12 @@ namespace dbaui :Window(pParent,nStyle) ,m_xServiceFactory(_rFactory) ,m_rController( _rController ) - ,m_pSeparator( NULL ) + ,m_aSeparator( this ) { DBG_CTOR(ODataView,NULL); m_rController.acquire(); m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper()); + m_aSeparator.Show(); } // ------------------------------------------------------------------------- @@ -120,30 +118,10 @@ namespace dbaui { DBG_DTOR(ODataView,NULL); - enableSeparator( sal_False ); m_rController.release(); } // ------------------------------------------------------------------------- - void ODataView::enableSeparator( const sal_Bool _bEnable ) - { - if ( _bEnable == isSeparatorEnabled() ) - // nothing to do - return; - - if ( _bEnable ) - { - m_pSeparator = new FixedLine( this ); - m_pSeparator->Show( ); - } - else - { - ::std::auto_ptr<FixedLine> aTemp(m_pSeparator); - m_pSeparator = NULL; - } - Resize(); - } - // ------------------------------------------------------------------------- void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ ) { } @@ -167,15 +145,10 @@ namespace dbaui { Rectangle aPlayground( _rPlayground ); - // position thew separator - if ( m_pSeparator ) - { - Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 ); - - m_pSeparator->SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize ); - - aPlayground.Top() += aSeparatorSize.Height() + 1; - } + // position the separator + const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 ); + m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize ); + aPlayground.Top() += aSeparatorSize.Height() + 1; // position the controls of the document's view resizeDocumentView( aPlayground ); diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx index 41200c7625ec..ba40583141ab 100644 --- a/dbaccess/source/ui/browser/exsrcbrw.cxx +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -145,7 +145,7 @@ Reference< XRowSet > SbaExternalSourceBrowser::CreateForm() } //------------------------------------------------------------------------------ -sal_Bool SbaExternalSourceBrowser::InitializeForm(const Reference< XRowSet > & /*xForm*/) +sal_Bool SbaExternalSourceBrowser::InitializeForm(const Reference< XPropertySet > & /*i_formProperties*/) { return sal_True; } diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 7115ffa5636c..200c87a729b3 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -704,6 +704,18 @@ void OGenericUnoController::InvalidateFeature_Impl() // ----------------------------------------------------------------------- void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Reference< XStatusListener >& _xListener, sal_Bool _bForceBroadcast ) { +#if OSL_DEBUG_LEVEL > 0 + if ( _nId != -1 ) + { + SupportedFeatures::iterator aFeaturePos = ::std::find_if( + m_aSupportedFeatures.begin(), + m_aSupportedFeatures.end(), + ::std::bind2nd( CompareFeatureById(), _nId ) + ); + OSL_ENSURE( aFeaturePos != m_aSupportedFeatures.end(), "OGenericUnoController::ImplInvalidateFeature: invalidating an unsupported feature is suspicious, at least!" ); + } +#endif + FeatureListener aListener; aListener.nId = _nId; aListener.xListener = _xListener; diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index b8837aac6c25..a187217f2f5f 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -67,6 +67,7 @@ #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/form/XGridColumnFactory.hpp> #include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/lang/DisposedException.hpp> @@ -419,8 +420,146 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent) return sal_True; } -// ------------------------------------------------------------------------- -sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm) +// --------------------------------------------------------------------------------------------------------------------- +namespace +{ + // ----------------------------------------------------------------------------------------------------------------- + struct SelectValueByName : public ::std::unary_function< ::rtl::OUString, Any > + { + const Any& operator()( ::rtl::OUString const& i_name ) const + { + return m_rCollection.get( i_name ); + } + + SelectValueByName( ::comphelper::NamedValueCollection const& i_collection ) + :m_rCollection( i_collection ) + { + } + + ::comphelper::NamedValueCollection const& m_rCollection; + }; +} + +// --------------------------------------------------------------------------------------------------------------------- +void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow() +{ + try + { + Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); + sal_Bool bEscapeProcessing = sal_False; + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing ); + if ( !bEscapeProcessing ) + // don't touch or interpret anything if escape processing is disabled + return; + + Reference< XSingleSelectQueryComposer > xComposer( createParser_nothrow() ); + if ( !xComposer.is() ) + // can't do anything. Already reported via assertion in createParser_nothrow. + return; + + // the tables participating in the statement + const Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY_THROW ); + const Reference< XNameAccess > xTableNames( xSuppTables->getTables(), UNO_QUERY_THROW ); + + // the columns participating in the statement + const Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY_THROW ); + const Reference< XNameAccess > xColumnNames( xSuppColumns->getColumns(), UNO_QUERY_THROW ); + + // ............................................................................................................. + // check if the order columns apply to tables which really exist in the statement + const Reference< XIndexAccess > xOrderColumns( xComposer->getOrderColumns(), UNO_SET_THROW ); + const sal_Int32 nOrderColumns( xOrderColumns->getCount() ); + bool invalidColumn = false; + for ( sal_Int32 c=0; ( c < nOrderColumns ) && !invalidColumn; ++c ) + { + const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW ); + ::rtl::OUString sTableName; + OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName ); + ::rtl::OUString sColumnName; + OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName ); + + if ( sTableName.getLength() == 0 ) + { + if ( !xColumnNames->hasByName( sColumnName ) ) + { + invalidColumn = true; + break; + } + } + else + { + if ( !xTableNames->hasByName( sTableName ) ) + { + invalidColumn = true; + break; + } + + const Reference< XColumnsSupplier > xSuppTableColumns( xTableNames->getByName( sTableName ), UNO_QUERY_THROW ); + const Reference< XNameAccess > xTableColumnNames( xSuppTableColumns->getColumns(), UNO_QUERY_THROW ); + if ( !xTableColumnNames->hasByName( sColumnName ) ) + { + invalidColumn = true; + break; + } + } + } + + if ( invalidColumn ) + { + // reset the complete order statement at both the row set and the parser + const ::rtl::OUString sEmptyOrder; + xRowSetProps->setPropertyValue( PROPERTY_ORDER, makeAny( sEmptyOrder ) ); + xComposer->setOrder( sEmptyOrder ); + } + + // ............................................................................................................. + // check if the columns participating in the filter refer to existing tables + // TODO: there's no API at all for this. The method which comes nearest to what we need is + // "getStructuredFilter", but it returns pure column names only. That is, for a statement like + // "SELECT * FROM <table> WHERE <other_table>.<column> = <value>", it will return "<column>". But + // there's no API at all to retrieve the information about "<other_table>" - which is what would + // be needed here. + // That'd be a chance to replace getStructuredFilter with something more reasonable. This method + // has at least one other problem: For a clause like "<column> != <value>", it will return "<column>" + // as column name, "NOT_EQUAL" as operator, and "!= <value>" as value, effectively duplicating the + // information about the operator, and beding all clients to manually remove the "!=" from the value + // string. + // So, what really would be handy, is some + // XNormalizedFilter getNormalizedFilter(); + // with + // interface XDisjunctiveFilterExpression + // { + // XConjunctiveFilterTerm getTerm( int index ); + // } + // interface XConjunctiveFilterTerm + // { + // ComparisonPredicate getPredicate( int index ); + // } + // struct ComparisonPredicate + // { + // XComparisonOperand Lhs; + // SQLFilterOperator Operator; + // XComparisonOperand Rhs; + // } + // interface XComparisonOperand + // { + // SQLFilterOperand Type; + // XPropertySet getColumn(); + // string getLiteral(); + // ... + // } + // enum SQLFilterOperand { Column, Literal, ... } + // + // ... or something like this .... + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// --------------------------------------------------------------------------------------------------------------------- +sal_Bool SbaTableQueryBrowser::InitializeForm( const Reference< XPropertySet > & i_formProperties ) { if(!m_pCurrentlyDisplayed) return sal_True; @@ -428,50 +567,46 @@ sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star: // this method set all format settings from the orignal table or query try { - // we send all properties at once, maybe the implementation is clever enough to handle one big PropertiesChanged - // more effective than many small PropertyChanged ;) - Sequence< ::rtl::OUString> aProperties(3); - Sequence< Any> aValues(3); - DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); - OSL_ENSURE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" ); - OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" ); + ENSURE_OR_RETURN_FALSE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" ); + ENSURE_OR_RETURN_FALSE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" ); + + Reference< XPropertySetInfo > xPSI( pData->xObjectProperties->getPropertySetInfo(), UNO_SET_THROW ); + + ::comphelper::NamedValueCollection aPropertyValues; - if ( pData->xObjectProperties.is() ) + const ::rtl::OUString aTransferProperties[] = { - sal_Int32 nPos = 0; - // is the filter intially applied ? - aProperties.getArray()[nPos] = PROPERTY_APPLYFILTER; - aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_APPLYFILTER); + PROPERTY_APPLYFILTER, + PROPERTY_FILTER, + PROPERTY_HAVING_CLAUSE, + PROPERTY_ORDER + }; + for ( size_t i=0; i < sizeof( aTransferProperties ) / sizeof( aTransferProperties[0] ); ++i ) + { + if ( !xPSI->hasPropertyByName( aTransferProperties[i] ) ) + continue; + aPropertyValues.put( aTransferProperties[i], pData->xObjectProperties->getPropertyValue( aTransferProperties[i] ) ); + } - // the initial filter - aProperties.getArray()[nPos] = PROPERTY_FILTER; - aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_FILTER); + const ::std::vector< ::rtl::OUString > aNames( aPropertyValues.getNames() ); + Sequence< ::rtl::OUString > aPropNames( aNames.size() ); + ::std::copy( aNames.begin(), aNames.end(), aPropNames.getArray() ); - if ( pData->xObjectProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_HAVING_CLAUSE) ) - { - aProperties.realloc(aProperties.getLength()+1); - aValues.realloc(aValues.getLength()+1); - // the initial having clause - aProperties.getArray()[nPos] = PROPERTY_HAVING_CLAUSE; - aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_HAVING_CLAUSE); - } + Sequence< Any > aPropValues( aNames.size() ); + ::std::transform( aNames.begin(), aNames.end(), aPropValues.getArray(), SelectValueByName( aPropertyValues ) ); - // the initial ordering - aProperties.getArray()[nPos] = PROPERTY_ORDER; - aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_ORDER); + Reference< XMultiPropertySet > xFormMultiSet( i_formProperties, UNO_QUERY_THROW ); + xFormMultiSet->setPropertyValues( aPropNames, aPropValues ); - Reference< XMultiPropertySet > xFormMultiSet(_rxForm, UNO_QUERY); - xFormMultiSet->setPropertyValues(aProperties, aValues); - } + impl_sanitizeRowSetClauses_nothrow(); } - catch(Exception&) + catch ( const Exception& ) { - DBG_ERROR("SbaTableQueryBrowser::InitializeForm : something went wrong !"); + DBG_UNHANDLED_EXCEPTION(); return sal_False; } - return sal_True; } @@ -601,6 +736,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: ::std::vector< NamedValue > aInitialValues; ::std::vector< ::rtl::OUString > aCopyProperties; + Any aDefault; switch(nType) { @@ -617,6 +753,8 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TriState" ) ), makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) ) ) ); + if ( ColumnValue::NO_NULLS == nNullable ) + aDefault <<= (sal_Int16)STATE_NOCHECK; } break; @@ -658,18 +796,17 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: Reference< XPropertySetInfo > xGridColPSI( xGridCol->getPropertySetInfo(), UNO_SET_THROW ); // calculate the default - Any aDefault; if ( xGridColPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) ) - aDefault = xColumn->getPropertyValue( PROPERTY_CONTROLDEFAULT ); - - // default value - if ( nType == DataType::BIT || nType == DataType::BOOLEAN ) { - if ( aDefault.hasValue() ) - aDefault <<= (comphelper::getString(aDefault).toInt32() == 0) ? (sal_Int16)STATE_NOCHECK : (sal_Int16)STATE_CHECK; - else - aDefault <<= ((sal_Int16)STATE_DONTKNOW); - + aDefault = xColumn->getPropertyValue( PROPERTY_CONTROLDEFAULT ); + // default value + if ( nType == DataType::BIT || nType == DataType::BOOLEAN ) + { + if ( aDefault.hasValue() ) + aDefault <<= (comphelper::getString(aDefault).toInt32() == 0) ? (sal_Int16)STATE_NOCHECK : (sal_Int16)STATE_CHECK; + else + aDefault <<= ((sal_Int16)STATE_DONTKNOW); + } } if ( aDefault.hasValue() ) @@ -2293,77 +2430,82 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _r sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand, const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing, const SharedConnection& _rxConnection) { - Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); - if(xProp.is()) + try { - Reference< ::com::sun::star::form::XLoadable > xLoadable(xProp,UNO_QUERY); - try + Reference<XPropertySet> xProp( getRowSet(), UNO_QUERY_THROW ); + Reference< XLoadable > xLoadable( xProp, UNO_QUERY_THROW ); + // the values allowing the RowSet to re-execute + xProp->setPropertyValue(PROPERTY_DATASOURCENAME, makeAny(_rDataSourceName)); + if(_rxConnection.is()) + xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _rxConnection.getTyped() ) ); + + // set this _before_ setting the connection, else the rowset would rebuild it ... + xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(_nCommandType)); + xProp->setPropertyValue(PROPERTY_COMMAND, makeAny(_rCommand)); + xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, ::cppu::bool2any(_bEscapeProcessing)); + if ( m_bPreview ) { - // the values allowing the RowSet to re-execute - xProp->setPropertyValue(PROPERTY_DATASOURCENAME, makeAny(_rDataSourceName)); - if(_rxConnection.is()) - xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _rxConnection.getTyped() ) ); - - // set this _before_ setting the connection, else the rowset would rebuild it ... - xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(_nCommandType)); - xProp->setPropertyValue(PROPERTY_COMMAND, makeAny(_rCommand)); - xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, ::cppu::bool2any(_bEscapeProcessing)); - if ( m_bPreview ) - { - xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD)); - } + xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD)); + } - // the formatter depends on the data source we're working on, so rebuild it here ... - initFormatter(); + // the formatter depends on the data source we're working on, so rebuild it here ... + initFormatter(); - // switch the grid to design mode while loading - getBrowserView()->getGridControl()->setDesignMode(sal_True); - InitializeForm(getRowSet()); + // switch the grid to design mode while loading + getBrowserView()->getGridControl()->setDesignMode(sal_True); + InitializeForm( xProp ); - sal_Bool bSuccess = sal_True; + sal_Bool bSuccess = sal_True; + { { - { - Reference< XNameContainer > xColContainer(getFormComponent(), UNO_QUERY); - // first we have to clear the grid - clearGridColumns(xColContainer); - } - FormErrorHelper aHelper(this); - // load the form - bSuccess = reloadForm(xLoadable); - - // initialize the model - InitializeGridModel(getFormComponent()); - - if ( m_bPreview ) - initializePreviewMode(); - - LoadFinished(sal_True); + Reference< XNameContainer > xColContainer(getFormComponent(), UNO_QUERY); + // first we have to clear the grid + clearGridColumns(xColContainer); } + FormErrorHelper aHelper(this); + // load the form + bSuccess = reloadForm(xLoadable); - InvalidateAll(); - return bSuccess; - } - catch( const SQLException& e ) - { - Any aException( ::cppu::getCaughtException() ); - showError( SQLExceptionInfo( aException ) ); - } - catch( const WrappedTargetException& e ) - { - SQLException aSql; - if ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) ) - showError( SQLExceptionInfo( e.TargetException ) ); - else + // initialize the model + InitializeGridModel(getFormComponent()); + + Any aVal = xProp->getPropertyValue(PROPERTY_ISNEW); + if (aVal.hasValue() && ::comphelper::getBOOL(aVal)) { - DBG_UNHANDLED_EXCEPTION(); + // then set the default values and the parameters given from the parent + Reference< XReset> xReset(xProp, UNO_QUERY); + xReset->reset(); } + + if ( m_bPreview ) + initializePreviewMode(); + + LoadFinished(sal_True); } - catch(Exception&) + + InvalidateAll(); + return bSuccess; + } + catch( const SQLException& e ) + { + Any aException( ::cppu::getCaughtException() ); + showError( SQLExceptionInfo( aException ) ); + } + catch( const WrappedTargetException& e ) + { + SQLException aSql; + if ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) ) + showError( SQLExceptionInfo( e.TargetException ) ); + else { DBG_UNHANDLED_EXCEPTION(); } } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } InvalidateAll(); return sal_False; |