Tag: cws_src680_oj14 User: fs Date: 2007-06-05 20:55:41+0000 Modified: dba/reportdesign/source/ui/dlg/AddField.cxx dba/reportdesign/source/ui/inc/GeometryHandler.hxx dba/reportdesign/source/ui/inc/UITools.hxx dba/reportdesign/source/ui/inspection/GeometryHandler.cxx dba/reportdesign/source/ui/misc/UITools.cxx dba/reportdesign/source/ui/report/DesignView.cxx dba/reportdesign/source/ui/report/ReportController.cxx
Log: #i78077# parameters support File Changes: Directory: /dba/reportdesign/source/ui/dlg/ =========================================== File [changed]: AddField.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/dlg/AddField.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +6 -18 -------------------- --- AddField.cxx 2007-06-05 20:17:43+0000 1.1.2.2 +++ AddField.cxx 2007-06-05 20:55:37+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: AddField.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: fs $ $Date: 2007/06/05 20:17:43 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:37 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -37,6 +37,8 @@ #ifndef RPTUI_ADDFIELDWINDOW_HXX #include "AddField.hxx" #endif +#include "UITools.hxx" + #ifndef _SVX_DBAEXCHANGE_HXX_ #include <svx/dbaexchange.hxx> #endif @@ -47,9 +49,6 @@ #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ #include <com/sun/star/sdb/XDocumentDataSource.hpp> #endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ -#include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif #ifndef _COMPHELPER_PROCESSFACTORY_HXX_ #include <comphelper/processfactory.hxx> #endif @@ -345,19 +344,8 @@ lcl_addToList( *m_pListBox, m_xColumns->getElementNames() ); // add the parameter columns to the list - uno::Reference< sdb::XParametersSupplier > xSuppParams( m_rController.getRowSet(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters(), uno::UNO_QUERY ); - if ( xParams.is() ) - { - sal_Int32 nCount( xParams->getCount() ); - for ( sal_Int32 i=0; i<nCount; ++i ) - { - uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW ); - ::rtl::OUString sParamName; - OSL_VERIFY( xParamCol->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sParamName ); - m_pListBox->InsertEntry( sParamName ); - } - } + Sequence< ::rtl::OUString > aParamNames( getParameterNames( m_rController.getRowSet() ) ); + lcl_addToList( *m_pListBox, aParamNames ); // set title aTitle.AppendAscii(" "); Directory: /dba/reportdesign/source/ui/inc/ =========================================== File [changed]: GeometryHandler.hxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/GeometryHandler.hxx?r1=1.1.2.3&r2=1.1.2.4 Delta lines: +3 -3 ------------------- --- GeometryHandler.hxx 2007-06-05 13:19:52+0000 1.1.2.3 +++ GeometryHandler.hxx 2007-06-05 20:55:37+0000 1.1.2.4 @@ -4,9 +4,9 @@ * * $RCSfile: GeometryHandler.hxx,v $ * - * $Revision: 1.1.2.3 $ + * $Revision: 1.1.2.4 $ * - * last change: $Author: fs $ $Date: 2007/06/05 13:19:52 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:37 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -166,7 +166,7 @@ virtual void SAL_CALL disposing(); ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aFieldNames; - ::std::vector< ::rtl::OUString > m_aParamNames; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aParamNames; ::std::vector< ::rtl::OUString > m_aFunctionNames; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > m_xFormComponentHandler; /// delegatee File [changed]: UITools.hxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/UITools.hxx?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +8 -2 ------------------- --- UITools.hxx 2007-05-30 13:07:05+0000 1.1.2.4 +++ UITools.hxx 2007-06-05 20:55:37+0000 1.1.2.5 @@ -6,9 +6,9 @@ * * $RCSfile: UITools.hxx,v $ * - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * - * last change: $Author: fs $ $Date: 2007/05/30 13:07:05 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:37 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,6 +42,7 @@ #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> #include <rtl/ref.hxx> #include <vcl/taskpanelist.hxx> @@ -146,6 +147,11 @@ * \return the object which is overlapped, otherwise <NULL/>. If the given object is not of type OUnoObject <NULL/> will be returned. */ SdrObject* isOver(SdrObject* _pObj,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects = false); + + /** retrieves the names of the parameters of the command which the given RowSet is bound to + */ + ::com::sun::star::uno::Sequence< ::rtl::OUString > + getParameterNames( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet ); } #endif //RPTUI_UITOOLS_HXX Directory: /dba/reportdesign/source/ui/inspection/ ================================================== File [changed]: GeometryHandler.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inspection/GeometryHandler.cxx?r1=1.1.2.7&r2=1.1.2.8 Delta lines: +8 -16 -------------------- --- GeometryHandler.cxx 2007-06-05 13:20:15+0000 1.1.2.7 +++ GeometryHandler.cxx 2007-06-05 20:55:38+0000 1.1.2.8 @@ -4,9 +4,9 @@ * * $RCSfile: GeometryHandler.cxx,v $ * - * $Revision: 1.1.2.7 $ + * $Revision: 1.1.2.8 $ * - * last change: $Author: fs $ $Date: 2007/06/05 13:20:15 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -115,9 +115,6 @@ #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> #endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ -#include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif #include <com/sun/star/report/XFixedLine.hpp> #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> @@ -291,15 +288,14 @@ const ::rtl::OUString* pEnd = m_aFieldNames.getConstArray() + m_aFieldNames.getLength(); bool bIsField = ( ::std::find( m_aFieldNames.getConstArray(), pEnd, sName ) != pEnd ); - bool bIsParam = ( ::std::find( m_aParamNames.begin(), m_aParamNames.end(), sName ) != m_aParamNames.end() ); + + pEnd = m_aFieldNames.getConstArray() + m_aParamNames.getLength(); + bool bIsParam = ( ::std::find( m_aParamNames.getConstArray(), pEnd, sName ) != pEnd ); aParser = ReportFormula( bIsField || bIsParam ? ReportFormula::Field : ReportFormula::Expression, sName ); return aParser.getCompleteFormula(); } - - - GeometryHandler::GeometryHandler(uno::Reference< uno::XComponentContext > const & context) : GeometryHandler_Base(m_aMutex), m_xContext(context), @@ -604,13 +600,9 @@ m_aFieldNames = xListControl->getListEntries(); // add parameter names - uno::Reference< sdb::XParametersSupplier > xSuppParams( m_xRowSet, uno::UNO_QUERY ); - if ( xSuppParams.is() ) - { - lcl_collectParamNames_nothrow( xSuppParams->getParameters(), m_aParamNames ); - ::std::for_each( m_aParamNames.begin(), m_aParamNames.end(), + m_aParamNames = getParameterNames( m_xRowSet ); + ::std::for_each( m_aParamNames.getConstArray(), m_aParamNames.getConstArray() + m_aParamNames.getLength(), ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl, _1 ) ); - } // add function names ::std::for_each( m_aFunctionNames.begin(), m_aFunctionNames.end(), Directory: /dba/reportdesign/source/ui/misc/ ============================================ File [changed]: UITools.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/misc/UITools.cxx?r1=1.1.2.8&r2=1.1.2.9 Delta lines: +35 -2 -------------------- --- UITools.cxx 2007-05-30 13:07:10+0000 1.1.2.8 +++ UITools.cxx 2007-06-05 20:55:38+0000 1.1.2.9 @@ -4,9 +4,9 @@ * * $RCSfile: UITools.cxx,v $ * - * $Revision: 1.1.2.8 $ + * $Revision: 1.1.2.9 $ * - * last change: $Author: fs $ $Date: 2007/05/30 13:07:10 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -150,6 +150,7 @@ #include <com/sun/star/awt/TextAlign.hpp> #include <com/sun/star/text/ParagraphVertAlign.hpp> #include <com/sun/star/report/XShape.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> #include <i18npool/mslangid.hxx> #ifndef RPTUI_DLGPAGE_HXX #include "dlgpage.hxx" @@ -832,7 +833,39 @@ } return pOverlappedObj; } + // ----------------------------------------------------------------------------- +uno::Sequence< ::rtl::OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet ) +{ + uno::Sequence< ::rtl::OUString > aNames; + + try + { + uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() ); + if ( xParams.is() ) + { + sal_Int32 count( xParams->getCount() ); + aNames.realloc( count ); + + uno::Reference< beans::XPropertySet > xParam; + ::rtl::OUString sParamName; + for ( sal_Int32 i=0; i<count; ++i ) + { + xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW ); + OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName ); + aNames[i] = sParamName; + } + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return aNames; +} + // ----------------------------------------------------------------------------- } // namespace rptui // ----------------------------------------------------------------------------- Directory: /dba/reportdesign/source/ui/report/ ============================================== File [changed]: DesignView.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/DesignView.cxx?r1=1.1.2.9&r2=1.1.2.10 Delta lines: +4 -4 ------------------- --- DesignView.cxx 2007-06-05 11:45:43+0000 1.1.2.9 +++ DesignView.cxx 2007-06-05 20:55:38+0000 1.1.2.10 @@ -4,9 +4,9 @@ * * $RCSfile: DesignView.cxx,v $ * - * $Revision: 1.1.2.9 $ + * $Revision: 1.1.2.10 $ * - * last change: $Author: oj $ $Date: 2007/06/05 11:45:43 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -560,8 +560,8 @@ uno::Reference< report::XSection > xSection = m_pCurrentView->getSectionWindow()->getSection(); xReport = xSection->getReportDefinition(); } - m_pAddField = new OAddFieldWindow(pReportController,this); - m_pAddField->Update(xReport); + m_pAddField = new OAddFieldWindow(*pReportController,this); + m_pAddField->Update(); m_pAddField->AddEventListener(LINK(pReportController,OReportController,EventLstHdl)); notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::AddWindow)); } File [changed]: ReportController.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/ReportController.cxx?r1=1.1.2.21&r2=1.1.2.22 Delta lines: +260 -192 ----------------------- --- ReportController.cxx 2007-06-05 11:45:43+0000 1.1.2.21 +++ ReportController.cxx 2007-06-05 20:55:38+0000 1.1.2.22 @@ -4,9 +4,9 @@ * * $RCSfile: ReportController.cxx,v $ * - * $Revision: 1.1.2.21 $ + * $Revision: 1.1.2.22 $ * - * last change: $Author: oj $ $Date: 2007/06/05 11:45:43 $ + * last change: $Author: fs $ $Date: 2007/06/05 20:55:38 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -148,13 +148,18 @@ #ifndef _COM_SUN_STAR_REPORT_FUNCTION_HPP_ #include <com/sun/star/report/Function.hpp> #endif +#ifndef _COM_SUN_STAR_REPORT_XSHAPE_HPP_ #include <com/sun/star/report/XShape.hpp> +#endif #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ #include <com/sun/star/awt/FontDescriptor.hpp> #endif #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ #include <com/sun/star/sdb/XDocumentDataSource.hpp> #endif +#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#endif #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #endif @@ -298,6 +303,27 @@ using namespace ::comphelper; // ----------------------------------------------------------------------------- +namespace +{ + class UndoManagerListAction + { + private: + SfxUndoManager& m_rManager; + + public: + UndoManagerListAction( SfxUndoManager& _rManager, const String& _rListActionComment ) + :m_rManager( _rManager ) + { + m_rManager.EnterListAction( _rListActionComment, String() ); + } + ~UndoManagerListAction() + { + m_rManager.LeaveListAction(); + } + }; +} + +// ----------------------------------------------------------------------------- uno::Reference< report::XReportControlFormat> lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,ODesignView* _pView,uno::Reference< awt::XWindow>& _xWindow) { uno::Reference< report::XReportControlFormat> xReportControlFormat; @@ -407,21 +433,19 @@ ::std::auto_ptr<FloatingWindow> aTemp(m_pGroupsFloater); m_pGroupsFloater = NULL; } - TRowSets::iterator aIter = m_aRowSets.begin(); - TRowSets::iterator aEnd = m_aRowSets.end(); - for (; aIter != aEnd; ++aIter) - { + try { - ::comphelper::disposeComponent(aIter->second.first); - ::comphelper::disposeComponent(aIter->second.second); + ::comphelper::disposeComponent( m_xRowSet ); + ::comphelper::disposeComponent( m_xRowSetMediator ); } catch(uno::Exception&) { OSL_ENSURE(0,"Exception caught while disposing row sets."); } - } - m_aRowSets.clear(); + m_xRowSet.clear(); + m_xRowSetMediator.clear(); + if ( m_xReportDefinition.is() ) { try @@ -2075,12 +2099,6 @@ {} } // ----------------------------------------------------------------------------- -void SAL_CALL OReportController::disposing( const EventObject& _rSource ) throw(RuntimeException) -{ - uno::Reference< uno::XInterface> xTemp(_rSource.Source,uno::UNO_QUERY); - m_aRowSets.erase(xTemp); -} -// ----------------------------------------------------------------------------- void OReportController::losingConnection( ) { // let the base class do it's reconnect @@ -2221,7 +2239,10 @@ else m_pMyOwnView->removeSection(m_pMyOwnView->getSectionCount() - 1); } - else if ( evt.PropertyName.equals( PROPERTY_COMMAND ) || evt.PropertyName.equals( PROPERTY_COMMANDTYPE )) + else if ( evt.PropertyName.equals( PROPERTY_COMMAND ) + || evt.PropertyName.equals( PROPERTY_COMMANDTYPE ) + || evt.PropertyName.equals( PROPERTY_ESCAPEPROCESSING ) + ) { InvalidateFeature(SID_FM_ADD_FIELD); if ( !m_pMyOwnView->isAddFieldVisible() ) @@ -2244,6 +2265,13 @@ DBG_UNHANDLED_EXCEPTION(); } } + +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::disposing( const lang::EventObject& /*Source*/ ) throw(uno::RuntimeException) +{ + // not interested in +} + // ----------------------------------------------------------------------------- USHORT lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups ,sal_Int32 _nGroupPos @@ -2949,49 +2977,36 @@ return m_xReportDefinition.get(); } // ----------------------------------------------------------------------------- -uno::Reference< sdbc::XRowSet > OReportController::getRowSetForComponent(const uno::Reference< uno::XInterface >& _xAWTComponent,const uno::Reference< uno::XInterface >& _xReportComponent) +uno::Reference< sdbc::XRowSet > OReportController::getRowSet() { - OSL_ENSURE(_xAWTComponent.is(),"OReportController::setRowSetAsParent: _xAWTComponent is NULL!" ); - OSL_ENSURE(_xReportComponent.is(),"OReportController::setRowSetAsParent: _xReportComponent is NULL!" ); - TRowSets::iterator aFind = m_aRowSets.find(_xAWTComponent); + OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" ); - uno::Reference< sdbc::XRowSet > xRowSet; - if ( aFind == m_aRowSets.end() ) - { - xRowSet.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RowSet"))),uno::UNO_QUERY); - uno::Reference< beans::XPropertySet> xRowSetProp(xRowSet,uno::UNO_QUERY); - xRowSetProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,uno::makeAny(getConnection())); - static TPropertyNamePair aMap; - if ( aMap.empty() ) - { - aMap.insert(TPropertyNamePair::value_type(PROPERTY_COMMAND,PROPERTY_COMMAND)); - aMap.insert(TPropertyNamePair::value_type(PROPERTY_COMMANDTYPE,PROPERTY_COMMANDTYPE)); - aMap.insert(TPropertyNamePair::value_type(PROPERTY_FILTER,PROPERTY_FILTER)); - aMap.insert(TPropertyNamePair::value_type(PROPERTY_ESCAPEPROCESSING,PROPERTY_ESCAPEPROCESSING)); - } + if ( m_xRowSet.is() || !m_xReportDefinition.is() ) + return m_xRowSet; - uno::Reference<report::XReportComponent> xComponent(_xReportComponent,uno::UNO_QUERY); - if ( xComponent.is() ) - { - uno::Reference< report::XSection > xSection = xComponent->getSection(); - uno::Reference< report::XReportDefinition> xReportDefinition; - if ( xSection.is() ) - xReportDefinition = xSection->getReportDefinition(); - else - xReportDefinition.set(xComponent,uno::UNO_QUERY); - if ( xReportDefinition.is() ) + try { - uno::Reference< beans::XPropertyChangeListener> xMediator = new OPropertyMediator(xReportDefinition.get(),xRowSetProp,aMap); - m_aRowSets.insert(TRowSets::value_type(_xAWTComponent,TRowSetPair(xMediator,xRowSet))); - uno::Reference< lang::XComponent> xAwtComponent(_xAWTComponent,uno::UNO_QUERY); - if ( xAwtComponent.is() ) - xAwtComponent->addEventListener(static_cast<XModifyListener*>(this)); - } + uno::Reference< sdbc::XRowSet > xRowSet( getORB()->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.RowSet" ) ) ), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW ); + + xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) ); + + TPropertyNamePair aPropertyMediation; + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMAND, PROPERTY_COMMAND ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMANDTYPE, PROPERTY_COMMANDTYPE ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_FILTER, PROPERTY_FILTER ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_ESCAPEPROCESSING, PROPERTY_ESCAPEPROCESSING ) ); + + m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation ); + m_xRowSet = xRowSet; } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } - else - xRowSet = aFind->second.second; - return xRowSet; + + return m_xRowSet; } // ----------------------------------------------------------------------------- void OReportController::insertGraphic() @@ -3244,6 +3259,7 @@ getUndoMgr()->LeaveListAction(); } + // ----------------------------------------------------------------------------- void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) { @@ -3253,12 +3269,14 @@ ::boost::shared_ptr<OReportSection> pReportSection[2]; pReportSection[0] = m_pMyOwnView->getMarkedSection(); - if ( pReportSection[0].get() ) - { + if ( !pReportSection[0].get() ) + return; + uno::Reference<report::XSection> xCurrentSection = m_pMyOwnView->getCurrentSection(); - const String sUndoAction(String(ModuleRes(RID_STR_UNDO_INSERT_CONTROL))); - getUndoMgr()->EnterListAction( sUndoAction, String() ); + UndoManagerListAction aUndo( *getUndoMgr(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) ); + try + { bool bHandleOnlyOne = false; const PropertyValue* pIter = aArgs.getConstArray(); const PropertyValue* pEnd = pIter + aArgs.getLength(); @@ -3301,15 +3319,19 @@ // clear all selections m_pMyOwnView->unmarkAllObjects(NULL); - uno::Reference<beans::XPropertySet> xField( aDescriptor[ ::svx::daColumnObject ],uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xField( aDescriptor[ ::svx::daColumnObject ], uno::UNO_QUERY ); uno::Reference< lang::XComponent > xHoldAlive; if ( !xField.is() ) { - uno::Reference< container::XNameAccess> xColumns; - ::rtl::OUString sCommand( ::comphelper::getString(aDescriptor[ ::svx::daCommand ])); - ::rtl::OUString sColumnName(::comphelper::getString(aDescriptor[ ::svx::daColumnName ])); - sal_Int32 nCommandType(::comphelper::getINT32(aDescriptor[ ::svx::daCommandType ])); - uno::Reference<sdbc::XConnection> xConnection(getConnection()); + ::rtl::OUString sCommand; + ::rtl::OUString sColumnName; + sal_Int32 nCommandType( -1 ); + OSL_VERIFY( aDescriptor[ ::svx::daCommand ] >>= sCommand ); + OSL_VERIFY( aDescriptor[ ::svx::daColumnName ] >>= sColumnName ); + OSL_VERIFY( aDescriptor[ ::svx::daCommandType ] >>= nCommandType ); + + uno::Reference< container::XNameAccess > xColumns; + uno::Reference< sdbc::XConnection > xConnection( getConnection() ); if ( sCommand.getLength() && nCommandType != -1 && sColumnName.getLength() && xConnection.is() ) { if ( !xReportDefinition->getCommand().getLength() ) @@ -3320,15 +3342,56 @@ xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive); if ( xColumns.is() && xColumns->hasByName(sColumnName) ) - xField.set(xColumns->getByName(sColumnName),uno::UNO_QUERY); + xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY ); + } + + if ( !xField.is() ) + { + #if OSL_DEBUG_LEVEL > 0 + try + { + uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); + ::rtl::OUString sRowSetCommand; + sal_Int32 nRowSetCommandType( -1 ); + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand ); + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType ); + OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ), + "OReportController::addPairControls: this only works for a data source which equals our current settings!" ); + // if this asserts, then either our row set and our report definition are not in sync, or somebody + // requested the creation of a control/pair for another data source than what our report + // definition is bound to - which is not supported for the parameters case, since we + // can retrieve parameters from the RowSet only. } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } - sal_uInt16 nOBJID = 0; - if ( xField.is() ) + #endif + + // no column name - perhaps a parameter name? + uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_QUERY_THROW ); + sal_Int32 nParamCount( xParams->getCount() ); + for ( sal_Int32 i=0; i<nParamCount; ++i) + { + uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW ); + ::rtl::OUString sParamName; + OSL_VERIFY( xParamCol->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sParamName ); + if ( sParamName == sColumnName ) { + xField = xParamCol; + break; + } + } + } + } + if ( !xField.is() ) + continue; + + sal_uInt16 nOBJID = 0; sal_Int32 nDataType = sdbc::DataType::BINARY; xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType; - switch (nDataType) + switch ( nDataType ) { case sdbc::DataType::BINARY: case sdbc::DataType::VARBINARY: @@ -3339,12 +3402,14 @@ nOBJID = OBJ_DLG_FORMATTEDFIELD; break; } - } - if (nOBJID) - { + + if ( !nOBJID ) + continue; + Reference< util::XNumberFormatsSupplier > xSupplier = getNumberFormatter()->getNumberFormatsSupplier(); - if ( xSupplier.is() ) - { + if ( !xSupplier.is() ) + continue; + Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats()); SdrUnoObj* pControl[2]; pControl[0] = NULL; @@ -3445,12 +3510,15 @@ } } else + { for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) delete pControl[i]; } - } // if (nOBJID) } - getUndoMgr()->LeaveListAction(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
