Kaydet (Commit) cd845c19 authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]
...@@ -737,6 +737,26 @@ sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _r ...@@ -737,6 +737,26 @@ sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _r
if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; 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 ); Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
if ( xWarnings.is() ) if ( xWarnings.is() )
{ {
...@@ -807,7 +827,8 @@ sal_Bool SbaXDataBrowserController::Construct(Window* pParent) ...@@ -807,7 +827,8 @@ sal_Bool SbaXDataBrowserController::Construct(Window* pParent)
m_xColumnsSupplier.set(m_xRowSet,UNO_QUERY); m_xColumnsSupplier.set(m_xRowSet,UNO_QUERY);
m_xLoadable.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; return sal_False;
m_xGridModel = CreateGridModel(); m_xGridModel = CreateGridModel();
...@@ -1205,34 +1226,16 @@ void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) t ...@@ -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_FILTER))
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 ( 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); InvalidateFeature(ID_BROWSER_REMOVEFILTER);
} }
else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE)) 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); InvalidateFeature(ID_BROWSER_REMOVEFILTER);
} }
else if (evt.PropertyName.equals(PROPERTY_ORDER)) 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); InvalidateFeature(ID_BROWSER_REMOVEFILTER);
} }
...@@ -1871,25 +1874,50 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi ...@@ -1871,25 +1874,50 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi
setCurrentColumnPosition(nPos); setCurrentColumnPosition(nPos);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow() Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow()
{ {
Reference< XSingleSelectQueryComposer > xRet; Reference< XSingleSelectQueryComposer > xComposer;
try try
{ {
Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY_THROW); const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY_THROW); const Reference< XMultiServiceFactory > xFactory(
xRet.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY_THROW); xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY_THROW );
xRet->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND))); xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
xRet->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER)));
xRet->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE))); ::rtl::OUString sActiveCommand;
xRet->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER))); 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(); DBG_UNHANDLED_EXCEPTION();
} }
return xRet; return xComposer;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
...@@ -1911,12 +1939,8 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) ...@@ -1911,12 +1939,8 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
{ {
DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() ); DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() );
String aFilter; String aFilter;
if(!aDlg.Execute()) if ( !aDlg.Execute() )
{ return; // if so we don't need to update the grid
//m_xParser->setFilter(sOldVal);
//m_xParser->setHavingClause(sOldHaving);
return; // if so we don't need to actualize the grid
}
aDlg.BuildWherePart(); aDlg.BuildWherePart();
} }
else else
...@@ -1925,7 +1949,6 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter) ...@@ -1925,7 +1949,6 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
String aOrder; String aOrder;
if(!aDlg.Execute()) if(!aDlg.Execute())
{ {
//m_xParser->setOrder(sOldVal);
return; // if so we don't need to actualize the grid return; // if so we don't need to actualize the grid
} }
aDlg.BuildOrderPart(); aDlg.BuildOrderPart();
...@@ -2707,22 +2730,7 @@ void SbaXDataBrowserController::initializeParser() const ...@@ -2707,22 +2730,7 @@ void SbaXDataBrowserController::initializeParser() const
{ // (only if the statement isn't native) { // (only if the statement isn't native)
// (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid) // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid)
xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser; 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&) catch(Exception&)
{ {
...@@ -2758,16 +2766,6 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R ...@@ -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 // 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 // the one we're interested in) we give them time to do what they want to before invalidating our
// bound-field-dependent slots .... // bound-field-dependent slots ....
/*
try
{
::comphelper::disposeComponent(m_xParser);
}
catch(Exception&)
{
OSL_ENSURE(0,"Exception thrown by dispose");
}
*/
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -145,7 +145,7 @@ Reference< XRowSet > SbaExternalSourceBrowser::CreateForm() ...@@ -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; return sal_True;
} }
......
...@@ -254,7 +254,8 @@ namespace dbaui ...@@ -254,7 +254,8 @@ namespace dbaui
// (probably this needs not to be overloaded, but you may return anything you want as long as it // (probably this needs not to be overloaded, but you may return anything you want as long as it
// supports the ::com::sun::star::form::DatabaseForm service. For instance you may want to create an adapter here which // supports the ::com::sun::star::form::DatabaseForm service. For instance you may want to create an adapter here which
// is synchronized with a foreign ::com::sun::star::form::DatabaseForm you got elsewhere) // is synchronized with a foreign ::com::sun::star::form::DatabaseForm you got elsewhere)
virtual sal_Bool InitializeForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xForm) = 0; virtual sal_Bool InitializeForm(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties ) = 0;
// called immediately after a successfull CreateForm // called immediately after a successfull CreateForm
// do any initialization (data source etc.) here. the form should be fully functional after that. // do any initialization (data source etc.) here. the form should be fully functional after that.
// return sal_False if you didn't succeed (don't throw exceptions, they won't be caught) // return sal_False if you didn't succeed (don't throw exceptions, they won't be caught)
...@@ -325,8 +326,11 @@ namespace dbaui ...@@ -325,8 +326,11 @@ namespace dbaui
/// loads or reloads the form /// loads or reloads the form
virtual sal_Bool reloadForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable); virtual sal_Bool reloadForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable);
virtual sal_Bool preReloadForm(){ return sal_False; } virtual sal_Bool preReloadForm(){ return sal_False; }
virtual void postReloadForm(){} virtual void postReloadForm(){}
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >
createParser_nothrow();
private: private:
void setCurrentModified( sal_Bool _bSet ); void setCurrentModified( sal_Bool _bSet );
...@@ -346,7 +350,6 @@ namespace dbaui ...@@ -346,7 +350,6 @@ namespace dbaui
void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel); void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
void impl_checkForCannotSelectUnfiltered( const ::dbtools::SQLExceptionInfo& _rError ); void impl_checkForCannotSelectUnfiltered( const ::dbtools::SQLExceptionInfo& _rError );
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > createParser_nothrow();
// time to check the CUT/COPY/PASTE-slot-states // time to check the CUT/COPY/PASTE-slot-states
DECL_LINK( OnInvalidateClipboard, AutoTimer* ); DECL_LINK( OnInvalidateClipboard, AutoTimer* );
......
...@@ -96,7 +96,7 @@ namespace dbaui ...@@ -96,7 +96,7 @@ namespace dbaui
~SbaExternalSourceBrowser(); ~SbaExternalSourceBrowser();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > CreateForm(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > CreateForm();
virtual sal_Bool InitializeForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xForm); virtual sal_Bool InitializeForm( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties );
virtual sal_Bool LoadForm(); virtual sal_Bool LoadForm();
......
...@@ -265,7 +265,7 @@ namespace dbaui ...@@ -265,7 +265,7 @@ namespace dbaui
protected: protected:
// SbaXDataBrowserController overridables // SbaXDataBrowserController overridables
virtual sal_Bool InitializeForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xForm); virtual sal_Bool InitializeForm( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties );
virtual sal_Bool InitializeGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid); virtual sal_Bool InitializeGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
virtual sal_Bool preReloadForm(); virtual sal_Bool preReloadForm();
...@@ -531,6 +531,10 @@ namespace dbaui ...@@ -531,6 +531,10 @@ namespace dbaui
of the load process of the load process
*/ */
void initializePreviewMode(); void initializePreviewMode();
/** checks whether the Order/Filter clauses set at our row set are valid, removes them if not so
*/
void impl_sanitizeRowSetClauses_nothrow();
}; };
// ......................................................................... // .........................................................................
......
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