diff options
19 files changed, 222 insertions, 206 deletions
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 440d5237f3b1..59d7bb702f83 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -33,6 +33,7 @@ #include "controltype.hxx" #include "propctrlr.hrc" +#include "extensio.hrc" #include "fontdialog.hxx" #include "formcomponenthandler.hxx" #include "formlinkdialog.hxx" @@ -2538,17 +2539,38 @@ namespace pcr Reference< XQueriesSupplier > xSupplyQueries( m_xRowSetConnection, UNO_QUERY ); Reference< XNameAccess > xQueryNames; if ( xSupplyQueries.is() ) + { xQueryNames = xSupplyQueries->getQueries(); - DBG_ASSERT( xQueryNames.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: no way to obtain the queries of the connection!" ); - if ( !xQueryNames.is() ) + impl_fillQueryNames_throw(xQueryNames,_out_rNames); + } + } + //------------------------------------------------------------------------ + void FormComponentPropertyHandler::impl_fillQueryNames_throw( const Reference< XNameAccess >& _xQueryNames,::std::vector< ::rtl::OUString >& _out_rNames,const ::rtl::OUString& _sName ) const + { + DBG_ASSERT( _xQueryNames.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: no way to obtain the queries of the connection!" ); + if ( !_xQueryNames.is() ) return; - Sequence< ::rtl::OUString> aQueryNames = xQueryNames->getElementNames(); + Sequence< ::rtl::OUString> aQueryNames = _xQueryNames->getElementNames(); sal_uInt32 nCount = aQueryNames.getLength(); const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray(); + sal_Bool bAdd = _sName.getLength(); for ( sal_uInt32 i=0; i<nCount; i++, ++pQueryNames ) - _out_rNames.push_back( *pQueryNames ); + { + ::rtl::OUStringBuffer sTemp; + if ( bAdd ) + { + sTemp.append(_sName); + sTemp.appendAscii("/"); + } + sTemp.append(*pQueryNames); + Reference< XNameAccess > xSubQueries(_xQueryNames->getByName(*pQueryNames),UNO_QUERY); + if ( xSubQueries.is() ) + impl_fillQueryNames_throw(xSubQueries,_out_rNames,sTemp.makeStringAndClear()); + else + _out_rNames.push_back( sTemp.makeStringAndClear() ); + } } //------------------------------------------------------------------------ @@ -2710,7 +2732,7 @@ namespace pcr SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter(); double dPreviewVal = OFormatSampleControl::getPreviewValue(pFormatter,nFormatKey); - SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO ); + SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, String( PcrRes( RID_STR_TEXT_FORMAT ) ), SID_ATTR_NUMBERFORMAT_INFO ); aCoreSet.Put( aFormatter ); // a tab dialog with a single page diff --git a/extensions/source/propctrlr/formcomponenthandler.hxx b/extensions/source/propctrlr/formcomponenthandler.hxx index 9b972896e856..d02a05c8e650 100644 --- a/extensions/source/propctrlr/formcomponenthandler.hxx +++ b/extensions/source/propctrlr/formcomponenthandler.hxx @@ -238,6 +238,15 @@ namespace pcr */ void impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const; + /** describes the UI for selecting a query name + + @precond + m_xRowSetConnection is not <NULL/> + */ + void impl_fillQueryNames_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xQueryNames + ,::std::vector< ::rtl::OUString >& _out_rNames + ,const ::rtl::OUString& _sName = ::rtl::OUString() ) const; + /** describes the UI for selecting a ListSource (for list-like form controls) @precond ->m_xRowSetConnection is not <NULL/> diff --git a/extensions/source/propctrlr/propres.src b/extensions/source/propctrlr/propres.src index 7ce673f8136f..6d2729f12625 100644 --- a/extensions/source/propctrlr/propres.src +++ b/extensions/source/propctrlr/propres.src @@ -64,3 +64,8 @@ String RID_EMBED_IMAGE_PLACEHOLDER { Text [ en-US ] = "<Embedded-Image>"; }; + +String RID_STR_TEXT_FORMAT +{ + Text [ en-US ] = "Text"; +}; diff --git a/extensions/source/propctrlr/propresid.hrc b/extensions/source/propctrlr/propresid.hrc index 338b0eebab88..9bbd490478a7 100644 --- a/extensions/source/propctrlr/propresid.hrc +++ b/extensions/source/propctrlr/propresid.hrc @@ -45,6 +45,7 @@ #define RID_STR_PROPPAGE_DEFAULT ( RID_PROPCONTROLLER_START + 1 ) #define RID_STR_PROPPAGE_DATA ( RID_PROPCONTROLLER_START + 2 ) #define RID_STR_HELP_SECTION_LABEL ( RID_PROPCONTROLLER_START + 3 ) -#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 5 ) +#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 4 ) +#define RID_STR_TEXT_FORMAT ( RID_PROPCONTROLLER_START + 5 ) #endif // EXTENSIONS_PROPRESID_HRC diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx index b27afa750fa6..b153369f3a6d 100644 --- a/extensions/source/propctrlr/usercontrol.cxx +++ b/extensions/source/propctrlr/usercontrol.cxx @@ -44,6 +44,7 @@ #include <com/sun/star/util/Time.hpp> #include "modulepcr.hxx" #include "propresid.hrc" + //............................................................................ namespace pcr { @@ -118,39 +119,52 @@ namespace pcr getTypedControlWindow()->SetFormatKey( nFormatKey ); SvNumberFormatter* pNF = getTypedControlWindow()->GetFormatter(); - getTypedControlWindow()->SetValue( getPreviewValue(pNF,getTypedControlWindow()->GetFormatKey()) ); + const SvNumberformat* pEntry = pNF->GetEntry( nFormatKey ); + OSL_ENSURE( pEntry, "OFormatSampleControl::setValue: invalid format entry!" ); + + const bool bIsTextFormat = ( pEntry && pEntry->IsTextFormat() ); + if ( bIsTextFormat ) + getTypedControlWindow()->SetText( String( PcrRes( RID_STR_TEXT_FORMAT ) ) ); + else + getTypedControlWindow()->SetValue( pEntry ? getPreviewValue( *pEntry ) : 1234.56789 ); } else getTypedControlWindow()->SetText( String() ); } //------------------------------------------------------------------ + double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry ) + { + double nValue = 1234.56789; + switch ( i_rEntry.GetType() & ~NUMBERFORMAT_DEFINED ) + { + case NUMBERFORMAT_DATE: + { + Date aCurrentDate; + static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899); + nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE); + } + break; + case NUMBERFORMAT_TIME: + case NUMBERFORMAT_DATETIME: + { + Time aCurrentTime; + nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime())); + } + break; + default: + break; + } + return nValue; + } + + //------------------------------------------------------------------ double OFormatSampleControl::getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey) { const SvNumberformat* pEntry = _pNF->GetEntry(_nFormatKey); DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" ); double nValue = 1234.56789; if ( pEntry ) - { - switch (pEntry->GetType() & ~NUMBERFORMAT_DEFINED) - { - case NUMBERFORMAT_DATE: - { - Date aCurrentDate; - static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899); - nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE); - } - break; - case NUMBERFORMAT_TIME: - case NUMBERFORMAT_DATETIME: - { - Time aCurrentTime; - nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime())); - } - break; - default: - break; - } - } + nValue = getPreviewValue( *pEntry ); return nValue; } //------------------------------------------------------------------ diff --git a/extensions/source/propctrlr/usercontrol.hxx b/extensions/source/propctrlr/usercontrol.hxx index 0d9a0e5a85d7..3fca7e12324f 100644 --- a/extensions/source/propctrlr/usercontrol.hxx +++ b/extensions/source/propctrlr/usercontrol.hxx @@ -90,6 +90,9 @@ namespace pcr * \return current date or time or the value 1234.56789 */ static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey); + + private: + static double getPreviewValue( const SvNumberformat& i_rEntry ); }; //======================================================================== diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 0ddab1faecdb..0ff3faca8beb 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -66,6 +66,7 @@ #include <comphelper/property.hxx> #include <connectivity/dbconversion.hxx> #include <connectivity/dbtools.hxx> +#include <connectivity/formattedcolumnvalue.hxx> #include <connectivity/predicateinput.hxx> #include <rtl/ustrbuf.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -106,7 +107,7 @@ namespace frm //--------------------------------------------------------------------- OFilterControl::OFilterControl( const Reference< XMultiServiceFactory >& _rxORB ) :m_aTextListeners( *this ) - ,m_xORB( _rxORB ) + ,m_aContext( _rxORB ) ,m_aParser( _rxORB ) ,m_nControlClass( FormComponentType::TEXTFIELD ) ,m_bFilterList( sal_False ) @@ -133,12 +134,11 @@ namespace frm if ( !m_xFormatter.is() ) { // we can create one from the connection, if it's an SDB connection - Reference< XNumberFormatsSupplier > xFormatSupplier = ::dbtools::getNumberFormats( m_xConnection, sal_True, m_xORB ); + Reference< XNumberFormatsSupplier > xFormatSupplier = ::dbtools::getNumberFormats( m_xConnection, sal_True, m_aContext.getLegacyServiceFactory() ); if ( xFormatSupplier.is() ) { - m_xFormatter = m_xFormatter.query( - m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) ) ) ); + m_aContext.createComponent( "com.sun.star.util.NumberFormatter", m_xFormatter ); if ( m_xFormatter.is() ) m_xFormatter->attachNumberFormatsSupplier( xFormatSupplier ); } @@ -380,170 +380,114 @@ namespace frm // already asserted in ensureInitialized return; - // declare here for later disposal - Reference< XResultSet > xListCursor; - Reference< XStatement > xStatement; + // ensure the cursor and the statement are disposed as soon as we leave + ::utl::SharedUNOComponent< XResultSet > xListCursor; + ::utl::SharedUNOComponent< XStatement > xStatement; try { m_bFilterListFilled = sal_True; - Reference< XPropertySet > xSet(getModel(), UNO_QUERY); - if (xSet.is() && m_xField.is()) + if ( !m_xField.is() ) + return; + + ::rtl::OUString sFieldName; + m_xField->getPropertyValue( PROPERTY_NAME ) >>= sFieldName; + + // here we need a table to which the field belongs to + const Reference< XChild > xModelAsChild( getModel(), UNO_QUERY_THROW ); + const Reference< XRowSet > xForm( xModelAsChild->getParent(), UNO_QUERY_THROW ); + const Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); + + // create a query composer + const Reference< XConnection > xConnection( ::dbtools::getConnection( xForm ), UNO_SET_THROW ); + const Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY_THROW ); + const Reference< XSQLQueryComposer > xComposer( xFactory->createQueryComposer(), UNO_SET_THROW ); + + // set the statement on the composer + ::rtl::OUString sStatement; + xFormProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sStatement; + xComposer->setQuery( sStatement ); + + // the field we're bound to + const Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY_THROW ); + const Reference< XNameAccess > xFieldNames( xSuppColumns->getColumns(), UNO_SET_THROW ); + if ( !xFieldNames->hasByName( sFieldName ) ) + return; + ::rtl::OUString sRealFieldName, sTableName; + const Reference< XPropertySet > xComposerFieldProps( xFieldNames->getByName( sFieldName ), UNO_QUERY_THROW ); + xComposerFieldProps->getPropertyValue( PROPERTY_REALNAME ) >>= sRealFieldName; + xComposerFieldProps->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName; + + // obtain the table of the field + const Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY_THROW ); + const Reference< XNameAccess > xTablesNames( xSuppTables->getTables(), UNO_SET_THROW ); + const Reference< XNamed > xNamedTable( xTablesNames->getByName( sTableName ), UNO_QUERY_THROW ); + sTableName = xNamedTable->getName(); + + // create a statement selecting all values for the given field + ::rtl::OUStringBuffer aStatement; + + const Reference< XDatabaseMetaData > xMeta( xConnection->getMetaData(), UNO_SET_THROW ); + const ::rtl::OUString sQuoteChar = xMeta->getIdentifierQuoteString(); + + aStatement.appendAscii( "SELECT DISTINCT " ); + aStatement.append( sQuoteChar ); + aStatement.append( sRealFieldName ); + aStatement.append( sQuoteChar ); + + // if the field had an alias in our form's statement, give it this alias in the new statement, too + if ( sFieldName.getLength() && ( sFieldName != sRealFieldName ) ) { - ::rtl::OUString sName; - m_xField->getPropertyValue(PROPERTY_NAME) >>= sName; - - // here we need a table to which the field belongs to - Reference< XChild > xModelAsChild( xSet, UNO_QUERY ); - Reference< XRowSet > xForm( xModelAsChild->getParent(), UNO_QUERY ); - Reference< XPropertySet > xFormAsSet( xForm, UNO_QUERY ); - - // Connection holen - Reference< XConnection > xConnection; - if ( xForm.is() ) - xConnection = ::dbtools::getConnection( xForm ); - Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY ); - OSL_ENSURE( xFactory.is() && xFormAsSet.is(), "OFilterControl::implInitFilterList: invalid form or invalid connection!" ); - if ( !xFactory.is() || !xFormAsSet.is() ) - return; - - // create a query composer - Reference< XSQLQueryComposer > xComposer = xFactory->createQueryComposer(); - OSL_ENSURE( xComposer.is() , "OFilterControl::implInitFilterList: invalid query composer!" ); - if ( !xComposer.is() ) - return; - - // set the statement on the composer, ... - ::rtl::OUString sStatement; - xFormAsSet->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sStatement; - xComposer->setQuery( sStatement ); - - // ... and ask it for the involved tables and queries - Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY ); - Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY ); - - Reference< XNameAccess > xFieldNames; - if ( xSuppColumns.is() ) xFieldNames = xSuppColumns->getColumns(); - Reference< XNameAccess > xTablesNames; - if ( xSuppTables.is() ) xTablesNames = xSuppTables->getTables(); - - if ( !xFieldNames.is() || !xTablesNames.is() ) - { - OSL_ENSURE( sal_False, "OFilterControl::implInitFilterList: invalid query composer (no fields or no tables supplied)!" ); - return; - } - - // search the field - Reference< XPropertySet > xComposerFieldAsSet; - if ( xFieldNames->hasByName( sName ) ) - xFieldNames->getByName( sName ) >>= xComposerFieldAsSet; - - if ( xComposerFieldAsSet.is() - && ::comphelper::hasProperty( PROPERTY_TABLENAME, xComposerFieldAsSet ) - && ::comphelper::hasProperty( PROPERTY_REALNAME, xComposerFieldAsSet ) - ) - { - ::rtl::OUString sFieldName, sTableName; - xComposerFieldAsSet->getPropertyValue(PROPERTY_REALNAME) >>= sFieldName; - xComposerFieldAsSet->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; - - // no possibility to create a select statement - // looking for the complete table name - if (!xTablesNames->hasByName(sTableName)) - return; - - // this is the tablename - Reference< XNamed > xName; - xTablesNames->getByName(sTableName) >>= xName; - OSL_ENSURE(xName.is(),"No XName interface!"); - sTableName = xName->getName(); - - // ein Statement aufbauen und abschicken als query - // Access to the connection - - Reference< XColumn > xDataField; - - Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData(); - ::rtl::OUString aQuote = xMeta->getIdentifierQuoteString(); - ::rtl::OUStringBuffer aStatement; - aStatement.appendAscii( "SELECT DISTINCT " ); - aStatement.append( ::dbtools::quoteName( aQuote, sName ) ); - - if ( sFieldName.getLength() && ( sName != sFieldName ) ) - { - aStatement.appendAscii(" AS "); - aStatement.append( ::dbtools::quoteName(aQuote, sFieldName) ); - } - - aStatement.appendAscii( " FROM " ); + aStatement.appendAscii(" AS "); + aStatement.append( sQuoteChar ); + aStatement.append( sFieldName ); + aStatement.append( sQuoteChar ); + } - ::rtl::OUString sCatalog, sSchema, sTable; - ::dbtools::qualifiedNameComponents( xMeta, sTableName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation ); - aStatement.append( ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sTable ) ); + aStatement.appendAscii( " FROM " ); - ::rtl::OUString sSelectStatement( aStatement.makeStringAndClear( ) ); - xStatement = xConnection->createStatement(); - xListCursor = xStatement->executeQuery( sSelectStatement ); + ::rtl::OUString sCatalog, sSchema, sTable; + ::dbtools::qualifiedNameComponents( xMeta, sTableName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation ); + aStatement.append( ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sTable ) ); - Reference< XColumnsSupplier > xSupplyCols(xListCursor, UNO_QUERY); - Reference< XIndexAccess > xFields; - if (xSupplyCols.is()) - xFields = Reference< XIndexAccess > (xSupplyCols->getColumns(), UNO_QUERY); - if (xFields.is()) - xFields->getByIndex(0) >>= xDataField; - if (!xDataField.is()) - return; + // execute the statement + xStatement.reset( xConnection->createStatement() ); + const ::rtl::OUString sSelectStatement( aStatement.makeStringAndClear( ) ); + xListCursor.reset( xStatement->executeQuery( sSelectStatement ) ); + // retrieve the one column which we take the values from + const Reference< XColumnsSupplier > xSupplyCols( xListCursor, UNO_QUERY_THROW ); + const Reference< XIndexAccess > xFields( xSupplyCols->getColumns(), UNO_QUERY_THROW ); + const Reference< XPropertySet > xDataField( xFields->getByIndex(0), UNO_QUERY_THROW ); - sal_Int16 i = 0; - ::std::vector< ::rtl::OUString> aStringList; - aStringList.reserve(16); - ::rtl::OUString aStr; + // ensure the values will be formatted according to the field format + const ::dbtools::FormattedColumnValue aFormatter( m_xFormatter, xDataField ); - ::com::sun::star::util::Date aNullDate( ::dbtools::DBTypeConversion::getStandardDate() ); - sal_Int32 nFormatKey = 0; - try - { - m_xFormatter->getNumberFormatsSupplier()->getNumberFormatSettings()->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) - >>= aNullDate; - nFormatKey = ::comphelper::getINT32(m_xField->getPropertyValue(PROPERTY_FORMATKEY)); - } - catch(const Exception&) - { - } + ::std::vector< ::rtl::OUString > aProposals; + aProposals.reserve(16); + while ( xListCursor->next() && ( aProposals.size() < size_t( SHRT_MAX ) ) ) + { + const ::rtl::OUString sCurrentValue = aFormatter.getFormattedValue(); + aProposals.push_back( sCurrentValue ); + } - sal_Int16 nKeyType = ::comphelper::getNumberFormatType(m_xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey); - while ( xListCursor->next() && ( i++ < SHRT_MAX) ) - { - aStr = ::dbtools::DBTypeConversion::getValue(xDataField, m_xFormatter, aNullDate, nFormatKey, nKeyType); - aStringList.push_back(aStr); - } + // fill the list items into our peer + Sequence< ::rtl::OUString> aStringSeq( aProposals.size() ); + ::std::copy( aProposals.begin(), aProposals.end(), aStringSeq.getArray() ); - Sequence< ::rtl::OUString> aStringSeq(aStringList.size()); - ::rtl::OUString* pustrStrings = aStringSeq.getArray(); - for (i = 0; i < (sal_Int16)aStringList.size(); ++i) - pustrStrings[i] = aStringList[i]; + const Reference< XComboBox > xComboBox( getPeer(), UNO_QUERY_THROW ); + xComboBox->addItems( aStringSeq, 0 ); - Reference< XComboBox > xComboBox( getPeer(), UNO_QUERY); - if ( xComboBox.is() ) - { - xComboBox->addItems(aStringSeq, 0); - // set the drop down line count - sal_Int16 nLineCount = ::std::min( (sal_Int16)10, (sal_Int16)aStringSeq.getLength() ); - xComboBox->setDropDownLineCount( nLineCount ); - } - } - } + // set the drop down line count to something reasonable + const sal_Int16 nLineCount = ::std::min( sal_Int16( 16 ), sal_Int16( aStringSeq.getLength() ) ); + xComboBox->setDropDownLineCount( nLineCount ); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - - ::comphelper::disposeComponent( xListCursor ); - ::comphelper::disposeComponent( xStatement ); } // XFocusListener @@ -587,7 +531,7 @@ namespace frm aNewText.trim(); if ( aNewText.getLength() ) { - ::dbtools::OPredicateInputController aPredicateInput( m_xORB, m_xConnection, getParseContext() ); + ::dbtools::OPredicateInputController aPredicateInput( m_aContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); ::rtl::OUString sErrorMessage; if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) { @@ -780,7 +724,8 @@ namespace frm aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny( m_xMessageParent ), PropertyState_DIRECT_VALUE); static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.sdb.ErrorMessageDialog" ); - Reference< XExecutableDialog > xErrorDialog( m_xORB->createInstanceWithArguments( s_sDialogServiceName, aArgs ), UNO_QUERY ); + + Reference< XExecutableDialog > xErrorDialog( m_aContext.createComponentWithArguments( s_sDialogServiceName, aArgs ), UNO_QUERY ); if ( xErrorDialog.is() ) xErrorDialog->execute(); else @@ -791,7 +736,7 @@ namespace frm } catch( const Exception& ) { - OSL_ENSURE( sal_False, "displayException: could not display the error message!" ); + DBG_UNHANDLED_EXCEPTION(); } } diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx index f07c8ff883c8..b59b673ac664 100644 --- a/forms/source/component/Filter.hxx +++ b/forms/source/component/Filter.hxx @@ -40,11 +40,10 @@ #include <com/sun/star/sdb/SQLContext.hpp> #include <toolkit/controls/unocontrol.hxx> -#ifndef _TOOLKIT_AWT_LISTENERMULTIPLEXER_HXX_ #include <toolkit/helper/listenermultiplexer.hxx> -#endif #include <cppuhelper/implbase5.hxx> #include <comphelper/uno3.hxx> +#include <comphelper/componentcontext.hxx> #include <cppuhelper/implbase4.hxx> #include <connectivity/sqlparse.hxx> #include <svx/ParseContext.hxx> @@ -72,7 +71,7 @@ namespace frm { TextListenerMultiplexer m_aTextListeners; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + ::comphelper::ComponentContext m_aContext; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java index 23dec6a80191..82f767a61ca4 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java @@ -459,7 +459,7 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog running = false; } - public void finishWizard() { + public boolean finishWizard() { boolean bSaveSuccess = false; // pesimistic :( XTextDocument xTextDocument; @@ -480,7 +480,7 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resFileExists); if (answer == 3) // user said: no, do not overwrite.... - return; + return false; } agendaTemplate.xTextDocument.lockControllers(); @@ -550,10 +550,11 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog } } else { agendaTemplate.xTextDocument.unlockControllers(); - return; + return false; } xDialog.endExecute(); running = false; + return true; } private void closeDocument() { diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index db5ccd32b8f7..10677558488c 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -292,7 +292,7 @@ public class SQLQueryComposer return sFromClause; } - public boolean setQueryCommand(String QueryName, XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) { try { diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java index a8dbe94e5db0..fe726c430a9b 100644 --- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java @@ -212,7 +212,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog running = false; } - public void finishWizard() + public boolean finishWizard() { switchToStep(getCurrentStep(), getMaxStep()); myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription); @@ -239,7 +239,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); if (answer == 3) // user said: no, do not overwrite.... { - return; + return false; } } } @@ -297,7 +297,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog xDialog.endExecute(); running = false; } - + return true; } public void closeDocument() diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java index 5b0a7939f6c2..678e5d55f3b1 100644 --- a/wizards/com/sun/star/wizards/form/FormWizard.java +++ b/wizards/com/sun/star/wizards/form/FormWizard.java @@ -308,7 +308,7 @@ public class FormWizard extends WizardDialog } // @Override - public void finishWizard() + public boolean finishWizard() { int ncurStep = getCurrentStep(); if ((switchToStep(ncurStep, SOSTORE_PAGE)) || (ncurStep == SOSTORE_PAGE)) @@ -326,6 +326,7 @@ public class FormWizard extends WizardDialog { bcreateForm = true; xDialog.endExecute(); + return true; } } } @@ -335,6 +336,7 @@ public class FormWizard extends WizardDialog showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage); } } + return false; } // @Override diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java index 1a47712ca213..5e5ce985c0c4 100644 --- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java @@ -253,7 +253,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog running = false; } - public void finishWizard() + public boolean finishWizard() { switchToStep(getCurrentStep(), getMaxStep()); try @@ -279,7 +279,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); if (answer == 3) // user said: no, do not overwrite.... { - return; + return false; } } } @@ -356,7 +356,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog xDialog.endExecute(); running = false; } - + return true; } public void closeDocument() diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 71fddc422d6a..7635425cf43f 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -174,7 +174,7 @@ public class Finalizer { CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); String queryName = getTitle(); - if ( CurDBMetaData.oSQLQueryComposer.setQueryCommand( queryName, m_queryWizard.xWindow, true, true ) + if ( CurDBMetaData.oSQLQueryComposer.setQueryCommand( m_queryWizard.xWindow, true, true ) && CurDBMetaData.createQuery( CurDBMetaData.oSQLQueryComposer, queryName ) ) return queryName; diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java index c9e4148dd3e1..e2cb0763dca9 100644 --- a/wizards/com/sun/star/wizards/query/QueryWizard.java +++ b/wizards/com/sun/star/wizards/query/QueryWizard.java @@ -284,22 +284,22 @@ public class QueryWizard extends DatabaseObjectWizard } } - public void finishWizard() + public boolean finishWizard() { int ncurStep = getCurrentStep(); - if ((switchToStep(ncurStep, SOSUMMARY_PAGE)) || (ncurStep == SOSUMMARY_PAGE)) + if ( ( ncurStep == SOSUMMARY_PAGE ) + || ( switchToStep( ncurStep, SOSUMMARY_PAGE ) ) + ) { m_createdQuery = CurFinalizer.finish(); if ( m_createdQuery.length() > 0 ) { loadSubComponent( CommandType.QUERY, m_createdQuery, CurFinalizer.displayQueryDesign() ); xDialog.endExecute(); - } - else - { - setControlProperty("btnWizardFinish", "Enabled", false); + return true; } } + return false; } protected void enterStep(int nOldStep, int nNewStep) diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index a4b4e3af18ad..a959c2dfd183 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -329,7 +329,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple boolean bQueryCreated = false; if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) { - bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(sMsgWizardName, this.xWindow, false, false); + bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(this.xWindow, false, false); CurReportDocument.setCommandType(CommandType.COMMAND); String sQuery = CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery(); @@ -520,7 +520,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple enableNavigationButtons(false, false, false); } - public void finishWizard() + public boolean finishWizard() { final int ncurStep = getCurrentStep(); if ((switchToStep(ncurStep, SOSTOREPAGE)) || (ncurStep == SOSTOREPAGE)) @@ -532,9 +532,11 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple nReportMode = CurReportFinalizer.getReportOpenMode(); m_sReportName = CurReportFinalizer.getStoreName(); xDialog.endExecute(); + return true; } } } + return false; } public void cancelWizard() diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 18a0a2a80e65..f72c73fd917c 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -288,7 +288,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, return bIsSuccessfull; } - public void finishWizard() + public boolean finishWizard() { super.switchToStep(super.getCurrentStep(), SOFINALPAGE); tablename = curFinalizer.getTableName(curScenarioSelector.getFirstTableName()); @@ -308,6 +308,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign ); m_tableName = curTableDescriptor.getComposedTableName(); super.xDialog.endExecute(); + return true; } } else @@ -317,6 +318,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, curFinalizer.setFocusToTableNameControl(); } } + return false; } private void callFormWizard() diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java index 15b840fa9c89..01d97c4278ed 100644 --- a/wizards/com/sun/star/wizards/ui/WizardDialog.java +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java @@ -685,7 +685,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL } } - public abstract void finishWizard(); + public abstract boolean finishWizard(); /** * This function will call if the finish button is pressed on the UI. @@ -693,8 +693,18 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL public void finishWizard_1() { enableFinishButton(false); - finishWizard(); - removeTerminateListener(); + boolean success = false; + try + { + success = finishWizard(); + } + finally + { + if ( !success ) + enableFinishButton( true ); + } + if ( success ) + removeTerminateListener(); } public int getMaximalStep() diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.java b/wizards/com/sun/star/wizards/web/WWD_Events.java index e396a46ddd30..88b986bb631c 100644 --- a/wizards/com/sun/star/wizards/web/WWD_Events.java +++ b/wizards/com/sun/star/wizards/web/WWD_Events.java @@ -942,9 +942,10 @@ public abstract class WWD_Events extends WWD_Startup /** * the user clicks the finish/create button. */ - public void finishWizard() + public boolean finishWizard() { finishWizard(true); + return true; } /** |