2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* $ RCSfile : fmvwimp . cxx , v $
*
2001-07-25 12:44:28 +00:00
* $ Revision : 1.11 $
2000-09-18 16:07:07 +00:00
*
2001-07-25 12:44:28 +00:00
* last change : $ Author : fs $ $ Date : 2001 - 07 - 25 13 : 43 : 36 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc . , October , 2000
*
* GNU Lesser General Public License Version 2.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Copyright 2000 by Sun Microsystems , Inc .
* 901 San Antonio Road , Palo Alto , CA 94303 , USA
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 , as published by the Free Software Foundation .
*
* This library 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 for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston ,
* MA 02111 - 1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 ( the " License " ) ; You may not use this file
* except in compliance with the License . You may obtain a copy of the
* License at http : //www.openoffice.org/license.html.
*
* Software provided under this License is provided on an " AS IS " basis ,
* WITHOUT WARRANTY OF ANY KIND , EITHER EXPRESSED OR IMPLIED , INCLUDING ,
* WITHOUT LIMITATION , WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS ,
* MERCHANTABLE , FIT FOR A PARTICULAR PURPOSE , OR NON - INFRINGING .
* See the License for the specific provisions governing your rights and
* obligations concerning the Software .
*
* The Initial Developer of the Original Code is : Sun Microsystems , Inc .
*
* Copyright : 2000 by Sun Microsystems , Inc .
*
* All Rights Reserved .
*
* Contributor ( s ) : _______________________________________
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# pragma hdrstop
# ifndef _SVX_FMCTRLER_HXX
# include <fmctrler.hxx>
# endif
# ifndef _SVX_FMVWIMP_HXX
# include "fmvwimp.hxx"
# endif
# ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
# include <com/sun/star/sdbc/XRowSet.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
# include <com/sun/star/form/XLoadable.hpp>
# endif
2001-04-20 15:12:48 +00:00
# ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
# include <com/sun/star/form/FormComponentType.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_XRESET_HPP_
# include <com/sun/star/form/XReset.hpp>
# endif
2000-09-18 16:07:07 +00:00
# ifndef _COM_SUN_STAR_AWT_XTABCONTROLLERMODEL_HPP_
# include <com/sun/star/awt/XTabControllerModel.hpp>
# endif
# ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
# include <com/sun/star/awt/XControlContainer.hpp>
# endif
# ifndef _COM_SUN_STAR_AWT_XTABCONTROLLER_HPP_
# include <com/sun/star/awt/XTabController.hpp>
# endif
2000-11-06 06:19:53 +00:00
# ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
# include <com/sun/star/container/XIndexAccess.hpp>
# endif
2000-09-18 16:07:07 +00:00
# ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_
# include <com/sun/star/awt/XControl.hpp>
# endif
2001-04-20 15:12:48 +00:00
# ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
2000-09-18 16:07:07 +00:00
# include <com/sun/star/lang/XUnoTunnel.hpp>
2001-04-20 15:12:48 +00:00
# endif
# ifndef _SVX_FMMODEL_HXX
2000-09-18 16:07:07 +00:00
# include <fmmodel.hxx>
# endif
# ifndef _SVX_FMUNDO_HXX
# include "fmundo.hxx"
# endif
# ifndef _SVX_FMPAGE_HXX
# include "fmpage.hxx"
# endif
# ifndef _SVX_FMUNOPGE_HXX
# include "fmpgeimp.hxx"
# endif
# ifndef _SVX_FMVIEW_HXX
# include "fmview.hxx"
# endif
# ifndef _SVX_FMSHELL_HXX
# include "fmshell.hxx"
# endif
# ifndef _SVX_FMSHIMP_HXX
# include "fmshimp.hxx"
# endif
# ifndef _SVX_FMTOOLS_HXX
# include "fmtools.hxx"
# endif
# ifndef _SVX_FMPROP_HRC
# include "fmprop.hrc"
# endif
# ifndef _SV_MSGBOX_HXX
# include <vcl/msgbox.hxx>
# endif
# ifndef _SVDPAGV_HXX
# include "svdpagv.hxx"
# endif
2001-03-15 08:02:28 +00:00
# ifndef _COMPHELPER_EXTRACT_HXX_
# include <comphelper/extract.hxx>
2000-10-24 14:22:40 +00:00
# endif
2000-10-20 13:18:57 +00:00
# ifndef _COMPHELPER_ENUMHELPER_HXX_
# include <comphelper/enumhelper.hxx>
2000-09-18 16:07:07 +00:00
# endif
2000-10-20 13:18:57 +00:00
# ifndef _CONNECTIVITY_DBTOOLS_HXX_
# include <connectivity/dbtools.hxx>
2000-09-18 16:07:07 +00:00
# endif
2000-10-24 14:22:40 +00:00
using namespace : : com : : sun : : star : : uno ;
2001-04-20 15:12:48 +00:00
using namespace : : com : : sun : : star : : beans ;
2001-07-25 12:44:28 +00:00
using namespace : : com : : sun : : star : : sdbc ;
2000-10-24 14:22:40 +00:00
using namespace : : com : : sun : : star : : container ;
2000-11-06 06:19:53 +00:00
using namespace : : com : : sun : : star : : form ;
using namespace : : com : : sun : : star : : awt ;
using namespace : : com : : sun : : star : : lang ;
2000-12-18 07:22:38 +00:00
using namespace : : dbtools ;
using namespace : : comphelper ;
using namespace : : svxform ;
2000-09-18 16:07:07 +00:00
DBG_NAME ( FmXPageViewWinRec ) ;
//------------------------------------------------------------------------
2000-11-06 06:19:53 +00:00
FmXPageViewWinRec : : FmXPageViewWinRec ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : lang : : XMultiServiceFactory > & _xORB ,
const SdrPageViewWinRec * pWinRec ,
2000-09-18 16:07:07 +00:00
FmXFormView * _pViewImpl )
: m_pViewImpl ( _pViewImpl )
, m_pWindow ( ( Window * ) pWinRec - > GetOutputDevice ( ) )
2000-11-06 06:19:53 +00:00
, m_xORB ( _xORB )
2000-09-18 16:07:07 +00:00
{
DBG_CTOR ( FmXPageViewWinRec , NULL ) ;
// legt fuer jede ::com::sun::star::form ein FormController an
FmFormPage * pP = NULL ;
if ( m_pViewImpl )
pP = PTR_CAST ( FmFormPage , m_pViewImpl - > getView ( ) - > GetPageViewPvNum ( 0 ) - > GetPage ( ) ) ;
DBG_ASSERT ( pP , " kein Page gefunden " ) ;
if ( pP )
{
2001-04-20 15:12:48 +00:00
Reference < XIndexAccess > xForms ( pP - > GetForms ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
sal_uInt32 nLength = xForms - > getCount ( ) ;
2001-04-20 15:12:48 +00:00
Any aElement ;
Reference < XForm > xForm ;
2000-09-18 16:07:07 +00:00
for ( sal_uInt32 i = 0 ; i < nLength ; i + + )
{
2000-11-06 06:19:53 +00:00
xForms - > getByIndex ( i ) > > = xForm ;
2000-09-18 16:07:07 +00:00
setController ( xForm , pWinRec - > GetControlContainerRef ( ) ) ;
}
}
}
2000-11-06 06:19:53 +00:00
// -----------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00
FmXPageViewWinRec : : ~ FmXPageViewWinRec ( )
{
DBG_DTOR ( FmXPageViewWinRec , NULL ) ;
}
//------------------------------------------------------------------
void FmXPageViewWinRec : : dispose ( )
{
for ( vector < : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > > : : const_iterator i = m_aControllerList . begin ( ) ;
i ! = m_aControllerList . end ( ) ; i + + )
{
// detaching the events
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XChild > xChild ( ( * i ) - > getModel ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xChild . is ( ) )
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : script : : XEventAttacherManager > xEventManager ( xChild - > getParent ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : uno : : XInterface > xIfc ( * i , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
xEventManager - > detach ( i - m_aControllerList . begin ( ) , xIfc ) ;
}
2000-11-06 06:19:53 +00:00
// dispose the formcontroller
2000-09-18 16:07:07 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : lang : : XComponent > xComp ( * i , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
xComp - > dispose ( ) ;
}
2000-11-06 06:19:53 +00:00
m_aControllerList . clear ( ) ; // this call deletes the formcontrollers
m_xORB = NULL ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
sal_Bool SAL_CALL FmXPageViewWinRec : : hasElements ( void ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
return getCount ( ) ! = 0 ;
}
//------------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Type SAL_CALL FmXPageViewWinRec : : getElementType ( void ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
return : : getCppuType ( ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > * ) 0 ) ;
}
// ::com::sun::star::container::XEnumerationAccess
//------------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XEnumeration > SAL_CALL FmXPageViewWinRec : : createEnumeration ( void ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
2000-10-20 13:18:57 +00:00
return new : : comphelper : : OEnumerationByIndex ( this ) ;
2000-09-18 16:07:07 +00:00
}
// ::com::sun::star::container::XIndexAccess
//------------------------------------------------------------------------------
sal_Int32 SAL_CALL FmXPageViewWinRec : : getCount ( void ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
return m_aControllerList . size ( ) ;
}
//------------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Any SAL_CALL FmXPageViewWinRec : : getByIndex ( sal_Int32 nIndex ) throw ( : : com : : sun : : star : : lang : : IndexOutOfBoundsException , : : com : : sun : : star : : lang : : WrappedTargetException , : : com : : sun : : star : : uno : : RuntimeException )
{
if ( nIndex < 0 | |
nIndex > = getCount ( ) )
throw : : com : : sun : : star : : lang : : IndexOutOfBoundsException ( ) ;
: : com : : sun : : star : : uno : : Any aElement ;
aElement < < = m_aControllerList [ nIndex ] ;
return aElement ;
}
//------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > getControllerSearchChilds ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > & xIndex , const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XTabControllerModel > & xModel )
{
if ( xIndex . is ( ) & & xIndex - > getCount ( ) )
{
2000-11-06 06:19:53 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > xController ;
2000-09-18 16:07:07 +00:00
for ( sal_Int32 n = xIndex - > getCount ( ) ; n - - ; )
{
2000-11-06 06:19:53 +00:00
xIndex - > getByIndex ( n ) > > = xController ;
2000-09-18 16:07:07 +00:00
if ( ( : : com : : sun : : star : : awt : : XTabControllerModel * ) xModel . get ( ) = = ( : : com : : sun : : star : : awt : : XTabControllerModel * ) xController - > getModel ( ) . get ( ) )
return xController ;
else
return getControllerSearchChilds ( : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > ( xController , : : com : : sun : : star : : uno : : UNO_QUERY ) , xModel ) ;
}
}
return : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > ( ) ;
}
// Search the according controller
//------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > FmXPageViewWinRec : : getController ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XForm > & xForm )
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XTabControllerModel > xModel ( xForm , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
for ( : : std : : vector < : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > > : : const_iterator i = m_aControllerList . begin ( ) ;
i ! = m_aControllerList . end ( ) ; i + + )
{
if ( ( : : com : : sun : : star : : awt : : XTabControllerModel * ) ( * i ) - > getModel ( ) . get ( ) = = ( : : com : : sun : : star : : awt : : XTabControllerModel * ) xModel . get ( ) )
return * i ;
// the current-round controller isn't the right one. perhaps one of it's children ?
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > xChildSearch = getControllerSearchChilds ( : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > ( * i , : : com : : sun : : star : : uno : : UNO_QUERY ) , xModel ) ;
if ( xChildSearch . is ( ) )
return xChildSearch ;
}
return : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > ( ) ;
}
//------------------------------------------------------------------------
void FmXPageViewWinRec : : setController ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XForm > & xForm ,
const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & xCC ,
FmXFormController * pParent , sal_Bool )
{
DBG_ASSERT ( xForm . is ( ) , " Kein Formular angegeben " ) ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > xFormCps ( xForm , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( ! xFormCps . is ( ) )
return ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XTabControllerModel > xTabOrder ( xForm , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
FmFormPage * pCurrentPage = PTR_CAST ( FmFormPage , m_pViewImpl - > getView ( ) - > GetPageViewPvNum ( 0 ) - > GetPage ( ) ) ;
DBG_ASSERT ( pCurrentPage , " FmXFormController::queryDispatch : could not retrieve my page ! " ) ;
String sPageId = pCurrentPage ? pCurrentPage - > GetImpl ( ) - > GetPageId ( ) : String : : CreateFromAscii ( " no page " ) ;
// this "no page" should result in a empty ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > provided by the controller's external dispatcher
// Anlegen des Tabcontrollers
2000-11-06 06:19:53 +00:00
FmXFormController * pController = new FmXFormController ( m_xORB , m_pViewImpl - > getView ( ) , m_pWindow , sPageId ) ;
2000-09-18 16:07:07 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > xController ( pController ) ;
pController - > setModel ( xTabOrder ) ;
pController - > setContainer ( xCC ) ;
pController - > activateTabOrder ( ) ;
pController - > addActivateListener ( m_pViewImpl ) ;
if ( pParent )
pParent - > addChild ( pController ) ;
else
{
2000-11-06 06:19:53 +00:00
// ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > xController(pController);
2000-09-18 16:07:07 +00:00
m_aControllerList . push_back ( xController ) ;
pController - > setParent ( * this ) ;
// attaching the events
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : script : : XEventAttacherManager > xEventManager ( xForm - > getParent ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : uno : : XInterface > xIfc ( xController , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
xEventManager - > attach ( m_aControllerList . size ( ) - 1 , xIfc , : : com : : sun : : star : : uno : : makeAny ( xController ) ) ;
}
// jetzt die Subforms durchgehen
sal_uInt32 nLength = xFormCps - > getCount ( ) ;
2000-11-06 06:19:53 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XForm > xSubForm ;
2000-09-18 16:07:07 +00:00
for ( sal_uInt32 i = 0 ; i < nLength ; i + + )
{
2000-11-06 06:19:53 +00:00
xFormCps - > getByIndex ( i ) > > = xSubForm ;
if ( xSubForm . is ( ) )
setController ( xSubForm , xCC , pController ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------
void FmXPageViewWinRec : : updateTabOrder ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControl > & xControl ,
const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & xCC )
{
// Das TabControllerModel der ::com::sun::star::form ermitteln, in der das Control
// enthalten ist ...
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormComponent > xFormComp ( xControl - > getModel ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( ! xFormComp . is ( ) )
return ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XForm > xForm ( xFormComp - > getParent ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( ! xForm . is ( ) )
return ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XTabController > xTabCtrl ( getController ( xForm ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
// Wenn es fuer dieses Formular noch keinen Tabcontroller gibt,
// dann einen neuen anlegen
if ( ! xTabCtrl . is ( ) )
{
// ist es ein Unterformular?
// dann muss ein Tabcontroller fuer den Parent existieren
// wichtig da ein hierarchischer Aufbau vorliegt
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XForm > xParentForm ( : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XChild > ( xForm , : : com : : sun : : star : : uno : : UNO_QUERY ) - > getParent ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
FmXFormController * pFormController = NULL ;
// zugehoerigen controller suchen
if ( xParentForm . is ( ) )
xTabCtrl = : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XTabController > ( getController ( xParentForm ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xTabCtrl . is ( ) )
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : lang : : XUnoTunnel > xTunnel ( xTabCtrl , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
DBG_ASSERT ( xTunnel . is ( ) , " FmPropController::ChangeFormatProperty : xTunnel is invalid! " ) ;
if ( xTunnel . is ( ) )
{
pFormController = ( FmXFormController * ) xTunnel - > getSomething ( FmXFormController : : getUnoTunnelImplementationId ( ) ) ;
}
2000-10-20 13:18:57 +00:00
// ::comphelper::getImplementation(pFormController, xTunnel);
2000-09-18 16:07:07 +00:00
}
// Es gibt noch keinen TabController fuer das Formular, also muss
// ein neuer angelegt werden.
setController ( xForm , xCC , pFormController ) ;
}
}
//------------------------------------------------------------------------
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > FmXPageViewWinRec : : getControlContainer ( ) const
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > xCC ;
if ( m_aControllerList . size ( ) )
xCC = m_aControllerList [ 0 ] - > getContainer ( ) ;
return xCC ;
}
//------------------------------------------------------------------------
FmXFormView : : ~ FmXFormView ( )
{
DBG_ASSERT ( m_aWinList . size ( ) = = 0 , " Liste nicht leer " ) ;
if ( m_nEvent )
Application : : RemoveUserEvent ( m_nEvent ) ;
if ( m_nErrorMessageEvent )
Application : : RemoveUserEvent ( m_nErrorMessageEvent ) ;
2000-10-24 14:22:40 +00:00
if ( m_nAutoFocusEvent )
Application : : RemoveUserEvent ( m_nAutoFocusEvent ) ;
2000-09-18 16:07:07 +00:00
}
// EventListener
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : disposing ( const : : com : : sun : : star : : lang : : EventObject & Source ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
}
// ::com::sun::star::form::XFormControllerListener
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : formActivated ( const : : com : : sun : : star : : lang : : EventObject & rEvent )
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XFormController > xController ( rEvent . Source , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
// benachrichtigung der Shell
if ( m_pView & & m_pView - > GetFormShell ( ) )
{
FmXFormShell * pShImpl = m_pView - > GetFormShell ( ) - > GetImpl ( ) ;
if ( pShImpl )
pShImpl - > setActiveController ( xController ) ;
}
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : formDeactivated ( const : : com : : sun : : star : : lang : : EventObject & rEvent )
{
// deaktivierung wird nicht registriert
}
// ::com::sun::star::container::XContainerListener
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : elementInserted ( const : : com : : sun : : star : : container : : ContainerEvent & evt )
{
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > xCC ( evt . Source , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xCC . is ( ) )
{
FmWinRecList : : iterator i = findWindow ( xCC ) ;
2000-11-06 06:19:53 +00:00
2000-09-18 16:07:07 +00:00
if ( i ! = m_aWinList . end ( ) )
{
2000-11-06 06:19:53 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControl > xControl ;
evt . Element > > = xControl ;
2000-09-18 16:07:07 +00:00
if ( xControl . is ( ) )
( * i ) - > updateTabOrder ( xControl , xCC ) ;
}
}
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : elementReplaced ( const : : com : : sun : : star : : container : : ContainerEvent & evt )
{
elementInserted ( evt ) ;
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormView : : elementRemoved ( const : : com : : sun : : star : : container : : ContainerEvent & evt )
{
}
//------------------------------------------------------------------------------
FmWinRecList : : const_iterator FmXFormView : : findWindow ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & rCC ) const
{
for ( FmWinRecList : : const_iterator i = m_aWinList . begin ( ) ;
i ! = m_aWinList . end ( ) ; i + + )
{
if ( rCC = = ( * i ) - > getControlContainer ( ) )
return i ;
}
return m_aWinList . end ( ) ;
}
//------------------------------------------------------------------------------
FmWinRecList : : iterator FmXFormView : : findWindow ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & rCC )
{
for ( FmWinRecList : : iterator i = m_aWinList . begin ( ) ;
i ! = m_aWinList . end ( ) ; i + + )
{
if ( rCC = = ( * i ) - > getControlContainer ( ) )
return i ;
}
return m_aWinList . end ( ) ;
}
//------------------------------------------------------------------------------
void FmXFormView : : addWindow ( const SdrPageViewWinRec * pRec )
{
// Wird gerufen, wenn
// - in den aktiven Modus geschaltet wird
// - ein Window hinzugefuegt wird, waehrend man im Design-Modus ist
// - der Control-Container fuer ein Window angelegt wird, waehrend
// der aktive Modus eingeschaltet ist.
// Wenn es noch keinen Control-Container gibt oder am Control-Container
// noch keine Peer Erzeugt wurde, dann ist es noch zu frueh, um die
// Tab-Order einzustellen ...
if ( pRec - > GetOutputDevice ( ) - > GetOutDevType ( ) = = OUTDEV_WINDOW )
{
const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & rCC = pRec - > GetControlContainerRef ( ) ;
if ( rCC . is ( ) & & findWindow ( rCC ) = = m_aWinList . end ( ) )
{
2000-11-06 06:19:53 +00:00
FmXPageViewWinRec * pFmRec = new FmXPageViewWinRec ( m_xORB , pRec , this ) ;
2000-09-18 16:07:07 +00:00
pFmRec - > acquire ( ) ;
m_aWinList . push_back ( pFmRec ) ;
// Am ControlContainer horchen um Aenderungen mitzbekommen
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XContainer > xContainer ( rCC , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xContainer . is ( ) )
xContainer - > addContainerListener ( this ) ;
}
}
}
//------------------------------------------------------------------------------
void FmXFormView : : removeWindow ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & rCC )
{
// Wird gerufen, wenn
// - in den Design-Modus geschaltet wird
// - ein Window geloescht wird, waehrend man im Design-Modus ist
// - der Control-Container fuer ein Window entfernt wird, waehrend
// der aktive Modus eingeschaltet ist.
FmWinRecList : : iterator i = findWindow ( rCC ) ;
if ( i ! = m_aWinList . end ( ) )
{
// Am ControlContainer horchen um Aenderungen mitzbekommen
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XContainer > xContainer ( rCC , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xContainer . is ( ) )
xContainer - > removeContainerListener ( this ) ;
( * i ) - > dispose ( ) ;
( * i ) - > release ( ) ;
m_aWinList . erase ( i ) ;
}
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormView , OnDelayedErrorMessage , void * , EMPTYTAG )
{
m_nErrorMessageEvent = 0 ;
Window * pParentWindow = Application : : GetDefDialogParent ( ) ;
ErrorBox ( pParentWindow , WB_OK , m_sErrorMessage ) . Execute ( ) ;
// ErrorBox(Application::GetDefDialogParent(), WB_OK, m_sErrorMessage).Execute();
return 0L ;
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormView , OnActivate , void * , EMPTYTAG )
{
m_nEvent = 0 ;
if ( m_pPageViewForActivation )
{
FmFormModel * pModel = PTR_CAST ( FmFormModel , m_pView - > GetModel ( ) ) ;
if ( pModel )
// lock the undo env so the forms can change non-transient properties while loading
// (without this my doc's modified flag would be set)
pModel - > GetUndoEnv ( ) . Lock ( ) ;
// Load all forms
FmFormPage * pPage = ( FmFormPage * ) m_pPageViewForActivation - > GetPage ( ) ;
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : container : : XIndexAccess > xForms ( pPage - > GetForms ( ) , : : com : : sun : : star : : uno : : UNO_QUERY ) ;
: : com : : sun : : star : : uno : : Any aElement ;
2000-11-06 06:19:53 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : form : : XLoadable > xForm ;
2000-09-18 16:07:07 +00:00
for ( sal_Int32 i = 0 , nCount = xForms - > getCount ( ) ; i < nCount ; i + + )
{
2000-11-06 06:19:53 +00:00
xForms - > getByIndex ( i ) > > = xForm ;
2000-09-18 16:07:07 +00:00
// a database form must be loaded for
if ( : : isLoadable ( xForm ) & & ! xForm - > isLoaded ( ) )
xForm - > load ( ) ;
}
2000-11-01 13:52:23 +00:00
if ( pModel & & pModel - > GetAutoControlFocus ( ) )
LINK ( this , FmXFormView , OnAutoFocus ) . Call ( NULL ) ;
2000-10-24 14:22:40 +00:00
2000-09-18 16:07:07 +00:00
if ( pModel )
// unlock the environment
pModel - > GetUndoEnv ( ) . UnLock ( ) ;
}
// setting the controller to activate
if ( m_pView - > GetFormShell ( ) & & m_pView - > GetActualOutDev ( ) & & m_pView - > GetActualOutDev ( ) - > GetOutDevType ( ) = = OUTDEV_WINDOW )
{
Window * pWindow = ( Window * ) m_pView - > GetActualOutDev ( ) ;
FmXPageViewWinRec * pFmRec = m_aWinList . size ( ) ? m_aWinList [ 0 ] : NULL ;
for ( FmWinRecList : : const_iterator i = m_aWinList . begin ( ) ;
i ! = m_aWinList . end ( ) ; i + + )
{
if ( pWindow = = ( * i ) - > getWindow ( ) )
pFmRec = * i ;
}
if ( pFmRec )
{
2001-07-25 12:44:28 +00:00
for ( vector < Reference < XFormController > > : : const_iterator i = pFmRec - > GetList ( ) . begin ( ) ;
2000-09-18 16:07:07 +00:00
i ! = pFmRec - > GetList ( ) . end ( ) ; i + + )
{
2001-07-25 12:44:28 +00:00
const Reference < XFormController > & xController = * i ;
2000-09-18 16:07:07 +00:00
if ( xController . is ( ) )
{
// Nur bei Datenbankformularen erfolgt eine aktivierung
2001-07-25 12:44:28 +00:00
Reference < XRowSet > xForm ( xController - > getModel ( ) , UNO_QUERY ) ;
if ( xForm . is ( ) & & getRowsetConnection ( xForm ) . is ( ) )
2000-09-18 16:07:07 +00:00
{
2001-07-25 12:44:28 +00:00
Reference < XPropertySet > xFormSet ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xFormSet . is ( ) )
{
// wenn es eine Datenquelle gibt, dann als aktive ::com::sun::star::form setzen
2000-10-20 13:18:57 +00:00
: : rtl : : OUString aSource = : : comphelper : : getString ( xFormSet - > getPropertyValue ( FM_PROP_COMMAND ) ) ;
2001-05-11 15:07:05 +00:00
if ( aSource . getLength ( ) )
2000-09-18 16:07:07 +00:00
{
// benachrichtigung der Shell
FmXFormShell * pShImpl = m_pView - > GetFormShell ( ) - > GetImpl ( ) ;
if ( pShImpl )
pShImpl - > setActiveController ( xController ) ;
break ;
}
}
}
}
}
}
}
return 0 ;
}
//------------------------------------------------------------------------------
void FmXFormView : : Activate ( SdrPageView * pPageView , sal_Bool bSync )
{
if ( m_nEvent )
{
Application : : RemoveUserEvent ( m_nEvent ) ;
m_nEvent = 0 ;
}
m_pPageViewForActivation = pPageView ;
if ( bSync )
{
LINK ( this , FmXFormView , OnActivate ) . Call ( NULL ) ;
}
else
m_nEvent = Application : : PostUserEvent ( LINK ( this , FmXFormView , OnActivate ) ) ;
}
//------------------------------------------------------------------------------
void FmXFormView : : Deactivate ( SdrPageView * pPageView , BOOL bDeactivateController )
{
if ( m_nEvent )
{
Application : : RemoveUserEvent ( m_nEvent ) ;
m_nEvent = 0 ;
m_pPageViewForActivation = NULL ;
}
FmXFormShell * pShImpl = m_pView - > GetFormShell ( ) ? m_pView - > GetFormShell ( ) - > GetImpl ( ) : NULL ;
if ( pShImpl & & bDeactivateController )
pShImpl - > setActiveController ( ) ;
}
//------------------------------------------------------------------------------
void FmXFormView : : AttachControl ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControl > & rControl , sal_Bool bDetach )
{
/* wird im fmctrler gemacht */
}
//------------------------------------------------------------------------------
void FmXFormView : : AttachControls ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : awt : : XControlContainer > & rCtrlContainer ,
sal_Bool bDetach )
{
}
2001-04-20 15:12:48 +00:00
//------------------------------------------------------------------------------
void FmXFormView : : smartControlReset ( const Reference < XIndexAccess > & _rxModels )
{
if ( ! _rxModels . is ( ) )
{
DBG_ERROR ( " FmXFormView::smartControlReset: invalid container! " ) ;
return ;
}
static const : : rtl : : OUString sClassIdPropertyName = FM_PROP_CLASSID ;
static const : : rtl : : OUString sBoundFieldPropertyName = FM_PROP_BOUNDFIELD ;
sal_Int32 nCount = _rxModels - > getCount ( ) ;
Reference < XPropertySet > xCurrent ;
Reference < XPropertySetInfo > xCurrentInfo ;
Reference < XPropertySet > xBoundField ;
for ( sal_Int32 i = 0 ; i < nCount ; + + i )
{
_rxModels - > getByIndex ( i ) > > = xCurrent ;
if ( xCurrent . is ( ) )
xCurrentInfo = xCurrent - > getPropertySetInfo ( ) ;
else
xCurrentInfo . clear ( ) ;
if ( ! xCurrentInfo . is ( ) )
continue ;
if ( xCurrentInfo - > hasPropertyByName ( sClassIdPropertyName ) )
{ // it's a control model
// check if this control is bound to a living database field
if ( xCurrentInfo - > hasPropertyByName ( sBoundFieldPropertyName ) )
xCurrent - > getPropertyValue ( sBoundFieldPropertyName ) > > = xBoundField ;
else
xBoundField . clear ( ) ;
if ( ! xBoundField . is ( ) )
{ // no, not valid bound -> reset it
Reference < XReset > xControlReset ( xCurrent , UNO_QUERY ) ;
if ( xControlReset . is ( ) )
xControlReset - > reset ( ) ;
}
}
else
{
Reference < XIndexAccess > xContainer ( xCurrent , UNO_QUERY ) ;
if ( xContainer . is ( ) )
smartControlReset ( xContainer ) ;
}
}
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
FmFormShell * FmXFormView : : GetFormShell ( ) const
{
return m_pView ? m_pView - > GetFormShell ( ) : NULL ;
}
2000-11-06 06:19:53 +00:00
// -----------------------------------------------------------------------------
void FmXFormView : : AutoFocus ( )
{
if ( m_nAutoFocusEvent )
Application : : RemoveUserEvent ( m_nAutoFocusEvent ) ;
m_nAutoFocusEvent = Application : : PostUserEvent ( LINK ( this , FmXFormView , OnAutoFocus ) ) ;
}
// -----------------------------------------------------------------------------
IMPL_LINK ( FmXFormView , OnAutoFocus , void * , EMPTYTAG )
{
m_nAutoFocusEvent = 0 ;
// go to the first form of our page, examine it's TabController, go to it's first (in terms of the tab order)
// control, give it the focus
// get the forms collection of the page we belong to
FmFormPage * pPage = m_pView ? PTR_CAST ( FmFormPage , m_pView - > GetPageViewPvNum ( 0 ) - > GetPage ( ) ) : NULL ;
Reference < XIndexAccess > xForms ;
if ( pPage )
xForms = Reference < XIndexAccess > ( pPage - > GetForms ( ) , UNO_QUERY ) ;
FmXPageViewWinRec * pViewWinRec = m_aWinList . size ( ) ? m_aWinList [ 0 ] : NULL ;
if ( pViewWinRec )
{
try
{
// go for the tab controller of the first form
sal_Int32 nObjects = xForms - > getCount ( ) ;
: : com : : sun : : star : : uno : : Reference < XForm > xForm ;
if ( nObjects )
: : cppu : : extractInterface ( xForm , xForms - > getByIndex ( 0 ) ) ;
Reference < XTabController > xTabControllerModel ( pViewWinRec - > getController ( xForm ) , UNO_QUERY ) ;
// go for the first control of the controller
Sequence < Reference < XControl > > aControls ;
if ( xTabControllerModel . is ( ) )
aControls = xTabControllerModel - > getControls ( ) ;
Reference < XControl > xFirstControl ;
if ( aControls . getLength ( ) )
xFirstControl = aControls [ 0 ] ;
// set the focus to this first control
Reference < XWindow > xControlWindow ( xFirstControl , UNO_QUERY ) ;
if ( xControlWindow . is ( ) )
xControlWindow - > setFocus ( ) ;
2000-12-07 15:02:36 +00:00
// ensure that the control is visible
// 80210 - 12/07/00 - FS
if ( xControlWindow . is ( ) & & m_pView - > GetActualOutDev ( ) & & ( OUTDEV_WINDOW = = m_pView - > GetActualOutDev ( ) - > GetOutDevType ( ) ) )
{
const Window * pWindow = static_cast < const Window * > ( m_pView - > GetActualOutDev ( ) ) ;
: : com : : sun : : star : : awt : : Rectangle aRect = xControlWindow - > getPosSize ( ) ;
: : Rectangle aNonUnoRect ( aRect . X , aRect . Y , aRect . X + aRect . Width , aRect . Y + aRect . Height ) ;
m_pView - > MakeVisible ( pWindow - > PixelToLogic ( aNonUnoRect ) , * const_cast < Window * > ( pWindow ) ) ;
}
2000-11-06 06:19:53 +00:00
}
catch ( Exception & )
{
DBG_ERROR ( " FmXFormView::OnAutoFocus: could not activate the first control! " ) ;
}
}
return 0L ;
}
// -----------------------------------------------------------------------------
2000-09-18 16:07:07 +00:00