diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-06-03 14:33:05 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-06-03 14:33:05 +0200 |
commit | 41b43f2fc66a490780d4751ed64f663fe1c548d7 (patch) | |
tree | bc4c07f29cea406016a10445103b39d0aac598e1 /svx/source/form | |
parent | 05a463c55182efc777e1fee5f708fc36de6eda92 (diff) | |
parent | f8e7afbac976ca862a801b9648fd95b2107757b2 (diff) |
slidecopy: merged latest DEV300.m80 changes
Diffstat (limited to 'svx/source/form')
-rw-r--r-- | svx/source/form/datanavi.cxx | 7 | ||||
-rw-r--r-- | svx/source/form/fmshimp.cxx | 104 | ||||
-rw-r--r-- | svx/source/form/fmundo.cxx | 47 |
3 files changed, 98 insertions, 60 deletions
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index 113b6f185b7b..8ce3d6e7ba7c 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -3683,11 +3683,8 @@ namespace svxform m_aURLED.DisableHistory(); m_aFilePickerBtn.SetClickHdl( LINK( this, AddInstanceDialog, FilePickerHdl ) ); - // load the filter name from svtools resource - ByteString aResMgrName( "svt" ); - ResMgr* pSvtResMgr = ResMgr::CreateResMgr( - aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); - m_sAllFilterName = String( ResId( STR_FILTERNAME_ALL, *pSvtResMgr ) ); + // load the filter name from fps_office resource + m_sAllFilterName = String( ResId( STR_FILTERNAME_ALL, *CREATEVERSIONRESMGR(fps_office) ) ); } AddInstanceDialog::~AddInstanceDialog() diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 2455f92b9b8d..bb18ae76f4e3 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -1578,22 +1578,25 @@ void FmXFormShell::ExecuteSearch() return; // filter out the forms which do not contain valid controls at all - FmFormArray::reverse_iterator form = m_aSearchForms.rbegin(); - ::std::vector< String >::reverse_iterator contextName = aContextNames.rbegin(); - sal_Int32 i = m_aSearchForms.size(); - for ( ; - form != m_aSearchForms.rend(); - ++form, ++contextName, --i - ) { - FmSearchContext aTestContext; - aTestContext.nContext = static_cast< sal_Int16 >( i-1 ); - sal_uInt32 nValidControls = OnSearchContextRequest( &aTestContext ); - if ( nValidControls == 0 ) + FmFormArray aValidForms; + ::std::vector< String > aValidContexts; + FmFormArray::const_iterator form = m_aSearchForms.begin(); + ::std::vector< String >::const_iterator contextName = aContextNames.begin(); + for ( ; form != m_aSearchForms.end(); ++form, ++contextName ) { - m_aSearchForms.erase( form.base() - 1 ); - aContextNames.erase( contextName.base() - 1 ); + FmSearchContext aTestContext; + aTestContext.nContext = static_cast< sal_Int16 >( form - m_aSearchForms.begin() ); + sal_uInt32 nValidControls = OnSearchContextRequest( &aTestContext ); + if ( nValidControls > 0 ) + { + aValidForms.push_back( *form ); + aValidContexts.push_back( *contextName ); + } } + + m_aSearchForms.swap( aValidForms ); + aContextNames.swap( aValidContexts ); } if (m_aSearchForms.size() == 0) @@ -1605,7 +1608,7 @@ void FmXFormShell::ExecuteSearch() // jetzt brauche ich noch einen 'initial context' sal_Int16 nInitialContext = 0; Reference< XForm> xActiveForm( getActiveForm()); - for (i=0; i<(sal_Int32)m_aSearchForms.size(); ++i) + for ( size_t i=0; i<m_aSearchForms.size(); ++i ) { if (m_aSearchForms.at(i) == xActiveForm) { @@ -2372,6 +2375,8 @@ IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere) FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject ); Reference< XControlModel > xControlModel( pFormObject ? pFormObject->GetUnoControlModel() : Reference< XControlModel >() ); DBG_ASSERT( xControlModel.is(), "FmXFormShell::OnFoundData: invalid control!" ); + if ( !xControlModel.is() ) + return 0; // disable the permanent cursor for the last grid we found a record if (m_xLastGridFound.is() && (m_xLastGridFound != xControlModel)) @@ -2389,7 +2394,7 @@ IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere) sal_Int32 nGridColumn = m_arrRelativeGridColumn.GetObject(pfriWhere->nFieldPos); if (nGridColumn != -1) { // dummer weise muss ich mir das Control erst wieder besorgen - Reference< XControl> xControl( GetControlFromModel(xControlModel)); + Reference< XControl> xControl( impl_getControl( xControlModel, *pFormObject ) ); Reference< XGrid> xGrid(xControl, UNO_QUERY); DBG_ASSERT(xGrid.is(), "FmXFormShell::OnFoundData : ungueltiges Control !"); // wenn eine der Asserts anschlaegt, habe ich beim Aufbauen von m_arrSearchedControls wohl was falsch gemacht @@ -2401,7 +2406,8 @@ IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere) xModelSet->setPropertyValue( FM_PROP_CURSORCOLOR, makeAny( sal_Int32( COL_LIGHTRED ) ) ); m_xLastGridFound = xControlModel; - xGrid->setCurrentColumnPosition((sal_Int16)nGridColumn); + if ( xGrid.is() ) + xGrid->setCurrentColumnPosition((sal_Int16)nGridColumn); } // als der Cursor neu positioniert wurde, habe ich (in positioned) meine Formularleisten-Slots invalidiert, aber das greift @@ -2509,7 +2515,7 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn // ... nach der ControlSource-Eigenschaft fragen SearchableControlIterator iter( xCurrentFormComponent ); - Reference< XControl> xControlBehindModel; + Reference< XControl> xControl; // das Control, das als Model xControlModel hat // (das folgende while kann mehrmals durchlaufen werden, ohne dass das Control sich aendert, dann muss // ich nicht jedesmal neu suchen) @@ -2521,10 +2527,12 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn if ( sControlSource.getLength() == 0 ) { // das aktuelle Element hat keine ControlSource, also ist es ein GridControl (das ist das einzige, was // der SearchableControlIterator noch zulaesst) - xControlBehindModel = GetControlFromModel(xControlModel); - DBG_ASSERT(xControlBehindModel.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !"); + xControl = impl_getControl( xControlModel, *pFormObject ); + DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !"); - Reference< XGridPeer> xGridPeer(xControlBehindModel->getPeer(), UNO_QUERY); + Reference< XGridPeer> xGridPeer; + if ( xControl.is() ) + xGridPeer.set( xControl->getPeer(), UNO_QUERY ); do { if (!xGridPeer.is()) @@ -2578,13 +2586,13 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn if (sControlSource.getLength() && xValidFormFields->hasByName(sControlSource)) { // jetzt brauche ich das Control zum SdrObject - if (!xControlBehindModel.is()) + if (!xControl.is()) { - xControlBehindModel = GetControlFromModel(xControlModel); - DBG_ASSERT(xControlBehindModel.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !"); + xControl = impl_getControl( xControlModel, *pFormObject ); + DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !"); } - if (IsSearchableControl(xControlBehindModel)) + if (IsSearchableControl(xControl)) { // alle Tests ueberstanden -> in die Liste mit aufnehmen strFieldList += sControlSource.getStr(); strFieldList += ';'; @@ -2600,7 +2608,7 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn m_arrRelativeGridColumn.Insert(-1, m_arrRelativeGridColumn.Count()); // und fuer die formatierte Suche ... - pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControlBehindModel, UNO_QUERY)); + pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControl, UNO_QUERY)); } } } @@ -2974,24 +2982,48 @@ void FmXFormShell::SetDesignMode(sal_Bool bDesign) } //------------------------------------------------------------------------------ -Reference< XControl> FmXFormShell::GetControlFromModel(const Reference< XControlModel>& xModel) +Reference< XControl> FmXFormShell::impl_getControl( const Reference< XControlModel >& i_rxModel, const FmFormObj& i_rKnownFormObj ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::GetControlFromModel" ); if ( impl_checkDisposed() ) return NULL; - Reference< XControlContainer> xControlContainer( getControlContainerForView() ); + Reference< XControl > xControl; + try + { + Reference< XControlContainer> xControlContainer( getControlContainerForView(), UNO_SET_THROW ); - Sequence< Reference< XControl> > seqControls( xControlContainer->getControls() ); - Reference< XControl>* pControls = seqControls.getArray(); - // ... die ich dann durchsuchen kann - for (int i=0; i<seqControls.getLength(); ++i) + Sequence< Reference< XControl > > seqControls( xControlContainer->getControls() ); + const Reference< XControl >* pControls = seqControls.getArray(); + // ... die ich dann durchsuchen kann + for (sal_Int32 i=0; i<seqControls.getLength(); ++i) + { + xControl.set( pControls[i], UNO_SET_THROW ); + Reference< XControlModel > xCurrentModel( xControl->getModel() ); + if ( xCurrentModel == i_rxModel ) + break; + xControl.clear(); + } + + if ( !xControl.is() ) + { + // fallabck (some controls might not have been created, yet, since they were never visible so far) + Reference< XControl > xContainerControl( xControlContainer, UNO_QUERY_THROW ); + const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerControl->getPeer() ); + ENSURE_OR_THROW( pContainerWindow, "unexpected control container implementation" ); + + const SdrView* pSdrView = m_pShell ? m_pShell->GetFormView() : NULL; + ENSURE_OR_THROW( pSdrView, "no current view" ); + + xControl.set( i_rKnownFormObj.GetUnoControl( *pSdrView, *pContainerWindow ), UNO_QUERY_THROW ); + } + } + catch( const Exception& ) { - Reference< XControlModel> xSearchLoopModel( pControls[i]->getModel()); - if ((XControlModel*)xSearchLoopModel.get() == (XControlModel*)xModel.get()) - return pControls[i]; + DBG_UNHANDLED_EXCEPTION(); } - return Reference< XControl>(NULL); + + OSL_ENSURE( xControl.is(), "FmXFormShell::impl_getControl: no control found!" ); + return xControl; } //------------------------------------------------------------------------------ diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index ba7ba492c2fb..e6559850ea5d 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -90,25 +90,7 @@ class ScriptEventListenerWrapper : public ScriptEventListener_BASE public: ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel) { - Reference < XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - if ( xProps.is() ) - { - Reference< XComponentContext > xCtx( xProps->getPropertyValue( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); - if ( xCtx.is() ) - { - Reference< XMultiComponentFactory > xMFac( - xCtx->getServiceManager(), UNO_QUERY ); - if ( xMFac.is() ) - { - m_vbaListener.set( xMFac->createInstanceWithContext( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "ooo.vba.EventListener" ) ), xCtx ), - UNO_QUERY_THROW ); - } - } - } + } // XEventListener virtual void SAL_CALL disposing(const EventObject& ) throw( RuntimeException ){} @@ -136,6 +118,33 @@ public: private: void setModel() { + if ( !m_vbaListener.is() ) + { + Reference < XPropertySet > xProps( + ::comphelper::getProcessServiceFactory(), UNO_QUERY ); + if ( xProps.is() ) + { + Reference< XComponentContext > xCtx( xProps->getPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); + if ( xCtx.is() ) + { + Reference< XMultiComponentFactory > xMFac( + xCtx->getServiceManager(), UNO_QUERY ); + SfxObjectShellRef xObjSh = pModel->GetObjectShell(); + Reference< XMultiServiceFactory > xDocFac; + if ( xObjSh.Is() ) + xDocFac.set( xObjSh->GetModel(), UNO_QUERY ); + + if ( xMFac.is() ) + { + m_vbaListener.set( xMFac->createInstanceWithContext( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "ooo.vba.EventListener" ) ), xCtx ), + UNO_QUERY_THROW ); + } + } + } + } Reference< XPropertySet > xProps( m_vbaListener, UNO_QUERY ); if ( xProps.is() ) { |