diff options
Diffstat (limited to 'svx/source/form/fmshimp.cxx')
-rw-r--r-- | svx/source/form/fmshimp.cxx | 463 |
1 files changed, 337 insertions, 126 deletions
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 4d265d324820..38df41896f13 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -30,89 +30,88 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "gridcols.hxx" -#include <svx/obj3d.hxx> -#include "fmvwimp.hxx" -#include "fmshimp.hxx" -#include "fmtextcontrolshell.hxx" -#include <svx/svdpagv.hxx> -#include <svx/fmpage.hxx> -#include <svx/dialmgr.hxx> -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif + #include "fmitems.hxx" #include "fmobj.hxx" -#include "formtoolbars.hxx" -#include <svx/fmglob.hxx> -#include "svditer.hxx" -#include "fmservs.hxx" #include "fmpgeimp.hxx" #include "svx/fmtools.hxx" -#ifndef _SVX_FMPROP_HRC #include "fmprop.hrc" -#endif -#include <svx/fmshell.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#include <svx/fmmodel.hxx> +#include "fmresids.hrc" +#include "fmservs.hxx" +#include "fmshimp.hxx" +#include "fmtextcontrolshell.hxx" #include "fmundo.hxx" #include "fmurl.hxx" -#include "formcontrolling.hxx" -#include <svx/svxdlg.hxx> -#include <svx/dialogs.hrc> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/form/XLoadable.hpp> -#include <com/sun/star/container/XNamed.hpp> +#include "fmvwimp.hxx" +#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 <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XListBox.hpp> -#include <com/sun/star/awt/XCheckBox.hpp> -#include <com/sun/star/form/XBoundComponent.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/form/ListSourceType.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> #include <com/sun/star/form/XBoundControl.hpp> -#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/form/XGrid.hpp> #include <com/sun/star/form/XGridPeer.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/util/XModeSelector.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/form/binding/XBindableValue.hpp> -#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/form/binding/XListEntrySink.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/util/XModeSelector.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> +/** === end UNO includes === **/ + +#include <comphelper/extract.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/property.hxx> +#include <comphelper/stl_types.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/servicefactory.hxx> #include <osl/mutex.hxx> -#include <sfx2/viewsh.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/frame.hxx> -#include <vcl/waitobj.hxx> -#include <tools/shl.hxx> -#include <tools/diagnose_ex.h> -#include <vcl/msgbox.hxx> +#include <rtl/logfile.hxx> #include <sfx2/dispatch.hxx> -#include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/viewsh.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <tools/color.hxx> +#include <tools/diagnose_ex.h> +#include <tools/shl.hxx> #include <tools/urlobj.hxx> -#include <comphelper/property.hxx> -#include <connectivity/dbtools.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/processfactory.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <comphelper/extract.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include <svx/sdrpagewindow.hxx> -#include <rtl/logfile.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/waitobj.hxx> +#include <vos/mutex.hxx> #include <algorithm> #include <functional> @@ -281,6 +280,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; @@ -289,7 +289,7 @@ using namespace ::svx; //============================================================================== namespace { - //.................................................................... + //.......................................................................... void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces ) { _rInterfaces.clear(); @@ -327,6 +327,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; i<rColumns->getCount(); ++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 (i<rColumns->getCount()) + 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;i<pType->nMembers;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<typelib_InterfaceMemberTypeDescription*>(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<rTransferIfAvailable.getLength(); ++i, ++pCurrent) + { + // search the model/control idl classes for the event described by pCurrent + for ( Sequence< Type>* pCurrentArray = &aModelListeners; + pCurrentArray; + pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL + ) + { + const Type* pCurrentListeners = pCurrentArray->getConstArray(); + for (j=0; j<pCurrentArray->getLength(); ++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; k<aMethodsNames.getLength(); ++k, ++pMethodsNames) + { + if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != 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 (k<aMethodsNames.getLength()) + break; + } + } + } + + sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray(); + aTransferable.realloc(nRealNewLen); + + xEventManager->registerScriptEvents(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(); + } + } //------------------------------------------------------------------------------ @@ -504,7 +696,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 ) @@ -675,7 +866,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 +957,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 +969,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 ); } @@ -798,14 +990,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; @@ -1703,7 +1887,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 +1903,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 +1992,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 +2287,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,31 +3120,39 @@ 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); if (xModeSelector.is()) - xModeSelector->setMode(FILTER_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); } } 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 ); + } } //------------------------------------------------------------------------------ -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; @@ -2995,7 +3187,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 @@ -3004,13 +3196,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,18 +3227,18 @@ 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) { 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 { - 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 +3279,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++) { @@ -3132,7 +3324,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 @@ -3141,8 +3333,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 +3445,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 +3521,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 +3663,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 +3730,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; @@ -3557,28 +3749,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); @@ -3876,7 +4048,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); } @@ -4162,6 +4335,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 */ ) { @@ -4206,7 +4417,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 |