From f62c1a55c09050d54387312b4bd2e58bc8d869ad Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 16 Oct 2009 13:30:15 +0200 Subject: replace boost/spirit/core.hpp with boost/spirit/include/classic_core.hpp (prevents a warning) --- svx/inc/pch/precompiled_svx.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 8e9bc4d17930..8df4139a3d97 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -57,7 +57,7 @@ #include "basic/sbxvar.hxx" #include "boost/scoped_ptr.hpp" #include "boost/shared_ptr.hpp" -#include "boost/spirit/core.hpp" +#include "boost/spirit/include/classic_core.hpp" #include "bootstrp/sstring.hxx" #include "com/sun/star/accessibility/AccessibleEventId.hpp" #include "com/sun/star/accessibility/AccessibleEventObject.hpp" -- cgit From baf36e763f65cba54c8168d10ade4f38a5f62c64 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 16 Oct 2009 14:16:52 +0200 Subject: #i104329# introduce a dedicated PrimaryKeySupport property at DataSource.Settings, which determines whether a data source should (be assumed to) support primary keys. Valid values are TRUE (=> supports), FALSE (=> doesn't support) and VOID (=> use the old heuristics, i.e. consult XDatabaseMetaData.supportsCoreSQLGrammar) --- connectivity/inc/connectivity/dbmetadata.hxx | 11 +++++++++++ connectivity/source/commontools/dbmetadata.cxx | 21 +++++++++++++++++++++ connectivity/source/drivers/ado/ado.xcu | 5 +++++ connectivity/source/drivers/jdbc/jdbc.xcu | 5 +++++ connectivity/source/drivers/odbc/odbc.xcu | 5 +++++ 5 files changed, 47 insertions(+) diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx index 32662c5c157a..e1a38c71b5fe 100644 --- a/connectivity/inc/connectivity/dbmetadata.hxx +++ b/connectivity/inc/connectivity/dbmetadata.hxx @@ -121,6 +121,17 @@ namespace dbtools */ bool supportsSubqueriesInFrom() const; + /** checks whether the database supports primary keys + + Since there's no dedicated API to ask a database for this, a heuristics needs to be applied. + First, the PrimaryKeySupport settings of the data source is examined. If it is + or , then value is returned. If it is , then the database meta data are examined + for support of core SQL grammar, and the result is returned. The assumption is that a database/driver + which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience + shows this is true most of the time. + */ + bool supportsPrimaryKeys() const; + /** determines whether names in the database should be restricted to SQL-92 identifiers Effectively, this method checks the EnableSQL92Check property of the data source settings, diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 70220b1cd563..0c0e4b3e6bbc 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -256,6 +256,27 @@ namespace dbtools return supportsSubQueries; } + //-------------------------------------------------------------------- + bool DatabaseMetaData::supportsPrimaryKeys() const + { + lcl_checkConnected( *m_pImpl ); + + bool supportsPrimaryKeys = false; + try + { + Any setting; + if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) + || !( setting >>= supportsPrimaryKeys ) + ) + supportsPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return supportsPrimaryKeys; + } + //-------------------------------------------------------------------- const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const { diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index 236d38bd7ff7..8a106c70283f 100755 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -115,6 +115,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index 73fe2e9adc55..953e669906be 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -145,6 +145,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index cf306f10d57f..b3a9d7149650 100755 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -150,6 +150,11 @@ true + + + true + + -- cgit From f71d9e086e3735b0f489f5eac6bf735fb07f0f39 Mon Sep 17 00:00:00 2001 From: fs93730 Date: Fri, 16 Oct 2009 16:08:12 +0200 Subject: #i10000# --- connectivity/source/commontools/dbmetadata.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 0c0e4b3e6bbc..d148e5ca5a72 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -261,20 +261,20 @@ namespace dbtools { lcl_checkConnected( *m_pImpl ); - bool supportsPrimaryKeys = false; + bool doesSupportPrimaryKeys = false; try { Any setting; if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) - || !( setting >>= supportsPrimaryKeys ) + || !( setting >>= doesSupportPrimaryKeys ) ) - supportsPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + doesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return supportsPrimaryKeys; + return doesSupportPrimaryKeys; } //-------------------------------------------------------------------- -- cgit From 2b2cfc9d54f7de4bccf8715b00ea083301659cfc Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 16 Oct 2009 21:06:14 +0200 Subject: removed a useless usage of m_pView --- svx/source/form/fmctrler.cxx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index 48db5acbb01e..63cdd049ad89 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -1545,7 +1545,7 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException } // invalidate all features which depend on the currently focused control - if ( m_bDBConnection && !m_bFiltering && m_pView ) + if ( m_bDBConnection && !m_bFiltering ) implInvalidateCurrentControlDependentFeatures(); if (m_xCurrentControl.is()) @@ -3150,10 +3150,6 @@ void FmXFormController::stopFiltering() Sequence< Reference< XControl > > aControlsCopy( m_aControls ); const Reference< XControl > * pControls = aControlsCopy.getConstArray(); sal_Int32 nControlCount = aControlsCopy.getLength(); - // SdrPageView* pCurPageView = m_pView->GetSdrPageView(); - - // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND; - // const SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*((OutputDevice*)m_pView->GetActualOutDev())) : 0L; // clear the filter control map for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); @@ -4007,8 +4003,6 @@ void FmXFormController::implInvalidateCurrentControlDependentFeatures() aCurrentControlDependentFeatures.push_back( SID_FM_AUTOFILTER ); aCurrentControlDependentFeatures.push_back( SID_FM_REFRESH_FORM_CONTROL ); - if ( m_pView && m_pView->GetFormShell() && m_pView->GetFormShell()->GetImpl() ) - m_pView->GetFormShell()->GetImpl()->invalidateFeatures( aCurrentControlDependentFeatures ); invalidateFeatures( aCurrentControlDependentFeatures ); } -- cgit From 6fbd976a6a6c281857bdce2cc6c529b275312c9e Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 23 Oct 2009 09:46:03 +0200 Subject: step 0 of an UNOization of the css.form.(X)FormController implementation: move the API to css.form.runtime, so we can later add new API chunks without breaking compatibility of the existing API in css.form --- svx/inc/pch/precompiled_svx.hxx | 2 +- svx/inc/svx/fmdpage.hxx | 5 - svx/inc/svx/fmshell.hxx | 6 +- svx/inc/svx/fmview.hxx | 6 +- svx/source/form/filtnav.cxx | 221 ++++---- svx/source/form/fmctrler.cxx | 840 +++++++++++++--------------- svx/source/form/fmservs.cxx | 9 +- svx/source/form/fmshell.cxx | 4 +- svx/source/form/fmshimp.cxx | 176 +++--- svx/source/form/fmtextcontrolshell.cxx | 1 + svx/source/form/fmundo.cxx | 1 - svx/source/form/fmview.cxx | 2 +- svx/source/form/fmvwimp.cxx | 146 ++--- svx/source/form/formcontrolling.cxx | 2 +- svx/source/form/legacyformcontroller.cxx | 225 ++++++++ svx/source/form/makefile.mk | 3 +- svx/source/inc/filtnav.hxx | 27 +- svx/source/inc/fmcontrolbordermanager.hxx | 2 +- svx/source/inc/fmctrler.hxx | 883 +++++++++++++++--------------- svx/source/inc/fmservs.hxx | 2 +- svx/source/inc/fmshimp.hxx | 26 +- svx/source/inc/fmtextcontrolshell.hxx | 16 +- svx/source/inc/fmvwimp.hxx | 20 +- svx/source/inc/formcontrolling.hxx | 12 +- 24 files changed, 1414 insertions(+), 1223 deletions(-) create mode 100644 svx/source/form/legacyformcontroller.cxx diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 8df4139a3d97..b5a092b87eee 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -263,7 +263,7 @@ #include "com/sun/star/form/XDatabaseParameterListener.hpp" #include "com/sun/star/form/XForm.hpp" #include "com/sun/star/form/XFormComponent.hpp" -#include "com/sun/star/form/XFormController.hpp" +#include "com/sun/star/form/runtime/XFormController.hpp" #include "com/sun/star/form/XFormControllerListener.hpp" #include "com/sun/star/form/XFormsSupplier.hpp" #include "com/sun/star/form/XFormsSupplier2.hpp" diff --git a/svx/inc/svx/fmdpage.hxx b/svx/inc/svx/fmdpage.hxx index f71cc4751a63..a9f2783d643a 100644 --- a/svx/inc/svx/fmdpage.hxx +++ b/svx/inc/svx/fmdpage.hxx @@ -31,11 +31,6 @@ #define _SVX_FMDPAGE_HXX #include -#include -#include -#include -#include -#include #include #include #include "svx/svxdllapi.h" diff --git a/svx/inc/svx/fmshell.hxx b/svx/inc/svx/fmshell.hxx index f5d1c7b0c615..9f180156367f 100644 --- a/svx/inc/svx/fmshell.hxx +++ b/svx/inc/svx/fmshell.hxx @@ -58,7 +58,9 @@ class SdrUnoObj; namespace com { namespace sun { namespace star { namespace form { class XForm; - class XFormController; + namespace runtime { + class XFormController; + } } } } } //======================================================================== @@ -147,7 +149,7 @@ public: const OutputDevice& _rDevice, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _out_rxControl ) const; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > GetFormController( + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice diff --git a/svx/inc/svx/fmview.hxx b/svx/inc/svx/fmview.hxx index c79748ddb94f..3b965967ed42 100644 --- a/svx/inc/svx/fmview.hxx +++ b/svx/inc/svx/fmview.hxx @@ -54,7 +54,9 @@ namespace svx { class SdrUnoObj; namespace com { namespace sun { namespace star { namespace form { class XForm; - class XFormController; + namespace runtime { + class XFormController; + } } } } } class SVX_DLLPUBLIC FmFormView : public E3dView @@ -125,7 +127,7 @@ public: /** returns the form controller for a given form and a given device */ - SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > + SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; // SdrView diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 7ac8f8afbe29..437b0ff4f88a 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -30,50 +30,42 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif -#include "fmctrler.hxx" -#include "filtnav.hxx" -#include -#include -#include -#include "fmitems.hxx" -#ifndef _SVX_SVXIDS_HRC -#include -#endif -#ifndef _SVX_FMPROP_HRC +#include "filtnav.hxx" +#include "fmctrler.hxx" +#include "fmexch.hxx" +#include "fmhelp.hrc" +#include "fmitems.hxx" #include "fmprop.hrc" -#endif +#include "fmresids.hrc" +#include "gridcell.hxx" -#ifndef _SVX_FMHELP_HRC -#include "fmhelp.hrc" -#endif -#include -#include -#include -#include -#include -#include +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ -#ifndef _WRKWIN_HXX //autogen -#include -#endif -#include -#include -#include -#include -#include +#include #include +#include #include #include -#include -#include -#include -#include "gridcell.hxx" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -85,11 +77,6 @@ #define DROP_ACTION_TIMER_TICK_BASE 10 // das ist die Basis, mit der beide Angaben multipliziert werden (in ms) -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::beans; using namespace ::svxform; using namespace ::connectivity::simple; using namespace ::connectivity; @@ -100,6 +87,31 @@ namespace svxform { //........................................................................ + /** === begin UNO using === **/ + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::XTextListener; + using ::com::sun::star::awt::TextEvent; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::form::runtime::XFormController; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::form::XForm; + using ::com::sun::star::container::XChild; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::util::XNumberFormatter; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::uno::XInterface; + /** === end UNO using === **/ + //======================================================================== OFilterItemExchange::OFilterItemExchange() { @@ -168,7 +180,7 @@ Image FmFormItem::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItems, FmParentData); //------------------------------------------------------------------------ -FmFilterItem* FmFilterItems::Find(const Reference< ::com::sun::star::awt::XTextComponent > & _xText) const +FmFilterItem* FmFilterItems::Find(const Reference< XTextComponent > & _xText) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::Find" ); for (::std::vector::const_iterator i = m_aChilds.begin(); @@ -203,11 +215,11 @@ Image FmFilterItems::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItem, FmFilterData); //------------------------------------------------------------------------ -FmFilterItem::FmFilterItem(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, +FmFilterItem::FmFilterItem(const Reference< XMultiServiceFactory >& _rxFactory, FmFilterItems* pParent, const ::rtl::OUString& aFieldName, const ::rtl::OUString& aText, - const Reference< ::com::sun::star::awt::XTextComponent > & _xText) + const Reference< XTextComponent > & _xText) :FmFilterData(_rxFactory,pParent, aText) ,m_aFieldName(aFieldName) ,m_xText(_xText) @@ -315,36 +327,36 @@ TYPEINIT1( FmFilterCurrentChangedHint, SfxHint ); //======================================================================== // class FmFilterAdapter, Listener an den FilterControls //======================================================================== -class FmFilterAdapter : public ::cppu::WeakImplHelper1< ::com::sun::star::awt::XTextListener > +class FmFilterAdapter : public ::cppu::WeakImplHelper1< XTextListener > { FmFilterControls m_aFilterControls; FmFilterModel* m_pModel; public: - FmFilterAdapter(FmFilterModel* pModel, const Reference< ::com::sun::star::container::XIndexAccess >& xControllers); + FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers); -// ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ); +// XEventListener + virtual void SAL_CALL disposing(const EventObject& Source) throw( RuntimeException ); -// ::com::sun::star::awt::XTextListener - virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& e) throw( ::com::sun::star::uno::RuntimeException ); +// XTextListener + virtual void SAL_CALL textChanged(const TextEvent& e) throw( RuntimeException ); // helpers void dispose() throw( RuntimeException ); - void InsertElements(const Reference< ::com::sun::star::container::XIndexAccess >& xControllers); - void RemoveElement(const Reference< ::com::sun::star::awt::XTextComponent > & xText); + void InsertElements(const Reference< XIndexAccess >& xControllers); + void RemoveElement(const Reference< XTextComponent > & xText); - Reference< ::com::sun::star::beans::XPropertySet > getField(const Reference< ::com::sun::star::awt::XTextComponent > & xText) const; + Reference< XPropertySet > getField(const Reference< XTextComponent > & xText) const; void setText(sal_Int32 nPos, const FmFilterItem* pFilterItem, const ::rtl::OUString& rText); - void DeleteItemsByText(::std::vector& rItems, const Reference< ::com::sun::star::awt::XTextComponent > & xText); - Reference< ::com::sun::star::form::XForm > findForm(const Reference< ::com::sun::star::container::XChild >& xChild); + void DeleteItemsByText(::std::vector& rItems, const Reference< XTextComponent > & xText); + Reference< XForm > findForm(const Reference< XChild >& xChild); }; //------------------------------------------------------------------------ -FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< ::com::sun::star::container::XIndexAccess >& xControllers) +FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers) :m_pModel(pModel) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::FmFilterAdapter" ); @@ -371,7 +383,7 @@ void FmFilterAdapter::dispose() throw( RuntimeException ) //------------------------------------------------------------------------------ // delete all items relate to the control void FmFilterAdapter::DeleteItemsByText(::std::vector& _rItems, - const Reference< ::com::sun::star::awt::XTextComponent > & xText) + const Reference< XTextComponent > & xText) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::DeleteItemsByText" ); for (::std::vector::reverse_iterator i = _rItems.rbegin(); @@ -399,19 +411,19 @@ void FmFilterAdapter::DeleteItemsByText(::std::vector& _rItems, } //------------------------------------------------------------------------ -void FmFilterAdapter::InsertElements(const Reference< ::com::sun::star::container::XIndexAccess >& xControllers) +void FmFilterAdapter::InsertElements(const Reference< XIndexAccess >& xControllers) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::InsertElements" ); for (sal_Int32 i = 0, nLen = xControllers->getCount(); i < nLen; ++i) { - Reference< ::com::sun::star::container::XIndexAccess > xElement; + Reference< XIndexAccess > xElement; xControllers->getByIndex(i) >>= xElement; // Insert the Elements of the controller InsertElements(xElement); // store the filter controls - FmXFormController* pController = FmXFormController::getImplementation( xElement.get() ); + FormController* pController = FormController::getImplementation( xElement ); DBG_ASSERT( pController, "FmFilterAdapter::InsertElements: no controller!" ); const FmFilterControls& rControls = pController->getFilterControls(); @@ -421,7 +433,7 @@ void FmFilterAdapter::InsertElements(const Reference< ::com::sun::star::containe } //------------------------------------------------------------------------------ -void FmFilterAdapter::RemoveElement(const Reference< ::com::sun::star::awt::XTextComponent > & xText) +void FmFilterAdapter::RemoveElement(const Reference< XTextComponent > & xText) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::RemoveElement" ); if (xText.is()) @@ -437,10 +449,10 @@ void FmFilterAdapter::RemoveElement(const Reference< ::com::sun::star::awt::XTex } //------------------------------------------------------------------------ -Reference< ::com::sun::star::beans::XPropertySet > FmFilterAdapter::getField(const Reference< ::com::sun::star::awt::XTextComponent > & xText) const +Reference< XPropertySet > FmFilterAdapter::getField(const Reference< XTextComponent > & xText) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::getField" ); - Reference< ::com::sun::star::beans::XPropertySet > xField; + Reference< XPropertySet > xField; FmFilterControls::const_iterator i = m_aFilterControls.find(xText); if (i != m_aFilterControls.end()) xField = (*i).second; @@ -455,12 +467,12 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos, { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::setText" ); // set the text for the text component - Reference< ::com::sun::star::awt::XTextComponent > xText(pFilterItem->GetTextComponent()); + Reference< XTextComponent > xText(pFilterItem->GetTextComponent()); xText->setText(rText); // get the controller of the text component and its filter rows FmFormItem* pFormItem = PTR_CAST(FmFormItem,pFilterItem->GetParent()->GetParent()); - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); + FormController* pController = FormController::getImplementation( pFormItem->GetController() ); DBG_ASSERT( pController, "FmFilterAdapter::setText: no controller!" ); FmFilterRows& rRows = pController->getFilterRows(); @@ -482,49 +494,49 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos, } -// ::com::sun::star::lang::XEventListener +// XEventListener //------------------------------------------------------------------------ -void SAL_CALL FmFilterAdapter::disposing(const ::com::sun::star::lang::EventObject& e) throw( RuntimeException ) +void SAL_CALL FmFilterAdapter::disposing(const EventObject& e) throw( RuntimeException ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::disposing" ); - Reference< ::com::sun::star::awt::XTextComponent > xText(e.Source,UNO_QUERY); + Reference< XTextComponent > xText(e.Source,UNO_QUERY); if (xText.is()) RemoveElement(xText); } // XTextListener //------------------------------------------------------------------------ -Reference< ::com::sun::star::form::XForm > FmFilterAdapter::findForm(const Reference< ::com::sun::star::container::XChild >& xChild) +Reference< XForm > FmFilterAdapter::findForm(const Reference< XChild >& xChild) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::findForm" ); - Reference< ::com::sun::star::form::XForm > xForm; + Reference< XForm > xForm; if (xChild.is()) { - xForm = Reference< ::com::sun::star::form::XForm >(xChild->getParent(), UNO_QUERY); + xForm = Reference< XForm >(xChild->getParent(), UNO_QUERY); if (!xForm.is()) - xForm = findForm(Reference< ::com::sun::star::container::XChild >(xChild->getParent(), UNO_QUERY)); + xForm = findForm(Reference< XChild >(xChild->getParent(), UNO_QUERY)); } return xForm; } // XTextListener //------------------------------------------------------------------------ -void FmFilterAdapter::textChanged(const ::com::sun::star::awt::TextEvent& e) throw( ::com::sun::star::uno::RuntimeException ) +void FmFilterAdapter::textChanged(const TextEvent& e) throw( RuntimeException ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::textChanged" ); // Find the according formitem in the - Reference< ::com::sun::star::awt::XControl > xControl(e.Source, UNO_QUERY); + Reference< XControl > xControl(e.Source, UNO_QUERY); if (!m_pModel || !xControl.is()) return; - Reference< ::com::sun::star::form::XForm > xForm(findForm(Reference< ::com::sun::star::container::XChild >(xControl->getModel(), UNO_QUERY))); + Reference< XForm > xForm(findForm(Reference< XChild >(xControl->getModel(), UNO_QUERY))); if (!xForm.is()) return; FmFormItem* pFormItem = m_pModel->Find(m_pModel->m_aChilds, xForm); if (pFormItem) { - Reference< ::com::sun::star::awt::XTextComponent > xText(e.Source, UNO_QUERY); + Reference< XTextComponent > xText(e.Source, UNO_QUERY); FmFilterItems* pFilter = PTR_CAST(FmFilterItems, pFormItem->GetChilds()[pFormItem->GetCurrentPosition()]); FmFilterItem* pFilterItem = pFilter->Find(xText); if (pFilterItem) @@ -545,7 +557,7 @@ void FmFilterAdapter::textChanged(const ::com::sun::star::awt::TextEvent& e) thr else { // searching the component by field name - ::rtl::OUString aFieldName = getLabelName(Reference< ::com::sun::star::beans::XPropertySet > (Reference< ::com::sun::star::awt::XControl > (xText, UNO_QUERY)->getModel(),UNO_QUERY)); + ::rtl::OUString aFieldName = getLabelName(Reference< XPropertySet > (Reference< XControl > (xText, UNO_QUERY)->getModel(),UNO_QUERY)); pFilterItem = new FmFilterItem(m_pModel->getORB(),pFilter, aFieldName, xText->getText(), xText); m_pModel->Insert(pFilter->GetChilds().end(), pFilterItem); @@ -559,7 +571,7 @@ void FmFilterAdapter::textChanged(const ::com::sun::star::awt::TextEvent& e) thr //======================================================================== TYPEINIT1(FmFilterModel, FmParentData); //------------------------------------------------------------------------ -FmFilterModel::FmFilterModel(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) +FmFilterModel::FmFilterModel(const Reference< XMultiServiceFactory >& _rxFactory) :FmParentData(_rxFactory,NULL, ::rtl::OUString()) ,OSQLParserClient(_rxFactory) ,m_xORB(_rxFactory) @@ -603,10 +615,10 @@ void FmFilterModel::Clear() } //------------------------------------------------------------------------ -void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); - if ((::com::sun::star::form::XFormController*) xCurrent.get() == (::com::sun::star::form::XFormController*) m_xController.get()) + if ((XFormController*) xCurrent.get() == (XFormController*) m_xController.get()) return; if (!xControllers.is()) @@ -616,7 +628,7 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA } // there is only a new current controller - if ((::com::sun::star::container::XIndexAccess*)m_xControllers.get() != (::com::sun::star::container::XIndexAccess*)xControllers.get()) + if ((XIndexAccess*)m_xControllers.get() != (XIndexAccess*)xControllers.get()) { Clear(); @@ -637,15 +649,15 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA } //------------------------------------------------------------------------ -void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent) +void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, FmParentData* pParent) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); sal_Int32 nCount = xControllers->getCount(); for (sal_Int32 i = 0; i < nCount; i++) { - Reference< ::com::sun::star::form::XFormController > xController; + Reference< XFormController > xController; xControllers->getByIndex(i) >>= xController; - Reference< ::com::sun::star::beans::XPropertySet > xModelAsSet(xController->getModel(), UNO_QUERY); + Reference< XPropertySet > xModelAsSet(xController->getModel(), UNO_QUERY); ::rtl::OUString aName = ::comphelper::getString(xModelAsSet->getPropertyValue(FM_PROP_NAME)); // Insert a new ::com::sun::star::form @@ -653,7 +665,7 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA Insert(pParent->GetChilds().end(), pFormItem); // And now insert the filters for the form - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); + FormController* pController = FormController::getImplementation( pFormItem->GetController() ); DBG_ASSERT( pController, "FmFilterAdapter::Update: no controller!" ); INT32 nPos = pController->getCurrentFilterPosition(); @@ -672,7 +684,7 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA for (FmFilterRow::const_iterator iter1 = rRow.begin(); iter1 != rRow.end(); ++iter1) { // insert new and conditons - ::rtl::OUString aFieldName = getLabelName(Reference< ::com::sun::star::beans::XPropertySet > (Reference< ::com::sun::star::awt::XControl > ((*iter1).first, UNO_QUERY)->getModel(),UNO_QUERY)); + ::rtl::OUString aFieldName = getLabelName(Reference< XPropertySet > (Reference< XControl > ((*iter1).first, UNO_QUERY)->getModel(),UNO_QUERY)); FmFilterItem* pANDCondition = new FmFilterItem(m_xORB,pFilterItems, aFieldName, (*iter1).second, (*iter1).first); Insert(pFilterItems->GetChilds().end(), pANDCondition); } @@ -681,13 +693,13 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA } // now add dependent controllers - Reference< ::com::sun::star::container::XIndexAccess > xControllerAsIndex(xController, UNO_QUERY); + Reference< XIndexAccess > xControllerAsIndex(xController, UNO_QUERY); Update(xControllerAsIndex, pFormItem); } } //------------------------------------------------------------------------ -FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< ::com::sun::star::form::XFormController > & xController) const +FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< XFormController > & xController) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector::const_iterator i = rItems.begin(); @@ -696,7 +708,7 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons FmFormItem* pForm = PTR_CAST(FmFormItem,*i); if (pForm) { - if ((::com::sun::star::form::XFormController*)xController.get() == (::com::sun::star::form::XFormController*)pForm->GetController().get()) + if ((XFormController*)xController.get() == (XFormController*)pForm->GetController().get()) return pForm; else { @@ -710,7 +722,7 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons } //------------------------------------------------------------------------ -FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< ::com::sun::star::form::XForm >& xForm) const +FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< XForm >& xForm) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector::const_iterator i = rItems.begin(); @@ -733,10 +745,10 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons } //------------------------------------------------------------------------ -void FmFilterModel::SetCurrentController(const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterModel::SetCurrentController(const Reference< XFormController > & xCurrent) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetCurrentController" ); - if ((::com::sun::star::form::XFormController*) xCurrent.get() == (::com::sun::star::form::XFormController*) m_xController.get()) + if ((XFormController*) xCurrent.get() == (XFormController*) m_xController.get()) return; m_xController = xCurrent; @@ -771,7 +783,7 @@ void FmFilterModel::AppendFilterItems(FmFormItem* pFormItem) Insert(i, pFilterItems); // do we need a new row - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); + FormController* pController = FormController::getImplementation( pFormItem->GetController() ); DBG_ASSERT( pController, "FmFilterAdapter::AppendFilterItems: no controller!" ); FmFilterRows& rRows = pController->getFilterRows(); @@ -808,7 +820,7 @@ void FmFilterModel::Remove(FmFilterData* pData) if (pData->ISA(FmFilterItems)) { FmFormItem* pFormItem = (FmFormItem*)pParent; - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); + FormController* pController = FormController::getImplementation( pFormItem->GetController() ); DBG_ASSERT( pController, "FmFilterAdapter::Remove: no controller!" ); FmFilterRows& rRows = pController->getFilterRows(); @@ -929,9 +941,9 @@ sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, UniString& rText, UniS OStaticDataAccessTools aStaticTools; Reference< XConnection > xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet > (m_xController->getModel(), UNO_QUERY))); - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); + Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - Reference< ::com::sun::star::util::XNumberFormatter > xFormatter(m_xORB->createInstance(FM_NUMBER_FORMATTER), UNO_QUERY); + Reference< XNumberFormatter > xFormatter(m_xORB->createInstance(FM_NUMBER_FORMATTER), UNO_QUERY); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); ::rtl::OUString aErr, aTxt(rText); @@ -941,7 +953,7 @@ sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, UniString& rText, UniS if (xParseNode.is()) { ::rtl::OUString aPreparedText; - ::com::sun::star::lang::Locale aAppLocale = Application::GetSettings().GetUILocale(); + Locale aAppLocale = Application::GetSettings().GetUILocale(); xParseNode->parseNodeToPredicateStr( aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); rText = aPreparedText; @@ -997,12 +1009,12 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) { // determine the filter position sal_Int32 nPos = i - rItems.begin(); - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); + FormController* pController = FormController::getImplementation( pFormItem->GetController() ); DBG_ASSERT( pController, "FmFilterAdapter::SetCurrentItems: no controller!" ); pController->setCurrentFilterPosition(nPos); pFormItem->SetCurrentPosition(nPos); - if ((::com::sun::star::form::XFormController*)m_xController.get() != (::com::sun::star::form::XFormController*)pFormItem->GetController().get()) + if ((XFormController*)m_xController.get() != (XFormController*)pFormItem->GetController().get()) // calls SetCurrentItems again SetCurrentController(pFormItem->GetController()); else @@ -1216,7 +1228,7 @@ void FmFilterNavigator::Clear() } //------------------------------------------------------------------------ -void FmFilterNavigator::UpdateContent(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::UpdateContent" ); if (xCurrent == m_pModel->GetCurrentController()) @@ -1293,7 +1305,6 @@ sal_Bool FmFilterNavigator::EditedEntry( SvLBoxEntry* pEntry, const XubString& r else { // display the error and return sal_False - SQLContext aError; aError.Message = String(SVX_RES(RID_STR_SYNTAXERROR)); aError.Details = aErrorMsg; @@ -1972,17 +1983,17 @@ void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell) m_pNavigator->UpdateContent( NULL, NULL ); else { - Reference< ::com::sun::star::form::XFormController > xController(pFormShell->GetImpl()->getActiveInternalController()); - Reference< ::com::sun::star::container::XIndexAccess > xContainer; + Reference< XFormController > xController(pFormShell->GetImpl()->getActiveInternalController()); + Reference< XIndexAccess > xContainer; if (xController.is()) { - Reference< ::com::sun::star::container::XChild > xChild(xController, UNO_QUERY); + Reference< XChild > xChild(xController, UNO_QUERY); for (Reference< XInterface > xParent(xChild->getParent()); xParent.is(); xParent = xChild.is() ? xChild->getParent() : Reference< XInterface > ()) { - xContainer = Reference< ::com::sun::star::container::XIndexAccess > (xParent, UNO_QUERY); - xChild = Reference< ::com::sun::star::container::XChild > (xParent, UNO_QUERY); + xContainer = Reference< XIndexAccess > (xParent, UNO_QUERY); + xChild = Reference< XChild > (xParent, UNO_QUERY); } } m_pNavigator->UpdateContent(xContainer, xController); diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index 63cdd049ad89..d0bff4ea83b0 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -100,26 +100,112 @@ #include using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::form::validation; -using namespace ::com::sun::star::form::runtime; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::container; using namespace ::comphelper; using namespace ::connectivity; -using namespace ::svxform; using namespace ::connectivity::simple; +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) +{ + return *( new ::svxform::FormController( _rxORB ) ); +} + +namespace svxform +{ + + /** === begin UNO using === **/ + using ::com::sun::star::sdb::XColumn; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::awt::XTabController; + using ::com::sun::star::awt::XToolkit; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::form::XGrid; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::sdb::XInteractionSupplyParameters; + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::uno::Any; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::XAggregation; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::sdbc::XDatabaseMetaData; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormatter; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::Property; + using ::com::sun::star::container::XEnumeration; + using ::com::sun::star::form::XFormComponent; + using ::com::sun::star::form::runtime::XFormOperations; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::container::XIdentifierReplace; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::form::XFormControllerListener; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::awt::XControlModel; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::form::validation::XValidatableFormComponent; + using ::com::sun::star::form::XLoadable; + using ::com::sun::star::script::XEventAttacherManager; + using ::com::sun::star::container::XContainer; + using ::com::sun::star::form::XBoundControl; + using ::com::sun::star::beans::XPropertyChangeListener; + using ::com::sun::star::awt::TextEvent; + using ::com::sun::star::form::XBoundComponent; + using ::com::sun::star::awt::XCheckBox; + using ::com::sun::star::awt::XComboBox; + using ::com::sun::star::awt::XListBox; + using ::com::sun::star::awt::ItemEvent; + using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::form::XReset; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::form::XGridControl; + using ::com::sun::star::awt::XVclWindowPeer; + using ::com::sun::star::form::validation::XValidator; + using ::com::sun::star::awt::FocusEvent; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::container::XChild; + using ::com::sun::star::form::TabulatorCycle_RECORDS; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::beans::NamedValue; + using ::com::sun::star::lang::NoSupportException; + using ::com::sun::star::sdb::RowChangeEvent; + using ::com::sun::star::frame::XStatusListener; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::sdb::SQLErrorEvent; + using ::com::sun::star::form::DatabaseParameterEvent; + using ::com::sun::star::sdb::ParametersRequest; + using ::com::sun::star::task::XInteractionRequest; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::FeatureStateEvent; + /** === end UNO using === **/ + namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason; + namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction; + //============================================================================== // ColumnInfo //============================================================================== @@ -184,7 +270,6 @@ ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSup :m_aColumns() ,m_bControlsInitialized( false ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::ColumnInfoCache" ); try { m_aColumns.clear(); @@ -242,7 +327,6 @@ namespace //------------------------------------------------------------------------------ void ColumnInfoCache::deinitializeControls() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::deinitializeControls" ); for ( ColumnInfos::iterator col = m_aColumns.begin(); col != m_aColumns.end(); ++col @@ -255,7 +339,6 @@ void ColumnInfoCache::deinitializeControls() //------------------------------------------------------------------------------ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::initializeControls" ); try { // for every of our known columns, find the controls which are bound to this column @@ -338,7 +421,6 @@ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > //------------------------------------------------------------------------------ const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::getColumnInfo" ); if ( _pos >= m_aColumns.size() ) throw IndexOutOfBoundsException(); @@ -424,7 +506,7 @@ void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, cons } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) +IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) { activateTabOrder(); return 1; @@ -441,7 +523,7 @@ struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch > } }; //.............................................................................. -IMPL_LINK( FmXFormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) +IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) { ::osl::MutexGuard aGuard( m_aMutex ); for ( ::std::set< sal_Int32 >::const_iterator aLoop = m_aInvalidFeatures.begin(); @@ -462,30 +544,12 @@ IMPL_LINK( FmXFormController, OnInvalidateFeatures, void*, /*_pNotInterestedInTh /*************************************************************************/ +DBG_NAME( FormController ) //------------------------------------------------------------------ -Reference< XInterface > SAL_CALL - FmXFormController_NewInstance_Impl(const Reference< XMultiServiceFactory > & _rxORB) -{ - return *(new FmXFormController(_rxORB)); -} - -//------------------------------------------------------------------ -namespace fmctrlr -{ - const ::rtl::OUString& getDataModeIdentifier() - { - static ::rtl::OUString s_sDataModeIdentifier = DATA_MODE; - return s_sDataModeIdentifier; - } -} -using namespace fmctrlr; - -DBG_NAME( FmXFormController ) -//------------------------------------------------------------------ -FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _rxORB, +FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB, FmFormView* _pView, Window* _pWindow ) - :FmXFormController_BASE( m_aMutex ) - ,OPropertySetHelper( FmXFormController_BASE::rBHelper ) + :FormController_BASE( m_aMutex ) + ,OPropertySetHelper( FormController_BASE::rBHelper ) ,OSQLParserClient(_rxORB) ,m_xORB(_rxORB) ,m_aActivateListeners(m_aMutex) @@ -498,11 +562,11 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ ,m_pWindow(_pWindow) ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) ,m_aControllerFeatures( _rxORB, this ) - ,m_aMode(getDataModeIdentifier()) - ,m_aLoadEvent( LINK( this, FmXFormController, OnLoad ) ) - ,m_aToggleEvent( LINK( this, FmXFormController, OnToggleAutoFields ) ) - ,m_aActivationEvent( LINK( this, FmXFormController, OnActivated ) ) - ,m_aDeactivationEvent( LINK( this, FmXFormController, OnDeactivated ) ) + ,m_aMode( DATA_MODE ) + ,m_aLoadEvent( LINK( this, FormController, OnLoad ) ) + ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) + ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) + ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) ) ,m_nCurrentFilterPosition(0) ,m_bCurrentRecordModified(sal_False) ,m_bCurrentRecordNew(sal_False) @@ -519,8 +583,7 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ ,m_bDetachEvents(sal_True) ,m_bAttemptedHandlerCreation( false ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::FmXFormController" ); - DBG_CTOR( FmXFormController, NULL ); + DBG_CTOR( FormController, NULL ); ::comphelper::increment(m_refCount); { @@ -529,7 +592,7 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ m_xORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.TabController" ) ), UNO_QUERY ); - DBG_ASSERT( m_xAggregate.is(), "FmXFormController::FmXFormController : could not create my aggregate !" ); + DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" ); m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY ); } @@ -539,14 +602,14 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ ::comphelper::decrement(m_refCount); m_aTabActivationTimer.SetTimeout( 500 ); - m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FmXFormController, OnActivateTabOrder ) ); + m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) ); m_aFeatureInvalidationTimer.SetTimeout( 200 ); - m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FmXFormController, OnInvalidateFeatures ) ); + m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) ); } //------------------------------------------------------------------ -FmXFormController::~FmXFormController() +FormController::~FormController() { { ::osl::MutexGuard aGuard( m_aMutex ); @@ -574,28 +637,25 @@ FmXFormController::~FmXFormController() DELETEZ( m_pControlBorderManager ); - DBG_DTOR( FmXFormController, NULL ); + DBG_DTOR( FormController, NULL ); } // ----------------------------------------------------------------------------- -void SAL_CALL FmXFormController::acquire() throw () +void SAL_CALL FormController::acquire() throw () { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::acquire" ); - FmXFormController_BASE::acquire(); + FormController_BASE::acquire(); } // ----------------------------------------------------------------------------- -void SAL_CALL FmXFormController::release() throw () +void SAL_CALL FormController::release() throw () { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::release" ); - FmXFormController_BASE::release(); + FormController_BASE::release(); } //------------------------------------------------------------------ -Any SAL_CALL FmXFormController::queryInterface( const Type& _rType ) throw(RuntimeException) +Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::queryInterface" ); - Any aRet = FmXFormController_BASE::queryInterface( _rType ); + Any aRet = FormController_BASE::queryInterface( _rType ); if ( !aRet.hasValue() ) aRet = OPropertySetHelper::queryInterface( _rType ); if ( !aRet.hasValue() ) @@ -604,9 +664,8 @@ Any SAL_CALL FmXFormController::queryInterface( const Type& _rType ) throw(Runti } //------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( RuntimeException ) +Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementationId" ); static ::cppu::OImplementationId* pId = NULL; if ( !pId ) { @@ -621,20 +680,18 @@ Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( Ru } //------------------------------------------------------------------------------ -Sequence< Type > SAL_CALL FmXFormController::getTypes( ) throw(RuntimeException) +Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getTypes" ); return comphelper::concatSequences( - FmXFormController_BASE::getTypes(), + FormController_BASE::getTypes(), ::cppu::OPropertySetHelper::getTypes() ); } // ----------------------------------------------------------------------------- // XUnoTunnel -Sequence< sal_Int8 > FmXFormController::getUnoTunnelImplementationId() +Sequence< sal_Int8 > FormController::getUnoTunnelImplementationId() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getUnoTunnelImplementationId" ); static ::cppu::OImplementationId * pId = NULL; if ( !pId ) { @@ -648,18 +705,16 @@ Sequence< sal_Int8 > FmXFormController::getUnoTunnelImplementationId() return pId->getImplementationId(); } //------------------------------------------------------------------------------ -FmXFormController* FmXFormController::getImplementation( const Reference< XInterface >& _rxComponent ) +FormController* FormController::getImplementation( const Reference< XInterface >& _rxComponent ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementation" ); Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY ); if ( xTunnel.is() ) - return reinterpret_cast< FmXFormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) ); + return reinterpret_cast< FormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) ); return NULL; } //------------------------------------------------------------------------------ -sal_Int64 SAL_CALL FmXFormController::getSomething(Sequence const& rId)throw( RuntimeException ) +sal_Int64 SAL_CALL FormController::getSomething(Sequence const& rId)throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSomething" ); if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) return reinterpret_cast< sal_Int64 >( this ); @@ -668,9 +723,8 @@ sal_Int64 SAL_CALL FmXFormController::getSomething(Sequence const& rId // XServiceInfo //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::supportsService" ); Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames()); const ::rtl::OUString * pArray = aSNL.getConstArray(); for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) @@ -680,16 +734,14 @@ sal_Bool SAL_CALL FmXFormController::supportsService(const ::rtl::OUString& Serv } //------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FmXFormController::getImplementationName() throw( RuntimeException ) +::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementationName" ); - return ::rtl::OUString::createFromAscii("com.sun.star.form.FmXFormController"); + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.FormController" ); } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> SAL_CALL FmXFormController::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedServiceNames" ); // service names which are supported only, but cannot be used to created an // instance at a service factory Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 ); @@ -701,39 +753,35 @@ Sequence< ::rtl::OUString> SAL_CALL FmXFormController::getSupportedServiceNames( } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveReset" ); return sal_True; } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::resetted(const EventObject& rEvent) throw( RuntimeException ) +void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::resetted" ); ::osl::MutexGuard aGuard(m_aMutex); if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source)) m_bModified = sal_False; } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> FmXFormController::getSupportedServiceNames_Static(void) +Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedServiceNames_Static" ); static Sequence< ::rtl::OUString> aServices; if (!aServices.getLength()) { aServices.realloc(2); - aServices.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormController"); + aServices.getArray()[0] = FM_FORM_CONTROLLER; aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); } return aServices; } //------------------------------------------------------------------------------ -void FmXFormController::setCurrentFilterPosition( sal_Int32 nPos ) +void FormController::setCurrentFilterPosition( sal_Int32 nPos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setCurrentFilterPosition" ); DBG_ASSERT(nPos < (sal_Int32)m_aFilters.size(), "Invalid Position"); if (nPos != m_nCurrentFilterPosition) @@ -752,11 +800,11 @@ void FmXFormController::setCurrentFilterPosition( sal_Int32 nPos ) } } // ----------------------------------------------------------------------------- -void FmXFormController::impl_setTextOnAllFilter_throw() +void FormController::impl_setTextOnAllFilter_throw() { // set the text for all filters OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FmXFormController::setCurrentFilterPosition: m_nCurrentFilterPosition too big" ); + "FormController::setCurrentFilterPosition: m_nCurrentFilterPosition too big" ); if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) { @@ -770,25 +818,22 @@ void FmXFormController::impl_setTextOnAllFilter_throw() } // OPropertySetHelper //------------------------------------------------------------------------------ -sal_Bool FmXFormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, +sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) throw( IllegalArgumentException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::convertFastPropertyValue" ); return sal_False; } //------------------------------------------------------------------------------ -void FmXFormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) +void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) throw( Exception ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setFastPropertyValue_NoBroadcast" ); } //------------------------------------------------------------------------------ -void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getFastPropertyValue" ); switch (nHandle) { case FM_ATTR_FILTER: @@ -826,7 +871,7 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c // get the field of the controls map Reference< XTextComponent > xText = condition->first; Reference< XPropertySet > xField = m_aFilterControls.find( xText )->second; - DBG_ASSERT( xField.is(), "FmXFormController::getFastPropertyValue: no field found!" ); + DBG_ASSERT( xField.is(), "FormController::getFastPropertyValue: no field found!" ); if ( condition != rRow.begin() ) aFilter.appendAscii( " AND " ); @@ -834,7 +879,7 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c ::rtl::OUString sErrorMsg, sCriteria; ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); - OSL_ENSURE( xParseNode.is(), "FmXFormController::getFastPropertyValue: could not parse the field value predicate!" ); + OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); if ( xParseNode.is() ) { // don't use a parse context here, we need it unlocalized @@ -856,9 +901,8 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c } //------------------------------------------------------------------------------ -Reference< XPropertySetInfo > FmXFormController::getPropertySetInfo() throw( RuntimeException ) +Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getPropertySetInfo" ); static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); return xInfo; } @@ -872,12 +916,11 @@ pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((co DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1) //------------------------------------------------------------------------------ -void FmXFormController::fillProperties( +void FormController::fillProperties( Sequence< Property >& /* [out] */ _rProps, Sequence< Property >& /* [out] */ /*_rAggregateProps*/ ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::fillProperties" ); _rProps.realloc(2); sal_Int32 nPos = 0; Property* pDesc = _rProps.getArray(); @@ -886,51 +929,45 @@ void FmXFormController::fillProperties( } //------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& FmXFormController::getInfoHelper() +::cppu::IPropertyArrayHelper& FormController::getInfoHelper() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getInfoHelper" ); return *getArrayHelper(); } // XElementAccess //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::hasElements(void) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::hasElements" ); ::osl::MutexGuard aGuard( m_aMutex ); return !m_aChilds.empty(); } //------------------------------------------------------------------------------ -Type SAL_CALL FmXFormController::getElementType(void) throw( RuntimeException ) +Type SAL_CALL FormController::getElementType(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getElementType" ); return ::getCppuType((const Reference< XFormController>*)0); } // XEnumerationAccess //------------------------------------------------------------------------------ -Reference< XEnumeration > SAL_CALL FmXFormController::createEnumeration(void) throw( RuntimeException ) +Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::createEnumeration" ); ::osl::MutexGuard aGuard( m_aMutex ); return new ::comphelper::OEnumerationByIndex(this); } // XIndexAccess //------------------------------------------------------------------------------ -sal_Int32 SAL_CALL FmXFormController::getCount(void) throw( RuntimeException ) +sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getCount" ); ::osl::MutexGuard aGuard( m_aMutex ); return m_aChilds.size(); } //------------------------------------------------------------------------------ -Any SAL_CALL FmXFormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getByIndex" ); ::osl::MutexGuard aGuard( m_aMutex ); if (Index < 0 || Index >= (sal_Int32)m_aChilds.size()) @@ -941,12 +978,11 @@ Any SAL_CALL FmXFormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBou } //----------------------------------------------------------------------------- -void FmXFormController::addChild(FmXFormController* pChild) +void FormController::addChild(FormController* pChild) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addChild" ); Reference< XFormController > xController(pChild); m_aChilds.push_back(xController); - pChild->setParent(static_cast< XFormController* >(this)); + pChild->setParent( *this ); Reference< XFormComponent > xForm(pChild->getModel(), UNO_QUERY); @@ -967,9 +1003,8 @@ void FmXFormController::addChild(FmXFormController* pChild) // EventListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::disposing(const EventObject& e) throw( RuntimeException ) +void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposing" ); // Ist der Container disposed worden ::osl::MutexGuard aGuard( m_aMutex ); Reference< XControlContainer > xContainer(e.Source, UNO_QUERY); @@ -991,9 +1026,8 @@ void SAL_CALL FmXFormController::disposing(const EventObject& e) throw( RuntimeE // OComponentHelper //----------------------------------------------------------------------------- -void FmXFormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) +void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposeAllFeaturesAndDispatchers" ); for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin(); aDispatcher != m_aFeatureDispatchers.end(); ++aDispatcher @@ -1005,7 +1039,7 @@ void FmXFormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::disposeAllFeaturesAndDispatchers: caught an exception while disposing a dispatcher!" ); + OSL_ENSURE( sal_False, "FormController::disposeAllFeaturesAndDispatchers: caught an exception while disposing a dispatcher!" ); } } m_aFeatureDispatchers.clear(); @@ -1013,10 +1047,9 @@ void FmXFormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) } //----------------------------------------------------------------------------- -void FmXFormController::disposing(void) +void FormController::disposing(void) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposing" ); - EventObject aEvt(static_cast< XFormController* >(this)); + EventObject aEvt( *this ); // if we're still active, simulate a "deactivated" event if ( m_xActiveControl.is() ) @@ -1096,10 +1129,9 @@ namespace } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::propertyChange" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if ( evt.PropertyName == FM_PROP_BOUNDFIELD ) { Reference xOldBound; @@ -1164,14 +1196,13 @@ void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt) } //------------------------------------------------------------------------------ -bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) +bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::replaceControl" ); bool bSuccess = false; try { Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY ); - DBG_ASSERT( xContainer.is(), "FmXFormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); + DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); if ( xContainer.is() ) { // look up the ID of _rxExistentControl @@ -1184,7 +1215,7 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent if ( xCheck == _rxExistentControl ) break; } - DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FmXFormController::replaceControl: did not find the control in the container!" ); + DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" ); if ( pIdentifiers != pIdentifiersEnd ) { bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() ); @@ -1217,7 +1248,7 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::replaceControl: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::replaceControl: caught an exception!" ); } Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl ); @@ -1226,10 +1257,9 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent } //------------------------------------------------------------------------------ -void FmXFormController::toggleAutoFields(sal_Bool bAutoFields) +void FormController::toggleAutoFields(sal_Bool bAutoFields) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::toggleAutoFields" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Sequence< Reference< XControl > > aControlsCopy( m_aControls ); @@ -1300,9 +1330,9 @@ void FmXFormController::toggleAutoFields(sal_Bool bAutoFields) } //------------------------------------------------------------------------------ -IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG) +IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); toggleAutoFields(m_bCurrentRecordNew); return 1L; @@ -1310,10 +1340,9 @@ IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG) // XTextListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeException ) +void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::textChanged" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if (m_bFiltering) { Reference< XTextComponent > xText(e.Source,UNO_QUERY); @@ -1321,7 +1350,7 @@ void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeE // Suchen der aktuellen Row OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FmXFormController::textChanged: m_nCurrentFilterPosition too big" ); + "FormController::textChanged: m_nCurrentFilterPosition too big" ); if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) { @@ -1346,36 +1375,32 @@ void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeE // XItemListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) +void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::itemStateChanged" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); impl_onModify(); } // XModificationBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addModifyListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aModifyListeners.addInterface( l ); } //------------------------------------------------------------------------------ -void FmXFormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeModifyListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aModifyListeners.removeInterface( l ); } // XModificationListener //------------------------------------------------------------------------------ -void FmXFormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) +void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::modified" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); try { @@ -1400,10 +1425,9 @@ void FmXFormController::modified( const EventObject& _rEvent ) throw( RuntimeExc } //------------------------------------------------------------------------------ -void FmXFormController::impl_onModify() +void FormController::impl_onModify() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::onModify" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); { ::osl::MutexGuard aGuard( m_aMutex ); @@ -1416,10 +1440,9 @@ void FmXFormController::impl_onModify() } //------------------------------------------------------------------------------ -sal_Bool FmXFormController::determineLockState() const +sal_Bool FormController::determineLockState() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::determineLockState" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // a.) in filter mode we are always locked // b.) if we have no valid model or our model (a result set) is not alive -> we're locked // c.) if we are inserting everything is OK and we are not locked @@ -1434,12 +1457,11 @@ sal_Bool FmXFormController::determineLockState() const // FocusListener //------------------------------------------------------------------------------ -void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException ) +void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::focusGained" ); - TRACE_RANGE( "FmXFormController::focusGained" ); + TRACE_RANGE( "FormController::focusGained" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XControl > xControl(e.Source, UNO_QUERY); @@ -1473,7 +1495,7 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY); sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); - OSL_ENSURE(!bControlIsLocked, "FmXFormController::Gained: I'm modified and the current control is locked ? How this ?"); + OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?"); // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext // gesetzt worden sein, was ich nicht verstehen wuerde ... #endif @@ -1563,7 +1585,7 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnActivated, void*, /**/ ) +IMPL_LINK( FormController, OnActivated, void*, /**/ ) { EventObject aEvent; aEvent.Source = *this; @@ -1573,7 +1595,7 @@ IMPL_LINK( FmXFormController, OnActivated, void*, /**/ ) } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnDeactivated, void*, /**/ ) +IMPL_LINK( FormController, OnDeactivated, void*, /**/ ) { EventObject aEvent; aEvent.Source = *this; @@ -1583,10 +1605,9 @@ IMPL_LINK( FmXFormController, OnDeactivated, void*, /**/ ) } //------------------------------------------------------------------------------ -void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException ) +void FormController::focusLost(const FocusEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::focusLost" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_pControlBorderManager->focusLost( e.Source ); @@ -1601,53 +1622,47 @@ void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException ) } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mousePressed" ); // not interested in } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseReleased" ); // not interested in } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseEntered" ); m_pControlBorderManager->mouseEntered( _rEvent.Source ); } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseExited" ); m_pControlBorderManager->mouseExited( _rEvent.Source ); } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) +void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::componentValidityChanged" ); Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) ); Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY ); - OSL_ENSURE( xControl.is() && xValidatable.is(), "FmXFormController::componentValidityChanged: huh?" ); + OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" ); if ( xControl.is() && xValidatable.is() ) m_pControlBorderManager->validityChanged( xControl, xValidatable ); } //-------------------------------------------------------------------- -void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) +void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setModel" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::setModel : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !"); try { @@ -1743,27 +1758,25 @@ void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::setModel: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::setModel: caught an exception!" ); } } //------------------------------------------------------------------------------ -Reference< XTabControllerModel > FmXFormController::getModel() throw( RuntimeException ) +Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getModel" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::getModel : invalid aggregate !"); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XTabControllerModel > (); return m_xTabController->getModel(); } //------------------------------------------------------------------------------ -void FmXFormController::addToEventAttacher(const Reference< XControl > & xControl) +void FormController::addToEventAttacher(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addToEventAttacher" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FmXFormController::addToEventAttacher: invalid control - how did you reach this?" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" ); if ( !xControl.is() ) return; /* throw IllegalArgumentException(); */ @@ -1788,11 +1801,10 @@ void FmXFormController::addToEventAttacher(const Reference< XControl > & xContro } //------------------------------------------------------------------------------ -void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xControl) +void FormController::removeFromEventAttacher(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeFromEventAttacher" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FmXFormController::removeFromEventAttacher: invalid control - how did you reach this?" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" ); if ( !xControl.is() ) return; /* throw IllegalArgumentException(); */ @@ -1817,14 +1829,13 @@ void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xC } //------------------------------------------------------------------------------ -void FmXFormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) +void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setContainer" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Reference< XTabControllerModel > xTabModel(getModel()); DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined"); // if we have a new container we need a model - DBG_ASSERT(m_xTabController.is(), "FmXFormController::setContainer : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !"); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XContainer > xCurrentContainer; @@ -1906,22 +1917,20 @@ void FmXFormController::setContainer(const Reference< XControlContainer > & xCon } //------------------------------------------------------------------------------ -Reference< XControlContainer > FmXFormController::getContainer() throw( RuntimeException ) +Reference< XControlContainer > FormController::getContainer() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getContainer" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::getContainer : invalid aggregate !"); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XControlContainer > (); return m_xTabController->getContainer(); } //------------------------------------------------------------------------------ -Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( RuntimeException ) +Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getControls" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); if (!m_bControlsSorted) { @@ -1958,32 +1967,29 @@ Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( Ru } //------------------------------------------------------------------------------ -void FmXFormController::autoTabOrder() throw( RuntimeException ) +void FormController::autoTabOrder() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::autoTabOrder" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::autoTabOrder : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->autoTabOrder(); } //------------------------------------------------------------------------------ -void FmXFormController::activateTabOrder() throw( RuntimeException ) +void FormController::activateTabOrder() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateTabOrder" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateTabOrder : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateTabOrder(); } //------------------------------------------------------------------------------ -void FmXFormController::setControlLock(const Reference< XControl > & xControl) +void FormController::setControlLock(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setControlLock" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); sal_Bool bLocked = isLocked(); // es wird gelockt @@ -2022,8 +2028,9 @@ void FmXFormController::setControlLock(const Reference< XControl > & xControl) else xBound->setLock(bLocked); } - catch(...) + catch( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } @@ -2034,10 +2041,9 @@ void FmXFormController::setControlLock(const Reference< XControl > & xControl) } //------------------------------------------------------------------------------ -void FmXFormController::setLocks() +void FormController::setLocks() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setLocks" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); @@ -2076,10 +2082,9 @@ namespace } //------------------------------------------------------------------------------ -void FmXFormController::startControlModifyListening(const Reference< XControl > & xControl) +void FormController::startControlModifyListening(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startControlModifyListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); bool bModifyListening = lcl_shouldListenForModifications( xControl, this ); @@ -2126,10 +2131,9 @@ void FmXFormController::startControlModifyListening(const Reference< XControl > } //------------------------------------------------------------------------------ -void FmXFormController::stopControlModifyListening(const Reference< XControl > & xControl) +void FormController::stopControlModifyListening(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopControlModifyListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL ); @@ -2175,10 +2179,9 @@ void FmXFormController::stopControlModifyListening(const Reference< XControl > & } //------------------------------------------------------------------------------ -void FmXFormController::startListening() +void FormController::startListening() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bModified = sal_False; // jetzt anmelden bei gebundenen feldern @@ -2189,10 +2192,9 @@ void FmXFormController::startListening() } //------------------------------------------------------------------------------ -void FmXFormController::stopListening() +void FormController::stopListening() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bModified = sal_False; // jetzt anmelden bei gebundenen feldern @@ -2204,10 +2206,9 @@ void FmXFormController::stopListening() //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const +Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::findControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" ); Reference< XControl >* pControls = _rControls.getArray(); @@ -2232,9 +2233,8 @@ Reference< XControl > FmXFormController::findControl(Sequence< Reference< XCont } //------------------------------------------------------------------------------ -void FmXFormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) +void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implControlInserted" ); Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); if ( xWindow.is() ) { @@ -2272,9 +2272,8 @@ void FmXFormController::implControlInserted( const Reference< XControl>& _rxCont } //------------------------------------------------------------------------------ -void FmXFormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) +void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implControlRemoved" ); Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); if ( xWindow.is() ) { @@ -2304,9 +2303,8 @@ void FmXFormController::implControlRemoved( const Reference< XControl>& _rxContr } //------------------------------------------------------------------------------ -void FmXFormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) +void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implSetCurrentControl" ); if ( m_xCurrentControl.get() == _rxControl.get() ) return; @@ -2322,10 +2320,9 @@ void FmXFormController::implSetCurrentControl( const Reference< XControl >& _rxC } //------------------------------------------------------------------------------ -void FmXFormController::insertControl(const Reference< XControl > & xControl) +void FormController::insertControl(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::insertControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bControlsSorted = sal_False; m_aControls.realloc(m_aControls.getLength() + 1); m_aControls.getArray()[m_aControls.getLength() - 1] = xControl; @@ -2343,10 +2340,9 @@ void FmXFormController::insertControl(const Reference< XControl > & xControl) } //------------------------------------------------------------------------------ -void FmXFormController::removeControl(const Reference< XControl > & xControl) +void FormController::removeControl(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); while ( pControls != pControlsEnd ) @@ -2374,12 +2370,11 @@ void FmXFormController::removeControl(const Reference< XControl > & xControl) // XLoadListener //------------------------------------------------------------------------------ -void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeException ) +void FormController::loaded(const EventObject& rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::loaded" ); - OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FmXFormController::loaded: where did this come from?" ); + OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY); // do we have a connected data source @@ -2431,9 +2426,8 @@ void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeExceptio } //------------------------------------------------------------------------------ -void FmXFormController::updateAllDispatchers() const +void FormController::updateAllDispatchers() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::updateAllDispatchers" ); ::std::for_each( m_aFeatureDispatchers.begin(), m_aFeatureDispatchers.end(), @@ -2445,9 +2439,9 @@ void FmXFormController::updateAllDispatchers() const } //------------------------------------------------------------------------------ -IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG) +IMPL_LINK(FormController, OnLoad, void*, EMPTYARG) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bLocked = determineLockState(); setLocks(); @@ -2463,18 +2457,16 @@ IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG) } //------------------------------------------------------------------------------ -void FmXFormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) +void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unloaded" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); updateAllDispatchers(); } //------------------------------------------------------------------------------ -void FmXFormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::reloading" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); // do the same like in unloading // just one exception toggle the auto values @@ -2483,26 +2475,23 @@ void FmXFormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeE } //------------------------------------------------------------------------------ -void FmXFormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) +void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::reloaded" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); loaded(aEvent); } //------------------------------------------------------------------------------ -void FmXFormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unloading" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); unload(); } //------------------------------------------------------------------------------ -void FmXFormController::unload() throw( RuntimeException ) +void FormController::unload() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unload" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); m_aLoadEvent.CancelPendingCall(); @@ -2529,9 +2518,8 @@ void FmXFormController::unload() throw( RuntimeException ) } // ----------------------------------------------------------------------------- -void FmXFormController::removeBoundFieldListener() +void FormController::removeBoundFieldListener() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeBoundFieldListener" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); while ( pControls != pControlsEnd ) @@ -2543,9 +2531,8 @@ void FmXFormController::removeBoundFieldListener() } //------------------------------------------------------------------------------ -void FmXFormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startFormListening" ); try { if ( m_bCanInsert || m_bCanUpdate ) // form can be modified @@ -2573,14 +2560,13 @@ void FmXFormController::startFormListening( const Reference< XPropertySet >& _rx } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::startFormListening: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::startFormListening: caught an exception!" ); } } //------------------------------------------------------------------------------ -void FmXFormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopFormListening" ); try { if ( m_bCanInsert || m_bCanUpdate ) @@ -2606,16 +2592,15 @@ void FmXFormController::stopFormListening( const Reference< XPropertySet >& _rxF } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::stopFormListening: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::stopFormListening: caught an exception!" ); } } // com::sun::star::sdbc::XRowSetListener //------------------------------------------------------------------------------ -void FmXFormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::cursorMoved" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // toggle the locking ? if (m_bLocked != determineLockState()) { @@ -2633,25 +2618,22 @@ void FmXFormController::cursorMoved(const EventObject& /*event*/) throw( Runtime } //------------------------------------------------------------------------------ -void FmXFormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::rowChanged" ); // not interested in ... } //------------------------------------------------------------------------------ -void FmXFormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::rowSetChanged" ); // not interested in ... } // XContainerListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementInserted" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Reference< XControl > xControl; evt.Element >>= xControl; if (!xControl.is()) @@ -2695,9 +2677,8 @@ void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) thro } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementReplaced" ); // simulate an elementRemoved ContainerEvent aRemoveEvent( evt ); aRemoveEvent.Element = evt.ReplacedElement; @@ -2711,10 +2692,9 @@ void SAL_CALL FmXFormController::elementReplaced(const ContainerEvent& evt) thro } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementRemoved" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XControl > xControl; @@ -2739,10 +2719,9 @@ void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw } //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer > & xPeer) const +Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::isInList" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); sal_uInt32 nCtrls = m_aControls.getLength(); @@ -2759,58 +2738,62 @@ Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer } //------------------------------------------------------------------------------ -void FmXFormController::activateFirst() throw( RuntimeException ) +void FormController::activateFirst() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateFirst" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateFirst : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateFirst(); } //------------------------------------------------------------------------------ -void FmXFormController::activateLast() throw( RuntimeException ) +void FormController::activateLast() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateLast" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateLast : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateLast(); } // XFormController //------------------------------------------------------------------------------ -Reference< XControl> SAL_CALL FmXFormController::getCurrentControl(void) throw( RuntimeException ) +Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *this ); + + return m_aControllerFeatures->getFormOperations(); +} + +//------------------------------------------------------------------------------ +Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getCurrentControl" ); ::osl::MutexGuard aGuard( m_aMutex ); return m_xCurrentControl; } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addActivateListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aActivateListeners.addInterface(l); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeActivateListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aActivateListeners.removeInterface(l); } //------------------------------------------------------------------------------ -void FmXFormController::setFilter(::std::vector& rFieldInfos) +void FormController::setFilter(::std::vector& rFieldInfos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setFilter" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // create the composer Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY); Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm)); @@ -2983,10 +2966,9 @@ void FmXFormController::setFilter(::std::vector& rFieldInfos) } //------------------------------------------------------------------------------ -void FmXFormController::startFiltering() +void FormController::startFiltering() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startFiltering" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); OStaticDataAccessTools aStaticTools; Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) ); @@ -3098,7 +3080,7 @@ void FmXFormController::startFiltering() ), UNO_QUERY ); - DBG_ASSERT( xFilterControl.is(), "FmXFormController::startFiltering: could not create a filter control!" ); + DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" ); if ( replaceControl( xControl, xFilterControl ) ) { @@ -3132,10 +3114,9 @@ void FmXFormController::startFiltering() } //------------------------------------------------------------------------------ -void FmXFormController::stopFiltering() +void FormController::stopFiltering() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopFiltering" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if ( !m_bFiltering ) // #104693# OJ { // nothing to do return; @@ -3221,12 +3202,11 @@ void FmXFormController::stopFiltering() // XModeSelector //------------------------------------------------------------------------------ -void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) +void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setMode" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if (!supportsMode(Mode)) throw NoSupportException(); @@ -3250,19 +3230,17 @@ void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExc } //------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FmXFormController::getMode(void) throw( RuntimeException ) +::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getMode" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); return m_aMode; } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FmXFormController::getSupportedModes(void) throw( RuntimeException ) +Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedModes" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); static Sequence< ::rtl::OUString > aModes; if (!aModes.getLength()) { @@ -3275,10 +3253,9 @@ Sequence< ::rtl::OUString > SAL_CALL FmXFormController::getSupportedModes(void) } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::supportsMode" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Sequence< ::rtl::OUString > aModes(getSupportedModes()); const ::rtl::OUString* pModes = aModes.getConstArray(); for (sal_Int32 i = aModes.getLength(); i > 0; ) @@ -3290,10 +3267,9 @@ sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) t } //------------------------------------------------------------------------------ -Window* FmXFormController::getDialogParentWindow() +Window* FormController::getDialogParentWindow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getDialogParentWindow" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Window* pParent = m_pWindow; if ( !pParent ) { @@ -3305,22 +3281,21 @@ Window* FmXFormController::getDialogParentWindow() } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::getDialogParentWindow: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::getDialogParentWindow: caught an exception!" ); } } return pParent; } //------------------------------------------------------------------------------ -bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) +bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::checkFormComponentValidity" ); try { Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY ); Reference< XEnumeration > xControlEnumeration; if ( xControlEnumAcc.is() ) xControlEnumeration = xControlEnumAcc->createEnumeration(); - OSL_ENSURE( xControlEnumeration.is(), "FmXFormController::checkFormComponentValidity: cannot enumerate the controls!" ); + OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" ); if ( !xControlEnumeration.is() ) // assume all valid return true; @@ -3336,7 +3311,7 @@ bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ continue; Reference< XValidator > xValidator( xValidatable->getValidator() ); - OSL_ENSURE( xValidator.is(), "FmXFormController::checkFormComponentValidity: invalid, but no validator?" ); + OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" ); if ( !xValidator.is() ) // this violates the interface definition of css.form.validation.XValidatableFormComponent ... continue; @@ -3348,15 +3323,14 @@ bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::checkFormComponentValidity: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::checkFormComponentValidity: caught an exception!" ); } return true; } //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) +Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::locateControl" ); try { Sequence< Reference< XControl > > aControls( getControls() ); @@ -3365,18 +3339,18 @@ Reference< XControl > FmXFormController::locateControl( const Reference< XContro for ( ; pControls != pControlsEnd; ++pControls ) { - OSL_ENSURE( pControls->is(), "FmXFormController::locateControl: NULL-control?" ); + OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" ); if ( pControls->is() ) { if ( ( *pControls)->getModel() == _rxModel ) return *pControls; } } - OSL_ENSURE( sal_False, "FmXFormController::locateControl: did not find a control for this model!" ); + OSL_ENSURE( sal_False, "FormController::locateControl: did not find a control for this model!" ); } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::locateControl: caught an exception!" ); + OSL_ENSURE( sal_False, "FormController::locateControl: caught an exception!" ); } return NULL; } @@ -3444,12 +3418,11 @@ namespace // XRowSetApproveListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveRowChange" ); ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); sal_Bool bValid = sal_True; if (aIter.hasMoreElements()) @@ -3482,7 +3455,7 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) ) return sal_True; - OSL_ENSURE( m_pColumnInfoCache.get(), "FmXFormController::approveRowChange: no column infos!" ); + OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" ); if ( !m_pColumnInfoCache.get() ) return sal_True; @@ -3533,11 +3506,10 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveCursorMove" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3550,11 +3522,10 @@ sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event) } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveRowSetChange" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3568,30 +3539,27 @@ sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& even // XRowSetApproveBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addRowSetApproveListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aRowSetApproveListeners.addInterface(_rxListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeRowSetApproveListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aRowSetApproveListeners.removeInterface(_rxListener); } // XErrorListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) +void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::errorOccured" ); ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners); if (aIter.hasMoreElements()) @@ -3609,61 +3577,54 @@ void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw // XErrorBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addSQLErrorListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aErrorListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeSQLErrorListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aErrorListeners.removeInterface(aListener); } // XDatabaseParameterBroadcaster2 //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addDatabaseParameterListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aParameterListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeDatabaseParameterListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aParameterListeners.removeInterface(aListener); } // XDatabaseParameterBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addParameterListener" ); - FmXFormController::addDatabaseParameterListener( aListener ); + FormController::addDatabaseParameterListener( aListener ); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeParameterListener" ); - FmXFormController::removeDatabaseParameterListener( aListener ); + FormController::removeDatabaseParameterListener( aListener ); } // XDatabaseParameterListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveParameter" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners); if (aIter.hasMoreElements()) @@ -3707,7 +3668,7 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve Sequence< PropertyValue > aFinalValues = pParamValues->getValues(); if (aFinalValues.getLength() != aRequest.Parameters->getCount()) { - DBG_ERROR("FmXFormController::approveParameter: the InteractionHandler returned nonsense!"); + DBG_ERROR("FormController::approveParameter: the InteractionHandler returned nonsense!"); return sal_False; } const PropertyValue* pFinalValues = aFinalValues.getConstArray(); @@ -3720,19 +3681,19 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve #ifdef DBG_UTIL ::rtl::OUString sName; xParam->getPropertyValue(FM_PROP_NAME) >>= sName; - DBG_ASSERT(sName.equals(pFinalValues->Name), "FmXFormController::approveParameter: suspicious value names!"); + DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!"); #endif try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); } catch(Exception&) { - DBG_ERROR("FmXFormController::approveParameter: setting one of the properties failed!"); + DBG_ERROR("FormController::approveParameter: setting one of the properties failed!"); } } } } catch(Exception&) { - DBG_ERROR("FmXFormController::approveParameter: caught an Exception (tried to let the InteractionHandler handle it)!"); + DBG_ERROR("FormController::approveParameter: caught an Exception (tried to let the InteractionHandler handle it)!"); } } return sal_True; @@ -3740,27 +3701,24 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve // XConfirmDeleteBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addConfirmDeleteListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aDeleteListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeConfirmDeleteListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_aDeleteListeners.removeInterface(aListener); } // XConfirmDeleteListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::confirmDelete" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners); if (aIter.hasMoreElements()) @@ -3788,9 +3746,8 @@ sal_Bool SAL_CALL FmXFormController::confirmDelete(const RowChangeEvent& aEvent) } //------------------------------------------------------------------------------ -void FmXFormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) +void FormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::invalidateFeatures" ); ::osl::MutexGuard aGuard( m_aMutex ); // for now, just copy the ids of the features, because .... ::std::copy( _rFeatures.begin(), _rFeatures.end(), @@ -3804,12 +3761,11 @@ void FmXFormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _r //------------------------------------------------------------------------------ Reference< XDispatch > -FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, +FormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::interceptedQueryDispatch" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Reference< XDispatch > xReturn; // dispatches handled by ourself if ( ( aURL.Complete == FMURL_CONFIRM_DELETION ) @@ -3835,7 +3791,7 @@ FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL ).first; } - OSL_ENSURE( aDispatcherPos->second.is(), "FmXFormController::interceptedQueryDispatch: should have a dispatcher by now!" ); + OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" ); return aDispatcherPos->second; } } @@ -3845,12 +3801,11 @@ FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) +void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::dispatch" ); if ( _rArgs.getLength() != 1 ) { - DBG_ERROR( "FmXFormController::dispatch: no arguments -> no dispatch!" ); + DBG_ERROR( "FormController::dispatch: no arguments -> no dispatch!" ); return; } @@ -3865,18 +3820,17 @@ void SAL_CALL FmXFormController::dispatch( const URL& _rURL, const Sequence< Pro if ( _rURL.Complete == FMURL_CONFIRM_DELETION ) { - DBG_ERROR( "FmXFormController::dispatch: How do you expect me to return something via this call?" ); + DBG_ERROR( "FormController::dispatch: How do you expect me to return something via this call?" ); // confirmDelete has a return value - dispatch hasn't return; } - DBG_ERROR( "FmXFormController::dispatch: unknown URL!" ); + DBG_ERROR( "FormController::dispatch: unknown URL!" ); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) +void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addStatusListener" ); if (_rURL.Complete == FMURL_CONFIRM_DELETION) { if (_rxListener.is()) @@ -3889,23 +3843,21 @@ void SAL_CALL FmXFormController::addStatusListener( const Reference< XStatusList } } else - OSL_ENSURE(sal_False, "FmXFormController::addStatusListener: invalid (unsupported) URL!"); + OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!"); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) +void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeStatusListener" ); (void)_rURL; - OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FmXFormController::removeStatusListener: invalid (unsupported) URL!"); + OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!"); // we never really added the listener, so we don't need to remove it } //------------------------------------------------------------------------------ -Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::createInterceptor" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); #ifdef DBG_UTIL // check if we already have a interceptor for the given object for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin(); @@ -3914,7 +3866,7 @@ Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor( ) { if ((*aIter)->getIntercepted() == _xInterception) - DBG_ERROR("FmXFormController::createInterceptor : we already do intercept this objects dispatches !"); + DBG_ERROR("FormController::createInterceptor : we already do intercept this objects dispatches !"); } #endif @@ -3927,9 +3879,8 @@ Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor( } //------------------------------------------------------------------------------ -bool FmXFormController::ensureInteractionHandler() +bool FormController::ensureInteractionHandler() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::ensureInteractionHandler" ); if ( m_xInteractionHandler.is() ) return true; if ( m_bAttemptedHandlerCreation ) @@ -3939,24 +3890,22 @@ bool FmXFormController::ensureInteractionHandler() return false; m_xInteractionHandler.set( m_xORB->createInstance( SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); - OSL_ENSURE( m_xInteractionHandler.is(), "FmXFormController::ensureInteractionHandler: could not create an interaction handler!" ); + OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" ); return m_xInteractionHandler.is(); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) +void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::handle" ); if ( !ensureInteractionHandler() ) return; m_xInteractionHandler->handle( _rRequest ); } //------------------------------------------------------------------------------ -void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::deleteInterceptor" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // search the interceptor responsible for the given object InterceptorsIterator aIter; for ( aIter = m_aControlDispatchInterceptors.begin(); @@ -3982,10 +3931,9 @@ void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInte } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) +void SAL_CALL FormController::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::initialize" ); - DBG_ASSERT( !m_xInteractionHandler.is(), "FmXFormController::initialize: already initialized!" ); + DBG_ASSERT( !m_xInteractionHandler.is(), "FormController::initialize: already initialized!" ); // currently, we only initialize our interaction handler here, so it's sufficient to assert this ::comphelper::NamedValueCollection aArgs( aArguments ); @@ -3993,9 +3941,8 @@ void SAL_CALL FmXFormController::initialize( const Sequence< Any >& aArguments ) } //-------------------------------------------------------------------- -void FmXFormController::implInvalidateCurrentControlDependentFeatures() +void FormController::implInvalidateCurrentControlDependentFeatures() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implInvalidateCurrentControlDependentFeatures" ); ::std::vector< sal_Int32 > aCurrentControlDependentFeatures; aCurrentControlDependentFeatures.push_back( SID_FM_SORTUP ); @@ -4007,8 +3954,9 @@ void FmXFormController::implInvalidateCurrentControlDependentFeatures() } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) +void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::columnChanged" ); implInvalidateCurrentControlDependentFeatures(); } + +} // namespace svxform diff --git a/svx/source/form/fmservs.cxx b/svx/source/form/fmservs.cxx index b9f40b6ddda2..feef02baa555 100644 --- a/svx/source/form/fmservs.cxx +++ b/svx/source/form/fmservs.cxx @@ -49,7 +49,8 @@ DECL_SERVICE( FmXGridControl ) - DECL_SERVICE( FmXFormController ) + DECL_SERVICE( FormController ) + DECL_SERVICE( LegacyFormController ); // ------------------------------------------------------------------------ @@ -91,7 +92,8 @@ namespace svxform // ------------------------------------------------------------------------ // FormController - REGISTER_SERVICE(FmXFormController, FM_FORM_CONTROLLER); + REGISTER_SERVICE( FormController, FM_FORM_CONTROLLER ); + REGISTER_SERVICE( LegacyFormController, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) ); // ------------------------------------------------------------------------ // FormController @@ -102,9 +104,6 @@ namespace svxform REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID); // compatibility REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL); REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL); - - }; - } // namespace svxform diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index ccdfb2b1af39..c7e810e48f36 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -827,7 +827,7 @@ void FmFormShell::Execute(SfxRequest &rReq) bReopenNavigator = sal_True; } - Reference< XFormController > xController( GetImpl()->getActiveController() ); + Reference< runtime::XFormController > xController( GetImpl()->getActiveController() ); if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) // closing the window was denied, for instance because of a invalid criterion @@ -1400,7 +1400,7 @@ SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxMod } //------------------------------------------------------------------------ -Reference< XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const +Reference< runtime::XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const { const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView ); if ( !pFormView ) diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 8c5ca61f6691..139b9c23b374 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -30,89 +30,87 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "gridcols.hxx" -#include -#include "fmvwimp.hxx" -#include "fmshimp.hxx" -#include "fmtextcontrolshell.hxx" -#include -#include -#include -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif + #include "fmitems.hxx" #include "fmobj.hxx" -#include "formtoolbars.hxx" -#include -#include "svditer.hxx" -#include "fmservs.hxx" #include "fmpgeimp.hxx" -#include "fmtools.hxx" -#ifndef _SVX_FMPROP_HRC #include "fmprop.hrc" -#endif -#include -#ifndef _SVX_SVXIDS_HRC -#include -#endif -#include +#include "fmresids.hrc" +#include "fmservs.hxx" +#include "fmshimp.hxx" +#include "fmtextcontrolshell.hxx" +#include "fmtools.hxx" #include "fmundo.hxx" #include "fmurl.hxx" +#include "fmvwimp.hxx" #include "formcontrolling.hxx" -#include -#include -#include -#include -#include +#include "formtoolbars.hxx" +#include "gridcols.hxx" +#include "svditer.hxx" +#include "svx/dialmgr.hxx" +#include "svx/dialogs.hrc" +#include "svx/fmglob.hxx" +#include "svx/fmmodel.hxx" +#include "svx/fmpage.hxx" +#include "svx/fmshell.hxx" +#include "svx/obj3d.hxx" +#include "svx/sdrpagewindow.hxx" +#include "svx/svdpagv.hxx" +#include "svx/svxdlg.hxx" +#include "svx/svxids.hrc" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#include -#include +#include +#include #include -#include -#include +#include #include -#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include #include -#include #include +#include +#include #include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include #include +#include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include @@ -675,7 +673,8 @@ void SAL_CALL FmXFormShell::disposing(const EventObject& e) throw( RuntimeExcept if (e.Source == m_xExternalViewController) { - Reference< XFormController> xFormController(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); + OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" ); if (xFormController.is()) xFormController->removeActivateListener((XFormControllerListener*)this); @@ -765,7 +764,7 @@ void SAL_CALL FmXFormShell::formActivated(const EventObject& rEvent) throw( Runt if ( impl_checkDisposed() ) return; - Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); + Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); m_pTextShell->formActivated( xController ); setActiveController( xController ); } @@ -777,7 +776,7 @@ void SAL_CALL FmXFormShell::formDeactivated(const EventObject& rEvent) throw( Ru if ( impl_checkDisposed() ) return; - Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); + Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); m_pTextShell->formDeactivated( xController ); } @@ -1703,7 +1702,7 @@ Reference< XResultSet> FmXFormShell::getInternalForm(const Reference< XResultSet if ( impl_checkDisposed() ) return NULL; - Reference< XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel())) { DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !"); @@ -1719,7 +1718,7 @@ Reference< XForm> FmXFormShell::getInternalForm(const Reference< XForm>& _xForm) if ( impl_checkDisposed() ) return NULL; - Reference< XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xExternalCtrlr(m_xExternalViewController, UNO_QUERY); if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel())) { DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !"); @@ -1808,7 +1807,7 @@ void FmXFormShell::impl_switchActiveControllerListening( const bool _bListen ) } //------------------------------------------------------------------------------ -void FmXFormShell::setActiveController( const Reference< XFormController>& xController, sal_Bool _bNoSaveOldContent ) +void FmXFormShell::setActiveController( const Reference< runtime::XFormController >& xController, sal_Bool _bNoSaveOldContent ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::setActiveController" ); if ( impl_checkDisposed() ) @@ -2103,11 +2102,11 @@ void FmXFormShell::startListening() { // suchen des Controllers, ueber den eine Navigation moeglich ist Reference< XChild> xChild(m_xActiveController, UNO_QUERY); - Reference< XFormController> xParent; + Reference< runtime::XFormController > xParent; while (xChild.is()) { xChild = Reference< XChild>(xChild->getParent(), UNO_QUERY); - xParent = Reference< XFormController>(xChild, UNO_QUERY); + xParent = Reference< runtime::XFormController >(xChild, UNO_QUERY); Reference< XPropertySet> xParentSet; if (xParent.is()) xParentSet = Reference< XPropertySet>(xParent->getModel(), UNO_QUERY); @@ -2936,8 +2935,8 @@ void FmXFormShell::startFiltering() FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> >& rControllerList = (*i)->GetList(); - for (::std::vector< Reference< XFormController> >::const_iterator j = rControllerList.begin(); + const ::std::vector< Reference< runtime::XFormController> >& rControllerList = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController> >::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); @@ -2953,14 +2952,14 @@ void FmXFormShell::startFiltering() } //------------------------------------------------------------------------------ -void saveFilter(const Reference< XFormController>& _rxController) +void saveFilter(const Reference< runtime::XFormController >& _rxController) { Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY); Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY); Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY); // call the subcontroller - Reference< XFormController> xController; + Reference< runtime::XFormController > xController; for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; ++i) { xControllerAsIndex->getByIndex(i) >>= xController; @@ -3004,13 +3003,13 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> >& rControllerList = (*i)->GetList(); + const ::std::vector< Reference< runtime::XFormController > >& rControllerList = (*i)->GetList(); ::std::vector < ::rtl::OUString > aOriginalFilters; ::std::vector < sal_Bool > aOriginalApplyFlags; if (bSave) { - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { if (bSave) @@ -3035,7 +3034,7 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) saveFilter(*j); } } - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { @@ -3045,8 +3044,8 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) } if (bSave) // execute the filter { - const ::std::vector< Reference< XFormController> > & rControllers = (*i)->GetList(); - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllers.begin(); + const ::std::vector< Reference< runtime::XFormController > > & rControllers = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllers.begin(); j != rControllers.end(); ++j) { Reference< XLoadable> xReload((*j)->getModel(), UNO_QUERY); @@ -3087,13 +3086,13 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) } //------------------------------------------------------------------------------ -void clearFilter(const Reference< XFormController>& _rxController) +void clearFilter(const Reference< runtime::XFormController >& _rxController) { Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY); Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY); // call the subcontroller - Reference< XFormController> xController; + Reference< runtime::XFormController > xController; for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; i++) { @@ -3141,8 +3140,8 @@ void FmXFormShell::clearFilter() FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> > & rControllerList = (*i)->GetList(); - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + const ::std::vector< Reference< runtime::XFormController > > & rControllerList = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { ::clearFilter(*j); @@ -3253,7 +3252,7 @@ void FmXFormShell::restoreControlLocks() } //------------------------------------------------------------------------------ -void FmXFormShell::DoAsyncCursorAction(const Reference< XFormController>& _xController, CURSOR_ACTION _eWhat) +void FmXFormShell::DoAsyncCursorAction(const Reference< runtime::XFormController >& _xController, CURSOR_ACTION _eWhat) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::DoAsyncCursorAction" ); if ( impl_checkDisposed() ) @@ -3329,7 +3328,7 @@ sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< XResultSet>& _xFo } //------------------------------------------------------------------------------ -sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< XFormController>& xController) const +sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< runtime::XFormController >& xController) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::HasPendingCursorAction" ); if ( impl_checkDisposed() ) @@ -3471,7 +3470,7 @@ void FmXFormShell::CreateExternalView() ::rtl::OUString sFrameName = ::rtl::OUString::createFromAscii("_beamer"); sal_Int32 nSearchFlags = ::com::sun::star::frame::FrameSearchFlag::CHILDREN | ::com::sun::star::frame::FrameSearchFlag::CREATE; - Reference< XFormController> xCurrentNavController( getNavController()); + Reference< runtime::XFormController > xCurrentNavController( getNavController()); // the creation of the "partwindow" may cause a deactivate of the document which will result in our nav controller to be set to NULL // _first_ check if we have any valid fields we can use for the grid view @@ -3538,12 +3537,12 @@ void FmXFormShell::CreateExternalView() { if ( m_xExternalViewController == getActiveController() ) { - Reference< XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY ); + Reference< runtime::XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY ); ControllerFeatures aHelper( ::comphelper::getProcessServiceFactory(), xAsFormController, NULL ); aHelper->commitCurrentControl(); } - Reference< XFormController> xNewController(m_xExtViewTriggerController); + Reference< runtime::XFormController > xNewController(m_xExtViewTriggerController); CloseExternalFormViewer(); setActiveController(xNewController); return; @@ -3876,7 +3875,8 @@ void FmXFormShell::CreateExternalView() // we want to know modifications done in the external view // if the external controller is a XFormController we can use all our default handlings for it - Reference< XFormController> xFormController(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); + OSL_ENSURE( xFormController.is(), "FmXFormShell::CreateExternalView:: invalid external view controller!" ); if (xFormController.is()) xFormController->addActivateListener((XFormControllerListener*)this); } diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 10c0978288a6..166b09f8a1c1 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -89,6 +89,7 @@ namespace svx using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::form; + using namespace ::com::sun::star::form::runtime; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 2436113312cc..ed8a4a382ed3 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -35,7 +35,6 @@ /** === begin UNO includes === **/ #include #include -#include #include #include #include diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 222407a36021..1c16a092ad18 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -626,7 +626,7 @@ void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOf ); } // ----------------------------------------------------------------------------- -Reference< XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const +Reference< runtime::XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const { return pImpl->getFormController( _rxForm, _rDevice ); } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 46750d524a4d..d88ecf0e5052 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -88,8 +88,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -98,54 +100,70 @@ #include -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::style; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::ui::dialogs; using namespace ::comphelper; -using namespace ::svxform; using namespace ::svx; -using com::sun::star::style::VerticalAlignment_MIDDLE; -using ::com::sun::star::form::binding::XValueBinding; -using ::com::sun::star::form::binding::XBindableValue; - -namespace svxform -{ - //======================================================================== - class OAutoDispose - { - protected: - Reference< XComponent > m_xComp; - - public: - OAutoDispose( const Reference< XInterface > _rxObject ); - ~OAutoDispose(); - }; +using namespace ::svxform; - //------------------------------------------------------------------------ - OAutoDispose::OAutoDispose( const Reference< XInterface > _rxObject ) - :m_xComp(_rxObject, UNO_QUERY) - { - } - - //------------------------------------------------------------------------ - OAutoDispose::~OAutoDispose() - { - if (m_xComp.is()) - m_xComp->dispose(); - } -} + using namespace ::com::sun::star; + /** === begin UNO using === **/ + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Type; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::style::VerticalAlignment_MIDDLE; + using ::com::sun::star::form::FormButtonType_SUBMIT; + using ::com::sun::star::form::binding::XValueBinding; + using ::com::sun::star::form::binding::XBindableValue; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::form::XForm; + using ::com::sun::star::form::runtime::XFormController; + using ::com::sun::star::script::XEventAttacherManager; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::container::XChild; + using ::com::sun::star::container::XEnumeration; + using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::lang::XInitialization; + using ::com::sun::star::awt::XTabController; + using ::com::sun::star::lang::XUnoTunnel; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::form::XFormComponent; + using ::com::sun::star::form::XForm; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::container::XContainer; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::NamedValue; + using ::com::sun::star::sdb::SQLErrorEvent; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::container::XElementAccess; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::awt::FocusEvent; + using ::com::sun::star::ui::dialogs::XExecutableDialog; + using ::com::sun::star::sdbc::XDataSource; + using ::com::sun::star::container::XIndexContainer; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::sdbc::SQLWarning; + using ::com::sun::star::sdbc::SQLException; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormats; + using ::com::sun::star::beans::XPropertySetInfo; + /** === end UNO using === **/ + namespace FormComponentType = ::com::sun::star::form::FormComponentType; + namespace CommandType = ::com::sun::star::sdb::CommandType; + namespace DataType = ::com::sun::star::sdbc::DataType; //------------------------------------------------------------------------------ class FmXFormView::ObjectRemoveListener : public SfxListener @@ -207,7 +225,7 @@ void FmXPageViewWinRec::dispose() { try { - Reference< XFormController > xController( *i, UNO_SET_THROW ); + Reference< XFormController > xController( *i, UNO_QUERY_THROW ); // detaching the events Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY ); @@ -319,7 +337,7 @@ Reference< XFormController > FmXPageViewWinRec::getController( const Reference< } //------------------------------------------------------------------------ -void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FmXFormController* _pParent ) +void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormController* _pParent ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::setController" ); DBG_ASSERT( xForm.is(), "FmXPageViewWinRec::setController: there should be a form!" ); @@ -330,7 +348,7 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FmXForm Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY); // create a form controller - FmXFormController* pController = new FmXFormController( m_aContext.getLegacyServiceFactory(), m_pViewImpl->getView(), m_pWindow ); + FormController* pController = new FormController( m_aContext.getLegacyServiceFactory(), m_pViewImpl->getView(), m_pWindow ); Reference< XFormController > xController( pController ); Reference< XInteractionHandler > xHandler; @@ -406,7 +424,7 @@ void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm ) // if it's a sub form, then we must ensure there exist TabControllers // for all its ancestors, too Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY ); - FmXFormController* pFormController = NULL; + FormController* pFormController = NULL; // there is a parent form -> look for the respective controller if ( xParentForm.is() ) xTabCtrl = Reference< XTabController >( getController( xParentForm ), UNO_QUERY ); @@ -414,7 +432,7 @@ void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm ) if ( xTabCtrl.is() ) { Reference< XUnoTunnel > xTunnel( xTabCtrl, UNO_QUERY_THROW ); - pFormController = reinterpret_cast< FmXFormController* >( xTunnel->getSomething( FmXFormController::getUnoTunnelImplementationId() ) ); + pFormController = reinterpret_cast< FormController* >( xTunnel->getSomething( FormController::getUnoTunnelImplementationId() ) ); } setController( _rxForm, pFormController ); @@ -1068,20 +1086,14 @@ IMPL_LINK( FmXFormView, OnStartControlWizard, void*, /**/ ) if ( pWizardAsciiName ) { // build the argument list - Sequence< Any > aWizardArgs(1); - // the object affected - aWizardArgs[0] = makeAny( PropertyValue( - ::rtl::OUString::createFromAscii("ObjectModel"), - 0, - makeAny( m_xLastCreatedControlModel ), - PropertyState_DIRECT_VALUE - ) ); + ::comphelper::NamedValueCollection aWizardArgs; + aWizardArgs.put( "ObjectModel", m_xLastCreatedControlModel ); // create the wizard object Reference< XExecutableDialog > xWizard; try { - m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs, xWizard ); + m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs.getWrappedPropertyValues(), xWizard ); } catch( const Exception& ) { @@ -1187,9 +1199,10 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript m_aContext.getLegacyServiceFactory() ) ); } - catch(const SQLContext& e) { aError.Reason <<= e; } - catch(const SQLWarning& e) { aError.Reason <<= e; } - catch(const SQLException& e) { aError.Reason <<= e; } + catch ( const SQLException& ) + { + aError.Reason = ::cppu::getCaughtException(); + } catch( const Exception& ) { /* will be asserted below */ } if (aError.Reason.hasValue()) { @@ -1217,14 +1230,11 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript if (xFields.is() && xFields->hasByName(sFieldName)) xFields->getByName(sFieldName) >>= xField; - - Reference< XNumberFormatsSupplier > xSupplier = aDBATools.getNumberFormats(xConnection, sal_False); - if (!xSupplier.is() || !xField.is()) + if ( !xField.is() ) return NULL; - Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats()); - if (!xNumberFormats.is()) - return NULL; + Reference< XNumberFormatsSupplier > xSupplier( aDBATools.getNumberFormats( xConnection, sal_False ), UNO_SET_THROW ); + Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW ); ::rtl::OUString sLabelPostfix; diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index 104d2f423eb5..5485763904ce 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -60,7 +60,7 @@ namespace svx /** === begin UNO using === **/ using ::com::sun::star::uno::Reference; using ::com::sun::star::lang::XMultiServiceFactory; - using ::com::sun::star::form::XFormController; + using ::com::sun::star::form::runtime::XFormController; using ::com::sun::star::form::XForm; using ::com::sun::star::form::runtime::FormOperations; using ::com::sun::star::uno::Exception; diff --git a/svx/source/form/legacyformcontroller.cxx b/svx/source/form/legacyformcontroller.cxx new file mode 100644 index 000000000000..47805a8d6ee1 --- /dev/null +++ b/svx/source/form/legacyformcontroller.cxx @@ -0,0 +1,225 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "fmservs.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include + +//........................................................................ +namespace svxform +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::lang::XServiceInfo; + /** === end UNO using === **/ + + using namespace ::com::sun::star; + + //==================================================================== + //= LegacyFormController + //==================================================================== + typedef ::cppu::WeakImplHelper2 < form::XFormController + , XServiceInfo + > LegacyFormController_Base; + /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the + css.form.XFormController interface. + + This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal + usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely). + */ + class LegacyFormController : public LegacyFormController_Base + { + public: + static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory ) + { + return *( new LegacyFormController( _rxFactory ) ); + } + + protected: + LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory ) + :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW ) + { + } + + // form::XFormController + virtual Reference< XControl > SAL_CALL getCurrentControl( ) throw (RuntimeException); + virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); + virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); + + // awt::XTabController + virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException); + virtual Reference< XTabControllerModel > SAL_CALL getModel( ) throw (RuntimeException); + virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException); + virtual Reference< XControlContainer > SAL_CALL getContainer( ) throw (RuntimeException); + virtual Sequence< Reference< XControl > > SAL_CALL getControls( ) throw (RuntimeException); + virtual void SAL_CALL autoTabOrder( ) throw (RuntimeException); + virtual void SAL_CALL activateTabOrder( ) throw (RuntimeException); + virtual void SAL_CALL activateFirst( ) throw (RuntimeException); + virtual void SAL_CALL activateLast( ) throw (RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + private: + const Reference< form::runtime::XFormController > m_xDelegator; + }; + + //-------------------------------------------------------------------- + Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl( ) throw (RuntimeException) + { + return m_xDelegator->getCurrentControl(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) + { + m_xDelegator->addActivateListener( _listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) + { + m_xDelegator->removeActivateListener( _listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException) + { + m_xDelegator->setModel( _model ); + } + + //-------------------------------------------------------------------- + Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel( ) throw (RuntimeException) + { + return m_xDelegator->getModel(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException) + { + m_xDelegator->setContainer( _container ); + } + + //-------------------------------------------------------------------- + Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer( ) throw (RuntimeException) + { + return m_xDelegator->getContainer(); + } + + //-------------------------------------------------------------------- + Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls( ) throw (RuntimeException) + { + return m_xDelegator->getControls(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::autoTabOrder( ) throw (RuntimeException) + { + m_xDelegator->autoTabOrder(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateTabOrder( ) throw (RuntimeException) + { + m_xDelegator->activateTabOrder(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateFirst( ) throw (RuntimeException) + { + m_xDelegator->activateFirst(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateLast( ) throw (RuntimeException) + { + m_xDelegator->activateLast(); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) ); + } + + //-------------------------------------------------------------------- + ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); + const ::rtl::OUString* pServices = aServices.getConstArray(); + for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices ) + if( pServices->equals( _serviceName ) ) + return sal_True; + return sal_False; + } + + //-------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServices(2); + aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ); + aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); + return aServices; + } + +//........................................................................ +} // namespace svxform +//........................................................................ + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) +{ + return ::svxform::LegacyFormController::Create( _rxORB ); +} + diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk index b649be94d106..fc6963d22b74 100644 --- a/svx/source/form/makefile.mk +++ b/svx/source/form/makefile.mk @@ -98,7 +98,8 @@ LIB1OBJFILES= \ $(SLO)$/fmscriptingenv.obj \ $(SLO)$/stringlistresource.obj \ $(SLO)$/delayedevent.obj \ - $(SLO)$/formcontrolfactory.obj + $(SLO)$/formcontrolfactory.obj \ + $(SLO)$/legacyformcontroller.obj LIB2TARGET= $(SLB)$/$(TARGET).lib LIB2OBJFILES= \ diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index 2bb298836d02..56cf6d428c2e 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -110,19 +112,19 @@ public: // Item representing the forms and subforms class FmFormItem : public FmParentData { - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; sal_Int32 m_nCurrent; public: TYPEINFO(); FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){} FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & _xController, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController, const ::rtl::OUString& _rText):FmParentData(_rxFactory,_pParent, _rText) ,m_xController(_xController) ,m_nCurrent(0){} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & GetController(){return m_xController;} + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetController(){return m_xController;} void SetCurrentPosition(sal_Int32 nCurrent){m_nCurrent = nCurrent;} sal_Int32 GetCurrentPosition() const {return m_nCurrent;} virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; @@ -167,9 +169,9 @@ class FmFilterModel : public FmParentData { friend class FmFilterAdapter; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; FmFilterAdapter* m_pAdapter; FmFilterItems* m_pCurrentItems; @@ -178,7 +180,7 @@ public: FmFilterModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); virtual ~FmFilterModel(); - void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xCurrent); + void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent); void Clear(); sal_Bool ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const; void Append(FmFilterItems* pItems, FmFilterItem* pFilterItem); @@ -190,8 +192,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; } const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & GetControllers() const {return m_xControllers;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & GetCurrentController() const {return m_xController;} - void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xController); + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetCurrentController() const {return m_xController;} + void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController); void Remove(FmFilterData* pFilterItem); void AppendFilterItems(FmFormItem* pItem); @@ -200,7 +202,7 @@ public: protected: void Insert(const ::std::vector::iterator& rPos, FmFilterData* pFilterItem); void Remove(const ::std::vector::iterator& rPos, FmFilterData* pFilterItem); - FmFormItem* Find(const ::std::vector& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xController) const; + FmFormItem* Find(const ::std::vector& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const; FmFormItem* Find(const ::std::vector& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const; void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent); }; @@ -267,7 +269,10 @@ public: FmFilterNavigator( Window* pParent ); virtual ~FmFilterNavigator(); - void UpdateContent(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xCurrent); + void UpdateContent( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent + ); const FmFilterModel* GetFilterModel() const {return m_pModel;} protected: diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx index c08907026585..34dc8d86fb0b 100644 --- a/svx/source/inc/fmcontrolbordermanager.hxx +++ b/svx/source/inc/fmcontrolbordermanager.hxx @@ -132,7 +132,7 @@ namespace svxform //==================================================================== /** manages the dynamic border color for form controls - Used by the FmXFormController, this class manages the dynamic changes in the + Used by the FormController, this class manages the dynamic changes in the border color of form controls. For this a set of events have to be forwarded to the manager instance, which then will switch the border color depending on the mouse and focus status of the controls. diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx index 7a973e129280..b455c6c4f2ca 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/fmctrler.hxx @@ -65,7 +65,7 @@ #include #include #include -#include +#include #include #include #include @@ -101,9 +101,9 @@ #include #include -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 31 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 #include #endif @@ -118,500 +118,491 @@ struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::u typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, FmXTextComponentLess> FmFilterControls; typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; typedef ::std::vector< FmFilterRow > FmFilterRows; -typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > > FmFormControllers; +typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers; -struct FmFieldInfo; class FmFormView; class Window; namespace svxform { class ControlBorderManager; -} - -typedef ::comphelper::WeakComponentImplHelper31 < ::com::sun::star::form::XFormController - , ::com::sun::star::container::XChild - , ::com::sun::star::container::XIndexAccess - , ::com::sun::star::container::XEnumerationAccess - , ::com::sun::star::awt::XFocusListener - , ::com::sun::star::form::XLoadListener - , ::com::sun::star::beans::XPropertyChangeListener - , ::com::sun::star::awt::XTextListener - , ::com::sun::star::awt::XItemListener - , ::com::sun::star::container::XContainerListener - , ::com::sun::star::util::XModifyListener - , ::com::sun::star::util::XModifyBroadcaster - , ::com::sun::star::util::XModeSelector - , ::com::sun::star::form::XConfirmDeleteListener - , ::com::sun::star::form::XConfirmDeleteBroadcaster - , ::com::sun::star::sdb::XSQLErrorListener - , ::com::sun::star::sdb::XSQLErrorBroadcaster - , ::com::sun::star::sdbc::XRowSetListener - , ::com::sun::star::sdb::XRowSetApproveListener - , ::com::sun::star::sdb::XRowSetApproveBroadcaster - , ::com::sun::star::form::XDatabaseParameterListener - , ::com::sun::star::form::XDatabaseParameterBroadcaster - , ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::form::XResetListener - , ::com::sun::star::lang::XUnoTunnel - , ::com::sun::star::frame::XDispatch - , ::com::sun::star::awt::XMouseListener - , ::com::sun::star::form::validation::XFormComponentValidityListener - , ::com::sun::star::task::XInteractionHandler - , ::com::sun::star::lang::XInitialization - , ::com::sun::star::form::XGridControlListener - > FmXFormController_BASE; - -//================================================================== -// FmXFormController -//================================================================== -class ColumnInfoCache; -class SAL_DLLPRIVATE FmXFormController :public ::comphelper::OBaseMutex - ,public FmXFormController_BASE + struct FmFieldInfo; + + typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + , ::com::sun::star::awt::XFocusListener + , ::com::sun::star::form::XLoadListener + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::awt::XTextListener + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XModifyListener + , ::com::sun::star::form::XConfirmDeleteListener + , ::com::sun::star::sdb::XSQLErrorListener + , ::com::sun::star::sdbc::XRowSetListener + , ::com::sun::star::sdb::XRowSetApproveListener + , ::com::sun::star::form::XDatabaseParameterListener + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::form::XResetListener + , ::com::sun::star::lang::XUnoTunnel + , ::com::sun::star::frame::XDispatch + , ::com::sun::star::awt::XMouseListener + , ::com::sun::star::form::validation::XFormComponentValidityListener + , ::com::sun::star::task::XInteractionHandler + , ::com::sun::star::lang::XInitialization + , ::com::sun::star::form::XGridControlListener + > FormController_BASE; + + //================================================================== + // FormController + //================================================================== + class ColumnInfoCache; + class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex + ,public FormController_BASE ,public ::cppu::OPropertySetHelper ,public FmDispatchInterceptor - ,public ::comphelper::OAggregationArrayUsageHelper< FmXFormController > + ,public ::comphelper::OAggregationArrayUsageHelper< FormController > ,public ::svxform::OSQLParserClient ,public ::svx::IControllerFeatureInvalidation -{ - typedef ::std::map < sal_Int32, - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > - > DispatcherContainer; - - friend class FmXPageViewWinRec; - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; - ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; - // Composer used for checking filter conditions - ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; - ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; - - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; - ::cppu::OInterfaceContainerHelper - m_aActivateListeners, - m_aModifyListeners, - m_aErrorListeners, - m_aDeleteListeners, - m_aRowSetApproveListeners, - m_aParameterListeners; - - FmFormControllers m_aChilds; - FmFilterControls m_aFilterControls; - FmFilterRows m_aFilters; - - Timer m_aTabActivationTimer; - Timer m_aFeatureInvalidationTimer; - - FmFormView* m_pView; - Window* m_pWindow; - ::svxform::ControlBorderManager* - m_pControlBorderManager; - - ::svx::ControllerFeatures m_aControllerFeatures; - DispatcherContainer m_aFeatureDispatchers; - ::std::set< sal_Int32 > m_aInvalidFeatures; // for asynchronous feature invalidation - - ::rtl::OUString m_aMode; - - ::svxform::DelayedEvent m_aLoadEvent; - ::svxform::DelayedEvent m_aToggleEvent; - ::svxform::DelayedEvent m_aActivationEvent; - ::svxform::DelayedEvent m_aDeactivationEvent; - - ::std::auto_ptr< ColumnInfoCache > - m_pColumnInfoCache; - - sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) - - sal_Bool m_bCurrentRecordModified : 1; - sal_Bool m_bCurrentRecordNew : 1; - sal_Bool m_bLocked : 1; - sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare - sal_Bool m_bCycle : 1; - sal_Bool m_bCanInsert : 1; - sal_Bool m_bCanUpdate : 1; - sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained - sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? - sal_Bool m_bControlsSorted : 1; - sal_Bool m_bFiltering : 1; - sal_Bool m_bAttachEvents : 1; - sal_Bool m_bDetachEvents : 1; - sal_Bool m_bAttemptedHandlerCreation : 1; - - // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing - // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class - DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); - Interceptors m_aControlDispatchInterceptors; - -public: - inline const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& - getInteractionHandler() const { - const_cast< FmXFormController* >( this )->ensureInteractionHandler(); - return m_xInteractionHandler; - } - -public: - FmXFormController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB, - FmFormView* _pView = NULL, Window* _pWindow = NULL ); - ~FmXFormController(); - -// XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); - -// XTypeProvider - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - -// XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - SVX_DLLPUBLIC static FmXFormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); - -// XDispatch - virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - -// ::com::sun::star::container::XChild - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ) {return m_xParent;} - virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ) - {m_xParent = Parent;} - -// ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); - -// OComponentHelper - virtual void SAL_CALL disposing(); - -// OPropertySetHelper - virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) - throw( ::com::sun::star::lang::IllegalArgumentException ); - - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); - virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - using OPropertySetHelper::getFastPropertyValue; + typedef ::std::map < sal_Int32, + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > + > DispatcherContainer; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; + ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + // Composer used for checking filter conditions + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; + ::cppu::OInterfaceContainerHelper + m_aActivateListeners, + m_aModifyListeners, + m_aErrorListeners, + m_aDeleteListeners, + m_aRowSetApproveListeners, + m_aParameterListeners; + + FmFormControllers m_aChilds; + FmFilterControls m_aFilterControls; + FmFilterRows m_aFilters; + + Timer m_aTabActivationTimer; + Timer m_aFeatureInvalidationTimer; + + FmFormView* m_pView; + Window* m_pWindow; + ::svxform::ControlBorderManager* + m_pControlBorderManager; + + ::svx::ControllerFeatures m_aControllerFeatures; + DispatcherContainer m_aFeatureDispatchers; + ::std::set< sal_Int32 > m_aInvalidFeatures; // for asynchronous feature invalidation + + ::rtl::OUString m_aMode; + + ::svxform::DelayedEvent m_aLoadEvent; + ::svxform::DelayedEvent m_aToggleEvent; + ::svxform::DelayedEvent m_aActivationEvent; + ::svxform::DelayedEvent m_aDeactivationEvent; + + ::std::auto_ptr< ColumnInfoCache > + m_pColumnInfoCache; + + sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) + + sal_Bool m_bCurrentRecordModified : 1; + sal_Bool m_bCurrentRecordNew : 1; + sal_Bool m_bLocked : 1; + sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare + sal_Bool m_bCycle : 1; + sal_Bool m_bCanInsert : 1; + sal_Bool m_bCanUpdate : 1; + sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained + sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? + sal_Bool m_bControlsSorted : 1; + sal_Bool m_bFiltering : 1; + sal_Bool m_bAttachEvents : 1; + sal_Bool m_bDetachEvents : 1; + sal_Bool m_bAttemptedHandlerCreation : 1; + + // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing + // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class + DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); + Interceptors m_aControlDispatchInterceptors; + + public: + inline const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& + getInteractionHandler() const + { + const_cast< FormController* >( this )->ensureInteractionHandler(); + return m_xInteractionHandler; + } + + public: + FormController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB, + FmFormView* _pView = NULL, Window* _pWindow = NULL ); + ~FormController(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + SVX_DLLPUBLIC static FormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ) {return m_xParent;} + virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ) + {m_xParent = Parent;} + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + using OPropertySetHelper::getFastPropertyValue; + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XEnumerationAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XContainerListener + virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XLoadListener + virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XModeSelector + virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + + // XFocusListener + virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); -// XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); + // XMouseListener + virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); + // XFormComponentValidityListener + virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XContainerListener - virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + // XInteractionHandler + virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); -// XLoadListener - virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); -// XModeSelector - virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); - virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); + // XGridControlListener + virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + // ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati + virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); -// XModifyBroadcaster - virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + // XTextListener -> modify setzen + virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); -// XFocusListener - virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + // XItemListener -> modify setzen + virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); -// XMouseListener - virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + // XModifyListener -> modify setzen + virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); -// XFormComponentValidityListener - virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); + // XFormController + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); -// XInteractionHandler - virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); + // XTabController + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); -// XInitialization - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); -// XGridControlListener - virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); -// ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati - virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); -// XTextListener -> modify setzen - virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); -// XItemListener -> modify setzen - virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + // com::sun::star::sdbc::XRowSetListener + virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); -// XModifyListener -> modify setzen - virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + // XRowSetApproveListener + virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); -// XFormController - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + // XRowSetApproveBroadcaster + virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); -// XTabController - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); + // XSQLErrorBroadcaster + virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); + // XSQLErrorListener + virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); + // XDatabaseParameterBroadcaster2 + virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + // XDatabaseParameterBroadcaster + virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); + // XDatabaseParameterListener + virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); -// com::sun::star::sdbc::XRowSetListener - virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + // XConfirmDeleteBroadcaster + virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); -// XRowSetApproveListener - virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + // XConfirmDeleteListener + virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); -// XRowSetApproveBroadcaster - virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); -// XSQLErrorBroadcaster - virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + // XResetListener + virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); -// XSQLErrorListener - virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + // method for registration + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); -// XDatabaseParameterBroadcaster2 - virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + // comphelper::OPropertyArrayUsageHelper + virtual void fillProperties( + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps + ) const; -// XDatabaseParameterBroadcaster - virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + // access to the controls for filtering + const FmFilterControls& getFilterControls() const {return m_aFilterControls;} -// XDatabaseParameterListener - virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + // access to the current filter rows + const FmFilterRows& getFilterRows() const {return m_aFilters;} + FmFilterRows& getFilterRows() {return m_aFilters;} -// XConfirmDeleteBroadcaster - virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + // just decr. the positions no notifications for the view + void decrementCurrentFilterPosition() + { + DBG_ASSERT(m_nCurrentFilterPosition, "Invalid Position"); + --m_nCurrentFilterPosition; + } -// XConfirmDeleteListener - virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + SVX_DLLPUBLIC void setCurrentFilterPosition(sal_Int32 nPos); + sal_Int32 getCurrentFilterPosition() const {return m_nCurrentFilterPosition;} -// XServiceInfo - virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); + void addChild( FormController* pChild ); -// XResetListener - virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + protected: + // FmDispatchInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> + interceptedQueryDispatch(sal_uInt16 _nId,const ::com::sun::star::util::URL& aURL, + const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) + throw( ::com::sun::star::uno::RuntimeException ); -// method for registration - static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); + // IControllerFeatureInvalidation + virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ); - // comphelper::OPropertyArrayUsageHelper - virtual void fillProperties( - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps - ) const; + virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } -// access to the controls for filtering - const FmFilterControls& getFilterControls() const {return m_aFilterControls;} + /// update all our dispatchers + void updateAllDispatchers() const; -// access to the current filter rows - const FmFilterRows& getFilterRows() const {return m_aFilters;} - FmFilterRows& getFilterRows() {return m_aFilters;} - - // just decr. the positions no notifications for the view - void decrementCurrentFilterPosition() - { - DBG_ASSERT(m_nCurrentFilterPosition, "Invalid Position"); - --m_nCurrentFilterPosition; - } - - SVX_DLLPUBLIC void setCurrentFilterPosition(sal_Int32 nPos); - sal_Int32 getCurrentFilterPosition() const {return m_nCurrentFilterPosition;} - -protected: - // FmDispatchInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> - interceptedQueryDispatch(sal_uInt16 _nId,const ::com::sun::star::util::URL& aURL, - const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) - throw( ::com::sun::star::uno::RuntimeException ); - - // IControllerFeatureInvalidation - virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ); - - virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } - - /// update all our dispatchers - void updateAllDispatchers() const; - - /** disposes all dispatchers in m_aFeatureDispatchers, empties m_aFeatureDispatchers, - and disposes m_aControllerFeatures - */ - void disposeAllFeaturesAndDispatchers() SAL_THROW(()); - - void startFiltering(); - void stopFiltering(); - void setFilter(::std::vector&); - void startListening(); - void stopListening(); - - /** ensures that we have an interaction handler, if possible - - If an interaction handler was provided at creation time (initialize), this - one will be used. Else, an attempt is made to create an InteractionHandler - is made. - - @return - if and only if m_xInteractionHandler is valid when the method returns - */ - bool ensureInteractionHandler(); - - /** replaces one of our controls with another one - - Upon successful replacing, the old control will be disposed. Also, internal members pointing - to the current or active control will be adjusted. Yet more, if the replaced control was - the active control, the new control will be made active. - - @param _rxExistentControl - The control to replace. Must be one of the controls in our ControlContainer. - @param _rxNewControl - The control which should replace the existent control. - @return - if and only if the control was successfully replaced - */ - bool replaceControl( - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl - ); - - // we're listening at all bound controls for modifications - void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - void setLocks(); - void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void toggleAutoFields(sal_Bool bAutoFields); - void unload() throw( ::com::sun::star::uno::RuntimeException ); - void removeBoundFieldListener(); - - void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; - - void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - /// called when a new control is to be handled by the controller - void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); - /// called when a control is not to be handled by the controller anymore - void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); - - /** sets m_xCurrentControl, plus does administrative tasks depending on it - */ - void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); - - /** invalidates the FormFeatures which depend on the current control - */ - void implInvalidateCurrentControlDependentFeatures(); - - bool impl_isDisposed_nofail() const { return FmXFormController_BASE::rBHelper.bDisposed; } - - void impl_onModify(); - - sal_Bool isLocked() const {return m_bLocked;} - sal_Bool determineLockState() const; - - Window* getDialogParentWindow(); - // returns m_pWindow or - if m_pWindow is NULL - the window of the currently set container - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // create a new interceptor, register it on the given object - void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // if createInterceptor was called for the given object the according interceptor will be removed - // from the objects interceptor chain and released - - /** checks all form controls belonging to our form for validity - - If a form control supports the XValidatableFormComponent interface, this is used to determine - the validity of the control. If the interface is not supported, the control is supposed to be - valid. - - @param _rFirstInvalidityExplanation - if the method returns (i.e. if there is an invalid control), this string contains - the explanation for the invalidity, as obtained from the validator. - - @param _rxFirstInvalidModel - if the method returns (i.e. if there is an invalid control), this contains - the control model - - @return - if and only if all controls belonging to our form are valid - */ - bool checkFormComponentValidity( - ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel - ) SAL_THROW(()); - - /** locates the control which belongs to a given model - */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > - locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); - - // set the text for all filters - void impl_setTextOnAllFilter_throw(); - - // in filter mode we do not listen for changes - sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} - void addChild(FmXFormController* pChild); - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; - - DECL_LINK( OnActivateTabOrder, void* ); - DECL_LINK( OnInvalidateFeatures, void* ); - DECL_LINK( OnLoad, void* ); - DECL_LINK( OnToggleAutoFields, void* ); - DECL_LINK( OnActivated, void* ); - DECL_LINK( OnDeactivated, void* ); -}; + /** disposes all dispatchers in m_aFeatureDispatchers, empties m_aFeatureDispatchers, + and disposes m_aControllerFeatures + */ + void disposeAllFeaturesAndDispatchers() SAL_THROW(()); + void startFiltering(); + void stopFiltering(); + void setFilter(::std::vector&); + void startListening(); + void stopListening(); + + /** ensures that we have an interaction handler, if possible + + If an interaction handler was provided at creation time (initialize), this + one will be used. Else, an attempt is made to create an InteractionHandler + is made. + + @return + if and only if m_xInteractionHandler is valid when the method returns + */ + bool ensureInteractionHandler(); + + /** replaces one of our controls with another one + + Upon successful replacing, the old control will be disposed. Also, internal members pointing + to the current or active control will be adjusted. Yet more, if the replaced control was + the active control, the new control will be made active. + + @param _rxExistentControl + The control to replace. Must be one of the controls in our ControlContainer. + @param _rxNewControl + The control which should replace the existent control. + @return + if and only if the control was successfully replaced + */ + bool replaceControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl + ); + + // we're listening at all bound controls for modifications + void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + void setLocks(); + void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void toggleAutoFields(sal_Bool bAutoFields); + void unload() throw( ::com::sun::star::uno::RuntimeException ); + void removeBoundFieldListener(); + + void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; + + void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + /// called when a new control is to be handled by the controller + void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); + /// called when a control is not to be handled by the controller anymore + void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); + + /** sets m_xCurrentControl, plus does administrative tasks depending on it + */ + void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); + + /** invalidates the FormFeatures which depend on the current control + */ + void implInvalidateCurrentControlDependentFeatures(); + + bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } + + void impl_onModify(); + + sal_Bool isLocked() const {return m_bLocked;} + sal_Bool determineLockState() const; + + Window* getDialogParentWindow(); + // returns m_pWindow or - if m_pWindow is NULL - the window of the currently set container + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // create a new interceptor, register it on the given object + void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // if createInterceptor was called for the given object the according interceptor will be removed + // from the objects interceptor chain and released + + /** checks all form controls belonging to our form for validity + + If a form control supports the XValidatableFormComponent interface, this is used to determine + the validity of the control. If the interface is not supported, the control is supposed to be + valid. + + @param _rFirstInvalidityExplanation + if the method returns (i.e. if there is an invalid control), this string contains + the explanation for the invalidity, as obtained from the validator. + + @param _rxFirstInvalidModel + if the method returns (i.e. if there is an invalid control), this contains + the control model + + @return + if and only if all controls belonging to our form are valid + */ + bool checkFormComponentValidity( + ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel + ) SAL_THROW(()); + + /** locates the control which belongs to a given model + */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > + locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); + + // set the text for all filters + void impl_setTextOnAllFilter_throw(); + + // in filter mode we do not listen for changes + sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; + + DECL_LINK( OnActivateTabOrder, void* ); + DECL_LINK( OnInvalidateFeatures, void* ); + DECL_LINK( OnLoad, void* ); + DECL_LINK( OnToggleAutoFields, void* ); + DECL_LINK( OnActivated, void* ); + DECL_LINK( OnDeactivated, void* ); + }; + +} // namespace svxform #endif // _SVX_FMCTRLER_HXX diff --git a/svx/source/inc/fmservs.hxx b/svx/source/inc/fmservs.hxx index 201a5a351224..62d9654858a3 100644 --- a/svx/source/inc/fmservs.hxx +++ b/svx/source/inc/fmservs.hxx @@ -57,7 +57,7 @@ #define FM_COMPONENT_IMAGECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ImageControl" ) ) #define FM_CONTROL_GRID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.Grid" ) ) #define FM_CONTROL_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.GridControl" ) ) -#define FM_FORM_CONTROLLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) +#define FM_FORM_CONTROLLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.runtime.FormController" ) ) #define SRV_SDB_CONNECTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.Connection" ) ) #define SRV_SDB_INTERACTION_HANDLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.InteractionHandler" ) ) #define FM_SUN_COMPONENT_FORM rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.Form" ) ) diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 85644ea5daba..7d60e60f6d0e 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -243,9 +243,9 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE // aktuelle Form, Controller // nur im alive mode verfuegbar - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xActiveController; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xNavigationController; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> m_xActiveForm; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xNavigationController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xActiveForm; // Aktueller container einer Page // nur im designmode verfuegbar @@ -266,9 +266,9 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE // the frame we live in ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame> m_xAttachedFrame; // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot) - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController> m_xExternalViewController; // the controller for the external form view - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xExtViewTriggerController; // the nav controller at the time the external display was triggered - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xExternalDisplayedForm; // the form which the external view is based on + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xExternalViewController; // the controller for the external form view + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on FmXDispatchInterceptorImpl* m_pExternalViewInterceptor; @@ -399,11 +399,11 @@ protected: public: // methode fuer nicht designmode (alive mode) - void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False ); - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getActiveController() const {return m_xActiveController;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; } + void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False ); + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveController() const {return m_xActiveController;} + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; } const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& getActiveForm() const {return m_xActiveForm;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getNavController() const {return m_xNavigationController;} + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getNavController() const {return m_xNavigationController;} inline const ::svx::ControllerFeatures& getActiveControllerFeatures() const { return m_aActiveControllerFeatures; } @@ -568,13 +568,13 @@ private: public: enum CURSOR_ACTION { CA_MOVE_TO_LAST, CA_MOVE_ABSOLUTE }; - void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController, CURSOR_ACTION _eWhat); + void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, CURSOR_ACTION _eWhat); void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm, CURSOR_ACTION _eWhat); sal_Bool HasAnyPendingCursorAction() const; void CancelAnyPendingCursorAction(); - sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController) const; + sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController) const; sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm) const; /** execute the given form slot diff --git a/svx/source/inc/fmtextcontrolshell.hxx b/svx/source/inc/fmtextcontrolshell.hxx index 17ba06d5513b..a67520f89ed8 100644 --- a/svx/source/inc/fmtextcontrolshell.hxx +++ b/svx/source/inc/fmtextcontrolshell.hxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include /** === end UNO includes === **/ @@ -92,10 +92,10 @@ namespace svx ,public IContextRequestObserver { private: - ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xActiveControl; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xActiveTextComponent; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xActiveController; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xActiveControl; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xActiveTextComponent; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController; #ifndef DONT_REMEMBER_LAST_CONTROL // without this define, m_xActiveControl remembers the *last* active control, even // if it, in the meantime, already lost the focus @@ -144,10 +144,10 @@ namespace svx /** to be called when a form in our document has been activated */ - void formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** to be called when a form in our document has been deactivated */ - void formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** notifies the instance that the design mode has changed */ @@ -205,7 +205,7 @@ namespace svx @precond we don't have an active controller currently */ - void startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** stops listening at the active controller @precond we have an active controller currently diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx index 12965c07ad3b..b6e1c74e9375 100644 --- a/svx/source/inc/fmvwimp.hxx +++ b/svx/source/inc/fmvwimp.hxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -73,7 +73,9 @@ FORWARD_DECLARE_INTERFACE(awt,XWindow) FORWARD_DECLARE_INTERFACE(beans,XPropertySet) FORWARD_DECLARE_INTERFACE(util,XNumberFormats) -class FmXFormController; +namespace svxform { + class FormController; +} class FmXFormView; namespace svx { @@ -88,9 +90,9 @@ class FmXPageViewWinRec : public ::cppu::WeakImplHelper1< ::com::sun::star::cont { friend class FmXFormView; - ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > > m_aControllerList; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer; - ::comphelper::ComponentContext m_aContext; + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > m_aControllerList; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer; + ::comphelper::ComponentContext m_aContext; FmXFormView* m_pViewImpl; Window* m_pWindow; @@ -113,12 +115,12 @@ public: virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _Index) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > >& GetList() {return m_aControllerList;} + const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;} protected: - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const; void setController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, - FmXFormController* pParent = NULL); + ::svxform::FormController* pParent = NULL); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; } void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); void dispose(); @@ -213,7 +215,7 @@ public: FmWinRecList::const_iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const; const FmWinRecList& getWindowList() const {return m_aWinList;} - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; // activation handling diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx index d082bd889804..2b5b64db262d 100644 --- a/svx/source/inc/formcontrolling.hxx +++ b/svx/source/inc/formcontrolling.hxx @@ -31,7 +31,7 @@ #ifndef SVX_FORMCONTROLLING_HXX #define SVX_FORMCONTROLLING_HXX -#include +#include #include #include #include @@ -117,7 +117,7 @@ namespace svx IControllerFeatureInvalidation* _pInvalidationCallback ); - /** constructs the instance from a XFormController instance + /** constructs the instance from a XFormController instance @param _rxORB a multi service factory for creating various needed components @@ -131,7 +131,7 @@ namespace svx */ ControllerFeatures( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback ); @@ -163,7 +163,7 @@ namespace svx /** assign to a controller */ void assign( - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** assign to a controller @@ -206,7 +206,7 @@ namespace svx ::com::sun::star::uno::Any m_aOperationError; public: - /** constructs the helper from a XFormController instance + /** constructs the helper from a XFormController instance @param _rContext the context the component lives in @@ -218,7 +218,7 @@ namespace svx */ FormControllerHelper( const ::comphelper::ComponentContext& _rContext, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback ); -- cgit From 1797003bca0efd998218baba2cd90b10764a2256 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 23 Oct 2009 16:03:52 +0200 Subject: step 1 of the FormController UNOization: base the outgoing calls in the FormController implementation on (new) UNO API, instead of using implementation classes --- svx/source/form/fmctrler.cxx | 147 ++++++++++++++++++++++++++----------------- svx/source/form/fmvwimp.cxx | 52 ++++++++------- svx/source/inc/fmctrler.hxx | 59 ++++++++--------- svx/source/inc/fmvwimp.hxx | 24 ++++--- 4 files changed, 161 insertions(+), 121 deletions(-) diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index d0bff4ea83b0..9f314bb4af82 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -200,6 +200,8 @@ namespace svxform using ::com::sun::star::task::XInteractionRequest; using ::com::sun::star::util::URL; using ::com::sun::star::frame::FeatureStateEvent; + using ::com::sun::star::form::runtime::XFormControllerContext; + using ::com::sun::star::task::XInteractionHandler; /** === end UNO using === **/ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -546,8 +548,7 @@ IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisP DBG_NAME( FormController ) //------------------------------------------------------------------ -FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB, - FmFormView* _pView, Window* _pWindow ) +FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ) :FormController_BASE( m_aMutex ) ,OPropertySetHelper( FormController_BASE::rBHelper ) ,OSQLParserClient(_rxORB) @@ -558,8 +559,6 @@ FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB, ,m_aDeleteListeners(m_aMutex) ,m_aRowSetApproveListeners(m_aMutex) ,m_aParameterListeners(m_aMutex) - ,m_pView(_pView) - ,m_pWindow(_pWindow) ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) ,m_aControllerFeatures( _rxORB, this ) ,m_aMode( DATA_MODE ) @@ -978,13 +977,12 @@ Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBounds } //----------------------------------------------------------------------------- -void FormController::addChild(FormController* pChild) +void FormController::addChild( const Reference< XFormController >& _rxChildController ) { - Reference< XFormController > xController(pChild); - m_aChilds.push_back(xController); - pChild->setParent( *this ); + m_aChilds.push_back( _rxChildController ); + _rxChildController->setParent( *this ); - Reference< XFormComponent > xForm(pChild->getModel(), UNO_QUERY); + Reference< XFormComponent > xForm( _rxChildController->getModel(), UNO_QUERY); // search the position of the model within the form sal_uInt32 nPos = m_xModelAsIndex->getCount(); @@ -992,10 +990,10 @@ void FormController::addChild(FormController* pChild) for( ; nPos; ) { m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ((XFormComponent*)xForm.get() == (XFormComponent*)xTemp.get()) + if ( xForm.get() == xTemp.get() ) { - Reference< XInterface > xIfc(xController, UNO_QUERY); - m_xModelAsManager->attach( nPos, xIfc, makeAny( xController) ); + Reference< XInterface > xIfc( _rxChildController, UNO_QUERY ); + m_xModelAsManager->attach( nPos, xIfc, makeAny( _rxChildController) ); break; } } @@ -1039,7 +1037,7 @@ void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::disposeAllFeaturesAndDispatchers: caught an exception while disposing a dispatcher!" ); + DBG_UNHANDLED_EXCEPTION(); } } m_aFeatureDispatchers.clear(); @@ -1248,7 +1246,7 @@ bool FormController::replaceControl( const Reference< XControl >& _rxExistentCon } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::replaceControl: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl ); @@ -1461,12 +1459,13 @@ void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) { TRACE_RANGE( "FormController::focusGained" ); + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XControl > xControl(e.Source, UNO_QUERY); m_pControlBorderManager->focusGained( e.Source ); + Reference< XControl > xControl(e.Source, UNO_QUERY); if (m_bDBConnection) { // do we need to keep the locking of the commit @@ -1570,18 +1569,17 @@ void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) if ( m_bDBConnection && !m_bFiltering ) implInvalidateCurrentControlDependentFeatures(); - if (m_xCurrentControl.is()) - { - // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich - Reference< XWindow > xWindow(xControl, UNO_QUERY); - if (xWindow.is() && m_pView && m_pWindow) - { - ::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize(); - ::Rectangle aNewRect(aRect.X,aRect.Y,aRect.X+aRect.Width,aRect.Y+aRect.Height); - aNewRect = m_pWindow->PixelToLogic(aNewRect); - m_pView->MakeVisible( aNewRect, *const_cast< Window* >( m_pWindow ) ); - } - } + if ( !m_xCurrentControl.is() ) + return; + + // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich + Reference< XFormControllerContext > xContext( m_xContext ); + Reference< XControl > xCurrentControl( m_xCurrentControl ); + aGuard.clear(); + // <-- SYNCHRONIZED + + if ( xContext.is() ) + xContext->makeVisible( xCurrentControl ); } //------------------------------------------------------------------------------ @@ -1758,7 +1756,7 @@ void FormController::setModel(const Reference< XTabControllerModel > & Model) th } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::setModel: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -2560,7 +2558,7 @@ void FormController::startFormListening( const Reference< XPropertySet >& _rxFor } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::startFormListening: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -2592,7 +2590,7 @@ void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::stopFormListening: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -2790,6 +2788,42 @@ void SAL_CALL FormController::removeActivateListener(const Reference< XFormContr m_aActivateListeners.removeInterface(l); } +//------------------------------------------------------------------------------ +Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_xContext; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *this ); + m_xContext = _context; +} + +//------------------------------------------------------------------------------ +Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_xInteractionHandler; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *this ); + m_xInteractionHandler = _interactionHandler; +} + //------------------------------------------------------------------------------ void FormController::setFilter(::std::vector& rFieldInfos) { @@ -3270,21 +3304,18 @@ sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) thro Window* FormController::getDialogParentWindow() { OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - Window* pParent = m_pWindow; - if ( !pParent ) + Window* pParentWindow = NULL; + try { - try - { - Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); - Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); - pParent = VCLUnoHelper::GetWindow( xContainerPeer ); - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "FormController::getDialogParentWindow: caught an exception!" ); - } + Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); + Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); + pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ); } - return pParent; + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return pParentWindow; } //------------------------------------------------------------------------------ bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) @@ -3323,7 +3354,7 @@ bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _r } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::checkFormComponentValidity: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return true; } @@ -3350,7 +3381,7 @@ Reference< XControl > FormController::locateControl( const Reference< XControlMo } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FormController::locateControl: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return NULL; } @@ -3693,7 +3724,7 @@ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& } catch(Exception&) { - DBG_ERROR("FormController::approveParameter: caught an Exception (tried to let the InteractionHandler handle it)!"); + DBG_UNHANDLED_EXCEPTION(); } } return sal_True; @@ -3846,6 +3877,18 @@ void SAL_CALL FormController::addStatusListener( const Reference< XStatusListene OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!"); } +//------------------------------------------------------------------------------ +Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException ) +{ + return m_xParent; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException ) +{ + m_xParent = Parent; +} + //------------------------------------------------------------------------------ void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) { @@ -3930,16 +3973,6 @@ void FormController::deleteInterceptor(const Reference< XDispatchProviderInterce m_aControlDispatchInterceptors.erase(aIter); } -//-------------------------------------------------------------------- -void SAL_CALL FormController::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) -{ - DBG_ASSERT( !m_xInteractionHandler.is(), "FormController::initialize: already initialized!" ); - // currently, we only initialize our interaction handler here, so it's sufficient to assert this - - ::comphelper::NamedValueCollection aArgs( aArguments ); - m_xInteractionHandler = aArgs.getOrDefault( "InteractionHandler", m_xInteractionHandler ); -} - //-------------------------------------------------------------------- void FormController::implInvalidateCurrentControlDependentFeatures() { diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index d88ecf0e5052..58ad69b5417c 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -293,6 +293,21 @@ Any SAL_CALL FmXPageViewWinRec::getByIndex(sal_Int32 nIndex) throw( IndexOutOfBo return aElement; } +//------------------------------------------------------------------------ +void SAL_CALL FmXPageViewWinRec::makeVisible( const Reference< XControl >& _Control ) throw (RuntimeException) +{ + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + + Reference< XWindow > xWindow( _Control, UNO_QUERY ); + if ( xWindow.is() && m_pViewImpl->getView() && m_pWindow ) + { + awt::Rectangle aRect = xWindow->getPosSize(); + ::Rectangle aNewRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height ); + aNewRect = m_pWindow->PixelToLogic( aNewRect ); + m_pViewImpl->getView()->MakeVisible( aNewRect, *m_pWindow ); + } +} + //------------------------------------------------------------------------ Reference< XFormController > getControllerSearchChilds( const Reference< XIndexAccess > & xIndex, const Reference< XTabControllerModel > & xModel) { @@ -348,51 +363,42 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormCon Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY); // create a form controller - FormController* pController = new FormController( m_aContext.getLegacyServiceFactory(), m_pViewImpl->getView(), m_pWindow ); + FormController* pController = new FormController( m_aContext.getLegacyServiceFactory() ); Reference< XFormController > xController( pController ); + Reference< XFormController > xParentController( _pParent ); Reference< XInteractionHandler > xHandler; - if ( _pParent ) - xHandler = _pParent->getInteractionHandler(); + if ( xParentController.is() ) + xHandler = xParentController->getInteractionHandler(); else { // TODO: should we create a default handler? Not really necessary, since the // FormController itself has a default fallback } if ( xHandler.is() ) - { - Reference< XInitialization > xInitController( xController, UNO_QUERY ); - DBG_ASSERT( xInitController.is(), "FmXPageViewWinRec::setController: can't initialize the controller!" ); - if ( xInitController.is() ) - { - Sequence< Any > aInitArgs( 1 ); - aInitArgs[ 0 ] <<= NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ), makeAny( xHandler ) ); - xInitController->initialize( aInitArgs ); - } - } + xController->setInteractionHandler( xHandler ); - pController->setModel(xTabOrder); - pController->setContainer( m_xControlContainer ); - pController->activateTabOrder(); - pController->addActivateListener(m_pViewImpl); + xController->setContext( this ); + + xController->setModel( xTabOrder ); + xController->setContainer( m_xControlContainer ); + xController->activateTabOrder(); + xController->addActivateListener( m_pViewImpl ); if ( _pParent ) - _pParent->addChild(pController); + _pParent->addChild( xController ); else { - // Reference< XFormController > xController(pController); m_aControllerList.push_back(xController); - pController->setParent(*this); + xController->setParent( xParentController ); // attaching the events - Reference< XEventAttacherManager > xEventManager(xForm->getParent(), UNO_QUERY); + Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY ); Reference< XInterface > xIfc(xController, UNO_QUERY); xEventManager->attach(m_aControllerList.size() - 1, xIfc, makeAny(xController) ); } - - // jetzt die Subforms durchgehen sal_uInt32 nLength = xFormCps->getCount(); Reference< XForm > xSubForm; diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx index b455c6c4f2ca..24795558981c 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/fmctrler.hxx @@ -76,7 +76,6 @@ #include #include #include -#include #include #include #include @@ -101,9 +100,9 @@ #include #include -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 #include #endif @@ -128,7 +127,7 @@ namespace svxform class ControlBorderManager; struct FmFieldInfo; - typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + typedef ::comphelper::WeakComponentImplHelper21 < ::com::sun::star::form::runtime::XFormController , ::com::sun::star::awt::XFocusListener , ::com::sun::star::form::XLoadListener , ::com::sun::star::beans::XPropertyChangeListener @@ -148,7 +147,6 @@ namespace svxform , ::com::sun::star::awt::XMouseListener , ::com::sun::star::form::validation::XFormComponentValidityListener , ::com::sun::star::task::XInteractionHandler - , ::com::sun::star::lang::XInitialization , ::com::sun::star::form::XGridControlListener > FormController_BASE; @@ -176,8 +174,9 @@ namespace svxform ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; // Composer used for checking filter conditions - ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; - ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > m_xContext; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; ::cppu::OInterfaceContainerHelper @@ -195,8 +194,6 @@ namespace svxform Timer m_aTabActivationTimer; Timer m_aFeatureInvalidationTimer; - FmFormView* m_pView; - Window* m_pWindow; ::svxform::ControlBorderManager* m_pControlBorderManager; @@ -236,19 +233,18 @@ namespace svxform DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); Interceptors m_aControlDispatchInterceptors; - public: - inline const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& - getInteractionHandler() const - { - const_cast< FormController* >( this )->ensureInteractionHandler(); - return m_xInteractionHandler; - } + protected: + ~FormController(); public: - FormController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB, - FmFormView* _pView = NULL, Window* _pWindow = NULL ); - ~FormController(); + FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + SVX_DLLPUBLIC static FormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + protected: // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL acquire() throw (); @@ -258,20 +254,14 @@ namespace svxform virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - SVX_DLLPUBLIC static FormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); - // XDispatch virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::container::XChild - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ) {return m_xParent;} - virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ) - {m_xParent = Parent;} + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); // ::com::sun::star::lang::XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); @@ -341,9 +331,6 @@ namespace svxform // XInteractionHandler virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); - // XInitialization - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - // XGridControlListener virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); @@ -365,6 +352,11 @@ namespace svxform virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException); + // XTabController virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); @@ -437,6 +429,7 @@ namespace svxform ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps ) const; + public: // access to the controls for filtering const FmFilterControls& getFilterControls() const {return m_aFilterControls;} @@ -454,7 +447,7 @@ namespace svxform SVX_DLLPUBLIC void setCurrentFilterPosition(sal_Int32 nPos); sal_Int32 getCurrentFilterPosition() const {return m_nCurrentFilterPosition;} - void addChild( FormController* pChild ); + void addChild( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxChildController ); protected: // FmDispatchInterceptor @@ -552,7 +545,7 @@ namespace svxform sal_Bool determineLockState() const; Window* getDialogParentWindow(); - // returns m_pWindow or - if m_pWindow is NULL - the window of the currently set container + // returns the window which should be used as parent window for dialogs ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); // create a new interceptor, register it on the given object diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx index b6e1c74e9375..62e913afdac2 100644 --- a/svx/source/inc/fmvwimp.hxx +++ b/svx/source/inc/fmvwimp.hxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -49,7 +50,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,7 +87,11 @@ namespace svx { //================================================================== // FmXPageViewWinRec //================================================================== -class FmXPageViewWinRec : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess> +typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XIndexAccess + , ::com::sun::star::form::runtime::XFormControllerContext + > FmXPageViewWinRec_Base; + +class FmXPageViewWinRec : public FmXPageViewWinRec_Base { friend class FmXFormView; @@ -96,25 +101,28 @@ class FmXPageViewWinRec : public ::cppu::WeakImplHelper1< ::com::sun::star::cont FmXFormView* m_pViewImpl; Window* m_pWindow; +protected: + ~FmXPageViewWinRec(); + public: FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext, const SdrPageWindow&, FmXFormView* pView); //const SdrPageViewWinRec*, FmXFormView* pView); - ~FmXPageViewWinRec(); - -// UNO Anbindung -// ::com::sun::star::container::XElementAccess + // XElementAccess virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XEnumerationAccess + // XEnumerationAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XIndexAccess + // XIndexAccess virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _Index) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XFormControllerContext + virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException); + const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;} protected: -- cgit From 0ddf79332ac1d5af90fcd318ed201e73d1a99ac2 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Tue, 27 Oct 2009 12:58:43 +0100 Subject: (during #i106263#) exception safety for commitControl --- svx/source/fmcomp/gridcell.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index ff7cfd422eb8..5f6f56ac075c 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -679,7 +679,15 @@ sal_Bool DbCellControl::Commit() // lock the listening for value property changes lockValueProperty(); // commit the content of the control into the model's value property - sal_Bool bReturn = commitControl(); + sal_Bool bReturn = sal_False; + try + { + bReturn = commitControl(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // unlock the listening for value property changes unlockValueProperty(); // outta here -- cgit From 7cef9bd05b4f0372fb3f1668b9ddd140b5b07633 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 28 Oct 2009 08:48:59 +0100 Subject: copying fix for issue #i105367# herein --- svx/source/form/fmtextcontrolshell.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 166b09f8a1c1..66feffd2feba 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -102,6 +102,7 @@ namespace svx //==================================================================== static SfxSlotId pTextControlSlots[] = { + SID_CLIPBOARD_FORMAT_ITEMS, SID_CUT, SID_COPY, SID_PASTE, @@ -141,7 +142,6 @@ namespace svx // SID_TEXTDIRECTION_TOP_TO_BOTTOM, SID_ATTR_CHAR_SCALEWIDTH, /* 911 */ SID_ATTR_CHAR_RELIEF, - SID_CLIPBOARD_FORMAT_ITEMS, /* 922 */ SID_ATTR_PARA_LEFT_TO_RIGHT, /* 950 */ SID_ATTR_PARA_RIGHT_TO_LEFT, 0 -- cgit From b1896d2ad88e9162731c2ffe03436786883d9661 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 28 Oct 2009 09:50:28 +0100 Subject: #i106368# --- .../sdr/contact/viewobjectcontactofunocontrol.hxx | 8 ++ .../sdr/contact/viewobjectcontactofunocontrol.cxx | 86 +++++++++++----------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx b/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx index 27359ebf9738..854466ca72f1 100644 --- a/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx +++ b/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx @@ -97,6 +97,11 @@ namespace sdr { namespace contact { */ virtual void ActionChanged(); + /** to be called when any aspect of the control which requires view updates changed + */ + struct ImplAccess { friend class ViewObjectContactOfUnoControl_Impl; friend class ViewObjectContactOfUnoControl; private: ImplAccess() { } }; + void onControlChangedOrModified( ImplAccess ) { impl_onControlChangedOrModified(); } + protected: ViewObjectContactOfUnoControl( ObjectContact& _rObjectContact, ViewContactOfUnoControl& _rViewContact ); ~ViewObjectContactOfUnoControl(); @@ -104,6 +109,9 @@ namespace sdr { namespace contact { // support for Primitive2D virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const; + /// to be called when any aspect of the control which requires view updates changed + void impl_onControlChangedOrModified(); + private: ViewObjectContactOfUnoControl(); // never implemented ViewObjectContactOfUnoControl( const ViewObjectContactOfUnoControl& ); // never implemented diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index 667129e27653..6c3ce35ab1aa 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -565,14 +565,6 @@ namespace sdr { namespace contact { */ bool isControlVisible() const { return impl_isControlVisible_nofail(); } - /** determines whether the instance belongs to a given OutputDevice - @precond - The instance knows the device it belongs to, or can determine it. - If this is not the case, you will notice an assertion, and the method will - return false. - */ - bool belongsToDevice( const OutputDevice* _pDevice ) const; - /// creates an XControl for the given device and SdrUnoObj static bool createControlForDevice( @@ -988,10 +980,10 @@ namespace sdr { namespace contact { namespace { - static void lcl_resetFlag( bool& rbFlag ) - { - rbFlag = false; - } + static void lcl_resetFlag( bool& rbFlag ) + { + rbFlag = false; + } } //-------------------------------------------------------------------- @@ -1014,8 +1006,8 @@ namespace sdr { namespace contact { } m_bCreatingControl = true; - ::comphelper::ScopeGuard aGuard( ::boost::bind( lcl_resetFlag, ::boost::ref( m_bCreatingControl ) ) ); - + ::comphelper::ScopeGuard aGuard( ::boost::bind( lcl_resetFlag, ::boost::ref( m_bCreatingControl ) ) ); + if ( m_aControl.is() ) { if ( m_pOutputDeviceForWindow == &_rDevice ) @@ -1418,31 +1410,33 @@ namespace sdr { namespace contact { VOCGuard aGuard( *this ); DBG_ASSERT( Event.Source == m_xContainer, "ViewObjectContactOfUnoControl_Impl::elementReplaced: where did this come from?" ); - if ( m_aControl == Event.ReplacedElement ) - { - Reference< XControl > xNewControl( Event.Element, UNO_QUERY ); - DBG_ASSERT( xNewControl.is(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: invalid new control!" ); - if ( !xNewControl.is() ) - return; + if ( ! ( m_aControl == Event.ReplacedElement ) ) + return; - ENSURE_OR_THROW( m_pOutputDeviceForWindow, "calling this without /me having an output device should be impossible." ); + Reference< XControl > xNewControl( Event.Element, UNO_QUERY ); + DBG_ASSERT( xNewControl.is(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: invalid new control!" ); + if ( !xNewControl.is() ) + return; - DBG_ASSERT( xNewControl->getModel() == m_aControl.getModel(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: another model at the new control?" ); - // another model should - in the drawing layer - also imply another SdrUnoObj, which - // should also result in new ViewContact, and thus in new ViewObjectContacts + ENSURE_OR_THROW( m_pOutputDeviceForWindow, "calling this without /me having an output device should be impossible." ); - impl_switchControlListening_nothrow( false ); + DBG_ASSERT( xNewControl->getModel() == m_aControl.getModel(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: another model at the new control?" ); + // another model should - in the drawing layer - also imply another SdrUnoObj, which + // should also result in new ViewContact, and thus in new ViewObjectContacts - ControlHolder aNewControl( xNewControl ); - aNewControl.setZoom( m_aControl.getZoom() ); - aNewControl.setPosSize( m_aControl.getPosSize() ); - aNewControl.setDesignMode( impl_isControlDesignMode_nothrow() ); + impl_switchControlListening_nothrow( false ); - m_aControl = xNewControl; - m_bControlIsVisible = m_aControl.isVisible(); + ControlHolder aNewControl( xNewControl ); + aNewControl.setZoom( m_aControl.getZoom() ); + aNewControl.setPosSize( m_aControl.getPosSize() ); + aNewControl.setDesignMode( impl_isControlDesignMode_nothrow() ); - impl_switchControlListening_nothrow( true ); - } + m_aControl = xNewControl; + m_bControlIsVisible = m_aControl.isVisible(); + + impl_switchControlListening_nothrow( true ); + + m_pAntiImpl->onControlChangedOrModified( ViewObjectContactOfUnoControl::ImplAccess() ); } //-------------------------------------------------------------------- @@ -1659,8 +1653,8 @@ namespace sdr { namespace contact { // our control already died. // TODO: Is it worth re-creating the control? Finally, this is a pathological situation, it means some instance // disposed the control though it doesn't own it. So, /me thinks we should not bother here. - return drawinglayer::primitive2d::Primitive2DSequence(); - + return drawinglayer::primitive2d::Primitive2DSequence(); + ::drawinglayer::primitive2d::Primitive2DReference xPrimitive( new LazyControlCreationPrimitive2D( m_pImpl ) ); return ::drawinglayer::primitive2d::Primitive2DSequence( &xPrimitive, 1 ); } @@ -1668,14 +1662,7 @@ namespace sdr { namespace contact { //-------------------------------------------------------------------- void ViewObjectContactOfUnoControl::propertyChange() { - // graphical invalidate at all views - ActionChanged(); - - // #i93318# flush Primitive2DSequence to force recreation with updated XControlModel - // since e.g. background color has changed and existing decompositions are possibly no - // longer valid. Unfortunately this is not detected from ControlPrimitive2D::operator== - // since it only has a uno reference to the XControlModel - flushPrimitive2DSequence(); + impl_onControlChangedOrModified(); } //-------------------------------------------------------------------- @@ -1703,6 +1690,19 @@ namespace sdr { namespace contact { } } + //-------------------------------------------------------------------- + void ViewObjectContactOfUnoControl::impl_onControlChangedOrModified() + { + // graphical invalidate at all views + ActionChanged(); + + // #i93318# flush Primitive2DSequence to force recreation with updated XControlModel + // since e.g. background color has changed and existing decompositions are possibly no + // longer valid. Unfortunately this is not detected from ControlPrimitive2D::operator== + // since it only has a uno reference to the XControlModel + flushPrimitive2DSequence(); + } + //==================================================================== //= UnoControlDefaultContact //==================================================================== -- cgit From ec06c94db9cc080aa563a3323e18e850906c4c62 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 08:29:49 +0100 Subject: getZoom: access the peer, not the control, for getting implementation access --- svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index 6c3ce35ab1aa..26b4fe0d5059 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -257,8 +257,8 @@ namespace sdr { namespace contact { // no check whether we're valid, this is the responsibility of the caller // Argh. Why does XView have a setZoom only, but not a getZoom? - Window* pWindow = VCLUnoHelper::GetWindow( m_xControlWindow ); - OSL_ENSURE( pWindow, "ControlHolder::setZoom: no implementation access!" ); + Window* pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() ); + OSL_ENSURE( pWindow, "ControlHolder::getZoom: no implementation access!" ); ::basegfx::B2DVector aZoom( 1, 1 ); if ( pWindow ) -- cgit From e37f884c0e998b48a798285f43eebc514ab5ba8a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 11:59:44 +0100 Subject: step 2 of the FormController UNOization: UNOized all the incoming and outgoing calls, now the interface is completely UNO-based --- svx/source/form/filtnav.cxx | 958 +++++++++++++++++++++---------------------- svx/source/form/fmctrler.cxx | 548 +++++++++++++++++++------ svx/source/form/fmshell.cxx | 19 +- svx/source/form/fmshimp.cxx | 14 +- svx/source/form/fmvwimp.cxx | 6 +- svx/source/inc/filtnav.hxx | 55 +-- svx/source/inc/fmctrler.hxx | 56 +-- 7 files changed, 985 insertions(+), 671 deletions(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 437b0ff4f88a..46044fb58e2a 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -88,15 +88,16 @@ namespace svxform //........................................................................ /** === begin UNO using === **/ - using ::com::sun::star::awt::XTextComponent; using ::com::sun::star::uno::Reference; using ::com::sun::star::lang::XMultiServiceFactory; - using ::com::sun::star::awt::XTextListener; using ::com::sun::star::awt::TextEvent; using ::com::sun::star::container::XIndexAccess; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::form::runtime::XFormController; + using ::com::sun::star::form::runtime::XFilterController; + using ::com::sun::star::form::runtime::XFilterControllerListener; + using ::com::sun::star::form::runtime::FilterEvent; using ::com::sun::star::lang::EventObject; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::form::XForm; @@ -110,6 +111,11 @@ namespace svxform using ::com::sun::star::lang::Locale; using ::com::sun::star::sdb::SQLContext; using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::uno::Sequence; /** === end UNO using === **/ //======================================================================== @@ -153,8 +159,8 @@ TYPEINIT1(FmParentData, FmFilterData); //------------------------------------------------------------------------ FmParentData::~FmParentData() { - for (::std::vector::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (::std::vector::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete (*i); } @@ -180,16 +186,17 @@ Image FmFormItem::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItems, FmParentData); //------------------------------------------------------------------------ -FmFilterItem* FmFilterItems::Find(const Reference< XTextComponent > & _xText) const +FmFilterItem* FmFilterItems::Find( const ::sal_Int32 _nFilterComponentIndex ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::Find" ); - for (::std::vector::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); ++i) + for ( ::std::vector< FmFilterData* >::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); + ++i + ) { - FmFilterItem* pCond = PTR_CAST(FmFilterItem, *i); - DBG_ASSERT(pCond, "Wrong element in container"); - if (_xText == pCond->GetTextComponent()) - return pCond; + FmFilterItem* pCondition = PTR_CAST( FmFilterItem, *i ); + DBG_ASSERT( pCondition, "FmFilterItems::Find: Wrong element in container!" ); + if ( _nFilterComponentIndex == pCondition->GetComponentIndex() ) + return pCondition; } return NULL; } @@ -197,7 +204,6 @@ FmFilterItem* FmFilterItems::Find(const Reference< XTextComponent > & _xText) co //------------------------------------------------------------------------ Image FmFilterItems::GetImage( BmpColorMode _eMode ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::GetImage" ); static Image aImage; static Image aImage_HC; @@ -215,16 +221,15 @@ Image FmFilterItems::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItem, FmFilterData); //------------------------------------------------------------------------ -FmFilterItem::FmFilterItem(const Reference< XMultiServiceFactory >& _rxFactory, - FmFilterItems* pParent, - const ::rtl::OUString& aFieldName, - const ::rtl::OUString& aText, - const Reference< XTextComponent > & _xText) +FmFilterItem::FmFilterItem( const Reference< XMultiServiceFactory >& _rxFactory, + FmFilterItems* pParent, + const ::rtl::OUString& aFieldName, + const ::rtl::OUString& aText, + const sal_Int32 _nComponentIndex ) :FmFilterData(_rxFactory,pParent, aText) ,m_aFieldName(aFieldName) - ,m_xText(_xText) + ,m_nComponentIndex( _nComponentIndex ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::FmFilterItem" ); } //------------------------------------------------------------------------ @@ -273,17 +278,6 @@ public: }; TYPEINIT1( FmFilterInsertedHint, FmFilterHint ); -//======================================================================== -class FmFilterReplacedHint : public FmFilterHint -{ -public: - TYPEINFO(); - FmFilterReplacedHint(FmFilterData* pData) - :FmFilterHint(pData){} - -}; -TYPEINIT1( FmFilterReplacedHint, FmFilterHint ); - //======================================================================== class FmFilterRemovedHint : public FmFilterHint { @@ -327,9 +321,8 @@ TYPEINIT1( FmFilterCurrentChangedHint, SfxHint ); //======================================================================== // class FmFilterAdapter, Listener an den FilterControls //======================================================================== -class FmFilterAdapter : public ::cppu::WeakImplHelper1< XTextListener > +class FmFilterAdapter : public ::cppu::WeakImplHelper1< XFilterControllerListener > { - FmFilterControls m_aFilterControls; FmFilterModel* m_pModel; public: @@ -338,82 +331,36 @@ public: // XEventListener virtual void SAL_CALL disposing(const EventObject& Source) throw( RuntimeException ); -// XTextListener - virtual void SAL_CALL textChanged(const TextEvent& e) throw( RuntimeException ); +// XFilterControllerListener + virtual void SAL_CALL predicateExpressionChanged( const FilterEvent& _Event ) throw (RuntimeException); + virtual void SAL_CALL disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException); + virtual void SAL_CALL disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException); // helpers void dispose() throw( RuntimeException ); - void InsertElements(const Reference< XIndexAccess >& xControllers); - void RemoveElement(const Reference< XTextComponent > & xText); + void InsertElements( const Reference< XIndexAccess >& xControllers ); - Reference< XPropertySet > getField(const Reference< XTextComponent > & xText) const; void setText(sal_Int32 nPos, const FmFilterItem* pFilterItem, const ::rtl::OUString& rText); - void DeleteItemsByText(::std::vector& rItems, const Reference< XTextComponent > & xText); - Reference< XForm > findForm(const Reference< XChild >& xChild); }; //------------------------------------------------------------------------ FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers) :m_pModel(pModel) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::FmFilterAdapter" ); InsertElements(xControllers); - - // listen on all controls as text listener - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->addTextListener(this); } //------------------------------------------------------------------------ void FmFilterAdapter::dispose() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::dispose" ); - // clear the filter control map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); -} - -//------------------------------------------------------------------------------ -// delete all items relate to the control -void FmFilterAdapter::DeleteItemsByText(::std::vector& _rItems, - const Reference< XTextComponent > & xText) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::DeleteItemsByText" ); - for (::std::vector::reverse_iterator i = _rItems.rbegin(); - // link problems with operator == - i.base() != _rItems.rend().base(); i++) - { - FmFilterItems* pFilterItems = PTR_CAST(FmFilterItems, *i); - if (pFilterItems) - { - FmFilterItem* pFilterItem = pFilterItems->Find(xText); - if (pFilterItem) - { - // remove the condition - ::std::vector& rItems = pFilterItems->GetChilds(); - ::std::vector::iterator j = ::std::find(rItems.begin(), rItems.end(), pFilterItem); - if (j != rItems.end()) - m_pModel->Remove(j, pFilterItem); - } - continue; - } - FmFormItem* pFormItem = PTR_CAST(FmFormItem, *i); - if (pFormItem) - DeleteItemsByText(pFormItem->GetChilds(), xText); - } } //------------------------------------------------------------------------ void FmFilterAdapter::InsertElements(const Reference< XIndexAccess >& xControllers) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::InsertElements" ); for (sal_Int32 i = 0, nLen = xControllers->getCount(); i < nLen; ++i) { Reference< XIndexAccess > xElement; @@ -422,74 +369,28 @@ void FmFilterAdapter::InsertElements(const Reference< XIndexAccess >& xControlle // Insert the Elements of the controller InsertElements(xElement); - // store the filter controls - FormController* pController = FormController::getImplementation( xElement ); - DBG_ASSERT( pController, "FmFilterAdapter::InsertElements: no controller!" ); - - const FmFilterControls& rControls = pController->getFilterControls(); - for (FmFilterControls::const_iterator iter = rControls.begin(); iter != rControls.end(); ++iter ) - m_aFilterControls.insert(*iter); + Reference< XFilterController > xController( xElement, UNO_QUERY ); + OSL_ENSURE( xController.is(), "FmFilterAdapter::InsertElements: no XFilterController, cannot sync data!" ); + if ( xController.is() ) + xController->addFilterControllerListener( this ); } } -//------------------------------------------------------------------------------ -void FmFilterAdapter::RemoveElement(const Reference< XTextComponent > & xText) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::RemoveElement" ); - if (xText.is()) - { - // alle Level durchlaufen und eintraege entfernen - if (m_pModel) - DeleteItemsByText(m_pModel->GetChilds(), xText); - - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); - } -} - -//------------------------------------------------------------------------ -Reference< XPropertySet > FmFilterAdapter::getField(const Reference< XTextComponent > & xText) const -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::getField" ); - Reference< XPropertySet > xField; - FmFilterControls::const_iterator i = m_aFilterControls.find(xText); - if (i != m_aFilterControls.end()) - xField = (*i).second; - - return xField; -} - //------------------------------------------------------------------------ void FmFilterAdapter::setText(sal_Int32 nRowPos, const FmFilterItem* pFilterItem, const ::rtl::OUString& rText) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::setText" ); - // set the text for the text component - Reference< XTextComponent > xText(pFilterItem->GetTextComponent()); - xText->setText(rText); - - // get the controller of the text component and its filter rows - FmFormItem* pFormItem = PTR_CAST(FmFormItem,pFilterItem->GetParent()->GetParent()); - FormController* pController = FormController::getImplementation( pFormItem->GetController() ); - DBG_ASSERT( pController, "FmFilterAdapter::setText: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); + FmFormItem* pFormItem = PTR_CAST( FmFormItem, pFilterItem->GetParent()->GetParent() ); - DBG_ASSERT(nRowPos < (sal_Int32)rRows.size(), "wrong row pos"); - // Suchen der aktuellen Row - FmFilterRow& rRow = rRows[nRowPos]; - - // do we have a new filter - if (rText.getLength()) - rRow[xText] = rText; - else + try { - // do we have the control in the row - FmFilterRow::iterator iter = rRow.find(xText); - // erase the entry out of the row - if (iter != rRow.end()) - rRow.erase(iter); + Reference< XFilterController > xController( pFormItem->GetController(), UNO_QUERY_THROW ); + xController->setPredicateExpression( pFilterItem->GetComponentIndex(), nRowPos, rText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } @@ -498,74 +399,154 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos, //------------------------------------------------------------------------ void SAL_CALL FmFilterAdapter::disposing(const EventObject& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::disposing" ); - Reference< XTextComponent > xText(e.Source,UNO_QUERY); - if (xText.is()) - RemoveElement(xText); } -// XTextListener //------------------------------------------------------------------------ -Reference< XForm > FmFilterAdapter::findForm(const Reference< XChild >& xChild) +namespace { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::findForm" ); - Reference< XForm > xForm; - if (xChild.is()) + ::rtl::OUString lcl_getLabelName_nothrow( const Reference< XControl >& _rxControl ) { - xForm = Reference< XForm >(xChild->getParent(), UNO_QUERY); - if (!xForm.is()) - xForm = findForm(Reference< XChild >(xChild->getParent(), UNO_QUERY)); + ::rtl::OUString sLabelName; + try + { + Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); + Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY_THROW ); + sLabelName = getLabelName( xModel ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sLabelName; + } + + Reference< XPropertySet > lcl_getBoundField_nothrow( const Reference< XControl >& _rxControl ) + { + Reference< XPropertySet > xField; + try + { + Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); + Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + xField.set( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xField; } - return xForm; } -// XTextListener +// XFilterControllerListener //------------------------------------------------------------------------ -void FmFilterAdapter::textChanged(const TextEvent& e) throw( RuntimeException ) +void FmFilterAdapter::predicateExpressionChanged( const FilterEvent& _Event ) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::textChanged" ); - // Find the according formitem in the - Reference< XControl > xControl(e.Source, UNO_QUERY); - if (!m_pModel || !xControl.is()) + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + if ( !m_pModel ) return; - Reference< XForm > xForm(findForm(Reference< XChild >(xControl->getModel(), UNO_QUERY))); - if (!xForm.is()) + // the controller which sent the event + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); + + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::predicateExpressionChanged: don't know this form!" ); + if ( !pFormItem ) return; - FmFormItem* pFormItem = m_pModel->Find(m_pModel->m_aChilds, xForm); - if (pFormItem) + const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() ); + + FmFilterItems* pFilter = PTR_CAST( FmFilterItems, pFormItem->GetChildren()[ nActiveTerm ] ); + FmFilterItem* pFilterItem = pFilter->Find( _Event.FilterComponent ); + if ( pFilterItem ) { - Reference< XTextComponent > xText(e.Source, UNO_QUERY); - FmFilterItems* pFilter = PTR_CAST(FmFilterItems, pFormItem->GetChilds()[pFormItem->GetCurrentPosition()]); - FmFilterItem* pFilterItem = pFilter->Find(xText); - if (pFilterItem) + if ( _Event.PredicateExpression.getLength()) { - if (xText->getText().getLength()) - { - pFilterItem->SetText(xText->getText()); - // UI benachrichtigen - FmFilterTextChangedHint aChangeHint(pFilterItem); - m_pModel->Broadcast( aChangeHint ); - } - else - { - // no text anymore so remove the condition - m_pModel->Remove(pFilterItem); - } + pFilterItem->SetText( _Event.PredicateExpression ); + // UI benachrichtigen + FmFilterTextChangedHint aChangeHint(pFilterItem); + m_pModel->Broadcast( aChangeHint ); } else { - // searching the component by field name - ::rtl::OUString aFieldName = getLabelName(Reference< XPropertySet > (Reference< XControl > (xText, UNO_QUERY)->getModel(),UNO_QUERY)); - - pFilterItem = new FmFilterItem(m_pModel->getORB(),pFilter, aFieldName, xText->getText(), xText); - m_pModel->Insert(pFilter->GetChilds().end(), pFilterItem); + // no text anymore so remove the condition + m_pModel->Remove(pFilterItem); } - m_pModel->CheckIntegrity(pFormItem); } + else + { + // searching the component by field name + ::rtl::OUString aFieldName( lcl_getLabelName_nothrow( xFilterController->getFilterComponent( _Event.FilterComponent ) ) ); + + pFilterItem = new FmFilterItem( m_pModel->getORB(), pFilter, aFieldName, _Event.PredicateExpression, _Event.FilterComponent ); + m_pModel->Insert(pFilter->GetChildren().end(), pFilterItem); + } + m_pModel->CheckIntegrity(pFormItem); } +//------------------------------------------------------------------------ +void SAL_CALL FmFilterAdapter::disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); + + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermRemoved: don't know this form!" ); + if ( !pFormItem ) + return; + + ::std::vector< FmFilterData* >& rTermItems = pFormItem->GetChildren(); + const bool bValidIndex = ( _Event.DisjunctiveTerm >= 0 ) && ( _Event.DisjunctiveTerm < rTermItems.size() ); + OSL_ENSURE( bValidIndex, "FmFilterAdapter::disjunctiveTermRemoved: invalid term index!" ); + if ( !bValidIndex ) + return; + + // if the first term was removed, then the to-be first term needs its text updated + if ( _Event.DisjunctiveTerm == 0 ) + { + rTermItems[1]->SetText( String( SVX_RES( RID_STR_FILTER_FILTER_FOR ) ) ); + FmFilterTextChangedHint aChangeHint( rTermItems[1] ); + m_pModel->Broadcast( aChangeHint ); + } + + // finally remove the entry from the model + m_pModel->Remove( rTermItems.begin() + _Event.DisjunctiveTerm ); +} + +//------------------------------------------------------------------------ +void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); + + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermAdded: don't know this form!" ); + if ( !pFormItem ) + return; + + const sal_Int32 nInsertPos = _Event.DisjunctiveTerm; + bool bValidIndex = ( nInsertPos >= 0 ) && ( nInsertPos <= pFormItem->GetChildren().size() ); + if ( !bValidIndex ) + { + OSL_ENSURE( false, "FmFilterAdapter::disjunctiveTermAdded: invalid index!" ); + return; + } + + const ::std::vector< FmFilterData* >::iterator insertPos = pFormItem->GetChildren().begin() + nInsertPos; + + FmFilterItems* pFilterItems = new FmFilterItems( m_pModel->getORB(), pFormItem, String( SVX_RES( RID_STR_FILTER_FILTER_OR ) ) ); + m_pModel->Insert( insertPos, pFilterItems ); +} + + //======================================================================== // class FmFilterModel //======================================================================== @@ -578,7 +559,6 @@ FmFilterModel::FmFilterModel(const Reference< XMultiServiceFactory >& _rxFactory ,m_pAdapter(NULL) ,m_pCurrentItems(NULL) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::FmFilterModel" ); } //------------------------------------------------------------------------ @@ -590,7 +570,6 @@ FmFilterModel::~FmFilterModel() //------------------------------------------------------------------------ void FmFilterModel::Clear() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Clear" ); // notify FilterClearingHint aClearedHint; Broadcast( aClearedHint ); @@ -607,18 +586,17 @@ void FmFilterModel::Clear() m_xController = NULL; m_xControllers = NULL; - for (::std::vector::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (::std::vector::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete (*i); - m_aChilds.clear(); + m_aChildren.clear(); } //------------------------------------------------------------------------ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); - if ((XFormController*) xCurrent.get() == (XFormController*) m_xController.get()) + if ( xCurrent == m_xController ) return; if (!xControllers.is()) @@ -628,7 +606,7 @@ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const } // there is only a new current controller - if ((XIndexAccess*)m_xControllers.get() != (XIndexAccess*)xControllers.get()) + if ( m_xControllers != xControllers ) { Clear(); @@ -651,68 +629,86 @@ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const //------------------------------------------------------------------------ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, FmParentData* pParent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); - sal_Int32 nCount = xControllers->getCount(); - for (sal_Int32 i = 0; i < nCount; i++) + try { - Reference< XFormController > xController; - xControllers->getByIndex(i) >>= xController; - Reference< XPropertySet > xModelAsSet(xController->getModel(), UNO_QUERY); - ::rtl::OUString aName = ::comphelper::getString(xModelAsSet->getPropertyValue(FM_PROP_NAME)); + sal_Int32 nCount = xControllers->getCount(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + Reference< XFormController > xController( xControllers->getByIndex(i), UNO_QUERY_THROW ); - // Insert a new ::com::sun::star::form - FmFormItem* pFormItem = new FmFormItem(m_xORB,pParent, xController, aName); - Insert(pParent->GetChilds().end(), pFormItem); + Reference< XPropertySet > xFormProperties( xController->getModel(), UNO_QUERY_THROW ); + ::rtl::OUString aName; + OSL_VERIFY( xFormProperties->getPropertyValue( FM_PROP_NAME ) >>= aName ); - // And now insert the filters for the form - FormController* pController = FormController::getImplementation( pFormItem->GetController() ); - DBG_ASSERT( pController, "FmFilterAdapter::Update: no controller!" ); + // Insert a new item for the form + FmFormItem* pFormItem = new FmFormItem( m_xORB, pParent, xController, aName ); + Insert( pParent->GetChildren().end(), pFormItem ); - INT32 nPos = pController->getCurrentFilterPosition(); - pFormItem->SetCurrentPosition(nPos); + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); - String aTitle(SVX_RES(RID_STR_FILTER_FILTER_FOR)); - const FmFilterRows& rRows = pController->getFilterRows(); - for (FmFilterRows::const_iterator iter = rRows.begin(); iter != rRows.end(); ++iter) - { - const FmFilterRow& rRow = *iter; - // now add the filter rows - // One Row always exists + // insert the existing filters for the form + String aTitle( SVX_RES( RID_STR_FILTER_FILTER_FOR ) ); - FmFilterItems* pFilterItems = new FmFilterItems(m_xORB,pFormItem, aTitle); - Insert(pFormItem->GetChilds().end(), pFilterItems); - for (FmFilterRow::const_iterator iter1 = rRow.begin(); iter1 != rRow.end(); ++iter1) + Sequence< Sequence< ::rtl::OUString > > aExpressions = xFilterController->getPredicateExpressions(); + for ( const Sequence< ::rtl::OUString >* pConjunctionTerm = aExpressions.getConstArray(); + pConjunctionTerm != aExpressions.getConstArray() + aExpressions.getLength(); + ++pConjunctionTerm + ) { - // insert new and conditons - ::rtl::OUString aFieldName = getLabelName(Reference< XPropertySet > (Reference< XControl > ((*iter1).first, UNO_QUERY)->getModel(),UNO_QUERY)); - FmFilterItem* pANDCondition = new FmFilterItem(m_xORB,pFilterItems, aFieldName, (*iter1).second, (*iter1).first); - Insert(pFilterItems->GetChilds().end(), pANDCondition); + // we always display one row, even if there's no term to be displayed + FmFilterItems* pFilterItems = new FmFilterItems( m_xORB, pFormItem, aTitle ); + Insert( pFormItem->GetChildren().end(), pFilterItems ); + + const Sequence< ::rtl::OUString >& rDisjunction( *pConjunctionTerm ); + for ( const ::rtl::OUString* pDisjunctiveTerm = rDisjunction.getConstArray(); + pDisjunctiveTerm != rDisjunction.getConstArray() + rDisjunction.getLength(); + ++pDisjunctiveTerm + ) + { + if ( pDisjunctiveTerm->getLength() == 0 ) + // no condition for this particular component in this particular conjunction term + continue; + + const sal_Int32 nComponentIndex = pDisjunctiveTerm - rDisjunction.getConstArray(); + + // determine the display name of the control + const Reference< XControl > xFilterControl( xFilterController->getFilterComponent( nComponentIndex ) ); + const ::rtl::OUString sDisplayName( lcl_getLabelName_nothrow( xFilterControl ) ); + + // insert a new entry + FmFilterItem* pANDCondition = new FmFilterItem( m_xORB, pFilterItems, sDisplayName, *pDisjunctiveTerm, nComponentIndex ); + Insert( pFilterItems->GetChildren().end(), pANDCondition ); + } + + // title for the next conditions + aTitle = SVX_RES( RID_STR_FILTER_FILTER_OR ); } - // title for the next conditions - aTitle = SVX_RES(RID_STR_FILTER_FILTER_OR); - } - // now add dependent controllers - Reference< XIndexAccess > xControllerAsIndex(xController, UNO_QUERY); - Update(xControllerAsIndex, pFormItem); + // now add dependent controllers + Reference< XIndexAccess > xControllerAsIndex( xController, UNO_QUERY ); + Update( xControllerAsIndex, pFormItem ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< XFormController > & xController) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector::const_iterator i = rItems.begin(); i != rItems.end(); i++) { FmFormItem* pForm = PTR_CAST(FmFormItem,*i); if (pForm) { - if ((XFormController*)xController.get() == (XFormController*)pForm->GetController().get()) + if ( xController == pForm->GetController() ) return pForm; else { - pForm = Find(pForm->GetChilds(), xController); + pForm = Find(pForm->GetChildren(), xController); if (pForm) return pForm; } @@ -724,7 +720,6 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons //------------------------------------------------------------------------ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, const Reference< XForm >& xForm) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector::const_iterator i = rItems.begin(); i != rItems.end(); i++) { @@ -735,7 +730,7 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons return pForm; else { - pForm = Find(pForm->GetChilds(), xForm); + pForm = Find(pForm->GetChildren(), xForm); if (pForm) return pForm; } @@ -747,56 +742,74 @@ FmFormItem* FmFilterModel::Find(const ::std::vector& rItems, cons //------------------------------------------------------------------------ void FmFilterModel::SetCurrentController(const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetCurrentController" ); - if ((XFormController*) xCurrent.get() == (XFormController*) m_xController.get()) + if ( xCurrent == m_xController ) return; m_xController = xCurrent; - FmFormItem* pItem = Find(m_aChilds, xCurrent); - if (pItem) + FmFormItem* pItem = Find( m_aChildren, xCurrent ); + if ( !pItem ) + return; + + try + { + Reference< XFilterController > xFilterController( m_xController, UNO_QUERY_THROW ); + const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() ); + if ( pItem->GetChildren().size() > (size_t)nActiveTerm ) + { + SetCurrentItems( static_cast< FmFilterItems* >( pItem->GetChildren()[ nActiveTerm ] ) ); + } + } + catch( const Exception& ) { - if ( (USHORT)pItem->GetChilds().size() > pItem->GetCurrentPosition() ) - SetCurrentItems( static_cast< FmFilterItems* >( pItem->GetChilds()[ pItem->GetCurrentPosition() ] ) ); + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------ -void FmFilterModel::AppendFilterItems(FmFormItem* pFormItem) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::AppendFilterItems" ); - DBG_ASSERT(pFormItem, "AppendFilterItems(): no form item present"); +void FmFilterModel::AppendFilterItems( FmFormItem& _rFormItem ) +{ + OSL_ENSURE( false, "FmFilterModel::AppendFilterItems: this should be dead code!" ); + // Before the UNOization of hte FormController, the controller implementation itself + // did not care for keeping at least one empty filter row. With the changes done now, + // it should be impossible to get a FormController to *not* have at least one empty + // filter row. + // Since the task of this method here was to ensure the controller *has* an empty row, + // this means the method should not be needed anymore. However, it's left here for the moment, + // to be on the safe side ... + // If the assertion above fires, then it needs to be investigated at which place the + // FormController failed to fulfill its contract of having at least one empty filter row + // all the time. - FmFilterItems* pFilterItems = new FmFilterItems(m_xORB,pFormItem, ::rtl::OUString(String(SVX_RES(RID_STR_FILTER_FILTER_OR)))); // insert the condition behind the last filter items ::std::vector::reverse_iterator iter; - for (iter = pFormItem->GetChilds().rbegin(); - // link problems with operator == - iter.base() != pFormItem->GetChilds().rend().base(); iter++) + for ( iter = _rFormItem.GetChildren().rbegin(); + iter != _rFormItem.GetChildren().rend(); + ++iter + ) { if ((*iter)->ISA(FmFilterItems)) break; } - sal_Int32 nInsertPos = iter.base() - pFormItem->GetChilds().rend().base(); - ::std::vector::iterator i = pFormItem->GetChilds().begin() + nInsertPos; - - Insert(i, pFilterItems); - // do we need a new row - FormController* pController = FormController::getImplementation( pFormItem->GetController() ); - DBG_ASSERT( pController, "FmFilterAdapter::AppendFilterItems: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); - - // determine the filter position - if (nInsertPos >= (sal_Int32)rRows.size()) - rRows.push_back(FmFilterRow()); + sal_Int32 nInsertPos = iter.base() - _rFormItem.GetChildren().begin(); + // delegate this to the FilterController, it will notify us, which will let us update our model + try + { + Reference< XFilterController > xFilterController( _rFormItem.GetFilterController(), UNO_SET_THROW ); + if ( nInsertPos >= xFilterController->getDisjunctiveTerms() ) + xFilterController->appendEmptyDisjunctiveTerm(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------ void FmFilterModel::Insert(const ::std::vector::iterator& rPos, FmFilterData* pData) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Insert" ); - ::std::vector& rItems = pData->GetParent()->GetChilds(); + ::std::vector& rItems = pData->GetParent()->GetChildren(); sal_Int32 nPos = rPos == rItems.end() ? LIST_APPEND : rPos - rItems.begin(); rItems.insert(rPos, pData); @@ -808,9 +821,8 @@ void FmFilterModel::Insert(const ::std::vector::iterator& rPos, F //------------------------------------------------------------------------ void FmFilterModel::Remove(FmFilterData* pData) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Remove" ); FmParentData* pParent = pData->GetParent(); - ::std::vector& rItems = pParent->GetChilds(); + ::std::vector& rItems = pParent->GetChildren(); // erase the item from the model ::std::vector::iterator i = ::std::find(rItems.begin(), rItems.end(), pData); @@ -820,80 +832,32 @@ void FmFilterModel::Remove(FmFilterData* pData) if (pData->ISA(FmFilterItems)) { FmFormItem* pFormItem = (FmFormItem*)pParent; - FormController* pController = FormController::getImplementation( pFormItem->GetController() ); - DBG_ASSERT( pController, "FmFilterAdapter::Remove: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); - // how many entries do we have - // it's the last row than we just empty it - if (nPos == (sal_Int32)(rRows.size() - 1)) - { - // remove all childs and stay current - ::std::vector& rChilds = ((FmFilterItems*)pData)->GetChilds(); - while (!rChilds.empty()) - { - ::std::vector::iterator j = rChilds.end(); - j--; - - // we stay on the level so delete each item explizit to clean the controls - sal_Int32 nParentPos = j - rChilds.begin(); - // EmptyText removes the filter - FmFilterItem* pFilterItem = PTR_CAST(FmFilterItem, *j); - m_pAdapter->setText(nParentPos, pFilterItem, ::rtl::OUString()); - Remove(j, pFilterItem); - } - } - else // delete the row + try { - // if the row is on the current position we have to away from that position. - // than we can delete it - if (nPos == pFormItem->GetCurrentPosition()) - { - ::std::vector::iterator j = i; - - // give a new current postion - if (nPos < (sal_Int32)(rRows.size() - 1)) - // set it to the next row - ++j; - else - // set it to the previous row - --j; - - // if necessary we have the formItem for the current controller - // than we have to adjust the data displayed in the form - pFormItem->SetCurrentPosition(j - rItems.begin()); - pController->setCurrentFilterPosition(j - rItems.begin()); + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); - // Keep the view consistent and force and new painting - FmFilterTextChangedHint aChangeHint(*j); - Broadcast( aChangeHint ); - } - - // now delete the entry - // before deleting we have to shift the current position of the form if necessary - if (nPos < pFormItem->GetCurrentPosition()) + bool bEmptyLastTerm = ( ( nPos == 0 ) && xFilterController->getDisjunctiveTerms() == 1 ); + if ( bEmptyLastTerm ) { - pFormItem->SetCurrentPosition(pFormItem->GetCurrentPosition() - 1); - pController->decrementCurrentFilterPosition(); - - // is it the first row, than the nex row has to recieve a different name - if (nPos == 0) + // remove all children (by setting an empty predicate expression) + ::std::vector< FmFilterData* >& rChildren = ((FmFilterItems*)pData)->GetChildren(); + while ( !rChildren.empty() ) { - // ensure that the text labels are consistent - rItems[1]->SetText(String(SVX_RES(RID_STR_FILTER_FILTER_FOR))); - FmFilterTextChangedHint aChangeHint(rItems[1]); - Broadcast( aChangeHint ); + ::std::vector< FmFilterData* >::iterator removePos = rChildren.end() - 1; + FmFilterItem* pFilterItem = PTR_CAST( FmFilterItem, *removePos ); + m_pAdapter->setText( nPos, pFilterItem, ::rtl::OUString() ); + Remove( removePos ); } } - - // delete it - rRows.erase(rRows.begin() + nPos); - - // and keep the controller consistent - DBG_ASSERT(rRows.size() != 0, "wrong row size"); - - // and remove it from the model - Remove(i, pData); + else + { + xFilterController->removeDisjunctiveTerm( nPos ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } else // FormItems can not be deleted @@ -906,26 +870,26 @@ void FmFilterModel::Remove(FmFilterData* pData) else { // find the position of the father within his father - ::std::vector& rParentParentItems = pData->GetParent()->GetParent()->GetChilds(); + ::std::vector& rParentParentItems = pData->GetParent()->GetParent()->GetChildren(); ::std::vector::iterator j = ::std::find(rParentParentItems.begin(), rParentParentItems.end(), pFilterItem->GetParent()); DBG_ASSERT(j != rParentParentItems.end(), "FmFilterModel::Remove(): unknown Item"); sal_Int32 nParentPos = j - rParentParentItems.begin(); // EmptyText removes the filter m_pAdapter->setText(nParentPos, pFilterItem, ::rtl::OUString()); - Remove(i, pData); + Remove( i ); } } } //------------------------------------------------------------------------ -void FmFilterModel::Remove(const ::std::vector::iterator& rPos, FmFilterData* pData) +void FmFilterModel::Remove( const ::std::vector::iterator& rPos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Remove" ); - ::std::vector& rItems = pData->GetParent()->GetChilds(); - rItems.erase(rPos); + // remove from parent's child list + FmFilterData* pData = *rPos; + pData->GetParent()->GetChildren().erase( rPos ); - // UI benachrichtigen + // notify the view, this will remove the actual SvLBoxEntry FmFilterRemovedHint aRemoveHint( pData ); Broadcast( aRemoveHint ); @@ -935,46 +899,58 @@ void FmFilterModel::Remove(const ::std::vector::iterator& rPos, F //------------------------------------------------------------------------ sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::ValidateText" ); - // check the input - Reference< XPropertySet > xField(m_pAdapter->getField(pItem->GetTextComponent())); - - OStaticDataAccessTools aStaticTools; - Reference< XConnection > xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet > (m_xController->getModel(), UNO_QUERY))); - Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - - Reference< XNumberFormatter > xFormatter(m_xORB->createInstance(FM_NUMBER_FORMATTER), UNO_QUERY); - xFormatter->attachNumberFormatsSupplier(xFormatSupplier); - - ::rtl::OUString aErr, aTxt(rText); - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(aErr, aTxt, xFormatter, xField); - rErrorMsg = aErr; - rText = aTxt; - if (xParseNode.is()) + FmFormItem* pFormItem = PTR_CAST( FmFormItem, pItem->GetParent()->GetParent() ); + try { - ::rtl::OUString aPreparedText; - Locale aAppLocale = Application::GetSettings().GetUILocale(); - xParseNode->parseNodeToPredicateStr( - aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); - rText = aPreparedText; - return sal_True; + Reference< XFormController > xFormController( pFormItem->GetController() ); + // obtain the connection of the form belonging to the controller + OStaticDataAccessTools aStaticTools; + Reference< XRowSet > xRowSet( xFormController->getModel(), UNO_QUERY_THROW ); + Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( xRowSet ) ); + + // obtain a number formatter for this connection + // TODO: shouldn't this be cached? + Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats( xConnection, sal_True ); + Reference< XNumberFormatter > xFormatter( m_xORB->createInstance( FM_NUMBER_FORMATTER ), UNO_QUERY ); + xFormatter->attachNumberFormatsSupplier( xFormatSupplier ); + + // get the field (database column) which the item is responsible for + Reference< XFilterController > xFilterController( xFormController, UNO_QUERY_THROW ); + Reference< XPropertySet > xField( lcl_getBoundField_nothrow( xFilterController->getFilterComponent( pItem->GetComponentIndex() ) ), UNO_SET_THROW ); + + // parse the given text as filter predicate + ::rtl::OUString aErr, aTxt( rText ); + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( aErr, aTxt, xFormatter, xField ); + rErrorMsg = aErr; + rText = aTxt; + if ( xParseNode.is() ) + { + ::rtl::OUString aPreparedText; + Locale aAppLocale = Application::GetSettings().GetUILocale(); + xParseNode->parseNodeToPredicateStr( + aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); + rText = aPreparedText; + return sal_True; + } } - else - return sal_False; + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return sal_False; } //------------------------------------------------------------------------ void FmFilterModel::Append(FmFilterItems* pItems, FmFilterItem* pFilterItem) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Append" ); - Insert(pItems->GetChilds().end(), pFilterItem); + Insert(pItems->GetChildren().end(), pFilterItem); } //------------------------------------------------------------------------ void FmFilterModel::SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& rText) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetTextForItem" ); - ::std::vector& rItems = pItem->GetParent()->GetParent()->GetChilds(); + ::std::vector& rItems = pItem->GetParent()->GetParent()->GetChildren(); ::std::vector::iterator i = ::std::find(rItems.begin(), rItems.end(), pItem->GetParent()); sal_Int32 nParentPos = i - rItems.begin(); @@ -994,7 +970,6 @@ void FmFilterModel::SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& r //------------------------------------------------------------------------ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetCurrentItems" ); if (m_pCurrentItems == pCurrent) return; @@ -1002,21 +977,26 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) if (pCurrent) { FmFormItem* pFormItem = (FmFormItem*)pCurrent->GetParent(); - ::std::vector& rItems = pFormItem->GetChilds(); + ::std::vector& rItems = pFormItem->GetChildren(); ::std::vector::const_iterator i = ::std::find(rItems.begin(), rItems.end(), pCurrent); if (i != rItems.end()) { // determine the filter position sal_Int32 nPos = i - rItems.begin(); - FormController* pController = FormController::getImplementation( pFormItem->GetController() ); - DBG_ASSERT( pController, "FmFilterAdapter::SetCurrentItems: no controller!" ); - pController->setCurrentFilterPosition(nPos); - pFormItem->SetCurrentPosition(nPos); + try + { + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); + xFilterController->setActiveTerm( nPos ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } - if ((XFormController*)m_xController.get() != (XFormController*)pFormItem->GetController().get()) + if ( m_xController != pFormItem->GetController() ) // calls SetCurrentItems again - SetCurrentController(pFormItem->GetController()); + SetCurrentController( pFormItem->GetController() ); else m_pCurrentItems = pCurrent; } @@ -1035,19 +1015,20 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) //------------------------------------------------------------------------ void FmFilterModel::CheckIntegrity(FmParentData* pItem) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::CheckIntegrity" ); // checks whether for each form there's one free level for input - ::std::vector& rItems = pItem->GetChilds(); + ::std::vector< FmFilterData* >& rItems = pItem->GetChildren(); sal_Bool bAppendLevel = sal_False; - for (::std::vector::iterator i = rItems.begin(); - i != rItems.end(); i++) + for ( ::std::vector::iterator i = rItems.begin(); + i != rItems.end(); + ++i + ) { FmFilterItems* pItems = PTR_CAST(FmFilterItems, *i); if (pItems) { - bAppendLevel = !pItems->GetChilds().empty(); + bAppendLevel = !pItems->GetChildren().empty(); continue; } @@ -1058,8 +1039,14 @@ void FmFilterModel::CheckIntegrity(FmParentData* pItem) continue; } } - if (bAppendLevel) - AppendFilterItems((FmFormItem*)pItem); + + if ( bAppendLevel ) + { + FmFormItem* pFormItem = PTR_CAST( FmFormItem, pItem ); + OSL_ENSURE( pFormItem, "FmFilterModel::CheckIntegrity: no FmFormItem, but a FmFilterItems child?" ); + if ( pFormItem ) + AppendFilterItems( *pFormItem ); + } } //======================================================================== @@ -1081,25 +1068,31 @@ void FmFilterItemsString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nF { FmFilterItems* pRow = (FmFilterItems*)pEntry->GetUserData(); FmFormItem* pForm = (FmFormItem*)pRow->GetParent(); + // current filter is significant painted - if (pForm->GetChilds()[pForm->GetCurrentPosition()] == pRow) + const bool bIsCurrentFilter = pForm->GetChildren()[ pForm->GetFilterController()->getActiveTerm() ] == pRow; + if ( bIsCurrentFilter ) { - Color aLineColor(rDev.GetLineColor()); - Rectangle aRect(rPos, GetSize(&rDev, pEntry )); - Point aFirst(rPos.X(), aRect.Bottom() - 6); - Point aSecond(aFirst.X() + 2, aFirst.Y() + 3); + rDev.Push( PUSH_LINECOLOR ); + + rDev.SetLineColor( rDev.GetTextColor() ); + + Rectangle aRect( rPos, GetSize( &rDev, pEntry ) ); + Point aFirst( rPos.X(), aRect.Bottom() - 6 ); + Point aSecond(aFirst .X() + 2, aFirst.Y() + 3 ); - rDev.SetLineColor(rDev.GetTextColor()); - rDev.DrawLine(aFirst, aSecond); + rDev.DrawLine( aFirst, aSecond ); aFirst = aSecond; aFirst.X() += 1; aSecond.X() += 6; aSecond.Y() -= 5; - rDev.DrawLine(aFirst, aSecond); - rDev.SetLineColor( aLineColor ); + rDev.DrawLine( aFirst, aSecond ); + + rDev.Pop(); } + rDev.DrawText( Point(rPos.X() + nxDBmp, rPos.Y()), GetText() ); } @@ -1180,7 +1173,6 @@ FmFilterNavigator::FmFilterNavigator( Window* pParent ) ,m_aTimerCounter( 0 ) ,m_aDropActionType( DA_SCROLLUP ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::FmFilterNavigator" ); SetHelpId( HID_FILTER_NAVIGATOR ); { @@ -1223,14 +1215,12 @@ FmFilterNavigator::~FmFilterNavigator() //------------------------------------------------------------------------ void FmFilterNavigator::Clear() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Clear" ); m_pModel->Clear(); } //------------------------------------------------------------------------ void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::UpdateContent" ); if (xCurrent == m_pModel->GetCurrentController()) return; @@ -1258,7 +1248,6 @@ void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControl //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::EditingEntry" ); m_pEditingCurrently = pEntry; if (!SvTreeListBox::EditingEntry( pEntry, rSelection )) return sal_False; @@ -1269,7 +1258,6 @@ sal_Bool FmFilterNavigator::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelec //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::EditedEntry" ); DBG_ASSERT(pEntry == m_pEditingCurrently, "FmFilterNavigator::EditedEntry: suspicious entry!"); m_pEditingCurrently = NULL; @@ -1361,7 +1349,6 @@ IMPL_LINK( FmFilterNavigator, OnDropActionTimer, void*, EMPTYARG ) //------------------------------------------------------------------------ sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::AcceptDrop" ); Point aDropPos = rEvt.maPosPixel; // kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen) @@ -1389,7 +1376,7 @@ sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt ) bNeedTrigger = sal_True; } else - { // auf einem Entry mit Childs, der nicht aufgeklappt ist ? + { // is it an entry whith children, and not yet expanded? SvLBoxEntry* pDropppedOn = GetEntry(aDropPos); if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn)) { @@ -1468,7 +1455,6 @@ namespace //------------------------------------------------------------------------ sal_Int8 FmFilterNavigator::ExecuteDrop( const ExecuteDropEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::ExecuteDrop" ); // ware schlecht, wenn nach dem Droppen noch gescrollt wird ... if (m_aDropActionTimer.IsActive()) m_aDropActionTimer.Stop(); @@ -1502,7 +1488,6 @@ void FmFilterNavigator::InitEntry(SvLBoxEntry* pEntry, const Image& rImg2, SvLBoxButtonKind eButtonKind) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::InitEntry" ); SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); SvLBoxString* pString = NULL; @@ -1518,7 +1503,6 @@ void FmFilterNavigator::InitEntry(SvLBoxEntry* pEntry, //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Select" ); if (bSelect == IsSelected(pEntry)) // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;) return sal_True; @@ -1554,7 +1538,6 @@ sal_Bool FmFilterNavigator::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) //------------------------------------------------------------------------ void FmFilterNavigator::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Notify" ); if (rHint.ISA(FmFilterInsertedHint)) { FmFilterInsertedHint* pHint = (FmFilterInsertedHint*)&rHint; @@ -1588,7 +1571,6 @@ void FmFilterNavigator::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) //------------------------------------------------------------------------ SvLBoxEntry* FmFilterNavigator::FindEntry(const FmFilterData* pItem) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::FindEntry" ); SvLBoxEntry* pEntry = NULL; if (pItem) { @@ -1605,7 +1587,6 @@ SvLBoxEntry* FmFilterNavigator::FindEntry(const FmFilterData* pItem) const //------------------------------------------------------------------------ void FmFilterNavigator::Insert(FmFilterData* pItem, sal_Int32 nPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Insert" ); const FmParentData* pParent = pItem->GetParent() ? pItem->GetParent() : GetFilterModel(); // insert the item @@ -1621,7 +1602,6 @@ void FmFilterNavigator::Insert(FmFilterData* pItem, sal_Int32 nPos) //------------------------------------------------------------------------ void FmFilterNavigator::Remove(FmFilterData* pItem) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Remove" ); // der Entry zu den Daten SvLBoxEntry* pEntry = FindEntry(pItem); @@ -1635,7 +1615,6 @@ void FmFilterNavigator::Remove(FmFilterData* pItem) // ----------------------------------------------------------------------------- FmFormItem* FmFilterNavigator::getSelectedFilterItems(::std::vector& _rItemList) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getSelectedFilterItems" ); // be sure that the data is only used within only one form! FmFormItem* pFirstItem = NULL; @@ -1670,35 +1649,35 @@ FmFormItem* FmFilterNavigator::getSelectedFilterItems(::std::vector& _rFilterList,FmFilterItems* _pTargetItems,sal_Bool _bCopy) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::insertFilterItem" ); ::std::vector::const_iterator aEnd = _rFilterList.end(); - for (::std::vector::const_iterator i = _rFilterList.begin(); i != aEnd; ++i) + for ( ::std::vector< FmFilterItem* >::const_iterator i = _rFilterList.begin(); + i != aEnd; + ++i + ) { - if ((*i)->GetParent() == _pTargetItems) + FmFilterItem* pLookupItem( *i ); + if ( pLookupItem->GetParent() == _pTargetItems ) continue; - else + + FmFilterItem* pFilterItem = _pTargetItems->Find( pLookupItem->GetComponentIndex() ); + String aText = pLookupItem->GetText(); + if ( !pFilterItem ) { - FmFilterItem* pFilterItem = _pTargetItems->Find((*i)->GetTextComponent()); - String aText = (*i)->GetText(); - if ( !pFilterItem ) - { - pFilterItem = new FmFilterItem(m_pModel->getORB(),_pTargetItems, (*i)->GetFieldName(), aText, (*i)->GetTextComponent()); - m_pModel->Append(_pTargetItems, pFilterItem); - } + pFilterItem = new FmFilterItem( m_pModel->getORB(), _pTargetItems, pLookupItem->GetFieldName(), aText, pLookupItem->GetComponentIndex() ); + m_pModel->Append( _pTargetItems, pFilterItem ); + } - if ( !_bCopy ) - m_pModel->Remove(*i); + if ( !_bCopy ) + m_pModel->Remove( pLookupItem ); - // now set the text for the new dragged item - m_pModel->SetTextForItem(pFilterItem, aText); - } + // now set the text for the new dragged item + m_pModel->SetTextForItem( pFilterItem, aText ); } - m_pModel->CheckIntegrity((FmFormItem*)_pTargetItems->GetParent()); + m_pModel->CheckIntegrity( (FmFormItem*)_pTargetItems->GetParent() ); } //------------------------------------------------------------------------------ void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::StartDrag" ); EndSelection(); // be sure that the data is only used within a only one form! @@ -1716,7 +1695,6 @@ void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPi //------------------------------------------------------------------------------ void FmFilterNavigator::Command( const CommandEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Command" ); sal_Bool bHandled = sal_False; switch (rEvt.GetCommand()) { @@ -1761,8 +1739,8 @@ void FmFilterNavigator::Command( const CommandEvent& rEvt ) { // don't delete the only empty row of a form FmFilterItems* pFilterItems = PTR_CAST(FmFilterItems, aSelectList[0]); - if (pFilterItems && pFilterItems->GetChilds().empty() - && pFilterItems->GetParent()->GetChilds().size() == 1) + if (pFilterItems && pFilterItems->GetChildren().empty() + && pFilterItems->GetParent()->GetChildren().size() == 1) aSelectList.clear(); } @@ -1819,7 +1797,6 @@ void FmFilterNavigator::Command( const CommandEvent& rEvt ) // ----------------------------------------------------------------------------- SvLBoxEntry* FmFilterNavigator::getNextEntry(SvLBoxEntry* _pStartWith) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getNextEntry" ); SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : LastSelected(); pEntry = Next(pEntry); // we need the next filter entry @@ -1830,7 +1807,6 @@ SvLBoxEntry* FmFilterNavigator::getNextEntry(SvLBoxEntry* _pStartWith) // ----------------------------------------------------------------------------- SvLBoxEntry* FmFilterNavigator::getPrevEntry(SvLBoxEntry* _pStartWith) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getPrevEntry" ); SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : FirstSelected(); pEntry = Prev(pEntry); // check if the previous entry is a filter, if so get the next prev @@ -1846,81 +1822,91 @@ SvLBoxEntry* FmFilterNavigator::getPrevEntry(SvLBoxEntry* _pStartWith) //------------------------------------------------------------------------ void FmFilterNavigator::KeyInput(const KeyEvent& rKEvt) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::KeyInput" ); const KeyCode& rKeyCode = rKEvt.GetKeyCode(); - if ( rKeyCode.IsMod1() - && rKeyCode.IsMod2() - && !rKeyCode.IsShift() - && ( rKeyCode.GetCode() == KEY_UP || rKeyCode.GetCode() == KEY_DOWN ) - ) + + switch ( rKeyCode.GetCode() ) + { + case KEY_UP: + case KEY_DOWN: { + if ( !rKeyCode.IsMod1() || !rKeyCode.IsMod2() || rKeyCode.IsShift() ) + break; + ::std::vector aItemList; - if ( getSelectedFilterItems(aItemList) ) - { - ::std::mem_fun1_t aGetEntry = ::std::mem_fun(&FmFilterNavigator::getNextEntry); - if ( rKeyCode.GetCode() == KEY_UP ) - aGetEntry = ::std::mem_fun(&FmFilterNavigator::getPrevEntry); + if ( !getSelectedFilterItems( aItemList ) ) + break; + + ::std::mem_fun1_t getter = ::std::mem_fun(&FmFilterNavigator::getNextEntry); + if ( rKeyCode.GetCode() == KEY_UP ) + getter = ::std::mem_fun(&FmFilterNavigator::getPrevEntry); - SvLBoxEntry* pTarget = aGetEntry(this,NULL); + SvLBoxEntry* pTarget = getter( this, NULL ); + if ( !pTarget ) + break; + + FmFilterItems* pTargetItems = getTargetItems( pTarget ); + if ( !pTargetItems ) + break; - if ( pTarget ) + ::std::vector::const_iterator aEnd = aItemList.end(); + sal_Bool bNextTargetItem = sal_True; + while ( bNextTargetItem ) + { + ::std::vector::const_iterator i = aItemList.begin(); + for (; i != aEnd; ++i) { - FmFilterItems* pTargetItems = getTargetItems(pTarget); - if ( pTargetItems ) + if ( (*i)->GetParent() == pTargetItems ) { - ::std::vector::const_iterator aEnd = aItemList.end(); - sal_Bool bNextTargetItem = sal_True; - while ( bNextTargetItem ) - { - ::std::vector::const_iterator i = aItemList.begin(); - for (; i != aEnd; ++i) - { - if ( (*i)->GetParent() == pTargetItems ) - { - pTarget = aGetEntry(this,pTarget); - if ( !pTarget ) - return; - pTargetItems = getTargetItems(pTarget); - break; - } - else - { - FmFilterItem* pFilterItem = pTargetItems->Find((*i)->GetTextComponent()); - // we found the text component so jump above - if ( pFilterItem ) - { - pTarget = aGetEntry(this,pTarget); - if ( !pTarget ) - return; - pTargetItems = getTargetItems(pTarget); - break; - } - } - } - bNextTargetItem = i != aEnd && pTargetItems; - } - if ( pTargetItems ) - { - insertFilterItem(aItemList,pTargetItems); + pTarget = getter(this,pTarget); + if ( !pTarget ) return; + pTargetItems = getTargetItems( pTarget ); + break; + } + else + { + FmFilterItem* pFilterItem = pTargetItems->Find( (*i)->GetComponentIndex() ); + // we found the text component so jump above + if ( pFilterItem ) + { + pTarget = getter( this, pTarget ); + if ( !pTarget ) + return; + + pTargetItems = getTargetItems( pTarget ); + break; } } } + bNextTargetItem = i != aEnd && pTargetItems; + } + + if ( pTargetItems ) + { + insertFilterItem( aItemList, pTargetItems ); + return; } } - else if (rKeyCode.GetCode() == KEY_DELETE && !rKeyCode.GetModifier()) + break; + + case KEY_DELETE: { - if (!IsSelected(First()) || GetEntryCount() > 1) + if ( rKeyCode.GetModifier() ) + break; + + if ( !IsSelected( First() ) || GetEntryCount() > 1 ) DeleteSelection(); return; } + break; + } + SvTreeListBox::KeyInput(rKEvt); } //------------------------------------------------------------------------------ void FmFilterNavigator::DeleteSelection() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::DeleteSelection" ); // to avoid the deletion of an entry twice (e.g. deletion of a parent and afterward // the deletion of it's child, i have to shrink the selecton list ::std::vector aEntryList; @@ -1945,6 +1931,7 @@ void FmFilterNavigator::DeleteSelection() i.base() != aEntryList.rend().base(); i++) { m_pModel->Remove((FmFilterData*)(*i)->GetUserData()); + Update(); } // now check if we need to insert new items @@ -1960,7 +1947,6 @@ FmFilterNavigatorWin::FmFilterNavigatorWin( SfxBindings* _pBindings, SfxChildWin :SfxDockingWindow( _pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) ) ,SfxControllerItem( SID_FM_FILTER_NAVIGATOR_CONTROL, *_pBindings ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::FmFilterNavigatorWin" ); SetHelpId( HID_FILTER_NAVIGATOR_WIN ); m_pNavigator = new FmFilterNavigator( this ); @@ -1978,7 +1964,6 @@ FmFilterNavigatorWin::~FmFilterNavigatorWin() //----------------------------------------------------------------------- void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::UpdateContent" ); if (!pFormShell) m_pNavigator->UpdateContent( NULL, NULL ); else @@ -2003,7 +1988,6 @@ void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell) //----------------------------------------------------------------------- void FmFilterNavigatorWin::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::StateChanged" ); if( !pState || SID_FM_FILTER_NAVIGATOR_CONTROL != nSID ) return; @@ -2019,7 +2003,6 @@ void FmFilterNavigatorWin::StateChanged( sal_uInt16 nSID, SfxItemState eState, c //----------------------------------------------------------------------- sal_Bool FmFilterNavigatorWin::Close() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::Close" ); if ( m_pNavigator && m_pNavigator->IsEditingActive() ) m_pNavigator->EndEditing(); @@ -2034,7 +2017,6 @@ sal_Bool FmFilterNavigatorWin::Close() //----------------------------------------------------------------------- void FmFilterNavigatorWin::FillInfo( SfxChildWinInfo& rInfo ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::FillInfo" ); SfxDockingWindow::FillInfo( rInfo ); rInfo.bVisible = sal_False; } @@ -2042,7 +2024,6 @@ void FmFilterNavigatorWin::FillInfo( SfxChildWinInfo& rInfo ) const //----------------------------------------------------------------------- Size FmFilterNavigatorWin::CalcDockingSize( SfxChildAlignment eAlign ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::CalcDockingSize" ); if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) ) return Size(); @@ -2052,7 +2033,6 @@ Size FmFilterNavigatorWin::CalcDockingSize( SfxChildAlignment eAlign ) //----------------------------------------------------------------------- SfxChildAlignment FmFilterNavigatorWin::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::CheckAlignment" ); switch (eAlign) { case SFX_ALIGN_LEFT: @@ -2069,7 +2049,6 @@ SfxChildAlignment FmFilterNavigatorWin::CheckAlignment( SfxChildAlignment eActAl //------------------------------------------------------------------------ void FmFilterNavigatorWin::Resize() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::Resize" ); SfxDockingWindow::Resize(); Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT ); @@ -2085,7 +2064,6 @@ void FmFilterNavigatorWin::Resize() // ----------------------------------------------------------------------------- void FmFilterNavigatorWin::GetFocus() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::GetFocus" ); // oj #97405# if ( m_pNavigator ) m_pNavigator->GrabFocus(); diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index 9f314bb4af82..af1158f1b3cb 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -155,6 +155,8 @@ namespace svxform using ::com::sun::star::container::XEnumeration; using ::com::sun::star::form::XFormComponent; using ::com::sun::star::form::runtime::XFormOperations; + using ::com::sun::star::form::runtime::FilterEvent; + using ::com::sun::star::form::runtime::XFilterControllerListener; using ::com::sun::star::awt::XControlContainer; using ::com::sun::star::container::XIdentifierReplace; using ::com::sun::star::lang::WrappedTargetException; @@ -559,6 +561,7 @@ FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ,m_aDeleteListeners(m_aMutex) ,m_aRowSetApproveListeners(m_aMutex) ,m_aParameterListeners(m_aMutex) + ,m_aFilterListeners(m_aMutex) ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) ,m_aControllerFeatures( _rxORB, this ) ,m_aMode( DATA_MODE ) @@ -778,42 +781,34 @@ Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) return aServices; } -//------------------------------------------------------------------------------ -void FormController::setCurrentFilterPosition( sal_Int32 nPos ) -{ - DBG_ASSERT(nPos < (sal_Int32)m_aFilters.size(), "Invalid Position"); - - if (nPos != m_nCurrentFilterPosition) - { - m_nCurrentFilterPosition = nPos; - - // reset the text for all controls - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->setText(rtl::OUString()); - - if ( nPos != -1 ) - { - impl_setTextOnAllFilter_throw(); - } - } -} // ----------------------------------------------------------------------------- void FormController::impl_setTextOnAllFilter_throw() { + // reset the text for all controls + for ( FmFilterControls::const_iterator iter = m_aFilterControls.begin(); + iter != m_aFilterControls.end(); + ++iter + ) + iter->first->setText( ::rtl::OUString() ); + + if ( m_nCurrentFilterPosition < 0 ) + return; + // set the text for all filters - OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FormController::setCurrentFilterPosition: m_nCurrentFilterPosition too big" ); + OSL_ENSURE( m_aFilters.size() > (size_t)m_nCurrentFilterPosition, + "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" ); - if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + if ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) { - FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; - for (FmFilterRow::const_iterator iter2 = rRow.begin(); - iter2 != rRow.end(); iter2++) + FmFilterRow& rRow = m_aFilters[ m_nCurrentFilterPosition ]; + for ( FmFilterRow::const_iterator iter2 = rRow.begin(); + iter2 != rRow.end(); + ++iter2 + ) { - (*iter2).first->setText((*iter2).second); + iter2->first->setText( iter2->second ); } - } // if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + } } // OPropertySetHelper //------------------------------------------------------------------------------ @@ -853,7 +848,7 @@ void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() ); - // now add the filter rows + // now add the filter rows for ( FmFilterRows::const_iterator row = m_aFilters.begin(); row != m_aFilters.end(); ++row ) { const FmFilterRow& rRow = *row; @@ -933,11 +928,197 @@ void FormController::fillProperties( return *getArrayHelper(); } +// XFilterController +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.addInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.removeInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilterControls.size(); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilters.size(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + FmFilterControls::const_iterator componentPos( m_aFilterControls.begin() ); + while ( _Component > 0 ) + ++componentPos, --_Component; + // TODO: make m_aFilterControls a vector + + Reference< XTextComponent > xText( componentPos->first ); + xText->setText( _PredicateExpression ); + + FmFilterRow& rFilterRow = m_aFilters[ _Term ]; + if ( _PredicateExpression.getLength() ) + rFilterRow[ xText ] = _PredicateExpression; + else + rFilterRow.erase( xText ); +} + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + FmFilterControls::const_iterator componentPos( m_aFilterControls.begin() ); + while ( _Component > 0 ) + ++componentPos, --_Component; + + return Reference< XControl >( componentPos->first, UNO_QUERY ); +} + +//------------------------------------------------------------------------------ +Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilters.size() ); + sal_Int32 termIndex = 0; + for ( FmFilterRows::const_iterator row = m_aFilters.begin(); + row != m_aFilters.end(); + ++row, ++termIndex + ) + { + const FmFilterRow& rRow( *row ); + + Sequence< ::rtl::OUString > aConjunction( m_aFilterControls.size() ); + sal_Int32 componentIndex = 0; + for ( FmFilterControls::const_iterator comp = m_aFilterControls.begin(); + comp != m_aFilterControls.end(); + ++comp, ++componentIndex + ) + { + FmFilterRow::const_iterator predicate = rRow.find( comp->first ); + if ( predicate != rRow.end() ) + aConjunction[ componentIndex ] = predicate->second; + } + + aExpressions[ termIndex ] = aConjunction; + } + + return aExpressions; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + if ( ( _Term == 0 ) && ( m_aFilters.size() == 1 ) ) + // not allowed to remove the one and only last term + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + // if the to-be-deleted row is our current row, we need to shift + sal_Int32 nNewFilterPosition( m_nCurrentFilterPosition ); + if ( _Term == m_nCurrentFilterPosition ) + { + if ( m_nCurrentFilterPosition < sal_Int32( m_aFilters.size() - 1 ) ) + ++m_nCurrentFilterPosition; + else + --m_nCurrentFilterPosition; + } + + FmFilterRows::iterator pos = m_aFilters.begin() + _Term; + m_aFilters.erase( pos ); + + // adjust m_nCurrentFilterPosition if the removed row preceeded it + if ( _Term < m_nCurrentFilterPosition ) + --m_nCurrentFilterPosition; + + // update the texts in the filter controls + impl_setTextOnAllFilter_throw(); + + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = _Term; + aGuard.clear(); + // <-- SYNCHRONIZED + + // ensure there's an empty row (perhaps we just removed the last empty row) + implts_ensureEmptyFilterRow_nothrow(); + + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + impl_appendEmptyFilterRow( aGuard ); + // <-- SYNCHRONIZED +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_nCurrentFilterPosition; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + if ( _ActiveTerm == getActiveTerm() ) + return; + + m_nCurrentFilterPosition = _ActiveTerm; + impl_setTextOnAllFilter_throw(); +} + // XElementAccess //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException ) { -::osl::MutexGuard aGuard( m_aMutex ); + ::osl::MutexGuard aGuard( m_aMutex ); return !m_aChilds.empty(); } @@ -972,31 +1153,7 @@ Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBounds Index >= (sal_Int32)m_aChilds.size()) throw IndexOutOfBoundsException(); - return makeAny(m_aChilds[Index]); - // , ::getCppuType((const XFormController*)0)); -} - -//----------------------------------------------------------------------------- -void FormController::addChild( const Reference< XFormController >& _rxChildController ) -{ - m_aChilds.push_back( _rxChildController ); - _rxChildController->setParent( *this ); - - Reference< XFormComponent > xForm( _rxChildController->getModel(), UNO_QUERY); - - // search the position of the model within the form - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ( xForm.get() == xTemp.get() ) - { - Reference< XInterface > xIfc( _rxChildController, UNO_QUERY ); - m_xModelAsManager->attach( nPos, xIfc, makeAny( _rxChildController) ); - break; - } - } + return makeAny( m_aChilds[ Index ] ); } // EventListener @@ -1060,6 +1217,7 @@ void FormController::disposing(void) m_aDeleteListeners.disposeAndClear(aEvt); m_aRowSetApproveListeners.disposeAndClear(aEvt); m_aParameterListeners.disposeAndClear(aEvt); + m_aFilterListeners.disposeAndClear(aEvt); removeBoundFieldListener(); stopFiltering(); @@ -1340,6 +1498,8 @@ IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG) //------------------------------------------------------------------------------ void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException ) { + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if (m_bFiltering) { @@ -1347,25 +1507,44 @@ void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeExce ::rtl::OUString aText = xText->getText(); // Suchen der aktuellen Row - OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FormController::textChanged: m_nCurrentFilterPosition too big" ); - - if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilters.size() ) || ( m_nCurrentFilterPosition < 0 ) ) { - FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; + OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" ); + return; + } - // do we have a new filter - if (aText.getLength()) - rRow[xText] = aText; - else - { - // do we have the control in the row - FmFilterRow::iterator iter = rRow.find(xText); - // erase the entry out of the row - if (iter != rRow.end()) - rRow.erase(iter); - } + FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; + + // do we have a new filter + if (aText.getLength()) + rRow[xText] = aText; + else + { + // do we have the control in the row + FmFilterRow::iterator iter = rRow.find(xText); + // erase the entry out of the row + if (iter != rRow.end()) + rRow.erase(iter); } + + // multiplex the event to our FilterControllerListeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.FilterComponent = 0; + aEvent.DisjunctiveTerm = getActiveTerm(); + FmFilterControls::const_iterator lookup( m_aFilterControls.begin() ); + while ( lookup != m_aFilterControls.end() && ( lookup->first != xText ) ) + ++lookup, ++aEvent.FilterComponent; + aEvent.PredicateExpression = aText; + + aGuard.clear(); + // <-- SYNCHRONIZED + + // ensure there's an empty row (perhaps we just filled the previously empty row) + implts_ensureEmptyFilterRow_nothrow(); + + // notify the changed filter expression + m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent ); } else impl_onModify(); @@ -1383,14 +1562,16 @@ void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) thro //------------------------------------------------------------------------------ void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aModifyListeners.addInterface( l ); } //------------------------------------------------------------------------------ void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aModifyListeners.removeInterface( l ); } @@ -1422,6 +1603,13 @@ void FormController::modified( const EventObject& _rEvent ) throw( RuntimeExcept impl_onModify(); } +//------------------------------------------------------------------------------ +void FormController::impl_checkDisposed_throw() const +{ + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) ); +} + //------------------------------------------------------------------------------ void FormController::impl_onModify() { @@ -1437,6 +1625,43 @@ void FormController::impl_onModify() m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt ); } +//------------------------------------------------------------------------------ +void FormController::implts_ensureEmptyFilterRow_nothrow() +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + // do we have an empty row? + for ( FmFilterRows::const_iterator pos = m_aFilters.begin(); + pos != m_aFilters.end(); + ++pos + ) + { + if ( pos->empty() ) + // all fine, found one + return; + } + + impl_appendEmptyFilterRow( aGuard ); + // <-- SYNCHRONIZED +} + +//------------------------------------------------------------------------------ +void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) +{ + // SYNCHRONIZED --> + m_aFilters.push_back( FmFilterRow() ); + + // notify the listeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = (sal_Int32)m_aFilters.size() - 1; + _rClearBeforeNotify.clear(); + // <-- SYNCHRONIZED + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent ); +} + //------------------------------------------------------------------------------ sal_Bool FormController::determineLockState() const { @@ -1461,7 +1686,7 @@ void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) // SYNCHRONIZED --> ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); m_pControlBorderManager->focusGained( e.Source ); @@ -1658,8 +1883,9 @@ void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSou //-------------------------------------------------------------------- void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !"); try @@ -1763,7 +1989,9 @@ void FormController::setModel(const Reference< XTabControllerModel > & Model) th //------------------------------------------------------------------------------ Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XTabControllerModel > (); @@ -1918,7 +2146,8 @@ void FormController::setContainer(const Reference< XControlContainer > & xContai Reference< XControlContainer > FormController::getContainer() throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XControlContainer > (); @@ -1928,8 +2157,9 @@ Reference< XControlContainer > FormController::getContainer() throw( RuntimeExc //------------------------------------------------------------------------------ Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + if (!m_bControlsSorted) { Reference< XTabControllerModel > xModel = getModel(); @@ -1967,8 +2197,9 @@ Sequence< Reference< XControl > > FormController::getControls(void) throw( Runti //------------------------------------------------------------------------------ void FormController::autoTabOrder() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->autoTabOrder(); @@ -1977,8 +2208,9 @@ void FormController::autoTabOrder() throw( RuntimeException ) //------------------------------------------------------------------------------ void FormController::activateTabOrder() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateTabOrder(); @@ -2457,15 +2689,18 @@ IMPL_LINK(FormController, OnLoad, void*, EMPTYARG) //------------------------------------------------------------------------------ void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + updateAllDispatchers(); } //------------------------------------------------------------------------------ void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + // do the same like in unloading // just one exception toggle the auto values m_aToggleEvent.CancelPendingCall(); @@ -2475,22 +2710,26 @@ void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeExce //------------------------------------------------------------------------------ void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + loaded(aEvent); } //------------------------------------------------------------------------------ void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + unload(); } //------------------------------------------------------------------------------ void FormController::unload() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aLoadEvent.CancelPendingCall(); @@ -2598,7 +2837,9 @@ void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm //------------------------------------------------------------------------------ void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + // toggle the locking ? if (m_bLocked != determineLockState()) { @@ -2631,13 +2872,13 @@ void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeE //------------------------------------------------------------------------------ void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - Reference< XControl > xControl; - evt.Element >>= xControl; - if (!xControl.is()) + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Reference< XControl > xControl( evt.Element, UNO_QUERY ); + if ( !xControl.is() ) return; - ::osl::MutexGuard aGuard( m_aMutex ); Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); if (xModel.is() && m_xModelAsIndex == xModel->getParent()) { @@ -2692,8 +2933,8 @@ void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( //------------------------------------------------------------------------------ void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); Reference< XControl > xControl; evt.Element >>= xControl; @@ -2738,8 +2979,9 @@ Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & //------------------------------------------------------------------------------ void FormController::activateFirst() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateFirst(); @@ -2748,8 +2990,9 @@ void FormController::activateFirst() throw( RuntimeException ) //------------------------------------------------------------------------------ void FormController::activateLast() throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateLast(); @@ -2760,8 +3003,7 @@ void FormController::activateLast() throw( RuntimeException ) Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *this ); + impl_checkDisposed_throw(); return m_aControllerFeatures->getFormOperations(); } @@ -2770,6 +3012,7 @@ Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); return m_xCurrentControl; } @@ -2777,23 +3020,60 @@ Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( Run void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); m_aActivateListeners.addInterface(l); } //------------------------------------------------------------------------------ void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); m_aActivateListeners.removeInterface(l); } +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( !_ChildController.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + // the parent of our (to-be-)child must be our own model + Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY ); + if ( !xFormOfChild.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + if ( xFormOfChild->getParent() != m_xModelAsIndex ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + m_aChilds.push_back( _ChildController ); + _ChildController->setParent( *this ); + + // search the position of the model within the form + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if ( xFormOfChild == xTemp ) + { + Reference< XInterface > xIfc( _ChildController, UNO_QUERY ); + m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) ); + break; + } + } +} + //------------------------------------------------------------------------------ Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *this ); + impl_checkDisposed_throw(); return m_xContext; } @@ -2801,8 +3081,7 @@ Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *this ); + impl_checkDisposed_throw(); m_xContext = _context; } @@ -2810,8 +3089,7 @@ void SAL_CALL FormController::setContext( const Reference< XFormControllerContex Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *this ); + impl_checkDisposed_throw(); return m_xInteractionHandler; } @@ -2819,8 +3097,7 @@ Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler( void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *this ); + impl_checkDisposed_throw(); m_xInteractionHandler = _interactionHandler; } @@ -3239,8 +3516,8 @@ void FormController::stopFiltering() void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if (!supportsMode(Mode)) throw NoSupportException(); @@ -3266,15 +3543,18 @@ void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExcept //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException ) { -::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_aMode; } //------------------------------------------------------------------------------ Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + static Sequence< ::rtl::OUString > aModes; if (!aModes.getLength()) { @@ -3289,7 +3569,9 @@ Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) thr //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + Sequence< ::rtl::OUString > aModes(getSupportedModes()); const ::rtl::OUString* pModes = aModes.getConstArray(); for (sal_Int32 i = aModes.getLength(); i > 0; ) @@ -3452,8 +3734,8 @@ namespace sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) { ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); sal_Bool bValid = sal_True; if (aIter.hasMoreElements()) @@ -3540,7 +3822,8 @@ sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3556,7 +3839,8 @@ sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) th sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3573,7 +3857,8 @@ sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aRowSetApproveListeners.addInterface(_rxListener); } @@ -3581,7 +3866,8 @@ void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetA void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aRowSetApproveListeners.removeInterface(_rxListener); } @@ -3590,7 +3876,7 @@ void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowS void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) { ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners); if (aIter.hasMoreElements()) @@ -3611,7 +3897,8 @@ void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( R void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aErrorListeners.addInterface(aListener); } @@ -3619,7 +3906,8 @@ void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorList void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aErrorListeners.removeInterface(aListener); } @@ -3627,14 +3915,18 @@ void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorL //------------------------------------------------------------------------------ void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aParameterListeners.addInterface(aListener); } //------------------------------------------------------------------------------ void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aParameterListeners.removeInterface(aListener); } @@ -3655,7 +3947,8 @@ void SAL_CALL FormController::removeParameterListener(const Reference< XDatabase //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners); if (aIter.hasMoreElements()) @@ -3734,14 +4027,18 @@ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& //------------------------------------------------------------------------------ void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aDeleteListeners.addInterface(aListener); } //------------------------------------------------------------------------------ void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aDeleteListeners.removeInterface(aListener); } @@ -3749,7 +4046,8 @@ void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConf //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners); if (aIter.hasMoreElements()) diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index c7e810e48f36..1b4dde021b8d 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -685,7 +685,15 @@ void FmFormShell::Execute(SfxRequest &rReq) case SID_FM_FILTER_NAVIGATOR: case SID_FM_SHOW_DATANAVIGATOR : { - GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq); + SFX_REQUEST_ARG( rReq, pShowItem, SfxBoolItem, nSlot, sal_False ); + if ( !pShowItem ) + GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq ); + else + { + sal_Bool bShow = pShowItem->GetValue(); + GetViewShell()->GetViewFrame()->ShowChildWindow( nSlot, bShow ); + } + rReq.Done(); } break; case SID_FM_SHOW_FMEXPLORER: @@ -857,6 +865,15 @@ void FmFormShell::Execute(SfxRequest &rReq) { GetImpl()->startFiltering(); rReq.Done(); + + // initially open the filter navigator, the whole form based filter is pretty useless without it + SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, TRUE ); + const SfxPoolItem* pArgs[] = + { + &aIdentifierItem, NULL + }; + GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, + pArgs, rReq.GetModifier() ); } break; } } diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 139b9c23b374..8d71cfb4ce24 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -2948,7 +2948,15 @@ void FmXFormShell::startFiltering() m_bFilterMode = sal_True; m_pShell->UIFeatureChanged(); - m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell); + SfxViewFrame* pViewFrame = m_pShell->GetViewShell()->GetViewFrame(); + pViewFrame->GetBindings().InvalidateShell( *m_pShell ); + + if ( pViewFrame->KnowsChildWindow( SID_FM_FILTER_NAVIGATOR ) + && !pViewFrame->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) + ) + { + pViewFrame->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR ); + } } //------------------------------------------------------------------------------ @@ -2994,7 +3002,7 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) Reference< XControlContainer> xContainer; if (getActiveController() == m_xExternalViewController) { - DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this !"); + DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::stopFiltering : inconsistent : active external controller, but noone triggered this !"); xContainer = m_xExtViewTriggerController->getContainer(); } else @@ -3131,7 +3139,7 @@ void FmXFormShell::clearFilter() Reference< XControlContainer> xContainer; if (getActiveController() == m_xExternalViewController) { - DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this !"); + DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::clearFilter : inconsistent : active external controller, but noone triggered this !"); xContainer = m_xExtViewTriggerController->getContainer(); } else diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 58ad69b5417c..d6cdd12fdff2 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -385,13 +385,13 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormCon xController->activateTabOrder(); xController->addActivateListener( m_pViewImpl ); - if ( _pParent ) - _pParent->addChild( xController ); + if ( xParentController.is() ) + xParentController->addChildController( xController ); else { m_aControllerList.push_back(xController); - xController->setParent( xParentController ); + xController->setParent( *this ); // attaching the events Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY ); diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index 56cf6d428c2e..93532ed1a92a 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -30,9 +30,9 @@ #ifndef _SVX_FILTNAV_HXX #define _SVX_FILTNAV_HXX -#include #include #include +#include #include #include @@ -95,8 +95,7 @@ public: class FmParentData : public FmFilterData { protected: - ::std::vector m_aChilds; - + ::std::vector< FmFilterData* > m_aChildren; public: TYPEINFO(); @@ -105,7 +104,7 @@ public: {} virtual ~FmParentData(); - ::std::vector& GetChilds() {return m_aChilds;} + ::std::vector< FmFilterData* >& GetChildren() { return m_aChildren; } }; //======================================================================== @@ -113,20 +112,26 @@ public: class FmFormItem : public FmParentData { ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; - sal_Int32 m_nCurrent; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController > m_xFilterController; public: TYPEINFO(); - FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){} - FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent, + + FmFormItem( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController, - const ::rtl::OUString& _rText):FmParentData(_rxFactory,_pParent, _rText) - ,m_xController(_xController) - ,m_nCurrent(0){} + const ::rtl::OUString& _rText) + :FmParentData( _rxFactory, _pParent, _rText ) + ,m_xController( _xController ) + ,m_xFilterController( _xController, ::com::sun::star::uno::UNO_QUERY_THROW ) + { + } + + inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& + GetController() { return m_xController; } + + inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >& + GetFilterController() { return m_xFilterController; } - const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetController(){return m_xController;} - void SetCurrentPosition(sal_Int32 nCurrent){m_nCurrent = nCurrent;} - sal_Int32 GetCurrentPosition() const {return m_nCurrent;} virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; @@ -138,26 +143,28 @@ public: FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){} FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmFormItem* pParent, const ::rtl::OUString& rText ):FmParentData(_rxFactory,pParent, rText){} - FmFilterItem* Find(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & xText) const; + FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const; virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; //======================================================================== class FmFilterItem : public FmFilterData { - ::rtl::OUString m_aFieldName; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xText; + ::rtl::OUString m_aFieldName; + const sal_Int32 m_nComponentIndex; public: TYPEINFO(); - FmFilterItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, - FmFilterItems* pParent, - const ::rtl::OUString& aFieldName, - const ::rtl::OUString& aCondition, - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & xText); + FmFilterItem( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, + FmFilterItems* pParent, + const ::rtl::OUString& aFieldName, + const ::rtl::OUString& aCondition, + const sal_Int32 _nComponentIndex + ); const ::rtl::OUString& GetFieldName() const {return m_aFieldName;} - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & GetTextComponent() const {return m_xText;} + sal_Int32 GetComponentIndex() const { return m_nComponentIndex; } virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; @@ -196,12 +203,12 @@ public: void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController); void Remove(FmFilterData* pFilterItem); - void AppendFilterItems(FmFormItem* pItem); + void AppendFilterItems( FmFormItem& _rItem ); void CheckIntegrity(FmParentData* pItem); protected: void Insert(const ::std::vector::iterator& rPos, FmFilterData* pFilterItem); - void Remove(const ::std::vector::iterator& rPos, FmFilterData* pFilterItem); + void Remove( const ::std::vector::iterator& rPos ); FmFormItem* Find(const ::std::vector& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const; FmFormItem* Find(const ::std::vector& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const; void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent); diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx index 24795558981c..703954927b15 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/fmctrler.hxx @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -100,9 +101,9 @@ #include #include -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 #include #endif @@ -127,7 +128,8 @@ namespace svxform class ControlBorderManager; struct FmFieldInfo; - typedef ::comphelper::WeakComponentImplHelper21 < ::com::sun::star::form::runtime::XFormController + typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + , ::com::sun::star::form::runtime::XFilterController , ::com::sun::star::awt::XFocusListener , ::com::sun::star::form::XLoadListener , ::com::sun::star::beans::XPropertyChangeListener @@ -185,7 +187,8 @@ namespace svxform m_aErrorListeners, m_aDeleteListeners, m_aRowSetApproveListeners, - m_aParameterListeners; + m_aParameterListeners, + m_aFilterListeners; FmFormControllers m_aChilds; FmFilterControls m_aFilterControls; @@ -282,6 +285,19 @@ namespace svxform using OPropertySetHelper::getFastPropertyValue; + // XFilterController + virtual ::sal_Int32 SAL_CALL getFilterComponents() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 _Component ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getPredicateExpressions() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendEmptyDisjunctiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getActiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + // XElementAccess virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); @@ -351,6 +367,7 @@ namespace svxform virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); @@ -429,26 +446,6 @@ namespace svxform ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps ) const; - public: - // access to the controls for filtering - const FmFilterControls& getFilterControls() const {return m_aFilterControls;} - - // access to the current filter rows - const FmFilterRows& getFilterRows() const {return m_aFilters;} - FmFilterRows& getFilterRows() {return m_aFilters;} - - // just decr. the positions no notifications for the view - void decrementCurrentFilterPosition() - { - DBG_ASSERT(m_nCurrentFilterPosition, "Invalid Position"); - --m_nCurrentFilterPosition; - } - - SVX_DLLPUBLIC void setCurrentFilterPosition(sal_Int32 nPos); - sal_Int32 getCurrentFilterPosition() const {return m_nCurrentFilterPosition;} - - void addChild( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxChildController ); - protected: // FmDispatchInterceptor virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> @@ -538,9 +535,18 @@ namespace svxform void implInvalidateCurrentControlDependentFeatures(); bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } + void impl_checkDisposed_throw() const; void impl_onModify(); + /** ensures that m_aFilters contains at least one empty row + */ + void implts_ensureEmptyFilterRow_nothrow(); + + /** adds an empty filter row to m_aFilters, and notifies our listeners + */ + void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); + sal_Bool isLocked() const {return m_bLocked;} sal_Bool determineLockState() const; -- cgit From 939ce4dfdd902e8adb2cfa4049c9e92b19d7d999 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Oct 2009 12:00:17 +0100 Subject: #i106422# assure that the sequence stays alive when set binary data --- connectivity/source/drivers/odbcbase/OPreparedStatement.cxx | 11 +---------- connectivity/source/drivers/odbcbase/OTools.cxx | 5 +---- connectivity/source/inc/odbc/OBoundParam.hxx | 6 ++++++ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 8d72c3271b82..1c963874d201 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -321,16 +321,6 @@ void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool setInt (parameterIndex, value); } // ------------------------------------------------------------------------- -#define PREP_BIND_PARAM(_ty,_jt) \ - OTools::bindParameter(m_pConnection, \ - m_aStatementHandle, \ - parameterIndex, \ - bindBuf, \ - getLengthBuf(parameterIndex), \ - (SWORD)_jt, \ - sal_False,m_pConnection->useOldDateFormat(),_pData,(Reference )*this,getOwnConnection()->getTextEncoding()) - - void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -568,6 +558,7 @@ void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) { setParameter(parameterIndex,DataType::BINARY,x.getLength(),(void*)&x); + boundParams[parameterIndex-1].setSequence(x); // this assures that the sequence stays alive } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index 39c848f34eaf..3cadb33cf188 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -210,12 +210,9 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, if(pSeq) { - // memcpy(_pData,pSeq->getConstArray(),pSeq->getLength()); - _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + _pData = (sal_Int8*)pSeq->getConstArray(); *pLen = pSeq->getLength(); } - // _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); - // *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); } break; case SQL_LONGVARBINARY: diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx index c71977a94910..bc896c2361d8 100644 --- a/connectivity/source/inc/odbc/OBoundParam.hxx +++ b/connectivity/source/inc/odbc/OBoundParam.hxx @@ -119,6 +119,11 @@ namespace connectivity paramInputStreamLen = len; } + void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence) + { + aSequence = _aSequence; + } + //-------------------------------------------------------------------- // getInputStream // Gets the input stream for the bound parameter @@ -191,6 +196,7 @@ namespace connectivity // data is in native format. ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream; + ::com::sun::star::uno::Sequence< sal_Int8 > aSequence; // When an input stream is // bound to a parameter, the // input stream is saved -- cgit From 7b84a221e4e00245c71fb9442ca8c84562ec08af Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Oct 2009 13:03:41 +0100 Subject: #i106422# assure that the sequence stays alive when set binary data --- connectivity/source/drivers/odbcbase/OPreparedStatement.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 1c963874d201..6e9d87e933ca 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -343,6 +343,10 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType, case SQL_NUMERIC: ++nRealSize; break; + case SQL_BINARY: + case SQL_VARBINARY: + nRealSize=1; //dummy buffer, binary data isn't copied + break; default: break; } -- cgit From fbd5fd6e304ee633e92b88bba45e26a65ad6cb05 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 13:18:02 +0100 Subject: #i10000# --- svx/source/form/filtnav.cxx | 6 +++--- svx/source/form/fmctrler.cxx | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 46044fb58e2a..a0210c9b4c96 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -397,7 +397,7 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos, // XEventListener //------------------------------------------------------------------------ -void SAL_CALL FmFilterAdapter::disposing(const EventObject& e) throw( RuntimeException ) +void SAL_CALL FmFilterAdapter::disposing(const EventObject& /*e*/) throw( RuntimeException ) { } @@ -501,7 +501,7 @@ void SAL_CALL FmFilterAdapter::disjunctiveTermRemoved( const FilterEvent& _Event return; ::std::vector< FmFilterData* >& rTermItems = pFormItem->GetChildren(); - const bool bValidIndex = ( _Event.DisjunctiveTerm >= 0 ) && ( _Event.DisjunctiveTerm < rTermItems.size() ); + const bool bValidIndex = ( _Event.DisjunctiveTerm >= 0 ) && ( (size_t)_Event.DisjunctiveTerm < rTermItems.size() ); OSL_ENSURE( bValidIndex, "FmFilterAdapter::disjunctiveTermRemoved: invalid term index!" ); if ( !bValidIndex ) return; @@ -533,7 +533,7 @@ void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& _Event ) return; const sal_Int32 nInsertPos = _Event.DisjunctiveTerm; - bool bValidIndex = ( nInsertPos >= 0 ) && ( nInsertPos <= pFormItem->GetChildren().size() ); + bool bValidIndex = ( nInsertPos >= 0 ) && ( (size_t)nInsertPos <= pFormItem->GetChildren().size() ); if ( !bValidIndex ) { OSL_ENSURE( false, "FmFilterAdapter::disjunctiveTermAdded: invalid index!" ); diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index af1158f1b3cb..b8d7b18ffddc 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -1047,7 +1047,6 @@ void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw ( throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); // if the to-be-deleted row is our current row, we need to shift - sal_Int32 nNewFilterPosition( m_nCurrentFilterPosition ); if ( _Term == m_nCurrentFilterPosition ) { if ( m_nCurrentFilterPosition < sal_Int32( m_aFilters.size() - 1 ) ) @@ -2843,7 +2842,6 @@ void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeExc // toggle the locking ? if (m_bLocked != determineLockState()) { - ::osl::MutexGuard aGuard( m_aMutex ); m_bLocked = !m_bLocked; setLocks(); if (isListeningForChanges()) @@ -3947,6 +3945,7 @@ void SAL_CALL FormController::removeParameterListener(const Reference< XDatabase //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) { + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); @@ -3979,10 +3978,7 @@ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& pParamRequest->addContinuation(pAbort); // handle the request - { - ::vos::OGuard aGuard(Application::GetSolarMutex()); - m_xInteractionHandler->handle(xParamRequest); - } + m_xInteractionHandler->handle(xParamRequest); if (!pParamValues->wasSelected()) // canceled -- cgit From f748b201799c61d87f2ecf3569b75a22c107f1ae Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 13:18:16 +0100 Subject: added a TODO comment --- svx/source/form/fmctrler.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index af1158f1b3cb..b851b254f993 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -1628,6 +1628,17 @@ void FormController::impl_onModify() //------------------------------------------------------------------------------ void FormController::implts_ensureEmptyFilterRow_nothrow() { + // TODO: + // strictly, this method should not be needed. There is no compelling reason why a FormController must always + // have an empty filter row (or, in API terminology, an empty disjunctive term). Except ... the implementation + // probably cannot cope with an empty filter row container. + // Before the UNOiization of the FormController, the responsibility between ensuring the empty row was + // shared between the form controller and the filter navigator, which of course is nonsense. In the course + // of the UNOization, this was changed so that now the FormController is responsible alone. + // However, ideally, the FormController should not expect this empty row, and be able to work with no row at all. + // It would then be the responsibility of the UI (aka the filter navigator), to always ensure this empty row, + // if it really needs it. + // SYNCHRONIZED --> ::osl::ClearableMutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); -- cgit From e7f32a0dc59f554c20eeaa7d66a2b1190e752564 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Oct 2009 13:43:24 +0100 Subject: apply changes from m62 --- xmloff/source/core/xmlimp.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index d4dc48ede241..0dece7c6965c 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1629,6 +1629,7 @@ sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion if ( aODFVersion.getLength() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 ) { // check the consistency only for the ODF1.2 and later ( according to content.xml ) + // manifest.xml might have no version, it should be checked here and the correct version should be set try { uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW ); @@ -1654,7 +1655,24 @@ sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion ::rtl::OUString aStorVersion; xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= aStorVersion; - bResult = aODFVersion.equals( aStorVersion ); + + // if the storage version is set in manifest.xml, it must be the same as in content.xml + // if not, set it explicitly to be used further ( it will work even for readonly storage ) + // This workaround is not nice, but I see no other way to handle it, since there are + // ODF1.2 documents without version in manifest.xml + if ( aStorVersion.getLength() ) + bResult = aODFVersion.equals( aStorVersion ); + else + xStorProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), + uno::makeAny( aODFVersion ) ); + + if ( bResult ) + { + sal_Bool bInconsistent = sal_False; + xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsInconsistent" ) ) ) + >>= bInconsistent; + bResult = !bInconsistent; + } } } } -- cgit From 5f6bed9fc0b019fa78319bc1cdf8db4ac1abce6c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 15:55:37 +0100 Subject: finally removed XUnoTunnel from the FormController implementation, and did some small re-factorings in preparation of moving the responsibility for always having an empty filter row to the navigator --- svx/source/form/filtnav.cxx | 29 +++-- svx/source/form/fmctrler.cxx | 276 +++++++++++++++++++++---------------------- svx/source/form/fmshell.cxx | 8 +- svx/source/form/fmvwimp.cxx | 38 +++--- svx/source/inc/fmctrler.hxx | 41 +++---- svx/source/inc/fmvwimp.hxx | 8 +- 6 files changed, 193 insertions(+), 207 deletions(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index a0210c9b4c96..1c5003f1df3e 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -33,7 +33,6 @@ #include "filtnav.hxx" -#include "fmctrler.hxx" #include "fmexch.hxx" #include "fmhelp.hrc" #include "fmitems.hxx" @@ -323,7 +322,8 @@ TYPEINIT1( FmFilterCurrentChangedHint, SfxHint ); //======================================================================== class FmFilterAdapter : public ::cppu::WeakImplHelper1< XFilterControllerListener > { - FmFilterModel* m_pModel; + Reference< XIndexAccess > m_xControllers; + FmFilterModel* m_pModel; public: FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers); @@ -339,7 +339,7 @@ public: // helpers void dispose() throw( RuntimeException ); - void InsertElements( const Reference< XIndexAccess >& xControllers ); + void AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd ); void setText(sal_Int32 nPos, const FmFilterItem* pFilterItem, @@ -348,31 +348,36 @@ public: //------------------------------------------------------------------------ FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers) - :m_pModel(pModel) + :m_pModel( pModel ) + ,m_xControllers( xControllers ) { - InsertElements(xControllers); + AddOrRemoveListener( m_xControllers, true ); } //------------------------------------------------------------------------ void FmFilterAdapter::dispose() throw( RuntimeException ) { + AddOrRemoveListener( m_xControllers, false ); } //------------------------------------------------------------------------ -void FmFilterAdapter::InsertElements(const Reference< XIndexAccess >& xControllers) +void FmFilterAdapter::AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd ) { - for (sal_Int32 i = 0, nLen = xControllers->getCount(); i < nLen; ++i) + for (sal_Int32 i = 0, nLen = _rxControllers->getCount(); i < nLen; ++i) { - Reference< XIndexAccess > xElement; - xControllers->getByIndex(i) >>= xElement; + Reference< XIndexAccess > xElement( _rxControllers->getByIndex(i), UNO_QUERY ); - // Insert the Elements of the controller - InsertElements(xElement); + // step down + AddOrRemoveListener( xElement, _bAdd ); + // handle this particular controller Reference< XFilterController > xController( xElement, UNO_QUERY ); OSL_ENSURE( xController.is(), "FmFilterAdapter::InsertElements: no XFilterController, cannot sync data!" ); if ( xController.is() ) - xController->addFilterControllerListener( this ); + if ( _bAdd ) + xController->addFilterControllerListener( this ); + else + xController->removeFilterControllerListener( this ); } } diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index 88f9a5303077..c23897522626 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmctrler.cxx,v $ - * $Revision: 1.71 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -137,6 +134,7 @@ namespace svxform using ::com::sun::star::lang::IndexOutOfBoundsException; using ::com::sun::star::sdb::XInteractionSupplyParameters; using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::awt::XTextListener; using ::com::sun::star::uno::Any; using ::com::sun::star::frame::XDispatch; using ::com::sun::star::lang::XMultiServiceFactory; @@ -569,7 +567,7 @@ FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) ) - ,m_nCurrentFilterPosition(0) + ,m_nCurrentFilterPosition(-1) ,m_bCurrentRecordModified(sal_False) ,m_bCurrentRecordNew(sal_False) ,m_bLocked(sal_False) @@ -690,39 +688,6 @@ Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException) ); } -// ----------------------------------------------------------------------------- -// XUnoTunnel -Sequence< sal_Int8 > FormController::getUnoTunnelImplementationId() -{ - static ::cppu::OImplementationId * pId = NULL; - if ( !pId ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pId ) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} -//------------------------------------------------------------------------------ -FormController* FormController::getImplementation( const Reference< XInterface >& _rxComponent ) -{ - Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY ); - if ( xTunnel.is() ) - return reinterpret_cast< FormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) ); - return NULL; -} -//------------------------------------------------------------------------------ -sal_Int64 SAL_CALL FormController::getSomething(Sequence const& rId)throw( RuntimeException ) -{ - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return reinterpret_cast< sal_Int64 >( this ); - - return sal_Int64(); -} - // XServiceInfo //------------------------------------------------------------------------------ sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) @@ -781,26 +746,54 @@ Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) return aServices; } +// ----------------------------------------------------------------------------- +namespace +{ + struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void > + { + void operator()( const Reference< XTextComponent >& _rxText ) + { + _rxText->setText( ::rtl::OUString() ); + } + }; + + struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void > + { + RemoveComponentTextListener( const Reference< XTextListener >& _rxListener ) + :m_xListener( _rxListener ) + { + } + + void operator()( const Reference< XTextComponent >& _rxText ) + { + _rxText->removeTextListener( m_xListener ); + } + + private: + Reference< XTextListener > m_xListener; + }; +} + // ----------------------------------------------------------------------------- void FormController::impl_setTextOnAllFilter_throw() { // reset the text for all controls - for ( FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); - ++iter - ) - iter->first->setText( ::rtl::OUString() ); + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() ); + + if ( m_aFilterRows.empty() ) + // nothing to do anymore + return; if ( m_nCurrentFilterPosition < 0 ) return; // set the text for all filters - OSL_ENSURE( m_aFilters.size() > (size_t)m_nCurrentFilterPosition, + OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition, "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" ); - if ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) + if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() ) { - FmFilterRow& rRow = m_aFilters[ m_nCurrentFilterPosition ]; + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; for ( FmFilterRow::const_iterator iter2 = rRow.begin(); iter2 != rRow.end(); ++iter2 @@ -849,39 +842,47 @@ void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() ); // now add the filter rows - for ( FmFilterRows::const_iterator row = m_aFilters.begin(); row != m_aFilters.end(); ++row ) + try { - const FmFilterRow& rRow = *row; + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row ) + { + const FmFilterRow& rRow = *row; - if ( rRow.empty() ) - continue; + if ( rRow.empty() ) + continue; - if ( aFilter.getLength() ) - aFilter.appendAscii( " OR " ); + if ( aFilter.getLength() ) + aFilter.appendAscii( " OR " ); - aFilter.appendAscii( "( " ); - for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) - { - // get the field of the controls map - Reference< XTextComponent > xText = condition->first; - Reference< XPropertySet > xField = m_aFilterControls.find( xText )->second; - DBG_ASSERT( xField.is(), "FormController::getFastPropertyValue: no field found!" ); - if ( condition != rRow.begin() ) - aFilter.appendAscii( " AND " ); - - ::rtl::OUString sFilterValue( condition->second ); - - ::rtl::OUString sErrorMsg, sCriteria; - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); - OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); - if ( xParseNode.is() ) + aFilter.appendAscii( "( " ); + for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) { - // don't use a parse context here, we need it unlocalized - xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); - aFilter.append( sCriteria ); + // get the field of the controls map + Reference< XControl > xControl( condition->first, UNO_QUERY_THROW ); + Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); + if ( condition != rRow.begin() ) + aFilter.appendAscii( " AND " ); + + ::rtl::OUString sFilterValue( condition->second ); + + ::rtl::OUString sErrorMsg, sCriteria; + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); + OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); + if ( xParseNode.is() ) + { + // don't use a parse context here, we need it unlocalized + xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); + aFilter.append( sCriteria ); + } } + aFilter.appendAscii( " )" ); } - aFilter.appendAscii( " )" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + aFilter.setLength(0); } } rValue <<= aFilter.makeStringAndClear(); @@ -947,7 +948,7 @@ void SAL_CALL FormController::removeFilterControllerListener( const Reference< X ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - return m_aFilterControls.size(); + return m_aFilterComponents.size(); } //------------------------------------------------------------------------------ @@ -956,7 +957,7 @@ void SAL_CALL FormController::removeFilterControllerListener( const Reference< X ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - return m_aFilters.size(); + return m_aFilterRows.size(); } //------------------------------------------------------------------------------ @@ -968,15 +969,10 @@ void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, :: if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - FmFilterControls::const_iterator componentPos( m_aFilterControls.begin() ); - while ( _Component > 0 ) - ++componentPos, --_Component; - // TODO: make m_aFilterControls a vector - - Reference< XTextComponent > xText( componentPos->first ); + Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] ); xText->setText( _PredicateExpression ); - FmFilterRow& rFilterRow = m_aFilters[ _Term ]; + FmFilterRow& rFilterRow = m_aFilterRows[ _Term ]; if ( _PredicateExpression.getLength() ) rFilterRow[ xText ] = _PredicateExpression; else @@ -992,11 +988,7 @@ Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - FmFilterControls::const_iterator componentPos( m_aFilterControls.begin() ); - while ( _Component > 0 ) - ++componentPos, --_Component; - - return Reference< XControl >( componentPos->first, UNO_QUERY ); + return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY ); } //------------------------------------------------------------------------------ @@ -1005,23 +997,23 @@ Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions( ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilters.size() ); + Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() ); sal_Int32 termIndex = 0; - for ( FmFilterRows::const_iterator row = m_aFilters.begin(); - row != m_aFilters.end(); + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); + row != m_aFilterRows.end(); ++row, ++termIndex ) { const FmFilterRow& rRow( *row ); - Sequence< ::rtl::OUString > aConjunction( m_aFilterControls.size() ); + Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() ); sal_Int32 componentIndex = 0; - for ( FmFilterControls::const_iterator comp = m_aFilterControls.begin(); - comp != m_aFilterControls.end(); + for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin(); + comp != m_aFilterComponents.end(); ++comp, ++componentIndex ) { - FmFilterRow::const_iterator predicate = rRow.find( comp->first ); + FmFilterRow::const_iterator predicate = rRow.find( *comp ); if ( predicate != rRow.end() ) aConjunction[ componentIndex ] = predicate->second; } @@ -1042,26 +1034,25 @@ void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw ( if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - if ( ( _Term == 0 ) && ( m_aFilters.size() == 1 ) ) - // not allowed to remove the one and only last term - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - // if the to-be-deleted row is our current row, we need to shift if ( _Term == m_nCurrentFilterPosition ) { - if ( m_nCurrentFilterPosition < sal_Int32( m_aFilters.size() - 1 ) ) + if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) ) ++m_nCurrentFilterPosition; else --m_nCurrentFilterPosition; } - FmFilterRows::iterator pos = m_aFilters.begin() + _Term; - m_aFilters.erase( pos ); + FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term; + m_aFilterRows.erase( pos ); // adjust m_nCurrentFilterPosition if the removed row preceeded it if ( _Term < m_nCurrentFilterPosition ) --m_nCurrentFilterPosition; + OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ), + "FormController::removeDisjunctiveTerm: inconsistency!" ); + // update the texts in the filter controls impl_setTextOnAllFilter_throw(); @@ -1223,7 +1214,7 @@ void FormController::disposing(void) m_pControlBorderManager->restoreAll(); - m_aFilters.clear(); + m_aFilterRows.clear(); ::osl::MutexGuard aGuard( m_aMutex ); m_xActiveControl = NULL; @@ -1505,14 +1496,17 @@ void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeExce Reference< XTextComponent > xText(e.Source,UNO_QUERY); ::rtl::OUString aText = xText->getText(); + if ( m_aFilterRows.empty() ) + appendEmptyDisjunctiveTerm(); + // Suchen der aktuellen Row - if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilters.size() ) || ( m_nCurrentFilterPosition < 0 ) ) + if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) ) { OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" ); return; } - FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; // do we have a new filter if (aText.getLength()) @@ -1529,11 +1523,8 @@ void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeExce // multiplex the event to our FilterControllerListeners FilterEvent aEvent; aEvent.Source = *this; - aEvent.FilterComponent = 0; + aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin(); aEvent.DisjunctiveTerm = getActiveTerm(); - FmFilterControls::const_iterator lookup( m_aFilterControls.begin() ); - while ( lookup != m_aFilterControls.end() && ( lookup->first != xText ) ) - ++lookup, ++aEvent.FilterComponent; aEvent.PredicateExpression = aText; aGuard.clear(); @@ -1624,6 +1615,18 @@ void FormController::impl_onModify() m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt ); } +//------------------------------------------------------------------------------ +void FormController::impl_addFilterRow( const FmFilterRow& _row ) +{ + m_aFilterRows.push_back( _row ); + + if ( m_aFilterRows.size() == 1 ) + { // that's the first row ever + OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" ); + m_nCurrentFilterPosition = 0; + } +} + //------------------------------------------------------------------------------ void FormController::implts_ensureEmptyFilterRow_nothrow() { @@ -1643,8 +1646,8 @@ void FormController::implts_ensureEmptyFilterRow_nothrow() impl_checkDisposed_throw(); // do we have an empty row? - for ( FmFilterRows::const_iterator pos = m_aFilters.begin(); - pos != m_aFilters.end(); + for ( FmFilterRows::const_iterator pos = m_aFilterRows.begin(); + pos != m_aFilterRows.end(); ++pos ) { @@ -1661,12 +1664,12 @@ void FormController::implts_ensureEmptyFilterRow_nothrow() void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) { // SYNCHRONIZED --> - m_aFilters.push_back( FmFilterRow() ); + impl_addFilterRow( FmFilterRow() ); // notify the listeners FilterEvent aEvent; aEvent.Source = *this; - aEvent.DisjunctiveTerm = (sal_Int32)m_aFilters.size() - 1; + aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1; _rClearBeforeNotify.clear(); // <-- SYNCHRONIZED m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent ); @@ -2085,11 +2088,8 @@ void FormController::setContainer(const Reference< XControlContainer > & xContai m_aTabActivationTimer.Stop(); // clear the filter map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); ++iter) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); // einsammeln der Controls const Reference< XControl >* pControls = m_aControls.getConstArray(); @@ -2594,13 +2594,9 @@ void FormController::removeControl(const Reference< XControl > & xControl) } } - if (m_aFilterControls.size()) - { - Reference< XTextComponent > xText(xControl, UNO_QUERY); - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); - } + FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); implControlRemoved( xControl, m_bDetachEvents ); @@ -2916,8 +2912,8 @@ void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) { - m_aFilterControls[xText] = xField; - xText->addTextListener(this); + m_aFilterComponents.push_back( xText ); + xText->addTextListener( this ); } } } @@ -2959,10 +2955,10 @@ void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( R // are we in filtermode and a XModeSelector has inserted an element else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) { - Reference< XTextComponent > xText(xControl, UNO_QUERY); - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); + FilterComponents::iterator componentPos = ::std::find( + m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); } } @@ -3270,19 +3266,20 @@ void FormController::setFilter(::std::vector& rFieldInfos) if (aRow.empty()) continue; - m_aFilters.push_back(aRow); + impl_addFilterRow( aRow ); } } // now set the filter controls - for (::std::vector::iterator iter = rFieldInfos.begin(); - iter != rFieldInfos.end(); iter++) + for ( ::std::vector::iterator field = rFieldInfos.begin(); + field != rFieldInfos.end(); + ++field + ) { - m_aFilterControls[(*iter).xText] = (*iter).xField; + m_aFilterComponents.push_back( field->xText ); } - // add an empty row - m_aFilters.push_back(FmFilterRow()); + implts_ensureEmptyFilterRow_nothrow(); } //------------------------------------------------------------------------------ @@ -3453,11 +3450,8 @@ void FormController::stopFiltering() sal_Int32 nControlCount = aControlsCopy.getLength(); // clear the filter control map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); for ( sal_Int32 i = nControlCount; i > 0; ) { @@ -3507,8 +3501,8 @@ void FormController::stopFiltering() m_bDetachEvents = sal_True; - m_aFilters.clear(); - m_nCurrentFilterPosition = 0; + m_aFilterRows.clear(); + m_nCurrentFilterPosition = -1; // release the locks if possible // lock all controls which are not used for filtering diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 1b4dde021b8d..fff584964132 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -690,7 +690,7 @@ void FmFormShell::Execute(SfxRequest &rReq) GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq ); else { - sal_Bool bShow = pShowItem->GetValue(); + const sal_Bool bShow = pShowItem->GetValue(); GetViewShell()->GetViewFrame()->ShowChildWindow( nSlot, bShow ); } @@ -868,12 +868,8 @@ void FmFormShell::Execute(SfxRequest &rReq) // initially open the filter navigator, the whole form based filter is pretty useless without it SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, TRUE ); - const SfxPoolItem* pArgs[] = - { - &aIdentifierItem, NULL - }; GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, - pArgs, rReq.GetModifier() ); + &aIdentifierItem, NULL ); } break; } } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index d6cdd12fdff2..829d9f6b61e8 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "fmctrler.hxx" #include "fmdocumentclassification.hxx" #include "fmobj.hxx" #include "fmpgeimp.hxx" @@ -84,6 +83,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include @@ -199,7 +199,7 @@ FmXPageViewWinRec::FmXPageViewWinRec( const ::comphelper::ComponentContext& _rCo { Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY ); if ( xForm.is() ) - setController( xForm ); + setController( xForm, NULL ); } } catch( const Exception& ) @@ -352,9 +352,8 @@ Reference< XFormController > FmXPageViewWinRec::getController( const Reference< } //------------------------------------------------------------------------ -void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormController* _pParent ) +void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, const Reference< XFormController >& _rxParentController ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::setController" ); DBG_ASSERT( xForm.is(), "FmXPageViewWinRec::setController: there should be a form!" ); Reference< XIndexAccess > xFormCps(xForm, UNO_QUERY); if (!xFormCps.is()) @@ -363,13 +362,16 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormCon Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY); // create a form controller - FormController* pController = new FormController( m_aContext.getLegacyServiceFactory() ); - Reference< XFormController > xController( pController ); + Reference< XFormController > xController( m_aContext.createComponent( FM_FORM_CONTROLLER ), UNO_QUERY ); + if ( !xController.is() ) + { + ShowServiceNotAvailableError( m_pWindow, FM_FORM_CONTROLLER, sal_True ); + return; + } - Reference< XFormController > xParentController( _pParent ); Reference< XInteractionHandler > xHandler; - if ( xParentController.is() ) - xHandler = xParentController->getInteractionHandler(); + if ( _rxParentController.is() ) + xHandler = _rxParentController->getInteractionHandler(); else { // TODO: should we create a default handler? Not really necessary, since the @@ -385,8 +387,8 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormCon xController->activateTabOrder(); xController->addActivateListener( m_pViewImpl ); - if ( xParentController.is() ) - xParentController->addChildController( xController ); + if ( _rxParentController.is() ) + _rxParentController->addChildController( xController ); else { m_aControllerList.push_back(xController); @@ -405,7 +407,7 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FormCon for (sal_uInt32 i = 0; i < nLength; i++) { if ( xFormCps->getByIndex(i) >>= xSubForm ) - setController(xSubForm, pController); + setController( xSubForm, xController ); } } @@ -430,18 +432,12 @@ void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm ) // if it's a sub form, then we must ensure there exist TabControllers // for all its ancestors, too Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY ); - FormController* pFormController = NULL; // there is a parent form -> look for the respective controller + Reference< XFormController > xParentController; if ( xParentForm.is() ) - xTabCtrl = Reference< XTabController >( getController( xParentForm ), UNO_QUERY ); - - if ( xTabCtrl.is() ) - { - Reference< XUnoTunnel > xTunnel( xTabCtrl, UNO_QUERY_THROW ); - pFormController = reinterpret_cast< FormController* >( xTunnel->getSomething( FormController::getUnoTunnelImplementationId() ) ); - } + xParentController.set( getController( xParentForm ), UNO_QUERY ); - setController( _rxForm, pFormController ); + setController( _rxForm, xParentController ); } } catch( const Exception& ) diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx index 703954927b15..af4d5402db04 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/fmctrler.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmctrler.hxx,v $ - * $Revision: 1.24 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -79,7 +76,6 @@ #include #include #include -#include #include #include #include @@ -101,9 +97,9 @@ #include #include -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 #include #endif @@ -115,7 +111,6 @@ struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::u } }; -typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, FmXTextComponentLess> FmFilterControls; typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; typedef ::std::vector< FmFilterRow > FmFilterRows; typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers; @@ -125,10 +120,11 @@ class Window; namespace svxform { + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > > FilterComponents; class ControlBorderManager; struct FmFieldInfo; - typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + typedef ::comphelper::WeakComponentImplHelper21 < ::com::sun::star::form::runtime::XFormController , ::com::sun::star::form::runtime::XFilterController , ::com::sun::star::awt::XFocusListener , ::com::sun::star::form::XLoadListener @@ -144,7 +140,6 @@ namespace svxform , ::com::sun::star::form::XDatabaseParameterListener , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::form::XResetListener - , ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::frame::XDispatch , ::com::sun::star::awt::XMouseListener , ::com::sun::star::form::validation::XFormComponentValidityListener @@ -191,8 +186,8 @@ namespace svxform m_aFilterListeners; FmFormControllers m_aChilds; - FmFilterControls m_aFilterControls; - FmFilterRows m_aFilters; + FilterComponents m_aFilterComponents; + FmFilterRows m_aFilterRows; Timer m_aTabActivationTimer; Timer m_aFeatureInvalidationTimer; @@ -236,18 +231,12 @@ namespace svxform DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); Interceptors m_aControlDispatchInterceptors; - protected: - ~FormController(); - public: FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ); - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - SVX_DLLPUBLIC static FormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); - protected: + ~FormController(); + // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL acquire() throw (); @@ -539,11 +528,19 @@ namespace svxform void impl_onModify(); - /** ensures that m_aFilters contains at least one empty row + /** ensures that m_aFilterRows contains at least one empty row */ void implts_ensureEmptyFilterRow_nothrow(); - /** adds an empty filter row to m_aFilters, and notifies our listeners + /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added + row is the first one. + + @precond + our mutex is locked + */ + void impl_addFilterRow( const FmFilterRow& _row ); + + /** adds an empty filter row to m_aFilterRows, and notifies our listeners */ void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx index 62e913afdac2..c51c935883ed 100644 --- a/svx/source/inc/fmvwimp.hxx +++ b/svx/source/inc/fmvwimp.hxx @@ -74,9 +74,6 @@ FORWARD_DECLARE_INTERFACE(awt,XWindow) FORWARD_DECLARE_INTERFACE(beans,XPropertySet) FORWARD_DECLARE_INTERFACE(util,XNumberFormats) -namespace svxform { - class FormController; -} class FmXFormView; namespace svx { @@ -127,8 +124,9 @@ public: protected: ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const; - void setController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, - ::svxform::FormController* pParent = NULL); + void setController( + const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; } void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); void dispose(); -- cgit From 834a384180018be5d8ad3833f5f9f5918be88922 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 21:15:59 +0100 Subject: #i10000# --- svx/source/form/filtnav.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 1c5003f1df3e..90091d62e269 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -322,8 +322,8 @@ TYPEINIT1( FmFilterCurrentChangedHint, SfxHint ); //======================================================================== class FmFilterAdapter : public ::cppu::WeakImplHelper1< XFilterControllerListener > { - Reference< XIndexAccess > m_xControllers; FmFilterModel* m_pModel; + Reference< XIndexAccess > m_xControllers; public: FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers); -- cgit From 97b267dea22695eb9a0d12a97dcc3dbffe1ab419 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Oct 2009 21:26:38 +0100 Subject: moved the responsibility for always having an empty filter row to the navigator, so the mere FormController implementation now is able to work on an empty filter --- svx/source/form/filtnav.cxx | 57 +++++++++++++++++++------------------------- svx/source/form/fmctrler.cxx | 41 ------------------------------- svx/source/inc/filtnav.hxx | 2 +- svx/source/inc/fmctrler.hxx | 4 ---- 4 files changed, 25 insertions(+), 79 deletions(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 90091d62e269..73b077068ac3 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -488,7 +488,9 @@ void FmFilterAdapter::predicateExpressionChanged( const FilterEvent& _Event ) th pFilterItem = new FmFilterItem( m_pModel->getORB(), pFilter, aFieldName, _Event.PredicateExpression, _Event.FilterComponent ); m_pModel->Insert(pFilter->GetChildren().end(), pFilterItem); } - m_pModel->CheckIntegrity(pFormItem); + + // ensure there's one empty term in the filter, just in case the active term was previously empty + m_pModel->EnsureEmptyFilterRows( *pFormItem ); } //------------------------------------------------------------------------ @@ -521,6 +523,9 @@ void SAL_CALL FmFilterAdapter::disjunctiveTermRemoved( const FilterEvent& _Event // finally remove the entry from the model m_pModel->Remove( rTermItems.begin() + _Event.DisjunctiveTerm ); + + // ensure there's one empty term in the filter, just in case the currently removed one was the last empty one + m_pModel->EnsureEmptyFilterRows( *pFormItem ); } //------------------------------------------------------------------------ @@ -551,7 +556,6 @@ void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& _Event ) m_pModel->Insert( insertPos, pFilterItems ); } - //======================================================================== // class FmFilterModel //======================================================================== @@ -625,7 +629,7 @@ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const m_pAdapter->acquire(); SetCurrentController(xCurrent); - CheckIntegrity(this); + EnsureEmptyFilterRows( *this ); } else SetCurrentController(xCurrent); @@ -774,18 +778,6 @@ void FmFilterModel::SetCurrentController(const Reference< XFormController > & xC //------------------------------------------------------------------------ void FmFilterModel::AppendFilterItems( FmFormItem& _rFormItem ) { - OSL_ENSURE( false, "FmFilterModel::AppendFilterItems: this should be dead code!" ); - // Before the UNOization of hte FormController, the controller implementation itself - // did not care for keeping at least one empty filter row. With the changes done now, - // it should be impossible to get a FormController to *not* have at least one empty - // filter row. - // Since the task of this method here was to ensure the controller *has* an empty row, - // this means the method should not be needed anymore. However, it's left here for the moment, - // to be on the safe side ... - // If the assertion above fires, then it needs to be investigated at which place the - // FormController failed to fulfill its contract of having at least one empty filter row - // all the time. - // insert the condition behind the last filter items ::std::vector::reverse_iterator iter; for ( iter = _rFormItem.GetChildren().rbegin(); @@ -1018,37 +1010,36 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) } //------------------------------------------------------------------------ -void FmFilterModel::CheckIntegrity(FmParentData* pItem) +void FmFilterModel::EnsureEmptyFilterRows( FmParentData& _rItem ) { // checks whether for each form there's one free level for input + ::std::vector< FmFilterData* >& rChildren = _rItem.GetChildren(); + sal_Bool bAppendLevel = _rItem.ISA( FmFormItem ); - ::std::vector< FmFilterData* >& rItems = pItem->GetChildren(); - sal_Bool bAppendLevel = sal_False; - - for ( ::std::vector::iterator i = rItems.begin(); - i != rItems.end(); + for ( ::std::vector::iterator i = rChildren.begin(); + i != rChildren.end(); ++i ) { FmFilterItems* pItems = PTR_CAST(FmFilterItems, *i); - if (pItems) + if ( pItems && pItems->GetChildren().empty() ) { - bAppendLevel = !pItems->GetChildren().empty(); - continue; + bAppendLevel = sal_False; + break; } FmFormItem* pFormItem = PTR_CAST(FmFormItem, *i); if (pFormItem) { - CheckIntegrity(pFormItem); + EnsureEmptyFilterRows( *pFormItem ); continue; } } if ( bAppendLevel ) { - FmFormItem* pFormItem = PTR_CAST( FmFormItem, pItem ); - OSL_ENSURE( pFormItem, "FmFilterModel::CheckIntegrity: no FmFormItem, but a FmFilterItems child?" ); + FmFormItem* pFormItem = PTR_CAST( FmFormItem, &_rItem ); + OSL_ENSURE( pFormItem, "FmFilterModel::EnsureEmptyFilterRows: no FmFormItem, but a FmFilterItems child?" ); if ( pFormItem ) AppendFilterItems( *pFormItem ); } @@ -1595,13 +1586,15 @@ void FmFilterNavigator::Insert(FmFilterData* pItem, sal_Int32 nPos) const FmParentData* pParent = pItem->GetParent() ? pItem->GetParent() : GetFilterModel(); // insert the item - SvLBoxEntry* pParentEntry = FindEntry(pParent); + SvLBoxEntry* pParentEntry = FindEntry( pParent ); SvLBoxEntry* pNewEntry = InsertEntry(pItem->GetText(), pItem->GetImage(), pItem->GetImage(), pParentEntry, sal_False, nPos, pItem ); if ( pNewEntry ) { SetExpandedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); SetCollapsedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); } + if ( pParentEntry ) + Expand( pParentEntry ); } //------------------------------------------------------------------------ @@ -1678,8 +1671,10 @@ void FmFilterNavigator::insertFilterItem(const ::std::vector& _rF // now set the text for the new dragged item m_pModel->SetTextForItem( pFilterItem, aText ); } - m_pModel->CheckIntegrity( (FmFormItem*)_pTargetItems->GetParent() ); + + m_pModel->EnsureEmptyFilterRows( *_pTargetItems->GetParent() ); } + //------------------------------------------------------------------------------ void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ ) { @@ -1936,11 +1931,7 @@ void FmFilterNavigator::DeleteSelection() i.base() != aEntryList.rend().base(); i++) { m_pModel->Remove((FmFilterData*)(*i)->GetUserData()); - Update(); } - - // now check if we need to insert new items - m_pModel->CheckIntegrity(m_pModel); } // ----------------------------------------------------------------------------- diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx index c23897522626..cc3855518889 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/fmctrler.cxx @@ -1062,9 +1062,6 @@ void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw ( aGuard.clear(); // <-- SYNCHRONIZED - // ensure there's an empty row (perhaps we just removed the last empty row) - implts_ensureEmptyFilterRow_nothrow(); - m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent ); } @@ -1530,9 +1527,6 @@ void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeExce aGuard.clear(); // <-- SYNCHRONIZED - // ensure there's an empty row (perhaps we just filled the previously empty row) - implts_ensureEmptyFilterRow_nothrow(); - // notify the changed filter expression m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent ); } @@ -1627,39 +1621,6 @@ void FormController::impl_addFilterRow( const FmFilterRow& _row ) } } -//------------------------------------------------------------------------------ -void FormController::implts_ensureEmptyFilterRow_nothrow() -{ - // TODO: - // strictly, this method should not be needed. There is no compelling reason why a FormController must always - // have an empty filter row (or, in API terminology, an empty disjunctive term). Except ... the implementation - // probably cannot cope with an empty filter row container. - // Before the UNOiization of the FormController, the responsibility between ensuring the empty row was - // shared between the form controller and the filter navigator, which of course is nonsense. In the course - // of the UNOization, this was changed so that now the FormController is responsible alone. - // However, ideally, the FormController should not expect this empty row, and be able to work with no row at all. - // It would then be the responsibility of the UI (aka the filter navigator), to always ensure this empty row, - // if it really needs it. - - // SYNCHRONIZED --> - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - // do we have an empty row? - for ( FmFilterRows::const_iterator pos = m_aFilterRows.begin(); - pos != m_aFilterRows.end(); - ++pos - ) - { - if ( pos->empty() ) - // all fine, found one - return; - } - - impl_appendEmptyFilterRow( aGuard ); - // <-- SYNCHRONIZED -} - //------------------------------------------------------------------------------ void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) { @@ -3278,8 +3239,6 @@ void FormController::setFilter(::std::vector& rFieldInfos) { m_aFilterComponents.push_back( field->xText ); } - - implts_ensureEmptyFilterRow_nothrow(); } //------------------------------------------------------------------------------ diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index 93532ed1a92a..f1ae1ed4398d 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -204,7 +204,7 @@ public: void Remove(FmFilterData* pFilterItem); void AppendFilterItems( FmFormItem& _rItem ); - void CheckIntegrity(FmParentData* pItem); + void EnsureEmptyFilterRows( FmParentData& _rItem ); protected: void Insert(const ::std::vector::iterator& rPos, FmFilterData* pFilterItem); diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx index af4d5402db04..550bce611c73 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/fmctrler.hxx @@ -528,10 +528,6 @@ namespace svxform void impl_onModify(); - /** ensures that m_aFilterRows contains at least one empty row - */ - void implts_ensureEmptyFilterRow_nothrow(); - /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added row is the first one. -- cgit From 29275473927ad7944c34c22394ccd4ffea79ed36 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 30 Oct 2009 11:38:26 +0100 Subject: further isolated the FormController implementation from the SVX code (not yet finally there, though) --- svx/source/form/confirmdelete.cxx | 3 - svx/source/form/delayedevent.cxx | 4 - svx/source/form/fmcontrolbordermanager.cxx | 3 - svx/source/form/fmcontrollayout.cxx | 3 - svx/source/form/fmctrler.cxx | 4253 -------------------------- svx/source/form/fmdispatch.cxx | 229 -- svx/source/form/fmshimp.cxx | 38 +- svx/source/form/fmtools.cxx | 170 -- svx/source/form/formcontroller.cxx | 4286 +++++++++++++++++++++++++++ svx/source/form/formdispatchinterceptor.cxx | 213 ++ svx/source/form/formfeaturedispatcher.cxx | 241 ++ svx/source/form/makefile.mk | 5 +- svx/source/inc/confirmdelete.hxx | 3 - svx/source/inc/delayedevent.hxx | 4 - svx/source/inc/fmcontrolbordermanager.hxx | 3 - svx/source/inc/fmcontrollayout.hxx | 3 - svx/source/inc/fmctrler.hxx | 600 ---- svx/source/inc/fmdispatch.hxx | 158 - svx/source/inc/fmshimp.hxx | 2 - svx/source/inc/fmtools.hxx | 107 - svx/source/inc/formcontroller.hxx | 592 ++++ svx/source/inc/formcontrolling.hxx | 3 - svx/source/inc/formdispatchinterceptor.hxx | 118 + svx/source/inc/formfeaturedispatcher.hxx | 157 + 24 files changed, 5614 insertions(+), 5584 deletions(-) delete mode 100644 svx/source/form/fmctrler.cxx delete mode 100644 svx/source/form/fmdispatch.cxx create mode 100644 svx/source/form/formcontroller.cxx create mode 100644 svx/source/form/formdispatchinterceptor.cxx create mode 100644 svx/source/form/formfeaturedispatcher.cxx delete mode 100644 svx/source/inc/fmctrler.hxx delete mode 100644 svx/source/inc/fmdispatch.hxx create mode 100644 svx/source/inc/formcontroller.hxx create mode 100644 svx/source/inc/formdispatchinterceptor.hxx create mode 100644 svx/source/inc/formfeaturedispatcher.hxx diff --git a/svx/source/form/confirmdelete.cxx b/svx/source/form/confirmdelete.cxx index 819677c3f495..9bb4ab7ede49 100644 --- a/svx/source/form/confirmdelete.cxx +++ b/svx/source/form/confirmdelete.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: confirmdelete.cxx,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/delayedevent.cxx b/svx/source/form/delayedevent.cxx index c6bce8efec98..a185ef04d389 100644 --- a/svx/source/form/delayedevent.cxx +++ b/svx/source/form/delayedevent.cxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.cxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmcontrolbordermanager.cxx b/svx/source/form/fmcontrolbordermanager.cxx index 17bd10346302..5c6397662844 100644 --- a/svx/source/form/fmcontrolbordermanager.cxx +++ b/svx/source/form/fmcontrolbordermanager.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmcontrollayout.cxx b/svx/source/form/fmcontrollayout.cxx index 92e987db796c..bc0e15cd9647 100644 --- a/svx/source/form/fmcontrollayout.cxx +++ b/svx/source/form/fmcontrollayout.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx deleted file mode 100644 index cc3855518889..000000000000 --- a/svx/source/form/fmctrler.cxx +++ /dev/null @@ -1,4253 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" - -#include "confirmdelete.hxx" -#include "fmcontrolbordermanager.hxx" -#include "fmcontrollayout.hxx" -#include "fmctrler.hxx" -#include "fmdispatch.hxx" -#include "fmdocumentclassification.hxx" -#include "fmprop.hrc" -#include "fmresids.hrc" -#include "fmservs.hxx" -#include "fmshimp.hxx" -#include "fmtools.hxx" -#include "fmurl.hxx" -#include "svx/dialmgr.hxx" -#include "svx/fmshell.hxx" -#include "svx/fmview.hxx" -#include "svx/sdrpagewindow.hxx" -#include "svx/svdpagv.hxx" -#include "trace.hxx" - -/** === begin UNO includes === **/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/** === end UNO includes === **/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ::com::sun::star; -using namespace ::comphelper; -using namespace ::connectivity; -using namespace ::connectivity::simple; - -//------------------------------------------------------------------ -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) -{ - return *( new ::svxform::FormController( _rxORB ) ); -} - -namespace svxform -{ - - /** === begin UNO using === **/ - using ::com::sun::star::sdb::XColumn; - using ::com::sun::star::awt::XControl; - using ::com::sun::star::awt::XTabController; - using ::com::sun::star::awt::XToolkit; - using ::com::sun::star::awt::XWindowPeer; - using ::com::sun::star::form::XGrid; - using ::com::sun::star::beans::XPropertySet; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::sdbcx::XColumnsSupplier; - using ::com::sun::star::container::XIndexAccess; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::Reference; - using ::com::sun::star::beans::XPropertySetInfo; - using ::com::sun::star::beans::PropertyValue; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::lang::IndexOutOfBoundsException; - using ::com::sun::star::sdb::XInteractionSupplyParameters; - using ::com::sun::star::awt::XTextComponent; - using ::com::sun::star::awt::XTextListener; - using ::com::sun::star::uno::Any; - using ::com::sun::star::frame::XDispatch; - using ::com::sun::star::lang::XMultiServiceFactory; - using ::com::sun::star::uno::XAggregation; - using ::com::sun::star::uno::Type; - using ::com::sun::star::lang::IllegalArgumentException; - using ::com::sun::star::sdbc::XConnection; - using ::com::sun::star::sdbc::XRowSet; - using ::com::sun::star::sdbc::XDatabaseMetaData; - using ::com::sun::star::util::XNumberFormatsSupplier; - using ::com::sun::star::util::XNumberFormatter; - using ::com::sun::star::sdbcx::XColumnsSupplier; - using ::com::sun::star::container::XNameAccess; - using ::com::sun::star::lang::EventObject; - using ::com::sun::star::beans::Property; - using ::com::sun::star::container::XEnumeration; - using ::com::sun::star::form::XFormComponent; - using ::com::sun::star::form::runtime::XFormOperations; - using ::com::sun::star::form::runtime::FilterEvent; - using ::com::sun::star::form::runtime::XFilterControllerListener; - using ::com::sun::star::awt::XControlContainer; - using ::com::sun::star::container::XIdentifierReplace; - using ::com::sun::star::lang::WrappedTargetException; - using ::com::sun::star::form::XFormControllerListener; - using ::com::sun::star::awt::XWindow; - using ::com::sun::star::sdbc::XResultSet; - using ::com::sun::star::awt::XControlModel; - using ::com::sun::star::awt::XTabControllerModel; - using ::com::sun::star::beans::PropertyChangeEvent; - using ::com::sun::star::form::validation::XValidatableFormComponent; - using ::com::sun::star::form::XLoadable; - using ::com::sun::star::script::XEventAttacherManager; - using ::com::sun::star::container::XContainer; - using ::com::sun::star::form::XBoundControl; - using ::com::sun::star::beans::XPropertyChangeListener; - using ::com::sun::star::awt::TextEvent; - using ::com::sun::star::form::XBoundComponent; - using ::com::sun::star::awt::XCheckBox; - using ::com::sun::star::awt::XComboBox; - using ::com::sun::star::awt::XListBox; - using ::com::sun::star::awt::ItemEvent; - using ::com::sun::star::util::XModifyListener; - using ::com::sun::star::form::XReset; - using ::com::sun::star::frame::XDispatchProviderInterception; - using ::com::sun::star::form::XGridControl; - using ::com::sun::star::awt::XVclWindowPeer; - using ::com::sun::star::form::validation::XValidator; - using ::com::sun::star::awt::FocusEvent; - using ::com::sun::star::sdb::SQLContext; - using ::com::sun::star::container::XChild; - using ::com::sun::star::form::TabulatorCycle_RECORDS; - using ::com::sun::star::container::ContainerEvent; - using ::com::sun::star::lang::DisposedException; - using ::com::sun::star::lang::Locale; - using ::com::sun::star::beans::NamedValue; - using ::com::sun::star::lang::NoSupportException; - using ::com::sun::star::sdb::RowChangeEvent; - using ::com::sun::star::frame::XStatusListener; - using ::com::sun::star::frame::XDispatchProviderInterceptor; - using ::com::sun::star::sdb::SQLErrorEvent; - using ::com::sun::star::form::DatabaseParameterEvent; - using ::com::sun::star::sdb::ParametersRequest; - using ::com::sun::star::task::XInteractionRequest; - using ::com::sun::star::util::URL; - using ::com::sun::star::frame::FeatureStateEvent; - using ::com::sun::star::form::runtime::XFormControllerContext; - using ::com::sun::star::task::XInteractionHandler; - /** === end UNO using === **/ - namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; - namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; - namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason; - namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction; - -//============================================================================== -// ColumnInfo -//============================================================================== -struct ColumnInfo -{ - // information about the column itself - Reference< XColumn > xColumn; - sal_Int32 nNullable; - sal_Bool bAutoIncrement; - sal_Bool bReadOnly; - ::rtl::OUString sName; - - // information about the control(s) bound to this column - - /// the first control which is bound to the given column, and which requires input - Reference< XControl > xFirstControlWithInputRequired; - /** the first grid control which contains a column which is bound to the given database column, and requires - input - */ - Reference< XGrid > xFirstGridWithInputRequiredColumn; - /** if xFirstControlWithInputRequired is a grid control, then nRequiredGridColumn specifies the position - of the grid column which is actually bound - */ - sal_Int32 nRequiredGridColumn; - - ColumnInfo() - :xColumn() - ,nNullable( ColumnValue::NULLABLE_UNKNOWN ) - ,bAutoIncrement( sal_False ) - ,bReadOnly( sal_False ) - ,sName() - ,xFirstControlWithInputRequired() - ,xFirstGridWithInputRequiredColumn() - ,nRequiredGridColumn( -1 ) - { - } -}; - -//============================================================================== -//= ColumnInfoCache -//============================================================================== -class ColumnInfoCache -{ -public: - ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier ); - - size_t getColumnCount() const { return m_aColumns.size(); } - const ColumnInfo& getColumnInfo( size_t _pos ); - - bool controlsInitialized() const { return m_bControlsInitialized; } - void initializeControls( const Sequence< Reference< XControl > >& _rControls ); - void deinitializeControls(); - -private: - typedef ::std::vector< ColumnInfo > ColumnInfos; - ColumnInfos m_aColumns; - bool m_bControlsInitialized; -}; - -//------------------------------------------------------------------------------ -ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier ) - :m_aColumns() - ,m_bControlsInitialized( false ) -{ - try - { - m_aColumns.clear(); - - Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW ); - Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW ); - sal_Int32 nColumnCount = xColumns->getCount(); - m_aColumns.reserve( nColumnCount ); - - Reference< XPropertySet > xColumnProps; - for ( sal_Int32 i = 0; i < nColumnCount; ++i ) - { - ColumnInfo aColInfo; - aColInfo.xColumn.set( xColumns->getByIndex(i), UNO_QUERY_THROW ); - - xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW ); - OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable ); - OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_AUTOINCREMENT ) >>= aColInfo.bAutoIncrement ); - OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_NAME ) >>= aColInfo.sName ); - OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISREADONLY ) >>= aColInfo.bReadOnly ); - - m_aColumns.push_back( aColInfo ); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -//------------------------------------------------------------------------------ -namespace -{ - bool lcl_isBoundTo( const Reference< XPropertySet >& _rxControlModel, const Reference< XInterface >& _rxNormDBField ) - { - Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY ); - return ( xNormBoundField.get() == _rxNormDBField.get() ); - } - - bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel ) - { - sal_Bool bInputRequired = sal_True; - OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired ); - return ( bInputRequired != sal_False ); - } - - void lcl_resetColumnControlInfo( ColumnInfo& _rColInfo ) - { - _rColInfo.xFirstControlWithInputRequired.clear(); - _rColInfo.xFirstGridWithInputRequiredColumn.clear(); - _rColInfo.nRequiredGridColumn = -1; - } -} - -//------------------------------------------------------------------------------ -void ColumnInfoCache::deinitializeControls() -{ - for ( ColumnInfos::iterator col = m_aColumns.begin(); - col != m_aColumns.end(); - ++col - ) - { - lcl_resetColumnControlInfo( *col ); - } -} - -//------------------------------------------------------------------------------ -void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls ) -{ - try - { - // for every of our known columns, find the controls which are bound to this column - for ( ColumnInfos::iterator col = m_aColumns.begin(); - col != m_aColumns.end(); - ++col - ) - { - OSL_ENSURE( !col->xFirstControlWithInputRequired.is() && !col->xFirstGridWithInputRequiredColumn.is() - && ( col->nRequiredGridColumn == -1 ), "ColumnInfoCache::initializeControls: called me twice?" ); - - lcl_resetColumnControlInfo( *col ); - - Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW ); - - const Reference< XControl >* pControl( _rControls.getConstArray() ); - const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() ); - for ( ; pControl != pControlEnd; ++pControl ) - { - if ( !pControl->is() ) - continue; - - Reference< XPropertySet > xModel( (*pControl)->getModel(), UNO_QUERY_THROW ); - Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW ); - - // special handling for grid controls - Reference< XGrid > xGrid( *pControl, UNO_QUERY ); - if ( xGrid.is() ) - { - Reference< XIndexAccess > xGridColAccess( xModel, UNO_QUERY_THROW ); - sal_Int32 gridColCount = xGridColAccess->getCount(); - sal_Int32 gridCol = 0; - for ( gridCol = 0; gridCol < gridColCount; ++gridCol ) - { - Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW ); - - if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn ) - || !lcl_isInputRequired( xGridColumnModel ) - ) - continue; // with next grid column - - break; - } - - if ( gridCol < gridColCount ) - { - // found a grid column which is bound to the given - col->xFirstGridWithInputRequiredColumn = xGrid; - col->nRequiredGridColumn = gridCol; - break; - } - - continue; // with next control - } - - if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) - || !lcl_isBoundTo( xModel, xNormColumn ) - || !lcl_isInputRequired( xModel ) - ) - continue; // with next control - - break; - } - - if ( pControl == pControlEnd ) - // did not find a control which is bound to this particular column, and for which the input is required - continue; // with next DB column - - col->xFirstControlWithInputRequired = *pControl; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - m_bControlsInitialized = true; -} - -//------------------------------------------------------------------------------ -const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos ) -{ - if ( _pos >= m_aColumns.size() ) - throw IndexOutOfBoundsException(); - - return m_aColumns[ _pos ]; -} - -//================================================================== -// OParameterContinuation -//================================================================== -class OParameterContinuation : public OInteraction< XInteractionSupplyParameters > -{ - Sequence< PropertyValue > m_aValues; - -public: - OParameterContinuation() { } - - Sequence< PropertyValue > getValues() const { return m_aValues; } - -// XInteractionSupplyParameters - virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException); -}; - -//------------------------------------------------------------------ -void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException) -{ - m_aValues = _rValues; -} - -//================================================================== -// FmXAutoControl -//================================================================== -struct FmFieldInfo -{ - rtl::OUString aFieldName; - Reference< XPropertySet > xField; - Reference< XTextComponent > xText; - - FmFieldInfo(const Reference< XPropertySet >& _xField, const Reference< XTextComponent >& _xText) - :xField(_xField) - ,xText(_xText) - {xField->getPropertyValue(FM_PROP_NAME) >>= aFieldName;} -}; - -//================================================================== -// FmXAutoControl -//================================================================== -class FmXAutoControl: public UnoControl - -{ - friend Reference< XInterface > SAL_CALL FmXAutoControl_NewInstance_Impl(); - -public: - FmXAutoControl(){} - - virtual ::rtl::OUString GetComponentServiceName() {return ::rtl::OUString::createFromAscii("Edit");} - virtual void SAL_CALL createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException ); - -protected: - virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal ); -}; - -//------------------------------------------------------------------------------ -void FmXAutoControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException ) -{ - UnoControl::createPeer( rxToolkit, rParentPeer ); - - Reference< XTextComponent > xText(getPeer() , UNO_QUERY); - if (xText.is()) - { - xText->setText(::rtl::OUString(String(SVX_RES(RID_STR_AUTOFIELD)))); - xText->setEditable(sal_False); - } -} - -//------------------------------------------------------------------------------ -void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal ) -{ - // these properties are ignored - if (rPropName == FM_PROP_TEXT) - return; - - UnoControl::ImplSetPeerProperty( rPropName, rVal ); -} - -//------------------------------------------------------------------------------ -IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) -{ - activateTabOrder(); - return 1; -} - -//------------------------------------------------------------------------------ -struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch >, bool > -{ - bool operator()( const Reference< XDispatch >& _rxDispatcher ) const - { - static_cast< ::svx::OSingleFeatureDispatcher* >( _rxDispatcher.get() )->updateAllListeners(); - // the return is a dummy only so we can use this struct in a std::compose1 call - return true; - } -}; -//.............................................................................. -IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - for ( ::std::set< sal_Int32 >::const_iterator aLoop = m_aInvalidFeatures.begin(); - aLoop != m_aInvalidFeatures.end(); - ++aLoop - ) - { - DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( *aLoop ); - if ( aDispatcherPos != m_aFeatureDispatchers.end() ) - { - // TODO: for the real and actual listener notifications, we should release - // our mutex - UpdateAllListeners( )( aDispatcherPos->second ); - } - } - return 1; -} - -/*************************************************************************/ - -DBG_NAME( FormController ) -//------------------------------------------------------------------ -FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ) - :FormController_BASE( m_aMutex ) - ,OPropertySetHelper( FormController_BASE::rBHelper ) - ,OSQLParserClient(_rxORB) - ,m_xORB(_rxORB) - ,m_aActivateListeners(m_aMutex) - ,m_aModifyListeners(m_aMutex) - ,m_aErrorListeners(m_aMutex) - ,m_aDeleteListeners(m_aMutex) - ,m_aRowSetApproveListeners(m_aMutex) - ,m_aParameterListeners(m_aMutex) - ,m_aFilterListeners(m_aMutex) - ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) - ,m_aControllerFeatures( _rxORB, this ) - ,m_aMode( DATA_MODE ) - ,m_aLoadEvent( LINK( this, FormController, OnLoad ) ) - ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) - ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) - ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) ) - ,m_nCurrentFilterPosition(-1) - ,m_bCurrentRecordModified(sal_False) - ,m_bCurrentRecordNew(sal_False) - ,m_bLocked(sal_False) - ,m_bDBConnection(sal_False) - ,m_bCycle(sal_False) - ,m_bCanInsert(sal_False) - ,m_bCanUpdate(sal_False) - ,m_bCommitLock(sal_False) - ,m_bModified(sal_False) - ,m_bControlsSorted(sal_False) - ,m_bFiltering(sal_False) - ,m_bAttachEvents(sal_True) - ,m_bDetachEvents(sal_True) - ,m_bAttemptedHandlerCreation( false ) -{ - DBG_CTOR( FormController, NULL ); - - ::comphelper::increment(m_refCount); - { - { - m_xAggregate = Reference< XAggregation >( - m_xORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.TabController" ) ), - UNO_QUERY - ); - DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" ); - m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY ); - } - - if ( m_xAggregate.is() ) - m_xAggregate->setDelegator( *this ); - } - ::comphelper::decrement(m_refCount); - - m_aTabActivationTimer.SetTimeout( 500 ); - m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) ); - - m_aFeatureInvalidationTimer.SetTimeout( 200 ); - m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) ); -} - -//------------------------------------------------------------------ -FormController::~FormController() -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - - m_aLoadEvent.CancelPendingCall(); - m_aToggleEvent.CancelPendingCall(); - m_aActivationEvent.CancelPendingCall(); - m_aDeactivationEvent.CancelPendingCall(); - - if ( m_aTabActivationTimer.IsActive() ) - m_aTabActivationTimer.Stop(); - } - - if ( m_aFeatureInvalidationTimer.IsActive() ) - m_aFeatureInvalidationTimer.Stop(); - - disposeAllFeaturesAndDispatchers(); - - // Freigeben der Aggregation - if ( m_xAggregate.is() ) - { - m_xAggregate->setDelegator( NULL ); - m_xAggregate.clear(); - } - - DELETEZ( m_pControlBorderManager ); - - DBG_DTOR( FormController, NULL ); -} - -// ----------------------------------------------------------------------------- -void SAL_CALL FormController::acquire() throw () -{ - FormController_BASE::acquire(); -} - -// ----------------------------------------------------------------------------- -void SAL_CALL FormController::release() throw () -{ - FormController_BASE::release(); -} - -//------------------------------------------------------------------ -Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException) -{ - Any aRet = FormController_BASE::queryInterface( _rType ); - if ( !aRet.hasValue() ) - aRet = OPropertySetHelper::queryInterface( _rType ); - if ( !aRet.hasValue() ) - aRet = m_xAggregate->queryAggregation( _rType ); - return aRet; -} - -//------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException ) -{ - static ::cppu::OImplementationId* pId = NULL; - if ( !pId ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pId ) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -//------------------------------------------------------------------------------ -Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException) -{ - return comphelper::concatSequences( - FormController_BASE::getTypes(), - ::cppu::OPropertySetHelper::getTypes() - ); -} - -// XServiceInfo -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) -{ - Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames()); - const ::rtl::OUString * pArray = aSNL.getConstArray(); - for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return sal_True; - return sal_False; -} - -//------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException ) -{ - return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.FormController" ); -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException ) -{ - // service names which are supported only, but cannot be used to created an - // instance at a service factory - Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 ); - aNonCreatableServiceNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormControllerDispatcher" ) ); - - // services which can be used to created an instance at a service factory - Sequence< ::rtl::OUString > aCreatableServiceNames( getSupportedServiceNames_Static() ); - return ::comphelper::concatSequences( aCreatableServiceNames, aNonCreatableServiceNames ); -} - -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) -{ - return sal_True; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(m_aMutex); - if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source)) - m_bModified = sal_False; -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) -{ - static Sequence< ::rtl::OUString> aServices; - if (!aServices.getLength()) - { - aServices.realloc(2); - aServices.getArray()[0] = FM_FORM_CONTROLLER; - aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); - } - return aServices; -} - -// ----------------------------------------------------------------------------- -namespace -{ - struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void > - { - void operator()( const Reference< XTextComponent >& _rxText ) - { - _rxText->setText( ::rtl::OUString() ); - } - }; - - struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void > - { - RemoveComponentTextListener( const Reference< XTextListener >& _rxListener ) - :m_xListener( _rxListener ) - { - } - - void operator()( const Reference< XTextComponent >& _rxText ) - { - _rxText->removeTextListener( m_xListener ); - } - - private: - Reference< XTextListener > m_xListener; - }; -} - -// ----------------------------------------------------------------------------- -void FormController::impl_setTextOnAllFilter_throw() -{ - // reset the text for all controls - ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() ); - - if ( m_aFilterRows.empty() ) - // nothing to do anymore - return; - - if ( m_nCurrentFilterPosition < 0 ) - return; - - // set the text for all filters - OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition, - "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" ); - - if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() ) - { - FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; - for ( FmFilterRow::const_iterator iter2 = rRow.begin(); - iter2 != rRow.end(); - ++iter2 - ) - { - iter2->first->setText( iter2->second ); - } - } -} -// OPropertySetHelper -//------------------------------------------------------------------------------ -sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, - sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) - throw( IllegalArgumentException ) -{ - return sal_False; -} - -//------------------------------------------------------------------------------ -void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) - throw( Exception ) -{ -} - -//------------------------------------------------------------------------------ -void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const -{ - switch (nHandle) - { - case FM_ATTR_FILTER: - { - ::rtl::OUStringBuffer aFilter; - OStaticDataAccessTools aStaticTools; - Reference xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY))); - if (xConnection.is()) - { - Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); - Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); - xFormatter->attachNumberFormatsSupplier(xFormatSupplier); - - Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY); - Reference< XNameAccess> xFields(xSupplyCols->getColumns(), UNO_QUERY); - - ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() ); - - // now add the filter rows - try - { - for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row ) - { - const FmFilterRow& rRow = *row; - - if ( rRow.empty() ) - continue; - - if ( aFilter.getLength() ) - aFilter.appendAscii( " OR " ); - - aFilter.appendAscii( "( " ); - for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) - { - // get the field of the controls map - Reference< XControl > xControl( condition->first, UNO_QUERY_THROW ); - Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); - Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); - if ( condition != rRow.begin() ) - aFilter.appendAscii( " AND " ); - - ::rtl::OUString sFilterValue( condition->second ); - - ::rtl::OUString sErrorMsg, sCriteria; - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); - OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); - if ( xParseNode.is() ) - { - // don't use a parse context here, we need it unlocalized - xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); - aFilter.append( sCriteria ); - } - } - aFilter.appendAscii( " )" ); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - aFilter.setLength(0); - } - } - rValue <<= aFilter.makeStringAndClear(); - } - break; - - case FM_ATTR_FORM_OPERATIONS: - rValue <<= m_aControllerFeatures->getFormOperations(); - break; - } -} - -//------------------------------------------------------------------------------ -Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException ) -{ - static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); - return xInfo; -} - -//------------------------------------------------------------------------------ -#define DECL_PROP_CORE(varname, type) \ -pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((const type*)0), - - -#define DECL_PROP1(varname, type, attrib1) \ - DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1) - -//------------------------------------------------------------------------------ -void FormController::fillProperties( - Sequence< Property >& /* [out] */ _rProps, - Sequence< Property >& /* [out] */ /*_rAggregateProps*/ - ) const -{ - _rProps.realloc(2); - sal_Int32 nPos = 0; - Property* pDesc = _rProps.getArray(); - DECL_PROP1(FILTER, rtl::OUString, READONLY); - DECL_PROP1(FORM_OPERATIONS, Reference< XFormOperations >, READONLY); -} - -//------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& FormController::getInfoHelper() -{ - return *getArrayHelper(); -} - -// XFilterController -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) -{ - m_aFilterListeners.addInterface( _Listener ); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) -{ - m_aFilterListeners.removeInterface( _Listener ); -} - -//------------------------------------------------------------------------------ -::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - return m_aFilterComponents.size(); -} - -//------------------------------------------------------------------------------ -::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - return m_aFilterRows.size(); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] ); - xText->setText( _PredicateExpression ); - - FmFilterRow& rFilterRow = m_aFilterRows[ _Term ]; - if ( _PredicateExpression.getLength() ) - rFilterRow[ xText ] = _PredicateExpression; - else - rFilterRow.erase( xText ); -} - -//------------------------------------------------------------------------------ -Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY ); -} - -//------------------------------------------------------------------------------ -Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() ); - sal_Int32 termIndex = 0; - for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); - row != m_aFilterRows.end(); - ++row, ++termIndex - ) - { - const FmFilterRow& rRow( *row ); - - Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() ); - sal_Int32 componentIndex = 0; - for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin(); - comp != m_aFilterComponents.end(); - ++comp, ++componentIndex - ) - { - FmFilterRow::const_iterator predicate = rRow.find( *comp ); - if ( predicate != rRow.end() ) - aConjunction[ componentIndex ] = predicate->second; - } - - aExpressions[ termIndex ] = aConjunction; - } - - return aExpressions; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException) -{ - // SYNCHRONIZED --> - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - // if the to-be-deleted row is our current row, we need to shift - if ( _Term == m_nCurrentFilterPosition ) - { - if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) ) - ++m_nCurrentFilterPosition; - else - --m_nCurrentFilterPosition; - } - - FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term; - m_aFilterRows.erase( pos ); - - // adjust m_nCurrentFilterPosition if the removed row preceeded it - if ( _Term < m_nCurrentFilterPosition ) - --m_nCurrentFilterPosition; - - OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ), - "FormController::removeDisjunctiveTerm: inconsistency!" ); - - // update the texts in the filter controls - impl_setTextOnAllFilter_throw(); - - FilterEvent aEvent; - aEvent.Source = *this; - aEvent.DisjunctiveTerm = _Term; - aGuard.clear(); - // <-- SYNCHRONIZED - - m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent ); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException) -{ - // SYNCHRONIZED --> - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - impl_appendEmptyFilterRow( aGuard ); - // <-- SYNCHRONIZED -} - -//------------------------------------------------------------------------------ -::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - return m_nCurrentFilterPosition; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - if ( _ActiveTerm == getActiveTerm() ) - return; - - m_nCurrentFilterPosition = _ActiveTerm; - impl_setTextOnAllFilter_throw(); -} - -// XElementAccess -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return !m_aChilds.empty(); -} - -//------------------------------------------------------------------------------ -Type SAL_CALL FormController::getElementType(void) throw( RuntimeException ) -{ - return ::getCppuType((const Reference< XFormController>*)0); - -} - -// XEnumerationAccess -//------------------------------------------------------------------------------ -Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return new ::comphelper::OEnumerationByIndex(this); -} - -// XIndexAccess -//------------------------------------------------------------------------------ -sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return m_aChilds.size(); -} - -//------------------------------------------------------------------------------ -Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (Index < 0 || - Index >= (sal_Int32)m_aChilds.size()) - throw IndexOutOfBoundsException(); - - return makeAny( m_aChilds[ Index ] ); -} - -// EventListener -//------------------------------------------------------------------------------ -void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException ) -{ - // Ist der Container disposed worden - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XControlContainer > xContainer(e.Source, UNO_QUERY); - if (xContainer.is()) - { - setContainer(Reference< XControlContainer > ()); - } - else - { - // ist ein Control disposed worden - Reference< XControl > xControl(e.Source, UNO_QUERY); - if (xControl.is()) - { - if (getContainer().is()) - removeControl(xControl); - } - } -} - -// OComponentHelper -//----------------------------------------------------------------------------- -void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) -{ - for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin(); - aDispatcher != m_aFeatureDispatchers.end(); - ++aDispatcher - ) - { - try - { - ::comphelper::disposeComponent( aDispatcher->second ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - m_aFeatureDispatchers.clear(); - m_aControllerFeatures.dispose(); -} - -//----------------------------------------------------------------------------- -void FormController::disposing(void) -{ - EventObject aEvt( *this ); - - // if we're still active, simulate a "deactivated" event - if ( m_xActiveControl.is() ) - m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt ); - - // notify all our listeners - m_aActivateListeners.disposeAndClear(aEvt); - m_aModifyListeners.disposeAndClear(aEvt); - m_aErrorListeners.disposeAndClear(aEvt); - m_aDeleteListeners.disposeAndClear(aEvt); - m_aRowSetApproveListeners.disposeAndClear(aEvt); - m_aParameterListeners.disposeAndClear(aEvt); - m_aFilterListeners.disposeAndClear(aEvt); - - removeBoundFieldListener(); - stopFiltering(); - - m_pControlBorderManager->restoreAll(); - - m_aFilterRows.clear(); - - ::osl::MutexGuard aGuard( m_aMutex ); - m_xActiveControl = NULL; - implSetCurrentControl( NULL ); - - // clean up our children - for (FmFormControllers::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) - { - // search the position of the model within the form - Reference< XFormComponent > xForm((*i)->getModel(), UNO_QUERY); - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - - m_xModelAsIndex->getByIndex( --nPos ) >>= xTemp; - if ( xForm.get() == xTemp.get() ) - { - Reference< XInterface > xIfc( *i, UNO_QUERY ); - m_xModelAsManager->detach( nPos, xIfc ); - break; - } - } - - Reference< XComponent > (*i, UNO_QUERY)->dispose(); - } - m_aChilds.clear(); - - disposeAllFeaturesAndDispatchers(); - - if (m_bDBConnection) - unload(); - - setContainer( NULL ); - setModel( NULL ); - setParent( NULL ); - - ::comphelper::disposeComponent( m_xComposer ); - - m_xORB = NULL; - m_bDBConnection = sal_False; -} - -//------------------------------------------------------------------------------ -namespace -{ - static bool lcl_shouldUseDynamicControlBorder( const Reference< XInterface >& _rxForm, const Any& _rDynamicColorProp ) - { - bool bDoUse = false; - if ( !( _rDynamicColorProp >>= bDoUse ) ) - { - DocumentType eDocType = DocumentClassification::classifyHostDocument( _rxForm ); - return ControlLayouter::useDynamicBorderColor( eDocType ); - } - return bDoUse; - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - if ( evt.PropertyName == FM_PROP_BOUNDFIELD ) - { - Reference xOldBound; - evt.OldValue >>= xOldBound; - if ( !xOldBound.is() && evt.NewValue.hasValue() ) - { - Reference< XControlModel > xControlModel(evt.Source,UNO_QUERY); - Reference< XControl > xControl = findControl(m_aControls,xControlModel,sal_False,sal_False); - if ( xControl.is() ) - { - startControlModifyListening( xControl ); - Reference xProp(xControlModel,UNO_QUERY); - if ( xProp.is() ) - xProp->removePropertyChangeListener(FM_PROP_BOUNDFIELD, this); - } - } - } - else - { - sal_Bool bModifiedChanged = (evt.PropertyName == FM_PROP_ISMODIFIED); - sal_Bool bNewChanged = (evt.PropertyName == FM_PROP_ISNEW); - if (bModifiedChanged || bNewChanged) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if (bModifiedChanged) - m_bCurrentRecordModified = ::comphelper::getBOOL(evt.NewValue); - else - m_bCurrentRecordNew = ::comphelper::getBOOL(evt.NewValue); - - // toggle the locking - if (m_bLocked != determineLockState()) - { - m_bLocked = !m_bLocked; - setLocks(); - if (isListeningForChanges()) - startListening(); - else - stopListening(); - } - - if ( bNewChanged ) - m_aToggleEvent.Call(); - - if (!m_bCurrentRecordModified) - m_bModified = sal_False; - } - else if ( evt.PropertyName == FM_PROP_DYNAMIC_CONTROL_BORDER ) - { - bool bEnable = lcl_shouldUseDynamicControlBorder( evt.Source, evt.NewValue ); - if ( bEnable ) - { - m_pControlBorderManager->enableDynamicBorderColor(); - if ( m_xActiveControl.is() ) - m_pControlBorderManager->focusGained( m_xActiveControl.get() ); - } - else - { - m_pControlBorderManager->disableDynamicBorderColor(); - } - } - } -} - -//------------------------------------------------------------------------------ -bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) -{ - bool bSuccess = false; - try - { - Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY ); - DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); - if ( xContainer.is() ) - { - // look up the ID of _rxExistentControl - Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() ); - const sal_Int32* pIdentifiers = aIdentifiers.getConstArray(); - const sal_Int32* pIdentifiersEnd = aIdentifiers.getConstArray() + aIdentifiers.getLength(); - for ( ; pIdentifiers != pIdentifiersEnd; ++pIdentifiers ) - { - Reference< XControl > xCheck( xContainer->getByIdentifier( *pIdentifiers ), UNO_QUERY ); - if ( xCheck == _rxExistentControl ) - break; - } - DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" ); - if ( pIdentifiers != pIdentifiersEnd ) - { - bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() ); - bool bReplacedWasCurrent = ( m_xCurrentControl.get() == _rxExistentControl.get() ); - - if ( bReplacedWasActive ) - { - m_xActiveControl = NULL; - implSetCurrentControl( NULL ); - } - else if ( bReplacedWasCurrent ) - { - implSetCurrentControl( _rxNewControl ); - } - - // carry over the model - _rxNewControl->setModel( _rxExistentControl->getModel() ); - - xContainer->replaceByIdentifer( *pIdentifiers, makeAny( _rxNewControl ) ); - bSuccess = true; - - if ( bReplacedWasActive ) - { - Reference< XWindow > xControlWindow( _rxNewControl, UNO_QUERY ); - if ( xControlWindow.is() ) - xControlWindow->setFocus(); - } - } - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl ); - ::comphelper::disposeComponent( xDisposeIt ); - return bSuccess; -} - -//------------------------------------------------------------------------------ -void FormController::toggleAutoFields(sal_Bool bAutoFields) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - - Sequence< Reference< XControl > > aControlsCopy( m_aControls ); - const Reference< XControl >* pControls = aControlsCopy.getConstArray(); - sal_Int32 nControls = aControlsCopy.getLength(); - - if (bAutoFields) - { - // as we don't want new controls to be attached to the scripting environment - // we change attach flags - m_bAttachEvents = sal_False; - for (sal_Int32 i = nControls; i > 0;) - { - Reference< XControl > xControl = pControls[--i]; - if (xControl.is()) - { - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // does the model use a bound field ? - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - - // is it a autofield? - if ( xField.is() - && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField ) - && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_AUTOINCREMENT ) ) - ) - { - replaceControl( xControl, new FmXAutoControl ); - } - } - } - } - m_bAttachEvents = sal_True; - } - else - { - m_bDetachEvents = sal_False; - for (sal_Int32 i = nControls; i > 0;) - { - Reference< XControl > xControl = pControls[--i]; - if (xControl.is()) - { - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // does the model use a bound field ? - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - - // is it a autofield? - if ( xField.is() - && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField ) - && ::comphelper::getBOOL( xField->getPropertyValue(FM_PROP_AUTOINCREMENT ) ) - ) - { - ::rtl::OUString sServiceName; - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); - replaceControl( xControl, xNewControl ); - } - } - } - } - m_bDetachEvents = sal_True; - } -} - -//------------------------------------------------------------------------------ -IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - toggleAutoFields(m_bCurrentRecordNew); - return 1L; -} - -// XTextListener -//------------------------------------------------------------------------------ -void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException ) -{ - // SYNCHRONIZED --> - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - if (m_bFiltering) - { - Reference< XTextComponent > xText(e.Source,UNO_QUERY); - ::rtl::OUString aText = xText->getText(); - - if ( m_aFilterRows.empty() ) - appendEmptyDisjunctiveTerm(); - - // Suchen der aktuellen Row - if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) ) - { - OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" ); - return; - } - - FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; - - // do we have a new filter - if (aText.getLength()) - rRow[xText] = aText; - else - { - // do we have the control in the row - FmFilterRow::iterator iter = rRow.find(xText); - // erase the entry out of the row - if (iter != rRow.end()) - rRow.erase(iter); - } - - // multiplex the event to our FilterControllerListeners - FilterEvent aEvent; - aEvent.Source = *this; - aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin(); - aEvent.DisjunctiveTerm = getActiveTerm(); - aEvent.PredicateExpression = aText; - - aGuard.clear(); - // <-- SYNCHRONIZED - - // notify the changed filter expression - m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent ); - } - else - impl_onModify(); -} - -// XItemListener -//------------------------------------------------------------------------------ -void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - impl_onModify(); -} - -// XModificationBroadcaster -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_aModifyListeners.addInterface( l ); -} - -//------------------------------------------------------------------------------ -void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_aModifyListeners.removeInterface( l ); -} - -// XModificationListener -//------------------------------------------------------------------------------ -void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - try - { - if ( _rEvent.Source != m_xActiveControl ) - { // let this control grab the focus - // (this case may happen if somebody moves the scroll wheel of the mouse over a control - // which does not have the focus) - // 85511 - 29.05.2001 - frank.schoenheit@germany.sun.com - // - // also, it happens when an image control gets a new image by double-clicking it - // #i88458# / 2009-01-12 / frank.schoenheit@sun.com - Reference< XWindow > xControlWindow( _rEvent.Source, UNO_QUERY_THROW ); - xControlWindow->setFocus(); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - impl_onModify(); -} - -//------------------------------------------------------------------------------ -void FormController::impl_checkDisposed_throw() const -{ - if ( impl_isDisposed_nofail() ) - throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) ); -} - -//------------------------------------------------------------------------------ -void FormController::impl_onModify() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( !m_bModified ) - m_bModified = sal_True; - } - - EventObject aEvt(static_cast(this)); - m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt ); -} - -//------------------------------------------------------------------------------ -void FormController::impl_addFilterRow( const FmFilterRow& _row ) -{ - m_aFilterRows.push_back( _row ); - - if ( m_aFilterRows.size() == 1 ) - { // that's the first row ever - OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" ); - m_nCurrentFilterPosition = 0; - } -} - -//------------------------------------------------------------------------------ -void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) -{ - // SYNCHRONIZED --> - impl_addFilterRow( FmFilterRow() ); - - // notify the listeners - FilterEvent aEvent; - aEvent.Source = *this; - aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1; - _rClearBeforeNotify.clear(); - // <-- SYNCHRONIZED - m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent ); -} - -//------------------------------------------------------------------------------ -sal_Bool FormController::determineLockState() const -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - // a.) in filter mode we are always locked - // b.) if we have no valid model or our model (a result set) is not alive -> we're locked - // c.) if we are inserting everything is OK and we are not locked - // d.) if are not updatable or on invalid position - Reference< XResultSet > xResultSet(m_xModelAsIndex, UNO_QUERY); - if (m_bFiltering || !xResultSet.is() || !isRowSetAlive(xResultSet)) - return sal_True; - else - return (m_bCanInsert && m_bCurrentRecordNew) ? sal_False - : xResultSet->isBeforeFirst() || xResultSet->isAfterLast() || xResultSet->rowDeleted() || !m_bCanUpdate; -} - -// FocusListener -//------------------------------------------------------------------------------ -void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) -{ - TRACE_RANGE( "FormController::focusGained" ); - - // SYNCHRONIZED --> - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_pControlBorderManager->focusGained( e.Source ); - - Reference< XControl > xControl(e.Source, UNO_QUERY); - if (m_bDBConnection) - { - // do we need to keep the locking of the commit - // we hold the lock as long as the control differs from the current - // otherwhise we disabled the lock - m_bCommitLock = m_bCommitLock && (XControl*)xControl.get() != (XControl*)m_xCurrentControl.get(); - if (m_bCommitLock) - return; - - // when do we have to commit a value to form or a filter - // a.) if the current value is modified - // b.) there must be a current control - // c.) and it must be different from the new focus owning control or - // d.) the focus is moving around (so we have only one control) - - if ( ( m_bModified || m_bFiltering ) - && m_xCurrentControl.is() - && ( ( xControl.get() != m_xCurrentControl.get() ) - || ( ( e.FocusFlags & FocusChangeReason::AROUND ) - && ( m_bCycle || m_bFiltering ) - ) - ) - ) - { - // check the old control if the content is ok -#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL - Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY); - sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); - OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?"); - // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext - // gesetzt worden sein, was ich nicht verstehen wuerde ... -#endif - DBG_ASSERT(m_xCurrentControl.is(), "kein CurrentControl gesetzt"); - // zunaechst das Control fragen ob es das IFace unterstuetzt - Reference< XBoundComponent > xBound(m_xCurrentControl, UNO_QUERY); - if (!xBound.is() && m_xCurrentControl.is()) - xBound = Reference< XBoundComponent > (m_xCurrentControl->getModel(), UNO_QUERY); - - // lock if we lose the focus during commit - m_bCommitLock = sal_True; - - // Commit nicht erfolgreich, Focus zuruecksetzen - if (xBound.is() && !xBound->commit()) - { - // the commit failed and we don't commit again until the current control - // which couldn't be commit gains the focus again - Reference< XWindow > xWindow(m_xCurrentControl, UNO_QUERY); - if (xWindow.is()) - xWindow->setFocus(); - return; - } - else - { - m_bModified = sal_False; - m_bCommitLock = sal_False; - } - } - - if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is()) - { - if ( e.FocusFlags & FocusChangeReason::FORWARD ) - { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_NEXT ) ) - m_aControllerFeatures->moveRight(); - } - else // backward - { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_PREV ) ) - m_aControllerFeatures->moveLeft(); - } - } - } - - // Immer noch ein und dasselbe Control - if ( (m_xActiveControl.get() == xControl.get()) - && (xControl.get() == m_xCurrentControl.get()) - ) - { - DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert"); - return; - } - - sal_Bool bActivated = !m_xActiveControl.is() && xControl.is(); - - m_xActiveControl = xControl; - - implSetCurrentControl( xControl ); - OSL_POSTCOND( m_xCurrentControl.is(), "implSetCurrentControl did nonsense!" ); - - if ( bActivated ) - { - // (asynchronously) call activation handlers - m_aActivationEvent.Call(); - - // call modify listeners - if ( m_bModified ) - m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) ); - } - - // invalidate all features which depend on the currently focused control - if ( m_bDBConnection && !m_bFiltering ) - implInvalidateCurrentControlDependentFeatures(); - - if ( !m_xCurrentControl.is() ) - return; - - // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich - Reference< XFormControllerContext > xContext( m_xContext ); - Reference< XControl > xCurrentControl( m_xCurrentControl ); - aGuard.clear(); - // <-- SYNCHRONIZED - - if ( xContext.is() ) - xContext->makeVisible( xCurrentControl ); -} - -//------------------------------------------------------------------------------ -IMPL_LINK( FormController, OnActivated, void*, /**/ ) -{ - EventObject aEvent; - aEvent.Source = *this; - m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvent ); - - return 0L; -} - -//------------------------------------------------------------------------------ -IMPL_LINK( FormController, OnDeactivated, void*, /**/ ) -{ - EventObject aEvent; - aEvent.Source = *this; - m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvent ); - - return 0L; -} - -//------------------------------------------------------------------------------ -void FormController::focusLost(const FocusEvent& e) throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - m_pControlBorderManager->focusLost( e.Source ); - - Reference< XControl > xControl(e.Source, UNO_QUERY); - Reference< XWindowPeer > xNext(e.NextFocus, UNO_QUERY); - Reference< XControl > xNextControl = isInList(xNext); - if (!xNextControl.is()) - { - m_xActiveControl = NULL; - m_aDeactivationEvent.Call(); - } -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) -{ - // not interested in -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) -{ - // not interested in -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) -{ - m_pControlBorderManager->mouseEntered( _rEvent.Source ); -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) -{ - m_pControlBorderManager->mouseExited( _rEvent.Source ); -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) -{ - Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) ); - Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY ); - - OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" ); - - if ( xControl.is() && xValidatable.is() ) - m_pControlBorderManager->validityChanged( xControl, xValidatable ); -} - -//-------------------------------------------------------------------- -void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !"); - - try - { - // disconnect from the old model - if (m_xModelAsIndex.is()) - { - if (m_bDBConnection) - { - // we are currently working on the model - EventObject aEvt(m_xModelAsIndex); - unloaded(aEvt); - } - - Reference< XLoadable > xForm(m_xModelAsIndex, UNO_QUERY); - if (xForm.is()) - xForm->removeLoadListener(this); - - Reference< XSQLErrorBroadcaster > xBroadcaster(m_xModelAsIndex, UNO_QUERY); - if (xBroadcaster.is()) - xBroadcaster->removeSQLErrorListener(this); - - Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY); - if (xParamBroadcaster.is()) - xParamBroadcaster->removeParameterListener(this); - } - - disposeAllFeaturesAndDispatchers(); - - // set the new model wait for the load event - if (m_xTabController.is()) - m_xTabController->setModel(Model); - m_xModelAsIndex = Reference< XIndexAccess > (Model, UNO_QUERY); - m_xModelAsManager = Reference< XEventAttacherManager > (Model, UNO_QUERY); - - // only if both ifaces exit, the controller will work successful - if (!m_xModelAsIndex.is() || !m_xModelAsManager.is()) - { - m_xModelAsManager = NULL; - m_xModelAsIndex = NULL; - } - - if (m_xModelAsIndex.is()) - { - m_aControllerFeatures.assign( this ); - - // adding load and ui interaction listeners - Reference< XLoadable > xForm(Model, UNO_QUERY); - if (xForm.is()) - xForm->addLoadListener(this); - - Reference< XSQLErrorBroadcaster > xBroadcaster(Model, UNO_QUERY); - if (xBroadcaster.is()) - xBroadcaster->addSQLErrorListener(this); - - Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(Model, UNO_QUERY); - if (xParamBroadcaster.is()) - xParamBroadcaster->addParameterListener(this); - - // well, is the database already loaded? - // then we have to simulate a load event - Reference< XLoadable > xCursor(m_xModelAsIndex, UNO_QUERY); - if (xCursor.is() && xCursor->isLoaded()) - { - EventObject aEvt(xCursor); - loaded(aEvt); - } - - Reference< XPropertySet > xModelProps( m_xModelAsIndex, UNO_QUERY ); - Reference< XPropertySetInfo > xPropInfo( xModelProps->getPropertySetInfo() ); - if ( xPropInfo.is() - && xPropInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) - && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) - && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) - && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) - ) - { - bool bEnableDynamicControlBorder = lcl_shouldUseDynamicControlBorder( - xModelProps.get(), xModelProps->getPropertyValue( FM_PROP_DYNAMIC_CONTROL_BORDER ) ); - if ( bEnableDynamicControlBorder ) - m_pControlBorderManager->enableDynamicBorderColor(); - else - m_pControlBorderManager->disableDynamicBorderColor(); - - sal_Int32 nColor = 0; - if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) >>= nColor ) - m_pControlBorderManager->setStatusColor( CONTROL_STATUS_FOCUSED, nColor ); - if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) >>= nColor ) - m_pControlBorderManager->setStatusColor( CONTROL_STATUS_MOUSE_HOVER, nColor ); - if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) >>= nColor ) - m_pControlBorderManager->setStatusColor( CONTROL_STATUS_INVALID, nColor ); - } - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -//------------------------------------------------------------------------------ -Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !"); - if (!m_xTabController.is()) - return Reference< XTabControllerModel > (); - return m_xTabController->getModel(); -} - -//------------------------------------------------------------------------------ -void FormController::addToEventAttacher(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" ); - if ( !xControl.is() ) - return; /* throw IllegalArgumentException(); */ - - // anmelden beim Eventattacher - Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); - if (xComp.is() && m_xModelAsIndex.is()) - { - // Und die Position des ControlModel darin suchen - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) - { - Reference< XInterface > xIfc(xControl, UNO_QUERY); - m_xModelAsManager->attach( nPos, xIfc, makeAny(xControl) ); - break; - } - } - } -} - -//------------------------------------------------------------------------------ -void FormController::removeFromEventAttacher(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" ); - if ( !xControl.is() ) - return; /* throw IllegalArgumentException(); */ - - // abmelden beim Eventattacher - Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); - if ( xComp.is() && m_xModelAsIndex.is() ) - { - // Und die Position des ControlModel darin suchen - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) - { - Reference< XInterface > xIfc(xControl, UNO_QUERY); - m_xModelAsManager->detach( nPos, xIfc ); - break; - } - } - } -} - -//------------------------------------------------------------------------------ -void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - Reference< XTabControllerModel > xTabModel(getModel()); - DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined"); - // if we have a new container we need a model - DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !"); - - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XContainer > xCurrentContainer; - if (m_xTabController.is()) - xCurrentContainer = Reference< XContainer > (m_xTabController->getContainer(), UNO_QUERY); - if (xCurrentContainer.is()) - { - xCurrentContainer->removeContainerListener(this); - - if ( m_aTabActivationTimer.IsActive() ) - m_aTabActivationTimer.Stop(); - - // clear the filter map - ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); - m_aFilterComponents.clear(); - - // einsammeln der Controls - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - implControlRemoved( *pControls++, true ); - - // Datenbank spezifische Dinge vornehmen - if (m_bDBConnection && isListeningForChanges()) - stopListening(); - - m_aControls.realloc( 0 ); - } - - if (m_xTabController.is()) - m_xTabController->setContainer(xContainer); - - // Welche Controls gehoeren zum Container ? - if (xContainer.is() && xTabModel.is()) - { - Sequence< Reference< XControlModel > > aModels = xTabModel->getControlModels(); - const Reference< XControlModel > * pModels = aModels.getConstArray(); - Sequence< Reference< XControl > > aAllControls = xContainer->getControls(); - - sal_Int32 nCount = aModels.getLength(); - m_aControls = Sequence< Reference< XControl > >( nCount ); - Reference< XControl > * pControls = m_aControls.getArray(); - - // einsammeln der Controls - sal_Int32 i, j; - for (i = 0, j = 0; i < nCount; ++i, ++pModels ) - { - Reference< XControl > xControl = findControl( aAllControls, *pModels, sal_False, sal_True ); - if ( xControl.is() ) - { - pControls[j++] = xControl; - implControlInserted( xControl, true ); - } - } - - // not every model had an associated control - if (j != i) - m_aControls.realloc(j); - - // am Container horchen - Reference< XContainer > xNewContainer(xContainer, UNO_QUERY); - if (xNewContainer.is()) - xNewContainer->addContainerListener(this); - - // Datenbank spezifische Dinge vornehmen - if (m_bDBConnection) - { - m_bLocked = determineLockState(); - setLocks(); - if (!isLocked()) - startListening(); - } - } - // befinden sich die Controls in der richtigen Reihenfolge - m_bControlsSorted = sal_True; -} - -//------------------------------------------------------------------------------ -Reference< XControlContainer > FormController::getContainer() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !"); - if (!m_xTabController.is()) - return Reference< XControlContainer > (); - return m_xTabController->getContainer(); -} - -//------------------------------------------------------------------------------ -Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if (!m_bControlsSorted) - { - Reference< XTabControllerModel > xModel = getModel(); - if (!xModel.is()) - return m_aControls; - - Sequence< Reference< XControlModel > > aControlModels = xModel->getControlModels(); - const Reference< XControlModel > * pModels = aControlModels.getConstArray(); - sal_Int32 nModels = aControlModels.getLength(); - - Sequence< Reference< XControl > > aNewControls(nModels); - - Reference< XControl > * pControls = aNewControls.getArray(); - Reference< XControl > xControl; - - // Umsortieren der Controls entsprechend der TabReihenfolge - sal_Int32 j = 0; - for (sal_Int32 i = 0; i < nModels; ++i, ++pModels ) - { - xControl = findControl( m_aControls, *pModels, sal_True, sal_True ); - if ( xControl.is() ) - pControls[j++] = xControl; - } - - // not every model had an associated control - if ( j != nModels ) - aNewControls.realloc( j ); - - m_aControls = aNewControls; - m_bControlsSorted = sal_True; - } - return m_aControls; -} - -//------------------------------------------------------------------------------ -void FormController::autoTabOrder() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !"); - if (m_xTabController.is()) - m_xTabController->autoTabOrder(); -} - -//------------------------------------------------------------------------------ -void FormController::activateTabOrder() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !"); - if (m_xTabController.is()) - m_xTabController->activateTabOrder(); -} - -//------------------------------------------------------------------------------ -void FormController::setControlLock(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - sal_Bool bLocked = isLocked(); - - // es wird gelockt - // a.) wenn der ganze Datensatz gesperrt ist - // b.) wenn das zugehoerige Feld gespeert ist - Reference< XBoundControl > xBound(xControl, UNO_QUERY); - if (xBound.is() && (( (bLocked && bLocked != xBound->getLock()) || - !bLocked))) // beim entlocken immer einzelne Felder ueberprüfen - { - // gibt es eine Datenquelle - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // wie sieht mit den Properties ReadOnly und Enable aus - sal_Bool bTouch = sal_True; - if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet)) - bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED)); - if (::comphelper::hasProperty(FM_PROP_READONLY, xSet)) - bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY)); - - if (bTouch) - { - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - if (xField.is()) - { - if (bLocked) - xBound->setLock(bLocked); - else - { - try - { - Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY); - if (aVal.hasValue() && ::comphelper::getBOOL(aVal)) - xBound->setLock(sal_True); - else - xBound->setLock(bLocked); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - } - } - } - } - } -} - -//------------------------------------------------------------------------------ -void FormController::setLocks() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - setControlLock( *pControls++ ); -} - -//------------------------------------------------------------------------------ -namespace -{ - bool lcl_shouldListenForModifications( const Reference< XControl >& _rxControl, const Reference< XPropertyChangeListener >& _rxBoundFieldListener ) - { - bool bShould = false; - - Reference< XBoundComponent > xBound( _rxControl, UNO_QUERY ); - if ( xBound.is() ) - { - bShould = true; - } - else if ( _rxControl.is() ) - { - Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY ); - if ( xModelProps.is() && ::comphelper::hasProperty( FM_PROP_BOUNDFIELD, xModelProps ) ) - { - Reference< XPropertySet > xField; - xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField; - bShould = xField.is(); - - if ( !bShould && _rxBoundFieldListener.is() ) - xModelProps->addPropertyChangeListener( FM_PROP_BOUNDFIELD, _rxBoundFieldListener ); - } - } - - return bShould; - } -} - -//------------------------------------------------------------------------------ -void FormController::startControlModifyListening(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - bool bModifyListening = lcl_shouldListenForModifications( xControl, this ); - - // artificial while - while ( bModifyListening ) - { - Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY); - if (xMod.is()) - { - xMod->addModifyListener(this); - break; - } - - // alle die Text um vorzeitig ein modified zu erkennen - Reference< XTextComponent > xText(xControl, UNO_QUERY); - if (xText.is()) - { - xText->addTextListener(this); - break; - } - - Reference< XCheckBox > xBox(xControl, UNO_QUERY); - if (xBox.is()) - { - xBox->addItemListener(this); - break; - } - - Reference< XComboBox > xCbBox(xControl, UNO_QUERY); - if (xCbBox.is()) - { - xCbBox->addItemListener(this); - break; - } - - Reference< XListBox > xListBox(xControl, UNO_QUERY); - if (xListBox.is()) - { - xListBox->addItemListener(this); - break; - } - break; - } -} - -//------------------------------------------------------------------------------ -void FormController::stopControlModifyListening(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL ); - - // kuenstliches while - while (bModifyListening) - { - Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY); - if (xMod.is()) - { - xMod->removeModifyListener(this); - break; - } - // alle die Text um vorzeitig ein modified zu erkennen - Reference< XTextComponent > xText(xControl, UNO_QUERY); - if (xText.is()) - { - xText->removeTextListener(this); - break; - } - - Reference< XCheckBox > xBox(xControl, UNO_QUERY); - if (xBox.is()) - { - xBox->removeItemListener(this); - break; - } - - Reference< XComboBox > xCbBox(xControl, UNO_QUERY); - if (xCbBox.is()) - { - xCbBox->removeItemListener(this); - break; - } - - Reference< XListBox > xListBox(xControl, UNO_QUERY); - if (xListBox.is()) - { - xListBox->removeItemListener(this); - break; - } - break; - } -} - -//------------------------------------------------------------------------------ -void FormController::startListening() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - m_bModified = sal_False; - - // jetzt anmelden bei gebundenen feldern - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - startControlModifyListening( *pControls++ ); -} - -//------------------------------------------------------------------------------ -void FormController::stopListening() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - m_bModified = sal_False; - - // jetzt anmelden bei gebundenen feldern - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - stopControlModifyListening( *pControls++ ); -} - - -//------------------------------------------------------------------------------ -Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" ); - - Reference< XControl >* pControls = _rControls.getArray(); - Reference< XControlModel > xModel; - for ( sal_Int32 i = 0, nCount = _rControls.getLength(); i < nCount; ++i, ++pControls ) - { - if ( pControls->is() ) - { - xModel = (*pControls)->getModel(); - if ( xModel.get() == xCtrlModel.get() ) - { - Reference< XControl > xControl( *pControls ); - if ( _bRemove ) - ::comphelper::removeElementAt( _rControls, i ); - else if ( _bOverWrite ) - *pControls = Reference< XControl >(); - return xControl; - } - } - } - return Reference< XControl > (); -} - -//------------------------------------------------------------------------------ -void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) -{ - Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); - if ( xWindow.is() ) - { - xWindow->addFocusListener( this ); - xWindow->addMouseListener( this ); - - if ( _bAddToEventAttacher ) - addToEventAttacher( _rxControl ); - } - - // add a dispatch interceptor to the control (if supported) - Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY ); - if ( xInterception.is() ) - createInterceptor( xInterception ); - - if ( _rxControl.is() ) - { - Reference< XControlModel > xModel( _rxControl->getModel() ); - - // we want to know about the reset of the the model of our controls - // (for correctly resetting m_bModified) - Reference< XReset > xReset( xModel, UNO_QUERY ); - if ( xReset.is() ) - xReset->addResetListener( this ); - - // and we want to know about the validity, to visually indicate it - Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); - if ( xValidatable.is() ) - { - xValidatable->addFormComponentValidityListener( this ); - m_pControlBorderManager->validityChanged( _rxControl, xValidatable ); - } - } - -} - -//------------------------------------------------------------------------------ -void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) -{ - Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); - if ( xWindow.is() ) - { - xWindow->removeFocusListener( this ); - xWindow->removeMouseListener( this ); - - if ( _bRemoveFromEventAttacher ) - removeFromEventAttacher( _rxControl ); - } - - Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY); - if ( xInterception.is() ) - deleteInterceptor( xInterception ); - - if ( _rxControl.is() ) - { - Reference< XControlModel > xModel( _rxControl->getModel() ); - - Reference< XReset > xReset( xModel, UNO_QUERY ); - if ( xReset.is() ) - xReset->removeResetListener( this ); - - Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); - if ( xValidatable.is() ) - xValidatable->removeFormComponentValidityListener( this ); - } -} - -//------------------------------------------------------------------------------ -void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) -{ - if ( m_xCurrentControl.get() == _rxControl.get() ) - return; - - Reference< XGridControl > xGridControl( m_xCurrentControl, UNO_QUERY ); - if ( xGridControl.is() ) - xGridControl->removeGridControlListener( this ); - - m_xCurrentControl = _rxControl; - - xGridControl.set( m_xCurrentControl, UNO_QUERY ); - if ( xGridControl.is() ) - xGridControl->addGridControlListener( this ); -} - -//------------------------------------------------------------------------------ -void FormController::insertControl(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - m_bControlsSorted = sal_False; - m_aControls.realloc(m_aControls.getLength() + 1); - m_aControls.getArray()[m_aControls.getLength() - 1] = xControl; - - if ( m_pColumnInfoCache.get() ) - m_pColumnInfoCache->deinitializeControls(); - - implControlInserted( xControl, m_bAttachEvents ); - - if (m_bDBConnection && !m_bFiltering) - setControlLock(xControl); - - if (isListeningForChanges() && m_bAttachEvents) - startControlModifyListening( xControl ); -} - -//------------------------------------------------------------------------------ -void FormController::removeControl(const Reference< XControl > & xControl) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - { - if ( xControl.get() == (*pControls++).get() ) - { - ::comphelper::removeElementAt( m_aControls, pControls - m_aControls.getConstArray() - 1 ); - break; - } - } - - FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); - if ( componentPos != m_aFilterComponents.end() ) - m_aFilterComponents.erase( componentPos ); - - implControlRemoved( xControl, m_bDetachEvents ); - - if ( isListeningForChanges() && m_bDetachEvents ) - stopControlModifyListening( xControl ); -} - -// XLoadListener -//------------------------------------------------------------------------------ -void FormController::loaded(const EventObject& rEvent) throw( RuntimeException ) -{ - OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" ); - - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY); - // do we have a connected data source - OStaticDataAccessTools aStaticTools; - if (xForm.is() && aStaticTools.getRowSetConnection(xForm).is()) - { - Reference< XPropertySet > xSet(xForm, UNO_QUERY); - if (xSet.is()) - { - Any aVal = xSet->getPropertyValue(FM_PROP_CYCLE); - sal_Int32 aVal2 = 0; - ::cppu::enum2int(aVal2,aVal); - m_bCycle = !aVal.hasValue() || aVal2 == TabulatorCycle_RECORDS; - m_bCanUpdate = aStaticTools.canUpdate(xSet); - m_bCanInsert = aStaticTools.canInsert(xSet); - m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED)); - m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW)); - - startFormListening( xSet, sal_False ); - - // set the locks for the current controls - if (getContainer().is()) - { - m_aLoadEvent.Call(); - } - } - else - { - m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; - m_bCurrentRecordModified = sal_False; - m_bCurrentRecordNew = sal_False; - m_bLocked = sal_False; - } - m_bDBConnection = sal_True; - } - else - { - m_bDBConnection = sal_False; - m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; - m_bCurrentRecordModified = sal_False; - m_bCurrentRecordNew = sal_False; - m_bLocked = sal_False; - } - - Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY ); - m_pColumnInfoCache.reset( xFormColumns.is() ? new ColumnInfoCache( xFormColumns ) : NULL ); - - updateAllDispatchers(); -} - -//------------------------------------------------------------------------------ -void FormController::updateAllDispatchers() const -{ - ::std::for_each( - m_aFeatureDispatchers.begin(), - m_aFeatureDispatchers.end(), - ::std::compose1( - UpdateAllListeners(), - ::std::select2nd< DispatcherContainer::value_type >() - ) - ); -} - -//------------------------------------------------------------------------------ -IMPL_LINK(FormController, OnLoad, void*, EMPTYARG) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - m_bLocked = determineLockState(); - - setLocks(); - - if (!m_bLocked) - startListening(); - - // just one exception toggle the auto values - if (m_bCurrentRecordNew) - toggleAutoFields(sal_True); - - return 1L; -} - -//------------------------------------------------------------------------------ -void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - updateAllDispatchers(); -} - -//------------------------------------------------------------------------------ -void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - // do the same like in unloading - // just one exception toggle the auto values - m_aToggleEvent.CancelPendingCall(); - unload(); -} - -//------------------------------------------------------------------------------ -void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - loaded(aEvent); -} - -//------------------------------------------------------------------------------ -void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - unload(); -} - -//------------------------------------------------------------------------------ -void FormController::unload() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aLoadEvent.CancelPendingCall(); - - // be sure not to have autofields - if (m_bCurrentRecordNew) - toggleAutoFields(sal_False); - - // remove bound field listing again - removeBoundFieldListener(); - - if (m_bDBConnection && isListeningForChanges()) - stopListening(); - - Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); - if ( m_bDBConnection && xSet.is() ) - stopFormListening( xSet, sal_False ); - - m_bDBConnection = sal_False; - m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; - m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked = sal_False; - - m_pColumnInfoCache.reset( NULL ); -} - -// ----------------------------------------------------------------------------- -void FormController::removeBoundFieldListener() -{ - const Reference< XControl >* pControls = m_aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); - while ( pControls != pControlsEnd ) - { - Reference< XPropertySet > xProp( *pControls++, UNO_QUERY ); - if ( xProp.is() ) - xProp->removePropertyChangeListener( FM_PROP_BOUNDFIELD, this ); - } -} - -//------------------------------------------------------------------------------ -void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) -{ - try - { - if ( m_bCanInsert || m_bCanUpdate ) // form can be modified - { - _rxForm->addPropertyChangeListener( FM_PROP_ISNEW, this ); - _rxForm->addPropertyChangeListener( FM_PROP_ISMODIFIED, this ); - - if ( !_bPropertiesOnly ) - { - // set the Listener for UI interaction - Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY ); - if ( xApprove.is() ) - xApprove->addRowSetApproveListener( this ); - - // listener for row set changes - Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY ); - if ( xRowSet.is() ) - xRowSet->addRowSetListener( this ); - } - } - - Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo(); - if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) ) - _rxForm->addPropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -//------------------------------------------------------------------------------ -void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) -{ - try - { - if ( m_bCanInsert || m_bCanUpdate ) - { - _rxForm->removePropertyChangeListener( FM_PROP_ISNEW, this ); - _rxForm->removePropertyChangeListener( FM_PROP_ISMODIFIED, this ); - - if ( !_bPropertiesOnly ) - { - Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY ); - if (xApprove.is()) - xApprove->removeRowSetApproveListener(this); - - Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY ); - if ( xRowSet.is() ) - xRowSet->removeRowSetListener( this ); - } - } - - Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo(); - if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) ) - _rxForm->removePropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -// com::sun::star::sdbc::XRowSetListener -//------------------------------------------------------------------------------ -void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - // toggle the locking ? - if (m_bLocked != determineLockState()) - { - m_bLocked = !m_bLocked; - setLocks(); - if (isListeningForChanges()) - startListening(); - else - stopListening(); - } - - // neither the current control nor the current record are modified anymore - m_bCurrentRecordModified = m_bModified = sal_False; -} - -//------------------------------------------------------------------------------ -void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) -{ - // not interested in ... -} -//------------------------------------------------------------------------------ -void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) -{ - // not interested in ... -} - - -// XContainerListener -//------------------------------------------------------------------------------ -void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - Reference< XControl > xControl( evt.Element, UNO_QUERY ); - if ( !xControl.is() ) - return; - - Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); - if (xModel.is() && m_xModelAsIndex == xModel->getParent()) - { - insertControl(xControl); - - if ( m_aTabActivationTimer.IsActive() ) - m_aTabActivationTimer.Stop(); - - m_aTabActivationTimer.Start(); - } - // are we in filtermode and a XModeSelector has inserted an element - else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) - { - xModel = Reference< XFormComponent > (evt.Source, UNO_QUERY); - if (xModel.is() && m_xModelAsIndex == xModel->getParent()) - { - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // does the model use a bound field ? - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - - Reference< XTextComponent > xText(xControl, UNO_QUERY); - // may we filter the field? - if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && - ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) - { - m_aFilterComponents.push_back( xText ); - xText->addTextListener( this ); - } - } - } - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) -{ - // simulate an elementRemoved - ContainerEvent aRemoveEvent( evt ); - aRemoveEvent.Element = evt.ReplacedElement; - aRemoveEvent.ReplacedElement = Any(); - elementRemoved( aRemoveEvent ); - - // simulate an elementInserted - ContainerEvent aInsertEvent( evt ); - aInsertEvent.ReplacedElement = Any(); - elementInserted( aInsertEvent ); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - Reference< XControl > xControl; - evt.Element >>= xControl; - if (!xControl.is()) - return; - - Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); - if (xModel.is() && m_xModelAsIndex == xModel->getParent()) - { - removeControl(xControl); - // TabOrder nicht neu berechnen, da das intern schon funktionieren muß! - } - // are we in filtermode and a XModeSelector has inserted an element - else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) - { - FilterComponents::iterator componentPos = ::std::find( - m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); - if ( componentPos != m_aFilterComponents.end() ) - m_aFilterComponents.erase( componentPos ); - } -} - -//------------------------------------------------------------------------------ -Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - const Reference< XControl >* pControls = m_aControls.getConstArray(); - - sal_uInt32 nCtrls = m_aControls.getLength(); - for ( sal_uInt32 n = 0; n < nCtrls && xPeer.is(); ++n, ++pControls ) - { - if ( pControls->is() ) - { - Reference< XVclWindowPeer > xCtrlPeer( (*pControls)->getPeer(), UNO_QUERY); - if ( ( xCtrlPeer.get() == xPeer.get() ) || xCtrlPeer->isChild( xPeer ) ) - return *pControls; - } - } - return Reference< XControl > (); -} - -//------------------------------------------------------------------------------ -void FormController::activateFirst() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !"); - if (m_xTabController.is()) - m_xTabController->activateFirst(); -} - -//------------------------------------------------------------------------------ -void FormController::activateLast() throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !"); - if (m_xTabController.is()) - m_xTabController->activateLast(); -} - -// XFormController -//------------------------------------------------------------------------------ -Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - return m_aControllerFeatures->getFormOperations(); -} - -//------------------------------------------------------------------------------ -Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - return m_xCurrentControl; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_aActivateListeners.addInterface(l); -} -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_aActivateListeners.removeInterface(l); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if ( !_ChildController.is() ) - throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - // TODO: (localized) error message - - // the parent of our (to-be-)child must be our own model - Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY ); - if ( !xFormOfChild.is() ) - throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - // TODO: (localized) error message - - if ( xFormOfChild->getParent() != m_xModelAsIndex ) - throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - // TODO: (localized) error message - - m_aChilds.push_back( _ChildController ); - _ChildController->setParent( *this ); - - // search the position of the model within the form - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ( xFormOfChild == xTemp ) - { - Reference< XInterface > xIfc( _ChildController, UNO_QUERY ); - m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) ); - break; - } - } -} - -//------------------------------------------------------------------------------ -Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - return m_xContext; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_xContext = _context; -} - -//------------------------------------------------------------------------------ -Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - return m_xInteractionHandler; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - m_xInteractionHandler = _interactionHandler; -} - -//------------------------------------------------------------------------------ -void FormController::setFilter(::std::vector& rFieldInfos) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - // create the composer - Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY); - Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm)); - if (xForm.is()) - { - try - { - Reference< XMultiServiceFactory > xFactory( xConnection, UNO_QUERY_THROW ); - m_xComposer.set( - xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), - UNO_QUERY_THROW ); - - Reference< XPropertySet > xSet( xForm, UNO_QUERY ); - ::rtl::OUString sStatement = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_ACTIVECOMMAND ) ); - ::rtl::OUString sFilter = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_FILTER ) ); - m_xComposer->setElementaryQuery( sStatement ); - m_xComposer->setFilter( sFilter ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - if (m_xComposer.is()) - { - Sequence < PropertyValue> aLevel; - Sequence< Sequence < PropertyValue > > aFilterRows = m_xComposer->getStructuredFilter(); - - // ok, we recieve the list of filters as sequence of fieldnames, value - // now we have to transform the fieldname into UI names, that could be a label of the field or - // a aliasname or the fieldname itself - - // first adjust the field names if necessary - Reference< XNameAccess > xQueryColumns = - Reference< XColumnsSupplier >( m_xComposer, UNO_QUERY_THROW )->getColumns(); - - for (::std::vector::iterator iter = rFieldInfos.begin(); - iter != rFieldInfos.end(); iter++) - { - if ( xQueryColumns->hasByName((*iter).aFieldName) ) - { - if ( (xQueryColumns->getByName((*iter).aFieldName) >>= (*iter).xField) && (*iter).xField.is() ) - (*iter).xField->getPropertyValue(FM_PROP_REALNAME) >>= (*iter).aFieldName; - } - } - - Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); - // now transfer the filters into Value/TextComponent pairs - ::comphelper::UStringMixEqual aCompare(xMetaData->storesMixedCaseQuotedIdentifiers()); - - // need to parse criteria localized - OStaticDataAccessTools aStaticTools; - Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); - xFormatter->attachNumberFormatsSupplier(xFormatSupplier); - Locale aAppLocale = Application::GetSettings().GetUILocale(); - LocaleDataWrapper aLocaleWrapper(m_xORB,aAppLocale); - - // retrieving the filter - const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray(); - for (sal_Int32 i = 0, nLen = aFilterRows.getLength(); i < nLen; ++i) - { - FmFilterRow aRow; - - // search a field for the given name - const PropertyValue* pRefValues = pRow[i].getConstArray(); - for (sal_Int32 j = 0, nLen1 = pRow[i].getLength(); j < nLen1; j++) - { - // look for the text component - Reference< XPropertySet > xField; - try - { - Reference< XPropertySet > xSet; - ::rtl::OUString aRealName; - - // first look with the given name - if (xQueryColumns->hasByName(pRefValues[j].Name)) - { - xQueryColumns->getByName(pRefValues[j].Name) >>= xSet; - - // get the RealName - xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName; - - // compare the condition field name and the RealName - if (aCompare(aRealName, pRefValues[j].Name)) - xField = xSet; - } - if (!xField.is()) - { - // no we have to check every column to find the realname - Reference< XIndexAccess > xColumnsByIndex(xQueryColumns, UNO_QUERY); - for (sal_Int32 n = 0, nCount = xColumnsByIndex->getCount(); n < nCount; n++) - { - xColumnsByIndex->getByIndex(n) >>= xSet; - xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName; - if (aCompare(aRealName, pRefValues[j].Name)) - { - // get the column by its alias - xField = xSet; - break; - } - } - } - if (!xField.is()) - continue; - } - catch (const Exception&) - { - continue; - } - - // find the text component - for (::std::vector::iterator iter = rFieldInfos.begin(); - iter != rFieldInfos.end(); iter++) - { - // we found the field so insert a new entry to the filter row - if ((*iter).xField == xField) - { - // do we already have the control ? - if (aRow.find((*iter).xText) != aRow.end()) - { - ::rtl::OUString aCompText = aRow[(*iter).xText]; - aCompText += ::rtl::OUString::createFromAscii(" "); - ::rtl::OString aVal = m_xParser->getContext().getIntlKeywordAscii(OParseContext::KEY_AND); - aCompText += ::rtl::OUString(aVal.getStr(),aVal.getLength(),RTL_TEXTENCODING_ASCII_US); - aCompText += ::rtl::OUString::createFromAscii(" "); - aCompText += ::comphelper::getString(pRefValues[j].Value); - aRow[(*iter).xText] = aCompText; - } - else - { - ::rtl::OUString sPredicate,sErrorMsg; - pRefValues[j].Value >>= sPredicate; - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(sErrorMsg, sPredicate, xFormatter, xField); - if ( xParseNode.is() ) - { - ::rtl::OUString sCriteria; - xParseNode->parseNodeToPredicateStr( sCriteria - ,xConnection - ,xFormatter - ,xField - ,aAppLocale - ,(sal_Char)aLocaleWrapper.getNumDecimalSep().GetChar(0) - ,getParseContext()); - aRow[(*iter).xText] = sCriteria; - } - } - } - } - } - - if (aRow.empty()) - continue; - - impl_addFilterRow( aRow ); - } - } - - // now set the filter controls - for ( ::std::vector::iterator field = rFieldInfos.begin(); - field != rFieldInfos.end(); - ++field - ) - { - m_aFilterComponents.push_back( field->xText ); - } -} - -//------------------------------------------------------------------------------ -void FormController::startFiltering() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - - OStaticDataAccessTools aStaticTools; - Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) ); - if ( !xConnection.is() ) - // nothing to do - can't filter a form which is not connected - // 98023 - 19.03.2002 - fs@openoffice.org - return; - - // stop listening for controls - if (isListeningForChanges()) - stopListening(); - - m_bFiltering = sal_True; - - // as we don't want new controls to be attached to the scripting environment - // we change attach flags - m_bAttachEvents = sal_False; - - // Austauschen der Kontrols fuer das aktuelle Formular - Sequence< Reference< XControl > > aControlsCopy( m_aControls ); - const Reference< XControl >* pControls = aControlsCopy.getConstArray(); - sal_Int32 nControlCount = aControlsCopy.getLength(); - - // the control we have to activate after replacement - Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData()); - Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - Reference< XNumberFormatter > xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); - xFormatter->attachNumberFormatsSupplier(xFormatSupplier); - - // structure for storing the field info - ::std::vector aFieldInfos; - - for (sal_Int32 i = nControlCount; i > 0;) - { - Reference< XControl > xControl = pControls[--i]; - if (xControl.is()) - { - // no events for the control anymore - removeFromEventAttacher(xControl); - - // do we have a mode selector - Reference< XModeSelector > xSelector(xControl, UNO_QUERY); - if (xSelector.is()) - { - xSelector->setMode(FILTER_MODE); - - // listening for new controls of the selector - Reference< XContainer > xContainer(xSelector, UNO_QUERY); - if (xContainer.is()) - xContainer->addContainerListener(this); - - Reference< XEnumerationAccess > xElementAccess(xSelector, UNO_QUERY); - if (xElementAccess.is()) - { - Reference< XEnumeration > xEnumeration(xElementAccess->createEnumeration()); - Reference< XControl > xSubControl; - while (xEnumeration->hasMoreElements()) - { - xEnumeration->nextElement() >>= xSubControl; - if (xSubControl.is()) - { - Reference< XPropertySet > xSet(xSubControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // does the model use a bound field ? - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - - Reference< XTextComponent > xText(xSubControl, UNO_QUERY); - // may we filter the field? - if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && - ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) - { - aFieldInfos.push_back(FmFieldInfo(xField, xText)); - xText->addTextListener(this); - } - } - } - } - } - continue; - } - - Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY ); - if (xModel.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xModel)) - { - // does the model use a bound field ? - Any aVal = xModel->getPropertyValue(FM_PROP_BOUNDFIELD); - Reference< XPropertySet > xField; - aVal >>= xField; - - // may we filter the field? - - if ( xField.is() - && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField ) - && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) ) - ) - { - // create a filter control - Sequence< Any > aCreationArgs( 3 ); - aCreationArgs[ 0 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "MessageParent" ), makeAny( VCLUnoHelper::GetInterface( getDialogParentWindow() ) ) ); - aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "NumberFormatter" ), makeAny( xFormatter ) ); - aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "ControlModel" ), makeAny( xModel ) ); - Reference< XControl > xFilterControl( - m_xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii( "com.sun.star.form.control.FilterControl" ), - aCreationArgs - ), - UNO_QUERY - ); - DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" ); - - if ( replaceControl( xControl, xFilterControl ) ) - { - Reference< XTextComponent > xFilterText( xFilterControl, UNO_QUERY ); - aFieldInfos.push_back( FmFieldInfo( xField, xFilterText ) ); - xFilterText->addTextListener(this); - } - } - } - else - { - // abmelden vom EventManager - } - } - } - - // we have all filter controls now, so the next step is to read the filters from the form - // resolve all aliases and set the current filter to the according structure - setFilter(aFieldInfos); - - Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); - if ( xSet.is() ) - stopFormListening( xSet, sal_True ); - - impl_setTextOnAllFilter_throw(); - - // lock all controls which are not used for filtering - m_bLocked = determineLockState(); - setLocks(); - m_bAttachEvents = sal_True; -} - -//------------------------------------------------------------------------------ -void FormController::stopFiltering() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - if ( !m_bFiltering ) // #104693# OJ - { // nothing to do - return; - } - - m_bFiltering = sal_False; - m_bDetachEvents = sal_False; - - ::comphelper::disposeComponent(m_xComposer); - - // Austauschen der Kontrols fuer das aktuelle Formular - Sequence< Reference< XControl > > aControlsCopy( m_aControls ); - const Reference< XControl > * pControls = aControlsCopy.getConstArray(); - sal_Int32 nControlCount = aControlsCopy.getLength(); - - // clear the filter control map - ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); - m_aFilterComponents.clear(); - - for ( sal_Int32 i = nControlCount; i > 0; ) - { - Reference< XControl > xControl = pControls[--i]; - if (xControl.is()) - { - // now enable eventhandling again - addToEventAttacher(xControl); - - Reference< XModeSelector > xSelector(xControl, UNO_QUERY); - if (xSelector.is()) - { - xSelector->setMode(DATA_MODE); - - // listening for new controls of the selector - Reference< XContainer > xContainer(xSelector, UNO_QUERY); - if (xContainer.is()) - xContainer->removeContainerListener(this); - continue; - } - - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) - { - // does the model use a bound field ? - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - - // may we filter the field? - if ( xField.is() - && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField ) - && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) ) - ) - { - ::rtl::OUString sServiceName; - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); - replaceControl( xControl, xNewControl ); - } - } - } - } - - Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); - if ( xSet.is() ) - startFormListening( xSet, sal_True ); - - m_bDetachEvents = sal_True; - - m_aFilterRows.clear(); - m_nCurrentFilterPosition = -1; - - // release the locks if possible - // lock all controls which are not used for filtering - m_bLocked = determineLockState(); - setLocks(); - - // restart listening for control modifications - if (isListeningForChanges()) - startListening(); -} - -// XModeSelector -//------------------------------------------------------------------------------ -void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - if (!supportsMode(Mode)) - throw NoSupportException(); - - if (Mode == m_aMode) - return; - - m_aMode = Mode; - - if (Mode == FILTER_MODE) - startFiltering(); - else - stopFiltering(); - - for (FmFormControllers::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); ++i) - { - Reference< XModeSelector > xMode(*i, UNO_QUERY); - if ( xMode.is() ) - xMode->setMode(Mode); - } -} - -//------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - return m_aMode; -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - static Sequence< ::rtl::OUString > aModes; - if (!aModes.getLength()) - { - aModes.realloc(2); - ::rtl::OUString* pModes = aModes.getArray(); - pModes[0] = DATA_MODE; - pModes[1] = FILTER_MODE; - } - return aModes; -} - -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - Sequence< ::rtl::OUString > aModes(getSupportedModes()); - const ::rtl::OUString* pModes = aModes.getConstArray(); - for (sal_Int32 i = aModes.getLength(); i > 0; ) - { - if (pModes[--i] == Mode) - return sal_True; - } - return sal_False; -} - -//------------------------------------------------------------------------------ -Window* FormController::getDialogParentWindow() -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - Window* pParentWindow = NULL; - try - { - Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); - Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); - pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return pParentWindow; -} -//------------------------------------------------------------------------------ -bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) -{ - try - { - Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY ); - Reference< XEnumeration > xControlEnumeration; - if ( xControlEnumAcc.is() ) - xControlEnumeration = xControlEnumAcc->createEnumeration(); - OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" ); - if ( !xControlEnumeration.is() ) - // assume all valid - return true; - - Reference< XValidatableFormComponent > xValidatable; - while ( xControlEnumeration->hasMoreElements() ) - { - if ( !( xControlEnumeration->nextElement() >>= xValidatable ) ) - // control does not support validation - continue; - - if ( xValidatable->isValid() ) - continue; - - Reference< XValidator > xValidator( xValidatable->getValidator() ); - OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" ); - if ( !xValidator.is() ) - // this violates the interface definition of css.form.validation.XValidatableFormComponent ... - continue; - - _rFirstInvalidityExplanation = xValidator->explainInvalid( xValidatable->getCurrentValue() ); - _rxFirstInvalidModel = _rxFirstInvalidModel.query( xValidatable ); - return false; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return true; -} - -//------------------------------------------------------------------------------ -Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) -{ - try - { - Sequence< Reference< XControl > > aControls( getControls() ); - const Reference< XControl >* pControls = aControls.getConstArray(); - const Reference< XControl >* pControlsEnd = aControls.getConstArray() + aControls.getLength(); - - for ( ; pControls != pControlsEnd; ++pControls ) - { - OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" ); - if ( pControls->is() ) - { - if ( ( *pControls)->getModel() == _rxModel ) - return *pControls; - } - } - OSL_ENSURE( sal_False, "FormController::locateControl: did not find a control for this model!" ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return NULL; -} - -//------------------------------------------------------------------------------ -namespace -{ - void displayErrorSetFocus( const String& _rMessage, const Reference< XControl >& _rxFocusControl, Window* _pDialogParent ) - { - SQLContext aError; - aError.Message = String( SVX_RES( RID_STR_WRITEERROR ) ); - aError.Details = _rMessage; - displayException( aError, _pDialogParent ); - - if ( _rxFocusControl.is() ) - { - Reference< XWindow > xControlWindow( _rxFocusControl, UNO_QUERY ); - OSL_ENSURE( xControlWindow.is(), "displayErrorSetFocus: invalid control!" ); - if ( xControlWindow.is() ) - xControlWindow->setFocus(); - } - } - - sal_Bool lcl_shouldValidateRequiredFields_nothrow( const Reference< XInterface >& _rxForm ) - { - try - { - static ::rtl::OUString s_sFormsCheckRequiredFields( RTL_CONSTASCII_USTRINGPARAM( "FormsCheckRequiredFields" ) ); - - // first, check whether the form has a property telling us the answer - // this allows people to use the XPropertyContainer interface of a form to control - // the behaviour on a per-form basis. - Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY_THROW ); - Reference< XPropertySetInfo > xPSI( xFormProps->getPropertySetInfo() ); - if ( xPSI->hasPropertyByName( s_sFormsCheckRequiredFields ) ) - { - sal_Bool bShouldValidate = true; - OSL_VERIFY( xFormProps->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate ); - return bShouldValidate; - } - - // next, check the data source which created the connection - Reference< XChild > xConnectionAsChild( xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ), UNO_QUERY_THROW ); - Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY ); - if ( !xDataSource.is() ) - // seldom (but possible): this is not a connection created by a data source - return sal_True; - - Reference< XPropertySet > xDataSourceSettings( - xDataSource->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ) ), - UNO_QUERY_THROW ); - - sal_Bool bShouldValidate = true; - OSL_VERIFY( xDataSourceSettings->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate ); - return bShouldValidate; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - return sal_True; - } -} - -// XRowSetApproveListener -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) -{ - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); - sal_Bool bValid = sal_True; - if (aIter.hasMoreElements()) - { - RowChangeEvent aEvt( _rEvent ); - aEvt.Source = *this; - bValid = ((XRowSetApproveListener*)aIter.next())->approveRowChange(aEvt); - } - - if ( !bValid ) - return bValid; - - if ( ( _rEvent.Action != RowChangeAction::INSERT ) - && ( _rEvent.Action != RowChangeAction::UPDATE ) - ) - return bValid; - - // if some of the control models are bound to validators, check them - ::rtl::OUString sInvalidityExplanation; - Reference< XControlModel > xInvalidModel; - if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) ) - { - Reference< XControl > xControl( locateControl( xInvalidModel ) ); - aGuard.clear(); - displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow() ); - return false; - } - - // check values on NULL and required flag - if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) ) - return sal_True; - - OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" ); - if ( !m_pColumnInfoCache.get() ) - return sal_True; - - try - { - if ( !m_pColumnInfoCache->controlsInitialized() ) - m_pColumnInfoCache->initializeControls( getControls() ); - - size_t colCount = m_pColumnInfoCache->getColumnCount(); - for ( size_t col = 0; col < colCount; ++col ) - { - const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo( col ); - if ( rColInfo.nNullable != ColumnValue::NO_NULLS ) - continue; - - if ( rColInfo.bAutoIncrement ) - continue; - - if ( rColInfo.bReadOnly ) - continue; - - if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() ) - continue; - - // TODO: in case of binary fields, this "getString" below is extremely expensive - if ( rColInfo.xColumn->getString().getLength() || !rColInfo.xColumn->wasNull() ) - continue; - - String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) ); - sMessage.SearchAndReplace( '#', rColInfo.sName ); - - // the control to focus - Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired ); - if ( !xControl.is() ) - xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY ); - - aGuard.clear(); - displayErrorSetFocus( sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow() ); - return sal_False; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - return true; -} - -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); - if (aIter.hasMoreElements()) - { - EventObject aEvt(event); - aEvt.Source = *this; - return ((XRowSetApproveListener*)aIter.next())->approveCursorMove(aEvt); - } - - return sal_True; -} - -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); - if (aIter.hasMoreElements()) - { - EventObject aEvt(event); - aEvt.Source = *this; - return ((XRowSetApproveListener*)aIter.next())->approveRowSetChange(aEvt); - } - - return sal_True; -} - -// XRowSetApproveBroadcaster -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aRowSetApproveListeners.addInterface(_rxListener); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aRowSetApproveListeners.removeInterface(_rxListener); -} - -// XErrorListener -//------------------------------------------------------------------------------ -void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) -{ - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners); - if (aIter.hasMoreElements()) - { - SQLErrorEvent aEvt(aEvent); - aEvt.Source = *this; - ((XSQLErrorListener*)aIter.next())->errorOccured(aEvt); - } - else - { - aGuard.clear(); - displayException( aEvent ); - } -} - -// XErrorBroadcaster -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aErrorListeners.addInterface(aListener); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aErrorListeners.removeInterface(aListener); -} - -// XDatabaseParameterBroadcaster2 -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aParameterListeners.addInterface(aListener); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aParameterListeners.removeInterface(aListener); -} - -// XDatabaseParameterBroadcaster -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) -{ - FormController::addDatabaseParameterListener( aListener ); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) -{ - FormController::removeDatabaseParameterListener( aListener ); -} - -// XDatabaseParameterListener -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) -{ - ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners); - if (aIter.hasMoreElements()) - { - DatabaseParameterEvent aEvt(aEvent); - aEvt.Source = *this; - return ((XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt); - } - else - { - // default handling: instantiate an interaction handler and let it handle the parameter request - try - { - if ( !ensureInteractionHandler() ) - return sal_False; - - // two continuations allowed: OK and Cancel - OParameterContinuation* pParamValues = new OParameterContinuation; - OInteractionAbort* pAbort = new OInteractionAbort; - // the request - ParametersRequest aRequest; - aRequest.Parameters = aEvent.Parameters; - aRequest.Connection = OStaticDataAccessTools().getRowSetConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY)); - OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest)); - Reference< XInteractionRequest > xParamRequest(pParamRequest); - // some knittings - pParamRequest->addContinuation(pParamValues); - pParamRequest->addContinuation(pAbort); - - // handle the request - m_xInteractionHandler->handle(xParamRequest); - - if (!pParamValues->wasSelected()) - // canceled - return sal_False; - - // transfer the values into the parameter supplier - Sequence< PropertyValue > aFinalValues = pParamValues->getValues(); - if (aFinalValues.getLength() != aRequest.Parameters->getCount()) - { - DBG_ERROR("FormController::approveParameter: the InteractionHandler returned nonsense!"); - return sal_False; - } - const PropertyValue* pFinalValues = aFinalValues.getConstArray(); - for (sal_Int32 i=0; i xParam; - ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i)); - if (xParam.is()) - { -#ifdef DBG_UTIL - ::rtl::OUString sName; - xParam->getPropertyValue(FM_PROP_NAME) >>= sName; - DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!"); -#endif - try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); } - catch(Exception&) - { - DBG_ERROR("FormController::approveParameter: setting one of the properties failed!"); - } - } - } - } - catch(Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - return sal_True; -} - -// XConfirmDeleteBroadcaster -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aDeleteListeners.addInterface(aListener); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - m_aDeleteListeners.removeInterface(aListener); -} - -// XConfirmDeleteListener -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - impl_checkDisposed_throw(); - - ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners); - if (aIter.hasMoreElements()) - { - RowChangeEvent aEvt(aEvent); - aEvt.Source = *this; - return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt); - } - else - { - // default handling - UniString aTitle; - sal_Int32 nLength = aEvent.Rows; - if (nLength > 1) - { - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORDS); - aTitle.SearchAndReplace('#', String::CreateFromInt32(nLength)); - } - else - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORD); - - ConfirmDeleteDialog aDlg(getDialogParentWindow(), aTitle); - return RET_YES == aDlg.Execute(); - } -} - -//------------------------------------------------------------------------------ -void FormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - // for now, just copy the ids of the features, because .... - ::std::copy( _rFeatures.begin(), _rFeatures.end(), - ::std::insert_iterator< ::std::set< sal_Int32 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) - ); - - // ... we will do the real invalidation asynchronously - if ( !m_aFeatureInvalidationTimer.IsActive() ) - m_aFeatureInvalidationTimer.Start(); -} - -//------------------------------------------------------------------------------ -Reference< XDispatch > -FormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, - const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/) - throw( RuntimeException ) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - Reference< XDispatch > xReturn; - // dispatches handled by ourself - if ( ( aURL.Complete == FMURL_CONFIRM_DELETION ) - || ( ( aURL.Complete.equalsAscii( "private:/InteractionHandler" ) ) - && ensureInteractionHandler() - ) - ) - xReturn = static_cast< XDispatch* >( this ); - - // dispatches of FormSlot-URLs we have to translate - if ( !xReturn.is() && m_aControllerFeatures.isAssigned() ) - { - // find the slot id which corresponds to the URL - sal_Int32 nFeatureId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); - if ( nFeatureId > 0 ) - { - // get the dispatcher for this feature, create if necessary - DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFeatureId ); - if ( aDispatcherPos == m_aFeatureDispatchers.end() ) - { - aDispatcherPos = m_aFeatureDispatchers.insert( - DispatcherContainer::value_type( nFeatureId, new ::svx::OSingleFeatureDispatcher( aURL, nFeatureId, *m_aControllerFeatures, m_aMutex ) ) - ).first; - } - - OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" ); - return aDispatcherPos->second; - } - } - - // no more to offer - return xReturn; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) -{ - if ( _rArgs.getLength() != 1 ) - { - DBG_ERROR( "FormController::dispatch: no arguments -> no dispatch!" ); - return; - } - - if ( _rURL.Complete.equalsAscii( "private:/InteractionHandler" ) ) - { - Reference< XInteractionRequest > xRequest; - OSL_VERIFY( _rArgs[0].Value >>= xRequest ); - if ( xRequest.is() ) - handle( xRequest ); - return; - } - - if ( _rURL.Complete == FMURL_CONFIRM_DELETION ) - { - DBG_ERROR( "FormController::dispatch: How do you expect me to return something via this call?" ); - // confirmDelete has a return value - dispatch hasn't - return; - } - - DBG_ERROR( "FormController::dispatch: unknown URL!" ); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) -{ - if (_rURL.Complete == FMURL_CONFIRM_DELETION) - { - if (_rxListener.is()) - { // send an initial statusChanged event - FeatureStateEvent aEvent; - aEvent.FeatureURL = _rURL; - aEvent.IsEnabled = sal_True; - _rxListener->statusChanged(aEvent); - // and don't add the listener at all (the status will never change) - } - } - else - OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!"); -} - -//------------------------------------------------------------------------------ -Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException ) -{ - return m_xParent; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException ) -{ - m_xParent = Parent; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) -{ - (void)_rURL; - OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!"); - // we never really added the listener, so we don't need to remove it -} - -//------------------------------------------------------------------------------ -Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); -#ifdef DBG_UTIL - // check if we already have a interceptor for the given object - for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin(); - aIter != m_aControlDispatchInterceptors.end(); - ++aIter - ) - { - if ((*aIter)->getIntercepted() == _xInterception) - DBG_ERROR("FormController::createInterceptor : we already do intercept this objects dispatches !"); - } -#endif - - ::rtl::OUString sInterceptorScheme(RTL_CONSTASCII_USTRINGPARAM("*")); - FmXDispatchInterceptorImpl* pInterceptor = new FmXDispatchInterceptorImpl(_xInterception, this, 0, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); - pInterceptor->acquire(); - m_aControlDispatchInterceptors.insert(m_aControlDispatchInterceptors.end(), pInterceptor); - - return (XDispatchProviderInterceptor*)pInterceptor; -} - -//------------------------------------------------------------------------------ -bool FormController::ensureInteractionHandler() -{ - if ( m_xInteractionHandler.is() ) - return true; - if ( m_bAttemptedHandlerCreation ) - return false; - m_bAttemptedHandlerCreation = true; - if ( !m_xORB.is() ) - return false; - - m_xInteractionHandler.set( m_xORB->createInstance( SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); - OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" ); - return m_xInteractionHandler.is(); -} - -//------------------------------------------------------------------------------ -void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) -{ - if ( !ensureInteractionHandler() ) - return; - m_xInteractionHandler->handle( _rRequest ); -} - -//------------------------------------------------------------------------------ -void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) -{ - OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); - // search the interceptor responsible for the given object - InterceptorsIterator aIter; - for ( aIter = m_aControlDispatchInterceptors.begin(); - aIter != m_aControlDispatchInterceptors.end(); - ++aIter - ) - { - if ((*aIter)->getIntercepted() == _xInterception) - break; - } - if (aIter == m_aControlDispatchInterceptors.end()) - { - return; - } - - // log off the interception from it's interception object - FmXDispatchInterceptorImpl* pInterceptorImpl = *aIter; - pInterceptorImpl->dispose(); - pInterceptorImpl->release(); - - // remove the interceptor from our array - m_aControlDispatchInterceptors.erase(aIter); -} - -//-------------------------------------------------------------------- -void FormController::implInvalidateCurrentControlDependentFeatures() -{ - ::std::vector< sal_Int32 > aCurrentControlDependentFeatures; - - aCurrentControlDependentFeatures.push_back( SID_FM_SORTUP ); - aCurrentControlDependentFeatures.push_back( SID_FM_SORTDOWN ); - aCurrentControlDependentFeatures.push_back( SID_FM_AUTOFILTER ); - aCurrentControlDependentFeatures.push_back( SID_FM_REFRESH_FORM_CONTROL ); - - invalidateFeatures( aCurrentControlDependentFeatures ); -} - -//-------------------------------------------------------------------- -void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) -{ - implInvalidateCurrentControlDependentFeatures(); -} - -} // namespace svxform diff --git a/svx/source/form/fmdispatch.cxx b/svx/source/form/fmdispatch.cxx deleted file mode 100644 index 154063409bef..000000000000 --- a/svx/source/form/fmdispatch.cxx +++ /dev/null @@ -1,229 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: fmdispatch.cxx,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" -#include "fmdispatch.hxx" -#include "formcontrolling.hxx" - -//........................................................................ -namespace svx -{ -//........................................................................ - - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::frame; - using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::util; - using namespace ::com::sun::star::form::runtime; - - //==================================================================== - //= OSingleFeatureDispatcher - //==================================================================== - //-------------------------------------------------------------------- - OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) - ,m_aStatusListeners( _rMutex ) - ,m_rController( _rController ) - ,m_aFeatureURL( _rFeatureURL ) - ,m_nFeatureId( _nFeatureId ) - ,m_bLastKnownEnabled( sal_False ) - ,m_bDisposed( sal_False ) - { - } - - //-------------------------------------------------------------------- - void OSingleFeatureDispatcher::dispose() - { - { - ::osl::MutexGuard aGuard( m_rMutex ); - if ( m_bDisposed ) - return; - } - - EventObject aDisposeEvent( *this ); - m_aStatusListeners.disposeAndClear( aDisposeEvent ); - - { - ::osl::MutexGuard aGuard( m_rMutex ); - m_bDisposed = sal_True; - } - } - - //-------------------------------------------------------------------- - void OSingleFeatureDispatcher::getUnoState( FeatureStateEvent& /* [out] */ _rState ) const - { - FeatureState aState; - _rState.Source = *const_cast< OSingleFeatureDispatcher* >( this ); - - m_rController.getState( m_nFeatureId, aState ); - - _rState.FeatureURL = m_aFeatureURL; - _rState.IsEnabled = aState.Enabled; - _rState.Requery = sal_False; - _rState.State = aState.State; - } - - //-------------------------------------------------------------------- - void OSingleFeatureDispatcher::updateAllListeners() - { - ::osl::ClearableMutexGuard aGuard( m_rMutex ); - - FeatureStateEvent aUnoState; - getUnoState( aUnoState ); - - if ( ( m_aLastKnownState == aUnoState.State ) && ( m_bLastKnownEnabled == aUnoState.IsEnabled ) ) - return; - - m_aLastKnownState = aUnoState.State; - m_bLastKnownEnabled = aUnoState.IsEnabled; - - notifyStatus( NULL, aGuard ); - } - - //-------------------------------------------------------------------- - void OSingleFeatureDispatcher::notifyStatus( const Reference< XStatusListener >& _rxListener, ::osl::ClearableMutexGuard& _rFreeForNotification ) - { - FeatureStateEvent aUnoState; - getUnoState( aUnoState ); - - if ( _rxListener.is() ) - { - try - { - _rFreeForNotification.clear(); - _rxListener->statusChanged( aUnoState ); - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught an exception!" ); - } - } - else - { - ::cppu::OInterfaceIteratorHelper aIter( m_aStatusListeners ); - _rFreeForNotification.clear(); - - while ( aIter.hasMoreElements() ) - { - try - { - static_cast< XStatusListener* >( aIter.next() )->statusChanged( aUnoState ); - } - catch( const DisposedException& ) - { - OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a DisposedException - removing the listener!" ); - aIter.remove( ); - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a generic exception while notifying a single listener!" ); - } - } - } - } - - //-------------------------------------------------------------------- - void SAL_CALL OSingleFeatureDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException) - { - ::osl::ClearableMutexGuard aGuard( m_rMutex ); - checkAlive(); - - OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::dispatch: not responsible for this URL!" ); - (void)_rURL; - - if ( m_rController.isEnabled( m_nFeatureId ) ) - { - // release our mutex before executing the slot? - sal_Int32 nFeatureId( m_nFeatureId ); - aGuard.clear(); - - if ( !_rArguments.getLength() ) - { - m_rController.execute( nFeatureId ); - } - else - { // at the moment we only support one parameter - m_rController.execute( nFeatureId, _rArguments[0].Name, _rArguments[0].Value ); - } - } - } - - //-------------------------------------------------------------------- - void SAL_CALL OSingleFeatureDispatcher::addStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException) - { - (void)_rURL; - OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::addStatusListener: unexpected URL!" ); - OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::addStatusListener: senseless call!" ); - if ( !_rxControl.is() ) - return; - - ::osl::ClearableMutexGuard aGuard( m_rMutex ); - if ( m_bDisposed ) - { - EventObject aDisposeEvent( *this ); - aGuard.clear(); - _rxControl->disposing( aDisposeEvent ); - return; - } - - m_aStatusListeners.addInterface( _rxControl ); - - // initially update the status - notifyStatus( _rxControl, aGuard ); - } - - //-------------------------------------------------------------------- - void SAL_CALL OSingleFeatureDispatcher::removeStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException) - { - (void)_rURL; - OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::removeStatusListener: unexpected URL!" ); - OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::removeStatusListener: senseless call!" ); - if ( !_rxControl.is() ) - return; - - ::osl::MutexGuard aGuard( m_rMutex ); - checkAlive(); - - m_aStatusListeners.removeInterface( _rxControl ); - } - - //-------------------------------------------------------------------- - void OSingleFeatureDispatcher::checkAlive() const SAL_THROW((DisposedException)) - { - if ( m_bDisposed ) - throw DisposedException( ::rtl::OUString(), *const_cast< OSingleFeatureDispatcher* >( this ) ); - } - -//........................................................................ -} // namespace svx -//........................................................................ diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 8d71cfb4ce24..0f6894cb5ac8 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -43,7 +43,6 @@ #include "fmundo.hxx" #include "fmurl.hxx" #include "fmvwimp.hxx" -#include "formcontrolling.hxx" #include "formtoolbars.hxx" #include "gridcols.hxx" #include "svditer.hxx" @@ -502,7 +501,6 @@ FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame ) ,m_pTextShell( new ::svx::FmTextControlShell( _pViewFrame ) ) ,m_aActiveControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) ,m_aNavControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) - ,m_pExternalViewInterceptor( NULL ) ,m_eDocumentType( eUnknownDocumentType ) ,m_nLockSlotInvalidation( 0 ) ,m_bHadPropertyBrowserInDesignMode( sal_False ) @@ -797,14 +795,6 @@ void FmXFormShell::disposing() // are still uncommitted changes, the user explicitly wanted this. // 2002-11-11 - 104702 - fs@openoffice.org - // dispose our interceptor helpers - if (m_pExternalViewInterceptor) - { - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - m_pTextShell->dispose(); m_xAttachedFrame = NULL; @@ -2941,7 +2931,7 @@ void FmXFormShell::startFiltering() { Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(FILTER_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); } } @@ -3048,7 +3038,7 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(DATA_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); } if (bSave) // execute the filter { @@ -3564,28 +3554,8 @@ void FmXFormShell::CreateExternalView() xClear->dispatch(aClearURL, Sequence< PropertyValue>()); } - // interception of slots of the external view - if (m_pExternalViewInterceptor) - { // already intercepting ... - if (m_pExternalViewInterceptor->getIntercepted() != xExternalViewFrame) - { // ... but another frame -> create a new interceptor - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - } - - if (!m_pExternalViewInterceptor) - { - Reference< ::com::sun::star::frame::XDispatchProviderInterception> xSupplier(xExternalViewFrame, UNO_QUERY); - ::rtl::OUString sInterceptorScheme = FMURL_FORMSLOTS_PREFIX; - sInterceptorScheme += ::rtl::OUString::createFromAscii("*"); -// m_pExternalViewInterceptor = new FmXDispatchInterceptorImpl(xSupplier, this, 1, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); -// m_pExternalViewInterceptor->acquire(); - // TODO: re-implement this in a easier way than before: We need an interceptor at the xSupplier, which - // forwards all queryDispatch requests to the FormController instance for which this "external view" - // was triggered - } + // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController + // instance for which this "external view" was triggered // get the dispatch interface of the frame so we can communicate (interceptable) with the controller Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY); diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index df8b51b8b82f..03dd6f97021d 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -884,176 +884,6 @@ sal_Int16 GridView2ModelPos(const Reference< ::com::sun::star::container::XInd return (sal_Int16)-1; } -//======================================================================== -//= FmXDispatchInterceptorImpl -//======================================================================== - -DBG_NAME(FmXDispatchInterceptorImpl); -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::FmXDispatchInterceptorImpl( - const Reference< XDispatchProviderInterception >& _rxToIntercept, FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, Sequence< ::rtl::OUString > _rInterceptedSchemes) - :FmXDispatchInterceptorImpl_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) - ,m_xIntercepted(_rxToIntercept) - ,m_bListening(sal_False) - ,m_pMaster(_pMaster) - ,m_nId(_nId) - ,m_aInterceptedURLSchemes(_rInterceptedSchemes) -{ - DBG_CTOR(FmXDispatchInterceptorImpl,NULL); - - ::osl::MutexGuard aGuard(getAccessSafety()); - ::comphelper::increment(m_refCount); - if (_rxToIntercept.is()) - { - _rxToIntercept->registerDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this); - // this should make us the top-level dispatch-provider for the component, via a call to our - // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); - if (xInterceptedComponent.is()) - { - xInterceptedComponent->addEventListener(this); - m_bListening = sal_True; - } - } - ::comphelper::decrement(m_refCount); -} - -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::~FmXDispatchInterceptorImpl() -{ - if (!rBHelper.bDisposed) - dispose(); - - DBG_DTOR(FmXDispatchInterceptorImpl,NULL); -} - -//------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXDispatchInterceptorImpl::getImplementationId() throw(RuntimeException) -{ - static ::cppu::OImplementationId* pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXDispatchInterceptorImpl::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Reference< ::com::sun::star::frame::XDispatch> xResult; - // ask our 'real' interceptor - if (m_pMaster) - xResult = m_pMaster->interceptedQueryDispatch(m_nId, aURL, aTargetFrameName, nSearchFlags); - - // ask our slave provider - if (!xResult.is() && m_xSlaveDispatcher.is()) - xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); - - return xResult; -} - -//------------------------------------------------------------------------------ -Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL -FmXDispatchInterceptorImpl::queryDispatches( const Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Sequence< Reference< ::com::sun::star::frame::XDispatch> > aReturn(aDescripts.getLength()); - Reference< ::com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray(); - const ::com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - for (sal_Int16 i=0; iFeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); - } - return aReturn; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL FmXDispatchInterceptorImpl::getSlaveDispatchProvider( ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xSlaveDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setSlaveDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xSlaveDispatcher = xNewDispatchProvider; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider> SAL_CALL FmXDispatchInterceptorImpl::getMasterDispatchProvider(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xMasterDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setMasterDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewSupplier) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xMasterDispatcher = xNewSupplier; -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FmXDispatchInterceptorImpl::getInterceptedURLs( ) throw(RuntimeException) -{ - return m_aInterceptedURLSchemes; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ) -{ - if (m_bListening) - { - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (Source.Source == xIntercepted) - ImplDetach(); - } -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::ImplDetach() -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - OSL_ENSURE(m_bListening, "FmXDispatchInterceptorImpl::ImplDetach: invalid call!"); - - // deregister ourself from the interception component - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (xIntercepted.is()) - xIntercepted->releaseDispatchProviderInterceptor(static_cast(this)); - -// m_xIntercepted = Reference< XDispatchProviderInterception >(); - // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were - // responsible. As we hold the object with a weak reference only, this should be no problem. - // 88936 - 23.07.2001 - frank.schoenheit@sun.com - m_pMaster = NULL; - m_bListening = sal_False; -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::disposing() -{ - // remove ourself as event listener from the interception component - if (m_bListening) - { - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); - if (xInterceptedComponent.is()) - xInterceptedComponent->removeEventListener(static_cast(this)); - - // detach from the interception component - ImplDetach(); - } -} - //============================================================================== //============================================================================== diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx new file mode 100644 index 000000000000..bc50ee0de517 --- /dev/null +++ b/svx/source/form/formcontroller.cxx @@ -0,0 +1,4286 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "confirmdelete.hxx" +#include "fmcontrolbordermanager.hxx" +#include "fmcontrollayout.hxx" +#include "formcontroller.hxx" +#include "formfeaturedispatcher.hxx" +#include "fmdocumentclassification.hxx" +#include "formcontrolling.hxx" +#include "fmprop.hrc" +#include "svx/dialmgr.hxx" +#include "fmresids.hrc" +#include "fmservs.hxx" +#include "fmurl.hxx" +#include "fmtools.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace ::com::sun::star; +using namespace ::comphelper; +using namespace ::connectivity; +using namespace ::connectivity::simple; + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) +{ + return *( new ::svxform::FormController( _rxORB ) ); +} + +namespace svxform +{ + + /** === begin UNO using === **/ + using ::com::sun::star::sdb::XColumn; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::awt::XTabController; + using ::com::sun::star::awt::XToolkit; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::form::XGrid; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::sdb::XInteractionSupplyParameters; + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::awt::XTextListener; + using ::com::sun::star::uno::Any; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::XAggregation; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::sdbc::XDatabaseMetaData; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormatter; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::Property; + using ::com::sun::star::container::XEnumeration; + using ::com::sun::star::form::XFormComponent; + using ::com::sun::star::form::runtime::XFormOperations; + using ::com::sun::star::form::runtime::FilterEvent; + using ::com::sun::star::form::runtime::XFilterControllerListener; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::container::XIdentifierReplace; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::form::XFormControllerListener; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::awt::XControlModel; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::form::validation::XValidatableFormComponent; + using ::com::sun::star::form::XLoadable; + using ::com::sun::star::script::XEventAttacherManager; + using ::com::sun::star::form::XBoundControl; + using ::com::sun::star::beans::XPropertyChangeListener; + using ::com::sun::star::awt::TextEvent; + using ::com::sun::star::form::XBoundComponent; + using ::com::sun::star::awt::XCheckBox; + using ::com::sun::star::awt::XComboBox; + using ::com::sun::star::awt::XListBox; + using ::com::sun::star::awt::ItemEvent; + using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::form::XReset; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::form::XGridControl; + using ::com::sun::star::awt::XVclWindowPeer; + using ::com::sun::star::form::validation::XValidator; + using ::com::sun::star::awt::FocusEvent; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::container::XChild; + using ::com::sun::star::form::TabulatorCycle_RECORDS; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::beans::NamedValue; + using ::com::sun::star::lang::NoSupportException; + using ::com::sun::star::sdb::RowChangeEvent; + using ::com::sun::star::frame::XStatusListener; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::sdb::SQLErrorEvent; + using ::com::sun::star::form::DatabaseParameterEvent; + using ::com::sun::star::sdb::ParametersRequest; + using ::com::sun::star::task::XInteractionRequest; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::FeatureStateEvent; + using ::com::sun::star::form::runtime::XFormControllerContext; + using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::form::runtime::FormOperations; + using ::com::sun::star::container::XContainer; + /** === end UNO using === **/ + namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason; + namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; + +//============================================================================== +// ColumnInfo +//============================================================================== +struct ColumnInfo +{ + // information about the column itself + Reference< XColumn > xColumn; + sal_Int32 nNullable; + sal_Bool bAutoIncrement; + sal_Bool bReadOnly; + ::rtl::OUString sName; + + // information about the control(s) bound to this column + + /// the first control which is bound to the given column, and which requires input + Reference< XControl > xFirstControlWithInputRequired; + /** the first grid control which contains a column which is bound to the given database column, and requires + input + */ + Reference< XGrid > xFirstGridWithInputRequiredColumn; + /** if xFirstControlWithInputRequired is a grid control, then nRequiredGridColumn specifies the position + of the grid column which is actually bound + */ + sal_Int32 nRequiredGridColumn; + + ColumnInfo() + :xColumn() + ,nNullable( ColumnValue::NULLABLE_UNKNOWN ) + ,bAutoIncrement( sal_False ) + ,bReadOnly( sal_False ) + ,sName() + ,xFirstControlWithInputRequired() + ,xFirstGridWithInputRequiredColumn() + ,nRequiredGridColumn( -1 ) + { + } +}; + +//============================================================================== +//= ColumnInfoCache +//============================================================================== +class ColumnInfoCache +{ +public: + ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier ); + + size_t getColumnCount() const { return m_aColumns.size(); } + const ColumnInfo& getColumnInfo( size_t _pos ); + + bool controlsInitialized() const { return m_bControlsInitialized; } + void initializeControls( const Sequence< Reference< XControl > >& _rControls ); + void deinitializeControls(); + +private: + typedef ::std::vector< ColumnInfo > ColumnInfos; + ColumnInfos m_aColumns; + bool m_bControlsInitialized; +}; + +//------------------------------------------------------------------------------ +ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier ) + :m_aColumns() + ,m_bControlsInitialized( false ) +{ + try + { + m_aColumns.clear(); + + Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW ); + Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW ); + sal_Int32 nColumnCount = xColumns->getCount(); + m_aColumns.reserve( nColumnCount ); + + Reference< XPropertySet > xColumnProps; + for ( sal_Int32 i = 0; i < nColumnCount; ++i ) + { + ColumnInfo aColInfo; + aColInfo.xColumn.set( xColumns->getByIndex(i), UNO_QUERY_THROW ); + + xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW ); + OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable ); + OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_AUTOINCREMENT ) >>= aColInfo.bAutoIncrement ); + OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_NAME ) >>= aColInfo.sName ); + OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISREADONLY ) >>= aColInfo.bReadOnly ); + + m_aColumns.push_back( aColInfo ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +namespace +{ + bool lcl_isBoundTo( const Reference< XPropertySet >& _rxControlModel, const Reference< XInterface >& _rxNormDBField ) + { + Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY ); + return ( xNormBoundField.get() == _rxNormDBField.get() ); + } + + bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel ) + { + sal_Bool bInputRequired = sal_True; + OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired ); + return ( bInputRequired != sal_False ); + } + + void lcl_resetColumnControlInfo( ColumnInfo& _rColInfo ) + { + _rColInfo.xFirstControlWithInputRequired.clear(); + _rColInfo.xFirstGridWithInputRequiredColumn.clear(); + _rColInfo.nRequiredGridColumn = -1; + } +} + +//------------------------------------------------------------------------------ +void ColumnInfoCache::deinitializeControls() +{ + for ( ColumnInfos::iterator col = m_aColumns.begin(); + col != m_aColumns.end(); + ++col + ) + { + lcl_resetColumnControlInfo( *col ); + } +} + +//------------------------------------------------------------------------------ +void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls ) +{ + try + { + // for every of our known columns, find the controls which are bound to this column + for ( ColumnInfos::iterator col = m_aColumns.begin(); + col != m_aColumns.end(); + ++col + ) + { + OSL_ENSURE( !col->xFirstControlWithInputRequired.is() && !col->xFirstGridWithInputRequiredColumn.is() + && ( col->nRequiredGridColumn == -1 ), "ColumnInfoCache::initializeControls: called me twice?" ); + + lcl_resetColumnControlInfo( *col ); + + Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW ); + + const Reference< XControl >* pControl( _rControls.getConstArray() ); + const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() ); + for ( ; pControl != pControlEnd; ++pControl ) + { + if ( !pControl->is() ) + continue; + + Reference< XPropertySet > xModel( (*pControl)->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW ); + + // special handling for grid controls + Reference< XGrid > xGrid( *pControl, UNO_QUERY ); + if ( xGrid.is() ) + { + Reference< XIndexAccess > xGridColAccess( xModel, UNO_QUERY_THROW ); + sal_Int32 gridColCount = xGridColAccess->getCount(); + sal_Int32 gridCol = 0; + for ( gridCol = 0; gridCol < gridColCount; ++gridCol ) + { + Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW ); + + if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn ) + || !lcl_isInputRequired( xGridColumnModel ) + ) + continue; // with next grid column + + break; + } + + if ( gridCol < gridColCount ) + { + // found a grid column which is bound to the given + col->xFirstGridWithInputRequiredColumn = xGrid; + col->nRequiredGridColumn = gridCol; + break; + } + + continue; // with next control + } + + if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) + || !lcl_isBoundTo( xModel, xNormColumn ) + || !lcl_isInputRequired( xModel ) + ) + continue; // with next control + + break; + } + + if ( pControl == pControlEnd ) + // did not find a control which is bound to this particular column, and for which the input is required + continue; // with next DB column + + col->xFirstControlWithInputRequired = *pControl; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_bControlsInitialized = true; +} + +//------------------------------------------------------------------------------ +const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos ) +{ + if ( _pos >= m_aColumns.size() ) + throw IndexOutOfBoundsException(); + + return m_aColumns[ _pos ]; +} + +//================================================================== +// OParameterContinuation +//================================================================== +class OParameterContinuation : public OInteraction< XInteractionSupplyParameters > +{ + Sequence< PropertyValue > m_aValues; + +public: + OParameterContinuation() { } + + Sequence< PropertyValue > getValues() const { return m_aValues; } + +// XInteractionSupplyParameters + virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException); +}; + +//------------------------------------------------------------------ +void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException) +{ + m_aValues = _rValues; +} + +//================================================================== +// FmXAutoControl +//================================================================== +struct FmFieldInfo +{ + rtl::OUString aFieldName; + Reference< XPropertySet > xField; + Reference< XTextComponent > xText; + + FmFieldInfo(const Reference< XPropertySet >& _xField, const Reference< XTextComponent >& _xText) + :xField(_xField) + ,xText(_xText) + {xField->getPropertyValue(FM_PROP_NAME) >>= aFieldName;} +}; + +//================================================================== +// FmXAutoControl +//================================================================== +class FmXAutoControl: public UnoControl + +{ + friend Reference< XInterface > SAL_CALL FmXAutoControl_NewInstance_Impl(); + +public: + FmXAutoControl(){} + + virtual ::rtl::OUString GetComponentServiceName() {return ::rtl::OUString::createFromAscii("Edit");} + virtual void SAL_CALL createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException ); + +protected: + virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal ); +}; + +//------------------------------------------------------------------------------ +void FmXAutoControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException ) +{ + UnoControl::createPeer( rxToolkit, rParentPeer ); + + Reference< XTextComponent > xText(getPeer() , UNO_QUERY); + if (xText.is()) + { + xText->setText(::rtl::OUString(String(SVX_RES(RID_STR_AUTOFIELD)))); + xText->setEditable(sal_False); + } +} + +//------------------------------------------------------------------------------ +void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal ) +{ + // these properties are ignored + if (rPropName == FM_PROP_TEXT) + return; + + UnoControl::ImplSetPeerProperty( rPropName, rVal ); +} + +//------------------------------------------------------------------------------ +IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) +{ + activateTabOrder(); + return 1; +} + +//------------------------------------------------------------------------------ +struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch >, bool > +{ + bool operator()( const Reference< XDispatch >& _rxDispatcher ) const + { + static_cast< ::svx::OSingleFeatureDispatcher* >( _rxDispatcher.get() )->updateAllListeners(); + // the return is a dummy only so we can use this struct in a std::compose1 call + return true; + } +}; +//.............................................................................. +IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + for ( ::std::set< sal_Int16 >::const_iterator aLoop = m_aInvalidFeatures.begin(); + aLoop != m_aInvalidFeatures.end(); + ++aLoop + ) + { + DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( *aLoop ); + if ( aDispatcherPos != m_aFeatureDispatchers.end() ) + { + // TODO: for the real and actual listener notifications, we should release + // our mutex + UpdateAllListeners( )( aDispatcherPos->second ); + } + } + return 1; +} + +/*************************************************************************/ + +DBG_NAME( FormController ) +//------------------------------------------------------------------ +FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ) + :FormController_BASE( m_aMutex ) + ,OPropertySetHelper( FormController_BASE::rBHelper ) + ,OSQLParserClient( _rxORB ) + ,m_aContext( _rxORB ) + ,m_aActivateListeners(m_aMutex) + ,m_aModifyListeners(m_aMutex) + ,m_aErrorListeners(m_aMutex) + ,m_aDeleteListeners(m_aMutex) + ,m_aRowSetApproveListeners(m_aMutex) + ,m_aParameterListeners(m_aMutex) + ,m_aFilterListeners(m_aMutex) + ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) + ,m_xFormOperations() + ,m_aMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ) + ,m_aLoadEvent( LINK( this, FormController, OnLoad ) ) + ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) + ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) + ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) ) + ,m_nCurrentFilterPosition(-1) + ,m_bCurrentRecordModified(sal_False) + ,m_bCurrentRecordNew(sal_False) + ,m_bLocked(sal_False) + ,m_bDBConnection(sal_False) + ,m_bCycle(sal_False) + ,m_bCanInsert(sal_False) + ,m_bCanUpdate(sal_False) + ,m_bCommitLock(sal_False) + ,m_bModified(sal_False) + ,m_bControlsSorted(sal_False) + ,m_bFiltering(sal_False) + ,m_bAttachEvents(sal_True) + ,m_bDetachEvents(sal_True) + ,m_bAttemptedHandlerCreation( false ) +{ + DBG_CTOR( FormController, NULL ); + + ::comphelper::increment(m_refCount); + { + { + m_xAggregate = Reference< XAggregation >( + m_aContext.createComponent( "com.sun.star.awt.TabController" ), + UNO_QUERY + ); + DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" ); + m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY ); + } + + if ( m_xAggregate.is() ) + m_xAggregate->setDelegator( *this ); + } + ::comphelper::decrement(m_refCount); + + m_aTabActivationTimer.SetTimeout( 500 ); + m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) ); + + m_aFeatureInvalidationTimer.SetTimeout( 200 ); + m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) ); +} + +//------------------------------------------------------------------ +FormController::~FormController() +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + + m_aLoadEvent.CancelPendingCall(); + m_aToggleEvent.CancelPendingCall(); + m_aActivationEvent.CancelPendingCall(); + m_aDeactivationEvent.CancelPendingCall(); + + if ( m_aTabActivationTimer.IsActive() ) + m_aTabActivationTimer.Stop(); + } + + if ( m_aFeatureInvalidationTimer.IsActive() ) + m_aFeatureInvalidationTimer.Stop(); + + disposeAllFeaturesAndDispatchers(); + + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + + // Freigeben der Aggregation + if ( m_xAggregate.is() ) + { + m_xAggregate->setDelegator( NULL ); + m_xAggregate.clear(); + } + + DELETEZ( m_pControlBorderManager ); + + DBG_DTOR( FormController, NULL ); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL FormController::acquire() throw () +{ + FormController_BASE::acquire(); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL FormController::release() throw () +{ + FormController_BASE::release(); +} + +//------------------------------------------------------------------ +Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException) +{ + Any aRet = FormController_BASE::queryInterface( _rType ); + if ( !aRet.hasValue() ) + aRet = OPropertySetHelper::queryInterface( _rType ); + if ( !aRet.hasValue() ) + aRet = m_xAggregate->queryAggregation( _rType ); + return aRet; +} + +//------------------------------------------------------------------------------ +Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException ) +{ + static ::cppu::OImplementationId* pId = NULL; + if ( !pId ) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if ( !pId ) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +//------------------------------------------------------------------------------ +Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException) +{ + return comphelper::concatSequences( + FormController_BASE::getTypes(), + ::cppu::OPropertySetHelper::getTypes() + ); +} + +// XServiceInfo +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) +{ + Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames()); + const ::rtl::OUString * pArray = aSNL.getConstArray(); + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return sal_True; + return sal_False; +} + +//------------------------------------------------------------------------------ +::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException ) +{ + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.FormController" ); +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException ) +{ + // service names which are supported only, but cannot be used to created an + // instance at a service factory + Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 ); + aNonCreatableServiceNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormControllerDispatcher" ) ); + + // services which can be used to created an instance at a service factory + Sequence< ::rtl::OUString > aCreatableServiceNames( getSupportedServiceNames_Static() ); + return ::comphelper::concatSequences( aCreatableServiceNames, aNonCreatableServiceNames ); +} + +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) +{ + return sal_True; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source)) + m_bModified = sal_False; +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) +{ + static Sequence< ::rtl::OUString> aServices; + if (!aServices.getLength()) + { + aServices.realloc(2); + aServices.getArray()[0] = FM_FORM_CONTROLLER; + aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); + } + return aServices; +} + +// ----------------------------------------------------------------------------- +namespace +{ + struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void > + { + void operator()( const Reference< XTextComponent >& _rxText ) + { + _rxText->setText( ::rtl::OUString() ); + } + }; + + struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void > + { + RemoveComponentTextListener( const Reference< XTextListener >& _rxListener ) + :m_xListener( _rxListener ) + { + } + + void operator()( const Reference< XTextComponent >& _rxText ) + { + _rxText->removeTextListener( m_xListener ); + } + + private: + Reference< XTextListener > m_xListener; + }; +} + +// ----------------------------------------------------------------------------- +void FormController::impl_setTextOnAllFilter_throw() +{ + // reset the text for all controls + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() ); + + if ( m_aFilterRows.empty() ) + // nothing to do anymore + return; + + if ( m_nCurrentFilterPosition < 0 ) + return; + + // set the text for all filters + OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition, + "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" ); + + if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() ) + { + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; + for ( FmFilterRow::const_iterator iter2 = rRow.begin(); + iter2 != rRow.end(); + ++iter2 + ) + { + iter2->first->setText( iter2->second ); + } + } +} +// OPropertySetHelper +//------------------------------------------------------------------------------ +sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, + sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) + throw( IllegalArgumentException ) +{ + return sal_False; +} + +//------------------------------------------------------------------------------ +void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) + throw( Exception ) +{ +} + +//------------------------------------------------------------------------------ +void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +{ + switch (nHandle) + { + case FM_ATTR_FILTER: + { + ::rtl::OUStringBuffer aFilter; + OStaticDataAccessTools aStaticTools; + Reference xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY))); + if (xConnection.is()) + { + Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); + Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, sal_True ) ); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW ); + xFormatter->attachNumberFormatsSupplier(xFormatSupplier); + + Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY); + Reference< XNameAccess> xFields(xSupplyCols->getColumns(), UNO_QUERY); + + ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() ); + + // now add the filter rows + try + { + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row ) + { + const FmFilterRow& rRow = *row; + + if ( rRow.empty() ) + continue; + + if ( aFilter.getLength() ) + aFilter.appendAscii( " OR " ); + + aFilter.appendAscii( "( " ); + for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) + { + // get the field of the controls map + Reference< XControl > xControl( condition->first, UNO_QUERY_THROW ); + Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); + if ( condition != rRow.begin() ) + aFilter.appendAscii( " AND " ); + + ::rtl::OUString sFilterValue( condition->second ); + + ::rtl::OUString sErrorMsg, sCriteria; + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); + OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); + if ( xParseNode.is() ) + { + // don't use a parse context here, we need it unlocalized + xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); + aFilter.append( sCriteria ); + } + } + aFilter.appendAscii( " )" ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + aFilter.setLength(0); + } + } + rValue <<= aFilter.makeStringAndClear(); + } + break; + + case FM_ATTR_FORM_OPERATIONS: + rValue <<= m_xFormOperations; + break; + } +} + +//------------------------------------------------------------------------------ +Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException ) +{ + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +//------------------------------------------------------------------------------ +#define DECL_PROP_CORE(varname, type) \ +pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((const type*)0), + + +#define DECL_PROP1(varname, type, attrib1) \ + DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1) + +//------------------------------------------------------------------------------ +void FormController::fillProperties( + Sequence< Property >& /* [out] */ _rProps, + Sequence< Property >& /* [out] */ /*_rAggregateProps*/ + ) const +{ + _rProps.realloc(2); + sal_Int32 nPos = 0; + Property* pDesc = _rProps.getArray(); + DECL_PROP1(FILTER, rtl::OUString, READONLY); + DECL_PROP1(FORM_OPERATIONS, Reference< XFormOperations >, READONLY); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper& FormController::getInfoHelper() +{ + return *getArrayHelper(); +} + +// XFilterController +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.addInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.removeInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilterComponents.size(); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilterRows.size(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] ); + xText->setText( _PredicateExpression ); + + FmFilterRow& rFilterRow = m_aFilterRows[ _Term ]; + if ( _PredicateExpression.getLength() ) + rFilterRow[ xText ] = _PredicateExpression; + else + rFilterRow.erase( xText ); +} + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY ); +} + +//------------------------------------------------------------------------------ +Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() ); + sal_Int32 termIndex = 0; + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); + row != m_aFilterRows.end(); + ++row, ++termIndex + ) + { + const FmFilterRow& rRow( *row ); + + Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() ); + sal_Int32 componentIndex = 0; + for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin(); + comp != m_aFilterComponents.end(); + ++comp, ++componentIndex + ) + { + FmFilterRow::const_iterator predicate = rRow.find( *comp ); + if ( predicate != rRow.end() ) + aConjunction[ componentIndex ] = predicate->second; + } + + aExpressions[ termIndex ] = aConjunction; + } + + return aExpressions; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + // if the to-be-deleted row is our current row, we need to shift + if ( _Term == m_nCurrentFilterPosition ) + { + if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) ) + ++m_nCurrentFilterPosition; + else + --m_nCurrentFilterPosition; + } + + FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term; + m_aFilterRows.erase( pos ); + + // adjust m_nCurrentFilterPosition if the removed row preceeded it + if ( _Term < m_nCurrentFilterPosition ) + --m_nCurrentFilterPosition; + + OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ), + "FormController::removeDisjunctiveTerm: inconsistency!" ); + + // update the texts in the filter controls + impl_setTextOnAllFilter_throw(); + + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = _Term; + aGuard.clear(); + // <-- SYNCHRONIZED + + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + impl_appendEmptyFilterRow( aGuard ); + // <-- SYNCHRONIZED +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_nCurrentFilterPosition; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + if ( _ActiveTerm == getActiveTerm() ) + return; + + m_nCurrentFilterPosition = _ActiveTerm; + impl_setTextOnAllFilter_throw(); +} + +// XElementAccess +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return !m_aChilds.empty(); +} + +//------------------------------------------------------------------------------ +Type SAL_CALL FormController::getElementType(void) throw( RuntimeException ) +{ + return ::getCppuType((const Reference< XFormController>*)0); + +} + +// XEnumerationAccess +//------------------------------------------------------------------------------ +Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return new ::comphelper::OEnumerationByIndex(this); +} + +// XIndexAccess +//------------------------------------------------------------------------------ +sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return m_aChilds.size(); +} + +//------------------------------------------------------------------------------ +Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (Index < 0 || + Index >= (sal_Int32)m_aChilds.size()) + throw IndexOutOfBoundsException(); + + return makeAny( m_aChilds[ Index ] ); +} + +// EventListener +//------------------------------------------------------------------------------ +void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException ) +{ + // Ist der Container disposed worden + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XControlContainer > xContainer(e.Source, UNO_QUERY); + if (xContainer.is()) + { + setContainer(Reference< XControlContainer > ()); + } + else + { + // ist ein Control disposed worden + Reference< XControl > xControl(e.Source, UNO_QUERY); + if (xControl.is()) + { + if (getContainer().is()) + removeControl(xControl); + } + } +} + +// OComponentHelper +//----------------------------------------------------------------------------- +void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) +{ + for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin(); + aDispatcher != m_aFeatureDispatchers.end(); + ++aDispatcher + ) + { + try + { + ::comphelper::disposeComponent( aDispatcher->second ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + m_aFeatureDispatchers.clear(); +} + +//----------------------------------------------------------------------------- +void FormController::disposing(void) +{ + EventObject aEvt( *this ); + + // if we're still active, simulate a "deactivated" event + if ( m_xActiveControl.is() ) + m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt ); + + // notify all our listeners + m_aActivateListeners.disposeAndClear(aEvt); + m_aModifyListeners.disposeAndClear(aEvt); + m_aErrorListeners.disposeAndClear(aEvt); + m_aDeleteListeners.disposeAndClear(aEvt); + m_aRowSetApproveListeners.disposeAndClear(aEvt); + m_aParameterListeners.disposeAndClear(aEvt); + m_aFilterListeners.disposeAndClear(aEvt); + + removeBoundFieldListener(); + stopFiltering(); + + m_pControlBorderManager->restoreAll(); + + m_aFilterRows.clear(); + + ::osl::MutexGuard aGuard( m_aMutex ); + m_xActiveControl = NULL; + implSetCurrentControl( NULL ); + + // clean up our children + for (FmFormControllers::const_iterator i = m_aChilds.begin(); + i != m_aChilds.end(); i++) + { + // search the position of the model within the form + Reference< XFormComponent > xForm((*i)->getModel(), UNO_QUERY); + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + + m_xModelAsIndex->getByIndex( --nPos ) >>= xTemp; + if ( xForm.get() == xTemp.get() ) + { + Reference< XInterface > xIfc( *i, UNO_QUERY ); + m_xModelAsManager->detach( nPos, xIfc ); + break; + } + } + + Reference< XComponent > (*i, UNO_QUERY)->dispose(); + } + m_aChilds.clear(); + + disposeAllFeaturesAndDispatchers(); + + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + + if (m_bDBConnection) + unload(); + + setContainer( NULL ); + setModel( NULL ); + setParent( NULL ); + + ::comphelper::disposeComponent( m_xComposer ); + + m_bDBConnection = sal_False; +} + +//------------------------------------------------------------------------------ +namespace +{ + static bool lcl_shouldUseDynamicControlBorder( const Reference< XInterface >& _rxForm, const Any& _rDynamicColorProp ) + { + bool bDoUse = false; + if ( !( _rDynamicColorProp >>= bDoUse ) ) + { + DocumentType eDocType = DocumentClassification::classifyHostDocument( _rxForm ); + return ControlLayouter::useDynamicBorderColor( eDocType ); + } + return bDoUse; + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + if ( evt.PropertyName == FM_PROP_BOUNDFIELD ) + { + Reference xOldBound; + evt.OldValue >>= xOldBound; + if ( !xOldBound.is() && evt.NewValue.hasValue() ) + { + Reference< XControlModel > xControlModel(evt.Source,UNO_QUERY); + Reference< XControl > xControl = findControl(m_aControls,xControlModel,sal_False,sal_False); + if ( xControl.is() ) + { + startControlModifyListening( xControl ); + Reference xProp(xControlModel,UNO_QUERY); + if ( xProp.is() ) + xProp->removePropertyChangeListener(FM_PROP_BOUNDFIELD, this); + } + } + } + else + { + sal_Bool bModifiedChanged = (evt.PropertyName == FM_PROP_ISMODIFIED); + sal_Bool bNewChanged = (evt.PropertyName == FM_PROP_ISNEW); + if (bModifiedChanged || bNewChanged) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (bModifiedChanged) + m_bCurrentRecordModified = ::comphelper::getBOOL(evt.NewValue); + else + m_bCurrentRecordNew = ::comphelper::getBOOL(evt.NewValue); + + // toggle the locking + if (m_bLocked != determineLockState()) + { + m_bLocked = !m_bLocked; + setLocks(); + if (isListeningForChanges()) + startListening(); + else + stopListening(); + } + + if ( bNewChanged ) + m_aToggleEvent.Call(); + + if (!m_bCurrentRecordModified) + m_bModified = sal_False; + } + else if ( evt.PropertyName == FM_PROP_DYNAMIC_CONTROL_BORDER ) + { + bool bEnable = lcl_shouldUseDynamicControlBorder( evt.Source, evt.NewValue ); + if ( bEnable ) + { + m_pControlBorderManager->enableDynamicBorderColor(); + if ( m_xActiveControl.is() ) + m_pControlBorderManager->focusGained( m_xActiveControl.get() ); + } + else + { + m_pControlBorderManager->disableDynamicBorderColor(); + } + } + } +} + +//------------------------------------------------------------------------------ +bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) +{ + bool bSuccess = false; + try + { + Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY ); + DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); + if ( xContainer.is() ) + { + // look up the ID of _rxExistentControl + Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() ); + const sal_Int32* pIdentifiers = aIdentifiers.getConstArray(); + const sal_Int32* pIdentifiersEnd = aIdentifiers.getConstArray() + aIdentifiers.getLength(); + for ( ; pIdentifiers != pIdentifiersEnd; ++pIdentifiers ) + { + Reference< XControl > xCheck( xContainer->getByIdentifier( *pIdentifiers ), UNO_QUERY ); + if ( xCheck == _rxExistentControl ) + break; + } + DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" ); + if ( pIdentifiers != pIdentifiersEnd ) + { + bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() ); + bool bReplacedWasCurrent = ( m_xCurrentControl.get() == _rxExistentControl.get() ); + + if ( bReplacedWasActive ) + { + m_xActiveControl = NULL; + implSetCurrentControl( NULL ); + } + else if ( bReplacedWasCurrent ) + { + implSetCurrentControl( _rxNewControl ); + } + + // carry over the model + _rxNewControl->setModel( _rxExistentControl->getModel() ); + + xContainer->replaceByIdentifer( *pIdentifiers, makeAny( _rxNewControl ) ); + bSuccess = true; + + if ( bReplacedWasActive ) + { + Reference< XWindow > xControlWindow( _rxNewControl, UNO_QUERY ); + if ( xControlWindow.is() ) + xControlWindow->setFocus(); + } + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl ); + ::comphelper::disposeComponent( xDisposeIt ); + return bSuccess; +} + +//------------------------------------------------------------------------------ +void FormController::toggleAutoFields(sal_Bool bAutoFields) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + + Sequence< Reference< XControl > > aControlsCopy( m_aControls ); + const Reference< XControl >* pControls = aControlsCopy.getConstArray(); + sal_Int32 nControls = aControlsCopy.getLength(); + + if (bAutoFields) + { + // as we don't want new controls to be attached to the scripting environment + // we change attach flags + m_bAttachEvents = sal_False; + for (sal_Int32 i = nControls; i > 0;) + { + Reference< XControl > xControl = pControls[--i]; + if (xControl.is()) + { + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // does the model use a bound field ? + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + + // is it a autofield? + if ( xField.is() + && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField ) + && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_AUTOINCREMENT ) ) + ) + { + replaceControl( xControl, new FmXAutoControl ); + } + } + } + } + m_bAttachEvents = sal_True; + } + else + { + m_bDetachEvents = sal_False; + for (sal_Int32 i = nControls; i > 0;) + { + Reference< XControl > xControl = pControls[--i]; + if (xControl.is()) + { + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // does the model use a bound field ? + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + + // is it a autofield? + if ( xField.is() + && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField ) + && ::comphelper::getBOOL( xField->getPropertyValue(FM_PROP_AUTOINCREMENT ) ) + ) + { + ::rtl::OUString sServiceName; + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); + replaceControl( xControl, xNewControl ); + } + } + } + } + m_bDetachEvents = sal_True; + } +} + +//------------------------------------------------------------------------------ +IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + toggleAutoFields(m_bCurrentRecordNew); + return 1L; +} + +// XTextListener +//------------------------------------------------------------------------------ +void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException ) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + if (m_bFiltering) + { + Reference< XTextComponent > xText(e.Source,UNO_QUERY); + ::rtl::OUString aText = xText->getText(); + + if ( m_aFilterRows.empty() ) + appendEmptyDisjunctiveTerm(); + + // Suchen der aktuellen Row + if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) ) + { + OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" ); + return; + } + + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; + + // do we have a new filter + if (aText.getLength()) + rRow[xText] = aText; + else + { + // do we have the control in the row + FmFilterRow::iterator iter = rRow.find(xText); + // erase the entry out of the row + if (iter != rRow.end()) + rRow.erase(iter); + } + + // multiplex the event to our FilterControllerListeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin(); + aEvent.DisjunctiveTerm = getActiveTerm(); + aEvent.PredicateExpression = aText; + + aGuard.clear(); + // <-- SYNCHRONIZED + + // notify the changed filter expression + m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent ); + } + else + impl_onModify(); +} + +// XItemListener +//------------------------------------------------------------------------------ +void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + impl_onModify(); +} + +// XModificationBroadcaster +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aModifyListeners.addInterface( l ); +} + +//------------------------------------------------------------------------------ +void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aModifyListeners.removeInterface( l ); +} + +// XModificationListener +//------------------------------------------------------------------------------ +void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + try + { + if ( _rEvent.Source != m_xActiveControl ) + { // let this control grab the focus + // (this case may happen if somebody moves the scroll wheel of the mouse over a control + // which does not have the focus) + // 85511 - 29.05.2001 - frank.schoenheit@germany.sun.com + // + // also, it happens when an image control gets a new image by double-clicking it + // #i88458# / 2009-01-12 / frank.schoenheit@sun.com + Reference< XWindow > xControlWindow( _rEvent.Source, UNO_QUERY_THROW ); + xControlWindow->setFocus(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + impl_onModify(); +} + +//------------------------------------------------------------------------------ +void FormController::impl_checkDisposed_throw() const +{ + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) ); +} + +//------------------------------------------------------------------------------ +void FormController::impl_onModify() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_bModified ) + m_bModified = sal_True; + } + + EventObject aEvt(static_cast(this)); + m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt ); +} + +//------------------------------------------------------------------------------ +void FormController::impl_addFilterRow( const FmFilterRow& _row ) +{ + m_aFilterRows.push_back( _row ); + + if ( m_aFilterRows.size() == 1 ) + { // that's the first row ever + OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" ); + m_nCurrentFilterPosition = 0; + } +} + +//------------------------------------------------------------------------------ +void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) +{ + // SYNCHRONIZED --> + impl_addFilterRow( FmFilterRow() ); + + // notify the listeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1; + _rClearBeforeNotify.clear(); + // <-- SYNCHRONIZED + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent ); +} + +//------------------------------------------------------------------------------ +sal_Bool FormController::determineLockState() const +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + // a.) in filter mode we are always locked + // b.) if we have no valid model or our model (a result set) is not alive -> we're locked + // c.) if we are inserting everything is OK and we are not locked + // d.) if are not updatable or on invalid position + Reference< XResultSet > xResultSet(m_xModelAsIndex, UNO_QUERY); + if (m_bFiltering || !xResultSet.is() || !isRowSetAlive(xResultSet)) + return sal_True; + else + return (m_bCanInsert && m_bCurrentRecordNew) ? sal_False + : xResultSet->isBeforeFirst() || xResultSet->isAfterLast() || xResultSet->rowDeleted() || !m_bCanUpdate; +} + +// FocusListener +//------------------------------------------------------------------------------ +void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_pControlBorderManager->focusGained( e.Source ); + + Reference< XControl > xControl(e.Source, UNO_QUERY); + if (m_bDBConnection) + { + // do we need to keep the locking of the commit + // we hold the lock as long as the control differs from the current + // otherwhise we disabled the lock + m_bCommitLock = m_bCommitLock && (XControl*)xControl.get() != (XControl*)m_xCurrentControl.get(); + if (m_bCommitLock) + return; + + // when do we have to commit a value to form or a filter + // a.) if the current value is modified + // b.) there must be a current control + // c.) and it must be different from the new focus owning control or + // d.) the focus is moving around (so we have only one control) + + if ( ( m_bModified || m_bFiltering ) + && m_xCurrentControl.is() + && ( ( xControl.get() != m_xCurrentControl.get() ) + || ( ( e.FocusFlags & FocusChangeReason::AROUND ) + && ( m_bCycle || m_bFiltering ) + ) + ) + ) + { + // check the old control if the content is ok +#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL + Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY); + sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); + OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?"); + // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext + // gesetzt worden sein, was ich nicht verstehen wuerde ... +#endif + DBG_ASSERT(m_xCurrentControl.is(), "kein CurrentControl gesetzt"); + // zunaechst das Control fragen ob es das IFace unterstuetzt + Reference< XBoundComponent > xBound(m_xCurrentControl, UNO_QUERY); + if (!xBound.is() && m_xCurrentControl.is()) + xBound = Reference< XBoundComponent > (m_xCurrentControl->getModel(), UNO_QUERY); + + // lock if we lose the focus during commit + m_bCommitLock = sal_True; + + // Commit nicht erfolgreich, Focus zuruecksetzen + if (xBound.is() && !xBound->commit()) + { + // the commit failed and we don't commit again until the current control + // which couldn't be commit gains the focus again + Reference< XWindow > xWindow(m_xCurrentControl, UNO_QUERY); + if (xWindow.is()) + xWindow->setFocus(); + return; + } + else + { + m_bModified = sal_False; + m_bCommitLock = sal_False; + } + } + + if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is()) + { + SQLErrorEvent aErrorEvent; + OSL_ENSURE( m_xFormOperations.is(), "FormController::focusGained: hmm?" ); + // should have been created in setModel + try + { + if ( e.FocusFlags & FocusChangeReason::FORWARD ) + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) ) + m_xFormOperations->execute( FormFeature::MoveToNext ); + } + else // backward + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) ) + m_xFormOperations->execute( FormFeature::MoveToPrevious ); + } + } + catch ( const Exception& ) + { + // don't handle this any further. That's an ... admissible error. + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + // Immer noch ein und dasselbe Control + if ( ( m_xActiveControl == xControl ) + && ( xControl == m_xCurrentControl ) + ) + { + DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert"); + return; + } + + sal_Bool bActivated = !m_xActiveControl.is() && xControl.is(); + + m_xActiveControl = xControl; + + implSetCurrentControl( xControl ); + OSL_POSTCOND( m_xCurrentControl.is(), "implSetCurrentControl did nonsense!" ); + + if ( bActivated ) + { + // (asynchronously) call activation handlers + m_aActivationEvent.Call(); + + // call modify listeners + if ( m_bModified ) + m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) ); + } + + // invalidate all features which depend on the currently focused control + if ( m_bDBConnection && !m_bFiltering ) + implInvalidateCurrentControlDependentFeatures(); + + if ( !m_xCurrentControl.is() ) + return; + + // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich + Reference< XFormControllerContext > xContext( m_xContext ); + Reference< XControl > xCurrentControl( m_xCurrentControl ); + aGuard.clear(); + // <-- SYNCHRONIZED + + if ( xContext.is() ) + xContext->makeVisible( xCurrentControl ); +} + +//------------------------------------------------------------------------------ +IMPL_LINK( FormController, OnActivated, void*, /**/ ) +{ + EventObject aEvent; + aEvent.Source = *this; + m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvent ); + + return 0L; +} + +//------------------------------------------------------------------------------ +IMPL_LINK( FormController, OnDeactivated, void*, /**/ ) +{ + EventObject aEvent; + aEvent.Source = *this; + m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvent ); + + return 0L; +} + +//------------------------------------------------------------------------------ +void FormController::focusLost(const FocusEvent& e) throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + m_pControlBorderManager->focusLost( e.Source ); + + Reference< XControl > xControl(e.Source, UNO_QUERY); + Reference< XWindowPeer > xNext(e.NextFocus, UNO_QUERY); + Reference< XControl > xNextControl = isInList(xNext); + if (!xNextControl.is()) + { + m_xActiveControl = NULL; + m_aDeactivationEvent.Call(); + } +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +{ + // not interested in +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +{ + // not interested in +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +{ + m_pControlBorderManager->mouseEntered( _rEvent.Source ); +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +{ + m_pControlBorderManager->mouseExited( _rEvent.Source ); +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) +{ + Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) ); + Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY ); + + OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" ); + + if ( xControl.is() && xValidatable.is() ) + m_pControlBorderManager->validityChanged( xControl, xValidatable ); +} + +//-------------------------------------------------------------------- +void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !"); + + try + { + // disconnect from the old model + if (m_xModelAsIndex.is()) + { + if (m_bDBConnection) + { + // we are currently working on the model + EventObject aEvt(m_xModelAsIndex); + unloaded(aEvt); + } + + Reference< XLoadable > xForm(m_xModelAsIndex, UNO_QUERY); + if (xForm.is()) + xForm->removeLoadListener(this); + + Reference< XSQLErrorBroadcaster > xBroadcaster(m_xModelAsIndex, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeSQLErrorListener(this); + + Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY); + if (xParamBroadcaster.is()) + xParamBroadcaster->removeParameterListener(this); + + } + + disposeAllFeaturesAndDispatchers(); + + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + + // set the new model wait for the load event + if (m_xTabController.is()) + m_xTabController->setModel(Model); + m_xModelAsIndex = Reference< XIndexAccess > (Model, UNO_QUERY); + m_xModelAsManager = Reference< XEventAttacherManager > (Model, UNO_QUERY); + + // only if both ifaces exit, the controller will work successful + if (!m_xModelAsIndex.is() || !m_xModelAsManager.is()) + { + m_xModelAsManager = NULL; + m_xModelAsIndex = NULL; + } + + if (m_xModelAsIndex.is()) + { + // re-create m_xFormOperations + m_xFormOperations.set( FormOperations::createWithFormController( m_aContext.getUNOContext(), this ), UNO_SET_THROW ); + m_xFormOperations->setFeatureInvalidation( this ); + + // adding load and ui interaction listeners + Reference< XLoadable > xForm(Model, UNO_QUERY); + if (xForm.is()) + xForm->addLoadListener(this); + + Reference< XSQLErrorBroadcaster > xBroadcaster(Model, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addSQLErrorListener(this); + + Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(Model, UNO_QUERY); + if (xParamBroadcaster.is()) + xParamBroadcaster->addParameterListener(this); + + // well, is the database already loaded? + // then we have to simulate a load event + Reference< XLoadable > xCursor(m_xModelAsIndex, UNO_QUERY); + if (xCursor.is() && xCursor->isLoaded()) + { + EventObject aEvt(xCursor); + loaded(aEvt); + } + + Reference< XPropertySet > xModelProps( m_xModelAsIndex, UNO_QUERY ); + Reference< XPropertySetInfo > xPropInfo( xModelProps->getPropertySetInfo() ); + if ( xPropInfo.is() + && xPropInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) + && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) + && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) + && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) + ) + { + bool bEnableDynamicControlBorder = lcl_shouldUseDynamicControlBorder( + xModelProps.get(), xModelProps->getPropertyValue( FM_PROP_DYNAMIC_CONTROL_BORDER ) ); + if ( bEnableDynamicControlBorder ) + m_pControlBorderManager->enableDynamicBorderColor(); + else + m_pControlBorderManager->disableDynamicBorderColor(); + + sal_Int32 nColor = 0; + if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) >>= nColor ) + m_pControlBorderManager->setStatusColor( CONTROL_STATUS_FOCUSED, nColor ); + if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) >>= nColor ) + m_pControlBorderManager->setStatusColor( CONTROL_STATUS_MOUSE_HOVER, nColor ); + if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) >>= nColor ) + m_pControlBorderManager->setStatusColor( CONTROL_STATUS_INVALID, nColor ); + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !"); + if (!m_xTabController.is()) + return Reference< XTabControllerModel > (); + return m_xTabController->getModel(); +} + +//------------------------------------------------------------------------------ +void FormController::addToEventAttacher(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" ); + if ( !xControl.is() ) + return; /* throw IllegalArgumentException(); */ + + // anmelden beim Eventattacher + Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); + if (xComp.is() && m_xModelAsIndex.is()) + { + // Und die Position des ControlModel darin suchen + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) + { + Reference< XInterface > xIfc(xControl, UNO_QUERY); + m_xModelAsManager->attach( nPos, xIfc, makeAny(xControl) ); + break; + } + } + } +} + +//------------------------------------------------------------------------------ +void FormController::removeFromEventAttacher(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" ); + if ( !xControl.is() ) + return; /* throw IllegalArgumentException(); */ + + // abmelden beim Eventattacher + Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); + if ( xComp.is() && m_xModelAsIndex.is() ) + { + // Und die Position des ControlModel darin suchen + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get()) + { + Reference< XInterface > xIfc(xControl, UNO_QUERY); + m_xModelAsManager->detach( nPos, xIfc ); + break; + } + } + } +} + +//------------------------------------------------------------------------------ +void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + Reference< XTabControllerModel > xTabModel(getModel()); + DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined"); + // if we have a new container we need a model + DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !"); + + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XContainer > xCurrentContainer; + if (m_xTabController.is()) + xCurrentContainer = Reference< XContainer > (m_xTabController->getContainer(), UNO_QUERY); + if (xCurrentContainer.is()) + { + xCurrentContainer->removeContainerListener(this); + + if ( m_aTabActivationTimer.IsActive() ) + m_aTabActivationTimer.Stop(); + + // clear the filter map + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); + + // einsammeln der Controls + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + implControlRemoved( *pControls++, true ); + + // Datenbank spezifische Dinge vornehmen + if (m_bDBConnection && isListeningForChanges()) + stopListening(); + + m_aControls.realloc( 0 ); + } + + if (m_xTabController.is()) + m_xTabController->setContainer(xContainer); + + // Welche Controls gehoeren zum Container ? + if (xContainer.is() && xTabModel.is()) + { + Sequence< Reference< XControlModel > > aModels = xTabModel->getControlModels(); + const Reference< XControlModel > * pModels = aModels.getConstArray(); + Sequence< Reference< XControl > > aAllControls = xContainer->getControls(); + + sal_Int32 nCount = aModels.getLength(); + m_aControls = Sequence< Reference< XControl > >( nCount ); + Reference< XControl > * pControls = m_aControls.getArray(); + + // einsammeln der Controls + sal_Int32 i, j; + for (i = 0, j = 0; i < nCount; ++i, ++pModels ) + { + Reference< XControl > xControl = findControl( aAllControls, *pModels, sal_False, sal_True ); + if ( xControl.is() ) + { + pControls[j++] = xControl; + implControlInserted( xControl, true ); + } + } + + // not every model had an associated control + if (j != i) + m_aControls.realloc(j); + + // am Container horchen + Reference< XContainer > xNewContainer(xContainer, UNO_QUERY); + if (xNewContainer.is()) + xNewContainer->addContainerListener(this); + + // Datenbank spezifische Dinge vornehmen + if (m_bDBConnection) + { + m_bLocked = determineLockState(); + setLocks(); + if (!isLocked()) + startListening(); + } + } + // befinden sich die Controls in der richtigen Reihenfolge + m_bControlsSorted = sal_True; +} + +//------------------------------------------------------------------------------ +Reference< XControlContainer > FormController::getContainer() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !"); + if (!m_xTabController.is()) + return Reference< XControlContainer > (); + return m_xTabController->getContainer(); +} + +//------------------------------------------------------------------------------ +Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if (!m_bControlsSorted) + { + Reference< XTabControllerModel > xModel = getModel(); + if (!xModel.is()) + return m_aControls; + + Sequence< Reference< XControlModel > > aControlModels = xModel->getControlModels(); + const Reference< XControlModel > * pModels = aControlModels.getConstArray(); + sal_Int32 nModels = aControlModels.getLength(); + + Sequence< Reference< XControl > > aNewControls(nModels); + + Reference< XControl > * pControls = aNewControls.getArray(); + Reference< XControl > xControl; + + // Umsortieren der Controls entsprechend der TabReihenfolge + sal_Int32 j = 0; + for (sal_Int32 i = 0; i < nModels; ++i, ++pModels ) + { + xControl = findControl( m_aControls, *pModels, sal_True, sal_True ); + if ( xControl.is() ) + pControls[j++] = xControl; + } + + // not every model had an associated control + if ( j != nModels ) + aNewControls.realloc( j ); + + m_aControls = aNewControls; + m_bControlsSorted = sal_True; + } + return m_aControls; +} + +//------------------------------------------------------------------------------ +void FormController::autoTabOrder() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !"); + if (m_xTabController.is()) + m_xTabController->autoTabOrder(); +} + +//------------------------------------------------------------------------------ +void FormController::activateTabOrder() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !"); + if (m_xTabController.is()) + m_xTabController->activateTabOrder(); +} + +//------------------------------------------------------------------------------ +void FormController::setControlLock(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + sal_Bool bLocked = isLocked(); + + // es wird gelockt + // a.) wenn der ganze Datensatz gesperrt ist + // b.) wenn das zugehoerige Feld gespeert ist + Reference< XBoundControl > xBound(xControl, UNO_QUERY); + if (xBound.is() && (( (bLocked && bLocked != xBound->getLock()) || + !bLocked))) // beim entlocken immer einzelne Felder ueberprüfen + { + // gibt es eine Datenquelle + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // wie sieht mit den Properties ReadOnly und Enable aus + sal_Bool bTouch = sal_True; + if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet)) + bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED)); + if (::comphelper::hasProperty(FM_PROP_READONLY, xSet)) + bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY)); + + if (bTouch) + { + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + if (xField.is()) + { + if (bLocked) + xBound->setLock(bLocked); + else + { + try + { + Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY); + if (aVal.hasValue() && ::comphelper::getBOOL(aVal)) + xBound->setLock(sal_True); + else + xBound->setLock(bLocked); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + } + } + } + } + } +} + +//------------------------------------------------------------------------------ +void FormController::setLocks() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + setControlLock( *pControls++ ); +} + +//------------------------------------------------------------------------------ +namespace +{ + bool lcl_shouldListenForModifications( const Reference< XControl >& _rxControl, const Reference< XPropertyChangeListener >& _rxBoundFieldListener ) + { + bool bShould = false; + + Reference< XBoundComponent > xBound( _rxControl, UNO_QUERY ); + if ( xBound.is() ) + { + bShould = true; + } + else if ( _rxControl.is() ) + { + Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY ); + if ( xModelProps.is() && ::comphelper::hasProperty( FM_PROP_BOUNDFIELD, xModelProps ) ) + { + Reference< XPropertySet > xField; + xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField; + bShould = xField.is(); + + if ( !bShould && _rxBoundFieldListener.is() ) + xModelProps->addPropertyChangeListener( FM_PROP_BOUNDFIELD, _rxBoundFieldListener ); + } + } + + return bShould; + } +} + +//------------------------------------------------------------------------------ +void FormController::startControlModifyListening(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + bool bModifyListening = lcl_shouldListenForModifications( xControl, this ); + + // artificial while + while ( bModifyListening ) + { + Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY); + if (xMod.is()) + { + xMod->addModifyListener(this); + break; + } + + // alle die Text um vorzeitig ein modified zu erkennen + Reference< XTextComponent > xText(xControl, UNO_QUERY); + if (xText.is()) + { + xText->addTextListener(this); + break; + } + + Reference< XCheckBox > xBox(xControl, UNO_QUERY); + if (xBox.is()) + { + xBox->addItemListener(this); + break; + } + + Reference< XComboBox > xCbBox(xControl, UNO_QUERY); + if (xCbBox.is()) + { + xCbBox->addItemListener(this); + break; + } + + Reference< XListBox > xListBox(xControl, UNO_QUERY); + if (xListBox.is()) + { + xListBox->addItemListener(this); + break; + } + break; + } +} + +//------------------------------------------------------------------------------ +void FormController::stopControlModifyListening(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL ); + + // kuenstliches while + while (bModifyListening) + { + Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY); + if (xMod.is()) + { + xMod->removeModifyListener(this); + break; + } + // alle die Text um vorzeitig ein modified zu erkennen + Reference< XTextComponent > xText(xControl, UNO_QUERY); + if (xText.is()) + { + xText->removeTextListener(this); + break; + } + + Reference< XCheckBox > xBox(xControl, UNO_QUERY); + if (xBox.is()) + { + xBox->removeItemListener(this); + break; + } + + Reference< XComboBox > xCbBox(xControl, UNO_QUERY); + if (xCbBox.is()) + { + xCbBox->removeItemListener(this); + break; + } + + Reference< XListBox > xListBox(xControl, UNO_QUERY); + if (xListBox.is()) + { + xListBox->removeItemListener(this); + break; + } + break; + } +} + +//------------------------------------------------------------------------------ +void FormController::startListening() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + m_bModified = sal_False; + + // jetzt anmelden bei gebundenen feldern + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + startControlModifyListening( *pControls++ ); +} + +//------------------------------------------------------------------------------ +void FormController::stopListening() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + m_bModified = sal_False; + + // jetzt anmelden bei gebundenen feldern + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + stopControlModifyListening( *pControls++ ); +} + + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" ); + + Reference< XControl >* pControls = _rControls.getArray(); + Reference< XControlModel > xModel; + for ( sal_Int32 i = 0, nCount = _rControls.getLength(); i < nCount; ++i, ++pControls ) + { + if ( pControls->is() ) + { + xModel = (*pControls)->getModel(); + if ( xModel.get() == xCtrlModel.get() ) + { + Reference< XControl > xControl( *pControls ); + if ( _bRemove ) + ::comphelper::removeElementAt( _rControls, i ); + else if ( _bOverWrite ) + *pControls = Reference< XControl >(); + return xControl; + } + } + } + return Reference< XControl > (); +} + +//------------------------------------------------------------------------------ +void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) +{ + Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); + if ( xWindow.is() ) + { + xWindow->addFocusListener( this ); + xWindow->addMouseListener( this ); + + if ( _bAddToEventAttacher ) + addToEventAttacher( _rxControl ); + } + + // add a dispatch interceptor to the control (if supported) + Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY ); + if ( xInterception.is() ) + createInterceptor( xInterception ); + + if ( _rxControl.is() ) + { + Reference< XControlModel > xModel( _rxControl->getModel() ); + + // we want to know about the reset of the the model of our controls + // (for correctly resetting m_bModified) + Reference< XReset > xReset( xModel, UNO_QUERY ); + if ( xReset.is() ) + xReset->addResetListener( this ); + + // and we want to know about the validity, to visually indicate it + Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); + if ( xValidatable.is() ) + { + xValidatable->addFormComponentValidityListener( this ); + m_pControlBorderManager->validityChanged( _rxControl, xValidatable ); + } + } + +} + +//------------------------------------------------------------------------------ +void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) +{ + Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); + if ( xWindow.is() ) + { + xWindow->removeFocusListener( this ); + xWindow->removeMouseListener( this ); + + if ( _bRemoveFromEventAttacher ) + removeFromEventAttacher( _rxControl ); + } + + Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY); + if ( xInterception.is() ) + deleteInterceptor( xInterception ); + + if ( _rxControl.is() ) + { + Reference< XControlModel > xModel( _rxControl->getModel() ); + + Reference< XReset > xReset( xModel, UNO_QUERY ); + if ( xReset.is() ) + xReset->removeResetListener( this ); + + Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); + if ( xValidatable.is() ) + xValidatable->removeFormComponentValidityListener( this ); + } +} + +//------------------------------------------------------------------------------ +void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) +{ + if ( m_xCurrentControl.get() == _rxControl.get() ) + return; + + Reference< XGridControl > xGridControl( m_xCurrentControl, UNO_QUERY ); + if ( xGridControl.is() ) + xGridControl->removeGridControlListener( this ); + + m_xCurrentControl = _rxControl; + + xGridControl.set( m_xCurrentControl, UNO_QUERY ); + if ( xGridControl.is() ) + xGridControl->addGridControlListener( this ); +} + +//------------------------------------------------------------------------------ +void FormController::insertControl(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + m_bControlsSorted = sal_False; + m_aControls.realloc(m_aControls.getLength() + 1); + m_aControls.getArray()[m_aControls.getLength() - 1] = xControl; + + if ( m_pColumnInfoCache.get() ) + m_pColumnInfoCache->deinitializeControls(); + + implControlInserted( xControl, m_bAttachEvents ); + + if (m_bDBConnection && !m_bFiltering) + setControlLock(xControl); + + if (isListeningForChanges() && m_bAttachEvents) + startControlModifyListening( xControl ); +} + +//------------------------------------------------------------------------------ +void FormController::removeControl(const Reference< XControl > & xControl) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + { + if ( xControl.get() == (*pControls++).get() ) + { + ::comphelper::removeElementAt( m_aControls, pControls - m_aControls.getConstArray() - 1 ); + break; + } + } + + FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); + + implControlRemoved( xControl, m_bDetachEvents ); + + if ( isListeningForChanges() && m_bDetachEvents ) + stopControlModifyListening( xControl ); +} + +// XLoadListener +//------------------------------------------------------------------------------ +void FormController::loaded(const EventObject& rEvent) throw( RuntimeException ) +{ + OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" ); + + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY); + // do we have a connected data source + OStaticDataAccessTools aStaticTools; + if (xForm.is() && aStaticTools.getRowSetConnection(xForm).is()) + { + Reference< XPropertySet > xSet(xForm, UNO_QUERY); + if (xSet.is()) + { + Any aVal = xSet->getPropertyValue(FM_PROP_CYCLE); + sal_Int32 aVal2 = 0; + ::cppu::enum2int(aVal2,aVal); + m_bCycle = !aVal.hasValue() || aVal2 == TabulatorCycle_RECORDS; + m_bCanUpdate = aStaticTools.canUpdate(xSet); + m_bCanInsert = aStaticTools.canInsert(xSet); + m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED)); + m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW)); + + startFormListening( xSet, sal_False ); + + // set the locks for the current controls + if (getContainer().is()) + { + m_aLoadEvent.Call(); + } + } + else + { + m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; + m_bCurrentRecordModified = sal_False; + m_bCurrentRecordNew = sal_False; + m_bLocked = sal_False; + } + m_bDBConnection = sal_True; + } + else + { + m_bDBConnection = sal_False; + m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; + m_bCurrentRecordModified = sal_False; + m_bCurrentRecordNew = sal_False; + m_bLocked = sal_False; + } + + Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY ); + m_pColumnInfoCache.reset( xFormColumns.is() ? new ColumnInfoCache( xFormColumns ) : NULL ); + + updateAllDispatchers(); +} + +//------------------------------------------------------------------------------ +void FormController::updateAllDispatchers() const +{ + ::std::for_each( + m_aFeatureDispatchers.begin(), + m_aFeatureDispatchers.end(), + ::std::compose1( + UpdateAllListeners(), + ::std::select2nd< DispatcherContainer::value_type >() + ) + ); +} + +//------------------------------------------------------------------------------ +IMPL_LINK(FormController, OnLoad, void*, EMPTYARG) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + m_bLocked = determineLockState(); + + setLocks(); + + if (!m_bLocked) + startListening(); + + // just one exception toggle the auto values + if (m_bCurrentRecordNew) + toggleAutoFields(sal_True); + + return 1L; +} + +//------------------------------------------------------------------------------ +void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + updateAllDispatchers(); +} + +//------------------------------------------------------------------------------ +void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + // do the same like in unloading + // just one exception toggle the auto values + m_aToggleEvent.CancelPendingCall(); + unload(); +} + +//------------------------------------------------------------------------------ +void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + loaded(aEvent); +} + +//------------------------------------------------------------------------------ +void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + unload(); +} + +//------------------------------------------------------------------------------ +void FormController::unload() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aLoadEvent.CancelPendingCall(); + + // be sure not to have autofields + if (m_bCurrentRecordNew) + toggleAutoFields(sal_False); + + // remove bound field listing again + removeBoundFieldListener(); + + if (m_bDBConnection && isListeningForChanges()) + stopListening(); + + Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); + if ( m_bDBConnection && xSet.is() ) + stopFormListening( xSet, sal_False ); + + m_bDBConnection = sal_False; + m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False; + m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked = sal_False; + + m_pColumnInfoCache.reset( NULL ); +} + +// ----------------------------------------------------------------------------- +void FormController::removeBoundFieldListener() +{ + const Reference< XControl >* pControls = m_aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); + while ( pControls != pControlsEnd ) + { + Reference< XPropertySet > xProp( *pControls++, UNO_QUERY ); + if ( xProp.is() ) + xProp->removePropertyChangeListener( FM_PROP_BOUNDFIELD, this ); + } +} + +//------------------------------------------------------------------------------ +void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +{ + try + { + if ( m_bCanInsert || m_bCanUpdate ) // form can be modified + { + _rxForm->addPropertyChangeListener( FM_PROP_ISNEW, this ); + _rxForm->addPropertyChangeListener( FM_PROP_ISMODIFIED, this ); + + if ( !_bPropertiesOnly ) + { + // set the Listener for UI interaction + Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY ); + if ( xApprove.is() ) + xApprove->addRowSetApproveListener( this ); + + // listener for row set changes + Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY ); + if ( xRowSet.is() ) + xRowSet->addRowSetListener( this ); + } + } + + Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo(); + if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) ) + _rxForm->addPropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +{ + try + { + if ( m_bCanInsert || m_bCanUpdate ) + { + _rxForm->removePropertyChangeListener( FM_PROP_ISNEW, this ); + _rxForm->removePropertyChangeListener( FM_PROP_ISMODIFIED, this ); + + if ( !_bPropertiesOnly ) + { + Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY ); + if (xApprove.is()) + xApprove->removeRowSetApproveListener(this); + + Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY ); + if ( xRowSet.is() ) + xRowSet->removeRowSetListener( this ); + } + } + + Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo(); + if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) ) + _rxForm->removePropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// com::sun::star::sdbc::XRowSetListener +//------------------------------------------------------------------------------ +void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + // toggle the locking ? + if (m_bLocked != determineLockState()) + { + m_bLocked = !m_bLocked; + setLocks(); + if (isListeningForChanges()) + startListening(); + else + stopListening(); + } + + // neither the current control nor the current record are modified anymore + m_bCurrentRecordModified = m_bModified = sal_False; +} + +//------------------------------------------------------------------------------ +void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) +{ + // not interested in ... +} +//------------------------------------------------------------------------------ +void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) +{ + // not interested in ... +} + + +// XContainerListener +//------------------------------------------------------------------------------ +void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Reference< XControl > xControl( evt.Element, UNO_QUERY ); + if ( !xControl.is() ) + return; + + Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); + if (xModel.is() && m_xModelAsIndex == xModel->getParent()) + { + insertControl(xControl); + + if ( m_aTabActivationTimer.IsActive() ) + m_aTabActivationTimer.Stop(); + + m_aTabActivationTimer.Start(); + } + // are we in filtermode and a XModeSelector has inserted an element + else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) + { + xModel = Reference< XFormComponent > (evt.Source, UNO_QUERY); + if (xModel.is() && m_xModelAsIndex == xModel->getParent()) + { + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // does the model use a bound field ? + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + + Reference< XTextComponent > xText(xControl, UNO_QUERY); + // may we filter the field? + if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && + ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) + { + m_aFilterComponents.push_back( xText ); + xText->addTextListener( this ); + } + } + } + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) +{ + // simulate an elementRemoved + ContainerEvent aRemoveEvent( evt ); + aRemoveEvent.Element = evt.ReplacedElement; + aRemoveEvent.ReplacedElement = Any(); + elementRemoved( aRemoveEvent ); + + // simulate an elementInserted + ContainerEvent aInsertEvent( evt ); + aInsertEvent.ReplacedElement = Any(); + elementInserted( aInsertEvent ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Reference< XControl > xControl; + evt.Element >>= xControl; + if (!xControl.is()) + return; + + Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); + if (xModel.is() && m_xModelAsIndex == xModel->getParent()) + { + removeControl(xControl); + // TabOrder nicht neu berechnen, da das intern schon funktionieren muß! + } + // are we in filtermode and a XModeSelector has inserted an element + else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) + { + FilterComponents::iterator componentPos = ::std::find( + m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); + } +} + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + const Reference< XControl >* pControls = m_aControls.getConstArray(); + + sal_uInt32 nCtrls = m_aControls.getLength(); + for ( sal_uInt32 n = 0; n < nCtrls && xPeer.is(); ++n, ++pControls ) + { + if ( pControls->is() ) + { + Reference< XVclWindowPeer > xCtrlPeer( (*pControls)->getPeer(), UNO_QUERY); + if ( ( xCtrlPeer.get() == xPeer.get() ) || xCtrlPeer->isChild( xPeer ) ) + return *pControls; + } + } + return Reference< XControl > (); +} + +//------------------------------------------------------------------------------ +void FormController::activateFirst() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !"); + if (m_xTabController.is()) + m_xTabController->activateFirst(); +} + +//------------------------------------------------------------------------------ +void FormController::activateLast() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !"); + if (m_xTabController.is()) + m_xTabController->activateLast(); +} + +// XFormController +//------------------------------------------------------------------------------ +Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_xFormOperations; +} + +//------------------------------------------------------------------------------ +Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_xCurrentControl; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aActivateListeners.addInterface(l); +} +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aActivateListeners.removeInterface(l); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( !_ChildController.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + // the parent of our (to-be-)child must be our own model + Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY ); + if ( !xFormOfChild.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + if ( xFormOfChild->getParent() != m_xModelAsIndex ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + m_aChilds.push_back( _ChildController ); + _ChildController->setParent( *this ); + + // search the position of the model within the form + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if ( xFormOfChild == xTemp ) + { + Reference< XInterface > xIfc( _ChildController, UNO_QUERY ); + m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) ); + break; + } + } +} + +//------------------------------------------------------------------------------ +Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_xContext; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_xContext = _context; +} + +//------------------------------------------------------------------------------ +Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_xInteractionHandler; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_xInteractionHandler = _interactionHandler; +} + +//------------------------------------------------------------------------------ +void FormController::setFilter(::std::vector& rFieldInfos) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + // create the composer + Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY); + Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm)); + if (xForm.is()) + { + try + { + Reference< XMultiServiceFactory > xFactory( xConnection, UNO_QUERY_THROW ); + m_xComposer.set( + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), + UNO_QUERY_THROW ); + + Reference< XPropertySet > xSet( xForm, UNO_QUERY ); + ::rtl::OUString sStatement = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_ACTIVECOMMAND ) ); + ::rtl::OUString sFilter = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_FILTER ) ); + m_xComposer->setElementaryQuery( sStatement ); + m_xComposer->setFilter( sFilter ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + if (m_xComposer.is()) + { + Sequence < PropertyValue> aLevel; + Sequence< Sequence < PropertyValue > > aFilterRows = m_xComposer->getStructuredFilter(); + + // ok, we recieve the list of filters as sequence of fieldnames, value + // now we have to transform the fieldname into UI names, that could be a label of the field or + // a aliasname or the fieldname itself + + // first adjust the field names if necessary + Reference< XNameAccess > xQueryColumns = + Reference< XColumnsSupplier >( m_xComposer, UNO_QUERY_THROW )->getColumns(); + + for (::std::vector::iterator iter = rFieldInfos.begin(); + iter != rFieldInfos.end(); iter++) + { + if ( xQueryColumns->hasByName((*iter).aFieldName) ) + { + if ( (xQueryColumns->getByName((*iter).aFieldName) >>= (*iter).xField) && (*iter).xField.is() ) + (*iter).xField->getPropertyValue(FM_PROP_REALNAME) >>= (*iter).aFieldName; + } + } + + Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); + // now transfer the filters into Value/TextComponent pairs + ::comphelper::UStringMixEqual aCompare(xMetaData->storesMixedCaseQuotedIdentifiers()); + + // need to parse criteria localized + OStaticDataAccessTools aStaticTools; + Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); + xFormatter->attachNumberFormatsSupplier(xFormatSupplier); + Locale aAppLocale = Application::GetSettings().GetUILocale(); + LocaleDataWrapper aLocaleWrapper( m_aContext.getLegacyServiceFactory(), aAppLocale ); + + // retrieving the filter + const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray(); + for (sal_Int32 i = 0, nLen = aFilterRows.getLength(); i < nLen; ++i) + { + FmFilterRow aRow; + + // search a field for the given name + const PropertyValue* pRefValues = pRow[i].getConstArray(); + for (sal_Int32 j = 0, nLen1 = pRow[i].getLength(); j < nLen1; j++) + { + // look for the text component + Reference< XPropertySet > xField; + try + { + Reference< XPropertySet > xSet; + ::rtl::OUString aRealName; + + // first look with the given name + if (xQueryColumns->hasByName(pRefValues[j].Name)) + { + xQueryColumns->getByName(pRefValues[j].Name) >>= xSet; + + // get the RealName + xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName; + + // compare the condition field name and the RealName + if (aCompare(aRealName, pRefValues[j].Name)) + xField = xSet; + } + if (!xField.is()) + { + // no we have to check every column to find the realname + Reference< XIndexAccess > xColumnsByIndex(xQueryColumns, UNO_QUERY); + for (sal_Int32 n = 0, nCount = xColumnsByIndex->getCount(); n < nCount; n++) + { + xColumnsByIndex->getByIndex(n) >>= xSet; + xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName; + if (aCompare(aRealName, pRefValues[j].Name)) + { + // get the column by its alias + xField = xSet; + break; + } + } + } + if (!xField.is()) + continue; + } + catch (const Exception&) + { + continue; + } + + // find the text component + for (::std::vector::iterator iter = rFieldInfos.begin(); + iter != rFieldInfos.end(); iter++) + { + // we found the field so insert a new entry to the filter row + if ((*iter).xField == xField) + { + // do we already have the control ? + if (aRow.find((*iter).xText) != aRow.end()) + { + ::rtl::OUString aCompText = aRow[(*iter).xText]; + aCompText += ::rtl::OUString::createFromAscii(" "); + ::rtl::OString aVal = m_xParser->getContext().getIntlKeywordAscii(OParseContext::KEY_AND); + aCompText += ::rtl::OUString(aVal.getStr(),aVal.getLength(),RTL_TEXTENCODING_ASCII_US); + aCompText += ::rtl::OUString::createFromAscii(" "); + aCompText += ::comphelper::getString(pRefValues[j].Value); + aRow[(*iter).xText] = aCompText; + } + else + { + ::rtl::OUString sPredicate,sErrorMsg; + pRefValues[j].Value >>= sPredicate; + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(sErrorMsg, sPredicate, xFormatter, xField); + if ( xParseNode.is() ) + { + ::rtl::OUString sCriteria; + xParseNode->parseNodeToPredicateStr( sCriteria + ,xConnection + ,xFormatter + ,xField + ,aAppLocale + ,(sal_Char)aLocaleWrapper.getNumDecimalSep().GetChar(0) + ,getParseContext()); + aRow[(*iter).xText] = sCriteria; + } + } + } + } + } + + if (aRow.empty()) + continue; + + impl_addFilterRow( aRow ); + } + } + + // now set the filter controls + for ( ::std::vector::iterator field = rFieldInfos.begin(); + field != rFieldInfos.end(); + ++field + ) + { + m_aFilterComponents.push_back( field->xText ); + } +} + +//------------------------------------------------------------------------------ +void FormController::startFiltering() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + + OStaticDataAccessTools aStaticTools; + Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) ); + if ( !xConnection.is() ) + // nothing to do - can't filter a form which is not connected + // 98023 - 19.03.2002 - fs@openoffice.org + return; + + // stop listening for controls + if (isListeningForChanges()) + stopListening(); + + m_bFiltering = sal_True; + + // as we don't want new controls to be attached to the scripting environment + // we change attach flags + m_bAttachEvents = sal_False; + + // Austauschen der Kontrols fuer das aktuelle Formular + Sequence< Reference< XControl > > aControlsCopy( m_aControls ); + const Reference< XControl >* pControls = aControlsCopy.getConstArray(); + sal_Int32 nControlCount = aControlsCopy.getLength(); + + // the control we have to activate after replacement + Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData()); + Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); + Reference< XNumberFormatter > xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); + xFormatter->attachNumberFormatsSupplier(xFormatSupplier); + + // structure for storing the field info + ::std::vector aFieldInfos; + + for (sal_Int32 i = nControlCount; i > 0;) + { + Reference< XControl > xControl = pControls[--i]; + if (xControl.is()) + { + // no events for the control anymore + removeFromEventAttacher(xControl); + + // do we have a mode selector + Reference< XModeSelector > xSelector(xControl, UNO_QUERY); + if (xSelector.is()) + { + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); + + // listening for new controls of the selector + Reference< XContainer > xContainer(xSelector, UNO_QUERY); + if (xContainer.is()) + xContainer->addContainerListener(this); + + Reference< XEnumerationAccess > xElementAccess(xSelector, UNO_QUERY); + if (xElementAccess.is()) + { + Reference< XEnumeration > xEnumeration(xElementAccess->createEnumeration()); + Reference< XControl > xSubControl; + while (xEnumeration->hasMoreElements()) + { + xEnumeration->nextElement() >>= xSubControl; + if (xSubControl.is()) + { + Reference< XPropertySet > xSet(xSubControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // does the model use a bound field ? + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + + Reference< XTextComponent > xText(xSubControl, UNO_QUERY); + // may we filter the field? + if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && + ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) + { + aFieldInfos.push_back(FmFieldInfo(xField, xText)); + xText->addTextListener(this); + } + } + } + } + } + continue; + } + + Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY ); + if (xModel.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xModel)) + { + // does the model use a bound field ? + Any aVal = xModel->getPropertyValue(FM_PROP_BOUNDFIELD); + Reference< XPropertySet > xField; + aVal >>= xField; + + // may we filter the field? + + if ( xField.is() + && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField ) + && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) ) + ) + { + // create a filter control + Sequence< Any > aCreationArgs( 3 ); + aCreationArgs[ 0 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "MessageParent" ), makeAny( VCLUnoHelper::GetInterface( getDialogParentWindow() ) ) ); + aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "NumberFormatter" ), makeAny( xFormatter ) ); + aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "ControlModel" ), makeAny( xModel ) ); + Reference< XControl > xFilterControl( + m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ), + UNO_QUERY + ); + DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" ); + + if ( replaceControl( xControl, xFilterControl ) ) + { + Reference< XTextComponent > xFilterText( xFilterControl, UNO_QUERY ); + aFieldInfos.push_back( FmFieldInfo( xField, xFilterText ) ); + xFilterText->addTextListener(this); + } + } + } + else + { + // abmelden vom EventManager + } + } + } + + // we have all filter controls now, so the next step is to read the filters from the form + // resolve all aliases and set the current filter to the according structure + setFilter(aFieldInfos); + + Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); + if ( xSet.is() ) + stopFormListening( xSet, sal_True ); + + impl_setTextOnAllFilter_throw(); + + // lock all controls which are not used for filtering + m_bLocked = determineLockState(); + setLocks(); + m_bAttachEvents = sal_True; +} + +//------------------------------------------------------------------------------ +void FormController::stopFiltering() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + if ( !m_bFiltering ) // #104693# OJ + { // nothing to do + return; + } + + m_bFiltering = sal_False; + m_bDetachEvents = sal_False; + + ::comphelper::disposeComponent(m_xComposer); + + // Austauschen der Kontrols fuer das aktuelle Formular + Sequence< Reference< XControl > > aControlsCopy( m_aControls ); + const Reference< XControl > * pControls = aControlsCopy.getConstArray(); + sal_Int32 nControlCount = aControlsCopy.getLength(); + + // clear the filter control map + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); + + for ( sal_Int32 i = nControlCount; i > 0; ) + { + Reference< XControl > xControl = pControls[--i]; + if (xControl.is()) + { + // now enable eventhandling again + addToEventAttacher(xControl); + + Reference< XModeSelector > xSelector(xControl, UNO_QUERY); + if (xSelector.is()) + { + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); + + // listening for new controls of the selector + Reference< XContainer > xContainer(xSelector, UNO_QUERY); + if (xContainer.is()) + xContainer->removeContainerListener(this); + continue; + } + + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + { + // does the model use a bound field ? + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + + // may we filter the field? + if ( xField.is() + && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField ) + && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) ) + ) + { + ::rtl::OUString sServiceName; + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); + replaceControl( xControl, xNewControl ); + } + } + } + } + + Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY ); + if ( xSet.is() ) + startFormListening( xSet, sal_True ); + + m_bDetachEvents = sal_True; + + m_aFilterRows.clear(); + m_nCurrentFilterPosition = -1; + + // release the locks if possible + // lock all controls which are not used for filtering + m_bLocked = determineLockState(); + setLocks(); + + // restart listening for control modifications + if (isListeningForChanges()) + startListening(); +} + +// XModeSelector +//------------------------------------------------------------------------------ +void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if (!supportsMode(Mode)) + throw NoSupportException(); + + if (Mode == m_aMode) + return; + + m_aMode = Mode; + + if ( Mode.equalsAscii( "FilterMode" ) ) + startFiltering(); + else + stopFiltering(); + + for (FmFormControllers::const_iterator i = m_aChilds.begin(); + i != m_aChilds.end(); ++i) + { + Reference< XModeSelector > xMode(*i, UNO_QUERY); + if ( xMode.is() ) + xMode->setMode(Mode); + } +} + +//------------------------------------------------------------------------------ +::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aMode; +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + static Sequence< ::rtl::OUString > aModes; + if (!aModes.getLength()) + { + aModes.realloc(2); + ::rtl::OUString* pModes = aModes.getArray(); + pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ); + } + return aModes; +} + +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Sequence< ::rtl::OUString > aModes(getSupportedModes()); + const ::rtl::OUString* pModes = aModes.getConstArray(); + for (sal_Int32 i = aModes.getLength(); i > 0; ) + { + if (pModes[--i] == Mode) + return sal_True; + } + return sal_False; +} + +//------------------------------------------------------------------------------ +Window* FormController::getDialogParentWindow() +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + Window* pParentWindow = NULL; + try + { + Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); + Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); + pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return pParentWindow; +} +//------------------------------------------------------------------------------ +bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) +{ + try + { + Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY ); + Reference< XEnumeration > xControlEnumeration; + if ( xControlEnumAcc.is() ) + xControlEnumeration = xControlEnumAcc->createEnumeration(); + OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" ); + if ( !xControlEnumeration.is() ) + // assume all valid + return true; + + Reference< XValidatableFormComponent > xValidatable; + while ( xControlEnumeration->hasMoreElements() ) + { + if ( !( xControlEnumeration->nextElement() >>= xValidatable ) ) + // control does not support validation + continue; + + if ( xValidatable->isValid() ) + continue; + + Reference< XValidator > xValidator( xValidatable->getValidator() ); + OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" ); + if ( !xValidator.is() ) + // this violates the interface definition of css.form.validation.XValidatableFormComponent ... + continue; + + _rFirstInvalidityExplanation = xValidator->explainInvalid( xValidatable->getCurrentValue() ); + _rxFirstInvalidModel = _rxFirstInvalidModel.query( xValidatable ); + return false; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return true; +} + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) +{ + try + { + Sequence< Reference< XControl > > aControls( getControls() ); + const Reference< XControl >* pControls = aControls.getConstArray(); + const Reference< XControl >* pControlsEnd = aControls.getConstArray() + aControls.getLength(); + + for ( ; pControls != pControlsEnd; ++pControls ) + { + OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" ); + if ( pControls->is() ) + { + if ( ( *pControls)->getModel() == _rxModel ) + return *pControls; + } + } + OSL_ENSURE( sal_False, "FormController::locateControl: did not find a control for this model!" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return NULL; +} + +//------------------------------------------------------------------------------ +namespace +{ + void displayErrorSetFocus( const String& _rMessage, const Reference< XControl >& _rxFocusControl, Window* _pDialogParent ) + { + SQLContext aError; + aError.Message = String( SVX_RES( RID_STR_WRITEERROR ) ); + aError.Details = _rMessage; + displayException( aError, _pDialogParent ); + + if ( _rxFocusControl.is() ) + { + Reference< XWindow > xControlWindow( _rxFocusControl, UNO_QUERY ); + OSL_ENSURE( xControlWindow.is(), "displayErrorSetFocus: invalid control!" ); + if ( xControlWindow.is() ) + xControlWindow->setFocus(); + } + } + + sal_Bool lcl_shouldValidateRequiredFields_nothrow( const Reference< XInterface >& _rxForm ) + { + try + { + static ::rtl::OUString s_sFormsCheckRequiredFields( RTL_CONSTASCII_USTRINGPARAM( "FormsCheckRequiredFields" ) ); + + // first, check whether the form has a property telling us the answer + // this allows people to use the XPropertyContainer interface of a form to control + // the behaviour on a per-form basis. + Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xPSI( xFormProps->getPropertySetInfo() ); + if ( xPSI->hasPropertyByName( s_sFormsCheckRequiredFields ) ) + { + sal_Bool bShouldValidate = true; + OSL_VERIFY( xFormProps->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate ); + return bShouldValidate; + } + + // next, check the data source which created the connection + Reference< XChild > xConnectionAsChild( xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ), UNO_QUERY_THROW ); + Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY ); + if ( !xDataSource.is() ) + // seldom (but possible): this is not a connection created by a data source + return sal_True; + + Reference< XPropertySet > xDataSourceSettings( + xDataSource->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ) ), + UNO_QUERY_THROW ); + + sal_Bool bShouldValidate = true; + OSL_VERIFY( xDataSourceSettings->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate ); + return bShouldValidate; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return sal_True; + } +} + +// XRowSetApproveListener +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) +{ + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); + sal_Bool bValid = sal_True; + if (aIter.hasMoreElements()) + { + RowChangeEvent aEvt( _rEvent ); + aEvt.Source = *this; + bValid = ((XRowSetApproveListener*)aIter.next())->approveRowChange(aEvt); + } + + if ( !bValid ) + return bValid; + + if ( ( _rEvent.Action != RowChangeAction::INSERT ) + && ( _rEvent.Action != RowChangeAction::UPDATE ) + ) + return bValid; + + // if some of the control models are bound to validators, check them + ::rtl::OUString sInvalidityExplanation; + Reference< XControlModel > xInvalidModel; + if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) ) + { + Reference< XControl > xControl( locateControl( xInvalidModel ) ); + aGuard.clear(); + displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow() ); + return false; + } + + // check values on NULL and required flag + if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) ) + return sal_True; + + OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" ); + if ( !m_pColumnInfoCache.get() ) + return sal_True; + + try + { + if ( !m_pColumnInfoCache->controlsInitialized() ) + m_pColumnInfoCache->initializeControls( getControls() ); + + size_t colCount = m_pColumnInfoCache->getColumnCount(); + for ( size_t col = 0; col < colCount; ++col ) + { + const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo( col ); + if ( rColInfo.nNullable != ColumnValue::NO_NULLS ) + continue; + + if ( rColInfo.bAutoIncrement ) + continue; + + if ( rColInfo.bReadOnly ) + continue; + + if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() ) + continue; + + // TODO: in case of binary fields, this "getString" below is extremely expensive + if ( rColInfo.xColumn->getString().getLength() || !rColInfo.xColumn->wasNull() ) + continue; + + String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) ); + sMessage.SearchAndReplace( '#', rColInfo.sName ); + + // the control to focus + Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired ); + if ( !xControl.is() ) + xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY ); + + aGuard.clear(); + displayErrorSetFocus( sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow() ); + return sal_False; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return true; +} + +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); + if (aIter.hasMoreElements()) + { + EventObject aEvt(event); + aEvt.Source = *this; + return ((XRowSetApproveListener*)aIter.next())->approveCursorMove(aEvt); + } + + return sal_True; +} + +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); + if (aIter.hasMoreElements()) + { + EventObject aEvt(event); + aEvt.Source = *this; + return ((XRowSetApproveListener*)aIter.next())->approveRowSetChange(aEvt); + } + + return sal_True; +} + +// XRowSetApproveBroadcaster +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aRowSetApproveListeners.addInterface(_rxListener); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aRowSetApproveListeners.removeInterface(_rxListener); +} + +// XErrorListener +//------------------------------------------------------------------------------ +void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) +{ + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners); + if (aIter.hasMoreElements()) + { + SQLErrorEvent aEvt(aEvent); + aEvt.Source = *this; + ((XSQLErrorListener*)aIter.next())->errorOccured(aEvt); + } + else + { + aGuard.clear(); + displayException( aEvent ); + } +} + +// XErrorBroadcaster +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aErrorListeners.addInterface(aListener); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aErrorListeners.removeInterface(aListener); +} + +// XDatabaseParameterBroadcaster2 +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aParameterListeners.addInterface(aListener); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aParameterListeners.removeInterface(aListener); +} + +// XDatabaseParameterBroadcaster +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +{ + FormController::addDatabaseParameterListener( aListener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +{ + FormController::removeDatabaseParameterListener( aListener ); +} + +// XDatabaseParameterListener +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) +{ + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners); + if (aIter.hasMoreElements()) + { + DatabaseParameterEvent aEvt(aEvent); + aEvt.Source = *this; + return ((XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt); + } + else + { + // default handling: instantiate an interaction handler and let it handle the parameter request + try + { + if ( !ensureInteractionHandler() ) + return sal_False; + + // two continuations allowed: OK and Cancel + OParameterContinuation* pParamValues = new OParameterContinuation; + OInteractionAbort* pAbort = new OInteractionAbort; + // the request + ParametersRequest aRequest; + aRequest.Parameters = aEvent.Parameters; + aRequest.Connection = OStaticDataAccessTools().getRowSetConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY)); + OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest)); + Reference< XInteractionRequest > xParamRequest(pParamRequest); + // some knittings + pParamRequest->addContinuation(pParamValues); + pParamRequest->addContinuation(pAbort); + + // handle the request + m_xInteractionHandler->handle(xParamRequest); + + if (!pParamValues->wasSelected()) + // canceled + return sal_False; + + // transfer the values into the parameter supplier + Sequence< PropertyValue > aFinalValues = pParamValues->getValues(); + if (aFinalValues.getLength() != aRequest.Parameters->getCount()) + { + DBG_ERROR("FormController::approveParameter: the InteractionHandler returned nonsense!"); + return sal_False; + } + const PropertyValue* pFinalValues = aFinalValues.getConstArray(); + for (sal_Int32 i=0; i xParam; + ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i)); + if (xParam.is()) + { +#ifdef DBG_UTIL + ::rtl::OUString sName; + xParam->getPropertyValue(FM_PROP_NAME) >>= sName; + DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!"); +#endif + try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); } + catch(Exception&) + { + DBG_ERROR("FormController::approveParameter: setting one of the properties failed!"); + } + } + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + return sal_True; +} + +// XConfirmDeleteBroadcaster +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aDeleteListeners.addInterface(aListener); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + m_aDeleteListeners.removeInterface(aListener); +} + +// XConfirmDeleteListener +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners); + if (aIter.hasMoreElements()) + { + RowChangeEvent aEvt(aEvent); + aEvt.Source = *this; + return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt); + } + else + { + // default handling + UniString aTitle; + sal_Int32 nLength = aEvent.Rows; + if (nLength > 1) + { + aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORDS); + aTitle.SearchAndReplace('#', String::CreateFromInt32(nLength)); + } + else + aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORD); + + ConfirmDeleteDialog aDlg(getDialogParentWindow(), aTitle); + return RET_YES == aDlg.Execute(); + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + // for now, just copy the ids of the features, because .... + ::std::copy( _Features.getConstArray(), _Features.getConstArray() + _Features.getLength(), + ::std::insert_iterator< ::std::set< sal_Int16 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) + ); + + // ... we will do the real invalidation asynchronously + if ( !m_aFeatureInvalidationTimer.IsActive() ) + m_aFeatureInvalidationTimer.Start(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::invalidateAllFeatures( ) throw (RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() ); + ::std::transform( + m_aFeatureDispatchers.begin(), + m_aFeatureDispatchers.end(), + aInterceptedFeatures.getArray(), + ::std::select1st< DispatcherContainer::value_type >() + ); + + aGuard.clear(); + if ( aInterceptedFeatures.getLength() ) + invalidateFeatures( aInterceptedFeatures ); +} + +//------------------------------------------------------------------------------ +Reference< XDispatch > +FormController::interceptedQueryDispatch( const URL& aURL, + const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/) + throw( RuntimeException ) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + Reference< XDispatch > xReturn; + // dispatches handled by ourself + if ( ( aURL.Complete == FMURL_CONFIRM_DELETION ) + || ( ( aURL.Complete.equalsAscii( "private:/InteractionHandler" ) ) + && ensureInteractionHandler() + ) + ) + xReturn = static_cast< XDispatch* >( this ); + + // dispatches of FormSlot-URLs we have to translate + if ( !xReturn.is() && m_xFormOperations.is() ) + { + // find the slot id which corresponds to the URL + sal_Int32 nFeatureSlotId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); + sal_Int16 nFormFeature = ( nFeatureSlotId != -1 ) ? ::svx::FeatureSlotTranslation::getFormFeatureForSlotId( nFeatureSlotId ) : -1; + if ( nFormFeature > 0 ) + { + // get the dispatcher for this feature, create if necessary + DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFormFeature ); + if ( aDispatcherPos == m_aFeatureDispatchers.end() ) + { + aDispatcherPos = m_aFeatureDispatchers.insert( + DispatcherContainer::value_type( nFormFeature, new ::svx::OSingleFeatureDispatcher( aURL, nFormFeature, m_xFormOperations, m_aMutex ) ) + ).first; + } + + OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" ); + return aDispatcherPos->second; + } + } + + // no more to offer + return xReturn; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) +{ + if ( _rArgs.getLength() != 1 ) + { + DBG_ERROR( "FormController::dispatch: no arguments -> no dispatch!" ); + return; + } + + if ( _rURL.Complete.equalsAscii( "private:/InteractionHandler" ) ) + { + Reference< XInteractionRequest > xRequest; + OSL_VERIFY( _rArgs[0].Value >>= xRequest ); + if ( xRequest.is() ) + handle( xRequest ); + return; + } + + if ( _rURL.Complete == FMURL_CONFIRM_DELETION ) + { + DBG_ERROR( "FormController::dispatch: How do you expect me to return something via this call?" ); + // confirmDelete has a return value - dispatch hasn't + return; + } + + DBG_ERROR( "FormController::dispatch: unknown URL!" ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) +{ + if (_rURL.Complete == FMURL_CONFIRM_DELETION) + { + if (_rxListener.is()) + { // send an initial statusChanged event + FeatureStateEvent aEvent; + aEvent.FeatureURL = _rURL; + aEvent.IsEnabled = sal_True; + _rxListener->statusChanged(aEvent); + // and don't add the listener at all (the status will never change) + } + } + else + OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!"); +} + +//------------------------------------------------------------------------------ +Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException ) +{ + return m_xParent; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException ) +{ + m_xParent = Parent; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) +{ + (void)_rURL; + OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!"); + // we never really added the listener, so we don't need to remove it +} + +//------------------------------------------------------------------------------ +Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); +#ifdef DBG_UTIL + // check if we already have a interceptor for the given object + for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin(); + aIter != m_aControlDispatchInterceptors.end(); + ++aIter + ) + { + if ((*aIter)->getIntercepted() == _xInterception) + DBG_ERROR("FormController::createInterceptor : we already do intercept this objects dispatches !"); + } +#endif + + DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this ); + pInterceptor->acquire(); + m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor ); + + return pInterceptor; +} + +//------------------------------------------------------------------------------ +bool FormController::ensureInteractionHandler() +{ + if ( m_xInteractionHandler.is() ) + return true; + if ( m_bAttemptedHandlerCreation ) + return false; + m_bAttemptedHandlerCreation = true; + + m_xInteractionHandler.set( m_aContext.createComponent( (::rtl::OUString)SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); + OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" ); + return m_xInteractionHandler.is(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) +{ + if ( !ensureInteractionHandler() ) + return; + m_xInteractionHandler->handle( _rRequest ); +} + +//------------------------------------------------------------------------------ +void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + // search the interceptor responsible for the given object + InterceptorsIterator aIter; + for ( aIter = m_aControlDispatchInterceptors.begin(); + aIter != m_aControlDispatchInterceptors.end(); + ++aIter + ) + { + if ((*aIter)->getIntercepted() == _xInterception) + break; + } + if (aIter == m_aControlDispatchInterceptors.end()) + { + return; + } + + // log off the interception from it's interception object + DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter; + pInterceptorImpl->dispose(); + pInterceptorImpl->release(); + + // remove the interceptor from our array + m_aControlDispatchInterceptors.erase(aIter); +} + +//-------------------------------------------------------------------- +void FormController::implInvalidateCurrentControlDependentFeatures() +{ + Sequence< sal_Int16 > aCurrentControlDependentFeatures(4); + + aCurrentControlDependentFeatures[0] = FormFeature::SortAscending; + aCurrentControlDependentFeatures[1] = FormFeature::SortDescending; + aCurrentControlDependentFeatures[2] = FormFeature::AutoFilter; + aCurrentControlDependentFeatures[3] = FormFeature::RefreshCurrentControl; + + invalidateFeatures( aCurrentControlDependentFeatures ); +} + +//-------------------------------------------------------------------- +void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) +{ + implInvalidateCurrentControlDependentFeatures(); +} + +} // namespace svxform diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx new file mode 100644 index 000000000000..903d27d6e650 --- /dev/null +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -0,0 +1,213 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "formdispatchinterceptor.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include + +//........................................................................ +namespace svxform +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::frame::DispatchDescriptor; + using ::com::sun::star::frame::XDispatchProvider; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //======================================================================== + //= DispatchInterceptionMultiplexer + //======================================================================== + + DBG_NAME(DispatchInterceptionMultiplexer); + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::DispatchInterceptionMultiplexer( + const Reference< XDispatchProviderInterception >& _rxToIntercept, DispatchInterceptor* _pMaster ) + :DispatchInterceptionMultiplexer_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) + ,m_aFallback() + ,m_pMutex( _pMaster && _pMaster->getInterceptorMutex() ? _pMaster->getInterceptorMutex() : &m_aFallback ) + ,m_xIntercepted(_rxToIntercept) + ,m_bListening(sal_False) + ,m_pMaster(_pMaster) + { + DBG_CTOR(DispatchInterceptionMultiplexer,NULL); + + ::osl::MutexGuard aGuard( *m_pMutex ); + ::comphelper::increment(m_refCount); + if (_rxToIntercept.is()) + { + _rxToIntercept->registerDispatchProviderInterceptor((XDispatchProviderInterceptor*)this); + // this should make us the top-level dispatch-provider for the component, via a call to our + // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill + Reference< XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); + if (xInterceptedComponent.is()) + { + xInterceptedComponent->addEventListener(this); + m_bListening = sal_True; + } + } + ::comphelper::decrement(m_refCount); + } + + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::~DispatchInterceptionMultiplexer() + { + if (!rBHelper.bDisposed) + dispose(); + + DBG_DTOR(DispatchInterceptionMultiplexer,NULL); + } + + //------------------------------------------------------------------------------ + Reference< XDispatch > SAL_CALL DispatchInterceptionMultiplexer::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Reference< XDispatch> xResult; + // ask our 'real' interceptor + if (m_pMaster) + xResult = m_pMaster->interceptedQueryDispatch( aURL, aTargetFrameName, nSearchFlags); + + // ask our slave provider + if (!xResult.is() && m_xSlaveDispatcher.is()) + xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); + + return xResult; + } + + //------------------------------------------------------------------------------ + Sequence< Reference< XDispatch > > SAL_CALL + DispatchInterceptionMultiplexer::queryDispatches( const Sequence< DispatchDescriptor >& aDescripts ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength()); + Reference< XDispatch>* pReturn = aReturn.getArray(); + const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_Int16 i=0; iFeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); + } + return aReturn; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider > SAL_CALL DispatchInterceptionMultiplexer::getSlaveDispatchProvider( ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xSlaveDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setSlaveDispatchProvider(const Reference< XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xSlaveDispatcher = xNewDispatchProvider; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider> SAL_CALL DispatchInterceptionMultiplexer::getMasterDispatchProvider(void) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xMasterDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setMasterDispatchProvider(const Reference< XDispatchProvider>& xNewSupplier) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xMasterDispatcher = xNewSupplier; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::disposing(const EventObject& Source) throw( RuntimeException ) + { + if (m_bListening) + { + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (Source.Source == xIntercepted) + ImplDetach(); + } + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::ImplDetach() + { + ::osl::MutexGuard aGuard( *m_pMutex ); + OSL_ENSURE(m_bListening, "DispatchInterceptionMultiplexer::ImplDetach: invalid call!"); + + // deregister ourself from the interception component + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (xIntercepted.is()) + xIntercepted->releaseDispatchProviderInterceptor(static_cast(this)); + + // m_xIntercepted = Reference< XDispatchProviderInterception >(); + // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were + // responsible. As we hold the object with a weak reference only, this should be no problem. + // 88936 - 23.07.2001 - frank.schoenheit@sun.com + m_pMaster = NULL; + m_pMutex = &m_aFallback; + m_bListening = sal_False; + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::disposing() + { + // remove ourself as event listener from the interception component + if (m_bListening) + { + Reference< XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); + if (xInterceptedComponent.is()) + xInterceptedComponent->removeEventListener(static_cast(this)); + + // detach from the interception component + ImplDetach(); + } + } + +//........................................................................ +} // namespace svxform +//........................................................................ diff --git a/svx/source/form/formfeaturedispatcher.cxx b/svx/source/form/formfeaturedispatcher.cxx new file mode 100644 index 000000000000..82ca17812562 --- /dev/null +++ b/svx/source/form/formfeaturedispatcher.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "formfeaturedispatcher.hxx" + +#include +#include + +//........................................................................ +namespace svx +{ +//........................................................................ + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::frame; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::util; + using namespace ::com::sun::star::form::runtime; + + //==================================================================== + //= OSingleFeatureDispatcher + //==================================================================== + //-------------------------------------------------------------------- + OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, const sal_Int16 _nFormFeature, + const Reference< XFormOperations >& _rxFormOperations, ::osl::Mutex& _rMutex ) + :m_rMutex( _rMutex ) + ,m_aStatusListeners( _rMutex ) + ,m_xFormOperations( _rxFormOperations ) + ,m_aFeatureURL( _rFeatureURL ) + ,m_nFormFeature( _nFormFeature ) + ,m_bLastKnownEnabled( sal_False ) + ,m_bDisposed( sal_False ) + { + } + + //-------------------------------------------------------------------- + void OSingleFeatureDispatcher::dispose() + { + { + ::osl::MutexGuard aGuard( m_rMutex ); + if ( m_bDisposed ) + return; + } + + EventObject aDisposeEvent( *this ); + m_aStatusListeners.disposeAndClear( aDisposeEvent ); + + { + ::osl::MutexGuard aGuard( m_rMutex ); + m_bDisposed = sal_True; + } + } + + //-------------------------------------------------------------------- + void OSingleFeatureDispatcher::getUnoState( FeatureStateEvent& /* [out] */ _rState ) const + { + _rState.Source = *const_cast< OSingleFeatureDispatcher* >( this ); + + FeatureState aState( m_xFormOperations->getState( m_nFormFeature ) ); + + _rState.FeatureURL = m_aFeatureURL; + _rState.IsEnabled = aState.Enabled; + _rState.Requery = sal_False; + _rState.State = aState.State; + } + + //-------------------------------------------------------------------- + void OSingleFeatureDispatcher::updateAllListeners() + { + ::osl::ClearableMutexGuard aGuard( m_rMutex ); + + FeatureStateEvent aUnoState; + getUnoState( aUnoState ); + + if ( ( m_aLastKnownState == aUnoState.State ) && ( m_bLastKnownEnabled == aUnoState.IsEnabled ) ) + return; + + m_aLastKnownState = aUnoState.State; + m_bLastKnownEnabled = aUnoState.IsEnabled; + + notifyStatus( NULL, aGuard ); + } + + //-------------------------------------------------------------------- + void OSingleFeatureDispatcher::notifyStatus( const Reference< XStatusListener >& _rxListener, ::osl::ClearableMutexGuard& _rFreeForNotification ) + { + FeatureStateEvent aUnoState; + getUnoState( aUnoState ); + + if ( _rxListener.is() ) + { + try + { + _rFreeForNotification.clear(); + _rxListener->statusChanged( aUnoState ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught an exception!" ); + } + } + else + { + ::cppu::OInterfaceIteratorHelper aIter( m_aStatusListeners ); + _rFreeForNotification.clear(); + + while ( aIter.hasMoreElements() ) + { + try + { + static_cast< XStatusListener* >( aIter.next() )->statusChanged( aUnoState ); + } + catch( const DisposedException& ) + { + OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a DisposedException - removing the listener!" ); + aIter.remove( ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a generic exception while notifying a single listener!" ); + } + } + } + } + + //-------------------------------------------------------------------- + void SAL_CALL OSingleFeatureDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( m_rMutex ); + checkAlive(); + + OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::dispatch: not responsible for this URL!" ); + (void)_rURL; + + if ( !m_xFormOperations->isEnabled( m_nFormFeature ) ) + return; + + // release our mutex before executing the command + sal_Int16 nFormFeature( m_nFormFeature ); + Reference< XFormOperations > xFormOperations( m_xFormOperations ); + aGuard.clear(); + + try + { + if ( !_rArguments.getLength() ) + { + xFormOperations->execute( nFormFeature ); + } + else + { // at the moment we only support one parameter + ::comphelper::NamedValueCollection aArgs( _rArguments ); + xFormOperations->executeWithArguments( nFormFeature, aArgs.getNamedValues() ); + } + } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + void SAL_CALL OSingleFeatureDispatcher::addStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException) + { + (void)_rURL; + OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::addStatusListener: unexpected URL!" ); + OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::addStatusListener: senseless call!" ); + if ( !_rxControl.is() ) + return; + + ::osl::ClearableMutexGuard aGuard( m_rMutex ); + if ( m_bDisposed ) + { + EventObject aDisposeEvent( *this ); + aGuard.clear(); + _rxControl->disposing( aDisposeEvent ); + return; + } + + m_aStatusListeners.addInterface( _rxControl ); + + // initially update the status + notifyStatus( _rxControl, aGuard ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OSingleFeatureDispatcher::removeStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException) + { + (void)_rURL; + OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::removeStatusListener: unexpected URL!" ); + OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::removeStatusListener: senseless call!" ); + if ( !_rxControl.is() ) + return; + + ::osl::MutexGuard aGuard( m_rMutex ); + checkAlive(); + + m_aStatusListeners.removeInterface( _rxControl ); + } + + //-------------------------------------------------------------------- + void OSingleFeatureDispatcher::checkAlive() const SAL_THROW((DisposedException)) + { + if ( m_bDisposed ) + throw DisposedException( ::rtl::OUString(), *const_cast< OSingleFeatureDispatcher* >( this ) ); + } + +//........................................................................ +} // namespace svx +//........................................................................ diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk index fc6963d22b74..3c86a36c2685 100644 --- a/svx/source/form/makefile.mk +++ b/svx/source/form/makefile.mk @@ -75,7 +75,7 @@ LIB1OBJFILES= \ $(SLO)$/navigatortree.obj \ $(SLO)$/navigatortreemodel.obj \ $(SLO)$/fmexpl.obj \ - $(SLO)$/fmctrler.obj \ + $(SLO)$/formcontroller.obj \ $(SLO)$/fmpgeimp.obj \ $(SLO)$/fmvwimp.obj \ $(SLO)$/fmdpage.obj \ @@ -91,7 +91,8 @@ LIB1OBJFILES= \ $(SLO)$/fmview.obj \ $(SLO)$/sdbdatacolumn.obj \ $(SLO)$/formcontrolling.obj \ - $(SLO)$/fmdispatch.obj \ + $(SLO)$/formfeaturedispatcher.obj \ + $(SLO)$/formdispatchinterceptor.obj \ $(SLO)$/datanavi.obj \ $(SLO)$/xfm_addcondition.obj \ $(SLO)$/datalistener.obj \ diff --git a/svx/source/inc/confirmdelete.hxx b/svx/source/inc/confirmdelete.hxx index a06e297a8748..049f60e08f02 100644 --- a/svx/source/inc/confirmdelete.hxx +++ b/svx/source/inc/confirmdelete.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: confirmdelete.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/delayedevent.hxx b/svx/source/inc/delayedevent.hxx index 151b998f2f8c..bd8194a00c82 100644 --- a/svx/source/inc/delayedevent.hxx +++ b/svx/source/inc/delayedevent.hxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.hxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx index 34dc8d86fb0b..a9e605873940 100644 --- a/svx/source/inc/fmcontrolbordermanager.hxx +++ b/svx/source/inc/fmcontrolbordermanager.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.hxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmcontrollayout.hxx b/svx/source/inc/fmcontrollayout.hxx index 1110c274b9f8..fdaa5e17bc7e 100644 --- a/svx/source/inc/fmcontrollayout.hxx +++ b/svx/source/inc/fmcontrollayout.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx deleted file mode 100644 index 550bce611c73..000000000000 --- a/svx/source/inc/fmctrler.hxx +++ /dev/null @@ -1,600 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_FMCTRLER_HXX -#define _SVX_FMCTRLER_HXX - -#include "fmtools.hxx" -#include "formcontrolling.hxx" -#include "sqlparserclient.hxx" -#include "delayedevent.hxx" - -/** === begin UNO includes === **/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/** === end UNO includes === **/ - -#include -#include -#include -#include -#include -#include -#include - -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 -#include -#endif - -struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent> , sal_Bool> -{ - sal_Bool operator() (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& x, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& y) const - { - return reinterpret_cast(x.get()) < reinterpret_cast(y.get()); - } -}; - -typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; -typedef ::std::vector< FmFilterRow > FmFilterRows; -typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers; - -class FmFormView; -class Window; - -namespace svxform -{ - typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > > FilterComponents; - class ControlBorderManager; - struct FmFieldInfo; - - typedef ::comphelper::WeakComponentImplHelper21 < ::com::sun::star::form::runtime::XFormController - , ::com::sun::star::form::runtime::XFilterController - , ::com::sun::star::awt::XFocusListener - , ::com::sun::star::form::XLoadListener - , ::com::sun::star::beans::XPropertyChangeListener - , ::com::sun::star::awt::XTextListener - , ::com::sun::star::awt::XItemListener - , ::com::sun::star::container::XContainerListener - , ::com::sun::star::util::XModifyListener - , ::com::sun::star::form::XConfirmDeleteListener - , ::com::sun::star::sdb::XSQLErrorListener - , ::com::sun::star::sdbc::XRowSetListener - , ::com::sun::star::sdb::XRowSetApproveListener - , ::com::sun::star::form::XDatabaseParameterListener - , ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::form::XResetListener - , ::com::sun::star::frame::XDispatch - , ::com::sun::star::awt::XMouseListener - , ::com::sun::star::form::validation::XFormComponentValidityListener - , ::com::sun::star::task::XInteractionHandler - , ::com::sun::star::form::XGridControlListener - > FormController_BASE; - - //================================================================== - // FormController - //================================================================== - class ColumnInfoCache; - class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex - ,public FormController_BASE - ,public ::cppu::OPropertySetHelper - ,public FmDispatchInterceptor - ,public ::comphelper::OAggregationArrayUsageHelper< FormController > - ,public ::svxform::OSQLParserClient - ,public ::svx::IControllerFeatureInvalidation - { - typedef ::std::map < sal_Int32, - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > - > DispatcherContainer; - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; - ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; - // Composer used for checking filter conditions - ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; - ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; - ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > m_xContext; - - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; - ::cppu::OInterfaceContainerHelper - m_aActivateListeners, - m_aModifyListeners, - m_aErrorListeners, - m_aDeleteListeners, - m_aRowSetApproveListeners, - m_aParameterListeners, - m_aFilterListeners; - - FmFormControllers m_aChilds; - FilterComponents m_aFilterComponents; - FmFilterRows m_aFilterRows; - - Timer m_aTabActivationTimer; - Timer m_aFeatureInvalidationTimer; - - ::svxform::ControlBorderManager* - m_pControlBorderManager; - - ::svx::ControllerFeatures m_aControllerFeatures; - DispatcherContainer m_aFeatureDispatchers; - ::std::set< sal_Int32 > m_aInvalidFeatures; // for asynchronous feature invalidation - - ::rtl::OUString m_aMode; - - ::svxform::DelayedEvent m_aLoadEvent; - ::svxform::DelayedEvent m_aToggleEvent; - ::svxform::DelayedEvent m_aActivationEvent; - ::svxform::DelayedEvent m_aDeactivationEvent; - - ::std::auto_ptr< ColumnInfoCache > - m_pColumnInfoCache; - - sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) - - sal_Bool m_bCurrentRecordModified : 1; - sal_Bool m_bCurrentRecordNew : 1; - sal_Bool m_bLocked : 1; - sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare - sal_Bool m_bCycle : 1; - sal_Bool m_bCanInsert : 1; - sal_Bool m_bCanUpdate : 1; - sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained - sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? - sal_Bool m_bControlsSorted : 1; - sal_Bool m_bFiltering : 1; - sal_Bool m_bAttachEvents : 1; - sal_Bool m_bDetachEvents : 1; - sal_Bool m_bAttemptedHandlerCreation : 1; - - // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing - // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class - DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); - Interceptors m_aControlDispatchInterceptors; - - public: - FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ); - - protected: - ~FormController(); - - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); - - // XTypeProvider - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - // XDispatch - virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::container::XChild - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); - - // ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); - - // OComponentHelper - virtual void SAL_CALL disposing(); - - // OPropertySetHelper - virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) - throw( ::com::sun::star::lang::IllegalArgumentException ); - - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); - virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - using OPropertySetHelper::getFastPropertyValue; - - // XFilterController - virtual ::sal_Int32 SAL_CALL getFilterComponents() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 _Component ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getPredicateExpressions() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL appendEmptyDisjunctiveTerm() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getActiveTerm() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - - // XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); - - // ::com::sun::star::container::XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - - // ::com::sun::star::container::XContainerListener - virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XLoadListener - virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XModeSelector - virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); - virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); - - // ::com::sun::star::container::XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - // XModifyBroadcaster - virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - - // XFocusListener - virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); - - // XMouseListener - virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - - // XFormComponentValidityListener - virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); - - // XInteractionHandler - virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); - - // XGridControlListener - virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati - virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); - - // XTextListener -> modify setzen - virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XItemListener -> modify setzen - virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XModifyListener -> modify setzen - virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XFormController - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException); - - // XTabController - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); - - // com::sun::star::sdbc::XRowSetListener - virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - - // XRowSetApproveListener - virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - - // XRowSetApproveBroadcaster - virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); - - // XSQLErrorBroadcaster - virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XSQLErrorListener - virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - - // XDatabaseParameterBroadcaster2 - virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - - // XDatabaseParameterBroadcaster - virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - - // XDatabaseParameterListener - virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XConfirmDeleteBroadcaster - virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - - // XConfirmDeleteListener - virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // XServiceInfo - virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); - - // XResetListener - virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - - // method for registration - static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); - - // comphelper::OPropertyArrayUsageHelper - virtual void fillProperties( - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps - ) const; - - protected: - // FmDispatchInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> - interceptedQueryDispatch(sal_uInt16 _nId,const ::com::sun::star::util::URL& aURL, - const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) - throw( ::com::sun::star::uno::RuntimeException ); - - // IControllerFeatureInvalidation - virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ); - - virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } - - /// update all our dispatchers - void updateAllDispatchers() const; - - /** disposes all dispatchers in m_aFeatureDispatchers, empties m_aFeatureDispatchers, - and disposes m_aControllerFeatures - */ - void disposeAllFeaturesAndDispatchers() SAL_THROW(()); - - void startFiltering(); - void stopFiltering(); - void setFilter(::std::vector&); - void startListening(); - void stopListening(); - - /** ensures that we have an interaction handler, if possible - - If an interaction handler was provided at creation time (initialize), this - one will be used. Else, an attempt is made to create an InteractionHandler - is made. - - @return - if and only if m_xInteractionHandler is valid when the method returns - */ - bool ensureInteractionHandler(); - - /** replaces one of our controls with another one - - Upon successful replacing, the old control will be disposed. Also, internal members pointing - to the current or active control will be adjusted. Yet more, if the replaced control was - the active control, the new control will be made active. - - @param _rxExistentControl - The control to replace. Must be one of the controls in our ControlContainer. - @param _rxNewControl - The control which should replace the existent control. - @return - if and only if the control was successfully replaced - */ - bool replaceControl( - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl - ); - - // we're listening at all bound controls for modifications - void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - void setLocks(); - void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void toggleAutoFields(sal_Bool bAutoFields); - void unload() throw( ::com::sun::star::uno::RuntimeException ); - void removeBoundFieldListener(); - - void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; - - void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - /// called when a new control is to be handled by the controller - void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); - /// called when a control is not to be handled by the controller anymore - void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); - - /** sets m_xCurrentControl, plus does administrative tasks depending on it - */ - void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); - - /** invalidates the FormFeatures which depend on the current control - */ - void implInvalidateCurrentControlDependentFeatures(); - - bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } - void impl_checkDisposed_throw() const; - - void impl_onModify(); - - /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added - row is the first one. - - @precond - our mutex is locked - */ - void impl_addFilterRow( const FmFilterRow& _row ); - - /** adds an empty filter row to m_aFilterRows, and notifies our listeners - */ - void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); - - sal_Bool isLocked() const {return m_bLocked;} - sal_Bool determineLockState() const; - - Window* getDialogParentWindow(); - // returns the window which should be used as parent window for dialogs - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // create a new interceptor, register it on the given object - void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // if createInterceptor was called for the given object the according interceptor will be removed - // from the objects interceptor chain and released - - /** checks all form controls belonging to our form for validity - - If a form control supports the XValidatableFormComponent interface, this is used to determine - the validity of the control. If the interface is not supported, the control is supposed to be - valid. - - @param _rFirstInvalidityExplanation - if the method returns (i.e. if there is an invalid control), this string contains - the explanation for the invalidity, as obtained from the validator. - - @param _rxFirstInvalidModel - if the method returns (i.e. if there is an invalid control), this contains - the control model - - @return - if and only if all controls belonging to our form are valid - */ - bool checkFormComponentValidity( - ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel - ) SAL_THROW(()); - - /** locates the control which belongs to a given model - */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > - locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); - - // set the text for all filters - void impl_setTextOnAllFilter_throw(); - - // in filter mode we do not listen for changes - sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; - - DECL_LINK( OnActivateTabOrder, void* ); - DECL_LINK( OnInvalidateFeatures, void* ); - DECL_LINK( OnLoad, void* ); - DECL_LINK( OnToggleAutoFields, void* ); - DECL_LINK( OnActivated, void* ); - DECL_LINK( OnDeactivated, void* ); - }; - -} // namespace svxform - -#endif // _SVX_FMCTRLER_HXX - diff --git a/svx/source/inc/fmdispatch.hxx b/svx/source/inc/fmdispatch.hxx deleted file mode 100644 index 90480afc4609..000000000000 --- a/svx/source/inc/fmdispatch.hxx +++ /dev/null @@ -1,158 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: fmdispatch.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SVX_FMDISPATCH_HXX -#define SVX_FMDISPATCH_HXX - -#include -#include -#include -#include - - -//........................................................................ -namespace svx -{ -//........................................................................ - - class FormControllerHelper; - - //==================================================================== - //= OSingleFeatureDispatcher - //==================================================================== - typedef ::cppu::WeakImplHelper1 < ::com::sun::star::frame::XDispatch - > OSingleFeatureDispatcher_Base; - - class OSingleFeatureDispatcher : public OSingleFeatureDispatcher_Base - { - private: - ::osl::Mutex& m_rMutex; - ::cppu::OInterfaceContainerHelper m_aStatusListeners; - const FormControllerHelper& m_rController; - const ::com::sun::star::util::URL m_aFeatureURL; - ::com::sun::star::uno::Any m_aLastKnownState; - const sal_Int32 m_nFeatureId; - sal_Bool m_bLastKnownEnabled; - sal_Bool m_bDisposed; - - public: - /** constructs the dispatcher - - @param _rFeatureURL - the URL of the feature which this instance is responsible for - - @param _nFeatureId - the feature which this instance is responsible for - - @param _rController - the controller which is responsible for providing the state of feature of this instance, - and for executing it. After disposing the dispatcher instance, the controller will - not be accessed anymore - - @see dispose - */ - OSingleFeatureDispatcher( - const ::com::sun::star::util::URL& _rFeatureURL, - sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, - ::osl::Mutex& _rMutex - ); - - /** disposes the dispatcher instance - - All status listeners will, after receiving an XEventListener::disposing - call, be released. - - The controller provided in the in constructor will not be used anymore after returning from this call. - - No further requests to dispatch slots will be accepted. - - Multiple calls are allowed: if the object already was disposed, then subsequent calls are - silently ignored. - */ - void dispose(); - - /** notifies all our listeners of the current state - */ - void updateAllListeners(); - - protected: - // XDispatch - virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArguments ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - - protected: - /** notifies our current state to one or all listeners - - @param _rxListener - the listener to notify. May be NULL, in this case all our listeners will be - notified with the current state - - @param _rFreeForNotification - a guard which currently locks our mutex, and which is to be cleared - for actually doing the notification(s) - */ - void notifyStatus( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, - ::osl::ClearableMutexGuard& _rFreeForNotification - ); - - private: - /** checks whether our instance is alive - - If the instance already received a dispose call, then a - DisposedException is thrown. - - @precond - our Mutex is locked - else calling the method would not make sense, since - it's result could be out-of-date as soon as it's returned to the caller. - */ - void checkAlive() const SAL_THROW((::com::sun::star::lang::DisposedException)); - - /** retrieves the current status of our feature, in a format which can be used - for UNO notifications - - @precond - our mutex is locked - */ - void getUnoState( ::com::sun::star::frame::FeatureStateEvent& /* [out] */ _rState ) const; - - private: - OSingleFeatureDispatcher(); // never implemented - OSingleFeatureDispatcher( const OSingleFeatureDispatcher& ); // never implemented - OSingleFeatureDispatcher& operator=( const OSingleFeatureDispatcher& ); // never implemented - }; - -//........................................................................ -} // namespace svx -//........................................................................ - -#endif diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 7d60e60f6d0e..434f13a177d0 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -270,8 +270,6 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on - FmXDispatchInterceptorImpl* m_pExternalViewInterceptor; - mutable ::svxform::DocumentType m_eDocumentType; /// the type of document we're living in sal_Int16 m_nLockSlotInvalidation; diff --git a/svx/source/inc/fmtools.hxx b/svx/source/inc/fmtools.hxx index 935e84c6448e..9e9e892ef6cc 100644 --- a/svx/source/inc/fmtools.hxx +++ b/svx/source/inc/fmtools.hxx @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -93,8 +92,6 @@ #include #include #include -#include -#include #include #include @@ -114,9 +111,6 @@ SVX_DLLPUBLIC void displayException(const ::com::sun::star::sdb::SQLContext&, Wi void displayException(const ::com::sun::star::sdb::SQLErrorEvent&, Window* _pParent = NULL); void displayException(const ::com::sun::star::uno::Any&, Window* _pParent = NULL); -#define DATA_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) -#define FILTER_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) - // Kopieren von Persistenten Objecten ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> cloneUsingProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>& _xObj); @@ -258,107 +252,6 @@ public: // ================================================================== -//======================================================================== -//= dispatch interception helper classes -//======================================================================== - -//------------------------------------------------------------------------ -//- FmDispatchInterceptor -//------------------------------------------------------------------------ -class FmDispatchInterceptor -{ -public: - FmDispatchInterceptor() { } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch(sal_uInt16 _nId, - const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; - - virtual ::osl::Mutex* getInterceptorMutex() = 0; -}; - -//------------------------------------------------------------------------ -//- FmXDispatchInterceptorImpl -//------------------------------------------------------------------------ -typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::frame::XDispatchProviderInterceptor - , ::com::sun::star::lang::XEventListener - , ::com::sun::star::frame::XInterceptorInfo - > FmXDispatchInterceptorImpl_BASE; - -class FmXDispatchInterceptorImpl : public FmXDispatchInterceptorImpl_BASE -{ - ::osl::Mutex m_aFallback; - - // the component which's dispatches we're intercepting - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception> - m_xIntercepted; - sal_Bool m_bListening; - - // the real interceptor - FmDispatchInterceptor* m_pMaster; - - // chaining - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; - - // our id - sal_Int16 m_nId; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > - m_aInterceptedURLSchemes; - - virtual ~FmXDispatchInterceptorImpl(); - -public: - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } - -public: - FmXDispatchInterceptorImpl( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, - FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, - ::com::sun::star::uno::Sequence< ::rtl::OUString > _rInterceptedSchemes /// if not empty, this will be used for getInterceptedURLs - ); - - // StarOne - DECLARE_UNO3_DEFAULTS(FmXDispatchInterceptorImpl, FmXDispatchInterceptorImpl_BASE); - // virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - - // ::com::sun::star::frame::XDispatchProvider - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XDispatchProviderInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XInterceptorInfo - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getInterceptedURLs( ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - -protected: - void ImplDetach(); - - ::osl::Mutex& getAccessSafety() - { - if (m_pMaster && m_pMaster->getInterceptorMutex()) - return *m_pMaster->getInterceptorMutex(); - return m_aFallback; - } -}; - -//================================================================== -// ... -//================================================================== ::rtl::OUString getServiceNameByControlType(sal_Int16 nType); // get a service name to create a model of the given type (OBJ_FM_...) sal_Int16 getControlTypeByObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject); diff --git a/svx/source/inc/formcontroller.hxx b/svx/source/inc/formcontroller.hxx new file mode 100644 index 000000000000..4c4ba187187d --- /dev/null +++ b/svx/source/inc/formcontroller.hxx @@ -0,0 +1,592 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVX_FMCTRLER_HXX +#define _SVX_FMCTRLER_HXX + +#include "delayedevent.hxx" +#include "formdispatchinterceptor.hxx" +#include "sqlparserclient.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 +#include +#endif + +struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent> , sal_Bool> +{ + sal_Bool operator() (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& x, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& y) const + { + return reinterpret_cast(x.get()) < reinterpret_cast(y.get()); + } +}; + +typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; +typedef ::std::vector< FmFilterRow > FmFilterRows; +typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers; + +class FmFormView; +class Window; + +namespace svxform +{ + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > > FilterComponents; + class ControlBorderManager; + struct FmFieldInfo; + + typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + , ::com::sun::star::form::runtime::XFilterController + , ::com::sun::star::awt::XFocusListener + , ::com::sun::star::form::XLoadListener + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::awt::XTextListener + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XModifyListener + , ::com::sun::star::form::XConfirmDeleteListener + , ::com::sun::star::sdb::XSQLErrorListener + , ::com::sun::star::sdbc::XRowSetListener + , ::com::sun::star::sdb::XRowSetApproveListener + , ::com::sun::star::form::XDatabaseParameterListener + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::form::XResetListener + , ::com::sun::star::frame::XDispatch + , ::com::sun::star::awt::XMouseListener + , ::com::sun::star::form::validation::XFormComponentValidityListener + , ::com::sun::star::task::XInteractionHandler + , ::com::sun::star::form::XGridControlListener + , ::com::sun::star::form::runtime::XFeatureInvalidation + > FormController_BASE; + + //================================================================== + // FormController + //================================================================== + class ColumnInfoCache; + class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex + ,public FormController_BASE + ,public ::cppu::OPropertySetHelper + ,public DispatchInterceptor + ,public ::comphelper::OAggregationArrayUsageHelper< FormController > + ,public ::svxform::OSQLParserClient + { + typedef ::std::map < sal_Int16, + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > + > DispatcherContainer; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; + ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; + ::comphelper::ComponentContext m_aContext; + // Composer used for checking filter conditions + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > m_xContext; + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; + ::cppu::OInterfaceContainerHelper + m_aActivateListeners, + m_aModifyListeners, + m_aErrorListeners, + m_aDeleteListeners, + m_aRowSetApproveListeners, + m_aParameterListeners, + m_aFilterListeners; + + FmFormControllers m_aChilds; + FilterComponents m_aFilterComponents; + FmFilterRows m_aFilterRows; + + Timer m_aTabActivationTimer; + Timer m_aFeatureInvalidationTimer; + + ::svxform::ControlBorderManager* + m_pControlBorderManager; + + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; + DispatcherContainer m_aFeatureDispatchers; + ::std::set< sal_Int16 > m_aInvalidFeatures; // for asynchronous feature invalidation + + ::rtl::OUString m_aMode; + + ::svxform::DelayedEvent m_aLoadEvent; + ::svxform::DelayedEvent m_aToggleEvent; + ::svxform::DelayedEvent m_aActivationEvent; + ::svxform::DelayedEvent m_aDeactivationEvent; + + ::std::auto_ptr< ColumnInfoCache > + m_pColumnInfoCache; + + sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) + + sal_Bool m_bCurrentRecordModified : 1; + sal_Bool m_bCurrentRecordNew : 1; + sal_Bool m_bLocked : 1; + sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare + sal_Bool m_bCycle : 1; + sal_Bool m_bCanInsert : 1; + sal_Bool m_bCanUpdate : 1; + sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained + sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? + sal_Bool m_bControlsSorted : 1; + sal_Bool m_bFiltering : 1; + sal_Bool m_bAttachEvents : 1; + sal_Bool m_bDetachEvents : 1; + sal_Bool m_bAttemptedHandlerCreation : 1; + + // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing + // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class + DECLARE_STL_VECTOR(DispatchInterceptionMultiplexer*, Interceptors); + Interceptors m_aControlDispatchInterceptors; + + public: + FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ); + + protected: + ~FormController(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + using OPropertySetHelper::getFastPropertyValue; + + // XFilterController + virtual ::sal_Int32 SAL_CALL getFilterComponents() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 _Component ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getPredicateExpressions() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendEmptyDisjunctiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getActiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XEnumerationAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XContainerListener + virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XLoadListener + virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XModeSelector + virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + + // XFocusListener + virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + + // XMouseListener + virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + + // XFormComponentValidityListener + virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); + + // XGridControlListener + virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati + virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); + + // XTextListener -> modify setzen + virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XItemListener -> modify setzen + virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XModifyListener -> modify setzen + virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XFormController + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException); + + // XTabController + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); + + // com::sun::star::sdbc::XRowSetListener + virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + + // XRowSetApproveListener + virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + + // XRowSetApproveBroadcaster + virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + + // XSQLErrorBroadcaster + virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XSQLErrorListener + virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterBroadcaster2 + virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterBroadcaster + virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterListener + virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XConfirmDeleteBroadcaster + virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XConfirmDeleteListener + virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); + + // XResetListener + virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XFeatureInvalidation + virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL invalidateAllFeatures( ) throw (::com::sun::star::uno::RuntimeException); + +// method for registration + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); + + // comphelper::OPropertyArrayUsageHelper + virtual void fillProperties( + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps + ) const; + + protected: + // DispatchInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> + interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, + const ::rtl::OUString& aTargetFrameName, + sal_Int32 nSearchFlags + ) throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } + + /// update all our dispatchers + void updateAllDispatchers() const; + + /** disposes all dispatchers in m_aFeatureDispatchers, and empties m_aFeatureDispatchers + */ + void disposeAllFeaturesAndDispatchers() SAL_THROW(()); + + void startFiltering(); + void stopFiltering(); + void setFilter(::std::vector&); + void startListening(); + void stopListening(); + + /** ensures that we have an interaction handler, if possible + + If an interaction handler was provided at creation time (initialize), this + one will be used. Else, an attempt is made to create an InteractionHandler + is made. + + @return + if and only if m_xInteractionHandler is valid when the method returns + */ + bool ensureInteractionHandler(); + + /** replaces one of our controls with another one + + Upon successful replacing, the old control will be disposed. Also, internal members pointing + to the current or active control will be adjusted. Yet more, if the replaced control was + the active control, the new control will be made active. + + @param _rxExistentControl + The control to replace. Must be one of the controls in our ControlContainer. + @param _rxNewControl + The control which should replace the existent control. + @return + if and only if the control was successfully replaced + */ + bool replaceControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl + ); + + // we're listening at all bound controls for modifications + void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + void setLocks(); + void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void toggleAutoFields(sal_Bool bAutoFields); + void unload() throw( ::com::sun::star::uno::RuntimeException ); + void removeBoundFieldListener(); + + void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; + + void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + /// called when a new control is to be handled by the controller + void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); + /// called when a control is not to be handled by the controller anymore + void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); + + /** sets m_xCurrentControl, plus does administrative tasks depending on it + */ + void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); + + /** invalidates the FormFeatures which depend on the current control + */ + void implInvalidateCurrentControlDependentFeatures(); + + bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } + void impl_checkDisposed_throw() const; + + void impl_onModify(); + + /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added + row is the first one. + + @precond + our mutex is locked + */ + void impl_addFilterRow( const FmFilterRow& _row ); + + /** adds an empty filter row to m_aFilterRows, and notifies our listeners + */ + void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); + + sal_Bool isLocked() const {return m_bLocked;} + sal_Bool determineLockState() const; + + Window* getDialogParentWindow(); + // returns the window which should be used as parent window for dialogs + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // create a new interceptor, register it on the given object + void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // if createInterceptor was called for the given object the according interceptor will be removed + // from the objects interceptor chain and released + + /** checks all form controls belonging to our form for validity + + If a form control supports the XValidatableFormComponent interface, this is used to determine + the validity of the control. If the interface is not supported, the control is supposed to be + valid. + + @param _rFirstInvalidityExplanation + if the method returns (i.e. if there is an invalid control), this string contains + the explanation for the invalidity, as obtained from the validator. + + @param _rxFirstInvalidModel + if the method returns (i.e. if there is an invalid control), this contains + the control model + + @return + if and only if all controls belonging to our form are valid + */ + bool checkFormComponentValidity( + ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel + ) SAL_THROW(()); + + /** locates the control which belongs to a given model + */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > + locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); + + // set the text for all filters + void impl_setTextOnAllFilter_throw(); + + // in filter mode we do not listen for changes + sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; + + DECL_LINK( OnActivateTabOrder, void* ); + DECL_LINK( OnInvalidateFeatures, void* ); + DECL_LINK( OnLoad, void* ); + DECL_LINK( OnToggleAutoFields, void* ); + DECL_LINK( OnActivated, void* ); + DECL_LINK( OnDeactivated, void* ); + }; + +} // namespace svxform + +#endif // _SVX_FMCTRLER_HXX + diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx index 2b5b64db262d..f818ced85189 100644 --- a/svx/source/inc/formcontrolling.hxx +++ b/svx/source/inc/formcontrolling.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: formcontrolling.hxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/formdispatchinterceptor.hxx b/svx/source/inc/formdispatchinterceptor.hxx new file mode 100644 index 000000000000..5bcfc1726ad0 --- /dev/null +++ b/svx/source/inc/formdispatchinterceptor.hxx @@ -0,0 +1,118 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef SVX_FORMDISPATCHINTERCEPTOR_HXX +#define SVX_FORMDISPATCHINTERCEPTOR_HXX + +/** === begin UNO includes === **/ +#include +#include +/** === end UNO includes === **/ + +#include +#include + +//........................................................................ +namespace svxform +{ +//........................................................................ + + //==================================================================== + //= DispatchInterceptor + //==================================================================== + class DispatchInterceptor + { + public: + DispatchInterceptor() { } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; + + virtual ::osl::Mutex* getInterceptorMutex() = 0; + }; + + //==================================================================== + //= + //==================================================================== + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::frame::XDispatchProviderInterceptor + , ::com::sun::star::lang::XEventListener + > DispatchInterceptionMultiplexer_BASE; + + class DispatchInterceptionMultiplexer : public DispatchInterceptionMultiplexer_BASE + { + ::osl::Mutex m_aFallback; + ::osl::Mutex* m_pMutex; + + // the component which's dispatches we're intercepting + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception > + m_xIntercepted; + sal_Bool m_bListening; + + // the real interceptor + DispatchInterceptor* m_pMaster; + + // chaining + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; + + virtual ~DispatchInterceptionMultiplexer(); + + public: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } + + public: + DispatchInterceptionMultiplexer( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, + DispatchInterceptor* _pMaster + ); + + // UNO + DECLARE_UNO3_DEFAULTS(DispatchInterceptionMultiplexer, DispatchInterceptionMultiplexer_BASE); + + // ::com::sun::star::frame::XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::frame::XDispatchProviderInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + protected: + void ImplDetach(); + }; + +//........................................................................ +} // namespace svxform +//........................................................................ + +#endif // SVX_FORMDISPATCHINTERCEPTOR_HXX diff --git a/svx/source/inc/formfeaturedispatcher.hxx b/svx/source/inc/formfeaturedispatcher.hxx new file mode 100644 index 000000000000..32316d52b922 --- /dev/null +++ b/svx/source/inc/formfeaturedispatcher.hxx @@ -0,0 +1,157 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVX_FMDISPATCH_HXX +#define SVX_FMDISPATCH_HXX + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include + +//........................................................................ +namespace svx +{ +//........................................................................ + + //==================================================================== + //= OSingleFeatureDispatcher + //==================================================================== + typedef ::cppu::WeakImplHelper1 < ::com::sun::star::frame::XDispatch + > OSingleFeatureDispatcher_Base; + + class OSingleFeatureDispatcher : public OSingleFeatureDispatcher_Base + { + private: + ::osl::Mutex& m_rMutex; + ::cppu::OInterfaceContainerHelper m_aStatusListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; + const ::com::sun::star::util::URL m_aFeatureURL; + ::com::sun::star::uno::Any m_aLastKnownState; + const sal_Int16 m_nFormFeature; + sal_Bool m_bLastKnownEnabled; + sal_Bool m_bDisposed; + + public: + /** constructs the dispatcher + + @param _rFeatureURL + the URL of the feature which this instance is responsible for + + @param _nFeatureId + the feature which this instance is responsible for + + @param _rController + the controller which is responsible for providing the state of feature of this instance, + and for executing it. After disposing the dispatcher instance, the controller will + not be accessed anymore + + @see dispose + */ + OSingleFeatureDispatcher( + const ::com::sun::star::util::URL& _rFeatureURL, + const sal_Int16 _nFormFeature, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >& _rxFormOperations, + ::osl::Mutex& _rMutex + ); + + /** disposes the dispatcher instance + + All status listeners will, after receiving an XEventListener::disposing + call, be released. + + The controller provided in the in constructor will not be used anymore after returning from this call. + + No further requests to dispatch slots will be accepted. + + Multiple calls are allowed: if the object already was disposed, then subsequent calls are + silently ignored. + */ + void dispose(); + + /** notifies all our listeners of the current state + */ + void updateAllListeners(); + + protected: + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArguments ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + + protected: + /** notifies our current state to one or all listeners + + @param _rxListener + the listener to notify. May be NULL, in this case all our listeners will be + notified with the current state + + @param _rFreeForNotification + a guard which currently locks our mutex, and which is to be cleared + for actually doing the notification(s) + */ + void notifyStatus( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, + ::osl::ClearableMutexGuard& _rFreeForNotification + ); + + private: + /** checks whether our instance is alive + + If the instance already received a dispose call, then a + DisposedException is thrown. + + @precond + our Mutex is locked - else calling the method would not make sense, since + it's result could be out-of-date as soon as it's returned to the caller. + */ + void checkAlive() const SAL_THROW((::com::sun::star::lang::DisposedException)); + + /** retrieves the current status of our feature, in a format which can be used + for UNO notifications + + @precond + our mutex is locked + */ + void getUnoState( ::com::sun::star::frame::FeatureStateEvent& /* [out] */ _rState ) const; + + private: + OSingleFeatureDispatcher(); // never implemented + OSingleFeatureDispatcher( const OSingleFeatureDispatcher& ); // never implemented + OSingleFeatureDispatcher& operator=( const OSingleFeatureDispatcher& ); // never implemented + }; + +//........................................................................ +} // namespace svx +//........................................................................ + +#endif -- cgit From 346d0a2a7644c54da29338df9102cbbc027aa20a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 30 Oct 2009 12:03:32 +0100 Subject: removed the ConfirmDeleteDialog - its functionality is nowadays available via the usual sdb.InteractionHandler --- svx/source/form/confirmdelete.cxx | 135 ------------------------------------- svx/source/form/fmstring.src | 2 +- svx/source/form/formcontroller.cxx | 57 ++++++++++++---- svx/source/form/makefile.mk | 1 - svx/source/inc/confirmdelete.hxx | 59 ---------------- 5 files changed, 45 insertions(+), 209 deletions(-) delete mode 100644 svx/source/form/confirmdelete.cxx delete mode 100644 svx/source/inc/confirmdelete.hxx diff --git a/svx/source/form/confirmdelete.cxx b/svx/source/form/confirmdelete.cxx deleted file mode 100644 index 9bb4ab7ede49..000000000000 --- a/svx/source/form/confirmdelete.cxx +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" -#include "confirmdelete.hxx" -#include -#ifndef _SVX_FMHELP_HRC -#include "fmhelp.hrc" -#endif -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif -#include -#include - -//........................................................................ -namespace svxform -{ -//........................................................................ - -#define BORDER_HEIGHT 6 // default distance control-dialog -#define BORDER_WIDTH 6 // default distance control-dialog - - using namespace ::com::sun::star::uno; - - //==================================================================== - //= class ConfirmDeleteDialog - //==================================================================== - //------------------------------------------------------------------------------ - ConfirmDeleteDialog::ConfirmDeleteDialog(Window* pParent, const String& _rTitle) - :ButtonDialog(pParent, WB_HORZ | WB_STDDIALOG) - ,m_aInfoImage (this) - ,m_aTitle (this, WB_WORDBREAK | WB_LEFT) - ,m_aMessage (this, WB_WORDBREAK | WB_LEFT) - { - String sMessage(SVX_RES(RID_STR_DELETECONFIRM)); - - // Changed as per BugID 79541 Branding/Configuration - Any aProductName = ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME); - ::rtl::OUString sProductName; - aProductName >>= sProductName; - - String aTitle = sProductName; - aProductName = ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTVERSION); - aProductName >>= sProductName; - aTitle.AppendAscii(" "); - aTitle += String(sProductName); - SetText(aTitle); - - SetHelpId(HID_DLG_DBMSG); - SetSizePixel(LogicToPixel(Size(220, 30),MAP_APPFONT)); - - m_aInfoImage.SetPosSizePixel(LogicToPixel(Point(6, 6),MAP_APPFONT), - LogicToPixel(Size(20, 20),MAP_APPFONT)); - m_aInfoImage.Show(); - - m_aTitle.SetPosSizePixel(LogicToPixel(Point(45, 6),MAP_APPFONT), - LogicToPixel(Size(169, 20),MAP_APPFONT)); - - Font aFont = m_aTitle.GetFont(); - aFont.SetWeight(WEIGHT_SEMIBOLD); - m_aTitle.SetFont(aFont); - m_aTitle.Show(); - - m_aMessage.SetPosSizePixel(LogicToPixel(Point(45, 29),MAP_APPFONT), - LogicToPixel(Size(169, 1),MAP_APPFONT)); - m_aMessage.Show(); - - // Image festlegen - m_aInfoImage.SetImage(WarningBox::GetStandardImage()); - - // Title setzen - m_aTitle.SetText(_rTitle); - - // Ermitteln der Hoehe des Textfeldes und des Dialogs - Size aBorderSize = LogicToPixel(Size(BORDER_WIDTH, BORDER_HEIGHT),MAP_APPFONT); - Rectangle aDlgRect(GetPosPixel(),GetSizePixel()); - Rectangle aMessageRect(m_aMessage.GetPosPixel(),m_aMessage.GetSizePixel()); - Rectangle aTextRect = - GetTextRect(aMessageRect, sMessage, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT); - - long nHText = aTextRect.Bottom() > aMessageRect.Bottom() ? aTextRect.Bottom() - aMessageRect.Bottom() : 0; - - aDlgRect.Bottom() += nHText + 2 * aBorderSize.Height(); - aMessageRect.Bottom() += nHText; - - // Dialog anpassen - SetSizePixel(aDlgRect.GetSize()); - SetPageSizePixel(aDlgRect.GetSize()); - - // Message Text anpassen und setzen - m_aMessage.SetSizePixel(aMessageRect.GetSize()); - m_aMessage.SetText(sMessage); - - // Buttons anlegen - AddButton(BUTTON_YES, BUTTONID_YES, 0); - AddButton(BUTTON_NO, BUTTONID_NO, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON); - } - - //------------------------------------------------------------------------------ - ConfirmDeleteDialog::~ConfirmDeleteDialog() - { - } - -//........................................................................ -} // namespace svxform -//........................................................................ - - - diff --git a/svx/source/form/fmstring.src b/svx/source/form/fmstring.src index 8b42ccadc6a6..da9b47de43cf 100644 --- a/svx/source/form/fmstring.src +++ b/svx/source/form/fmstring.src @@ -130,7 +130,7 @@ String RID_STR_DELETECONFIRM_RECORDS }; String RID_STR_DELETECONFIRM { - Text [ en-US ] = "If you click Yes, you won't be able to undo this operation!\nDo you want to continue anyway?"; + Text [ en-US ] = "If you click Yes, you won't be able to undo this operation.\nDo you want to continue anyway?"; }; String RID_ERR_NO_ELEMENT diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index bc50ee0de517..ed3e37c3812b 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "confirmdelete.hxx" #include "fmcontrolbordermanager.hxx" #include "fmcontrollayout.hxx" #include "formcontroller.hxx" @@ -202,6 +201,7 @@ namespace svxform using ::com::sun::star::task::XInteractionHandler; using ::com::sun::star::form::runtime::FormOperations; using ::com::sun::star::container::XContainer; + using ::com::sun::star::sdbc::SQLWarning; /** === end UNO using === **/ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -4033,22 +4033,53 @@ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) th aEvt.Source = *this; return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt); } + // default handling: instantiate an interaction handler and let it handle the request + + String sTitle; + sal_Int32 nLength = aEvent.Rows; + if ( nLength > 1 ) + { + sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORDS ); + sTitle.SearchAndReplace( '#', String::CreateFromInt32( nLength ) ); + } else + sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORD ); + + try { - // default handling - UniString aTitle; - sal_Int32 nLength = aEvent.Rows; - if (nLength > 1) - { - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORDS); - aTitle.SearchAndReplace('#', String::CreateFromInt32(nLength)); - } - else - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORD); + if ( !ensureInteractionHandler() ) + return sal_False; + + // two continuations allowed: Yes and No + OInteractionApprove* pApprove = new OInteractionApprove; + OInteractionDisapprove* pDisapprove = new OInteractionDisapprove; + + // the request + SQLWarning aWarning; + aWarning.Message = sTitle; + SQLWarning aDetails; + aDetails.Message = String( SVX_RES( RID_STR_DELETECONFIRM ) ); + aWarning.NextException <<= aDetails; - ConfirmDeleteDialog aDlg(getDialogParentWindow(), aTitle); - return RET_YES == aDlg.Execute(); + OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aWarning ) ); + Reference< XInteractionRequest > xRequest( pRequest ); + + // some knittings + pRequest->addContinuation( pApprove ); + pRequest->addContinuation( pDisapprove ); + + // handle the request + m_xInteractionHandler->handle( xRequest ); + + if ( pApprove->wasSelected() ) + return sal_True; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } + + return sal_False; } //------------------------------------------------------------------------------ diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk index 3c86a36c2685..71002531544c 100644 --- a/svx/source/form/makefile.mk +++ b/svx/source/form/makefile.mk @@ -65,7 +65,6 @@ LIB1OBJFILES= \ $(SLO)$/fmtextcontrolshell.obj \ $(SLO)$/ParseContext.obj \ $(SLO)$/typeconversionclient.obj \ - $(SLO)$/confirmdelete.obj \ $(SLO)$/dbtoolsclient.obj \ $(SLO)$/sqlparserclient.obj \ $(SLO)$/dataaccessdescriptor.obj \ diff --git a/svx/source/inc/confirmdelete.hxx b/svx/source/inc/confirmdelete.hxx deleted file mode 100644 index 049f60e08f02..000000000000 --- a/svx/source/inc/confirmdelete.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SVX_FORM_CONFIRMDELETE_HXX -#define SVX_FORM_CONFIRMDELETE_HXX - -#include -#include - -//........................................................................ -namespace svxform -{ -//........................................................................ - - //==================================================================== - //= class ConfirmDeleteDialog - //==================================================================== - class ConfirmDeleteDialog : public ButtonDialog - { - FixedImage m_aInfoImage; - FixedText m_aTitle; - FixedText m_aMessage; - - public: - ConfirmDeleteDialog(Window* pParent, const String& _rTitle); - ~ConfirmDeleteDialog(); - }; - -//........................................................................ -} // namespace svxform -//........................................................................ - -#endif // SVX_FORM_CONFIRMDELETE_HXX - - -- cgit From e39dac8cb3f4d98f6aab875f64672b1f502264a2 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 30 Oct 2009 13:12:29 +0100 Subject: cleaned up fmtools.?xx, so that only files which need it include it, and functions having 1 client only are moved to the client file --- svx/source/fmcomp/fmgridif.cxx | 13 +- svx/source/fmcomp/gridcols.cxx | 35 ++- svx/source/form/filtnav.cxx | 1 - svx/source/form/fmobj.cxx | 72 +++-- svx/source/form/fmobjfac.cxx | 1 - svx/source/form/fmpage.cxx | 1 - svx/source/form/fmshell.cxx | 1 - svx/source/form/fmshimp.cxx | 238 ++++++++++++++- svx/source/form/fmsrcimp.cxx | 1 - svx/source/form/fmtools.cxx | 564 ++++-------------------------------- svx/source/form/fmundo.cxx | 68 +++-- svx/source/form/fmview.cxx | 1 - svx/source/form/fmvwimp.cxx | 2 +- svx/source/form/formcontrolling.cxx | 2 +- svx/source/form/tabwin.cxx | 1 - svx/source/inc/filtnav.hxx | 1 - svx/source/inc/fmPropBrw.hxx | 4 +- svx/source/inc/fmexpl.hxx | 6 +- svx/source/inc/fmsrcimp.hxx | 17 +- svx/source/inc/fmtools.hxx | 52 +--- svx/source/inc/gridcell.hxx | 2 +- svx/source/inc/tabwin.hxx | 3 - 22 files changed, 460 insertions(+), 626 deletions(-) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 0bfc7c768973..c7e19499e70a 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -34,14 +34,15 @@ #include "fmgridif.hxx" #include "fmprop.hrc" #include "fmservs.hxx" -#include "fmtools.hxx" #include "fmurl.hxx" +#include "fmtools.hxx" #include "formcontrolfactory.hxx" #include "gridcell.hxx" #include "sdbdatacolumn.hxx" #include "svx/fmgridcl.hxx" #include "svx/svxids.hrc" +/** === begin UNO includes === **/ #include #include #include @@ -52,6 +53,8 @@ #include #include #include +#include +/** === end UNO includes === **/ #include #include @@ -1118,7 +1121,7 @@ namespace fmgridif { const ::rtl::OUString getDataModeIdentifier() { - static ::rtl::OUString s_sDataModeIdentifier = DATA_MODE; + static ::rtl::OUString s_sDataModeIdentifier = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); return s_sDataModeIdentifier; } } @@ -2457,7 +2460,7 @@ void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException m_aMode = Mode; FmGridControl* pGrid = (FmGridControl*) GetWindow(); - if (Mode == FILTER_MODE) + if ( Mode == ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ) pGrid->SetFilterMode(sal_True); else { @@ -2480,8 +2483,8 @@ void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException { aModes.realloc(2); ::rtl::OUString* pModes = aModes.getArray(); - pModes[0] = DATA_MODE; - pModes[1] = FILTER_MODE; + pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ); } return aModes; } diff --git a/svx/source/fmcomp/gridcols.cxx b/svx/source/fmcomp/gridcols.cxx index da7fe3447b0a..1fb7c69c9835 100644 --- a/svx/source/fmcomp/gridcols.cxx +++ b/svx/source/fmcomp/gridcols.cxx @@ -34,7 +34,8 @@ #include #include #include "fmservs.hxx" -#include "fmtools.hxx" + +using namespace ::com::sun::star::uno; //------------------------------------------------------------------------------ const ::comphelper::StringSequence& getColumnTypes() @@ -57,6 +58,36 @@ const ::comphelper::StringSequence& getColumnTypes() return aColumnTypes; } +//------------------------------------------------------------------ +// Vergleichen von PropertyInfo +extern "C" int +#if defined( WNT ) + __cdecl +#endif +#if defined( ICC ) && defined( OS2 ) +_Optlink +#endif + NameCompare(const void* pFirst, const void* pSecond) +{ + return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond); +} + +namespace +{ + //------------------------------------------------------------------------------ + sal_Int32 lcl_findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList) + { + const ::rtl::OUString* pStrList = rList.getConstArray(); + ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString), + &NameCompare); + + if (pResult) + return (pResult - pStrList); + else + return -1; + } +} + //------------------------------------------------------------------------------ sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName) { @@ -79,7 +110,7 @@ sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName) : aModelName.copy(aCompatibleModelPrefix.getLength()); const ::comphelper::StringSequence& rColumnTypes = getColumnTypes(); - nTypeId = findPos(aColumnType, rColumnTypes); + nTypeId = lcl_findPos(aColumnType, rColumnTypes); } return nTypeId; } diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 73b077068ac3..dec2f4c0d5a6 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index f2773b7350fa..e6ec36515e87 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -30,35 +30,35 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include -#include #include "fmobj.hxx" #include "fmprop.hrc" #include "fmvwimp.hxx" -#include -#include +#include "fmtools.hxx" +#include "fmpgeimp.hxx" +#include "fmresids.hrc" +#include "svx/fmview.hxx" +#include "svx/fmglob.hxx" +#include "svx/fmpage.hxx" +#include "svx/editeng.hxx" +#include "svx/svdovirt.hxx" +#include "svx/fmmodel.hxx" +#include "svx/dialmgr.hxx" /** === begin UNO includes === **/ #include #include #include #include +#include /** === end UNO includes === **/ -#include -#include "fmtools.hxx" -#include -#include -#include "fmresids.hrc" -#include -#include - -#include "fmpgeimp.hxx" -#include +#include #include #include #include #include +#include +#include using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; @@ -421,11 +421,49 @@ void FmFormObj::operator= (const SdrObject& rObj) } } +//------------------------------------------------------------------ +namespace +{ + String lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) + { + Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY); + Reference< ::com::sun::star::container::XIndexAccess> xParent; + if (xChild.is()) + xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); + + // while the current content is a form + String sReturn; + String sCurrentIndex; + while (xChild.is()) + { + // get the content's relative pos within it's parent container + sal_Int32 nPos = getElementPos(xParent, xChild); + + // prepend this current relaive pos + sCurrentIndex = String::CreateFromInt32(nPos); + if (sReturn.Len() != 0) + { + sCurrentIndex += '\\'; + sCurrentIndex += sReturn; + } + + sReturn = sCurrentIndex; + + // travel up + if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild)) + xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); + } + + _rTopLevelElement = xParent; + return sReturn; + } +} + //------------------------------------------------------------------ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _rTopLevelDestContainer) { Reference< XInterface > xTopLevelSouce; - String sAccessPath = getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); + String sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); if (!xTopLevelSouce.is()) // somthing went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy return Reference< XInterface > (); @@ -532,8 +570,8 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > DBG_ASSERT(xSourcePersist.is(), "FmFormObj::ensureModelEnv : invalid form (no persist object) !"); // create and insert (into the destination) a clone of the form - xCurrentDestForm = Reference< XPropertySet > (cloneUsingProperties(xSourcePersist), UNO_QUERY); - DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid cloned form !"); + Reference< XCloneable > xCloneable( xSourcePersist, UNO_QUERY_THROW ); + xCurrentDestForm.set( xCloneable->createClone(), UNO_QUERY_THROW ); DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !"); xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm)); diff --git a/svx/source/form/fmobjfac.cxx b/svx/source/form/fmobjfac.cxx index e2c9101b718c..0a8bfe1c7885 100644 --- a/svx/source/form/fmobjfac.cxx +++ b/svx/source/form/fmobjfac.cxx @@ -32,7 +32,6 @@ #include "precompiled_svx.hxx" #include #include -#include "fmtools.hxx" #include "fmservs.hxx" #ifndef _FM_FMOBJFAC_HXX diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index 0ead41eb87bc..69c04ff862bf 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -78,7 +78,6 @@ #include "fmprop.hrc" #endif #include "fmundo.hxx" -#include "fmtools.hxx" using namespace ::svxform; #endif #include diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index fff584964132..4820cf44978b 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -32,7 +32,6 @@ #include "precompiled_svx.hxx" #include "fmvwimp.hxx" #include -#include "fmtools.hxx" #include "fmservs.hxx" #ifndef _SVX_FMPROP_HRC #include "fmprop.hrc" diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 0f6894cb5ac8..228f99ace265 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -39,7 +39,6 @@ #include "fmservs.hxx" #include "fmshimp.hxx" #include "fmtextcontrolshell.hxx" -#include "fmtools.hxx" #include "fmundo.hxx" #include "fmurl.hxx" #include "fmvwimp.hxx" @@ -87,6 +86,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include @@ -110,6 +110,7 @@ #include #include #include +#include #include #include @@ -278,6 +279,7 @@ using namespace ::com::sun::star::view; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::script; using namespace ::svxform; using namespace ::svx; @@ -286,7 +288,7 @@ using namespace ::svx; //============================================================================== namespace { - //.................................................................... + //.......................................................................... void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces ) { _rInterfaces.clear(); @@ -324,6 +326,198 @@ namespace } } + //.......................................................................... + sal_Int16 GridView2ModelPos(const Reference< XIndexAccess>& rColumns, sal_Int16 nViewPos) + { + try + { + if (rColumns.is()) + { + // loop through all columns + sal_Int16 i; + Reference< XPropertySet> xCur; + for (i=0; igetCount(); ++i) + { + rColumns->getByIndex(i) >>= xCur; + if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN))) + { + // for every visible col : if nViewPos is greater zero, decrement it, else we + // have found the model position + if (!nViewPos) + break; + else + --nViewPos; + } + } + if (igetCount()) + return i; + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return (sal_Int16)-1; + } + + //.......................................................................... + Sequence< ::rtl::OUString> getEventMethods(const Type& type) + { + typelib_InterfaceTypeDescription *pType=0; + type.getDescription( (typelib_TypeDescription**)&pType); + + if(!pType) + return Sequence< ::rtl::OUString>(); + + Sequence< ::rtl::OUString> aNames(pType->nMembers); + ::rtl::OUString* pNames = aNames.getArray(); + for(sal_Int32 i=0;inMembers;i++,++pNames) + { + // the decription reference + typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i]; + // the description for the reference + typelib_TypeDescription* pMemberDescription = NULL; + typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference); + if (pMemberDescription) + { + typelib_InterfaceMemberTypeDescription* pRealMemberDescription = + reinterpret_cast(pMemberDescription); + *pNames = pRealMemberDescription->pMemberName; + } + } + typelib_typedescription_release( (typelib_TypeDescription *)pType ); + return aNames; + } + + //.......................................................................... + void TransferEventScripts(const Reference< XControlModel>& xModel, const Reference< XControl>& xControl, + const Sequence< ScriptEventDescriptor>& rTransferIfAvailable) + { + // first check if we have a XEventAttacherManager for the model + Reference< XChild> xModelChild(xModel, UNO_QUERY); + if (!xModelChild.is()) + return; // nothing to do + + Reference< XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY); + if (!xEventManager.is()) + return; // nothing to do + + if (!rTransferIfAvailable.getLength()) + return; // nothing to do + + // check for the index of the model within it's parent + Reference< XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY); + if (!xParentIndex.is()) + return; // nothing to do + sal_Int32 nIndex = getElementPos(xParentIndex, xModel); + if (nIndex<0 || nIndex>=xParentIndex->getCount()) + return; // nothing to do + + // then we need informations about the listeners supported by the control and the model + Sequence< Type> aModelListeners; + Sequence< Type> aControlListeners; + + Reference< XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); + Reference< XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); + + if (xModelIntrospection.is() && xModel.is()) + { + Any aModel(makeAny(xModel)); + aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners(); + } + + if (xControlIntrospection.is() && xControl.is()) + { + Any aControl(makeAny(xControl)); + aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners(); + } + + sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength(); + if (!nMaxNewLen) + return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos) + + Sequence< ScriptEventDescriptor> aTransferable(nMaxNewLen); + ScriptEventDescriptor* pTransferable = aTransferable.getArray(); + + const ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray(); + sal_Int32 i,j,k; + for (i=0; i* pCurrentArray = &aModelListeners; + pCurrentArray; + pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL + ) + { + const Type* pCurrentListeners = pCurrentArray->getConstArray(); + for (j=0; jgetLength(); ++j, ++pCurrentListeners) + { + UniString aListener = (*pCurrentListeners).getTypeName(); + xub_StrLen nTokens = aListener.GetTokenCount('.'); + if (nTokens) + aListener = aListener.GetToken(nTokens - 1, '.'); + + if (aListener == pCurrent->ListenerType.getStr()) + // the current ScriptEventDescriptor doesn't match the current listeners class + continue; + + // now check the methods + Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners); + const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray(); + for (k=0; kEventMethod) != COMPARE_EQUAL) + // the current ScriptEventDescriptor doesn't match the current listeners current method + continue; + + // we can transfer the script event : the model (control) supports it + *pTransferable = *pCurrent; + ++pTransferable; + break; + } + if (kregisterScriptEvents(nIndex, aTransferable); + } + + //------------------------------------------------------------------------------ + ::rtl::OUString getServiceNameByControlType(sal_Int16 nType) + { + switch (nType) + { + case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD; + case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON; + case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT; + case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX; + case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX; + case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON; + case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX; + case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX; + case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL; + case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON; + case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL; + case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD; + case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD; + case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD; + case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD; + case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD; + case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL; + case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL; + case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD; + case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR; + case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON; + case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR; + } + return ::rtl::OUString(); + } + } //------------------------------------------------------------------------------ @@ -4136,6 +4330,44 @@ IMPL_LINK( FmXFormShell, OnLoadForms, FmFormPage*, /*_pPage*/ ) return 0L; } +//------------------------------------------------------------------------------ +namespace +{ + sal_Bool lcl_isLoadable( const Reference< XInterface >& _rxLoadable ) + { + // determines whether a form should be loaded or not + // if there is no datasource or connection there is no reason to load a form + Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY ); + if ( !xSet.is() ) + return sal_False; + try + { + Reference< XConnection > xConn; + if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) ) + return sal_True; + + // is there already a active connection + xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn; + if ( xConn.is() ) + return sal_True; + + ::rtl::OUString sPropertyValue; + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue ); + if ( sPropertyValue.getLength() ) + return sal_True; + + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue ); + if ( sPropertyValue.getLength() ) + return sal_True; + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sal_False; + } +} + //------------------------------------------------------------------------ void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour /* FORMS_LOAD | FORMS_SYNC */ ) { @@ -4180,7 +4412,7 @@ void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour / { if ( 0 == ( _nBehaviour & FORMS_UNLOAD ) ) { - if ( ::isLoadable( xForm ) && !xForm->isLoaded() ) + if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() ) xForm->load(); } else diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index 3d1235624802..91384d3274d5 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -34,7 +34,6 @@ #ifndef _SVX_FMRESIDS_HRC #include "fmresids.hrc" #endif -#include "fmtools.hxx" #include "fmsrccfg.hxx" #include #include diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index 03dd6f97021d..c3df100cd873 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -30,83 +30,74 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include -#include -#include -#include -#include -#include + +#include "fmprop.hrc" +#include "fmservs.hxx" #include "fmtools.hxx" #include "svx/dbtoolsclient.hxx" -#include "fmservs.hxx" -#include -#include -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ -#include -#endif +#include "svx/fmglob.hxx" -#include -#include -#include -#include -#include +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include -#include +#include +#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +/** === end UNO includes === **/ -#include -#include #include -#include -#include - -#ifndef _SVX_FMPROP_HRC -#include "fmprop.hrc" -#endif -#include -#include -#include -#include -#include -#include #include -#include +#include #include +#include #include -#include +#include #include #include -#include +#include +#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -203,107 +194,9 @@ void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Windo displayException(_rEvent.Reason, _pParent); } -//------------------------------------------------------------------------------ -Reference< XInterface > cloneUsingProperties(const Reference< ::com::sun::star::io::XPersistObject>& _xObj) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::cloneUsingProperties" ); - if (!_xObj.is()) - return Reference< XInterface >(); - - // create a new object - ::rtl::OUString aObjectService = _xObj->getServiceName(); - Reference< ::com::sun::star::beans::XPropertySet> xDestSet(::comphelper::getProcessServiceFactory()->createInstance(aObjectService), UNO_QUERY); - if (!xDestSet.is()) - { - DBG_ERROR("cloneUsingProperties : could not instantiate an object of the given type !"); - return Reference< XInterface >(); - } - // transfer properties - Reference< XPropertySet > xSourceSet(_xObj, UNO_QUERY); - Reference< XPropertySetInfo > xSourceInfo( xSourceSet->getPropertySetInfo()); - Sequence< Property> aSourceProperties = xSourceInfo->getProperties(); - Reference< XPropertySetInfo > xDestInfo( xDestSet->getPropertySetInfo()); - Sequence< Property> aDestProperties = xDestInfo->getProperties(); - int nDestLen = aDestProperties.getLength(); - - Property* pSourceProps = aSourceProperties.getArray(); - Property* pSourceEnd = pSourceProps + aSourceProperties.getLength(); - Property* pDestProps = aDestProperties.getArray(); - - for (; pSourceProps != pSourceEnd; ++pSourceProps) - { - ::com::sun::star::beans::Property* pResult = ::std::lower_bound( - pDestProps, - pDestProps + nDestLen, - pSourceProps->Name, - ::comphelper::PropertyStringLessFunctor() - ); - - if ( ( pResult != pDestProps + nDestLen ) - && ( pResult->Name == pSourceProps->Name ) - && ( pResult->Attributes == pSourceProps->Attributes ) - && ( (pResult->Attributes & PropertyAttribute::READONLY ) == 0 ) - && ( pResult->Type.equals( pSourceProps->Type ) ) - ) - { // Attribute/type are the same and the prop isn't readonly - try - { - xDestSet->setPropertyValue(pResult->Name, xSourceSet->getPropertyValue(pResult->Name)); - } - catch(IllegalArgumentException e) - { - (void)e; -#ifdef DBG_UTIL - ::rtl::OString sMessage("cloneUsingProperties : could not transfer the value for property \""); - sMessage = sMessage + ::rtl::OString(pResult->Name.getStr(), pResult->Name.getLength(), RTL_TEXTENCODING_ASCII_US); - sMessage = sMessage + '\"'; - DBG_ERROR(sMessage); -#endif - } - - } - } - - return xDestSet.get(); -} - -//------------------------------------------------------------------------------ -sal_Bool searchElement(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::searchElement" ); - if (!xCont.is() || !xElement.is()) - return sal_False; - - sal_Int32 nCount = xCont->getCount(); - Reference< XInterface > xComp; - for (sal_Int32 i = 0; i < nCount; i++) - { - try - { - xCont->getByIndex(i) >>= xComp; - if (xComp.is()) - { - if ( xElement == xComp ) - return sal_True; - else - { - Reference< ::com::sun::star::container::XIndexAccess> xCont2(xComp, UNO_QUERY); - if (xCont2.is() && searchElement(xCont2, xElement)) - return sal_True; - } - } - } - catch(Exception&) - { - } - } - return sal_False; -} - //------------------------------------------------------------------------------ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementPos" ); sal_Int32 nIndex = -1; if (!xCont.is()) return nIndex; @@ -335,127 +228,6 @@ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAcce return nIndex; } -//------------------------------------------------------------------ -String getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getFormComponentAccessPath" ); - Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY); - Reference< ::com::sun::star::container::XIndexAccess> xParent; - if (xChild.is()) - xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); - - // while the current content is a form - String sReturn; - String sCurrentIndex; - while (xChild.is()) - { - // get the content's relative pos within it's parent container - sal_Int32 nPos = getElementPos(xParent, xChild); - - // prepend this current relaive pos - sCurrentIndex = String::CreateFromInt32(nPos); - if (sReturn.Len() != 0) - { - sCurrentIndex += '\\'; - sCurrentIndex += sReturn; - } - - sReturn = sCurrentIndex; - - // travel up - if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild)) - xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); - } - - _rTopLevelElement = xParent; - return sReturn; -} - -//------------------------------------------------------------------ -String getFormComponentAccessPath(const Reference< XInterface >& _xElement) -{ - Reference< XInterface > xDummy; - return getFormComponentAccessPath(_xElement, xDummy); -} - -//------------------------------------------------------------------------------ -Reference< XInterface > getElementFromAccessPath(const Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementFromAccessPath" ); - if (!_xParent.is()) - return Reference< XInterface >(); - Reference< ::com::sun::star::container::XIndexAccess> xContainer(_xParent); - Reference< XInterface > xElement( _xParent); - - String sPath(_rRelativePath); - while (sPath.Len() && xContainer.is()) - { - xub_StrLen nSepPos = sPath.Search((sal_Unicode)'\\'); - - String sIndex(sPath.Copy(0, (nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos)); - // DBG_ASSERT(sIndex.IsNumeric(), "getElementFromAccessPath : invalid path !"); - - sPath = sPath.Copy((nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos+1); - - ::cppu::extractInterface(xElement, xContainer->getByIndex(sIndex.ToInt32())); - xContainer = Reference< ::com::sun::star::container::XIndexAccess>::query(xElement); - } - - if (sPath.Len() != 0) - // the loop terminated because an element wasn't a container, but we stil have a path -> the path is invalid - xElement = NULL; - - return xElement; -} - -//------------------------------------------------------------------ -// Vergleichen von PropertyInfo -extern "C" int -#if defined( WNT ) - __cdecl -#endif -#if defined( ICC ) && defined( OS2 ) -_Optlink -#endif - NameCompare(const void* pFirst, const void* pSecond) -{ - return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond); -} - -//------------------------------------------------------------------------------ -sal_Int32 findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::findPos" ); - const ::rtl::OUString* pStrList = rList.getConstArray(); - ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString), - &NameCompare); - - if (pResult) - return (pResult - pStrList); - else - return -1; -} - -//------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XModel> getXModel(const Reference< XInterface >& xIface) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getXModel" ); - Reference< ::com::sun::star::frame::XModel> xModel(xIface, UNO_QUERY); - if (xModel.is()) - return xModel; - else - { - Reference< ::com::sun::star::container::XChild> xChild(xIface, UNO_QUERY); - if (xChild.is()) - { - Reference< XInterface > xParent( xChild->getParent()); - return getXModel(xParent); - } - else - return NULL; - } -} - //------------------------------------------------------------------ ::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel) { @@ -689,242 +461,6 @@ sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServi return OBJ_FM_CONTROL; } -//------------------------------------------------------------------------------ -::rtl::OUString getServiceNameByControlType(sal_Int16 nType) -{ - switch (nType) - { - case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD; - case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON; - case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT; - case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX; - case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX; - case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON; - case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX; - case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX; - case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL; - case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON; - case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL; - case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD; - case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD; - case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD; - case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD; - case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD; - case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL; - case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL; - case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD; - case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR; - case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON; - case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR; - } - return ::rtl::OUString(); -} -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> getEventMethods(const Type& type) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getEventMethods" ); - typelib_InterfaceTypeDescription *pType=0; - type.getDescription( (typelib_TypeDescription**)&pType); - - if(!pType) - return Sequence< ::rtl::OUString>(); - - Sequence< ::rtl::OUString> aNames(pType->nMembers); - ::rtl::OUString* pNames = aNames.getArray(); - for(sal_Int32 i=0;inMembers;i++,++pNames) - { - // the decription reference - typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i]; - // the description for the reference - typelib_TypeDescription* pMemberDescription = NULL; - typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference); - if (pMemberDescription) - { - typelib_InterfaceMemberTypeDescription* pRealMemberDescription = - reinterpret_cast(pMemberDescription); - *pNames = pRealMemberDescription->pMemberName; - } - } - typelib_typedescription_release( (typelib_TypeDescription *)pType ); - return aNames; -} - - -//------------------------------------------------------------------------------ -void TransferEventScripts(const Reference< ::com::sun::star::awt::XControlModel>& xModel, const Reference< ::com::sun::star::awt::XControl>& xControl, - const Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::TransferEventScripts" ); - // first check if we have a XEventAttacherManager for the model - Reference< ::com::sun::star::container::XChild> xModelChild(xModel, UNO_QUERY); - if (!xModelChild.is()) - return; // nothing to do - - Reference< ::com::sun::star::script::XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY); - if (!xEventManager.is()) - return; // nothing to do - - if (!rTransferIfAvailable.getLength()) - return; // nothing to do - - // check for the index of the model within it's parent - Reference< ::com::sun::star::container::XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY); - if (!xParentIndex.is()) - return; // nothing to do - sal_Int32 nIndex = getElementPos(xParentIndex, xModel); - if (nIndex<0 || nIndex>=xParentIndex->getCount()) - return; // nothing to do - - // then we need informations about the listeners supported by the control and the model - Sequence< Type> aModelListeners; - Sequence< Type> aControlListeners; - - Reference< ::com::sun::star::beans::XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); - Reference< ::com::sun::star::beans::XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); - - if (xModelIntrospection.is() && xModel.is()) - { - Any aModel(makeAny(xModel)); - aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners(); - } - - if (xControlIntrospection.is() && xControl.is()) - { - Any aControl(makeAny(xControl)); - aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners(); - } - - sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength(); - if (!nMaxNewLen) - return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos) - - Sequence< ::com::sun::star::script::ScriptEventDescriptor> aTransferable(nMaxNewLen); - ::com::sun::star::script::ScriptEventDescriptor* pTransferable = aTransferable.getArray(); - - const ::com::sun::star::script::ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray(); - sal_Int32 i,j,k; - for (i=0; i* pCurrentArray = &aModelListeners; - pCurrentArray; - pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL - ) - { - const Type* pCurrentListeners = pCurrentArray->getConstArray(); - for (j=0; jgetLength(); ++j, ++pCurrentListeners) - { - UniString aListener = (*pCurrentListeners).getTypeName(); - xub_StrLen nTokens = aListener.GetTokenCount('.'); - if (nTokens) - aListener = aListener.GetToken(nTokens - 1, '.'); - - if (aListener == pCurrent->ListenerType.getStr()) - // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners class - continue; - - // now check the methods - Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners); - const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray(); - for (k=0; kEventMethod) != COMPARE_EQUAL) - // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners current method - continue; - - // we can transfer the script event : the model (control) supports it - *pTransferable = *pCurrent; - ++pTransferable; - break; - } - if (kregisterScriptEvents(nIndex, aTransferable); -} - -//------------------------------------------------------------------------------ -sal_Int16 GridView2ModelPos(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::GridView2ModelPos" ); - try - { - if (rColumns.is()) - { - // loop through all columns - sal_Int16 i; - Reference< ::com::sun::star::beans::XPropertySet> xCur; - for (i=0; igetCount(); ++i) - { - rColumns->getByIndex(i) >>= xCur; - if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN))) - { - // for every visible col : if nViewPos is greater zero, decrement it, else we - // have found the model position - if (!nViewPos) - break; - else - --nViewPos; - } - } - if (igetCount()) - return i; - } - } - catch(const Exception&) - { - DBG_ERROR("GridView2ModelPos Exception occured!"); - } - return (sal_Int16)-1; -} - -//============================================================================== -//============================================================================== - -//------------------------------------------------------------------------------ -sal_Bool isLoadable( const Reference< XInterface >& _rxLoadable ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isLoadable" ); - // determines whether a form should be loaded or not - // if there is no datasource or connection there is no reason to load a form - Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY ); - if ( xSet.is() ) - { - try - { - Reference< XConnection > xConn; - if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) ) - return sal_True; - - // is there already a active connection - xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn; - if ( xConn.is() ) - return sal_True; - - ::rtl::OUString sPropertyValue; - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue ); - if ( sPropertyValue.getLength() ) - return sal_True; - - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue ); - if ( sPropertyValue.getLength() ) - return sal_True; - } - catch(Exception&) - { - DBG_ERROR( "isLoadable: caught an exception!" ); - } - - } - return sal_False; -} - //------------------------------------------------------------------------------ void setConnection(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const Reference< ::com::sun::star::sdbc::XConnection>& _rxConn) { diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index ed8a4a382ed3..3295d011f9ff 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -30,7 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" + #include "fmundo.hxx" +#include "fmtools.hxx" +#include "fmpgeimp.hxx" +#include "svx/dbtoolsclient.hxx" +#include "svditer.hxx" +#include "fmobj.hxx" +#include "fmprop.hrc" +#include "fmresids.hrc" +#include "svx/fmglob.hxx" +#include "svx/dialmgr.hxx" +#include "svx/fmmodel.hxx" +#include "svx/fmpage.hxx" /** === begin UNO includes === **/ #include @@ -43,18 +55,7 @@ #include /** === end UNO includes === **/ -#ifndef _FM_FMMODEL_HXX -#include -#endif -#include "fmtools.hxx" -#include -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif #include -#include -#include "fmpgeimp.hxx" -#include "svx/dbtoolsclient.hxx" #include #include #include @@ -63,13 +64,8 @@ #include #include #include -#include "svditer.hxx" -#include "fmobj.hxx" #include -#include -#ifndef _SVX_FMPROP_HRC -#include "fmprop.hrc" -#endif +#include #include #include #include @@ -299,6 +295,42 @@ void FmXUndoEnvironment::Inserted(SdrObject* pObj) } } +//------------------------------------------------------------------------------ +namespace +{ + sal_Bool lcl_searchElement(const Reference< XIndexAccess>& xCont, const Reference< XInterface >& xElement) + { + if (!xCont.is() || !xElement.is()) + return sal_False; + + sal_Int32 nCount = xCont->getCount(); + Reference< XInterface > xComp; + for (sal_Int32 i = 0; i < nCount; i++) + { + try + { + xCont->getByIndex(i) >>= xComp; + if (xComp.is()) + { + if ( xElement == xComp ) + return sal_True; + else + { + Reference< XIndexAccess> xCont2(xComp, UNO_QUERY); + if (xCont2.is() && lcl_searchElement(xCont2, xElement)) + return sal_True; + } + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + return sal_False; + } +} + //------------------------------------------------------------------------------ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) { @@ -325,7 +357,7 @@ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) Reference< XIndexContainer > xNewParent; Reference< XForm > xForm; sal_Int32 nPos = -1; - if ( searchElement( xForms, xObjectParent ) ) + if ( lcl_searchElement( xForms, xObjectParent ) ) { // the form which was the parent of the object when it was removed is still // part of the form component hierachy of the current page diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 1c16a092ad18..24029a98a393 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -61,7 +61,6 @@ #include #include #include "fmpgeimp.hxx" -#include "fmtools.hxx" #include "fmshimp.hxx" #include "fmservs.hxx" #include "fmprop.hrc" diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 829d9f6b61e8..fc4bbc62b58e 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -38,7 +38,6 @@ #include "fmresids.hrc" #include "fmservs.hxx" #include "fmshimp.hxx" -#include "fmtools.hxx" #include "fmundo.hxx" #include "fmvwimp.hxx" #include "formcontrolfactory.hxx" @@ -96,6 +95,7 @@ #include #include #include +#include #include #include diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index 5485763904ce..63f2ddf69d8e 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -33,7 +33,7 @@ #include "formcontrolling.hxx" #include "fmurl.hxx" -#include +#include "svx/svxids.hrc" #include "fmprop.hrc" #include "fmtools.hxx" diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx index 4ad118418981..39c246b99730 100644 --- a/svx/source/form/tabwin.cxx +++ b/svx/source/form/tabwin.cxx @@ -32,7 +32,6 @@ #include "precompiled_svx.hxx" #include "tabwin.hxx" -#include "fmtools.hxx" #include "fmservs.hxx" #include "stringlistresource.hxx" diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index f1ae1ed4398d..08db2e8ae7dc 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -48,7 +48,6 @@ #include #include #include -#include "fmtools.hxx" #include "fmexch.hxx" #include #include "fmexch.hxx" diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx index 285cb90320d2..fb970eb0a22f 100644 --- a/svx/source/inc/fmPropBrw.hxx +++ b/svx/source/inc/fmPropBrw.hxx @@ -30,6 +30,8 @@ #ifndef SVX_FMPROPBRW_HXX #define SVX_FMPROPBRW_HXX +#include "fmtools.hxx" + /** === begin UNO includes === **/ #include #include @@ -37,10 +39,10 @@ #include #include /** === end UNO includes === **/ + #include #include #include -#include "fmtools.hxx" //======================================================================== class FmPropBrwMgr : public SfxChildWindow diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx index df60ba931739..a03940fd510b 100644 --- a/svx/source/inc/fmexpl.hxx +++ b/svx/source/inc/fmexpl.hxx @@ -39,12 +39,17 @@ #include #include #include + +/** === begin UNO includes === **/ #include #include #include #include #include #include +#include +#include +/** === end UNO includes === **/ #include @@ -57,7 +62,6 @@ #include #include "fmexch.hxx" -#include "fmtools.hxx" class SdrObjListIter; class FmFormShell; diff --git a/svx/source/inc/fmsrcimp.hxx b/svx/source/inc/fmsrcimp.hxx index eb2475bc56e8..cfe38153c0ba 100644 --- a/svx/source/inc/fmsrcimp.hxx +++ b/svx/source/inc/fmsrcimp.hxx @@ -32,18 +32,27 @@ #define _FMSRCIMP_HXX #include "fmtools.hxx" -#include -#include -#include +#include "svx/svxdllapi.h" + +/** === begin UNO includes === **/ #include #include +#include #include #include +/** === end UNO includes === **/ + #include #include +#include #include #include -#include "svx/svxdllapi.h" +#include + +#ifndef _SVSTDARR_ULONGS +#define _SVSTDARR_ULONGS +#include +#endif // =================================================================================================== // Hilfsstrukturen diff --git a/svx/source/inc/fmtools.hxx b/svx/source/inc/fmtools.hxx index 9e9e892ef6cc..a456bed35bc6 100644 --- a/svx/source/inc/fmtools.hxx +++ b/svx/source/inc/fmtools.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmtools.hxx,v $ - * $Revision: 1.27 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,6 +27,9 @@ #ifndef _SVX_FMTOOLS_HXX #define _SVX_FMTOOLS_HXX +#include "fmprop.hrc" +#include "svx/svxdllapi.h" + #include #include #include @@ -65,36 +65,18 @@ #include #include #include -#include -#include - -#ifndef _SVSTDARR_ULONGS -#define _SVSTDARR_ULONGS -#include -#endif -#include -#include -#include -#include -#include - -#include "fmprop.hrc" #include #include #include #include #include #include -#include -#include -#include + +#include #include #include #include #include -#include - -#include #include @@ -111,21 +93,7 @@ SVX_DLLPUBLIC void displayException(const ::com::sun::star::sdb::SQLContext&, Wi void displayException(const ::com::sun::star::sdb::SQLErrorEvent&, Window* _pParent = NULL); void displayException(const ::com::sun::star::uno::Any&, Window* _pParent = NULL); -// Kopieren von Persistenten Objecten -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> cloneUsingProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>& _xObj); - -sal_Int32 findPos(const ::rtl::OUString& aStr, const ::com::sun::star::uno::Sequence< ::rtl::OUString>& rList); - -// Suchen in einer Indexliste nach einem Element -sal_Bool searchElement(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& xCont, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElement); - sal_Int32 getElementPos(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& xCont, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElement); -String getFormComponentAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xElement); -String getFormComponentAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xElement, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rTopLevelElement); -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> getElementFromAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath); - - -::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel> getXModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xIface); SVX_DLLPUBLIC ::rtl::OUString getLabelName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xControlModel); @@ -230,10 +198,8 @@ protected: void setAdapter(FmXDisposeMultiplexer* pAdapter); }; -typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> FmXDisposeMultiplexer_x; //============================================================================== - class FmXDisposeMultiplexer :public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> m_xObject; @@ -252,18 +218,10 @@ public: // ================================================================== -::rtl::OUString getServiceNameByControlType(sal_Int16 nType); - // get a service name to create a model of the given type (OBJ_FM_...) sal_Int16 getControlTypeByObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject); // get the object type (OBJ_FM_...) from the services the object supports -void TransferEventScripts(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xModel, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, - const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable); - -sal_Int16 GridView2ModelPos(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos); - //================================================================== -sal_Bool isLoadable(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xLoad); sal_Bool isRowSetAlive(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxRowSet); // checks if the ::com::sun::star::sdbcx::XColumnsSupplier provided by _rxRowSet supllies any columns diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index cb747e3a894c..b3792b76422c 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -35,7 +35,6 @@ #include "sqlparserclient.hxx" #include "typeconversionclient.hxx" -#include "fmtools.hxx" /** === begin UNO includes === **/ #include @@ -51,6 +50,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx index be46c05a58d5..02f58a507511 100644 --- a/svx/source/inc/tabwin.hxx +++ b/svx/source/inc/tabwin.hxx @@ -37,9 +37,6 @@ #include #include -//#ifndef _SVX_FMTOOLS_HXX -//#include "fmtools.hxx" -//#endif #include #include #include "svx/dbtoolsclient.hxx" -- cgit From 1e0bc426a966d9920714d0d3404ae32bdda9bdd7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 30 Oct 2009 14:48:55 +0100 Subject: #i10000# --- svx/source/fmcomp/fmgridcl.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index c210919bd09d..92f46cf4ad69 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -35,6 +35,7 @@ #include "fmgridif.hxx" #include "fmitems.hxx" #include "fmprop.hrc" +#include "fmtools.hxx" #include "fmresids.hrc" #include "fmservs.hxx" #include "fmurl.hxx" -- cgit From d61d0e53ae498f93afa7f0f4725232242e111b74 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 4 Nov 2009 10:26:31 +0100 Subject: moved complex.dbaccess.CRMDatabase.java to connectivity.tools, to be able to use it outside of dbaccess --- .../qa/connectivity/tools/CRMDatabase.java | 281 +++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 connectivity/qa/connectivity/tools/CRMDatabase.java diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java new file mode 100644 index 000000000000..7e5a737129f7 --- /dev/null +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -0,0 +1,281 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CRMDatabase.java,v $ + * $Revision: 1.6.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package connectivity.tools; + +import com.sun.star.container.ElementExistException; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.io.IOException; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XRefreshable; +import connectivity.tools.DataSource; +import connectivity.tools.HsqlColumnDescriptor; +import connectivity.tools.HsqlDatabase; +import connectivity.tools.HsqlTableDescriptor; +import connectivity.tools.QueryDefinition; + +/** implements a small Customer Relationship Management database + * + * Not finished, by far. Feel free to add features as you need them. + */ +public class CRMDatabase +{ + private static final String INTEGER = "INTEGER"; + private static final String VARCHAR50 = "VARCHAR(50)"; + private final XMultiServiceFactory m_orb; + private final HsqlDatabase m_database; + private final DataSource m_dataSource; + private final XConnection m_connection; + + /** constructs the CRM database + */ + public CRMDatabase( XMultiServiceFactory _orb ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb ); + m_dataSource = m_database.getDataSource(); + m_connection = m_database.defaultConnection(); + createTables(); + createQueries(); + } + + /** + * creates a CRMDatabase from an existing document, given by URL + * @param _orb + * @param _existingDocumentURL + * @throws Exceptio + */ + public CRMDatabase( XMultiServiceFactory _orb, final String _existingDocumentURL ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb, _existingDocumentURL ); + m_dataSource = m_database.getDataSource(); + m_connection = m_database.defaultConnection(); + } + + // -------------------------------------------------------------------------------------------------------- + /** returns the database document underlying the CRM database + */ + public final HsqlDatabase getDatabase() + { + return m_database; + } + + // -------------------------------------------------------------------------------------------------------- + /** returns the default connection to the database + */ + public final XConnection getConnection() + { + return m_connection; + } + + // -------------------------------------------------------------------------------------------------------- + public void saveAndClose() throws SQLException, IOException + { + getDocumentUI().closeSubComponents(); + m_database.store(); + m_database.closeAndDelete(); + } + + // -------------------------------------------------------------------------------------------------------- + public XDatabaseDocumentUI getDocumentUI() + { + XModel docModel = UnoRuntime.queryInterface( XModel.class, m_database.getDatabaseDocument() ); + return UnoRuntime.queryInterface( XDatabaseDocumentUI.class, docModel.getCurrentController() ); + } + + // -------------------------------------------------------------------------------------------------------- + public XController loadSubComponent( final int _objectType, final String _name ) throws IllegalArgumentException, SQLException, NoSuchElementException + { + XDatabaseDocumentUI docUI = getDocumentUI(); + if ( !docUI.isConnected() ) + docUI.connect(); + + XComponent subComponent = docUI.loadComponent( _objectType, _name, false ); + XController controller = UnoRuntime.queryInterface( XController.class, subComponent ); + if ( controller != null ) + return controller; + XModel document = UnoRuntime.queryInterface( XModel.class, subComponent ); + return document.getCurrentController(); + } + + // -------------------------------------------------------------------------------------------------------- + private void createTables() throws SQLException + { + HsqlTableDescriptor table = new HsqlTableDescriptor( "categories", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ), + new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 1, 'Food' )" ); + m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 2, 'Furniture' )" ); + + table = new HsqlTableDescriptor( "products", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "CategoryID",INTEGER, HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 1, 'Oranges', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 2, 'Apples', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 3, 'Pears', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 4, 'Strawberries', 1 )" ); + + table = new HsqlTableDescriptor( "customers", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "Address",VARCHAR50), + new HsqlColumnDescriptor( "City",VARCHAR50), + new HsqlColumnDescriptor( "Postal",VARCHAR50), + new HsqlColumnDescriptor( "Comment","LONGVARCHAR")} ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(1,'Food, Inc.','Down Under','Melbourne','509','Prefered') " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518',null) " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107',null) " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021','Good one.') " ); + + table = new HsqlTableDescriptor( "orders", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "CustomerID",INTEGER, HsqlColumnDescriptor.REQUIRED, "customers", "ID" ), + new HsqlColumnDescriptor( "OrderDate", "DATE" ), + new HsqlColumnDescriptor( "ShipDate", "DATE" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"orders\" (\"ID\", \"CustomerID\", \"OrderDate\") VALUES(1, 1, {D '2009-01-01'})" ); + m_database.executeSQL( "INSERT INTO \"orders\" VALUES(2, 2, {D '2009-01-01'}, {D '2009-01-23'})" ); + + table = new HsqlTableDescriptor( "orders_details", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "OrderID",INTEGER, HsqlColumnDescriptor.PRIMARY, "orders", "ID" ), + new HsqlColumnDescriptor( "ProductID",INTEGER, HsqlColumnDescriptor.PRIMARY, "products", "ID" ), + new HsqlColumnDescriptor( "Quantity",INTEGER) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 1, 100)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 2, 100)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 2, 2000)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 3, 2000)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 4, 2000)" ); + + // since we created the tables by directly executing the SQL statements, we need to refresh + // the tables container + final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_connection ); + final XRefreshable refreshTables = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() ); + refreshTables.refresh(); + } + + // -------------------------------------------------------------------------------------------------------- + private void validateUnparseable() + { + // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query) + XSingleSelectQueryComposer composer; + QueryDefinition unparseableQuery; + try + { + final XMultiServiceFactory factory = UnoRuntime.queryInterface( + XMultiServiceFactory.class, m_database.defaultConnection() ); + composer = UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) ); + unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" ); + } + catch( Exception e ) + { + throw new RuntimeException( "caught an unexpected exception: " + e.getMessage() ); + } + + boolean caughtExpected = false; + try + { + composer.setQuery( unparseableQuery.getCommand() ); + } + catch (WrappedTargetException e) { } + catch( SQLException e ) + { + caughtExpected = true; + } + + if ( !caughtExpected ) + throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" ); + } + + // -------------------------------------------------------------------------------------------------------- + private void createQueries() throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException + { + m_database.getDataSource().createQuery( + "all orders", + "SELECT \"orders\".\"ID\" AS \"Order No.\", " + + "\"customers\".\"Name\" AS \"Customer Name\", " + + "\"orders\".\"OrderDate\" AS \"Order Date\", " + + "\"orders\".\"ShipDate\" AS \"Ship Date\", " + + "\"orders_details\".\"Quantity\", " + + "\"products\".\"Name\" AS \"Product Name\" " + + "FROM \"orders_details\" AS \"orders_details\", " + + "\"orders\" AS \"orders\", " + + "\"products\" AS \"products\", " + + "\"customers\" AS \"customers\" " + + "WHERE ( \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + "AND \"orders\".\"CustomerID\" = \"customers\".\"ID\" )" + ); + + m_database.getDataSource().createQuery( + "unshipped orders", + "SELECT * " + + "FROM \"all orders\"" + + "WHERE ( \"ShipDate\" IS NULL )" + ); + + m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" ); + m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false ); + m_database.getDataSource().createQuery( "unparseable", + "SELECT CAST( \"ID\" AS VARCHAR(3) ) AS \"ID_VARCHAR\" FROM \"products\"", false ); + + validateUnparseable(); + } +} -- cgit From c20822e212d940e415f32a8d7beb873bd3c714ef Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 4 Nov 2009 14:47:25 +0100 Subject: when loading the document, pass a PickListEntry=false argument --- .../qa/connectivity/tools/CRMDatabase.java | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java index 7e5a737129f7..e3fa60afa763 100644 --- a/connectivity/qa/connectivity/tools/CRMDatabase.java +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -29,8 +29,11 @@ ************************************************************************/ package connectivity.tools; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyState; import com.sun.star.container.ElementExistException; import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XController; import com.sun.star.frame.XModel; import com.sun.star.io.IOException; @@ -45,11 +48,6 @@ import com.sun.star.sdbc.XConnection; import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XRefreshable; -import connectivity.tools.DataSource; -import connectivity.tools.HsqlColumnDescriptor; -import connectivity.tools.HsqlDatabase; -import connectivity.tools.HsqlTableDescriptor; -import connectivity.tools.QueryDefinition; /** implements a small Customer Relationship Management database * @@ -66,13 +64,29 @@ public class CRMDatabase /** constructs the CRM database */ - public CRMDatabase( XMultiServiceFactory _orb ) throws Exception + public CRMDatabase( XMultiServiceFactory _orb, boolean _withUI ) throws Exception { m_orb = _orb; m_database = new HsqlDatabase( m_orb ); m_dataSource = m_database.getDataSource(); - m_connection = m_database.defaultConnection(); + + if ( _withUI ) + { + final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class, + m_orb.createInstance( "com.sun.star.frame.Desktop" ) ); + PropertyValue[] loadArgs = new PropertyValue[] { + new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + }; + loader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", 0, loadArgs ); + getDocumentUI().connect(); + m_connection = getDocumentUI().getActiveConnection(); + } + else + { + m_connection = m_database.defaultConnection(); + } + createTables(); createQueries(); } -- cgit From be4e334c516d3d5ceb4971dfe3225a23ee3fc462 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 5 Nov 2009 10:41:12 +0100 Subject: setColumns does a lot VCL stuff ... lock the SolarMutex --- svx/source/fmcomp/fmgridif.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index c7e19499e70a..3108a545d510 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1727,6 +1727,8 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol) //------------------------------------------------------------------------------ void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw( RuntimeException ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() ); if (m_xColumns.is()) -- cgit From a1b3bf8427d5535ca98106809b6fd90010d828e3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 5 Nov 2009 12:18:02 +0100 Subject: during #i100764#: added diagnostics (assertions) --- scripting/source/dlgprov/dlgevtatt.cxx | 88 ++++++++++++++-------------------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 6a6b6dbbbb4a..097525bd372e 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -32,14 +32,13 @@ #include "precompiled_scripting.hxx" #include "dlgevtatt.hxx" -#ifndef SCRIPTING_DLGPROV_HXX #include "dlgprov.hxx" -#endif + #include #include -#ifndef _MSGBOX_HXX //autogen #include -#endif +#include + #include #include #include @@ -53,6 +52,7 @@ #include #include #include + #ifdef FAKE_VBA_EVENT_SUPPORT #include #endif @@ -134,7 +134,10 @@ namespace dlgprov { xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName; } - catch ( Exception& ) {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } @@ -149,7 +152,10 @@ namespace dlgprov { mxListener->firing( aScriptEventCopy ); } - catch( Exception& ) {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } #endif @@ -248,17 +254,9 @@ namespace dlgprov if ( xListener_.is() ) bSuccess = true; } - catch ( IllegalArgumentException& ) - { - } - catch ( IntrospectionException& ) - { - } - catch ( CannotCreateAdapterException& ) - { - } - catch ( ServiceNotRegisteredException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } try @@ -271,17 +269,9 @@ namespace dlgprov aDesc.AddListenerParam, aDesc.EventMethod ); } } - catch( IllegalArgumentException& ) - { - } - catch( IntrospectionException& ) - { - } - catch( CannotCreateAdapterException& ) - { - } - catch( ServiceNotRegisteredException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } } @@ -495,15 +485,9 @@ namespace dlgprov } } } - catch ( RuntimeException& e ) - { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught RuntimeException reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - } - catch ( Exception& e ) + catch ( const Exception& ) { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught Exception reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -512,21 +496,21 @@ namespace dlgprov ::rtl::OUString sScriptURL; ::rtl::OUString sScriptCode( aScriptEvent.ScriptCode ); - if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) - { - // StarBasic script: convert ScriptCode to scriptURL - sal_Int32 nIndex = sScriptCode.indexOf( ':' ); - if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) { - sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); - sScriptURL += sScriptCode.copy( nIndex + 1 ); - sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); - sScriptURL += sScriptCode.copy( 0, nIndex ); + // StarBasic script: convert ScriptCode to scriptURL + sal_Int32 nIndex = sScriptCode.indexOf( ':' ); + if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + { + sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); + sScriptURL += sScriptCode.copy( nIndex + 1 ); + sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); + sScriptURL += sScriptCode.copy( 0, nIndex ); + } + ScriptEvent aSFScriptEvent( aScriptEvent ); + aSFScriptEvent.ScriptCode = sScriptURL; + DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); } - ScriptEvent aSFScriptEvent( aScriptEvent ); - aSFScriptEvent.ScriptCode = sScriptURL; - DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); - } } void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) @@ -603,12 +587,10 @@ namespace dlgprov bHandled = true; } } - catch( com::sun::star::lang::IllegalArgumentException& ) - {} - catch( com::sun::star::lang::NoSuchMethodException& ) - {} - catch( com::sun::star::reflection::InvocationTargetException& ) - {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } if( bHandled ) -- cgit From f175a7d39cff877b636a3b32d447a02bb024d53e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 5 Nov 2009 12:18:28 +0100 Subject: way too many traces here --- connectivity/source/parse/sqlbison.y | 3 --- 1 file changed, 3 deletions(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 97875dfd4de0..55d6c4d1313d 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -107,7 +107,6 @@ static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID); } @@ -115,7 +114,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } @@ -123,7 +121,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } -- cgit From 616109598f7fe5c271fa93030e2758b0916b0b71 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 5 Nov 2009 14:30:27 +0100 Subject: during (writing a test case for) #i105235#: queryFieldData should also work on the insertion row --- svx/inc/svx/fmgridcl.hxx | 5 ---- svx/inc/svx/gridctrl.hxx | 7 +++-- svx/source/fmcomp/fmgridif.cxx | 64 ++++++++++++++++++++++-------------------- svx/source/fmcomp/gridctrl.cxx | 46 +++++++++++++++--------------- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/svx/inc/svx/fmgridcl.hxx b/svx/inc/svx/fmgridcl.hxx index f6b533513784..f8e04c4c405c 100644 --- a/svx/inc/svx/fmgridcl.hxx +++ b/svx/inc/svx/fmgridcl.hxx @@ -31,13 +31,8 @@ #define _SVX_FMGRIDCL_HXX #include - -#ifndef _COM_SUN_STAR_FORM_XINDEXCONTAINER_HPP_ -#include -#endif #include -// alles nur fuer stl #include #include #include "svx/svxdllapi.h" diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx index 632ca6ea0805..834ea17eaa1f 100644 --- a/svx/inc/svx/gridctrl.hxx +++ b/svx/inc/svx/gridctrl.hxx @@ -584,9 +584,10 @@ protected: sal_Int32 GetSeekPos() const {return m_nSeekPos;} sal_Int32 GetTotalCount() const {return m_nTotalCount;} - const DbGridRowRef& GetEmptyRow() const {return m_xEmptyRow;} - const DbGridRowRef& GetSeekRow() const {return m_xSeekRow;} - CursorWrapper* GetSeekCursor() const {return m_pSeekCursor;} + const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; } + const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; } + const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; } + CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; } void ConnectToFields(); void DisconnectFromFields(); diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 3108a545d510..ad3680391aa4 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -69,6 +69,7 @@ using namespace ::svxform; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::view; @@ -1393,8 +1394,8 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type // don't use GetCurrentRow as this isn't affected by the above SeekRow // FS - 30.09.99 - 68644 - DbGridRowRef aRow = pGrid->GetSeekRow(); - DBG_ASSERT(aRow.Is(), "FmXGridPeer::queryFieldData : invalid current Row !"); + DbGridRowRef xPaintRow = pGrid->GetPaintRow(); + ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" ); // die Columns des Controls brauche ich fuer GetFieldText DbGridColumns aColumns = pGrid->GetColumns(); @@ -1416,39 +1417,40 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type // don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow // FS - 30.09.99 - 68644 pCol = aColumns.GetObject(nModelPos); - const DbGridRowRef xRow = pGrid->GetSeekRow(); - xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > (); + xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() ) + ? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn() + : Reference< XColumn > (); - if (xFieldContent.is()) + if ( !xFieldContent.is() ) + continue; + + if (bRequestedAsAny) { - if (bRequestedAsAny) - { - Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY); - pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE); - } - else + Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY); + pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE); + } + else + { + switch (xType.getTypeClass()) { - switch (xType.getTypeClass()) + // Strings werden direkt ueber das GetFieldText abgehandelt + case TypeClass_STRING : { - // Strings werden direkt ueber das GetFieldText abgehandelt - case TypeClass_STRING : - { - String sText = aColumns.GetObject(nModelPos)->GetCellText(aRow, pGrid->getNumberFormatter()); - pReturnArray[i] <<= ::rtl::OUString(sText); - } - break; - // alles andere wird an der DatabaseVariant erfragt - case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break; - case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break; - case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break; - case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break; - case TypeClass_UNSIGNED_SHORT: pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break; - case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break; - case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break; - default: - { - throw IllegalArgumentException(); - } + String sText = aColumns.GetObject(nModelPos)->GetCellText( xPaintRow, pGrid->getNumberFormatter() ); + pReturnArray[i] <<= ::rtl::OUString(sText); + } + break; + // alles andere wird an der DatabaseVariant erfragt + case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break; + case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break; + case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break; + case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break; + case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break; + case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break; + case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break; + default: + { + throw IllegalArgumentException(); } } } diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index f53168a273ac..1988983a5f0c 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -868,7 +868,7 @@ void DbGridRow::SetState(CursorWrapper* pCur, sal_Bool bPaintCursor) } catch(SQLException&) { - OSL_ENSURE(0,"SQLException catched while getting the bookmark"); + DBG_UNHANDLED_EXCEPTION(); m_aBookmark = Any(); m_eStatus = GRS_INVALID; m_bIsNew = sal_False; @@ -1786,30 +1786,32 @@ void DbGridControl::ColumnMoved(sal_uInt16 nId) sal_Bool DbGridControl::SeekRow(long nRow) { // in filter mode or in insert only mode we don't have any cursor! - if (SeekCursor(nRow)) + if ( !SeekCursor( nRow ) ) + return sal_False; + + if ( IsFilterMode() ) { - if (m_pSeekCursor) - { - // on the current position we have to take the current row for display as we want - // to have the most recent values for display - if ((nRow == m_nCurrentPos) && getDisplaySynchron()) - m_xPaintRow = m_xCurrentRow; - // seek to the empty insert row - else if (IsInsertionRow(nRow)) - m_xPaintRow = m_xEmptyRow; - else - { - m_xSeekRow->SetState(m_pSeekCursor, sal_True); - m_xPaintRow = m_xSeekRow; - } - } - else if (IsFilterMode()) - { - DBG_ASSERT(IsFilterRow(nRow), "DbGridControl::SeekRow(): No filter row, wrong mode"); + DBG_ASSERT( IsFilterRow( nRow ), "DbGridControl::SeekRow(): No filter row, wrong mode" ); + m_xPaintRow = m_xEmptyRow; + } + else + { + // on the current position we have to take the current row for display as we want + // to have the most recent values for display + if ( ( nRow == m_nCurrentPos ) && getDisplaySynchron() ) + m_xPaintRow = m_xCurrentRow; + // seek to the empty insert row + else if ( IsInsertionRow( nRow ) ) m_xPaintRow = m_xEmptyRow; + else + { + m_xSeekRow->SetState( m_pSeekCursor, sal_True ); + m_xPaintRow = m_xSeekRow; } - DbGridControl_Base::SeekRow(nRow); } + + DbGridControl_Base::SeekRow(nRow); + return m_nSeekPos >= 0; } //------------------------------------------------------------------------------ @@ -2381,7 +2383,7 @@ sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute) // da der letzte Datensatz bereits erreicht wurde! if (nRow == m_nCurrentPos) { - // auf die aktuelle Zeile bewegt, dann mu� kein abgleich gemacht werden, wenn + // auf die aktuelle Zeile bewegt, dann muß kein abgleich gemacht werden, wenn // gerade ein Datensatz eingefuegt wird m_nSeekPos = nRow; } -- cgit From f949bcea10117e99c731831eae335bf1d6793d0a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 5 Nov 2009 14:31:55 +0100 Subject: when creating a new HsqlDatabase, make sure it does not appear in the pick list --- connectivity/qa/connectivity/tools/HsqlDatabase.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java index d27816cf4b7e..c34e78c640a4 100644 --- a/connectivity/qa/connectivity/tools/HsqlDatabase.java +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -30,6 +30,7 @@ package connectivity.tools; import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyState; import com.sun.star.beans.XPropertySet; import com.sun.star.container.ElementExistException; import com.sun.star.frame.XStorable; @@ -82,9 +83,9 @@ public class HsqlDatabase extends AbstractDatabase dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb"); final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument); - storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[] - { - }); + storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[] + { new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + } ); } /** drops the table with a given name -- cgit From deaf11fb65dc66a845577492687558b6cd43d9b0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 6 Nov 2009 10:20:12 +0100 Subject: #i100764# set the WB_EXT_DOCUMENT style at the backing component's container window, when creating it without the TaskCreator (which would normally do this) --- desktop/source/app/app.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index d4e0a91c1d17..ea5f7a955ac7 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1468,6 +1468,13 @@ void Desktop::Main() xContainerWindow = xBackingFrame->getContainerWindow(); if (xContainerWindow.is()) { + // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank" + // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior, + // otherwise documents loaded into this frame will later on miss functionality depending on the style. + Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" ); + pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); + SetSplashScreenProgress(75); Sequence< Any > lArgs(1); lArgs[0] <<= xContainerWindow; -- cgit From 4ce1ac5cb0ff25fca45fc0956e1a4bdfd156dc02 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 6 Nov 2009 11:53:18 +0100 Subject: SID_FM_* not needed anymore in the image list, since #i106671# is fixed --- svx/source/src/app.src | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/svx/source/src/app.src b/svx/source/src/app.src index 0e23ea3a8a38..e06e60db9e02 100644 --- a/svx/source/src/app.src +++ b/svx/source/src/app.src @@ -58,26 +58,9 @@ ErrorBox RID_ERRBOX_MODULENOTINSTALLED SID_HLINKBAR_SEARCH; \ SID_HLINKBAR_TARGET; \ SID_HYPERLINK_DIALOG; \ - SID_FM_RECORD_ABSOLUTE; \ - SID_FM_RECORD_FIRST; \ - SID_FM_RECORD_PREV; \ - SID_FM_RECORD_NEXT; \ - SID_FM_RECORD_LAST; \ - SID_FM_RECORD_SAVE; \ - SID_FM_RECORD_UNDO; \ - SID_FM_RECORD_NEW; \ - SID_FM_RECORD_DELETE; \ - SID_FM_REFRESH; \ - SID_FM_SORTUP; \ - SID_FM_SORTDOWN; \ - SID_FM_ORDERCRIT; \ - SID_FM_AUTOFILTER; \ - SID_FM_FILTERCRIT; \ - SID_FM_FORM_FILTERED; \ - SID_FM_REMOVE_FILTER_SORT; \ };\ IdCount = {\ - 21;\ + 4;\ }; ImageList RID_DEFAULTIMAGELIST_SC -- cgit From a3b7e5e8ac58e2f9bc3253ae78dafa395db6a58f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 6 Nov 2009 16:18:17 +0100 Subject: do not set DropDown property when it doesn't exist --- svx/source/form/formcontrolfactory.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index de1a7d76b526..18c07096914b 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -519,7 +519,8 @@ namespace svxform case FormComponentType::COMBOBOX: { sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() ); - _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); + if ( xPSI->hasPropertyByName( FM_PROP_DROPDOWN ) ) + _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); _rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) ); } break; -- cgit From 540920f1b130375207a5362105fb3afbcf3bac3b Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 12:32:55 +0100 Subject: #i102791# fix decimal for odbc --- .../source/drivers/odbcbase/OPreparedStatement.cxx | 37 +++++++++++++++------- connectivity/source/drivers/odbcbase/OTools.cxx | 3 +- .../source/inc/odbc/OPreparedStatement.hxx | 3 +- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 6e9d87e933ca..03d9912e4e22 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -343,9 +343,9 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType, case SQL_NUMERIC: ++nRealSize; break; - case SQL_BINARY: - case SQL_VARBINARY: - nRealSize=1; //dummy buffer, binary data isn't copied + case SQL_BINARY: + case SQL_VARBINARY: + nRealSize=1; //dummy buffer, binary data isn't copied break; default: break; @@ -474,15 +474,17 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s } // ------------------------------------------------------------------------- -void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) { - ::dbtools::throwFunctionNotSupportedException( "XParameters::setClob", *this ); + if ( x.is() ) + setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- -void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) { - ::dbtools::throwFunctionNotSupportedException( "XParameters::setBlob", *this ); + if ( x.is() ) + setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- @@ -497,7 +499,12 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Re ::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this ); } // ------------------------------------------------------------------------- - +void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x ) +{ + ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding())); + setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x); +} +// ------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) { checkDisposed(OStatement_BASE::rBHelper.bDisposed); @@ -522,6 +529,12 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c setNull(parameterIndex,sqlType); break; case DataType::DECIMAL: + { + ORowSetValue aValue; + aValue.fill(x); + setDecimal(parameterIndex,aValue); + } + break; case DataType::NUMERIC: { ORowSetValue aValue; @@ -569,13 +582,13 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - setStream (parameterIndex, x, length, DataType::LONGVARCHAR); + setStream(parameterIndex, x, length, DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - setStream (parameterIndex, x, length, DataType::LONGVARBINARY); + setStream(parameterIndex, x, length, DataType::LONGVARBINARY); } // ------------------------------------------------------------------------- @@ -834,10 +847,10 @@ sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType) // Sets an input stream as a parameter, using the given SQL type //-------------------------------------------------------------------- -void OPreparedStatement::setStream ( +void OPreparedStatement::setStream( sal_Int32 ParameterIndex, const Reference< XInputStream>& x, - sal_Int32 length, + SQLLEN length, sal_Int32 SQLtype) throw(SQLException) { diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index 3cadb33cf188..daa6d28a0acf 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -135,6 +135,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, { case SQL_CHAR: case SQL_VARCHAR: + case SQL_DECIMAL: if(_bUseWChar) { *pLen = SQL_NTS; @@ -160,7 +161,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, *pLen = sizeof(sal_Int64); _nColumnSize = *pLen; break; - case SQL_DECIMAL: + case SQL_NUMERIC: if(_bUseWChar) { diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx index 9e6f6ca8a61f..d167c9edb9a0 100644 --- a/connectivity/source/inc/odbc/OPreparedStatement.hxx +++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx @@ -89,7 +89,7 @@ namespace connectivity void FreeParams(); void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException); void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, - sal_Int32 length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException); + SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException); sal_Int32 getParamLength ( sal_Int32 index); sal_Int8* getLengthBuf (sal_Int32 index); sal_Int8* getDataBuf (sal_Int32 index); @@ -102,6 +102,7 @@ namespace connectivity sal_Bool isPrepared() const { return m_bPrepared;} void prepareStatement(); void checkParameterIndex(sal_Int32 _parameterIndex); + void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x ); /** creates the driver specific resultset (factory) -- cgit From 526304a928bb243bfb7b2eeeafbdc1757b3f81d2 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 12:38:41 +0100 Subject: #i105102# ignore currency --- connectivity/source/drivers/jdbc/jdbc.xcu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index 953e669906be..f5ac8f20db5c 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -179,7 +179,7 @@ - false + true -- cgit From e5f5288c1398967c7a14544a22504165698010dc Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 13:27:33 +0100 Subject: #i105086# fix for clob and blob --- connectivity/source/drivers/ado/AResultSet.cxx | 6 +- connectivity/source/drivers/ado/Aolevariant.cxx | 93 +++++++++++++++++++++- connectivity/source/drivers/ado/adoimp.cxx | 2 + connectivity/source/drivers/file/FStatement.cxx | 17 ++-- connectivity/source/drivers/jdbc/Boolean.cxx | 10 ++- .../source/drivers/jdbc/CallableStatement.cxx | 12 ++- connectivity/source/drivers/jdbc/Clob.cxx | 7 ++ connectivity/source/drivers/jdbc/JConnection.cxx | 9 +-- connectivity/source/drivers/jdbc/Object.cxx | 12 ++- .../source/drivers/jdbc/PreparedStatement.cxx | 7 +- connectivity/source/drivers/jdbc/ResultSet.cxx | 54 ++++++++++--- connectivity/source/drivers/jdbc/Timestamp.cxx | 14 +++- .../source/drivers/odbcbase/ODatabaseMetaData.cxx | 10 +-- .../source/drivers/odbcbase/OResultSet.cxx | 8 ++ 14 files changed, 203 insertions(+), 58 deletions(-) diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 1c53614bba04..8a5da6f94134 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -334,11 +334,9 @@ Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw } // ------------------------------------------------------------------------- -Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) { - - ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this ); - return Any(); + return getValue(columnIndex).makeAny(); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index 09596da61bd6..b1b8235da3d8 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -39,8 +39,17 @@ #include "diagnose_ex.h" #include "resource/sharedresources.hxx" #include "resource/ado_res.hrc" - +#include "com/sun/star/bridge/oleautomation/Date.hpp" +#include "com/sun/star/bridge/oleautomation/Currency.hpp" +#include "com/sun/star/bridge/oleautomation/SCode.hpp" +#include "com/sun/star/bridge/oleautomation/Decimal.hpp" + +using namespace com::sun::star::beans; +using namespace com::sun::star::uno; +using namespace com::sun::star::bridge::oleautomation; using namespace connectivity::ado; +using ::rtl::OUString; + OLEString::OLEString() :m_sStr(NULL) { @@ -698,6 +707,88 @@ SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const return V_ARRAY(&varDest); } // ----------------------------------------------------------------------------- +::com::sun::star::uno::Any OLEVariant::makeAny() const +{ + ::com::sun::star::uno::Any aValue; + switch (V_VT(this)) + { + case VT_EMPTY: + case VT_NULL: + aValue.setValue(NULL, Type()); + break; + case VT_I2: + aValue.setValue( & iVal, getCppuType( (sal_Int16*)0)); + break; + case VT_I4: + aValue.setValue( & lVal, getCppuType( (sal_Int32*)0)); + break; + case VT_R4: + aValue.setValue( & fltVal, getCppuType( (float*)0)); + break; + case VT_R8: + aValue.setValue(& dblVal, getCppuType( (double*)0)); + break; + case VT_CY: + { + Currency cy(cyVal.int64); + aValue <<= cy; + break; + } + case VT_DATE: + { + aValue <<= (::com::sun::star::util::Date)*this; + break; + } + case VT_BSTR: + { + OUString b(reinterpret_cast(bstrVal)); + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_BOOL: + { + sal_Bool b= boolVal == VARIANT_TRUE; + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_I1: + aValue.setValue( & cVal, getCppuType((sal_Int8*)0)); + break; + case VT_UI1: // there is no unsigned char in UNO + aValue.setValue( & bVal, getCppuType( (sal_Int8*)0)); + break; + case VT_UI2: + aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0)); + break; + case VT_UI4: + aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_INT: + aValue.setValue( & intVal, getCppuType( (sal_Int32*)0)); + break; + case VT_UINT: + aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_VOID: + aValue.setValue( NULL, Type()); + break; + case VT_DECIMAL: + { + Decimal dec; + dec.Scale = decVal.scale; + dec.Sign = decVal.sign; + dec.LowValue = decVal.Lo32; + dec.MiddleValue = decVal.Mid32; + dec.HighValue = decVal.Hi32; + aValue <<= dec; + break; + } + + default: + break; + } + return aValue; +} // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx index 188303a1ba50..e3412babfdf6 100644 --- a/connectivity/source/drivers/ado/adoimp.cxx +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -157,8 +157,10 @@ DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine) case DataType::BIT: return adBoolean; break; case DataType::BINARY: return adBinary; break; case DataType::VARCHAR: return adVarWChar; break; + case DataType::CLOB: case DataType::LONGVARCHAR: return adLongVarWChar; break; case DataType::VARBINARY: return adVarBinary; break; + case DataType::BLOB: case DataType::LONGVARBINARY: return adLongVarBinary; break; case DataType::CHAR: return adWChar; break; case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break; diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 07cdf95d7b44..6e583644e3b9 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -497,13 +497,16 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, // SELECT statement without columns -> error m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this); - if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_CREATE_TABLE ) - // CREATE TABLE is not supported at all - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_ODBC_CALL ) || ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_UNKNOWN ) ) - // ODBC call or unknown statement type -> error - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + switch(m_aSQLIterator.getStatementType()) + { + case SQL_STATEMENT_CREATE_TABLE: + case SQL_STATEMENT_ODBC_CALL: + case SQL_STATEMENT_UNKNOWN: + m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + break; + default: + break; + } // at this moment we support only one table per select statement Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY); diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx index cac868d4792f..d778487655d5 100644 --- a/connectivity/source/drivers/jdbc/Boolean.cxx +++ b/connectivity/source/drivers/jdbc/Boolean.cxx @@ -40,17 +40,19 @@ jclass java_lang_Boolean::theClass = 0; java_lang_Boolean::~java_lang_Boolean() {} - -jclass java_lang_Boolean::getMyClass() const +jclass java_lang_Boolean::st_getMyClass() { // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) - { theClass = findMyClass("java/lang/Boolean"); - } return theClass; } +jclass java_lang_Boolean::getMyClass() const +{ + return st_getMyClass(); +} + java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ) { SDBThreadAttach t; diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx index 8cea582940d3..e6209a90f236 100644 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -227,9 +227,8 @@ void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parame static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,typeName); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str); - t.pEnv->DeleteLocalRef(str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName)); + t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get()); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } } @@ -336,23 +335,22 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/) // Java-Call absetzen jobject out = NULL; // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,m_sSqlStatement); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement)); static jmethodID mID(NULL); if ( !mID ) mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); if( mID ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str ,m_nResultSetType,m_nResultSetConcurrency); + out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency); } //mID else { static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;"; static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!"); if( mID2 ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str ); + out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() ); } //mID } - t.pEnv->DeleteLocalRef(str); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); if ( out ) diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx index 632504448e06..ef64ca7b05e9 100644 --- a/connectivity/source/drivers/jdbc/Clob.cxx +++ b/connectivity/source/drivers/jdbc/Clob.cxx @@ -34,6 +34,8 @@ #include "java/tools.hxx" #include "java/io/Reader.hxx" #include +#include + using namespace connectivity; //************************************************************** //************ Class: java.sql.Clob @@ -61,6 +63,7 @@ jclass java_sql_Clob::getMyClass() const sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::length" ); jlong out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -79,6 +82,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx ::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getSubString" ); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); ::rtl::OUString aStr; { @@ -98,6 +102,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getCharacterStream" ); SDBThreadAttach t; static jmethodID mID(NULL); jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID); @@ -108,6 +113,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::position" ); jlong out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -130,6 +136,7 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sa sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::positionOfClob" ); ::dbtools::throwFeatureNotImplementedException( "XClob::positionOfClob", *this ); // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore // the pattern parameter. Since the effort for proper implementation is rather high - we would need diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index 96325511807f..f7bbe5ee258a 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -553,10 +553,9 @@ Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,sql); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,sql)); - jobject out = t.pEnv->CallObjectMethod( object, mID, str ); - t.pEnv->DeleteLocalRef(str); + jobject out = t.pEnv->CallObjectMethod( object, mID, str.get() ); aStr = JavaString2String(t.pEnv, (jstring)out ); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } //t.pEnv @@ -810,8 +809,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"; static const char * cMethodName = "connect"; // Java-Call absetzen - jmethodID mID = NULL; - if ( !mID ) + static jmethodID mID = NULL; + if ( !mID ) mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature ); if ( mID ) { diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 6f4e78550dc0..73829b46ec64 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -43,7 +43,7 @@ #include #include #include - +#include "java/LocalRef.hxx" #include "resource/jdbc_log.hrc" #include #include @@ -395,10 +395,9 @@ void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jm OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID); - jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID , str); - t.pEnv->DeleteLocalRef(str); + t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get()); ThrowSQLException( t.pEnv, NULL ); } // ------------------------------------------------------------------------- @@ -417,10 +416,9 @@ sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName // *this // ); - jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); // call method - jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str); - t.pEnv->DeleteLocalRef(str); + jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get()); ThrowSQLException( t.pEnv, NULL ); return (sal_Int32)out; } diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index dbf7241885da..ae43b40b3a0b 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -45,7 +45,7 @@ #include "resource/jdbc_log.hrc" #include "resource/common_res.hrc" #include "resource/sharedresources.hxx" - +#include "java/LocalRef.hxx" #include using namespace connectivity; @@ -138,10 +138,9 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c // Java-Call absetzen static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jstring str = convertwchar_tToJavaString(t.pEnv,x); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); + t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get()); // und aufraeumen - t.pEnv->DeleteLocalRef(str); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } //t.pEnv } diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 677985ac6a90..257aa6405eee 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -30,10 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" +#include "java/lang/String.hxx" +#include "java/lang/Boolean.hxx" #include "java/sql/ResultSet.hxx" #include "java/math/BigDecimal.hxx" #include "java/sql/JStatement.hxx" #include "java/sql/SQLWarning.hxx" +#include "java/sql/Timestamp.hxx" #include "java/sql/Array.hxx" #include "java/sql/Ref.hxx" #include "java/sql/Clob.hxx" @@ -54,6 +57,7 @@ #include "connectivity/dbexception.hxx" #include "resource/common_res.hrc" #include "resource/sharedresources.hxx" +#include "java/LocalRef.hxx" #include #include @@ -324,6 +328,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" ); jobject out(0); + Any aRet; SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); { jvalue args[2]; @@ -341,15 +346,43 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen obtainMethodId(t.pEnv, cMethodName,cSignature, mID); } - out = t.pEnv->CallObjectMethodA( object, mID, args); - t.pEnv->DeleteLocalRef((jstring)args[1].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - // und aufraeumen - + out = t.pEnv->CallObjectMethodA( object, mID, args); + t.pEnv->DeleteLocalRef((jstring)args[1].l); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + // und aufraeumen + if ( out ) + { + if ( t.pEnv->IsInstanceOf(out,java_lang_String::st_getMyClass()) ) + { + java_lang_String aVal(t.pEnv,out); + aRet <<= (::rtl::OUString)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_lang_Boolean::st_getMyClass()) ) + { + java_lang_Boolean aVal(t.pEnv,out); + static jmethodID methodID = NULL; + aRet <<= aVal.callBooleanMethod("booleanValue",methodID); + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Date::st_getMyClass()) ) + { + java_sql_Date aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::Date)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Time::st_getMyClass()) ) + { + java_sql_Time aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::Time)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Timestamp::st_getMyClass()) ) + { + java_sql_Timestamp aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::DateTime)aVal; + } + else + t.pEnv->DeleteLocalRef(out); + } } //t.pEnv - // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! - ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this ); - return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out ); + return aRet; } // ------------------------------------------------------------------------- @@ -689,9 +722,8 @@ void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::r { // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,x); - t.pEnv->CallVoidMethod( object, mID,columnIndex,str); - t.pEnv->DeleteLocalRef(str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); + t.pEnv->CallVoidMethod( object, mID,columnIndex,str.get()); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } } diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx index 8c30f7a14efc..065ffe11d3e7 100644 --- a/connectivity/source/drivers/jdbc/Timestamp.cxx +++ b/connectivity/source/drivers/jdbc/Timestamp.cxx @@ -70,6 +70,10 @@ java_sql_Date::~java_sql_Date() {} jclass java_sql_Date::getMyClass() const +{ + return st_getMyClass(); +} +jclass java_sql_Date::st_getMyClass() { // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) @@ -93,13 +97,16 @@ java_sql_Time::~java_sql_Time() {} jclass java_sql_Time::getMyClass() const +{ + return st_getMyClass(); +} +jclass java_sql_Time::st_getMyClass() { // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) theClass = findMyClass("java/sql/Time"); return theClass; } - java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL ) { SDBThreadAttach t; @@ -139,13 +146,16 @@ java_sql_Timestamp::~java_sql_Timestamp() {} jclass java_sql_Timestamp::getMyClass() const +{ + return st_getMyClass(); +} +jclass java_sql_Timestamp::st_getMyClass() { // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) theClass = findMyClass("java/sql/Timestamp"); return theClass; } - java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut) :java_util_Date( NULL, (jobject)NULL ) { diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx index b92206199c24..f923987cc04e 100644 --- a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx +++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx @@ -921,6 +921,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this); break; case DataType::LONGVARCHAR: + case DataType::CLOB: OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this); break; case DataType::DATE: @@ -939,6 +940,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this); break; case DataType::LONGVARBINARY: + case DataType::BLOB: OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this); break; case DataType::SQLNULL: @@ -959,12 +961,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In case DataType::ARRAY: // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); break; - case DataType::BLOB: - // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); - break; - case DataType::CLOB: - // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); - break; case DataType::REF: // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); break; @@ -1009,6 +1005,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR; break; case DataType::LONGVARCHAR: + case DataType::CLOB: bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR; break; case DataType::DATE: @@ -1027,6 +1024,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY; break; case DataType::LONGVARBINARY: + case DataType::BLOB: bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY; break; } diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx index 8c885f0924ad..fb1a08147338 100644 --- a/connectivity/source/drivers/odbcbase/OResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx @@ -223,9 +223,11 @@ SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle) delete static_cast< double* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::LONGVARCHAR: + case DataType::CLOB: delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::LONGVARBINARY: + case DataType::BLOB: delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::DATE: @@ -284,9 +286,11 @@ TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex) aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType); break; case DataType::LONGVARCHAR: + case DataType::CLOB: aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden break; case DataType::LONGVARBINARY: + case DataType::BLOB: aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden break; case DataType::DATE: @@ -1499,6 +1503,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR: + case DataType::CLOB: { ::std::map::iterator aFind = m_aODBCColumnTypes.find(nColumn); if ( aFind == m_aODBCColumnTypes.end() ) @@ -1514,6 +1519,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) *pColumn = getDouble(nColumn); break; case DataType::LONGVARBINARY: + case DataType::BLOB: *pColumn = getBytes(nColumn); break; case DataType::DATE: @@ -1719,6 +1725,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: aSeq = m_aRow[nColumnIndex]; N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength()); break; @@ -1730,6 +1737,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) break; } case DataType::LONGVARCHAR: + case DataType::CLOB: { ::rtl::OUString sRet; sRet = m_aRow[nColumnIndex].getString(); -- cgit From a5a48d4f886b52e115db553346ffe959747ff03a Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 13:30:02 +0100 Subject: #i105086# fix for clob and blob --- connectivity/source/commontools/FValue.cxx | 87 ++++++++++++++++- connectivity/source/commontools/dbtools.cxx | 103 ++++++++++++--------- connectivity/source/commontools/predicateinput.cxx | 5 +- 3 files changed, 148 insertions(+), 47 deletions(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index cd09efa227fe..7a85cca57738 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -254,6 +254,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: (*this) = getAny(); break; default: @@ -844,6 +845,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: bRet = false; break; default: @@ -910,6 +912,7 @@ Any ORowSetValue::makeAny() const case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: rValue = getAny(); break; case DataType::BIT: @@ -1016,6 +1019,19 @@ Any ORowSetValue::makeAny() const else aRet = ::rtl::OUString::valueOf((sal_Int64)*this); break; + case DataType::CLOB: + { + Any aValue( getAny() ); + Reference< XClob > xClob; + if ( aValue >>= xClob ) + { + if ( xClob.is() ) + { + aRet = xClob->getSubString(1,(sal_Int32)xClob->length() ); + } + } + } + break; } } return aRet; @@ -1087,6 +1103,9 @@ sal_Bool ORowSetValue::getBool() const case DataType::INTEGER: bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast(m_aValue.m_pValue) != sal_Int64(0)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return bRet; @@ -1128,6 +1147,8 @@ sal_Int8 ORowSetValue::getInt8() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt8() for this type is not allowed!"); break; case DataType::BIT: @@ -1152,6 +1173,9 @@ sal_Int8 ORowSetValue::getInt8() const else nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1193,6 +1217,8 @@ sal_Int16 ORowSetValue::getInt16() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt16() for this type is not allowed!"); break; case DataType::BIT: @@ -1217,6 +1243,9 @@ sal_Int16 ORowSetValue::getInt16() const else nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1258,6 +1287,8 @@ sal_Int32 ORowSetValue::getInt32() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt32() for this type is not allowed!"); break; case DataType::BIT: @@ -1282,6 +1313,9 @@ sal_Int32 ORowSetValue::getInt32() const else nRet = static_cast(*static_cast(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1323,6 +1357,8 @@ sal_Int64 ORowSetValue::getLong() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt32() for this type is not allowed!"); break; case DataType::BIT: @@ -1347,6 +1383,9 @@ sal_Int64 ORowSetValue::getLong() const else nRet = *(sal_Int64*)m_aValue.m_pValue; break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1392,6 +1431,8 @@ float ORowSetValue::getFloat() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1416,6 +1457,9 @@ float ORowSetValue::getFloat() const else nRet = float(*(sal_Int64*)m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1463,6 +1507,8 @@ double ORowSetValue::getDouble() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1487,6 +1533,9 @@ double ORowSetValue::getDouble() const else nRet = double(*(sal_Int64*)m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1548,6 +1597,8 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"setFromDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1655,6 +1706,9 @@ Sequence ORowSetValue::getSequence() const aValue.Year = pDateTime->Year; } break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1693,6 +1747,9 @@ Sequence ORowSetValue::getSequence() const break; case DataType::TIME: aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue); + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1740,6 +1797,9 @@ Sequence ORowSetValue::getSequence() const case DataType::TIMESTAMP: aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1885,13 +1945,17 @@ void ORowSetValue::fill(sal_Int32 _nPos, (*this) = _xRow->getLong(_nPos); break; case DataType::CLOB: - (*this) = ::com::sun::star::uno::makeAny(_xRow->getCharacterStream(_nPos)); + (*this) = ::com::sun::star::uno::makeAny(_xRow->getClob(_nPos)); setTypeKind(DataType::CLOB); break; case DataType::BLOB: - (*this) = ::com::sun::star::uno::makeAny(_xRow->getBinaryStream(_nPos)); + (*this) = ::com::sun::star::uno::makeAny(_xRow->getBlob(_nPos)); setTypeKind(DataType::BLOB); break; + case DataType::OTHER: + (*this) = _xRow->getObject(_nPos,NULL); + setTypeKind(DataType::OTHER); + break; default: OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" ); bReadData = false; @@ -2037,6 +2101,25 @@ void ORowSetValue::fill(const Any& _rValue) break; } + case TypeClass_INTERFACE: + { + Reference< XClob > xClob; + if ( _rValue >>= xClob ) + { + (*this) = _rValue; + setTypeKind(DataType::CLOB); + } + else + { + Reference< XBlob > xBlob; + if ( _rValue >>= xBlob ) + { + (*this) = _rValue; + setTypeKind(DataType::BLOB); + } + } + } + break; default: OSL_ENSURE(0,"Unknown type"); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 02e6e420142f..bb088937c313 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -213,6 +213,7 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale); break; case DataType::DATE: @@ -234,10 +235,10 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, case DataType::STRUCT: case DataType::ARRAY: case DataType::BLOB: - case DataType::CLOB: case DataType::REF: default: - nFormat = NumberFormat::UNDEFINED; + nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale); + //nFormat = NumberFormat::UNDEFINED; } return nFormat; } @@ -1850,9 +1851,20 @@ void setObjectWithInfo(const Reference& _xParams, sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, - sal_Int32 /*scale*/) throw(SQLException, RuntimeException) + sal_Int32 scale) throw(SQLException, RuntimeException) +{ + ORowSetValue aVal; + aVal.fill(x); + setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale); +} +// ----------------------------------------------------------------------------- +void setObjectWithInfo(const Reference& _xParams, + sal_Int32 parameterIndex, + const ::connectivity::ORowSetValue& _rValue, + sal_Int32 sqlType, + sal_Int32 scale) throw(SQLException, RuntimeException) { - if(!x.hasValue()) + if ( _rValue.isNull() ) _xParams->setNull(parameterIndex,sqlType); else { @@ -1860,65 +1872,62 @@ void setObjectWithInfo(const Reference& _xParams, { case DataType::DECIMAL: case DataType::NUMERIC: - _xParams->setObjectWithInfo(parameterIndex,x,sqlType,0); + _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale); break; case DataType::CHAR: case DataType::VARCHAR: - //case DataType::DECIMAL: - //case DataType::NUMERIC: case DataType::LONGVARCHAR: - _xParams->setString(parameterIndex,::comphelper::getString(x)); + _xParams->setString(parameterIndex,_rValue); break; - case DataType::BIGINT: + case DataType::CLOB: { - sal_Int64 nValue = 0; - if(x >>= nValue) + Any x(_rValue.makeAny()); + ::rtl::OUString sValue; + if ( x >>= sValue ) + _xParams->setString(parameterIndex,sValue); + else { - _xParams->setLong(parameterIndex,nValue); - break; + Reference< XClob > xClob; + if(x >>= xClob) + _xParams->setClob(parameterIndex,xClob); + else + { + Reference< ::com::sun::star::io::XInputStream > xStream; + if(x >>= xStream) + _xParams->setCharacterStream(parameterIndex,xStream,xStream->available()); + } } } break; + case DataType::BIGINT: + if ( _rValue.isSigned() ) + _xParams->setLong(parameterIndex,_rValue); + else + _xParams->setString(parameterIndex,_rValue); + break; case DataType::FLOAT: + _xParams->setFloat(parameterIndex,_rValue); + break; case DataType::REAL: - { - float nValue = 0; - if(x >>= nValue) - { - _xParams->setFloat(parameterIndex,nValue); - break; - } - } - // run through if we couldn't set a float value case DataType::DOUBLE: - _xParams->setDouble(parameterIndex,::comphelper::getDouble(x)); + _xParams->setDouble(parameterIndex,_rValue); break; case DataType::DATE: - { - ::com::sun::star::util::Date aValue; - if(x >>= aValue) - _xParams->setDate(parameterIndex,aValue); - } + _xParams->setDate(parameterIndex,_rValue); break; case DataType::TIME: - { - ::com::sun::star::util::Time aValue; - if(x >>= aValue) - _xParams->setTime(parameterIndex,aValue); - } + _xParams->setTime(parameterIndex,_rValue); break; case DataType::TIMESTAMP: - { - ::com::sun::star::util::DateTime aValue; - if(x >>= aValue) - _xParams->setTimestamp(parameterIndex,aValue); - } + _xParams->setTimestamp(parameterIndex,_rValue); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: { + Any x(_rValue.makeAny()); Sequence< sal_Int8> aBytes; if(x >>= aBytes) _xParams->setBytes(parameterIndex,aBytes); @@ -1944,16 +1953,24 @@ void setObjectWithInfo(const Reference& _xParams, break; case DataType::BIT: case DataType::BOOLEAN: - _xParams->setBoolean(parameterIndex,::cppu::any2bool(x)); + _xParams->setBoolean(parameterIndex,_rValue); break; - case DataType::TINYINT: - _xParams->setByte(parameterIndex,(sal_Int8)::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setByte(parameterIndex,_rValue); + else + _xParams->setShort(parameterIndex,_rValue); break; case DataType::SMALLINT: - _xParams->setShort(parameterIndex,(sal_Int16)::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setShort(parameterIndex,_rValue); + else + _xParams->setInt(parameterIndex,_rValue); break; case DataType::INTEGER: - _xParams->setInt(parameterIndex,::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setInt(parameterIndex,_rValue); + else + _xParams->setLong(parameterIndex,_rValue); break; default: { diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 45e937235dd1..f5d22e2937aa 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -148,9 +148,10 @@ namespace dbtools sal_Int32 nType = DataType::OTHER; _rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nType; - if ( ( DataType::CHAR == nType ) - || ( DataType::VARCHAR == nType ) + if ( ( DataType::CHAR == nType ) + || ( DataType::VARCHAR == nType ) || ( DataType::LONGVARCHAR == nType ) + || ( DataType::CLOB == nType ) ) { // yes -> force a quoted text and try again ::rtl::OUString sQuoted( _rStatement ); -- cgit From 5fb1869f0f44a9810bb2b060f70558d5b255d08e Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 13:30:18 +0100 Subject: #i105086# fix for clob and blob --- connectivity/inc/connectivity/dbtools.hxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx index 493dc2a3802f..32ef3bcb7da1 100644 --- a/connectivity/inc/connectivity/dbtools.hxx +++ b/connectivity/inc/connectivity/dbtools.hxx @@ -37,6 +37,7 @@ #include #include #include "connectivity/dbtoolsdllapi.hxx" +#include "connectivity/FValue.hxx" namespace com { namespace sun { namespace star { @@ -593,6 +594,20 @@ namespace dbtools sal_Int32 sqlType, sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType + @param _xParams the parameters where to set the value + @param parameterIndex the index of the parameter, 1 based + @param x the value to set + @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType + @param scale the scale of the sql type can be 0 + */ + OOO_DLLPUBLIC_DBTOOLS + void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters, + sal_Int32 parameterIndex, + const ::connectivity::ORowSetValue& x, + sal_Int32 sqlType, + sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + /** implements XParameters::setObject

The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there -- cgit From 6daca460f9a204748e6feb3a80cee63646ad5b90 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 13:55:28 +0100 Subject: #i105086# fix for clob and blob --- connectivity/source/inc/ado/Aolevariant.hxx | 1 + connectivity/source/inc/java/lang/Boolean.hxx | 1 + connectivity/source/inc/java/sql/Timestamp.hxx | 3 +++ 3 files changed, 5 insertions(+) diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx index f15d78a37ed9..c9fd9807af41 100644 --- a/connectivity/source/inc/ado/Aolevariant.hxx +++ b/connectivity/source/inc/ado/Aolevariant.hxx @@ -161,6 +161,7 @@ namespace connectivity double getDate() const; CY getCurrency() const; SAFEARRAY* getUI1SAFEARRAYPtr() const; + ::com::sun::star::uno::Any makeAny() const; static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean); diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx index 2f33ea27bc11..7cfd1bbc4aa1 100644 --- a/connectivity/source/inc/java/lang/Boolean.hxx +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -48,6 +48,7 @@ namespace connectivity java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} java_lang_Boolean( sal_Bool _par0 ); + static jclass st_getMyClass(); }; } diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx index ce6de39b5bb9..2d234e1b52a1 100644 --- a/connectivity/source/inc/java/sql/Timestamp.hxx +++ b/connectivity/source/inc/java/sql/Timestamp.hxx @@ -54,6 +54,7 @@ namespace connectivity java_sql_Date( const ::com::sun::star::util::Date& _rOut ); operator ::com::sun::star::util::Date(); + static jclass st_getMyClass(); }; @@ -73,6 +74,7 @@ namespace connectivity java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} java_sql_Time( const ::com::sun::star::util::Time& _rOut ); operator ::com::sun::star::util::Time(); + static jclass st_getMyClass(); }; //************************************************************** @@ -93,6 +95,7 @@ namespace connectivity sal_Int32 getNanos(); void setNanos(sal_Int32 n); + static jclass st_getMyClass(); }; } #endif // _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ -- cgit From 2d26cea420271b10f01cd4a69e3b44963113633c Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 13:57:55 +0100 Subject: #i105086# fix for clob and blob --- connectivity/source/parse/sqlbison.y | 3 ++- connectivity/source/parse/sqliterator.cxx | 1 - connectivity/source/parse/sqlnode.cxx | 32 +++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 97875dfd4de0..19d3c3f94211 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -2043,7 +2043,8 @@ join_spec: | named_columns_join ; join_type: - SQL_TOKEN_INNER + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_INNER { $$ = SQL_NEW_RULE; $$->append($1); diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 26086495be89..6b839f0116dd 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1601,7 +1601,6 @@ void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask ) case SQL_STATEMENT_INSERT: break; default: - OSL_ENSURE( false, "OSQLParseTreeIterator::traverseAll: not yet implemented for this statement type!" ); break; } } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index a1fd44014314..8e915d8ead72 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -813,8 +813,9 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) - pReturn = NULL; + case DataType::CLOB: + if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) + pReturn = NULL; default: break; } @@ -829,6 +830,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: break; case DataType::DATE: case DataType::TIME: @@ -872,12 +874,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; default: m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE); @@ -893,12 +896,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; case DataType::INTEGER: default: @@ -967,6 +971,7 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: if(pLiteral->isRule()) { pAppend->append(pLiteral); @@ -1228,6 +1233,7 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const : case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: s_pScanner->SetRule(s_pScanner->GetSTRINGRule()); break; default: @@ -2074,18 +2080,18 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) if ( SQL_ISRULE(p2ndSearch,boolean_primary) ) p2ndSearch = p2ndSearch->getChild(1); - if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) + if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b { pNewNode = pSearchCondition->removeAt((sal_uInt32)0); replaceAndReset(pSearchCondition,pNewNode); } - else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) + else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b { pNewNode = pSearchCondition->removeAt((sal_uInt32)2); replaceAndReset(pSearchCondition,pNewNode); } - else if ( p2ndSearch->getByRule(OSQLParseNode::boolean_term) ) + else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) ) { // a and ( b or c ) -> ( a and b ) or ( a and c ) // ( b or c ) and a -> ( a and b ) or ( a and c ) @@ -2096,7 +2102,13 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) OSQLParseNode* p1stAnd = MakeANDNode(pA,pB); OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC); pNewNode = MakeORNode(p1stAnd,p2ndAnd); - replaceAndReset(pSearchCondition,pNewNode); + OSQLParseNode* pNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); + pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION)); + pNode->append(pNewNode); + pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION)); + OSQLParseNode::eraseBraces(p1stAnd); + OSQLParseNode::eraseBraces(p2ndAnd); + replaceAndReset(pSearchCondition,pNode); } } // a or a and b || a or b and a -- cgit From 9bf37b7f90baf165364f4e83b1b0adf31b17922a Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Wed, 11 Nov 2009 14:00:23 +0100 Subject: #i105086# fix for clob and blob --- svx/source/fmcomp/fmgridcl.cxx | 14 ++++++++++---- svx/source/form/fmvwimp.cxx | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index c210919bd09d..8775ad850422 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -435,6 +435,7 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ ) // diese Datentypen koennen im Gridcontrol nicht verarbeitet werden switch (nDataType) { + case DataType::BLOB: case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: @@ -1724,6 +1725,7 @@ void FmGridControl::InitColumnByField( sal_Bool bIllegalType = sal_False; switch ( nDataType ) { + case DataType::BLOB: case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: @@ -1768,14 +1770,18 @@ void FmGridControl::InitColumnsByFields(const Reference< ::com::sun::star::conta Reference< XIndexContainer > xColumns( GetPeer()->getColumns() ); Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY ); - // Einfuegen mu� sich an den Column Positionen orientieren + // Einfuegen muss sich an den Column Positionen orientieren for (sal_Int32 i = 0; i < xColumns->getCount(); i++) { DbGridColumn* pCol = GetColumns().GetObject(i); - Reference< XPropertySet > xColumnModel; - ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) ); + OSL_ENSURE(pCol,"No grid column!"); + if ( pCol ) + { + Reference< XPropertySet > xColumnModel; + ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) ); - InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields ); + InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields ); + } } } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index d6cdd12fdff2..c3214d967320 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1291,10 +1291,12 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript else switch (nDataType) { + case DataType::BLOB: case DataType::LONGVARBINARY: nOBJID = OBJ_FM_IMAGECONTROL; break; case DataType::LONGVARCHAR: + case DataType::CLOB: nOBJID = OBJ_FM_EDIT; break; case DataType::BINARY: @@ -1626,7 +1628,9 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& aControlSize = aDefSize; break; case DataType::LONGVARCHAR: + case DataType::CLOB: case DataType::LONGVARBINARY: + case DataType::BLOB: aControlSize = aDefImageSize; break; } @@ -1659,7 +1663,7 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& } } - if ( nDataType == DataType::LONGVARCHAR && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) ) + if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) ) { xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( sal_Bool( sal_True ) ) ); } -- cgit From 8421bb9bf5894fb7043747876172a89c6e5a4820 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 12 Nov 2009 09:35:14 +0100 Subject: #i99566# type of min and max depends on the parameter --- connectivity/inc/connectivity/sqliterator.hxx | 3 + connectivity/inc/connectivity/sqlnode.hxx | 4 ++ connectivity/source/parse/sqliterator.cxx | 96 ++++++++++++++++++++++----- connectivity/source/parse/sqlnode.cxx | 6 +- 4 files changed, 93 insertions(+), 16 deletions(-) diff --git a/connectivity/inc/connectivity/sqliterator.hxx b/connectivity/inc/connectivity/sqliterator.hxx index ddbf3e24af3c..e8e4c8e6a6f2 100644 --- a/connectivity/inc/connectivity/sqliterator.hxx +++ b/connectivity/inc/connectivity/sqliterator.hxx @@ -279,6 +279,9 @@ namespace connectivity // return true when the tableNode is a rule like catalog_name, schema_name or table_name sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const; + + // tries to find the correct type of the function + sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode ); private: /** traverses the list of table names, and filles _rTables */ diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 0adcae01d966..cc1b27cf4f57 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -225,6 +225,10 @@ namespace connectivity as, op_column_commalist, table_primary_as_range_column, + datetime_primary, + concatenation, + char_factor, + bit_value_fct, rule_count, // letzter_wert UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID) }; diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 6b839f0116dd..e8111f174486 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -952,21 +952,7 @@ bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele if ( pColumnRef->isRule() ) { bFkt = sal_True; - if ( SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term) || SQL_ISRULE(pColumnRef,factor) ) - { - nType = DataType::DOUBLE; - } - else - { - ::rtl::OUString sFunctionName; - if ( SQL_ISRULE(pColumnRef,length_exp) ) - pColumnRef->getChild(0)->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - else - pColumnRef->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); - } + nType = getFunctionReturnType(pColumnRef); } } /* @@ -2103,3 +2089,83 @@ void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError ) m_aErrors = _rError; } // ----------------------------------------------------------------------------- +sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode ) +{ + sal_Int32 nType = DataType::OTHER; + ::rtl::OUString sFunctionName; + if ( SQL_ISRULE(_pNode,length_exp) ) + { + _pNode->getChild(0)->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + else if ( SQL_ISRULE(_pNode,num_value_exp) || SQL_ISRULE(_pNode,term) || SQL_ISRULE(_pNode,factor) ) + { + nType = DataType::DOUBLE; + } + else + { + _pNode->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + + // MIN and MAX have another return type, we have to check the expression itself. + // @see http://qa.openoffice.org/issues/show_bug.cgi?id=99566 + if ( SQL_ISRULE(_pNode,general_set_fct) && (SQL_ISTOKEN(_pNode->getChild(0),MIN) || SQL_ISTOKEN(_pNode->getChild(0),MAX) )) + { + const OSQLParseNode* pValueExp = _pNode->getChild(3); + if (SQL_ISRULE(pValueExp,column_ref)) + { + ::rtl::OUString sColumnName; + ::rtl::OUString aTableRange; + getColumnRange(pValueExp,sColumnName,aTableRange); + OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein"); + Reference xColumn = findColumn( sColumnName, aTableRange, true ); + + if ( xColumn.is() ) + { + xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE)) >>= nType; + } + } + else + { + if ( SQL_ISRULE(pValueExp,num_value_exp) || SQL_ISRULE(pValueExp,term) || SQL_ISRULE(pValueExp,factor) ) + { + nType = DataType::DOUBLE; + } + else if ( SQL_ISRULE(pValueExp,datetime_primary) ) + { + switch(pValueExp->getChild(0)->getTokenID() ) + { + case SQL_TOKEN_CURRENT_DATE: + nType = DataType::DATE; + break; + case SQL_TOKEN_CURRENT_TIME: + nType = DataType::TIME; + break; + case SQL_TOKEN_CURRENT_TIMESTAMP: + nType = DataType::TIMESTAMP; + break; + } + } + else if ( SQL_ISRULE(pValueExp,value_exp_primary) ) + { + nType = getFunctionReturnType(pValueExp->getChild(1)); + } + else if ( SQL_ISRULE(pValueExp,concatenation) + || SQL_ISRULE(pValueExp,char_factor) + || SQL_ISRULE(pValueExp,bit_value_fct) + || SQL_ISRULE(pValueExp,char_value_fct) + || SQL_ISRULE(pValueExp,char_substring_fct) + || SQL_ISRULE(pValueExp,fold) + || SQL_ISTOKEN(pValueExp,STRING) ) + { + nType = DataType::VARCHAR; + } + } + if ( nType == DataType::OTHER ) + nType = DataType::DOUBLE; + } + else + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + + return nType; +} \ No newline at end of file diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 8e915d8ead72..c76dd44e3d18 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1421,7 +1421,11 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::table_node, "table_node" }, { OSQLParseNode::as, "as" }, { OSQLParseNode::op_column_commalist, "op_column_commalist" }, - { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" } + { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" }, + { OSQLParseNode::datetime_primary, "datetime_primary" }, + { OSQLParseNode::concatenation, "concatenation" }, + { OSQLParseNode::char_factor, "char_factor" }, + { OSQLParseNode::bit_value_fct, "bit_value_fct" } }; size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" ); -- cgit From 836e83354424454cfe5cdf9d211a976137b2f0f9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 12 Nov 2009 20:56:06 +0100 Subject: missed a break in getTime --- connectivity/source/commontools/FValue.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 7a85cca57738..ec878e05feaf 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -1747,6 +1747,7 @@ Sequence ORowSetValue::getSequence() const break; case DataType::TIME: aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue); + break; default: OSL_ENSURE(0,"Illegal conversion!"); break; -- cgit From 77adaec362dbc74aa8907ae3847d96e8ecce42ba Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 13 Nov 2009 08:59:36 +0100 Subject: some refactoring, done during creation of a test case for #i106643# --- connectivity/qa/connectivity/GeneralTest.java | 10 +-- .../qa/connectivity/tools/AbstractDatabase.java | 31 +++----- .../qa/connectivity/tools/CRMDatabase.java | 18 ++--- connectivity/qa/connectivity/tools/DataSource.java | 40 +++------- .../qa/connectivity/tools/DatabaseAccess.java | 4 +- .../qa/connectivity/tools/HsqlDatabase.java | 6 +- .../qa/connectivity/tools/HsqlTableDescriptor.java | 16 ++-- connectivity/qa/connectivity/tools/makefile.mk | 14 +--- .../qa/connectivity/tools/sdb/Connection.java | 93 ++++++++++++++++++++++ 9 files changed, 139 insertions(+), 93 deletions(-) create mode 100644 connectivity/qa/connectivity/tools/sdb/Connection.java diff --git a/connectivity/qa/connectivity/GeneralTest.java b/connectivity/qa/connectivity/GeneralTest.java index 18b6cf267a43..da894ba2cbdb 100644 --- a/connectivity/qa/connectivity/GeneralTest.java +++ b/connectivity/qa/connectivity/GeneralTest.java @@ -30,21 +30,13 @@ package complex.connectivity; import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; import com.sun.star.sdbc.*; -import com.sun.star.sdb.*; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; import com.sun.star.lang.XMultiServiceFactory; import complexlib.ComplexTestCase; -import java.io.PrintWriter; -import util.utils; -import java.util.*; -import java.io.*; //import complex.connectivity.DBaseStringFunctions; public class GeneralTest extends ComplexTestCase { @@ -63,7 +55,7 @@ public class GeneralTest extends ComplexTestCase { public void test() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException { try { - XDriverManager driverManager = (XDriverManager)UnoRuntime.queryInterface(XDriverManager.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.sdbc.DriverManager")); + XDriverManager driverManager = UnoRuntime.queryInterface( XDriverManager.class, ((XMultiServiceFactory)param.getMSF()).createInstance( "com.sun.star.sdbc.DriverManager" ) ); String databaseURL = "sdbc:calc:singin' in the rain" ; XConnection catalogConnection = driverManager.getConnection(databaseURL); failed(); diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java index d3150cd8aa07..4807860740ad 100755 --- a/connectivity/qa/connectivity/tools/AbstractDatabase.java +++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java @@ -38,10 +38,10 @@ import com.sun.star.sdb.XDocumentDataSource; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XCloseable; -import com.sun.star.sdbc.XConnection; import com.sun.star.sdbc.XStatement; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.CloseVetoException; +import connectivity.tools.sdb.Connection; import java.io.File; /** @@ -60,7 +60,7 @@ public abstract class AbstractDatabase implements DatabaseAccess // the data source belonging to the database document protected DataSource m_dataSource; // the default connection - protected XConnection m_connection; + protected Connection m_connection; public AbstractDatabase(final XMultiServiceFactory orb) throws Exception { @@ -80,12 +80,10 @@ public abstract class AbstractDatabase implements DatabaseAccess * the ownership of the connection, so you don't need to (and should not) dispose/close it. * */ - public XConnection defaultConnection() throws SQLException + public Connection defaultConnection() throws SQLException { - if (m_connection == null) - { - m_connection = m_databaseDocument.getDataSource().getConnection("", ""); - } + if ( m_connection == null ) + m_connection = new Connection( m_databaseDocument.getDataSource().getConnection("", "") ); return m_connection; } @@ -104,8 +102,7 @@ public abstract class AbstractDatabase implements DatabaseAccess { if (m_databaseDocument != null) { - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, - m_databaseDocument); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, m_databaseDocument); storeDoc.store(); } } @@ -118,8 +115,8 @@ public abstract class AbstractDatabase implements DatabaseAccess public void close() { // close connection - final XCloseable closeConn = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, - m_connection); + final XCloseable closeConn = UnoRuntime.queryInterface( XCloseable.class, + m_connection != null ? m_connection.getXConnection() : null ); if (closeConn != null) { try @@ -133,8 +130,7 @@ public abstract class AbstractDatabase implements DatabaseAccess m_connection = null; // close document - final com.sun.star.util.XCloseable closeDoc = (com.sun.star.util.XCloseable) UnoRuntime.queryInterface( - com.sun.star.util.XCloseable.class, m_databaseDocument); + final com.sun.star.util.XCloseable closeDoc = UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, m_databaseDocument ); if (closeDoc != null) { try @@ -178,7 +174,7 @@ public abstract class AbstractDatabase implements DatabaseAccess */ public XModel getModel() { - return (XModel) UnoRuntime.queryInterface(XModel.class, m_databaseDocument); + return UnoRuntime.queryInterface( XModel.class, m_databaseDocument ); } public XMultiServiceFactory getORB() @@ -191,10 +187,9 @@ public abstract class AbstractDatabase implements DatabaseAccess { m_databaseDocumentFile = _docURL; - final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, - m_orb.createInstance("com.sun.star.sdb.DatabaseContext")); - final XDocumentDataSource dataSource = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, - dbContext.getByName(_docURL)); + final XNameAccess dbContext = UnoRuntime.queryInterface( XNameAccess.class, + m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) ); + final XDocumentDataSource dataSource = UnoRuntime.queryInterface( XDocumentDataSource.class, dbContext.getByName( _docURL ) ); m_databaseDocument = dataSource.getDatabaseDocument(); m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource()); diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java index e3fa60afa763..7a6cb7e8c034 100644 --- a/connectivity/qa/connectivity/tools/CRMDatabase.java +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -44,10 +44,10 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XSingleSelectQueryComposer; import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.sdbc.SQLException; -import com.sun.star.sdbc.XConnection; import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XRefreshable; +import connectivity.tools.sdb.Connection; /** implements a small Customer Relationship Management database * @@ -60,7 +60,7 @@ public class CRMDatabase private final XMultiServiceFactory m_orb; private final HsqlDatabase m_database; private final DataSource m_dataSource; - private final XConnection m_connection; + private final Connection m_connection; /** constructs the CRM database */ @@ -80,7 +80,7 @@ public class CRMDatabase }; loader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", 0, loadArgs ); getDocumentUI().connect(); - m_connection = getDocumentUI().getActiveConnection(); + m_connection = new Connection( getDocumentUI().getActiveConnection() ); } else { @@ -117,7 +117,7 @@ public class CRMDatabase // -------------------------------------------------------------------------------------------------------- /** returns the default connection to the database */ - public final XConnection getConnection() + public final Connection getConnection() { return m_connection; } @@ -125,7 +125,9 @@ public class CRMDatabase // -------------------------------------------------------------------------------------------------------- public void saveAndClose() throws SQLException, IOException { - getDocumentUI().closeSubComponents(); + XDatabaseDocumentUI ui = getDocumentUI(); + if ( ui != null ) + ui.closeSubComponents(); m_database.store(); m_database.closeAndDelete(); } @@ -219,9 +221,7 @@ public class CRMDatabase // since we created the tables by directly executing the SQL statements, we need to refresh // the tables container - final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_connection ); - final XRefreshable refreshTables = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() ); - refreshTables.refresh(); + m_connection.refreshTables(); } // -------------------------------------------------------------------------------------------------------- @@ -233,7 +233,7 @@ public class CRMDatabase try { final XMultiServiceFactory factory = UnoRuntime.queryInterface( - XMultiServiceFactory.class, m_database.defaultConnection() ); + XMultiServiceFactory.class, m_database.defaultConnection().getXConnection() ); composer = UnoRuntime.queryInterface( XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) ); unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" ); diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java index 1ed8f7f98af7..23d0d142128a 100644 --- a/connectivity/qa/connectivity/tools/DataSource.java +++ b/connectivity/qa/connectivity/tools/DataSource.java @@ -39,10 +39,8 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; import com.sun.star.sdb.XQueryDefinitionsSupplier; import com.sun.star.sdbc.XDataSource; -import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XRefreshable; import java.util.logging.Level; import java.util.logging.Logger; @@ -57,11 +55,10 @@ public class DataSource { m_orb = _orb; - final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, - _orb.createInstance("com.sun.star.sdb.DatabaseContext")); + final XNameAccess dbContext = UnoRuntime.queryInterface( + XNameAccess.class, _orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) ); - m_dataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, - dbContext.getByName(_registeredName)); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, dbContext.getByName( _registeredName ) ); } public DataSource(final XMultiServiceFactory _orb,final XDataSource _dataSource) @@ -86,13 +83,11 @@ public class DataSource */ public void createQuery(final String _name, final String _sqlCommand, final boolean _escapeProcessing) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException { - final XSingleServiceFactory queryDefsFac = (XSingleServiceFactory) UnoRuntime.queryInterface( - XSingleServiceFactory.class, getQueryDefinitions()); + final XSingleServiceFactory queryDefsFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, getQueryDefinitions() ); XPropertySet queryDef = null; try { - queryDef = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, queryDefsFac.createInstance()); + queryDef = UnoRuntime.queryInterface( XPropertySet.class, queryDefsFac.createInstance() ); queryDef.setPropertyValue("Command", _sqlCommand); queryDef.setPropertyValue("EscapeProcessing", Boolean.valueOf(_escapeProcessing)); } @@ -101,8 +96,7 @@ public class DataSource e.printStackTrace(System.err); } - final XNameContainer queryDefsContainer = (XNameContainer) UnoRuntime.queryInterface( - XNameContainer.class, getQueryDefinitions()); + final XNameContainer queryDefsContainer = UnoRuntime.queryInterface( XNameContainer.class, getQueryDefinitions() ); queryDefsContainer.insertByName(_name, queryDef); } @@ -113,8 +107,7 @@ public class DataSource final XNameAccess allDefs = getQueryDefinitions(); try { - return new QueryDefinition( - (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, allDefs.getByName(_name))); + return new QueryDefinition( UnoRuntime.queryInterface( XPropertySet.class, allDefs.getByName( _name) ) ); } catch (WrappedTargetException e) { @@ -126,25 +119,11 @@ public class DataSource */ public XNameAccess getQueryDefinitions() { - final XQueryDefinitionsSupplier suppQueries = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface( + final XQueryDefinitionsSupplier suppQueries = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource); return suppQueries.getQueryDefinitions(); } - /** refreshs the table container of a given connection - * - * This is usually necessary if you created tables by directly executing SQL statements, - * bypassing the SDBCX layer. - */ - public void refreshTables(final com.sun.star.sdbc.XConnection _connection) - { - final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface( - XTablesSupplier.class, _connection); - final XRefreshable refreshTables = (XRefreshable) UnoRuntime.queryInterface( - XRefreshable.class, suppTables.getTables()); - refreshTables.refresh(); - } - /** returns the name of the data source * * If a data source is registered at the database context, the name is the registration @@ -157,8 +136,7 @@ public class DataSource String name = null; try { - final XPropertySet dataSourceProps = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, m_dataSource); + final XPropertySet dataSourceProps = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); name = (String) dataSourceProps.getPropertyValue("Name"); } catch (Exception ex) diff --git a/connectivity/qa/connectivity/tools/DatabaseAccess.java b/connectivity/qa/connectivity/tools/DatabaseAccess.java index bc39bb099087..78608063e64c 100755 --- a/connectivity/qa/connectivity/tools/DatabaseAccess.java +++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java @@ -34,7 +34,7 @@ import com.sun.star.io.IOException; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdbc.SQLException; -import com.sun.star.sdbc.XConnection; +import connectivity.tools.sdb.Connection; /** * @@ -42,7 +42,7 @@ import com.sun.star.sdbc.XConnection; */ public interface DatabaseAccess { - XConnection defaultConnection() throws SQLException; + Connection defaultConnection() throws SQLException; void executeSQL(final String statementString) throws SQLException; diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java index c34e78c640a4..7440d3865bb2 100644 --- a/connectivity/qa/connectivity/tools/HsqlDatabase.java +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -208,10 +208,8 @@ public class HsqlDatabase extends AbstractDatabase public void createTableInSDBCX(final HsqlTableDescriptor _tableDesc) throws SQLException, ElementExistException { final XPropertySet sdbcxDescriptor = _tableDesc.createSdbcxDescriptor(defaultConnection()); - final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface( - XTablesSupplier.class, defaultConnection()); - final XAppend appendTable = (XAppend) UnoRuntime.queryInterface( - XAppend.class, suppTables.getTables()); + final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, defaultConnection().getXConnection() ); + final XAppend appendTable = UnoRuntime.queryInterface( XAppend.class, suppTables.getTables() ); appendTable.appendByDescriptor(sdbcxDescriptor); } } diff --git a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java index ec6c472309d5..2c4f9d6e6466 100644 --- a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java +++ b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java @@ -33,11 +33,11 @@ package connectivity.tools; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.sdbc.ColumnValue; -import com.sun.star.sdbc.XConnection; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.sdbcx.XDataDescriptorFactory; import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.UnoRuntime; +import connectivity.tools.sdb.Connection; /** is a very simply descriptor of a HSQL table, to be used with a HsqlDatabase.createTable method */ @@ -67,12 +67,10 @@ public class HsqlTableDescriptor return m_columns; } - public XPropertySet createSdbcxDescriptor( XConnection _forConnection ) + public XPropertySet createSdbcxDescriptor( Connection _forConnection ) { - XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface( - XTablesSupplier.class, _forConnection ); - XDataDescriptorFactory tableDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface( - XDataDescriptorFactory.class, suppTables.getTables() ); + XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, _forConnection.getXConnection() ); + XDataDescriptorFactory tableDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, suppTables.getTables() ); XPropertySet tableDesc = tableDescFac.createDataDescriptor(); try @@ -81,12 +79,10 @@ public class HsqlTableDescriptor } catch ( Exception e ) { e.printStackTrace( System.err ); } - XColumnsSupplier suppDescCols = (XColumnsSupplier)UnoRuntime.queryInterface( - XColumnsSupplier.class, tableDesc ); + XColumnsSupplier suppDescCols = UnoRuntime.queryInterface( XColumnsSupplier.class, tableDesc ); XNameAccess descColumns = suppDescCols.getColumns(); - XDataDescriptorFactory columnDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface( - XDataDescriptorFactory.class, descColumns ); + XDataDescriptorFactory columnDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, descColumns ); HsqlColumnDescriptor[] myColumns = getColumns(); for ( int i = 0; i < myColumns.length; ++i ) diff --git a/connectivity/qa/connectivity/tools/makefile.mk b/connectivity/qa/connectivity/tools/makefile.mk index 589a85ea385f..c4f2b68f53f1 100644 --- a/connectivity/qa/connectivity/tools/makefile.mk +++ b/connectivity/qa/connectivity/tools/makefile.mk @@ -29,10 +29,10 @@ # #************************************************************************* -PRJ = ..$/..$/.. +PRJ = ../../.. TARGET = ConnectivityTools PRJNAME = connectivity -PACKAGE = connectivity$/tools +PACKAGE = connectivity/tools # --- Settings ----------------------------------------------------- .INCLUDE: settings.mk @@ -46,14 +46,8 @@ all: #----- compile .java files ----------------------------------------- JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunnerLight.jar -# Do not use $/ with the $(FIND) command as for W32-4nt this leads to a backslash -# in a posix command. In this special case use / instead of $/ -.IF "$(GUI)"=="OS2" -JAVAFILES := $(shell @ls ./*.java) -.ELSE -JAVAFILES := $(shell @$(FIND) ./*.java) -.ENDIF -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) +JAVAFILES := $(shell @$(FIND) -name "*.java") +JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:d)$(i:b).class) #----- make a jar from compiled files ------------------------------ diff --git a/connectivity/qa/connectivity/tools/sdb/Connection.java b/connectivity/qa/connectivity/tools/sdb/Connection.java new file mode 100644 index 000000000000..aac120fb1e73 --- /dev/null +++ b/connectivity/qa/connectivity/tools/sdb/Connection.java @@ -0,0 +1,93 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package connectivity.tools.sdb; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDatabaseMetaData; +import com.sun.star.sdbc.XPreparedStatement; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XStatement; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XRefreshable; + +/** + * is a convenience wrapper around a SDB-level connection object + */ +public class Connection +{ + private final XConnection m_connection; + + public Connection( final XConnection _connection ) + { + m_connection = _connection; + } + + public XConnection getXConnection() + { + return m_connection; + } + + public boolean execute( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.execute( _sql ); + } + + public XResultSet executeQuery( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.executeQuery( _sql ); + } + + public int executeUpdate( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.executeUpdate( _sql ); + } + + public void refreshTables() + { + final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_connection); + final XRefreshable refresh = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() ); + refresh.refresh(); + } + + public XSingleSelectQueryComposer createSingleSelectQueryComposer() throws Exception + { + final XMultiServiceFactory connectionFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_connection ); + return UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) ); + } + + public + XStatement createStatement() throws SQLException + { + return m_connection.createStatement(); + } + + public + XPreparedStatement prepareStatement( String _sql ) throws SQLException + { + return m_connection.prepareStatement( _sql ); + } + + public + XDatabaseMetaData getMetaData() throws SQLException + { + return m_connection.getMetaData(); + } + + public + void close() throws SQLException + { + m_connection.close(); + } +} -- cgit From fff9375fe7296dd390c6dbca0486aa60f95bd058 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 13 Nov 2009 13:30:51 +0100 Subject: #i105086# fix blob handling, map to bytes when possible --- .../sdbcx/comp/hsqldb/NativeInputStreamHelper.java | 31 +++++++++- .../comp/hsqldb/StorageNativeInputStream.java | 29 +++++++++ connectivity/inc/connectivity/BlobHelper.hxx | 54 ++++++++++++++++ connectivity/source/commontools/BlobHelper.cxx | 72 ++++++++++++++++++++++ connectivity/source/commontools/FValue.cxx | 37 ++++++++++- connectivity/source/commontools/makefile.mk | 1 + connectivity/source/drivers/ado/AResultSet.cxx | 18 ++++-- connectivity/source/drivers/jdbc/InputStream.cxx | 8 ++- connectivity/source/drivers/jdbc/ResultSet.cxx | 60 ++++++++++++++++-- connectivity/source/drivers/jdbc/tools.cxx | 57 ++++++++++++++++- connectivity/source/inc/java/tools.hxx | 4 ++ 11 files changed, 354 insertions(+), 17 deletions(-) create mode 100644 connectivity/inc/connectivity/BlobHelper.hxx create mode 100644 connectivity/source/commontools/BlobHelper.cxx diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java index 7fcfba0cf0a3..06f7da701f14 100644 --- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java @@ -1,4 +1,33 @@ -/* +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StorageFileAccess.java,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + /* * NativeInputStreamHelper.java * * Created on 9. September 2004, 11:51 diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java index 50697e07c6aa..5778c9ab830c 100644 --- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java @@ -1,3 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StorageFileAccess.java,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ /* * StorageNativeInputStream.java * diff --git a/connectivity/inc/connectivity/BlobHelper.hxx b/connectivity/inc/connectivity/BlobHelper.hxx new file mode 100644 index 000000000000..2fb832823bd2 --- /dev/null +++ b/connectivity/inc/connectivity/BlobHelper.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FValue.cxx,v $ + * $Revision: 1.34 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CONNECTIVITY_BLOBHELPER_HXX_ +#define _CONNECTIVITY_BLOBHELPER_HXX_ + +#include "connectivity/dbtoolsdllapi.hxx" +#include +#include + +namespace connectivity +{ + class OOO_DLLPUBLIC_DBTOOLS BlobHelper : public ::cppu::WeakImplHelper1< com::sun::star::sdbc::XBlob > + { + ::com::sun::star::uno::Sequence< sal_Int8 > m_aValue; + public: + BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val); + private: + virtual ::sal_Int64 SAL_CALL length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int64 SAL_CALL positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} + +#endif //_CONNECTIVITY_BLOBHELPER_HXX_ + diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx new file mode 100644 index 000000000000..46fdee9a78b5 --- /dev/null +++ b/connectivity/source/commontools/BlobHelper.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FValue.cxx,v $ + * $Revision: 1.34 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "connectivity/BlobHelper.hxx" +#include +#include "connectivity/dbexception.hxx" + +using namespace connectivity; +using namespace dbtools; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val) +{ +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return m_aValue.getLength(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if ( sal_Int32(pos + length) > m_aValue.getLength() ) + throw ::com::sun::star::sdbc::SQLException(); + return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),length); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return new ::comphelper::SequenceInputStream(m_aValue); +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this ); + return 0; +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this ); + return 0; +} diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 7a85cca57738..253c07bebdeb 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -1643,12 +1643,39 @@ Sequence ORowSetValue::getSequence() const case DataType::BLOB: { Reference xStream; - Any aValue = getAny(); + const Any aValue = makeAny(); if(aValue.hasValue()) { - aValue >>= xStream; + Reference xBlob(aValue,UNO_QUERY); + if ( xBlob.is() ) + xStream = xBlob->getBinaryStream(); + else + { + Reference xClob(aValue,UNO_QUERY); + if ( xClob.is() ) + xStream = xClob->getCharacterStream(); + } if(xStream.is()) - xStream->readBytes(aSeq,xStream->available()); + { + const sal_uInt32 nBytesToRead = 65535; + sal_uInt32 nRead; + + do + { + ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq; + + nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead ); + + if( nRead ) + { + const sal_uInt32 nOldLength = aSeq.getLength(); + aSeq.realloc( nOldLength + nRead ); + rtl_copyMemory( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); + } + } + while( nBytesToRead == nRead ); + xStream->closeInput(); + } } } break; @@ -2117,6 +2144,10 @@ void ORowSetValue::fill(const Any& _rValue) (*this) = _rValue; setTypeKind(DataType::BLOB); } + else + { + (*this) = _rValue; + } } } break; diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index cb5a4ad3f7aa..1cc6cf494919 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -89,6 +89,7 @@ EXCEPTIONSFILES=\ $(SLO)$/ParamterSubstitution.obj \ $(SLO)$/DriversConfig.obj \ $(SLO)$/formattedcolumnvalue.obj \ + $(SLO)$/BlobHelper.obj \ $(SLO)$/warningscontainer.obj SLOFILES=\ diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 8a5da6f94134..438f3bc473cc 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -784,14 +784,24 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::s } // ------------------------------------------------------------------------- -void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this ); + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); } // ------------------------------------------------------------------------- -void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); } // ------------------------------------------------------------------------- void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx index 522c1f67973e..dd2b0566b33f 100644 --- a/connectivity/source/drivers/jdbc/InputStream.cxx +++ b/connectivity/source/drivers/jdbc/InputStream.cxx @@ -84,8 +84,9 @@ void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::No // ----------------------------------------------------- sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { - if ( aData.getLength() < nBytesToRead ) - throw ::com::sun::star::io::BufferSizeExceededException(); + if (nBytesToRead < 0) + throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this ); + jint out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -102,7 +103,8 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen if(out > 0) { jboolean p = sal_False; - memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); + aData.realloc ( out ); + rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); } t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); } //t.pEnv diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 257aa6405eee..df90a68799bc 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -786,16 +786,68 @@ void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const } // ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" ); - ::dbtools::throwFeatureNotImplementedException( "XParameters::updateBinaryStream", *this ); + try + { + SDBThreadAttach t; + { + + // temporaere Variable initialisieren + // Java-Call absetzen + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "(ILjava/io/InputStream;I)V"; + static const char * cMethodName = "updateBinaryStream"; + obtainMethodId(t.pEnv, cMethodName,cSignature, mID); + } + + { + // Parameter konvertieren + jobject obj = createByteInputStream(x,length); + t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + } + } + } + catch(Exception) + { + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this ); + } } // ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" ); - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + try + { + SDBThreadAttach t; + { + + // temporaere Variable initialisieren + // Java-Call absetzen + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "(ILjava/io/Reader;I)V"; + static const char * cMethodName = "updateCharacterStream"; + obtainMethodId(t.pEnv, cMethodName,cSignature, mID); + } + + { + // Parameter konvertieren + jobject obj = createCharArrayReader(x,length); + t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + } + } + } + catch(Exception) + { + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + } } // ------------------------------------------------------------------------- void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index daaed46acdd9..f77c45d66fc8 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -218,5 +218,58 @@ sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear) return bRet; } - - +// ----------------------------------------------------------------------------- +jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) +{ + SDBThreadAttach t; + if( !t.pEnv || !x.is() ) + return NULL; + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream"); + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "([B)V"; + mID = t.pEnv->GetMethodID( clazz, "", cSignature ); + OSL_ENSURE( mID, cSignature ); + if ( !mID ) + throw SQLException(); + } // if ( !_inout_MethodID ) + jbyteArray pByteArray = t.pEnv->NewByteArray(length); + Sequence< sal_Int8 > aData; + x->readBytes(aData,length); + jboolean p = sal_False; + rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength()); + jobject out = t.pEnv->NewObject( clazz, mID,pByteArray); + t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); + return out; +} +// ----------------------------------------------------------------------------- +jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) +{ + SDBThreadAttach t; + if( !t.pEnv || !x.is() ) + return NULL; + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader"); + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "([C)V"; + mID = t.pEnv->GetMethodID( clazz, "", cSignature ); + OSL_ENSURE( mID, cSignature ); + if ( !mID ) + throw SQLException(); + } // if ( !_inout_MethodID ) + jcharArray pCharArray = t.pEnv->NewCharArray(length); + Sequence< sal_Int8 > aData; + x->readBytes(aData,length); + jboolean p = sal_False; + rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength()); + jobject out = t.pEnv->NewObject( clazz, mID,pCharArray); + t.pEnv->DeleteLocalRef((jcharArray)pCharArray); + return out; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx index af061d5599b7..a74865817ddb 100644 --- a/connectivity/source/inc/java/tools.hxx +++ b/connectivity/source/inc/java/tools.hxx @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -85,6 +86,9 @@ namespace connectivity if an exception is occured */ sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear); + + jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); + jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); } #endif // _CONNECTIVITY_JAVA_TOOLS_HXX_ -- cgit From 6d2f6cf1f9137fd17273f099d7fa8284c6f8c81d Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 13 Nov 2009 13:50:51 +0100 Subject: dba33b: #i106875# JavaDriverClassPath will now be read inside the JDBC driver --- connectivity/source/drivers/jdbc/JConnection.cxx | 18 +++++++++++++++++- connectivity/source/drivers/jdbc/makefile.mk | 1 + connectivity/source/inc/java/sql/Connection.hxx | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index f7bbe5ee258a..9e967a65b85d 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -56,6 +56,7 @@ #include #include #include "resource/common_res.hrc" +#include #include #include @@ -766,7 +767,20 @@ void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDri enableAutoRetrievingEnabled( bAutoRetrievingEnabled ); setAutoRetrievingStatement( sGeneratedValueStatement ); } - +// ----------------------------------------------------------------------------- +::rtl::OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass) +{ + static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths")); + ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( + m_pDriver->getContext().getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); + ::rtl::OUString sURL; + if ( aNamesRoot.isValid() && aNamesRoot.hasByName( _sDriverClass ) ) + { + ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( _sDriverClass ); + OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL ); + } + return sURL; +} // ----------------------------------------------------------------------------- sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info) @@ -789,6 +803,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, ::comphelper::NamedValueCollection aSettings( info ); sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass ); sDriverClassPath = aSettings.getOrDefault( "JavaDriverClassPath", sDriverClassPath); + if ( !sDriverClassPath.getLength() ) + sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass); bAutoRetrievingEnabled = aSettings.getOrDefault( "IsAutoRetrievingEnabled", bAutoRetrievingEnabled ); sGeneratedValueStatement = aSettings.getOrDefault( "AutoRetrievingStatement", sGeneratedValueStatement ); m_bParameterSubstitution = aSettings.getOrDefault( "ParameterNameSubstitution", m_bParameterSubstitution ); diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk index 831a6755af91..fb37a3077743 100644 --- a/connectivity/source/drivers/jdbc/makefile.mk +++ b/connectivity/source/drivers/jdbc/makefile.mk @@ -95,6 +95,7 @@ SHL1STDLIBS=\ $(SALLIB) \ $(JVMACCESSLIB) \ $(DBTOOLSLIB) \ + $(UNOTOOLSLIB) \ $(JVMFWKLIB) \ $(COMPHELPERLIB) diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx index 74d76d32f35a..41c18848021f 100644 --- a/connectivity/source/inc/java/sql/Connection.hxx +++ b/connectivity/source/inc/java/sql/Connection.hxx @@ -80,6 +80,11 @@ namespace connectivity const ::rtl::OUString& _sDriverClassPath, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties ); + /** load driver class path from system configuration. + @param _sDriverClass + The driver class name to look for in the configuration. + */ + ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass); protected: // statische Daten fuer die Klasse -- cgit From 9813c4bf4dd812123b9be5a4c548926df06456ee Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 13 Nov 2009 14:23:39 +0100 Subject: missing line end --- connectivity/source/parse/sqliterator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index e8111f174486..54ab874f70e1 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -2168,4 +2168,5 @@ sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNo } return nType; -} \ No newline at end of file +} + -- cgit From 9f4b70361a912d3611897bcc2cc54b6570a133cb Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 13 Nov 2009 14:28:22 +0100 Subject: rename var --- connectivity/source/commontools/BlobHelper.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx index 46fdee9a78b5..5859db9036ac 100644 --- a/connectivity/source/commontools/BlobHelper.cxx +++ b/connectivity/source/commontools/BlobHelper.cxx @@ -47,11 +47,11 @@ BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) return m_aValue.getLength(); } // ----------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 _length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - if ( sal_Int32(pos + length) > m_aValue.getLength() ) + if ( sal_Int32(pos + _length) > m_aValue.getLength() ) throw ::com::sun::star::sdbc::SQLException(); - return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),length); + return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length); } // ----------------------------------------------------------------------------- ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -- cgit From adcbc9187644e1463114baa16011ad3fc8401fd4 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 16 Nov 2009 12:01:50 +0100 Subject: in preparation of #i84012#: introduced a dedicated interface (css.sdb.XDatabaseRegistrations) for dealing with data source registrations, this way hiding the concrete configuration details. --- .../schema/org/openoffice/Office/DataAccess.xcs | 8 +- svx/source/cui/dbregisterednamesconfig.cxx | 171 +++++++-------------- 2 files changed, 63 insertions(+), 116 deletions(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs index cb684017c7c3..3755945df3f6 100644 --- a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs @@ -38,9 +38,9 @@ OJ - + - Describes how to establish a database connection and how to filter and layout the database data. + describes a single database document registration. @@ -310,9 +310,9 @@ - + - Specifies all names which are registered. + Specifies the database documents registered within OpenOffice.org, for quick access by a programmatic name. diff --git a/svx/source/cui/dbregisterednamesconfig.cxx b/svx/source/cui/dbregisterednamesconfig.cxx index 4f9cf1150422..71b776bf59fc 100644 --- a/svx/source/cui/dbregisterednamesconfig.cxx +++ b/svx/source/cui/dbregisterednamesconfig.cxx @@ -35,22 +35,22 @@ #undef SVX_DLLIMPLEMENTATION #endif +#include "connpooloptions.hxx" #include "dbregisterednamesconfig.hxx" +#include "dbregistersettings.hxx" +#include "svx/svxids.hrc" +#include +#include -#include -#include - -#include -#include +#include #include -#include -#include -#include #include +#include +#include #include -#include "dbregistersettings.hxx" -#include "connpooloptions.hxx" +#include +#include //........................................................................ namespace svx @@ -59,136 +59,83 @@ namespace svx using namespace ::utl; using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::container; - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbRegisteredNamesNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbNameNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbLocationNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location"); - return s_sNodeName; - } - //==================================================================== //= DbRegisteredNamesConfig //==================================================================== //-------------------------------------------------------------------- void DbRegisteredNamesConfig::GetOptions(SfxItemSet& _rFillItems) { - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); - TNameLocationMap aSettings; - // then look for which of them settings are stored in the configuration - Sequence< ::rtl::OUString > aDriverKeys = aDbRegisteredNamesRoot.getNodeNames(); - const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); - const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) + try + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XDatabaseRegistrations > xRegistrations( + aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + + Sequence< ::rtl::OUString > aRegistrationNames( xRegistrations->getRegistrationNames() ); + const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray(); + const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); + for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) + { + ::rtl::OUString sLocation( xRegistrations->getDatabaseLocation( *pRegistrationName ) ); + aSettings[ *pRegistrationName ] = sLocation; + } + } + catch( const Exception& ) { - // the name of the driver in this round - OConfigurationNode aThisDriverSettings = aDbRegisteredNamesRoot.openNode(*pDriverKeys); - ::rtl::OUString sName, sLocation; - aThisDriverSettings.getNodeValue(getDbNameNodeName()) >>= sName; - aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sLocation; - sLocation = SvtPathOptions().SubstituteVariable(sLocation); - - aSettings.insert(TNameLocationMap::value_type(sName,sLocation)); + DBG_UNHANDLED_EXCEPTION(); } - _rFillItems.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aSettings)); + _rFillItems.Put( DatabaseMapItem( SID_SB_DB_REGISTER, aSettings ) ); } //-------------------------------------------------------------------- void DbRegisteredNamesConfig::SetOptions(const SfxItemSet& _rSourceItems) { - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE); - - if (!aDbRegisteredNamesRoot.isValid()) - // already asserted by the OConfigurationTreeRoot + // the settings for the single drivers + SFX_ITEMSET_GET( _rSourceItems, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + if ( !pRegistrations ) return; - sal_Bool bNeedCommit = sal_False; - - - // the settings for the single drivers - SFX_ITEMSET_GET( _rSourceItems, pDriverSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); - if (pDriverSettings) + try { - Reference< XNameAccess > xDatabaseContext = Reference< XNameAccess >(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseContext"))), UNO_QUERY); - Reference< XNamingService> xNamingService(xDatabaseContext,UNO_QUERY); - ::rtl::OUString sName, sLocation; - OConfigurationNode aThisDriverSettings; - - const TNameLocationMap& rNewSettings = pDriverSettings->getSettings(); - TNameLocationMap::const_iterator aEnd = rNewSettings.end(); - for ( TNameLocationMap::const_iterator aLoop = rNewSettings.begin(); - aLoop != aEnd; - ++aLoop + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XDatabaseRegistrations > xRegistrations( + aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + + const TNameLocationMap& rNewRegistrations = pRegistrations->getSettings(); + for ( TNameLocationMap::const_iterator reg = rNewRegistrations.begin(); + reg != rNewRegistrations.end(); + ++reg ) { - // need the name as ::rtl::OUString - sName = aLoop->first; - - // the sub-node for this driver - if (aDbRegisteredNamesRoot.hasByName(sName)) - { - aThisDriverSettings = aDbRegisteredNamesRoot.openNode(sName); - // set the values - aThisDriverSettings.setNodeValue(getDbNameNodeName(), makeAny(sName)); - aThisDriverSettings.setNodeValue(getDbLocationNodeName(), makeAny(aLoop->second)); - bNeedCommit = sal_True; - } + const ::rtl::OUString sName = reg->first; + const ::rtl::OUString sLocation = reg->second; + + if ( xRegistrations->hasRegisteredDatabase( sName ) ) + xRegistrations->changeDatabaseLocation( sName, sLocation ); else - { - try - { - xNamingService->registerObject(sName,Reference< ::com::sun::star::uno::XInterface >(xDatabaseContext->getByName(aLoop->second),UNO_QUERY)); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } + xRegistrations->registerDatabaseLocation( sName, sLocation ); } - if (bNeedCommit) - aDbRegisteredNamesRoot.commit(); - - // delete unused entry - Sequence< ::rtl::OUString > aDriverKeys = xDatabaseContext->getElementNames(); - const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); - const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) + + // delete unused entries + Sequence< ::rtl::OUString > aRegistrationNames = xRegistrations->getRegistrationNames(); + const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray(); + const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); + for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) { - if ( rNewSettings.find(*pDriverKeys) == rNewSettings.end() ) - { - try - { - xNamingService->revokeObject(*pDriverKeys); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } + if ( rNewRegistrations.find( *pRegistrationName ) == rNewRegistrations.end() ) + xRegistrations->revokeDatabaseLocation( *pRegistrationName ); } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //........................................................................ -- cgit From ba27e603596f2ce6e68664e869315553a364605c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 16 Nov 2009 13:37:25 +0100 Subject: #i84012# respect data source registrations which are read-only --- svx/source/cui/dbregister.cxx | 147 ++++++++++++++++------------- svx/source/cui/dbregister.hxx | 2 +- svx/source/cui/dbregisterednamesconfig.cxx | 23 +++-- svx/source/cui/dbregistersettings.cxx | 18 ++-- svx/source/cui/dbregistersettings.hxx | 40 +++++++- 5 files changed, 144 insertions(+), 86 deletions(-) diff --git a/svx/source/cui/dbregister.cxx b/svx/source/cui/dbregister.cxx index a1b24691a280..1a5b0019ee9d 100644 --- a/svx/source/cui/dbregister.cxx +++ b/svx/source/cui/dbregister.cxx @@ -197,7 +197,7 @@ DbRegistrationOptionsPage::~DbRegistrationOptionsPage() pHeaderBar->Hide(); for ( USHORT i = 0; i < pPathBox->GetEntryCount(); ++i ) - delete static_cast(pPathBox->GetEntry(i)->GetUserData()); + delete static_cast< DatabaseRegistration* >( pPathBox->GetEntry(i)->GetUserData() ); delete pPathBox; delete pHeaderBar; } @@ -216,21 +216,22 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet ) { // the settings for the single drivers sal_Bool bModified = sal_False; - TNameLocationMap aMap; + DatabaseRegistrations aRegistrations; ULONG nCount = pPathBox->GetEntryCount(); for ( ULONG i = 0; i < nCount; ++i ) { SvLBoxEntry* pEntry = pPathBox->GetEntry(i); - String* pPath = static_cast(pEntry->GetUserData()); - if ( pPath && pPath->Len() ) + DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + if ( pRegistration && pRegistration->sLocation.getLength() ) { - OFileNotation aTransformer(*pPath); - aMap.insert(TNameLocationMap::value_type(::rtl::OUString(pPathBox->GetEntryText(pEntry,0)),aTransformer.get(OFileNotation::N_URL))); + ::rtl::OUString sName( pPathBox->GetEntryText( pEntry, 0 ) ); + OFileNotation aTransformer( pRegistration->sLocation ); + aRegistrations[ sName ] = DatabaseRegistration( aTransformer.get( OFileNotation::N_URL ), pRegistration->bReadOnly ); } } - if ( m_nOldCount != aMap.size() || m_bModified ) + if ( m_nOldCount != aRegistrations.size() || m_bModified ) { - rCoreSet.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aMap), SID_SB_DB_REGISTER); + rCoreSet.Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ), SID_SB_DB_REGISTER); bModified = sal_True; } @@ -242,47 +243,44 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet ) void DbRegistrationOptionsPage::Reset( const SfxItemSet& rSet ) { // the settings for the single drivers - SFX_ITEMSET_GET( rSet, pSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + SFX_ITEMSET_GET( rSet, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + if ( !pRegistrations ) + return; - if ( pSettings ) + pPathBox->Clear(); + + const DatabaseRegistrations& rRegistrations = pRegistrations->getRegistrations(); + m_nOldCount = rRegistrations.size(); + DatabaseRegistrations::const_iterator aIter = rRegistrations.begin(); + DatabaseRegistrations::const_iterator aEnd = rRegistrations.end(); + for ( ; aIter != aEnd; ++aIter ) + { + OFileNotation aTransformer( aIter->second.sLocation ); + insertNewEntry( aIter->first, aTransformer.get( OFileNotation::N_SYSTEM ), aIter->second.bReadOnly ); + } + + String aUserData = GetUserData(); + if ( aUserData.Len() ) { - // TabListBox f"ullen - pPathBox->Clear(); - - const TNameLocationMap& rMap = pSettings->getSettings(); - m_nOldCount = rMap.size(); - TNameLocationMap::const_iterator aIter = rMap.begin(); - TNameLocationMap::const_iterator aEnd = rMap.end(); - for (; aIter != aEnd; ++aIter) + // Spaltenbreite restaurieren + pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() ); + HeaderEndDrag_Impl( NULL ); + // Sortierrichtung restaurieren + BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32(); + HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE); + + if ( bUp ) { - OFileNotation aTransformer(aIter->second); - insertNewEntry(aIter->first,aTransformer.get(OFileNotation::N_SYSTEM)); + nBits &= ~HIB_UPARROW; + nBits |= HIB_DOWNARROW; } - - String aUserData = GetUserData(); - - if ( aUserData.Len() ) + else { - // Spaltenbreite restaurieren - pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() ); - HeaderEndDrag_Impl( NULL ); - // Sortierrichtung restaurieren - BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32(); - HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE); - - if ( bUp ) - { - nBits &= ~HIB_UPARROW; - nBits |= HIB_DOWNARROW; - } - else - { - nBits &= ~HIB_DOWNARROW; - nBits |= HIB_UPARROW; - } - pHeaderBar->SetItemBits( ITEMID_TYPE, nBits ); - HeaderSelect_Impl( NULL ); + nBits &= ~HIB_DOWNARROW; + nBits |= HIB_UPARROW; } + pHeaderBar->SetItemBits( ITEMID_TYPE, nBits ); + HeaderSelect_Impl( NULL ); } } @@ -323,16 +321,19 @@ IMPL_LINK( DbRegistrationOptionsPage, NewHdl, void *, EMPTYARG ) IMPL_LINK( DbRegistrationOptionsPage, EditHdl, void *, EMPTYARG ) { SvLBoxEntry* pEntry = pPathBox->GetCurEntry(); - if ( pEntry ) - { - String* pOldLocation = static_cast(pEntry->GetUserData()); - String sOldName = pPathBox->GetEntryText(pEntry,0); - m_pCurEntry = pEntry; - openLinkDialog(sOldName,*pOldLocation,pEntry); - m_pCurEntry = NULL; - } + if ( !pEntry ) + return 0L; - return 0; + DatabaseRegistration* pOldRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + if ( !pOldRegistration || pOldRegistration->bReadOnly ) + return 0L; + + String sOldName = pPathBox->GetEntryText(pEntry,0); + m_pCurEntry = pEntry; + openLinkDialog( sOldName, pOldRegistration->sLocation, pEntry ); + m_pCurEntry = NULL; + + return 1L; } // ----------------------------------------------------------------------- @@ -397,28 +398,42 @@ IMPL_LINK( DbRegistrationOptionsPage, HeaderEndDrag_Impl, HeaderBar*, pBar ) // ----------------------------------------------------------------------- IMPL_LINK( DbRegistrationOptionsPage, PathSelect_Impl, SvTabListBox *, EMPTYARG ) - -/* [Beschreibung] - -*/ - { SvLBoxEntry* pEntry = pPathBox->FirstSelected(); - m_aEdit.Enable( pEntry != NULL); - m_aDelete.Enable( pEntry != NULL); + bool bReadOnly = true; + if ( pEntry ) + { + DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + bReadOnly = pRegistration->bReadOnly; + } + + m_aEdit.Enable( !bReadOnly ); + m_aDelete.Enable( !bReadOnly ); return 0; } // ----------------------------------------------------------------------------- -void DbRegistrationOptionsPage::insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation) +void DbRegistrationOptionsPage::insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool _bReadOnly ) { String aStr( _sName ); aStr += '\t'; aStr += String(_sLocation); - SvLBoxEntry* pEntry = pPathBox->InsertEntry( aStr ); - String* pLocation = new String( _sLocation ); - pEntry->SetUserData( pLocation ); + + SvLBoxEntry* pEntry = NULL; + if ( _bReadOnly ) + { + sal_Bool bHighContrast = pPathBox->GetDisplayBackground().GetColor().IsDark(); + Image aLocked( SVX_RES( bHighContrast ? RID_SVXBMP_LOCK_HC : RID_SVXBMP_LOCK ) ); + pEntry = pPathBox->InsertEntry( aStr, aLocked, aLocked ); + } + else + { + pEntry = pPathBox->InsertEntry( aStr ); + } + + pEntry->SetUserData( new DatabaseRegistration( _sLocation, _bReadOnly ) ); } + // ----------------------------------------------------------------------------- String DbRegistrationOptionsPage::getFileLocation(const String& _sLocation) { @@ -489,10 +504,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const String& _sOldName,const Str { if ( _pEntry ) { - delete static_cast(_pEntry->GetUserData()); - pPathBox->GetModel()->Remove(_pEntry); + delete static_cast< DatabaseRegistration* >( _pEntry->GetUserData() ); + pPathBox->GetModel()->Remove( _pEntry ); } - insertNewEntry(sNewName,sNewLocation); + insertNewEntry( sNewName, sNewLocation, false ); m_bModified = sal_True; } } diff --git a/svx/source/cui/dbregister.hxx b/svx/source/cui/dbregister.hxx index 2e1496a42e1c..2e5e9fd4617b 100644 --- a/svx/source/cui/dbregister.hxx +++ b/svx/source/cui/dbregister.hxx @@ -87,7 +87,7 @@ namespace svx @param _sLocation The location of the file. */ - void insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation); + void insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool bReadOnly ); /** opens the LinkDialog to create a register pair @param _sOldName diff --git a/svx/source/cui/dbregisterednamesconfig.cxx b/svx/source/cui/dbregisterednamesconfig.cxx index 71b776bf59fc..e039448952d3 100644 --- a/svx/source/cui/dbregisterednamesconfig.cxx +++ b/svx/source/cui/dbregisterednamesconfig.cxx @@ -66,9 +66,9 @@ namespace svx //= DbRegisteredNamesConfig //==================================================================== //-------------------------------------------------------------------- - void DbRegisteredNamesConfig::GetOptions(SfxItemSet& _rFillItems) + void DbRegisteredNamesConfig::GetOptions( SfxItemSet& _rFillItems ) { - TNameLocationMap aSettings; + DatabaseRegistrations aSettings; try { @@ -82,7 +82,8 @@ namespace svx for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) { ::rtl::OUString sLocation( xRegistrations->getDatabaseLocation( *pRegistrationName ) ); - aSettings[ *pRegistrationName ] = sLocation; + aSettings[ *pRegistrationName ] = + DatabaseRegistration( sLocation, xRegistrations->isDatabaseRegistrationReadOnly( *pRegistrationName ) ); } } catch( const Exception& ) @@ -107,17 +108,25 @@ namespace svx Reference< XDatabaseRegistrations > xRegistrations( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); - const TNameLocationMap& rNewRegistrations = pRegistrations->getSettings(); - for ( TNameLocationMap::const_iterator reg = rNewRegistrations.begin(); + const DatabaseRegistrations& rNewRegistrations = pRegistrations->getRegistrations(); + for ( DatabaseRegistrations::const_iterator reg = rNewRegistrations.begin(); reg != rNewRegistrations.end(); ++reg ) { const ::rtl::OUString sName = reg->first; - const ::rtl::OUString sLocation = reg->second; + const ::rtl::OUString sLocation = reg->second.sLocation; if ( xRegistrations->hasRegisteredDatabase( sName ) ) - xRegistrations->changeDatabaseLocation( sName, sLocation ); + { + if ( !xRegistrations->isDatabaseRegistrationReadOnly( sName ) ) + xRegistrations->changeDatabaseLocation( sName, sLocation ); + else + { + OSL_ENSURE( xRegistrations->getDatabaseLocation( sName ) == sLocation, + "DbRegisteredNamesConfig::SetOptions: somebody changed a read-only registration. How unrespectful." ); + } + } else xRegistrations->registerDatabaseLocation( sName, sLocation ); } diff --git a/svx/source/cui/dbregistersettings.cxx b/svx/source/cui/dbregistersettings.cxx index 45745e3b59cb..abc715ec464a 100644 --- a/svx/source/cui/dbregistersettings.cxx +++ b/svx/source/cui/dbregistersettings.cxx @@ -37,6 +37,8 @@ #include "dbregistersettings.hxx" +#include + //........................................................................ namespace svx { @@ -47,9 +49,9 @@ namespace svx //==================================================================== TYPEINIT1( DatabaseMapItem, SfxPoolItem ) //-------------------------------------------------------------------- - DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings ) - :SfxPoolItem(_nId) - ,m_aSettings(_rSettings) + DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations ) + :SfxPoolItem( _nId ) + ,m_aRegistrations( _rRegistrations ) { } @@ -57,19 +59,19 @@ namespace svx int DatabaseMapItem::operator==( const SfxPoolItem& _rCompare ) const { const DatabaseMapItem* pItem = PTR_CAST(DatabaseMapItem, &_rCompare); - if (!pItem) + if ( !pItem ) return sal_False; - if (m_aSettings.size() != pItem->m_aSettings.size()) + if ( m_aRegistrations.size() != pItem->m_aRegistrations.size() ) return sal_False; - return m_aSettings != pItem->m_aSettings; + return m_aRegistrations == pItem->m_aRegistrations; } //-------------------------------------------------------------------- - SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool * ) const + SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool* ) const { - return new DatabaseMapItem(Which(), m_aSettings); + return new DatabaseMapItem( Which(), m_aRegistrations ); } //-------------------------------------------------------------------- diff --git a/svx/source/cui/dbregistersettings.hxx b/svx/source/cui/dbregistersettings.hxx index ef994e4d0ee2..4e79ae8b398f 100644 --- a/svx/source/cui/dbregistersettings.hxx +++ b/svx/source/cui/dbregistersettings.hxx @@ -39,24 +39,56 @@ namespace svx { //........................................................................ + struct DatabaseRegistration + { + ::rtl::OUString sLocation; + bool bReadOnly; + + DatabaseRegistration() + :sLocation() + ,bReadOnly( true ) + { + } + + DatabaseRegistration( const ::rtl::OUString& _rLocation, const sal_Bool _bReadOnly ) + :sLocation( _rLocation ) + ,bReadOnly( _bReadOnly ) + { + } + + bool operator==( const DatabaseRegistration& _rhs ) const + { + return ( sLocation == _rhs.sLocation ); + // do not take the read-only-ness into account, this is not maintained everywhere, but only + // properly set when filling the struct from the XDatabaseRegistrations data + } + + bool operator!=( const DatabaseRegistration& _rhs ) const + { + return !( this->operator==( _rhs ) ); + } + }; + + typedef ::std::map< ::rtl::OUString, DatabaseRegistration, ::comphelper::UStringLess > DatabaseRegistrations; + //==================================================================== //= DatabaseMapItem //==================================================================== - DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString,TNameLocationMap); class DatabaseMapItem : public SfxPoolItem { protected: - TNameLocationMap m_aSettings; + DatabaseRegistrations m_aRegistrations; public: TYPEINFO(); - DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings ); + DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations ); virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; - const TNameLocationMap& getSettings() const { return m_aSettings; } + const DatabaseRegistrations& + getRegistrations() const { return m_aRegistrations; } }; //........................................................................ -- cgit From 315171ac12d5c1c52dc06a4f4156fa76f86c5adf Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 16 Nov 2009 14:45:02 +0100 Subject: in the course of #i84012#: separate the display name of a database registration from the node name in der underlying configuration (the config structure for this was already there, it was just never used) --- officecfg/registry/data/org/openoffice/Office/DataAccess.xcu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu index 871ef6282299..7aa68980534d 100644 --- a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu +++ b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu @@ -156,7 +156,7 @@ - + $(userurl)/database/biblio.odb -- cgit From 2d7a36f76fc01f2e54f5fba46805f12013b48bfe Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 10 Dec 2009 08:08:38 +0100 Subject: dba33b: post-rebase problem resolution --- connectivity/source/commontools/FValue.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 7f6a8d0f5d03..0a1cb572c522 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -1923,6 +1923,7 @@ namespace detail virtual Reference< XInputStream > getCharacterStream() const = 0; virtual Reference< XBlob > getBlob() const = 0; virtual Reference< XClob > getClob() const = 0; + virtual Any getObject() const = 0; virtual sal_Bool wasNull() const = 0; virtual ~IValueSource() { } @@ -1954,6 +1955,7 @@ namespace detail virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); }; virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); }; virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); }; + virtual Any getObject() const { return m_xRow->getObject( m_nPos, NULL ); }; virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); }; private: @@ -1986,6 +1988,7 @@ namespace detail virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); }; virtual Reference< XBlob > getBlob() const { return m_xColumn->getBlob(); }; virtual Reference< XClob > getClob() const { return m_xColumn->getClob(); }; + virtual Any getObject() const { return m_xColumn->getObject( NULL ); }; virtual sal_Bool wasNull() const { return m_xColumn->wasNull(); }; private: @@ -2089,7 +2092,7 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const setTypeKind(DataType::BLOB); break; case DataType::OTHER: - (*this) = _xRow->getObject(_nPos,NULL); + (*this) = _rValueSource.getObject(); setTypeKind(DataType::OTHER); break; default: -- cgit From 87e5271ca967a93e5acb2605c36554752d2314a8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 11 Dec 2009 11:04:04 +0100 Subject: dba33b: #i10000# --- connectivity/qa/connectivity/tools/makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/qa/connectivity/tools/makefile.mk b/connectivity/qa/connectivity/tools/makefile.mk index c4f2b68f53f1..32aa94c77312 100644 --- a/connectivity/qa/connectivity/tools/makefile.mk +++ b/connectivity/qa/connectivity/tools/makefile.mk @@ -46,7 +46,7 @@ all: #----- compile .java files ----------------------------------------- JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunnerLight.jar -JAVAFILES := $(shell @$(FIND) -name "*.java") +JAVAFILES := $(shell @$(FIND) . -name "*.java") JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:d)$(i:b).class) #----- make a jar from compiled files ------------------------------ -- cgit From 31b72c3f3b632329d01b295d449eac0e38cea58c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 11 Dec 2009 11:08:45 +0100 Subject: dba32e: unxsoli compiler warned about unreachable code detecting an errornous commit this way --- connectivity/source/commontools/dbtools.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index bb088937c313..f00cfe14a9e5 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1955,7 +1955,8 @@ void setObjectWithInfo(const Reference& _xParams, case DataType::BOOLEAN: _xParams->setBoolean(parameterIndex,_rValue); break; - if ( _rValue.isSigned() ) + case DataType::TINYINT: + if ( _rValue.isSigned() ) _xParams->setByte(parameterIndex,_rValue); else _xParams->setShort(parameterIndex,_rValue); -- cgit From f613e609218618a64aa6aabccc865e75c5cb568d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 11 Dec 2009 13:27:14 +0100 Subject: dba33b: solaris compiler didn't like a ; --- svx/source/form/fmservs.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/form/fmservs.cxx b/svx/source/form/fmservs.cxx index feef02baa555..a69a541f3606 100644 --- a/svx/source/form/fmservs.cxx +++ b/svx/source/form/fmservs.cxx @@ -50,7 +50,7 @@ DECL_SERVICE( FmXGridControl ) DECL_SERVICE( FormController ) - DECL_SERVICE( LegacyFormController ); + DECL_SERVICE( LegacyFormController ) // ------------------------------------------------------------------------ -- cgit From 552d36de5623cbcf9b995da239b4f59ce16eb8a5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 11 Dec 2009 13:42:15 +0100 Subject: dba33b: fixed some nits picked by the Solaris compiler --- svx/source/form/filtnav.cxx | 1 - svx/source/form/formdispatchinterceptor.cxx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index dec2f4c0d5a6..d7d9961f8644 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -1897,7 +1897,6 @@ void FmFilterNavigator::KeyInput(const KeyEvent& rKEvt) DeleteSelection(); return; } - break; } SvTreeListBox::KeyInput(rKEvt); diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx index 903d27d6e650..2950b1605b0f 100644 --- a/svx/source/form/formdispatchinterceptor.cxx +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -64,7 +64,7 @@ namespace svxform //= DispatchInterceptionMultiplexer //======================================================================== - DBG_NAME(DispatchInterceptionMultiplexer); + DBG_NAME(DispatchInterceptionMultiplexer) //------------------------------------------------------------------------ DispatchInterceptionMultiplexer::DispatchInterceptionMultiplexer( const Reference< XDispatchProviderInterception >& _rxToIntercept, DispatchInterceptor* _pMaster ) -- cgit From b808bcd158de73623144e9dac18f39e6ec0b9bf0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 6 Jan 2010 08:22:40 +0100 Subject: do not switch off the property browser (and other child windows) with ShowChildWindow, but use ChildWindowExecute, which really destroys the window if necessary --- svx/source/form/fmshell.cxx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 4820cf44978b..5c46f0482b4a 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -684,15 +684,7 @@ void FmFormShell::Execute(SfxRequest &rReq) case SID_FM_FILTER_NAVIGATOR: case SID_FM_SHOW_DATANAVIGATOR : { - SFX_REQUEST_ARG( rReq, pShowItem, SfxBoolItem, nSlot, sal_False ); - if ( !pShowItem ) - GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq ); - else - { - const sal_Bool bShow = pShowItem->GetValue(); - GetViewShell()->GetViewFrame()->ShowChildWindow( nSlot, bShow ); - } - + GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq ); rReq.Done(); } break; case SID_FM_SHOW_FMEXPLORER: -- cgit