Kaydet (Commit) bc3f6b2c authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]

dba34b: #i109580# (preparations)

üst 15b94338
......@@ -1205,34 +1205,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 (evt.PropertyName.equals(PROPERTY_FILTER))
{
// 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 ( 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);
}
......@@ -1911,12 +1893,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 +1903,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 +2684,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 +2720,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");
}
*/
}
//------------------------------------------------------------------------------
......
......@@ -420,6 +420,24 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
return sal_True;
}
// -------------------------------------------------------------------------
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;
};
}
sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm)
{
if(!m_pCurrentlyDisplayed)
......@@ -428,46 +446,41 @@ 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!" );
if ( pData->xObjectProperties.is() )
{
sal_Int32 nPos = 0;
// is the filter intially applied ?
aProperties.getArray()[nPos] = PROPERTY_APPLYFILTER;
aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_APPLYFILTER);
Reference< XPropertySetInfo > xPSI( pData->xObjectProperties->getPropertySetInfo(), UNO_SET_THROW );
// the initial filter
aProperties.getArray()[nPos] = PROPERTY_FILTER;
aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_FILTER);
::comphelper::NamedValueCollection aPropertyValues;
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);
}
const ::rtl::OUString aTransferProperties[] =
{
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 ordering
aProperties.getArray()[nPos] = PROPERTY_ORDER;
aValues.getArray()[nPos++] = pData->xObjectProperties->getPropertyValue(PROPERTY_ORDER);
const ::std::vector< ::rtl::OUString > aNames( aPropertyValues.getNames() );
Sequence< ::rtl::OUString > aPropNames( aNames.size() );
::std::copy( aNames.begin(), aNames.end(), aPropNames.getArray() );
Reference< XMultiPropertySet > xFormMultiSet(_rxForm, UNO_QUERY);
xFormMultiSet->setPropertyValues(aProperties, aValues);
}
Sequence< Any > aPropValues( aNames.size() );
::std::transform( aNames.begin(), aNames.end(), aPropValues.getArray(), SelectValueByName( aPropertyValues ) );
Reference< XMultiPropertySet > xFormMultiSet( _rxForm, UNO_QUERY );
xFormMultiSet->setPropertyValues( aPropNames, aPropValues );
}
catch(Exception&)
{
DBG_ERROR("SbaTableQueryBrowser::InitializeForm : something went wrong !");
DBG_UNHANDLED_EXCEPTION();
return sal_False;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment