2000-09-18 16:07:07 +00:00
/*************************************************************************
*
2008-04-11 00:08:14 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* Copyright 2008 by Sun Microsystems , Inc .
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* $ RCSfile : fmshimp . cxx , v $
2008-08-28 05:55:02 +00:00
* $ Revision : 1.94 $
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* This file is part of OpenOffice . org .
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* 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 .
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* 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 ) .
2000-09-18 16:07:07 +00:00
*
2008-04-11 00:08:14 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-09-18 16:07:07 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-17 04:09:24 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_svx.hxx"
2000-09-18 16:07:07 +00:00
# include "gridcols.hxx"
2007-06-27 17:15:05 +00:00
# include <svx/obj3d.hxx>
2000-09-18 16:07:07 +00:00
# include "fmvwimp.hxx"
# include "fmshimp.hxx"
2004-05-07 14:47:38 +00:00
# include "fmtextcontrolshell.hxx"
2007-06-27 17:15:05 +00:00
# include <svx/svdpagv.hxx>
# include <svx/fmpage.hxx>
# include <svx/dialmgr.hxx>
2000-09-18 16:07:07 +00:00
# ifndef _SVX_FMRESIDS_HRC
# include "fmresids.hrc"
2006-10-18 12:24:00 +00:00
# endif
2000-09-18 16:07:07 +00:00
# include "fmitems.hxx"
# include "fmobj.hxx"
2005-03-10 15:23:52 +00:00
# include "formtoolbars.hxx"
2007-06-27 17:15:05 +00:00
# include <svx/fmglob.hxx>
2006-10-18 12:24:00 +00:00
# include "svditer.hxx"
# include "fmservs.hxx"
# include "fmpgeimp.hxx"
# include "fmtools.hxx"
# ifndef _SVX_FMPROP_HRC
# include "fmprop.hrc"
# endif
2007-06-27 17:15:05 +00:00
# include <svx/fmshell.hxx>
2006-10-18 12:24:00 +00:00
# ifndef _SVX_SVXIDS_HRC
2007-06-27 17:15:05 +00:00
# include <svx/svxids.hrc>
2006-10-18 12:24:00 +00:00
# endif
2007-06-27 17:15:05 +00:00
# include <svx/fmmodel.hxx>
2006-10-18 12:24:00 +00:00
# include "fmundo.hxx"
# include "fmurl.hxx"
# include "formcontrolling.hxx"
2007-06-27 17:15:05 +00:00
# include <svx/svxdlg.hxx>
# include <svx/dialogs.hrc>
2000-09-26 10:42:52 +00:00
# include <com/sun/star/frame/FrameSearchFlag.hpp>
2000-09-18 16:07:07 +00:00
# include <com/sun/star/form/XLoadable.hpp>
2007-07-31 12:57:49 +00:00
# include <com/sun/star/container/XNamed.hpp>
2000-09-18 16:07:07 +00:00
# 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>
2000-09-26 13:14:45 +00:00
# include <com/sun/star/frame/FrameSearchFlag.hpp>
2000-09-18 16:07:07 +00:00
# include <com/sun/star/awt/XTextComponent.hpp>
2007-07-31 12:57:49 +00:00
# include <com/sun/star/awt/XListBox.hpp>
# include <com/sun/star/awt/XCheckBox.hpp>
2000-09-18 16:07:07 +00:00
# include <com/sun/star/form/XBoundComponent.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/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>
2004-11-16 10:24:36 +00:00
# include <com/sun/star/beans/XPropertyState.hpp>
2004-04-02 09:29:40 +00:00
# include <com/sun/star/form/binding/XBindableValue.hpp>
2004-03-19 11:20:43 +00:00
# include <com/sun/star/beans/NamedValue.hpp>
2004-04-02 09:29:40 +00:00
# include <com/sun/star/form/binding/XListEntrySink.hpp>
2004-03-19 11:20:43 +00:00
# include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
2000-09-18 16:07:07 +00:00
# include <osl/mutex.hxx>
# include <sfx2/viewsh.hxx>
# include <sfx2/viewfrm.hxx>
# include <sfx2/frame.hxx>
2004-04-13 09:59:06 +00:00
# include <vcl/waitobj.hxx>
2006-10-18 12:24:00 +00:00
# include <tools/shl.hxx>
# include <tools/diagnose_ex.h>
# include <vcl/msgbox.hxx>
# include <sfx2/dispatch.hxx>
# include <sfx2/objsh.hxx>
# include <sfx2/docfile.hxx>
# include <tools/color.hxx>
2000-09-18 16:07:07 +00:00
# include <tools/urlobj.hxx>
2000-10-20 13:18:57 +00:00
# include <comphelper/property.hxx>
# include <connectivity/dbtools.hxx>
# include <comphelper/stl_types.hxx>
# include <comphelper/processfactory.hxx>
2000-09-18 16:07:07 +00:00
# include <cppuhelper/servicefactory.hxx>
2001-03-15 08:02:28 +00:00
# include <comphelper/extract.hxx>
2004-03-19 11:20:43 +00:00
# include <toolkit/helper/vclunohelper.hxx>
2007-06-27 17:15:05 +00:00
# include <svx/sdrpagewindow.hxx>
2006-11-14 12:25:13 +00:00
2004-04-13 09:59:06 +00:00
# include <algorithm>
2004-11-16 10:24:36 +00:00
# include <functional>
2000-09-18 16:07:07 +00:00
// wird fuer Invalidate verwendet -> mitpflegen
2004-04-13 09:59:06 +00:00
sal_uInt16 DatabaseSlotMap [ ] =
{
SID_FM_RECORD_FIRST ,
SID_FM_RECORD_NEXT ,
SID_FM_RECORD_PREV ,
SID_FM_RECORD_LAST ,
SID_FM_RECORD_NEW ,
SID_FM_RECORD_DELETE ,
SID_FM_RECORD_ABSOLUTE ,
SID_FM_RECORD_TOTAL ,
SID_FM_RECORD_SAVE ,
SID_FM_RECORD_UNDO ,
SID_FM_REMOVE_FILTER_SORT ,
SID_FM_SORTUP ,
SID_FM_SORTDOWN ,
SID_FM_ORDERCRIT ,
SID_FM_AUTOFILTER ,
SID_FM_FORM_FILTERED ,
SID_FM_REFRESH ,
2008-08-19 08:48:23 +00:00
SID_FM_REFRESH_FORM_CONTROL ,
2004-04-13 09:59:06 +00:00
SID_FM_SEARCH ,
SID_FM_FILTER_START ,
SID_FM_VIEW_AS_GRID ,
0
} ;
2000-09-18 16:07:07 +00:00
// wird fuer Invalidate verwendet -> mitpflegen
// aufsteigend sortieren !!!!!!
sal_Int16 DlgSlotMap [ ] = // slots des Controllers
{
SID_FM_CTL_PROPERTIES ,
SID_FM_PROPERTIES ,
SID_FM_TAB_DIALOG ,
SID_FM_ADD_FIELD ,
SID_FM_SHOW_FMEXPLORER ,
SID_FM_FIELDS_CONTROL ,
SID_FM_SHOW_PROPERTIES ,
SID_FM_PROPERTY_CONTROL ,
SID_FM_FMEXPLORER_CONTROL ,
2004-11-16 10:24:36 +00:00
SID_FM_SHOW_DATANAVIGATOR ,
SID_FM_DATANAVIGATOR_CONTROL ,
2000-09-18 16:07:07 +00:00
0
} ;
sal_Int16 SelObjectSlotMap [ ] = // vom SelObject abhaengige Slots
{
SID_FM_CONVERTTO_EDIT ,
SID_FM_CONVERTTO_BUTTON ,
SID_FM_CONVERTTO_FIXEDTEXT ,
SID_FM_CONVERTTO_LISTBOX ,
SID_FM_CONVERTTO_CHECKBOX ,
SID_FM_CONVERTTO_RADIOBUTTON ,
SID_FM_CONVERTTO_GROUPBOX ,
SID_FM_CONVERTTO_COMBOBOX ,
SID_FM_CONVERTTO_IMAGEBUTTON ,
SID_FM_CONVERTTO_FILECONTROL ,
SID_FM_CONVERTTO_DATE ,
SID_FM_CONVERTTO_TIME ,
SID_FM_CONVERTTO_NUMERIC ,
SID_FM_CONVERTTO_CURRENCY ,
SID_FM_CONVERTTO_PATTERN ,
SID_FM_CONVERTTO_IMAGECONTROL ,
SID_FM_CONVERTTO_FORMATTED ,
2003-12-11 11:18:40 +00:00
SID_FM_CONVERTTO_SCROLLBAR ,
SID_FM_CONVERTTO_SPINBUTTON ,
2004-04-13 09:59:06 +00:00
SID_FM_CONVERTTO_NAVIGATIONBAR ,
2000-09-18 16:07:07 +00:00
SID_FM_FMEXPLORER_CONTROL ,
2004-11-16 10:24:36 +00:00
SID_FM_DATANAVIGATOR_CONTROL ,
2000-09-18 16:07:07 +00:00
0
} ;
// die folgenden Arrays muessen kosistent sein, also einander entsprechende Eintraege an der selben relativen Position
// innerhalb ihres jeweiligen Arrays stehen
sal_Int16 nConvertSlots [ ] =
{
SID_FM_CONVERTTO_EDIT ,
SID_FM_CONVERTTO_BUTTON ,
SID_FM_CONVERTTO_FIXEDTEXT ,
SID_FM_CONVERTTO_LISTBOX ,
SID_FM_CONVERTTO_CHECKBOX ,
SID_FM_CONVERTTO_RADIOBUTTON ,
SID_FM_CONVERTTO_GROUPBOX ,
SID_FM_CONVERTTO_COMBOBOX ,
SID_FM_CONVERTTO_IMAGEBUTTON ,
SID_FM_CONVERTTO_FILECONTROL ,
SID_FM_CONVERTTO_DATE ,
SID_FM_CONVERTTO_TIME ,
SID_FM_CONVERTTO_NUMERIC ,
SID_FM_CONVERTTO_CURRENCY ,
SID_FM_CONVERTTO_PATTERN ,
SID_FM_CONVERTTO_IMAGECONTROL ,
2003-12-11 11:18:40 +00:00
SID_FM_CONVERTTO_FORMATTED ,
SID_FM_CONVERTTO_SCROLLBAR ,
2004-04-13 09:59:06 +00:00
SID_FM_CONVERTTO_SPINBUTTON ,
SID_FM_CONVERTTO_NAVIGATIONBAR
2000-09-18 16:07:07 +00:00
} ;
sal_Int16 nCreateSlots [ ] =
{
SID_FM_EDIT ,
SID_FM_PUSHBUTTON ,
SID_FM_FIXEDTEXT ,
SID_FM_LISTBOX ,
SID_FM_CHECKBOX ,
SID_FM_RADIOBUTTON ,
SID_FM_GROUPBOX ,
SID_FM_COMBOBOX ,
SID_FM_IMAGEBUTTON ,
SID_FM_FILECONTROL ,
SID_FM_DATEFIELD ,
SID_FM_TIMEFIELD ,
SID_FM_NUMERICFIELD ,
SID_FM_CURRENCYFIELD ,
SID_FM_PATTERNFIELD ,
SID_FM_IMAGECONTROL ,
2003-12-11 11:18:40 +00:00
SID_FM_FORMATTEDFIELD ,
SID_FM_SCROLLBAR ,
2004-04-13 09:59:06 +00:00
SID_FM_SPINBUTTON ,
SID_FM_NAVIGATIONBAR
2000-09-18 16:07:07 +00:00
} ;
sal_Int16 nObjectTypes [ ] =
{
OBJ_FM_EDIT ,
OBJ_FM_BUTTON ,
OBJ_FM_FIXEDTEXT ,
OBJ_FM_LISTBOX ,
OBJ_FM_CHECKBOX ,
OBJ_FM_RADIOBUTTON ,
OBJ_FM_GROUPBOX ,
OBJ_FM_COMBOBOX ,
OBJ_FM_IMAGEBUTTON ,
OBJ_FM_FILECONTROL ,
OBJ_FM_DATEFIELD ,
OBJ_FM_TIMEFIELD ,
OBJ_FM_NUMERICFIELD ,
OBJ_FM_CURRENCYFIELD ,
OBJ_FM_PATTERNFIELD ,
OBJ_FM_IMAGECONTROL ,
2003-12-11 11:18:40 +00:00
OBJ_FM_FORMATTEDFIELD ,
OBJ_FM_SCROLLBAR ,
2004-04-13 09:59:06 +00:00
OBJ_FM_SPINBUTTON ,
OBJ_FM_NAVIGATIONBAR
2000-09-18 16:07:07 +00:00
} ;
2004-03-19 11:20:43 +00:00
using namespace : : com : : sun : : star : : ui ;
2000-11-09 09:07:35 +00:00
using namespace : : com : : sun : : star : : uno ;
2000-11-24 06:01:26 +00:00
using namespace : : com : : sun : : star : : sdb ;
using namespace : : com : : sun : : star : : sdbc ;
using namespace : : com : : sun : : star : : sdbcx ;
using namespace : : com : : sun : : star : : beans ;
using namespace : : com : : sun : : star : : container ;
using namespace : : com : : sun : : star : : form ;
2004-04-02 09:29:40 +00:00
using namespace : : com : : sun : : star : : form : : binding ;
2008-08-19 08:48:23 +00:00
using namespace : : com : : sun : : star : : form : : runtime ;
2000-11-24 06:01:26 +00:00
using namespace : : com : : sun : : star : : awt ;
2004-11-16 10:24:36 +00:00
using namespace : : com : : sun : : star : : view ;
2000-11-24 06:01:26 +00:00
using namespace : : com : : sun : : star : : lang ;
using namespace : : com : : sun : : star : : util ;
2004-09-09 09:22:22 +00:00
using namespace : : com : : sun : : star : : frame ;
2000-12-18 07:22:38 +00:00
using namespace : : svxform ;
2004-04-13 09:59:06 +00:00
using namespace : : svx ;
2000-11-09 09:07:35 +00:00
2004-11-16 10:24:36 +00:00
//==============================================================================
//= helper
//==============================================================================
namespace
{
2007-07-31 12:57:49 +00:00
//....................................................................
2004-11-16 10:24:36 +00:00
void collectInterfacesFromMarkList ( const SdrMarkList & _rMarkList , InterfaceBag & /* [out] */ _rInterfaces )
{
_rInterfaces . clear ( ) ;
sal_uInt32 nMarkCount = _rMarkList . GetMarkCount ( ) ;
for ( sal_uInt32 i = 0 ; i < nMarkCount ; + + i )
{
2006-07-25 11:52:35 +00:00
SdrObject * pCurrent = _rMarkList . GetMark ( i ) - > GetMarkedSdrObj ( ) ;
2004-11-16 10:24:36 +00:00
SdrObjListIter * pGroupIterator = NULL ;
if ( pCurrent - > IsGroupObject ( ) )
{
pGroupIterator = new SdrObjListIter ( * pCurrent - > GetSubList ( ) ) ;
pCurrent = pGroupIterator - > IsMore ( ) ? pGroupIterator - > Next ( ) : NULL ;
}
while ( pCurrent )
{
2008-12-01 12:31:27 +00:00
FmFormObj * pAsFormObject = FmFormObj : : GetFormObject ( pCurrent ) ;
// note this will de-reference virtual objects, if necessary/possible
2004-11-16 10:24:36 +00:00
if ( pAsFormObject )
{
Reference < XInterface > xControlModel ( pAsFormObject - > GetUnoControlModel ( ) , UNO_QUERY ) ;
// the UNO_QUERY is important for normalization
if ( xControlModel . is ( ) )
_rInterfaces . insert ( xControlModel ) ;
}
// next element
pCurrent = pGroupIterator & & pGroupIterator - > IsMore ( ) ? pGroupIterator - > Next ( ) : NULL ;
}
if ( pGroupIterator )
delete pGroupIterator ;
}
}
2007-07-31 12:57:49 +00:00
}
//------------------------------------------------------------------------------
// check if the control has one of the interfaces we can use for searching
// *_pCurrentText will be filled with the current text of the control (as used when searching this control)
sal_Bool IsSearchableControl ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : uno : : XInterface > & _rxControl ,
: : rtl : : OUString * _pCurrentText )
{
if ( ! _rxControl . is ( ) )
return sal_False ;
Reference < XTextComponent > xAsText ( _rxControl , UNO_QUERY ) ;
if ( xAsText . is ( ) )
{
if ( _pCurrentText )
* _pCurrentText = xAsText - > getText ( ) ;
return sal_True ;
}
Reference < XListBox > xListBox ( _rxControl , UNO_QUERY ) ;
if ( xListBox . is ( ) )
{
if ( _pCurrentText )
* _pCurrentText = xListBox - > getSelectedItem ( ) ;
return sal_True ;
}
Reference < XCheckBox > xCheckBox ( _rxControl , UNO_QUERY ) ;
if ( xCheckBox . is ( ) )
{
if ( _pCurrentText )
{
switch ( ( TriState ) xCheckBox - > getState ( ) )
{
case STATE_NOCHECK : * _pCurrentText = : : rtl : : OUString : : createFromAscii ( " 0 " ) ; break ;
case STATE_CHECK : * _pCurrentText = : : rtl : : OUString : : createFromAscii ( " 1 " ) ; break ;
default : * _pCurrentText = : : rtl : : OUString ( ) ; break ;
}
}
return sal_True ;
}
return sal_False ;
2004-11-16 10:24:36 +00:00
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
sal_Bool FmXBoundFormFieldIterator : : ShouldStepInto ( const Reference < XInterface > & _rContainer ) const
2000-09-18 16:07:07 +00:00
{
if ( _rContainer = = m_xStartingPoint )
// would be quite stupid to step over the root ....
return sal_True ;
2000-11-24 06:01:26 +00:00
return Reference < XControlModel > ( _rContainer , UNO_QUERY ) . is ( ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
sal_Bool FmXBoundFormFieldIterator : : ShouldHandleElement ( const Reference < XInterface > & _rElement )
2000-09-18 16:07:07 +00:00
{
if ( ! _rElement . is ( ) )
// NULL element
return sal_False ;
2000-11-24 06:01:26 +00:00
if ( Reference < XForm > ( _rElement , UNO_QUERY ) . is ( ) | | Reference < XGrid > ( _rElement , UNO_QUERY ) . is ( ) )
2000-09-18 16:07:07 +00:00
// a forms or a grid
return sal_False ;
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xSet ( _rElement , UNO_QUERY ) ;
2000-10-20 13:18:57 +00:00
if ( ! xSet . is ( ) | | ! : : comphelper : : hasProperty ( FM_PROP_BOUNDFIELD , xSet ) )
2000-09-18 16:07:07 +00:00
// no "BoundField" property
return sal_False ;
2000-11-24 06:01:26 +00:00
Any aVal ( xSet - > getPropertyValue ( FM_PROP_BOUNDFIELD ) ) ;
if ( aVal . getValueTypeClass ( ) ! = TypeClass_INTERFACE )
2000-09-18 16:07:07 +00:00
// void or invalid property value
return sal_False ;
2000-11-07 12:16:50 +00:00
return aVal . hasValue ( ) ;
2000-09-18 16:07:07 +00:00
}
//==============================================================================
2006-06-19 14:57:11 +00:00
DECL_CURSOR_ACTION_THREAD ( FmMoveToLastThread )
2000-09-18 16:07:07 +00:00
IMPL_CURSOR_ACTION_THREAD ( FmMoveToLastThread , SVX_RES ( RID_STR_MOVING_CURSOR ) , last ( ) ) ;
//------------------------------------------------------------------------------
sal_Bool isControlList ( const SdrMarkList & rMarkList )
{
// enthaelt die liste nur Controls und mindestens ein control
sal_uInt32 nMarkCount = rMarkList . GetMarkCount ( ) ;
sal_Bool bControlList = nMarkCount ! = 0 ;
sal_Bool bHadAnyLeafs = sal_False ;
for ( sal_uInt32 i = 0 ; i < nMarkCount & & bControlList ; i + + )
{
2006-07-25 11:52:35 +00:00
SdrObject * pObj = rMarkList . GetMark ( i ) - > GetMarkedSdrObj ( ) ;
2000-09-18 16:07:07 +00:00
E3dObject * pAs3DObject = PTR_CAST ( E3dObject , pObj ) ;
// E3dObject's do not contain any 2D-objects (by definition)
// we need this extra check here : an E3dObject->IsGroupObject says "YES", but an SdrObjListIter working
// with an E3dObject doesn't give me any Nodes (E3dObject has a sub list, but no members in that list,
// cause there implementation differs from the one of "normal" SdrObject's. Unfortunally SdrObject::IsGroupObject
// doesn't check the element count of the sub list, which is simply a bug in IsGroupObject we can't fix at the moment).
// So at the end of this function bControlList would have the same value it was initialized with above : sal_True
// And this would be wrong :)
// 03.02.00 - 72529 - FS
if ( ! pAs3DObject )
if ( pObj - > IsGroupObject ( ) )
{
SdrObjListIter aIter ( * pObj - > GetSubList ( ) ) ;
while ( aIter . IsMore ( ) & & bControlList )
{
bControlList = FmFormInventor = = aIter . Next ( ) - > GetObjInventor ( ) ;
bHadAnyLeafs = sal_True ;
}
}
else
{
bHadAnyLeafs = sal_True ;
bControlList = FmFormInventor = = pObj - > GetObjInventor ( ) ;
}
}
return bControlList & & bHadAnyLeafs ;
}
//------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
Reference < XForm > GetForm ( const Reference < XInterface > & _rxElement )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
Reference < XForm > xForm ( _rxElement , UNO_QUERY ) ;
if ( xForm . is ( ) )
return xForm ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
Reference < XChild > xChild ( _rxElement , UNO_QUERY ) ;
if ( xChild . is ( ) )
return GetForm ( xChild - > getParent ( ) ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
return Reference < XForm > ( ) ;
2000-09-18 16:07:07 +00:00
}
2001-05-22 12:37:21 +00:00
//========================================================================
// class FmXFormShell_Base_Disambiguation
//========================================================================
FmXFormShell_Base_Disambiguation : : FmXFormShell_Base_Disambiguation ( : : osl : : Mutex & _rMutex )
: FmXFormShell_BD_BASE ( _rMutex )
{
}
void SAL_CALL FmXFormShell_Base_Disambiguation : : disposing ( )
{
WeakComponentImplHelperBase : : disposing ( ) ;
// Note:
// This is a HACK.
// Normally it should be sufficient to call the "disposing" of our direct
// base class, but SUN PRO 5 does not like this and claims there is a conflict
// with the XEventListener::disposing(EventObject) of our various listener
// base classes.
}
2000-09-18 16:07:07 +00:00
//========================================================================
// class FmXFormShell
//========================================================================
2000-11-07 12:16:50 +00:00
DBG_NAME ( FmXFormShell ) ;
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------
2008-08-28 05:55:02 +00:00
FmXFormShell : : FmXFormShell ( FmFormShell & _rShell , SfxViewFrame * _pViewFrame )
2000-11-06 13:09:32 +00:00
: FmXFormShell_BASE ( m_aMutex )
2001-02-21 12:45:24 +00:00
, FmXFormShell_CFGBASE ( : : rtl : : OUString : : createFromAscii ( " Office.Common/Misc " ) , CONFIG_MODE_DELAYED_UPDATE )
2006-06-19 14:57:11 +00:00
, m_eNavigate ( NavigationBarMode_NONE )
, m_nInvalidationEvent ( 0 )
, m_nActivationEvent ( 0 )
2008-08-28 05:55:02 +00:00
, m_pShell ( & _rShell )
2006-06-19 14:57:11 +00:00
, m_pTextShell ( new : : svx : : FmTextControlShell ( _pViewFrame ) )
2004-04-13 09:59:06 +00:00
, m_aActiveControllerFeatures ( : : comphelper : : getProcessServiceFactory ( ) , this )
, m_aNavControllerFeatures ( : : comphelper : : getProcessServiceFactory ( ) , this )
2006-06-19 14:57:11 +00:00
, m_pExternalViewInterceptor ( NULL )
2004-09-09 09:22:22 +00:00
, m_eDocumentType ( eUnknownDocumentType )
2006-06-19 14:57:11 +00:00
, m_nLockSlotInvalidation ( 0 )
, m_bHadPropertyBrowserInDesignMode ( sal_False )
, m_bTrackProperties ( sal_True )
, m_bUseWizards ( sal_True )
, m_bDatabaseBar ( sal_False )
, m_bInActivate ( sal_False )
, m_bSetFocus ( sal_False )
, m_bFilterMode ( sal_False )
, m_bChangingDesignMode ( sal_False )
, m_bPreparedClose ( sal_False )
2005-03-10 15:23:52 +00:00
, m_bFirstActivation ( sal_True )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
DBG_CTOR ( FmXFormShell , NULL ) ;
2000-09-18 16:07:07 +00:00
m_aMarkTimer . SetTimeout ( 100 ) ;
m_aMarkTimer . SetTimeoutHdl ( LINK ( this , FmXFormShell , OnTimeOut ) ) ;
SfxFrame * pFrame = _pViewFrame ? _pViewFrame - > GetFrame ( ) : NULL ;
2004-09-09 09:22:22 +00:00
if ( pFrame )
2004-10-22 10:53:40 +00:00
m_xAttachedFrame = pFrame - > GetFrameInterface ( ) ;
2000-09-18 16:07:07 +00:00
// to prevent deletion of this we acquire our refcounter once
2000-11-06 13:09:32 +00:00
: : comphelper : : increment ( FmXFormShell_BASE : : m_refCount ) ;
2000-09-18 16:07:07 +00:00
// correct the refcounter
2000-11-06 13:09:32 +00:00
: : comphelper : : decrement ( FmXFormShell_BASE : : m_refCount ) ;
2001-02-21 12:45:24 +00:00
// cache the current configuration settings we're interested in
implAdjustConfigCache ( ) ;
// and register for changes on this settings
Sequence < : : rtl : : OUString > aNames ( 1 ) ;
aNames [ 0 ] = : : rtl : : OUString : : createFromAscii ( " FormControlPilotsEnabled " ) ;
EnableNotification ( aNames ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------
FmXFormShell : : ~ FmXFormShell ( )
{
2004-05-07 14:47:38 +00:00
delete m_pTextShell ;
2000-11-07 12:16:50 +00:00
DBG_DTOR ( FmXFormShell , NULL ) ;
2000-09-18 16:07:07 +00:00
}
2008-08-28 05:55:02 +00:00
//------------------------------------------------------------------
2005-07-05 09:04:35 +00:00
Reference < XModel > FmXFormShell : : getContextDocument ( ) const
{
Reference < XModel > xModel ;
// determine the type of document we live in
2006-10-18 12:24:00 +00:00
try
{
Reference < XController > xController ;
if ( m_xAttachedFrame . is ( ) )
xController = m_xAttachedFrame - > getController ( ) ;
if ( xController . is ( ) )
xModel = xController - > getModel ( ) ;
}
catch ( const Exception & )
{
DBG_UNHANDLED_EXCEPTION ( ) ;
}
return xModel ;
2005-07-05 09:04:35 +00:00
}
2008-08-28 05:55:02 +00:00
//------------------------------------------------------------------
bool FmXFormShell : : isEnhancedForm ( ) const
2005-07-05 09:04:35 +00:00
{
2007-04-16 15:21:12 +00:00
return getDocumentType ( ) = = eEnhancedForm ;
2005-07-05 09:04:35 +00:00
}
2008-08-28 05:55:02 +00:00
//------------------------------------------------------------------
bool FmXFormShell : : impl_checkDisposed ( ) const
{
if ( ! m_pShell )
{
OSL_ENSURE ( false , " FmXFormShell::impl_checkDisposed: already disposed! " ) ;
return true ;
}
return false ;
}
2004-10-22 10:53:40 +00:00
//------------------------------------------------------------------
2005-01-21 15:57:42 +00:00
: : svxform : : DocumentType FmXFormShell : : getDocumentType ( ) const
2004-10-22 10:53:40 +00:00
{
if ( m_eDocumentType ! = eUnknownDocumentType )
return m_eDocumentType ;
// determine the type of document we live in
2005-07-05 09:04:35 +00:00
Reference < XModel > xModel = getContextDocument ( ) ;
2004-10-22 10:53:40 +00:00
if ( xModel . is ( ) )
m_eDocumentType = DocumentClassification : : classifyDocument ( xModel ) ;
else
{
OSL_ENSURE ( sal_False , " FmXFormShell::getDocumentType: can't determine the document type! " ) ;
m_eDocumentType = eTextDocument ;
// fallback, just to have a defined state
}
return m_eDocumentType ;
}
2005-01-21 15:57:42 +00:00
//------------------------------------------------------------------
bool FmXFormShell : : IsReadonlyDoc ( ) const
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return true ;
2005-01-21 15:57:42 +00:00
FmFormModel * pModel = m_pShell - > GetFormModel ( ) ;
if ( pModel & & pModel - > GetObjectShell ( ) )
return pModel - > GetObjectShell ( ) - > IsReadOnly ( ) | | pModel - > GetObjectShell ( ) - > IsReadOnlyUI ( ) ;
return true ;
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Any SAL_CALL FmXFormShell : : queryInterface ( const Type & type ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2000-11-06 13:09:32 +00:00
return FmXFormShell_BASE : : queryInterface ( type ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Sequence < Type > SAL_CALL FmXFormShell : : getTypes ( ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2000-11-06 13:09:32 +00:00
return FmXFormShell_BASE : : getTypes ( ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Sequence < sal_Int8 > SAL_CALL FmXFormShell : : getImplementationId ( ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2004-04-13 09:59:06 +00:00
static : : cppu : : OImplementationId * pId = 0 ;
if ( ! pId )
{
: : osl : : MutexGuard aGuard ( : : osl : : Mutex : : getGlobalMutex ( ) ) ;
if ( ! pId )
{
static : : cppu : : OImplementationId aId ;
pId = & aId ;
}
}
return pId - > getImplementationId ( ) ;
2000-09-18 16:07:07 +00:00
}
// EventListener
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void SAL_CALL FmXFormShell : : disposing ( const EventObject & e ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
impl_checkDisposed ( ) ;
2000-09-18 16:07:07 +00:00
if ( m_xActiveController = = e . Source )
{
// wird der Controller freigeben dann alles loslassen
stopListening ( ) ;
m_xActiveForm = NULL ;
m_xActiveController = NULL ;
m_xNavigationController = NULL ;
2000-09-21 11:31:31 +00:00
2004-04-13 09:59:06 +00:00
m_aActiveControllerFeatures . dispose ( ) ;
m_aNavControllerFeatures . dispose ( ) ;
2008-08-28 05:55:02 +00:00
if ( m_pShell )
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
}
if ( e . Source = = m_xExternalViewController )
{
2000-11-24 06:01:26 +00:00
Reference < XFormController > xFormController ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xFormController . is ( ) )
2000-11-24 06:01:26 +00:00
xFormController - > removeActivateListener ( ( XFormControllerListener * ) this ) ;
2000-09-18 16:07:07 +00:00
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : lang : : XComponent > xComp ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xComp . is ( ) )
2000-11-24 06:01:26 +00:00
xComp - > removeEventListener ( ( XEventListener * ) ( XPropertyChangeListener * ) this ) ;
2000-09-18 16:07:07 +00:00
m_xExternalViewController = NULL ;
m_xExternalDisplayedForm = NULL ;
m_xExtViewTriggerController = NULL ;
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_VIEW_AS_GRID , sal_False ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------------
2001-09-12 17:11:08 +00:00
void SAL_CALL FmXFormShell : : propertyChange ( const PropertyChangeEvent & evt ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
2006-01-03 15:11:58 +00:00
return ;
2004-04-13 09:59:06 +00:00
if ( evt . PropertyName = = FM_PROP_ROWCOUNT )
2000-09-18 16:07:07 +00:00
{
// Das gleich folgenden Update erzwingt ein Neu-Painten der entsprechenden Slots. Wenn ich mich aber hier nicht
// in dem HauptThread der Applikation befinde (weil zum Beispiel ein Cursor gerade Datensaetze zaehlt und mir dabei
// immer diese PropertyChanges beschert), kann sich das mit en normalen Paints im HauptThread der Applikation beissen.
// (Solche Paints passieren zum Beispiel, wenn man einfach nur eine andere Applikation ueber das Office legt und wieder
// zurueckschaltet).
// Deshalb die Benutzung des SolarMutex, der sichert das ab.
: : vos : : IMutex & rSolarSafety = Application : : GetSolarMutex ( ) ;
if ( rSolarSafety . tryToAcquire ( ) )
{
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( SID_FM_RECORD_TOTAL , sal_True , sal_False ) ;
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Update ( SID_FM_RECORD_TOTAL ) ;
2000-09-18 16:07:07 +00:00
rSolarSafety . release ( ) ;
}
else
{
// with the following the slot is invalidated asynchron
LockSlotInvalidation ( sal_True ) ;
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_RECORD_TOTAL , sal_False ) ;
2000-09-18 16:07:07 +00:00
LockSlotInvalidation ( sal_False ) ;
}
}
// this may be called from a non-main-thread so invalidate the shell asynchronously
LockSlotInvalidation ( sal_True ) ;
2005-01-05 11:21:07 +00:00
InvalidateSlot ( 0 , 0 ) ; // special meaning : invalidate m_pShell
2000-09-18 16:07:07 +00:00
LockSlotInvalidation ( sal_False ) ;
}
//------------------------------------------------------------------------------
2004-04-13 09:59:06 +00:00
void FmXFormShell : : invalidateFeatures ( const : : std : : vector < sal_Int32 > & _rFeatures )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2004-04-13 09:59:06 +00:00
OSL_ENSURE ( _rFeatures . size ( ) > 0 , " FmXFormShell::invalidateFeatures: invalid arguments! " ) ;
2002-11-12 10:28:01 +00:00
2008-08-28 05:55:02 +00:00
if ( m_pShell - > GetViewShell ( ) & & m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) )
2000-09-18 16:07:07 +00:00
{
2004-04-13 09:59:06 +00:00
// unfortunately, SFX requires sal_uInt16
: : std : : vector < sal_uInt16 > aSlotIds ;
aSlotIds . reserve ( _rFeatures . size ( ) ) ;
: : std : : copy ( _rFeatures . begin ( ) ,
_rFeatures . end ( ) ,
2008-01-29 16:09:57 +00:00
: : std : : insert_iterator < : : std : : vector < sal_uInt16 > > ( aSlotIds , aSlotIds . begin ( ) )
2004-04-13 09:59:06 +00:00
) ;
2000-09-18 16:07:07 +00:00
2004-04-13 09:59:06 +00:00
// furthermore, SFX wants a terminating 0
aSlotIds . push_back ( 0 ) ;
2000-09-18 16:07:07 +00:00
2004-04-13 09:59:06 +00:00
// and, last but not least, SFX wants the ids to be sorted
: : std : : sort ( aSlotIds . begin ( ) , aSlotIds . end ( ) - 1 ) ;
2000-09-18 16:07:07 +00:00
2004-09-08 13:40:45 +00:00
sal_uInt16 * pSlotIds = aSlotIds . empty ( ) ? 0 : & ( aSlotIds [ 0 ] ) ;
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( pSlotIds ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void SAL_CALL FmXFormShell : : formActivated ( const EventObject & rEvent ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2004-05-07 14:47:38 +00:00
2008-12-01 12:31:27 +00:00
Reference < XFormController > xController ( rEvent . Source , UNO_QUERY_THROW ) ;
2004-05-07 14:47:38 +00:00
m_pTextShell - > formActivated ( xController ) ;
2008-12-01 12:31:27 +00:00
setActiveController ( xController ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void SAL_CALL FmXFormShell : : formDeactivated ( const EventObject & rEvent ) throw ( RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2004-05-07 14:47:38 +00:00
2008-12-01 12:31:27 +00:00
Reference < XFormController > xController ( rEvent . Source , UNO_QUERY_THROW ) ;
2004-05-07 14:47:38 +00:00
m_pTextShell - > formDeactivated ( xController ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : disposing ( )
{
2008-08-28 05:55:02 +00:00
OSL_TRACE ( " --- FmXFormShell::disposing : %p, ........, ........ \n " , this ) ;
impl_checkDisposed ( ) ;
2000-11-06 13:09:32 +00:00
FmXFormShell_BASE : : disposing ( ) ;
2000-09-18 16:07:07 +00:00
2002-05-21 07:01:33 +00:00
if ( m_pShell & & ! m_pShell - > IsDesignMode ( ) )
2002-11-12 10:28:01 +00:00
setActiveController ( NULL , sal_True ) ;
// do NOT save the content of the old form (the second parameter tells this)
// if we're here, then we expect that PrepareClose has been called, and thus the user
2004-05-07 14:47:38 +00:00
// got a chance to commit or reject any changes. So in case we're here and there
2002-11-12 10:28:01 +00:00
// are still uncommitted changes, the user explicitly wanted this.
// 2002-11-11 - 104702 - fs@openoffice.org
2000-09-18 16:07:07 +00:00
// dispose our interceptor helpers
if ( m_pExternalViewInterceptor )
{
m_pExternalViewInterceptor - > dispose ( ) ;
m_pExternalViewInterceptor - > release ( ) ;
m_pExternalViewInterceptor = NULL ;
}
2004-05-07 14:47:38 +00:00
m_pTextShell - > dispose ( ) ;
2000-09-18 16:07:07 +00:00
m_xAttachedFrame = NULL ;
CloseExternalFormViewer ( ) ;
2002-09-09 13:27:00 +00:00
while ( m_aLoadingPages . size ( ) )
{
Application : : RemoveUserEvent ( m_aLoadingPages . front ( ) . nEventId ) ;
m_aLoadingPages . pop ( ) ;
}
2000-09-18 16:07:07 +00:00
{
: : osl : : MutexGuard aGuard ( m_aInvalidationSafety ) ;
if ( m_nInvalidationEvent )
{
Application : : RemoveUserEvent ( m_nInvalidationEvent ) ;
m_nInvalidationEvent = 0 ;
}
2005-03-10 15:23:52 +00:00
if ( m_nActivationEvent )
{
Application : : RemoveUserEvent ( m_nActivationEvent ) ;
m_nActivationEvent = 0 ;
}
2000-09-18 16:07:07 +00:00
}
2000-11-07 12:16:50 +00:00
{
: : osl : : ClearableMutexGuard aGuard ( m_aAsyncSafety ) ;
if ( HasAnyPendingCursorAction ( ) )
CancelAnyPendingCursorAction ( ) ;
aGuard . clear ( ) ;
DBG_ASSERT ( ! m_nInvalidationEvent , " FmXFormShell::~FmXFormShell : still have an invalidation event ! " ) ;
// should habe been deleted while beeing disposed
m_aMarkTimer . Stop ( ) ;
}
2006-01-19 14:40:05 +00:00
DisableNotification ( ) ;
2008-12-01 12:31:27 +00:00
RemoveElement ( m_xForms ) ;
m_xForms . clear ( ) ;
impl_switchActiveControllerListening ( false ) ;
2000-11-06 06:19:53 +00:00
m_xActiveController = NULL ;
m_xActiveForm = NULL ;
2008-12-01 12:31:27 +00:00
m_pShell = NULL ;
m_xNavigationController = NULL ;
2004-11-16 10:24:36 +00:00
m_xCurrentForm = NULL ;
2001-10-16 10:42:22 +00:00
m_xLastGridFound = NULL ;
2000-11-06 06:19:53 +00:00
m_xAttachedFrame = NULL ;
m_xExternalViewController = NULL ;
m_xExtViewTriggerController = NULL ;
m_xExternalDisplayedForm = NULL ;
2001-10-16 10:42:22 +00:00
m_xLastGridFound = NULL ;
2004-04-13 09:59:06 +00:00
2004-11-16 10:24:36 +00:00
InterfaceBag aEmpty ;
m_aCurrentSelection . swap ( aEmpty ) ;
2004-04-13 09:59:06 +00:00
m_aActiveControllerFeatures . dispose ( ) ;
m_aNavControllerFeatures . dispose ( ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2005-01-05 11:21:07 +00:00
void FmXFormShell : : UpdateSlot ( sal_Int16 _nId )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2005-01-05 11:21:07 +00:00
: : osl : : MutexGuard aGuard ( m_aInvalidationSafety ) ;
if ( m_nLockSlotInvalidation )
{
OSL_ENSURE ( sal_False , " FmXFormShell::UpdateSlot: cannot update if invalidation is currently locked! " ) ;
InvalidateSlot ( _nId , sal_False ) ;
}
else
{
OSL_ENSURE ( _nId , " FmXFormShell::UpdateSlot: can't update the complete shell! " ) ;
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( _nId , sal_True , sal_True ) ;
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Update ( _nId ) ;
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : InvalidateSlot ( sal_Int16 nId , sal_Bool bWithId )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2006-01-19 14:40:05 +00:00
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aInvalidationSafety ) ;
if ( m_nLockSlotInvalidation )
{
m_arrInvalidSlots . Insert ( nId , m_arrInvalidSlots . Count ( ) ) ;
2005-01-05 11:21:07 +00:00
BYTE nFlags = ( bWithId ? 0x01 : 0 ) ;
2000-09-18 16:07:07 +00:00
m_arrInvalidSlots_Flags . Insert ( nFlags , m_arrInvalidSlots_Flags . Count ( ) ) ;
}
else
if ( nId )
2005-01-05 11:21:07 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( nId , sal_True , bWithId ) ;
2000-09-18 16:07:07 +00:00
else
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : LockSlotInvalidation ( sal_Bool bLock )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aInvalidationSafety ) ;
DBG_ASSERT ( bLock | | m_nLockSlotInvalidation > 0 , " FmXFormShell::LockSlotInvalidation : invalid call ! " ) ;
if ( bLock )
+ + m_nLockSlotInvalidation ;
else if ( ! - - m_nLockSlotInvalidation )
{
// alles, was sich waehrend der gelockten Phase angesammelt hat, (asynchron) invalidieren
if ( ! m_nInvalidationEvent )
m_nInvalidationEvent = Application : : PostUserEvent ( LINK ( this , FmXFormShell , OnInvalidateSlots ) ) ;
}
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnInvalidateSlots , void * , EMPTYARG )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0L ;
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aInvalidationSafety ) ;
m_nInvalidationEvent = 0 ;
DBG_ASSERT ( m_arrInvalidSlots . Count ( ) = = m_arrInvalidSlots_Flags . Count ( ) ,
" FmXFormShell::OnInvalidateSlots : inconsistent slot arrays ! " ) ;
BYTE nFlags ;
for ( sal_Int16 i = 0 ; i < m_arrInvalidSlots . Count ( ) ; + + i )
{
nFlags = m_arrInvalidSlots_Flags [ i ] ;
if ( m_arrInvalidSlots [ i ] )
2005-01-05 11:21:07 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( m_arrInvalidSlots [ i ] , sal_True , ( nFlags & 0x01 ) ) ;
2000-09-18 16:07:07 +00:00
else
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
}
m_arrInvalidSlots . Remove ( 0 , m_arrInvalidSlots . Count ( ) ) ;
m_arrInvalidSlots_Flags . Remove ( 0 , m_arrInvalidSlots_Flags . Count ( ) ) ;
return 0L ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : ForceUpdateSelection ( sal_Bool bAllowInvalidation )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
if ( IsSelectionUpdatePending ( ) )
{
m_aMarkTimer . Stop ( ) ;
// die Invalidierung der Slots, die implizit von SetSelection besorgt wird, eventuell abschalten
if ( ! bAllowInvalidation )
LockSlotInvalidation ( sal_True ) ;
2004-07-12 13:36:51 +00:00
SetSelection ( m_pShell - > GetFormView ( ) - > GetMarkedObjectList ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( ! bAllowInvalidation )
LockSlotInvalidation ( sal_False ) ;
}
}
//------------------------------------------------------------------------------
PopupMenu * FmXFormShell : : GetConversionMenu ( )
{
2002-05-31 04:49:29 +00:00
const StyleSettings & rSettings = Application : : GetSettings ( ) . GetStyleSettings ( ) ;
BOOL bIsHiContrastMode = rSettings . GetMenuColor ( ) . IsDark ( ) ;
2000-09-18 16:07:07 +00:00
2002-05-31 04:49:29 +00:00
PopupMenu * pNewMenu = new PopupMenu ( SVX_RES ( RID_FMSHELL_CONVERSIONMENU ) ) ;
ImageList aImageList ( SVX_RES ( bIsHiContrastMode ? RID_SVXIMGLIST_FMEXPL_HC : RID_SVXIMGLIST_FMEXPL ) ) ;
2006-06-19 14:57:11 +00:00
for ( size_t i = 0 ; i < sizeof ( nConvertSlots ) / sizeof ( nConvertSlots [ 0 ] ) ; + + i )
2000-09-18 16:07:07 +00:00
{
// das entsprechende Image dran
pNewMenu - > SetItemImage ( nConvertSlots [ i ] , aImageList . GetImage ( nCreateSlots [ i ] ) ) ;
}
return pNewMenu ;
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
bool FmXFormShell : : isControlConversionSlot ( sal_uInt16 nSlotId )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
for ( size_t i = 0 ; i < sizeof ( nConvertSlots ) / sizeof ( nConvertSlots [ 0 ] ) ; + + i )
2000-09-18 16:07:07 +00:00
if ( nConvertSlots [ i ] = = nSlotId )
2004-11-16 10:24:36 +00:00
return true ;
return false ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
bool FmXFormShell : : executeControlConversionSlot ( sal_uInt16 _nSlotId )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
OSL_PRECOND ( canConvertCurrentSelectionToControl ( _nSlotId ) , " FmXFormShell::executeControlConversionSlot: illegal call! " ) ;
InterfaceBag : : const_iterator aSelectedElement = m_aCurrentSelection . begin ( ) ;
if ( aSelectedElement = = m_aCurrentSelection . end ( ) )
return false ;
return executeControlConversionSlot ( Reference < XFormComponent > ( * aSelectedElement , UNO_QUERY ) , _nSlotId ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
bool FmXFormShell : : executeControlConversionSlot ( const Reference < XFormComponent > & _rxObject , sal_uInt16 _nSlotId )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return false ;
2004-11-16 10:24:36 +00:00
OSL_ENSURE ( _rxObject . is ( ) , " FmXFormShell::executeControlConversionSlot: invalid object! " ) ;
if ( ! _rxObject . is ( ) )
return false ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
SdrPage * pPage = m_pShell - > GetCurPage ( ) ;
FmFormPage * pFormPage = pPage ? dynamic_cast < FmFormPage * > ( pPage ) : NULL ;
OSL_ENSURE ( pFormPage , " FmXFormShell::executeControlConversionSlot: no current (form) page! " ) ;
if ( ! pFormPage )
return false ;
2004-11-16 10:24:36 +00:00
OSL_ENSURE ( isSolelySelected ( _rxObject ) ,
" FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant? " ) ;
2000-09-18 16:07:07 +00:00
2006-06-19 14:57:11 +00:00
for ( size_t lookupSlot = 0 ; lookupSlot < sizeof ( nConvertSlots ) / sizeof ( nConvertSlots [ 0 ] ) ; + + lookupSlot )
2004-11-16 10:24:36 +00:00
{
if ( nConvertSlots [ lookupSlot ] = = _nSlotId )
{
2008-12-01 12:31:27 +00:00
Reference < XInterface > xNormalizedObject ( _rxObject , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
FmFormObj * pFormObject = NULL ;
SdrObjListIter aPageIter ( * pFormPage ) ;
while ( aPageIter . IsMore ( ) )
2004-11-16 10:24:36 +00:00
{
2008-12-01 12:31:27 +00:00
SdrObject * pCurrent = aPageIter . Next ( ) ;
pFormObject = FmFormObj : : GetFormObject ( pCurrent ) ;
if ( ! pFormObject )
continue ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
Reference < XInterface > xCurrentNormalized ( pFormObject - > GetUnoControlModel ( ) , UNO_QUERY ) ;
if ( xCurrentNormalized . get ( ) = = xNormalizedObject . get ( ) )
2004-11-16 10:24:36 +00:00
break ;
2008-12-01 12:31:27 +00:00
pFormObject = NULL ;
2004-11-16 10:24:36 +00:00
}
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
if ( ! pFormObject )
2004-11-16 10:24:36 +00:00
return false ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
: : rtl : : OUString sNewName ( getServiceNameByControlType ( nObjectTypes [ lookupSlot ] ) ) ;
Reference < XControlModel > xNewModel ( : : comphelper : : getProcessServiceFactory ( ) - > createInstance ( sNewName ) , UNO_QUERY ) ;
if ( ! xNewModel . is ( ) )
return false ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
Reference < XControlModel > xOldModel ( pFormObject - > GetUnoControlModel ( ) ) ;
2004-11-16 10:24:36 +00:00
Reference < XServiceInfo > xModelInfo ( xOldModel , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// Properties uebertragen
Reference < XPropertySet > xOldSet ( xOldModel , UNO_QUERY ) ;
Reference < XPropertySet > xNewSet ( xNewModel , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
Locale aNewLanguage = Application : : GetSettings ( ) . GetUILocale ( ) ;
TransferFormComponentProperties ( xOldSet , xNewSet , aNewLanguage ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
Sequence < : : com : : sun : : star : : script : : ScriptEventDescriptor > aOldScripts ;
Reference < XChild > xChild ( xOldModel , UNO_QUERY ) ;
if ( xChild . is ( ) )
{
Reference < XIndexAccess > xParent ( xChild - > getParent ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// remember old script events
Reference < : : com : : sun : : star : : script : : XEventAttacherManager > xEvManager ( xChild - > getParent ( ) , UNO_QUERY ) ;
if ( xParent . is ( ) & & xEvManager . is ( ) )
{
sal_Int32 nIndex = getElementPos ( xParent , xOldModel ) ;
if ( nIndex > = 0 & & nIndex < xParent - > getCount ( ) )
aOldScripts = xEvManager - > getScriptEvents ( nIndex ) ;
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// replace the mdoel within the parent container
Reference < XIndexContainer > xIndexParent ( xChild - > getParent ( ) , UNO_QUERY ) ; //Modified by BerryJia for fixing Bug102516 Time(China):2002-9-5 16:00
if ( xIndexParent . is ( ) )
{
// the form container works with FormComponents
Reference < XFormComponent > xComponent ( xNewModel , UNO_QUERY ) ;
DBG_ASSERT ( xComponent . is ( ) , " FmXFormShell::executeControlConversionSlot: the new model is no form component ! " ) ;
Any aNewModel ( makeAny ( xComponent ) ) ;
try
{
//Modified by BerryJia for fixing Bug102516 Time(China):2002-9-5 16:00
sal_Int32 nIndex = getElementPos ( xParent , xOldModel ) ;
if ( nIndex > = 0 & & nIndex < xParent - > getCount ( ) )
xIndexParent - > replaceByIndex ( nIndex , aNewModel ) ;
else
{
DBG_ERROR ( " FmXFormShell::executeControlConversionSlot: could not replace the model ! " ) ;
Reference < : : com : : sun : : star : : lang : : XComponent > xNewComponent ( xNewModel , UNO_QUERY ) ;
if ( xNewComponent . is ( ) )
xNewComponent - > dispose ( ) ;
return false ;
}
}
catch ( Exception & )
{
DBG_ERROR ( " FmXFormShell::executeControlConversionSlot: could not replace the model ! " ) ;
Reference < : : com : : sun : : star : : lang : : XComponent > xNewComponent ( xNewModel , UNO_QUERY ) ;
if ( xNewComponent . is ( ) )
xNewComponent - > dispose ( ) ;
return false ;
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
}
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// special handling for the LabelControl-property : can only be set when the model is placed
// within the forms hierarchy
if ( : : comphelper : : hasProperty ( FM_PROP_CONTROLLABEL , xOldSet ) & & : : comphelper : : hasProperty ( FM_PROP_CONTROLLABEL , xNewSet ) )
{
try
{
xNewSet - > setPropertyValue ( FM_PROP_CONTROLLABEL , xOldSet - > getPropertyValue ( FM_PROP_CONTROLLABEL ) ) ;
}
catch ( Exception & )
{
}
2001-07-20 11:49:12 +00:00
2004-11-16 10:24:36 +00:00
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// neues Model setzen
2008-12-01 12:31:27 +00:00
pFormObject - > SetChanged ( ) ;
pFormObject - > SetUnoControlModel ( xNewModel ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// transfer script events
// (do this _after_ SetUnoControlModel as we need the new (implicitly created) control)
if ( aOldScripts . getLength ( ) )
{
// das Control zum Model suchen
Reference < XControlContainer > xControlContainer ( getControlContainerForView ( ) ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
Sequence < Reference < XControl > > aControls ( xControlContainer - > getControls ( ) ) ;
const Reference < XControl > * pControls = aControls . getConstArray ( ) ;
sal_uInt32 nLen = aControls . getLength ( ) ;
Reference < XControl > xControl ;
for ( sal_uInt32 i = 0 ; i < nLen ; + + i )
{
if ( pControls [ i ] - > getModel ( ) = = xNewModel )
{
xControl = pControls [ i ] ;
break ;
}
}
TransferEventScripts ( xNewModel , xControl , aOldScripts ) ;
}
// transfer value bindings, if possible
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
Reference < XBindableValue > xOldBindable ( xOldModel , UNO_QUERY ) ;
Reference < XBindableValue > xNewBindable ( xNewModel , UNO_QUERY ) ;
2002-09-05 09:31:41 +00:00
{
2008-11-19 17:43:08 +00:00
try
{
xNewBindable - > setValueBinding ( xOldBindable - > getValueBinding ( ) ) ;
xOldBindable - > setValueBinding ( NULL ) ;
}
catch ( const IncompatibleTypesException & )
{
}
2002-09-05 09:31:41 +00:00
}
2000-09-18 16:07:07 +00:00
}
2004-11-16 10:24:36 +00:00
// same for list entry sources
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
Reference < XListEntrySink > xOldSink ( xOldModel , UNO_QUERY ) ;
Reference < XListEntrySink > xNewSink ( xNewModel , UNO_QUERY ) ;
if ( xOldSink . is ( ) & & xNewSink . is ( ) )
{
2008-11-19 17:43:08 +00:00
try
{
xNewSink - > setListEntrySource ( xOldSink - > getListEntrySource ( ) ) ;
xOldSink - > setListEntrySource ( NULL ) ;
}
catch ( const Exception & )
{
DBG_ERROR ( " FmXFormShell::executeControlConversionSlot: caught an exception while creating the control ! " ) ;
}
2004-11-16 10:24:36 +00:00
}
2000-09-18 16:07:07 +00:00
}
2004-11-16 10:24:36 +00:00
// create an undo action
FmFormModel * pModel = m_pShell - > GetFormModel ( ) ;
DBG_ASSERT ( pModel ! = NULL , " FmXFormShell::executeControlConversionSlot: my shell has no model ! " ) ;
if ( pModel )
2008-12-01 12:31:27 +00:00
pModel - > AddUndo ( new FmUndoModelReplaceAction ( * pModel , pFormObject , xOldModel ) ) ;
2004-11-16 10:24:36 +00:00
return true ;
2000-09-18 16:07:07 +00:00
}
}
2004-11-16 10:24:36 +00:00
return false ;
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
//------------------------------------------------------------------------------
bool FmXFormShell : : canConvertCurrentSelectionToControl ( sal_Int16 nConversionSlot )
{
if ( m_aCurrentSelection . empty ( ) )
return false ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
InterfaceBag : : const_iterator aCheck = m_aCurrentSelection . begin ( ) ;
Reference < XServiceInfo > xElementInfo ( * aCheck , UNO_QUERY ) ;
if ( ! xElementInfo . is ( ) )
// no service info -> cannot determine this
return false ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( + + aCheck ! = m_aCurrentSelection . end ( ) )
// more than one element
return false ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( Reference < XForm > : : query ( xElementInfo ) . is ( ) )
// it's a form
return false ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
sal_Int16 nObjectType = getControlTypeByObject ( xElementInfo ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( ( OBJ_FM_HIDDEN = = nObjectType )
| | ( OBJ_FM_CONTROL = = nObjectType )
| | ( OBJ_FM_GRID = = nObjectType )
)
return false ; // those types cannot be converted
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
DBG_ASSERT ( sizeof ( nConvertSlots ) / sizeof ( nConvertSlots [ 0 ] ) = = sizeof ( nObjectTypes ) / sizeof ( nObjectTypes [ 0 ] ) ,
" FmXFormShell::canConvertCurrentSelectionToControl: nConvertSlots & nObjectTypes must have the same size ! " ) ;
2003-10-21 07:44:09 +00:00
2006-06-19 14:57:11 +00:00
for ( size_t i = 0 ; i < sizeof ( nConvertSlots ) / sizeof ( nConvertSlots [ 0 ] ) ; + + i )
2004-11-16 10:24:36 +00:00
if ( nConvertSlots [ i ] = = nConversionSlot )
return nObjectTypes [ i ] ! = nObjectType ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
return sal_True ; // all other slots: assume "yes"
}
//------------------------------------------------------------------------------
void FmXFormShell : : checkControlConversionSlotsForCurrentSelection ( Menu & rMenu )
{
for ( sal_Int16 i = 0 ; i < rMenu . GetItemCount ( ) ; + + i )
// der Context ist schon von einem Typ, der dem Eitnrag entspricht -> disable
rMenu . EnableItem ( rMenu . GetItemId ( i ) , canConvertCurrentSelectionToControl ( rMenu . GetItemId ( i ) ) ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : LoopGrids ( sal_Int16 nWhat )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XIndexContainer > xControlModels ( m_xActiveForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xControlModels . is ( ) )
2004-03-19 11:20:43 +00:00
{
2000-09-18 16:07:07 +00:00
for ( sal_Int16 i = 0 ; i < xControlModels - > getCount ( ) ; + + i )
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xModelSet ;
2000-11-07 12:16:50 +00:00
xControlModels - > getByIndex ( i ) > > = xModelSet ;
2000-09-18 16:07:07 +00:00
if ( ! xModelSet . is ( ) )
continue ;
2000-10-20 13:18:57 +00:00
if ( ! : : comphelper : : hasProperty ( FM_PROP_CLASSID , xModelSet ) )
2000-09-18 16:07:07 +00:00
continue ;
2000-10-20 13:18:57 +00:00
sal_Int16 nClassId = : : comphelper : : getINT16 ( xModelSet - > getPropertyValue ( FM_PROP_CLASSID ) ) ;
2000-11-24 06:01:26 +00:00
if ( FormComponentType : : GRIDCONTROL ! = nClassId )
2000-09-18 16:07:07 +00:00
continue ;
2000-10-20 13:18:57 +00:00
if ( ! : : comphelper : : hasProperty ( FM_PROP_CURSORCOLOR , xModelSet ) | | ! : : comphelper : : hasProperty ( FM_PROP_ALWAYSSHOWCURSOR , xModelSet ) | | ! : : comphelper : : hasProperty ( FM_PROP_DISPLAYSYNCHRON , xModelSet ) )
2000-09-18 16:07:07 +00:00
continue ;
switch ( nWhat & GA_SYNC_MASK )
{
case GA_DISABLE_SYNC :
{
sal_Bool bB ( sal_False ) ;
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_DISPLAYSYNCHRON , Any ( & bB , getBooleanCppuType ( ) ) ) ;
2000-09-18 16:07:07 +00:00
}
break ;
case GA_FORCE_SYNC :
{
2000-11-24 06:01:26 +00:00
Any aOldVal ( xModelSet - > getPropertyValue ( FM_PROP_DISPLAYSYNCHRON ) ) ;
2000-09-18 16:07:07 +00:00
sal_Bool bB ( sal_True ) ;
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_DISPLAYSYNCHRON , Any ( & bB , getBooleanCppuType ( ) ) ) ;
2000-09-18 16:07:07 +00:00
xModelSet - > setPropertyValue ( FM_PROP_DISPLAYSYNCHRON , aOldVal ) ;
}
break ;
case GA_ENABLE_SYNC :
{
sal_Bool bB ( sal_True ) ;
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_DISPLAYSYNCHRON , Any ( & bB , getBooleanCppuType ( ) ) ) ;
2000-09-18 16:07:07 +00:00
}
break ;
}
if ( nWhat & GA_DISABLE_ROCTRLR )
{
sal_Bool bB ( sal_False ) ;
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_ALWAYSSHOWCURSOR , Any ( & bB , getBooleanCppuType ( ) ) ) ;
Reference < XPropertyState > xModelPropState ( xModelSet , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xModelPropState . is ( ) )
xModelPropState - > setPropertyToDefault ( FM_PROP_CURSORCOLOR ) ;
else
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_CURSORCOLOR , Any ( ) ) ; // this should be the default
2000-09-18 16:07:07 +00:00
}
else if ( nWhat & GA_ENABLE_ROCTRLR )
{
sal_Bool bB ( sal_True ) ;
2000-11-24 06:01:26 +00:00
xModelSet - > setPropertyValue ( FM_PROP_ALWAYSSHOWCURSOR , Any ( & bB , getBooleanCppuType ( ) ) ) ;
xModelSet - > setPropertyValue ( FM_PROP_CURSORCOLOR , makeAny ( sal_Int32 ( COL_LIGHTRED ) ) ) ;
2000-09-18 16:07:07 +00:00
}
}
2004-03-19 11:20:43 +00:00
}
}
2000-09-18 16:07:07 +00:00
2004-03-19 11:20:43 +00:00
//------------------------------------------------------------------------------
Reference < XControlContainer > FmXFormShell : : getControlContainerForView ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return NULL ;
2004-03-19 11:20:43 +00:00
SdrPageView * pPageView = NULL ;
if ( m_pShell & & m_pShell - > GetFormView ( ) )
2006-11-14 12:25:13 +00:00
pPageView = m_pShell - > GetFormView ( ) - > GetSdrPageView ( ) ;
2000-09-18 16:07:07 +00:00
2004-03-19 11:20:43 +00:00
Reference < XControlContainer > xControlContainer ;
if ( pPageView )
2006-11-14 12:25:13 +00:00
xControlContainer = pPageView - > GetPageWindow ( 0 ) - > GetControlContainer ( ) ;
2000-09-18 16:07:07 +00:00
2004-03-19 11:20:43 +00:00
return xControlContainer ;
}
2000-09-18 16:07:07 +00:00
2004-03-19 11:20:43 +00:00
//------------------------------------------------------------------------------
void FmXFormShell : : ExecuteTabOrderDialog ( const Reference < XTabControllerModel > & _rxForForm )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2004-03-19 11:20:43 +00:00
OSL_PRECOND ( _rxForForm . is ( ) , " FmXFormShell::ExecuteTabOrderDialog: invalid tabbing model! " ) ;
if ( ! _rxForForm . is ( ) )
return ;
try
{
Sequence < Any > aDialogArgs ( 3 ) ;
aDialogArgs [ 0 ] < < = NamedValue (
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " TabbingModel " ) ) ,
makeAny ( _rxForForm )
) ;
aDialogArgs [ 1 ] < < = NamedValue (
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ControlContext " ) ) ,
makeAny ( getControlContainerForView ( ) )
) ;
Reference < XWindow > xParentWindow ;
2008-08-28 05:55:02 +00:00
if ( m_pShell - > GetViewShell ( ) & & m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) )
2004-03-19 11:20:43 +00:00
xParentWindow = VCLUnoHelper : : GetInterface ( & m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetWindow ( ) ) ;
aDialogArgs [ 2 ] < < = NamedValue (
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ParentWindow " ) ) ,
makeAny ( xParentWindow )
) ;
Reference < dialogs : : XExecutableDialog > xDialog (
: : comphelper : : getProcessServiceFactory ( ) - > createInstanceWithArguments (
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.form.ui.TabOrderDialog " ) ) ,
aDialogArgs
) ,
UNO_QUERY
) ;
OSL_ENSURE ( xDialog . is ( ) , " FmXFormShell::ExecuteTabOrderDialog: could not create the dialog! " ) ;
if ( xDialog . is ( ) )
xDialog - > execute ( ) ;
}
catch ( const Exception & )
{
OSL_ENSURE ( sal_False , " FmXFormShell::ExecuteTabOrderDialog: caught an exception! " ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : ExecuteSearch ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
// eine Sammlung aller (logischen) Formulare
2007-07-31 12:57:49 +00:00
FmFormArray aEmpty ;
m_aSearchForms . swap ( aEmpty ) ;
: : std : : vector < String > aContextNames ;
impl_collectFormSearchContexts_nothrow ( m_pShell - > GetCurPage ( ) - > GetForms ( ) , : : rtl : : OUString ( ) , m_aSearchForms , aContextNames ) ;
OSL_POSTCOND ( m_aSearchForms . size ( ) = = aContextNames . size ( ) ,
" FmXFormShell::ExecuteSearch: nonsense! " ) ;
if ( m_aSearchForms . size ( ) ! = aContextNames . size ( ) )
return ;
2000-09-18 16:07:07 +00:00
2007-07-31 12:57:49 +00:00
// 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
)
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
FmSearchContext aTestContext ;
aTestContext . nContext = static_cast < sal_Int16 > ( i - 1 ) ;
sal_uInt32 nValidControls = OnSearchContextRequest ( & aTestContext ) ;
if ( nValidControls = = 0 )
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
m_aSearchForms . erase ( form . base ( ) - 1 ) ;
aContextNames . erase ( contextName . base ( ) - 1 ) ;
2000-09-18 16:07:07 +00:00
}
}
2007-07-31 12:57:49 +00:00
if ( m_aSearchForms . size ( ) = = 0 )
2000-09-18 16:07:07 +00:00
{ // es gibt keine Controls, die alle Bedingungen fuer eine Suche erfuellen
ErrorBox ( NULL , WB_OK , SVX_RESSTR ( RID_STR_NODATACONTROLS ) ) . Execute ( ) ;
return ;
}
// jetzt brauche ich noch einen 'initial context'
sal_Int16 nInitialContext = 0 ;
2000-11-24 06:01:26 +00:00
Reference < XForm > xActiveForm ( getActiveForm ( ) ) ;
2007-07-31 12:57:49 +00:00
for ( i = 0 ; i < ( sal_Int32 ) m_aSearchForms . size ( ) ; + + i )
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
if ( m_aSearchForms . at ( i ) = = xActiveForm )
2000-09-18 16:07:07 +00:00
{
2001-07-25 12:57:12 +00:00
nInitialContext = ( sal_Int16 ) i ;
2000-09-18 16:07:07 +00:00
break ;
}
}
// wenn der Dialog initial den Text des aktiven Controls anbieten soll, muss dieses ein XTextComponent-Interface habe,
// ausserdem macht das nur Sinn, wenn das aktuelle Feld auch an ein Tabellen- (oder was-auch-immer-)Feld gebunden ist
UniString strActiveField ;
UniString strInitialText ;
// ... das bekomme ich von meinem FormController
DBG_ASSERT ( m_xActiveController . is ( ) , " FmXFormShell::ExecuteSearch : no active controller ! " ) ;
2000-11-24 06:01:26 +00:00
Reference < XControl > xActiveControl ( m_xActiveController - > getCurrentControl ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( xActiveControl . is ( ) )
{
// das Control kann mir sein Model sagen ...
2000-11-24 06:01:26 +00:00
Reference < XControlModel > xActiveModel ( xActiveControl - > getModel ( ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xActiveModel . is ( ) , " FmXFormShell::ExecuteSearch : active control has no model ! " ) ;
// das Model frage ich nach der ControlSource-Eigenschaft ...
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xProperties ( xActiveControl - > getModel ( ) , UNO_QUERY ) ;
2000-10-20 13:18:57 +00:00
if ( : : comphelper : : hasProperty ( FM_PROP_CONTROLSOURCE , xProperties ) & & : : comphelper : : hasProperty ( FM_PROP_BOUNDFIELD , xProperties ) )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xField ;
2000-11-07 12:16:50 +00:00
xProperties - > getPropertyValue ( FM_PROP_BOUNDFIELD ) > > = xField ;
2000-09-18 16:07:07 +00:00
if ( xField . is ( ) ) // (nur wenn das Ding wirklich gebunden ist)
{
// und das Control selber nach einem TextComponent-Interface (damit ich mir dort den Text abholen kann)
2000-11-24 06:01:26 +00:00
Reference < XTextComponent > xText ( xActiveControl , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xText . is ( ) )
{
strActiveField = getLabelName ( xProperties ) . getStr ( ) ;
strInitialText = xText - > getText ( ) . getStr ( ) ;
}
}
}
else
{
// das Control selber hat keine ControlSource, aber vielleicht ist es ein GridControl
2000-11-24 06:01:26 +00:00
Reference < XGrid > xGrid ( xActiveControl , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xGrid . is ( ) )
{
// fuer strActiveField brauche ich die die ControlSource der Column, dafuer den Columns-Container, dafuer die
// GridPeer
2000-11-24 06:01:26 +00:00
Reference < XGridPeer > xGridPeer ( xActiveControl - > getPeer ( ) , UNO_QUERY ) ;
Reference < XIndexAccess > xColumns ;
2000-09-18 16:07:07 +00:00
if ( xGridPeer . is ( ) )
2000-11-24 06:01:26 +00:00
xColumns = Reference < XIndexAccess > ( xGridPeer - > getColumns ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
sal_Int16 nViewCol = xGrid - > getCurrentColumnPosition ( ) ;
sal_Int16 nModelCol = GridView2ModelPos ( xColumns , nViewCol ) ;
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xCurrentCol ;
2000-11-07 12:16:50 +00:00
if ( xColumns . is ( ) )
xColumns - > getByIndex ( nModelCol ) > > = xCurrentCol ;
2000-09-18 16:07:07 +00:00
if ( xCurrentCol . is ( ) )
2000-10-20 13:18:57 +00:00
strActiveField = : : comphelper : : getString ( xCurrentCol - > getPropertyValue ( FM_PROP_LABEL ) ) . getStr ( ) ;
2000-09-18 16:07:07 +00:00
// the text fo the current column
2000-11-24 06:01:26 +00:00
Reference < XIndexAccess > xColControls ( xGridPeer , UNO_QUERY ) ;
Reference < XInterface > xCurControl ;
2000-11-07 12:16:50 +00:00
xColControls - > getByIndex ( nViewCol ) > > = xCurControl ;
2000-09-18 16:07:07 +00:00
: : rtl : : OUString sInitialText ;
if ( IsSearchableControl ( xCurControl , & sInitialText ) )
strInitialText = sInitialText . getStr ( ) ;
}
}
}
// um eventuelle GridControls, die ich kenne, kuemmern
LoopGrids ( GA_DISABLE_SYNC /*| GA_ENABLE_ROCTRLR*/ ) ;
// jetzt bin ich reif fuer den Dialog
// wenn die potentiellen Deadlocks, die durch die Benutzung des Solar-Mutex in MTs VCLX...-Klasen entstehen, irgendwann mal
// ausgeraeumt sind, sollte hier ein SM_USETHREAD rein, denn die Suche in einem eigenen Thread ist doch etwas fluessiger
// sollte allerdings irgendwie von dem unterliegenden Cursor abhaengig gemacht werden, DAO zum Beispiel ist nicht thread-sicher
2004-02-03 18:09:19 +00:00
SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory : : Create ( ) ;
2004-11-16 13:45:44 +00:00
AbstractFmSearchDialog * pDialog = NULL ;
if ( pFact )
2007-07-31 12:57:49 +00:00
pDialog = pFact - > CreateFmSearchDialog ( & m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetWindow ( ) , strInitialText , aContextNames , nInitialContext , LINK ( this , FmXFormShell , OnSearchContextRequest ) ) ;
2004-11-16 13:45:44 +00:00
DBG_ASSERT ( pDialog , " FmXFormShell::ExecuteSearch: could not create the search dialog! " ) ;
if ( pDialog )
{
pDialog - > SetActiveField ( strActiveField ) ;
pDialog - > SetFoundHandler ( LINK ( this , FmXFormShell , OnFoundData ) ) ;
pDialog - > SetCanceledNotFoundHdl ( LINK ( this , FmXFormShell , OnCanceledNotFound ) ) ;
pDialog - > Execute ( ) ;
delete pDialog ;
}
2000-09-18 16:07:07 +00:00
// GridControls wieder restaurieren
LoopGrids ( GA_ENABLE_SYNC | GA_DISABLE_ROCTRLR ) ;
2006-11-14 12:25:13 +00:00
m_pShell - > GetFormView ( ) - > UnMarkAll ( m_pShell - > GetFormView ( ) - > GetSdrPageView ( ) ) ;
2000-09-18 16:07:07 +00:00
// da ich in OnFoundData (fals ich dort war) Controls markiert habe
}
//------------------------------------------------------------------------------
sal_Bool FmXFormShell : : GetY2KState ( sal_uInt16 & n )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return sal_False ;
2000-09-18 16:07:07 +00:00
if ( m_pShell - > IsDesignMode ( ) )
// im Design-Modus (ohne aktive Controls) soll sich das Haupt-Dokument darum kuemmern
return sal_False ;
2000-11-24 06:01:26 +00:00
Reference < XForm > xForm ( getActiveForm ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( ! xForm . is ( ) )
// kein aktuelles Formular (also insbesondere kein aktuelles Control) -> das Haupt-Dokument soll sich kuemmern
return sal_False ;
2000-11-24 06:01:26 +00:00
Reference < XRowSet > xDB ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xDB . is ( ) , " FmXFormShell::GetY2KState : current form has no dbform-interface ! " ) ;
2002-10-07 12:09:48 +00:00
Reference < XNumberFormatsSupplier > xSupplier ( getNumberFormats ( OStaticDataAccessTools ( ) . getRowSetConnection ( xDB ) , sal_False ) ) ;
2000-09-18 16:07:07 +00:00
if ( xSupplier . is ( ) )
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xSet ( xSupplier - > getNumberFormatSettings ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( xSet . is ( ) )
{
try
{
2000-11-24 06:01:26 +00:00
Any aVal ( xSet - > getPropertyValue ( : : rtl : : OUString : : createFromAscii ( " TwoDigitDateStart " ) ) ) ;
2000-09-18 16:07:07 +00:00
aVal > > = n ;
return sal_True ;
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
}
}
}
return sal_False ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : SetY2KState ( sal_uInt16 n )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2006-06-19 14:57:11 +00:00
Reference < XForm > xActiveForm ( getActiveForm ( ) ) ;
Reference < XRowSet > xActiveRowSet ( xActiveForm , UNO_QUERY ) ;
if ( xActiveRowSet . is ( ) )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
Reference < XNumberFormatsSupplier > xSupplier ( getNumberFormats ( getRowSetConnection ( xActiveRowSet ) , sal_False ) ) ;
2000-09-18 16:07:07 +00:00
if ( xSupplier . is ( ) )
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xSet ( xSupplier - > getNumberFormatSettings ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( xSet . is ( ) )
{
try
{
2000-11-24 06:01:26 +00:00
Any aVal ;
2000-09-18 16:07:07 +00:00
aVal < < = n ;
xSet - > setPropertyValue ( : : rtl : : OUString : : createFromAscii ( " TwoDigitDateStart " ) , aVal ) ;
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
DBG_ERROR ( " FmXFormShell::SetY2KState: Exception occured! " ) ;
2000-09-18 16:07:07 +00:00
}
}
return ;
}
}
// kein aktives Formular gefunden -> alle aktuell vorhandenen Formulare durchiterieren
2000-11-24 06:01:26 +00:00
Reference < XIndexAccess > xCurrentForms ( m_xForms ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCurrentForms . is ( ) )
{ // im alive-Modus sind meine Forms nicht gesetzt, wohl aber die an der Page
if ( m_pShell - > GetCurPage ( ) )
2005-03-18 17:43:13 +00:00
xCurrentForms = Reference < XIndexAccess > ( m_pShell - > GetCurPage ( ) - > GetForms ( false ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
}
if ( ! xCurrentForms . is ( ) )
return ;
2000-10-20 13:18:57 +00:00
: : comphelper : : IndexAccessIterator aIter ( xCurrentForms ) ;
2000-11-24 06:01:26 +00:00
Reference < XInterface > xCurrentElement ( aIter . Next ( ) ) ;
2000-09-18 16:07:07 +00:00
while ( xCurrentElement . is ( ) )
{
// ist das aktuelle Element eine DatabaseForm ?
2006-06-19 14:57:11 +00:00
Reference < XRowSet > xElementAsRowSet ( xCurrentElement , UNO_QUERY ) ;
if ( xElementAsRowSet . is ( ) )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
Reference < XNumberFormatsSupplier > xSupplier ( getNumberFormats ( getRowSetConnection ( xElementAsRowSet ) , sal_False ) ) ;
2000-09-18 16:07:07 +00:00
if ( ! xSupplier . is ( ) )
continue ;
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xSet ( xSupplier - > getNumberFormatSettings ( ) ) ;
2000-09-18 16:07:07 +00:00
if ( xSet . is ( ) )
{
try
{
2000-11-24 06:01:26 +00:00
Any aVal ;
2000-09-18 16:07:07 +00:00
aVal < < = n ;
xSet - > setPropertyValue ( : : rtl : : OUString : : createFromAscii ( " TwoDigitDateStart " ) , aVal ) ;
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
DBG_ERROR ( " FmXFormShell::SetY2KState: Exception occured! " ) ;
2000-09-18 16:07:07 +00:00
}
}
}
xCurrentElement = aIter . Next ( ) ;
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : CloseExternalFormViewer ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
if ( ! m_xExternalViewController . is ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XFrame > xExternalViewFrame ( m_xExternalViewController - > getFrame ( ) ) ;
Reference < : : com : : sun : : star : : frame : : XDispatchProvider > xCommLink ( xExternalViewFrame , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCommLink . is ( ) )
return ;
2001-11-22 12:17:07 +00:00
xExternalViewFrame - > setComponent ( NULL , NULL ) ;
: : comphelper : : disposeComponent ( xExternalViewFrame ) ;
m_xExternalViewController = NULL ;
2000-09-18 16:07:07 +00:00
m_xExtViewTriggerController = NULL ;
2001-11-22 12:17:07 +00:00
m_xExternalDisplayedForm = NULL ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Reference < XResultSet > FmXFormShell : : getInternalForm ( const Reference < XResultSet > & _xForm ) const
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return NULL ;
2000-11-24 06:01:26 +00:00
Reference < XFormController > xExternalCtrlr ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xExternalCtrlr . is ( ) & & ( _xForm = = xExternalCtrlr - > getModel ( ) ) )
{
DBG_ASSERT ( m_xExternalDisplayedForm . is ( ) , " FmXFormShell::getInternalForm : invalid external form ! " ) ;
return m_xExternalDisplayedForm ;
}
return _xForm ;
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Reference < XForm > FmXFormShell : : getInternalForm ( const Reference < XForm > & _xForm ) const
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return NULL ;
2000-11-24 06:01:26 +00:00
Reference < XFormController > xExternalCtrlr ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xExternalCtrlr . is ( ) & & ( _xForm = = xExternalCtrlr - > getModel ( ) ) )
{
DBG_ASSERT ( m_xExternalDisplayedForm . is ( ) , " FmXFormShell::getInternalForm : invalid external form ! " ) ;
2000-11-24 06:01:26 +00:00
return Reference < XForm > ( m_xExternalDisplayedForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
}
return _xForm ;
}
2008-08-19 08:48:23 +00:00
//------------------------------------------------------------------------
namespace
{
static bool lcl_isNavigationRelevant ( sal_Int32 _nWhich )
{
return ( _nWhich = = SID_FM_RECORD_FIRST )
| | ( _nWhich = = SID_FM_RECORD_PREV )
| | ( _nWhich = = SID_FM_RECORD_NEXT )
| | ( _nWhich = = SID_FM_RECORD_LAST )
| | ( _nWhich = = SID_FM_RECORD_NEW ) ;
}
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
2008-08-19 08:48:23 +00:00
bool FmXFormShell : : IsFormSlotEnabled ( sal_Int32 _nSlot , FeatureState * _pCompleteState )
2000-09-18 16:07:07 +00:00
{
2008-08-19 08:48:23 +00:00
const : : svx : : ControllerFeatures & rController =
lcl_isNavigationRelevant ( _nSlot )
? getNavControllerFeatures ( )
: getActiveControllerFeatures ( ) ;
2000-09-18 16:07:07 +00:00
2008-08-19 08:48:23 +00:00
if ( ! _pCompleteState )
return rController - > isEnabled ( _nSlot ) ;
2000-09-18 16:07:07 +00:00
2008-08-19 08:48:23 +00:00
rController - > getState ( _nSlot , * _pCompleteState ) ;
return _pCompleteState - > Enabled ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : ExecuteFormSlot ( sal_Int32 _nSlot )
{
const : : svx : : ControllerFeatures & rController =
lcl_isNavigationRelevant ( _nSlot )
? getNavControllerFeatures ( )
: getActiveControllerFeatures ( ) ;
rController - > execute ( _nSlot ) ;
2001-10-16 10:42:22 +00:00
2004-04-13 09:59:06 +00:00
if ( _nSlot = = SID_FM_RECORD_UNDO )
2006-11-14 12:25:13 +00:00
{
2004-04-13 09:59:06 +00:00
// if we're doing an UNDO, *and* if the affected form is the form which we also display
// as external view, then we need to reset the controls of the external form, too
2008-08-19 08:48:23 +00:00
if ( getInternalForm ( getActiveForm ( ) ) = = m_xExternalDisplayedForm )
2005-03-10 15:23:52 +00:00
{
2006-12-01 16:25:53 +00:00
Reference < XIndexAccess > xContainer ( m_xExternalDisplayedForm , UNO_QUERY ) ;
if ( xContainer . is ( ) )
{
Reference < XReset > xReset ;
for ( sal_Int32 i = 0 ; i < xContainer - > getCount ( ) ; + + i )
{
if ( ( xContainer - > getByIndex ( i ) > > = xReset ) & & xReset . is ( ) )
{
// no resets on sub forms
Reference < XForm > xAsForm ( xReset , UNO_QUERY ) ;
if ( ! xAsForm . is ( ) )
xReset - > reset ( ) ;
}
}
}
2002-01-21 08:18:58 +00:00
}
2000-09-18 16:07:07 +00:00
}
}
2008-12-01 12:31:27 +00:00
//------------------------------------------------------------------------------
void FmXFormShell : : impl_switchActiveControllerListening ( const bool _bListen )
{
Reference < XComponent > xComp ( m_xActiveController , UNO_QUERY ) ;
if ( ! xComp . is ( ) )
return ;
if ( _bListen )
xComp - > addEventListener ( ( XFormControllerListener * ) this ) ;
else
xComp - > removeEventListener ( ( XFormControllerListener * ) this ) ;
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
2002-11-12 10:28:01 +00:00
void FmXFormShell : : setActiveController ( const Reference < XFormController > & xController , sal_Bool _bNoSaveOldContent )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
if ( m_bChangingDesignMode )
return ;
DBG_ASSERT ( ! m_pShell - > IsDesignMode ( ) , " nur im alive mode verwenden " ) ;
// Ist die Routine ein zweites Mal gerufen worden,
// dann sollte der Focus nicht mehr umgesetzt werden
if ( m_bInActivate )
{
m_bSetFocus = xController ! = m_xActiveController ;
return ;
}
if ( xController ! = m_xActiveController )
{
// if there is a async cursor action running we have to restore the locking state of the controls of the old controller
2000-11-24 06:01:26 +00:00
if ( HasPendingCursorAction ( Reference < XResultSet > ( m_xActiveForm , UNO_QUERY ) ) )
2000-09-18 16:07:07 +00:00
restoreControlLocks ( ) ;
: : osl : : ClearableMutexGuard aGuard ( m_aAsyncSafety ) ;
// switch all nav dispatchers belonging to the form of the current nav controller to 'non active'
2000-11-24 06:01:26 +00:00
Reference < XResultSet > xNavigationForm ;
2000-09-18 16:07:07 +00:00
if ( m_xNavigationController . is ( ) )
2000-11-24 06:01:26 +00:00
xNavigationForm = Reference < XResultSet > ( m_xNavigationController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
aGuard . clear ( ) ;
m_bInActivate = sal_True ;
// check if the 2 controllers serve different forms
2000-11-24 06:01:26 +00:00
Reference < XResultSet > xOldForm ;
2000-09-18 16:07:07 +00:00
if ( m_xActiveController . is ( ) )
2000-11-24 06:01:26 +00:00
xOldForm = Reference < XResultSet > ( m_xActiveController - > getModel ( ) , UNO_QUERY ) ;
Reference < XResultSet > xNewForm ;
2000-09-18 16:07:07 +00:00
if ( xController . is ( ) )
2000-11-24 06:01:26 +00:00
xNewForm = Reference < XResultSet > ( xController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
xOldForm = getInternalForm ( xOldForm ) ;
xNewForm = getInternalForm ( xNewForm ) ;
2002-11-12 10:28:01 +00:00
sal_Bool bDifferentForm = ( xOldForm . get ( ) ! = xNewForm . get ( ) ) ;
sal_Bool bNeedSave = bDifferentForm & & ! _bNoSaveOldContent ;
// we save the content of the old form if we move to a new form, and saving old content is allowed
if ( m_xActiveController . is ( ) & & bNeedSave )
2000-09-18 16:07:07 +00:00
{
// beim Wechsel des Controllers den Inhalt speichern, ein Commit
// wurde bereits ausgefuehrt
2004-04-13 09:59:06 +00:00
if ( m_aActiveControllerFeatures - > commitCurrentControl ( ) )
2000-09-18 16:07:07 +00:00
{
m_bSetFocus = sal_True ;
2006-12-01 16:25:53 +00:00
if ( m_aActiveControllerFeatures - > isModifiedRow ( ) )
2008-12-01 12:31:27 +00:00
{
2006-12-01 16:25:53 +00:00
sal_Bool bIsNew = m_aActiveControllerFeatures - > isInsertionRow ( ) ;
2004-04-13 09:59:06 +00:00
sal_Bool bResult = m_aActiveControllerFeatures - > commitCurrentRecord ( ) ;
if ( ! bResult & & m_bSetFocus )
2000-09-18 16:07:07 +00:00
{
2004-04-13 09:59:06 +00:00
// if we couldn't save the current record, set the focus back to the
// current control
Reference < XWindow > xWindow ( m_xActiveController - > getCurrentControl ( ) , UNO_QUERY ) ;
if ( xWindow . is ( ) )
2008-12-01 12:31:27 +00:00
xWindow - > setFocus ( ) ;
2000-09-18 16:07:07 +00:00
m_bInActivate = sal_False ;
return ;
}
2004-04-13 09:59:06 +00:00
else if ( bResult & & bIsNew )
2000-09-18 16:07:07 +00:00
{
2004-04-13 09:59:06 +00:00
Reference < XResultSet > xCursor ( m_aActiveControllerFeatures - > getCursor ( ) . get ( ) ) ;
if ( xCursor . is ( ) )
{
DO_SAFE ( xCursor - > last ( ) ; ) ;
}
2000-09-18 16:07:07 +00:00
}
}
}
}
stopListening ( ) ;
2008-12-01 12:31:27 +00:00
impl_switchActiveControllerListening ( false ) ;
2004-04-13 09:59:06 +00:00
m_aActiveControllerFeatures . dispose ( ) ;
2000-09-18 16:07:07 +00:00
m_xActiveController = xController ;
2004-04-13 09:59:06 +00:00
if ( m_xActiveController . is ( ) )
m_aActiveControllerFeatures . assign ( m_xActiveController ) ;
2008-12-01 12:31:27 +00:00
impl_switchActiveControllerListening ( true ) ;
2000-11-06 13:09:32 +00:00
2008-12-01 12:31:27 +00:00
if ( m_xActiveController . is ( ) )
m_xActiveForm = getInternalForm ( Reference < XForm > ( m_xActiveController - > getModel ( ) , UNO_QUERY ) ) ;
2000-09-18 16:07:07 +00:00
else
m_xActiveForm = NULL ;
startListening ( ) ;
// activate all dispatchers belonging to form of the new navigation controller
xNavigationForm = NULL ;
if ( m_xNavigationController . is ( ) )
2000-11-24 06:01:26 +00:00
xNavigationForm = Reference < XResultSet > ( m_xNavigationController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// if there is a async cursor action running we have to lock the controls of the new controller
2000-11-24 06:01:26 +00:00
if ( HasPendingCursorAction ( Reference < XResultSet > ( m_xActiveForm , UNO_QUERY ) ) )
2000-09-18 16:07:07 +00:00
setControlLocks ( ) ;
m_bInActivate = sal_False ;
m_pShell - > UIFeatureChanged ( ) ;
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_FILTER_NAVIGATOR_CONTROL , sal_True ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
void FmXFormShell : : getCurrentSelection ( InterfaceBag & /* [out] */ _rSelection ) const
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
_rSelection = m_aCurrentSelection ;
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
//------------------------------------------------------------------------------
bool FmXFormShell : : setCurrentSelectionFromMark ( const SdrMarkList & _rMarkList )
{
m_aLastKnownMarkedControls . clear ( ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( ( _rMarkList . GetMarkCount ( ) > 0 ) & & isControlList ( _rMarkList ) )
collectInterfacesFromMarkList ( _rMarkList , m_aLastKnownMarkedControls ) ;
return setCurrentSelection ( m_aLastKnownMarkedControls ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
bool FmXFormShell : : selectLastMarkedControls ( )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
return setCurrentSelection ( m_aLastKnownMarkedControls ) ;
}
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
//------------------------------------------------------------------------------
bool FmXFormShell : : setCurrentSelection ( const InterfaceBag & _rSelection )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return false ;
2004-11-16 10:24:36 +00:00
DBG_ASSERT ( m_pShell - > IsDesignMode ( ) , " FmXFormShell::setCurrentSelection: only to be used in design mode! " ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( _rSelection . empty ( ) & & m_aCurrentSelection . empty ( ) )
// nothing to do
return false ;
if ( _rSelection . size ( ) = = m_aCurrentSelection . size ( ) )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
InterfaceBag : : const_iterator aNew = _rSelection . begin ( ) ;
InterfaceBag : : const_iterator aOld = m_aCurrentSelection . begin ( ) ;
for ( ; aNew ! = _rSelection . end ( ) ; + + aNew , + + aOld )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
OSL_ENSURE ( Reference < XInterface > ( * aNew , UNO_QUERY ) . get ( ) = = aNew - > get ( ) , " FmXFormShell::setCurrentSelection: new interface not normalized! " ) ;
OSL_ENSURE ( Reference < XInterface > ( * aOld , UNO_QUERY ) . get ( ) = = aOld - > get ( ) , " FmXFormShell::setCurrentSelection: old interface not normalized! " ) ;
if ( aNew - > get ( ) ! = aOld - > get ( ) )
break ;
}
if ( aNew = = _rSelection . end ( ) )
// both bags equal
return false ;
}
// the following is some strange code to ensure that when you have two grid controls in a document,
// only one of them can have a selected column.
// TODO: this should happen elsewhere, but not here - shouldn't it?
if ( ! m_aCurrentSelection . empty ( ) )
{
Reference < XChild > xCur ; if ( m_aCurrentSelection . size ( ) = = 1 ) xCur = xCur . query ( * m_aCurrentSelection . begin ( ) ) ;
Reference < XChild > xNew ; if ( _rSelection . size ( ) = = 1 ) xNew = xNew . query ( * _rSelection . begin ( ) ) ;
// is there nothing to be selected, or the parents differ, and the parent of the current object
// is a selection supplier, then deselect
if ( xCur . is ( ) & & ( ! xNew . is ( ) | | ( xCur - > getParent ( ) ! = xNew - > getParent ( ) ) ) )
{
Reference < XSelectionSupplier > xSel ( xCur - > getParent ( ) , UNO_QUERY ) ;
if ( xSel . is ( ) )
xSel - > select ( Any ( ) ) ;
2000-09-18 16:07:07 +00:00
}
}
2004-11-16 10:24:36 +00:00
m_aCurrentSelection = _rSelection ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// determine the form which all the selected obj<62> cts belong to, if any
2008-06-06 12:51:05 +00:00
Reference < XForm > xNewCurrentForm ;
2004-11-16 10:24:36 +00:00
for ( InterfaceBag : : const_iterator loop = m_aCurrentSelection . begin ( ) ;
loop ! = m_aCurrentSelection . end ( ) ;
+ + loop
)
{
Reference < XForm > xThisRoundsForm ( GetForm ( * loop ) ) ;
OSL_ENSURE ( xThisRoundsForm . is ( ) , " FmXFormShell::setCurrentSelection: *everything* should belong to a form! " ) ;
2008-06-06 12:51:05 +00:00
if ( ! xNewCurrentForm . is ( ) )
2004-11-16 10:24:36 +00:00
{ // the first form we encounterd
2008-06-06 12:51:05 +00:00
xNewCurrentForm = xThisRoundsForm ;
2004-11-16 10:24:36 +00:00
}
2008-06-06 12:51:05 +00:00
else if ( xNewCurrentForm ! = xThisRoundsForm )
2004-11-16 10:24:36 +00:00
{ // different forms -> no "current form" at all
2008-06-06 12:51:05 +00:00
xNewCurrentForm . clear ( ) ;
2004-11-16 10:24:36 +00:00
break ;
}
}
2008-06-06 12:51:05 +00:00
impl_updateCurrentForm ( xNewCurrentForm ) ;
2005-02-17 09:56:23 +00:00
2008-06-06 12:51:05 +00:00
// ensure some slots are updated
2006-06-19 14:57:11 +00:00
for ( size_t i = 0 ; i < sizeof ( SelObjectSlotMap ) / sizeof ( SelObjectSlotMap [ 0 ] ) ; + + i )
2005-02-17 09:56:23 +00:00
InvalidateSlot ( SelObjectSlotMap [ i ] , sal_False ) ;
2004-11-16 10:24:36 +00:00
return true ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
bool FmXFormShell : : isSolelySelected ( const Reference < XInterface > & _rxObject )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
return ( m_aCurrentSelection . size ( ) = = 1 ) & & ( * m_aCurrentSelection . begin ( ) = = _rxObject ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
void FmXFormShell : : forgetCurrentForm ( )
2000-09-18 16:07:07 +00:00
{
2004-11-16 10:24:36 +00:00
if ( ! m_xCurrentForm . is ( ) )
return ;
2008-06-06 12:51:05 +00:00
// reset ...
impl_updateCurrentForm ( NULL ) ;
// ... and try finding a new current form
// #i88186# / 2008-04-12 / frank.schoenheit@sun.com
impl_defaultCurrentForm_nothrow ( ) ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : impl_updateCurrentForm ( const Reference < XForm > & _rxNewCurForm )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2008-06-06 12:51:05 +00:00
m_xCurrentForm = _rxNewCurForm ;
// propagate to the FormPage(Impl)
2004-11-16 10:24:36 +00:00
FmFormPage * pPage = m_pShell - > GetCurPage ( ) ;
if ( pPage )
pPage - > GetImpl ( ) - > setCurForm ( m_xCurrentForm ) ;
2008-06-06 12:51:05 +00:00
// ensure the UI which depends on the current form is up-to-date
2006-06-19 14:57:11 +00:00
for ( size_t i = 0 ; i < sizeof ( DlgSlotMap ) / sizeof ( DlgSlotMap [ 0 ] ) ; + + i )
2005-01-05 11:21:07 +00:00
InvalidateSlot ( DlgSlotMap [ i ] , sal_False ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : startListening ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XRowSet > xDatabaseForm ( m_xActiveForm , UNO_QUERY ) ;
2002-10-07 12:09:48 +00:00
if ( xDatabaseForm . is ( ) & & getRowSetConnection ( xDatabaseForm ) . is ( ) )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xActiveFormSet ( m_xActiveForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xActiveFormSet . is ( ) )
{
// wenn es eine Datenquelle gibt, dann den Listener aufbauen
2003-12-01 08:29:19 +00:00
// TODO: this is strange - shouldn't this depend on a isLoaded instead of
// a "has command value"? Finally, the command value only means that it was
// intended to be loaded, not that it actually *is* loaded
2000-10-20 13:18:57 +00:00
: : rtl : : OUString aSource = : : comphelper : : getString ( xActiveFormSet - > getPropertyValue ( FM_PROP_COMMAND ) ) ;
2001-05-11 15:07:05 +00:00
if ( aSource . getLength ( ) )
2000-09-18 16:07:07 +00:00
{
m_bDatabaseBar = sal_True ;
2000-11-07 12:16:50 +00:00
xActiveFormSet - > getPropertyValue ( FM_PROP_NAVIGATION ) > > = m_eNavigate ;
2000-09-18 16:07:07 +00:00
switch ( m_eNavigate )
{
2000-11-24 06:01:26 +00:00
case NavigationBarMode_PARENT :
2000-09-18 16:07:07 +00:00
{
// suchen des Controllers, ueber den eine Navigation moeglich ist
2000-11-24 06:01:26 +00:00
Reference < XChild > xChild ( m_xActiveController , UNO_QUERY ) ;
Reference < XFormController > xParent ;
2000-09-18 16:07:07 +00:00
while ( xChild . is ( ) )
{
2000-11-24 06:01:26 +00:00
xChild = Reference < XChild > ( xChild - > getParent ( ) , UNO_QUERY ) ;
xParent = Reference < XFormController > ( xChild , UNO_QUERY ) ;
Reference < XPropertySet > xParentSet ;
2000-09-18 16:07:07 +00:00
if ( xParent . is ( ) )
2000-11-24 06:01:26 +00:00
xParentSet = Reference < XPropertySet > ( xParent - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xParentSet . is ( ) )
{
2000-11-07 12:16:50 +00:00
xParentSet - > getPropertyValue ( FM_PROP_NAVIGATION ) > > = m_eNavigate ;
2000-11-24 06:01:26 +00:00
if ( m_eNavigate = = NavigationBarMode_CURRENT )
2000-09-18 16:07:07 +00:00
break ;
}
}
m_xNavigationController = xParent ;
2004-04-13 09:59:06 +00:00
}
break ;
2000-11-24 06:01:26 +00:00
case NavigationBarMode_CURRENT :
2000-09-18 16:07:07 +00:00
m_xNavigationController = m_xActiveController ;
break ;
2004-04-13 09:59:06 +00:00
2000-09-18 16:07:07 +00:00
default :
m_xNavigationController = NULL ;
m_bDatabaseBar = sal_False ;
}
2004-04-13 09:59:06 +00:00
m_aNavControllerFeatures . dispose ( ) ;
if ( m_xNavigationController . is ( ) & & ( m_xNavigationController ! = m_xActiveController ) )
m_aNavControllerFeatures . assign ( m_xNavigationController ) ;
2000-09-18 16:07:07 +00:00
// an dem Controller, der die Navigation regelt, wg. RecordCount lauschen
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xNavigationSet ;
2000-09-18 16:07:07 +00:00
if ( m_xNavigationController . is ( ) )
{
2000-11-24 06:01:26 +00:00
xNavigationSet = Reference < XPropertySet > ( m_xNavigationController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xNavigationSet . is ( ) )
xNavigationSet - > addPropertyChangeListener ( FM_PROP_ROWCOUNT , this ) ;
}
return ;
}
}
}
2000-11-24 06:01:26 +00:00
m_eNavigate = NavigationBarMode_NONE ;
2000-09-18 16:07:07 +00:00
m_bDatabaseBar = sal_False ;
m_xNavigationController = NULL ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : stopListening ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XRowSet > xDatabaseForm ( m_xActiveForm , UNO_QUERY ) ;
2003-12-01 08:29:19 +00:00
if ( xDatabaseForm . is ( ) )
2000-09-18 16:07:07 +00:00
{
if ( m_xNavigationController . is ( ) )
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xSet ( m_xNavigationController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xSet . is ( ) )
xSet - > removePropertyChangeListener ( FM_PROP_ROWCOUNT , this ) ;
}
}
m_bDatabaseBar = sal_False ;
2000-11-24 06:01:26 +00:00
m_eNavigate = NavigationBarMode_NONE ;
2000-09-18 16:07:07 +00:00
m_xNavigationController = NULL ;
}
//------------------------------------------------------------------------------
2004-11-16 10:24:36 +00:00
void FmXFormShell : : ShowSelectionProperties ( sal_Bool bShow )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// if the window is already visible, only update the state
sal_Bool bHasChild = m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > HasChildWindow ( SID_FM_SHOW_PROPERTIES ) ;
if ( bHasChild & & bShow )
2005-01-05 11:21:07 +00:00
UpdateSlot ( SID_FM_PROPERTY_CONTROL ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
// else toggle state
2000-09-18 16:07:07 +00:00
else
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > ToggleChildWindow ( SID_FM_SHOW_PROPERTIES ) ;
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_PROPERTIES , sal_False ) ;
InvalidateSlot ( SID_FM_CTL_PROPERTIES , sal_False ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnFoundData , FmFoundRecordInformation * , pfriWhere )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0 ;
2007-07-31 12:57:49 +00:00
DBG_ASSERT ( ( pfriWhere - > nContext > = 0 ) & & ( pfriWhere - > nContext < ( sal_Int16 ) m_aSearchForms . size ( ) ) ,
2000-09-18 16:07:07 +00:00
" FmXFormShell::OnFoundData : ungueltiger Kontext ! " ) ;
2007-07-31 12:57:49 +00:00
Reference < XForm > xForm ( m_aSearchForms . at ( pfriWhere - > nContext ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xForm . is ( ) , " FmXFormShell::OnFoundData : ungueltige Form ! " ) ;
2000-11-24 06:01:26 +00:00
Reference < XRowLocate > xCursor ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCursor . is ( ) )
return 0 ; // was soll ich da machen ?
// zum Datensatz
2006-01-16 14:22:01 +00:00
try
{
xCursor - > moveToBookmark ( pfriWhere - > aPosition ) ;
}
catch ( const SQLException & )
{
OSL_ENSURE ( 0 , " Can position on bookmark! " ) ;
}
2000-09-18 16:07:07 +00:00
LoopGrids ( GA_FORCE_SYNC ) ;
// und zum Feld (dazu habe ich vor dem Start des Suchens die XVclComponent-Interfaces eingesammelt)
DBG_ASSERT ( pfriWhere - > nFieldPos < m_arrSearchedControls . Count ( ) , " FmXFormShell::OnFoundData : ungueltige Daten uebergeben ! " ) ;
SdrObject * pObject = m_arrSearchedControls . GetObject ( pfriWhere - > nFieldPos ) ;
DBG_ASSERT ( pObject ! = NULL , " FmXFormShell::OnFoundData : unerwartet : ungueltiges VclControl-Interface " ) ;
2006-11-14 12:25:13 +00:00
m_pShell - > GetFormView ( ) - > UnMarkAll ( m_pShell - > GetFormView ( ) - > GetSdrPageView ( ) ) ;
m_pShell - > GetFormView ( ) - > MarkObj ( pObject , m_pShell - > GetFormView ( ) - > GetSdrPageView ( ) ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
FmFormObj * pFormObject = FmFormObj : : GetFormObject ( pObject ) ;
Reference < XControlModel > xControlModel ( pFormObject ? pFormObject - > GetUnoControlModel ( ) : Reference < XControlModel > ( ) ) ;
DBG_ASSERT ( xControlModel . is ( ) , " FmXFormShell::OnFoundData: invalid control! " ) ;
2000-09-18 16:07:07 +00:00
// disable the permanent cursor for the last grid we found a record
2001-10-16 10:42:22 +00:00
if ( m_xLastGridFound . is ( ) & & ( m_xLastGridFound ! = xControlModel ) )
2000-09-18 16:07:07 +00:00
{
2001-10-16 10:42:22 +00:00
Reference < XPropertySet > xOldSet ( m_xLastGridFound , UNO_QUERY ) ;
xOldSet - > setPropertyValue ( FM_PROP_ALWAYSSHOWCURSOR , makeAny ( ( sal_Bool ) sal_False ) ) ;
2000-11-24 06:01:26 +00:00
Reference < XPropertyState > xOldSetState ( xOldSet , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xOldSetState . is ( ) )
xOldSetState - > setPropertyToDefault ( FM_PROP_CURSORCOLOR ) ;
else
2000-11-24 06:01:26 +00:00
xOldSet - > setPropertyValue ( FM_PROP_CURSORCOLOR , Any ( ) ) ;
2000-09-18 16:07:07 +00:00
}
// wenn das Feld sich in einem GridControl befindet, muss ich dort noch in die entsprechende Spalte gehen
sal_Int32 nGridColumn = m_arrRelativeGridColumn . GetObject ( pfriWhere - > nFieldPos ) ;
if ( nGridColumn ! = - 1 )
{ // dummer weise muss ich mir das Control erst wieder besorgen
2000-11-24 06:01:26 +00:00
Reference < XControl > xControl ( GetControlFromModel ( xControlModel ) ) ;
Reference < XGrid > xGrid ( xControl , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xGrid . is ( ) , " FmXFormShell::OnFoundData : ungueltiges Control ! " ) ;
// wenn eine der Asserts anschlaegt, habe ich beim Aufbauen von m_arrSearchedControls wohl was falsch gemacht
// enable a permanent cursor for the grid so we can see the found text
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xModelSet ( xControlModel , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xModelSet . is ( ) , " FmXFormShell::OnFoundData : invalid control model (no property set) ! " ) ;
2006-06-19 14:57:11 +00:00
xModelSet - > setPropertyValue ( FM_PROP_ALWAYSSHOWCURSOR , makeAny ( ( sal_Bool ) sal_True ) ) ;
xModelSet - > setPropertyValue ( FM_PROP_CURSORCOLOR , makeAny ( sal_Int32 ( COL_LIGHTRED ) ) ) ;
2001-10-16 10:42:22 +00:00
m_xLastGridFound = xControlModel ;
2000-09-18 16:07:07 +00:00
2001-07-25 12:57:12 +00:00
xGrid - > setCurrentColumnPosition ( ( sal_Int16 ) nGridColumn ) ;
2000-09-18 16:07:07 +00:00
}
// als der Cursor neu positioniert wurde, habe ich (in positioned) meine Formularleisten-Slots invalidiert, aber das greift
// hier dummerweise nicht, da i.A. ja der (modale) Suchdialog oben ist ... also Gewalt ...
sal_uInt16 nPos = 0 ;
while ( DatabaseSlotMap [ nPos ] )
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Update ( DatabaseSlotMap [ nPos + + ] ) ;
2000-09-18 16:07:07 +00:00
// leider geht das Update im Gegensatz zum Invalidate nur mit einzelnen Slots)
return 0 ;
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnCanceledNotFound , FmFoundRecordInformation * , pfriWhere )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0 ;
2007-07-31 12:57:49 +00:00
DBG_ASSERT ( ( pfriWhere - > nContext > = 0 ) & & ( pfriWhere - > nContext < ( sal_Int16 ) m_aSearchForms . size ( ) ) ,
2000-09-18 16:07:07 +00:00
" FmXFormShell::OnCanceledNotFound : ungueltiger Kontext ! " ) ;
2007-07-31 12:57:49 +00:00
Reference < XForm > xForm ( m_aSearchForms . at ( pfriWhere - > nContext ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xForm . is ( ) , " FmXFormShell::OnCanceledNotFound : ungueltige Form ! " ) ;
2000-11-24 06:01:26 +00:00
Reference < XRowLocate > xCursor ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCursor . is ( ) )
return 0 ; // was soll ich da machen ?
// zum Datensatz
2006-01-16 14:22:01 +00:00
try
{
xCursor - > moveToBookmark ( pfriWhere - > aPosition ) ;
}
catch ( const SQLException & )
{
OSL_ENSURE ( 0 , " Can position on bookmark! " ) ;
}
2000-09-18 16:07:07 +00:00
2006-11-14 12:25:13 +00:00
m_pShell - > GetFormView ( ) - > UnMarkAll ( m_pShell - > GetFormView ( ) - > GetSdrPageView ( ) ) ;
2000-09-18 16:07:07 +00:00
return 0L ;
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnSearchContextRequest , FmSearchContext * , pfmscContextInfo )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0 ;
2007-07-31 12:57:49 +00:00
DBG_ASSERT ( pfmscContextInfo - > nContext < ( sal_Int16 ) m_aSearchForms . size ( ) , " FmXFormShell::OnSearchContextRequest : invalid parameter ! " ) ;
Reference < XForm > xForm ( m_aSearchForms . at ( pfmscContextInfo - > nContext ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xForm . is ( ) , " FmXFormShell::OnSearchContextRequest : unexpected : invalid context ! " ) ;
2000-11-24 06:01:26 +00:00
Reference < XResultSet > xIter ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xIter . is ( ) , " FmXFormShell::OnSearchContextRequest : unexpected : context has no iterator ! " ) ;
// --------------------------------------------------------------------------------------------
// die Liste der zu involvierenden Felder zusammenstellen (sind die ControlSources aller Felder, die eine solche Eigenschaft habe)
UniString strFieldList , sFieldDisplayNames ;
m_arrSearchedControls . Remove ( 0 , m_arrSearchedControls . Count ( ) ) ;
m_arrRelativeGridColumn . Remove ( 0 , m_arrRelativeGridColumn . Count ( ) ) ;
// folgendes kleines Problem : Ich brauche, um gefundene Felder zu markieren, SdrObjekte. Um hier festzustellen, welche Controls
2000-11-24 06:01:26 +00:00
// ich in die Suche einbeziehen soll, brauche ich Controls (also XControl-Interfaces). Ich muss also ueber eines von beiden
2000-09-18 16:07:07 +00:00
// iterieren und mir das jeweils andere besorgen. Dummerweise gibt es keine direkte Verbindung zwischen beiden Welten (abgesehen
// von einem GetUnoControl an SdrUnoObject, das aber ein OutputDevice verlangt, womit ich nichts anfangen kann).
// Allerdings komme ich sowohl von einem Control als auch von einem SdrObject zum Model, und damit ist mir mit einer doppelten
// Schleife die Zuordnung SdrObject<->Control moeglich.
// Die Alternative zu dieser (unschoenen und sicher auch nicht ganz fixen) Loesung waere, auf das Cachen der SdrObjects zu
// verzichten, was dann aber in OnFoundData zu wesentlicher Mehrarbeit fuehren wuerde (da ich mir dort jedesmal das SdrObject
// erst besorgen muesste). Da aber OnFoundData i.d.R. oefter aufgerufen wird als ExecuteSearch, erledige ich das hier.
2000-11-24 06:01:26 +00:00
Reference < XNameAccess > xValidFormFields ;
Reference < XColumnsSupplier > xSupplyCols ( xIter , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xSupplyCols . is ( ) , " FmXFormShell::OnSearchContextRequest : invalid cursor : no columns supplier ! " ) ;
if ( xSupplyCols . is ( ) )
xValidFormFields = xSupplyCols - > getColumns ( ) ;
DBG_ASSERT ( xValidFormFields . is ( ) , " FmXFormShell::OnSearchContextRequest : form has no fields ! " ) ;
// aktuelle(r) Page/Controller
FmFormPage * pCurrentPage = m_pShell - > GetCurPage ( ) ;
DBG_ASSERT ( pCurrentPage ! = NULL , " FmXFormShell::OnSearchContextRequest : no page ! " ) ;
// alle Sdr-Controls dieser Seite durchsuchen ...
2008-12-01 12:31:27 +00:00
: : rtl : : OUString sControlSource , aName ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
SdrObjListIter aPageIter ( * pCurrentPage ) ;
while ( aPageIter . IsMore ( ) )
{
SdrObject * pCurrent = aPageIter . Next ( ) ;
FmFormObj * pFormObject = FmFormObj : : GetFormObject ( pCurrent ) ;
// note that in case pCurrent is a virtual object, pFormObject points to the referenced object
if ( ! pFormObject )
continue ;
// the current object's model, in different tastes
Reference < XControlModel > xControlModel ( pFormObject - > GetUnoControlModel ( ) ) ;
Reference < XFormComponent > xCurrentFormComponent ( xControlModel , UNO_QUERY ) ;
DBG_ASSERT ( xCurrentFormComponent . is ( ) , " FmXFormShell::OnSearchContextRequest: invalid objects! " ) ;
if ( ! xCurrentFormComponent . is ( ) )
continue ;
// does the component belong to the form which we're interested in?
if ( xCurrentFormComponent - > getParent ( ) ! = xForm )
continue ;
// ... nach der ControlSource-Eigenschaft fragen
SearchableControlIterator iter ( xCurrentFormComponent ) ;
Reference < XControl > xControlBehindModel ;
// 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)
Reference < XInterface > xSearchable ( iter . Next ( ) ) ;
while ( xSearchable . is ( ) )
2000-09-18 16:07:07 +00:00
{
2008-12-01 12:31:27 +00:00
sControlSource = iter . getCurrentValue ( ) ;
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 ! " ) ;
Reference < XGridPeer > xGridPeer ( xControlBehindModel - > getPeer ( ) , UNO_QUERY ) ;
do
2000-09-18 16:07:07 +00:00
{
2008-12-01 12:31:27 +00:00
if ( ! xGridPeer . is ( ) )
break ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
Reference < XIndexAccess > xPeerContainer ( xGridPeer , UNO_QUERY ) ;
if ( ! xPeerContainer . is ( ) )
break ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
Reference < XIndexAccess > xModelColumns ( xGridPeer - > getColumns ( ) , UNO_QUERY ) ;
DBG_ASSERT ( xModelColumns . is ( ) , " FmXFormShell::OnSearchContextRequest : there is a grid control without columns ! " ) ;
// the case 'no columns' should be indicated with an empty container, I think ...
DBG_ASSERT ( xModelColumns - > getCount ( ) > = xPeerContainer - > getCount ( ) , " FmXFormShell::OnSearchContextRequest : impossible : have more view than model columns ! " ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
Reference < XInterface > xCurrentColumn ;
for ( sal_Int16 nViewPos = 0 ; nViewPos < xPeerContainer - > getCount ( ) ; + + nViewPos )
{
xPeerContainer - > getByIndex ( nViewPos ) > > = xCurrentColumn ;
if ( ! xCurrentColumn . is ( ) )
continue ;
// can we use this column control fo searching ?
if ( ! IsSearchableControl ( xCurrentColumn ) )
continue ;
sal_Int16 nModelPos = GridView2ModelPos ( xModelColumns , nViewPos ) ;
Reference < XPropertySet > xCurrentColModel ;
xModelColumns - > getByIndex ( nModelPos ) > > = xCurrentColModel ;
aName = : : comphelper : : getString ( xCurrentColModel - > getPropertyValue ( FM_PROP_CONTROLSOURCE ) ) ;
// the cursor has a field matching the control source ?
if ( xValidFormFields - > hasByName ( aName ) )
2000-09-18 16:07:07 +00:00
{
2008-12-01 12:31:27 +00:00
strFieldList + = aName . getStr ( ) ;
strFieldList + = ' ; ' ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
sFieldDisplayNames + = : : comphelper : : getString ( xCurrentColModel - > getPropertyValue ( FM_PROP_LABEL ) ) . getStr ( ) ;
sFieldDisplayNames + = ' ; ' ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
pfmscContextInfo - > arrFields . push_back ( xCurrentColumn ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
// und das SdrObjekt zum Feld
m_arrSearchedControls . C40_INSERT ( SdrObject , pCurrent , m_arrSearchedControls . Count ( ) ) ;
// die Nummer der Spalte
m_arrRelativeGridColumn . Insert ( nViewPos , m_arrRelativeGridColumn . Count ( ) ) ;
}
2000-09-18 16:07:07 +00:00
}
2008-12-01 12:31:27 +00:00
} while ( sal_False ) ;
}
else
{
if ( sControlSource . getLength ( ) & & xValidFormFields - > hasByName ( sControlSource ) )
{
// jetzt brauche ich das Control zum SdrObject
if ( ! xControlBehindModel . is ( ) )
2000-09-18 16:07:07 +00:00
{
2008-12-01 12:31:27 +00:00
xControlBehindModel = GetControlFromModel ( xControlModel ) ;
DBG_ASSERT ( xControlBehindModel . is ( ) , " FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model ! " ) ;
}
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
if ( IsSearchableControl ( xControlBehindModel ) )
{ // alle Tests ueberstanden -> in die Liste mit aufnehmen
strFieldList + = sControlSource . getStr ( ) ;
strFieldList + = ' ; ' ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
// the label which should appear for the control :
sFieldDisplayNames + = getLabelName ( Reference < XPropertySet > ( xControlModel , UNO_QUERY ) ) . getStr ( ) ;
sFieldDisplayNames + = ' ; ' ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
// das SdrObjekt merken (beschleunigt die Behandlung in OnFoundData)
m_arrSearchedControls . C40_INSERT ( SdrObject , pCurrent , m_arrSearchedControls . Count ( ) ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
// die Nummer der Spalte (hier ein Dummy, nur fuer GridControls interesant)
m_arrRelativeGridColumn . Insert ( - 1 , m_arrRelativeGridColumn . Count ( ) ) ;
2000-09-18 16:07:07 +00:00
2008-12-01 12:31:27 +00:00
// und fuer die formatierte Suche ...
pfmscContextInfo - > arrFields . push_back ( Reference < XInterface > ( xControlBehindModel , UNO_QUERY ) ) ;
2000-09-18 16:07:07 +00:00
}
}
}
2008-12-01 12:31:27 +00:00
xSearchable = iter . Next ( ) ;
2000-09-18 16:07:07 +00:00
}
}
2008-12-01 12:31:27 +00:00
2000-09-18 16:07:07 +00:00
strFieldList . EraseTrailingChars ( ' ; ' ) ;
sFieldDisplayNames . EraseTrailingChars ( ' ; ' ) ;
if ( ! pfmscContextInfo - > arrFields . size ( ) )
{
pfmscContextInfo - > arrFields . clear ( ) ;
pfmscContextInfo - > xCursor = NULL ;
pfmscContextInfo - > strUsedFields . Erase ( ) ;
return 0L ;
}
pfmscContextInfo - > xCursor = xIter ;
pfmscContextInfo - > strUsedFields = strFieldList ;
pfmscContextInfo - > sFieldDisplayNames = sFieldDisplayNames ;
// 66463 - 31.05.99 - FS
// wenn der Cursor sich in einem anderen RecordMode als STANDARD befindet, ruecksetzen
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xCursorSet ( pfmscContextInfo - > xCursor , UNO_QUERY ) ;
Reference < XResultSetUpdate > xUpdateCursor ( pfmscContextInfo - > xCursor , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xUpdateCursor . is ( ) & & xCursorSet . is ( ) & & xCursorSet . is ( ) )
2000-10-20 13:18:57 +00:00
if ( : : comphelper : : getBOOL ( xCursorSet - > getPropertyValue ( FM_PROP_ISNEW ) ) )
2000-09-18 16:07:07 +00:00
xUpdateCursor - > moveToCurrentRow ( ) ;
else
2000-10-20 13:18:57 +00:00
if ( : : comphelper : : getBOOL ( xCursorSet - > getPropertyValue ( FM_PROP_ISMODIFIED ) ) )
2000-09-18 16:07:07 +00:00
xUpdateCursor - > cancelRowUpdates ( ) ;
return pfmscContextInfo - > arrFields . size ( ) ;
}
2000-11-24 06:01:26 +00:00
// XContainerListener
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
2001-09-12 17:11:08 +00:00
void FmXFormShell : : elementInserted ( const ContainerEvent & evt ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
// neues Object zum lauschen
2000-11-24 06:01:26 +00:00
Reference < XInterface > xTemp ;
2000-11-07 12:16:50 +00:00
evt . Element > > = xTemp ;
AddElement ( xTemp ) ;
2000-09-18 16:07:07 +00:00
m_pShell - > DetermineForms ( sal_True ) ;
}
//------------------------------------------------------------------------------
2001-09-12 17:11:08 +00:00
void FmXFormShell : : elementReplaced ( const ContainerEvent & evt ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XInterface > xTemp ;
2000-11-07 12:16:50 +00:00
evt . ReplacedElement > > = xTemp ;
RemoveElement ( xTemp ) ;
evt . Element > > = xTemp ;
AddElement ( xTemp ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2001-09-12 17:11:08 +00:00
void FmXFormShell : : elementRemoved ( const ContainerEvent & evt ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XInterface > xTemp ;
2000-11-07 12:16:50 +00:00
evt . Element > > = xTemp ;
RemoveElement ( xTemp ) ;
2008-08-28 05:55:02 +00:00
m_pShell - > DetermineForms ( sal_True ) ;
2000-09-18 16:07:07 +00:00
}
2008-01-29 07:49:28 +00:00
//------------------------------------------------------------------------------
void FmXFormShell : : UpdateForms ( sal_Bool _bInvalidate )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2008-06-25 11:24:46 +00:00
Reference < XIndexAccess > xForms ;
2008-08-28 05:55:02 +00:00
FmFormPage * pPage = m_pShell - > GetCurPage ( ) ;
2008-01-29 07:49:28 +00:00
if ( pPage )
{
if ( m_pShell - > m_bDesignMode )
xForms = xForms . query ( pPage - > GetForms ( false ) ) ;
}
2008-06-25 11:24:46 +00:00
if ( m_xForms ! = xForms )
2000-09-18 16:07:07 +00:00
{
2008-06-25 11:24:46 +00:00
RemoveElement ( m_xForms ) ;
m_xForms = xForms ;
AddElement ( m_xForms ) ;
2000-09-18 16:07:07 +00:00
}
2008-08-28 05:55:02 +00:00
m_pShell - > DetermineForms ( _bInvalidate ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void FmXFormShell : : AddElement ( const Reference < XInterface > & Element )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
// am Container horchen
2000-11-24 06:01:26 +00:00
Reference < XIndexContainer > xContainer ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xContainer . is ( ) )
{
sal_uInt32 nCount = xContainer - > getCount ( ) ;
2000-11-24 06:01:26 +00:00
Reference < XInterface > xElement ;
2000-09-18 16:07:07 +00:00
for ( sal_uInt32 i = 0 ; i < nCount ; i + + )
{
2000-11-07 12:16:50 +00:00
xContainer - > getByIndex ( i ) > > = xElement ;
AddElement ( xElement ) ;
2000-09-18 16:07:07 +00:00
}
2000-11-24 06:01:26 +00:00
Reference < XContainer > xCont ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xCont . is ( ) )
xCont - > addContainerListener ( this ) ;
}
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : view : : XSelectionSupplier > xSelSupplier ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xSelSupplier . is ( ) )
xSelSupplier - > addSelectionChangeListener ( this ) ;
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void FmXFormShell : : RemoveElement ( const Reference < XInterface > & Element )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : view : : XSelectionSupplier > xSelSupplier ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xSelSupplier . is ( ) )
xSelSupplier - > removeSelectionChangeListener ( this ) ;
// Verbindung zu Kindern aufheben
2000-11-24 06:01:26 +00:00
Reference < XIndexContainer > xContainer ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xContainer . is ( ) )
{
2000-11-24 06:01:26 +00:00
Reference < XContainer > xCont ( Element , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xCont . is ( ) )
xCont - > removeContainerListener ( this ) ;
sal_uInt32 nCount = xContainer - > getCount ( ) ;
2000-11-24 06:01:26 +00:00
Reference < XInterface > xElement ;
2000-09-18 16:07:07 +00:00
for ( sal_uInt32 i = 0 ; i < nCount ; i + + )
{
2000-11-07 12:16:50 +00:00
xContainer - > getByIndex ( i ) > > = xElement ;
RemoveElement ( xElement ) ;
2000-09-18 16:07:07 +00:00
}
}
}
//------------------------------------------------------------------------------
2001-09-12 17:11:08 +00:00
void FmXFormShell : : selectionChanged ( const EventObject & rEvent ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
Reference < XSelectionSupplier > xSupplier ( rEvent . Source , UNO_QUERY ) ;
Reference < XInterface > xSelObj ( xSupplier - > getSelection ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// es wurde eine Selektion weggenommen, dieses kann nur durch die Shell vorgenommen werden
2004-11-16 10:24:36 +00:00
if ( ! xSelObj . is ( ) )
2000-09-18 16:07:07 +00:00
return ;
EnableTrackProperties ( sal_False ) ;
2002-10-31 12:28:47 +00:00
sal_Bool bMarkChanged = m_pShell - > GetFormView ( ) - > checkUnMarkAll ( rEvent . Source ) ;
2004-11-16 10:24:36 +00:00
Reference < XForm > xNewForm ( GetForm ( rEvent . Source ) ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
InterfaceBag aNewSelection ;
aNewSelection . insert ( Reference < XInterface > ( xSelObj , UNO_QUERY ) ) ;
2000-09-18 16:07:07 +00:00
2004-11-16 10:24:36 +00:00
if ( setCurrentSelection ( aNewSelection ) & & IsPropBrwOpen ( ) )
ShowSelectionProperties ( sal_True ) ;
2000-09-18 16:07:07 +00:00
EnableTrackProperties ( sal_True ) ;
2004-11-16 10:24:36 +00:00
2002-10-31 12:28:47 +00:00
if ( bMarkChanged )
2004-11-16 10:24:36 +00:00
m_pShell - > NotifyMarkListChanged ( m_pShell - > GetFormView ( ) ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
IMPL_LINK ( FmXFormShell , OnTimeOut , void * , /*EMPTYTAG*/ )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0 ;
2000-09-18 16:07:07 +00:00
if ( m_pShell - > IsDesignMode ( ) & & m_pShell - > GetFormView ( ) )
2004-07-12 13:36:51 +00:00
SetSelection ( m_pShell - > GetFormView ( ) - > GetMarkedObjectList ( ) ) ;
2000-09-18 16:07:07 +00:00
return 0 ;
}
//------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
void FmXFormShell : : SetSelectionDelayed ( )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
if ( m_pShell - > IsDesignMode ( ) & & IsTrackPropertiesEnabled ( ) & & ! m_aMarkTimer . IsActive ( ) )
m_aMarkTimer . Start ( ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : SetSelection ( const SdrMarkList & rMarkList )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
DetermineSelection ( rMarkList ) ;
m_pShell - > NotifyMarkListChanged ( m_pShell - > GetFormView ( ) ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : DetermineSelection ( const SdrMarkList & rMarkList )
{
2004-11-16 10:24:36 +00:00
if ( setCurrentSelectionFromMark ( rMarkList ) & & IsPropBrwOpen ( ) )
ShowSelectionProperties ( sal_True ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2002-05-02 15:37:00 +00:00
sal_Bool FmXFormShell : : IsPropBrwOpen ( ) const
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return sal_False ;
2002-05-02 15:37:00 +00:00
return ( ( m_pShell - > GetViewShell ( ) & & m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) ) ?
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > HasChildWindow ( SID_FM_SHOW_PROPERTIES ) : sal_False ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2002-05-02 15:37:00 +00:00
class FmXFormShell : : SuspendPropertyTracking
2000-09-18 16:07:07 +00:00
{
2002-05-02 15:37:00 +00:00
private :
2008-08-28 05:55:02 +00:00
FmXFormShell & m_rShell ;
2002-05-02 15:37:00 +00:00
sal_Bool m_bEnabled ;
public :
2008-08-28 05:55:02 +00:00
SuspendPropertyTracking ( FmXFormShell & _rShell )
: m_rShell ( _rShell )
2002-05-02 15:37:00 +00:00
, m_bEnabled ( sal_False )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( m_rShell . IsTrackPropertiesEnabled ( ) )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
m_rShell . EnableTrackProperties ( sal_False ) ;
2002-05-02 15:37:00 +00:00
m_bEnabled = sal_True ;
2000-09-18 16:07:07 +00:00
}
}
2002-05-02 15:37:00 +00:00
~ SuspendPropertyTracking ( )
{
if ( m_bEnabled ) // note that ( sal_False != m_bEnabled ) implies ( NULL != m_pShell )
2008-08-28 05:55:02 +00:00
m_rShell . EnableTrackProperties ( sal_True ) ;
2002-05-02 15:37:00 +00:00
}
} ;
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------------------
void FmXFormShell : : SetDesignMode ( sal_Bool bDesign )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
2006-01-03 15:11:58 +00:00
return ;
2008-08-28 05:55:02 +00:00
DBG_ASSERT ( m_pShell - > GetFormView ( ) , " FmXFormShell::SetDesignMode : invalid call (have no shell or no view) ! " ) ;
2000-09-18 16:07:07 +00:00
m_bChangingDesignMode = sal_True ;
// 67506 - 15.07.99 - FS
// if we're switching off the design mode we have to force the property browser to be closed
// so it can commit it's changes _before_ we load the forms
if ( ! bDesign )
{
2006-06-19 14:57:11 +00:00
m_bHadPropertyBrowserInDesignMode = m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > HasChildWindow ( SID_FM_SHOW_PROPERTIES ) ;
if ( m_bHadPropertyBrowserInDesignMode )
2000-09-18 16:07:07 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > ToggleChildWindow ( SID_FM_SHOW_PROPERTIES ) ;
}
FmFormView * pFormView = m_pShell - > GetFormView ( ) ;
if ( bDesign )
{
// we are currently filtering, so stop filtering
if ( m_bFilterMode )
stopFiltering ( sal_False ) ;
// an den Objekten meiner MarkList als Listener abmelden
2002-05-02 15:37:00 +00:00
pFormView - > GetImpl ( ) - > stopMarkListWatching ( ) ;
2000-09-18 16:07:07 +00:00
}
else
2002-05-02 15:37:00 +00:00
{
m_aMarkTimer . Stop ( ) ;
2008-08-28 05:55:02 +00:00
SuspendPropertyTracking aSuspend ( * this ) ;
2002-05-02 15:37:00 +00:00
pFormView - > GetImpl ( ) - > saveMarkList ( sal_True ) ;
}
2000-09-18 16:07:07 +00:00
if ( bDesign & & m_xExternalViewController . is ( ) )
CloseExternalFormViewer ( ) ;
pFormView - > ChangeDesignMode ( bDesign ) ;
// Listener benachrichtigen
FmDesignModeChangedHint aChangedHint ( bDesign ) ;
m_pShell - > Broadcast ( aChangedHint ) ;
m_pShell - > m_bDesignMode = bDesign ;
2008-01-29 07:49:28 +00:00
UpdateForms ( sal_False ) ;
2004-05-07 14:47:38 +00:00
m_pTextShell - > designModeChanged ( m_pShell - > m_bDesignMode ) ;
2000-09-18 16:07:07 +00:00
if ( bDesign )
{
2002-05-02 15:37:00 +00:00
SdrMarkList aList ;
2000-09-18 16:07:07 +00:00
{
2002-05-02 15:37:00 +00:00
// during changing the mark list, don't track the selected objects in the property browser
2008-08-28 05:55:02 +00:00
SuspendPropertyTracking aSuspend ( * this ) ;
2002-05-02 15:37:00 +00:00
// restore the marks
pFormView - > GetImpl ( ) - > restoreMarkList ( aList ) ;
2000-09-18 16:07:07 +00:00
}
2002-05-02 15:37:00 +00:00
// synchronize with the restored mark list
if ( aList . GetMarkCount ( ) )
SetSelection ( aList ) ;
}
else
{
// am Model der View als Listener anmelden (damit ich mitbekomme, wenn jemand waehrend des Alive-Modus
// Controls loescht, die ich eigentlich mit saveMarkList gespeichert habe) (60343)
pFormView - > GetImpl ( ) - > startMarkListWatching ( ) ;
2000-09-18 16:07:07 +00:00
}
m_pShell - > UIFeatureChanged ( ) ;
// 67506 - 15.07.99 - FS
2006-06-19 14:57:11 +00:00
if ( bDesign & & m_bHadPropertyBrowserInDesignMode )
2000-09-18 16:07:07 +00:00
{
// The UIFeatureChanged performes an update (a check of the available features) asynchronously.
2004-11-16 10:24:36 +00:00
// So we can't call ShowSelectionProperties directly as the according feature isn't enabled yet.
2000-09-18 16:07:07 +00:00
// That's why we use an asynchron execution on the dispatcher.
// (And that's why this has to be done AFTER the UIFeatureChanged.)
2004-11-16 10:24:36 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetDispatcher ( ) - > Execute ( SID_FM_SHOW_PROPERTY_BROWSER , SFX_CALLMODE_ASYNCHRON ) ;
2000-09-18 16:07:07 +00:00
}
m_bChangingDesignMode = sal_False ;
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
Reference < XControl > FmXFormShell : : GetControlFromModel ( const Reference < XControlModel > & xModel )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return NULL ;
2004-03-19 11:20:43 +00:00
Reference < XControlContainer > xControlContainer ( getControlContainerForView ( ) ) ;
2003-11-24 15:39:52 +00:00
2000-11-24 06:01:26 +00:00
Sequence < Reference < XControl > > seqControls ( xControlContainer - > getControls ( ) ) ;
Reference < XControl > * pControls = seqControls . getArray ( ) ;
2000-09-18 16:07:07 +00:00
// ... die ich dann durchsuchen kann
for ( int i = 0 ; i < seqControls . getLength ( ) ; + + i )
{
2000-11-24 06:01:26 +00:00
Reference < XControlModel > xSearchLoopModel ( pControls [ i ] - > getModel ( ) ) ;
if ( ( XControlModel * ) xSearchLoopModel . get ( ) = = ( XControlModel * ) xModel . get ( ) )
2000-09-18 16:07:07 +00:00
return pControls [ i ] ;
}
2000-11-24 06:01:26 +00:00
return Reference < XControl > ( NULL ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2007-07-31 12:57:49 +00:00
void FmXFormShell : : impl_collectFormSearchContexts_nothrow ( const Reference < XInterface > & _rxStartingPoint ,
const : : rtl : : OUString & _rCurrentLevelPrefix , FmFormArray & _out_rForms , : : std : : vector < String > & _out_rNames )
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
try
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
Reference < XIndexAccess > xContainer ( _rxStartingPoint , UNO_QUERY ) ;
if ( ! xContainer . is ( ) )
return ;
sal_Int32 nCount ( xContainer - > getCount ( ) ) ;
if ( nCount = = 0 )
return ;
: : rtl : : OUString sCurrentFormName ;
: : rtl : : OUStringBuffer aNextLevelPrefix ;
for ( sal_Int32 i = 0 ; i < nCount ; + + i )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
// is the current child a form?
2007-07-31 12:57:49 +00:00
Reference < XForm > xCurrentAsForm ( xContainer - > getByIndex ( i ) , UNO_QUERY ) ;
if ( ! xCurrentAsForm . is ( ) )
continue ;
Reference < XNamed > xNamed ( xCurrentAsForm , UNO_QUERY_THROW ) ;
sCurrentFormName = xNamed - > getName ( ) ;
// the name of the current form
: : rtl : : OUStringBuffer sCompleteCurrentName ( sCurrentFormName ) ;
if ( _rCurrentLevelPrefix . getLength ( ) )
2000-09-18 16:07:07 +00:00
{
2007-07-31 12:57:49 +00:00
sCompleteCurrentName . appendAscii ( " ( " ) ;
sCompleteCurrentName . append ( _rCurrentLevelPrefix ) ;
sCompleteCurrentName . appendAscii ( " ) " ) ;
}
2000-09-18 16:07:07 +00:00
2007-07-31 12:57:49 +00:00
// the prefix for the next level
aNextLevelPrefix = _rCurrentLevelPrefix ;
if ( _rCurrentLevelPrefix . getLength ( ) )
aNextLevelPrefix . append ( ( sal_Unicode ) ' / ' ) ;
aNextLevelPrefix . append ( sCurrentFormName ) ;
2000-09-18 16:07:07 +00:00
2007-07-31 12:57:49 +00:00
// remember both the form and it's "display name"
_out_rForms . push_back ( xCurrentAsForm ) ;
_out_rNames . push_back ( sCompleteCurrentName . makeStringAndClear ( ) ) ;
2000-09-18 16:07:07 +00:00
2007-07-31 12:57:49 +00:00
// und absteigen
impl_collectFormSearchContexts_nothrow ( xCurrentAsForm , aNextLevelPrefix . makeStringAndClear ( ) , _out_rForms , _out_rNames ) ;
2000-09-18 16:07:07 +00:00
}
}
2007-07-31 12:57:49 +00:00
catch ( const Exception & )
{
DBG_UNHANDLED_EXCEPTION ( ) ;
}
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : startFiltering ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
// setting all forms in filter mode
FmXFormView * pXView = m_pShell - > GetFormView ( ) - > GetImpl ( ) ;
// if the active controller is our external one we have to use the trigger controller
2000-11-24 06:01:26 +00:00
Reference < XControlContainer > xContainer ;
2000-09-18 16:07:07 +00:00
if ( getActiveController ( ) = = m_xExternalViewController )
{
DBG_ASSERT ( m_xExtViewTriggerController . is ( ) , " FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this ! " ) ;
xContainer = m_xExtViewTriggerController - > getContainer ( ) ;
}
else
xContainer = getActiveController ( ) - > getContainer ( ) ;
FmWinRecList : : iterator i = pXView - > findWindow ( xContainer ) ;
if ( i ! = pXView - > getWindowList ( ) . end ( ) )
{
2000-11-24 06:01:26 +00:00
const : : std : : vector < Reference < XFormController > > & rControllerList = ( * i ) - > GetList ( ) ;
for ( : : std : : vector < Reference < XFormController > > : : const_iterator j = rControllerList . begin ( ) ;
2000-09-18 16:07:07 +00:00
j ! = rControllerList . end ( ) ; + + j )
{
2000-11-24 06:01:26 +00:00
Reference < XModeSelector > xModeSelector ( * j , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xModeSelector . is ( ) )
xModeSelector - > setMode ( FILTER_MODE ) ;
}
}
m_bFilterMode = sal_True ;
m_pShell - > UIFeatureChanged ( ) ;
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void saveFilter ( const Reference < XFormController > & _rxController )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xFormAsSet ( _rxController - > getModel ( ) , UNO_QUERY ) ;
Reference < XPropertySet > xControllerAsSet ( _rxController , UNO_QUERY ) ;
Reference < XIndexAccess > xControllerAsIndex ( _rxController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// call the subcontroller
2000-11-24 06:01:26 +00:00
Reference < XFormController > xController ;
2000-11-07 12:16:50 +00:00
for ( sal_Int32 i = 0 , nCount = xControllerAsIndex - > getCount ( ) ; i < nCount ; + + i )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
xControllerAsIndex - > getByIndex ( i ) > > = xController ;
2000-09-18 16:07:07 +00:00
saveFilter ( xController ) ;
}
try
{
2007-11-21 14:23:26 +00:00
xFormAsSet - > setPropertyValue ( FM_PROP_FILTER , xControllerAsSet - > getPropertyValue ( FM_PROP_FILTER ) ) ;
xFormAsSet - > setPropertyValue ( FM_PROP_APPLYFILTER , makeAny ( ( sal_Bool ) sal_True ) ) ;
2000-09-18 16:07:07 +00:00
}
2007-11-21 14:23:26 +00:00
catch ( const Exception & )
2000-09-18 16:07:07 +00:00
{
2007-11-21 14:23:26 +00:00
DBG_UNHANDLED_EXCEPTION ( ) ;
2000-09-18 16:07:07 +00:00
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : stopFiltering ( sal_Bool bSave )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
m_bFilterMode = sal_False ;
FmXFormView * pXView = m_pShell - > GetFormView ( ) - > GetImpl ( ) ;
// if the active controller is our external one we have to use the trigger controller
2000-11-24 06:01:26 +00:00
Reference < XControlContainer > xContainer ;
2000-09-18 16:07:07 +00:00
if ( getActiveController ( ) = = m_xExternalViewController )
{
DBG_ASSERT ( m_xExtViewTriggerController . is ( ) , " FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this ! " ) ;
xContainer = m_xExtViewTriggerController - > getContainer ( ) ;
}
else
xContainer = getActiveController ( ) - > getContainer ( ) ;
FmWinRecList : : iterator i = pXView - > findWindow ( xContainer ) ;
if ( i ! = pXView - > getWindowList ( ) . end ( ) )
{
2000-11-24 06:01:26 +00:00
const : : std : : vector < Reference < XFormController > > & rControllerList = ( * i ) - > GetList ( ) ;
2000-09-18 16:07:07 +00:00
: : std : : vector < : : rtl : : OUString > aOriginalFilters ;
: : std : : vector < sal_Bool > aOriginalApplyFlags ;
if ( bSave )
{
2000-11-24 06:01:26 +00:00
for ( : : std : : vector < Reference < XFormController > > : : const_iterator j = rControllerList . begin ( ) ;
2000-09-18 16:07:07 +00:00
j ! = rControllerList . end ( ) ; + + j )
{
if ( bSave )
{ // remember the current filter settings in case we're goin to reload the forms below (which may fail)
try
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xFormAsSet ( ( * j ) - > getModel ( ) , UNO_QUERY ) ;
2007-11-21 14:23:26 +00:00
aOriginalFilters . push_back ( : : comphelper : : getString ( xFormAsSet - > getPropertyValue ( FM_PROP_FILTER ) ) ) ;
2000-10-20 13:18:57 +00:00
aOriginalApplyFlags . push_back ( : : comphelper : : getBOOL ( xFormAsSet - > getPropertyValue ( FM_PROP_APPLYFILTER ) ) ) ;
2000-09-18 16:07:07 +00:00
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
DBG_ERROR ( " FmXFormShell::stopFiltering : could not get the original filter ! " ) ;
// put dummies into the arrays so the they have the right size
if ( aOriginalFilters . size ( ) = = aOriginalApplyFlags . size ( ) )
// the first getPropertyValue failed -> use two dummies
aOriginalFilters . push_back ( : : rtl : : OUString ( ) ) ;
aOriginalApplyFlags . push_back ( sal_False ) ;
}
}
saveFilter ( * j ) ;
}
}
2000-11-24 06:01:26 +00:00
for ( : : std : : vector < Reference < XFormController > > : : const_iterator j = rControllerList . begin ( ) ;
2000-09-18 16:07:07 +00:00
j ! = rControllerList . end ( ) ; + + j )
{
2000-11-24 06:01:26 +00:00
Reference < XModeSelector > xModeSelector ( * j , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xModeSelector . is ( ) )
xModeSelector - > setMode ( DATA_MODE ) ;
}
if ( bSave ) // execute the filter
{
2006-06-19 14:57:11 +00:00
const : : std : : vector < Reference < XFormController > > & rControllers = ( * i ) - > GetList ( ) ;
for ( : : std : : vector < Reference < XFormController > > : : const_iterator j = rControllers . begin ( ) ;
j ! = rControllers . end ( ) ; + + j )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Reference < XLoadable > xReload ( ( * j ) - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xReload . is ( ) )
continue ;
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xFormSet ( xReload , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
try
{
xReload - > reload ( ) ;
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
DBG_ERROR ( " FmXFormShell::stopFiltering: Exception occured! " ) ;
2000-09-18 16:07:07 +00:00
}
if ( ! isRowSetAlive ( xFormSet ) )
{ // something went wrong -> restore the original state
2006-06-19 14:57:11 +00:00
: : rtl : : OUString sOriginalFilter = aOriginalFilters [ j - rControllers . begin ( ) ] ;
sal_Bool bOriginalApplyFlag = aOriginalApplyFlags [ j - rControllers . begin ( ) ] ;
2000-09-18 16:07:07 +00:00
try
{
2007-11-21 14:23:26 +00:00
xFormSet - > setPropertyValue ( FM_PROP_FILTER , makeAny ( sOriginalFilter ) ) ;
2000-11-24 06:01:26 +00:00
xFormSet - > setPropertyValue ( FM_PROP_APPLYFILTER , makeAny ( bOriginalApplyFlag ) ) ;
2000-09-18 16:07:07 +00:00
xReload - > reload ( ) ;
}
2007-11-21 14:23:26 +00:00
catch ( const Exception & )
2000-09-18 16:07:07 +00:00
{
2007-11-21 14:23:26 +00:00
DBG_UNHANDLED_EXCEPTION ( ) ;
2000-09-18 16:07:07 +00:00
}
}
}
}
}
m_pShell - > UIFeatureChanged ( ) ;
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . InvalidateShell ( * m_pShell ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void clearFilter ( const Reference < XFormController > & _rxController )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xControllerAsSet ( _rxController , UNO_QUERY ) ;
Reference < XIndexAccess > xControllerAsIndex ( _rxController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// call the subcontroller
2000-11-24 06:01:26 +00:00
Reference < XFormController > xController ;
2000-09-18 16:07:07 +00:00
for ( sal_Int32 i = 0 , nCount = xControllerAsIndex - > getCount ( ) ;
i < nCount ; i + + )
{
2000-11-07 12:16:50 +00:00
xControllerAsIndex - > getByIndex ( i ) > > = xController ;
2000-09-18 16:07:07 +00:00
clearFilter ( xController ) ;
}
// clear the filter
2000-11-24 06:01:26 +00:00
Reference < XIndexContainer > xContainer ;
2000-11-07 12:16:50 +00:00
xControllerAsSet - > getPropertyValue ( FM_PROP_FILTERSUPPLIER ) > > = xContainer ;
2000-09-18 16:07:07 +00:00
if ( xContainer . is ( ) )
{
// clear the current filter
2000-11-24 06:01:26 +00:00
Sequence < PropertyValue > aCondition ;
2000-09-18 16:07:07 +00:00
// as there is always an empty row, if we have a filter:
if ( xContainer - > getCount ( ) )
{
2000-11-24 06:01:26 +00:00
xControllerAsSet - > setPropertyValue ( FM_PROP_CURRENTFILTER , makeAny ( sal_Int32 ( xContainer - > getCount ( ) - 1 ) ) ) ;
2000-09-18 16:07:07 +00:00
while ( xContainer - > getCount ( ) > 1 )
xContainer - > removeByIndex ( 0 ) ;
}
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : clearFilter ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
FmXFormView * pXView = m_pShell - > GetFormView ( ) - > GetImpl ( ) ;
// if the active controller is our external one we have to use the trigger controller
2000-11-24 06:01:26 +00:00
Reference < XControlContainer > xContainer ;
2000-09-18 16:07:07 +00:00
if ( getActiveController ( ) = = m_xExternalViewController )
{
DBG_ASSERT ( m_xExtViewTriggerController . is ( ) , " FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this ! " ) ;
xContainer = m_xExtViewTriggerController - > getContainer ( ) ;
}
else
xContainer = getActiveController ( ) - > getContainer ( ) ;
FmWinRecList : : iterator i = pXView - > findWindow ( xContainer ) ;
if ( i ! = pXView - > getWindowList ( ) . end ( ) )
{
2000-11-24 06:01:26 +00:00
const : : std : : vector < Reference < XFormController > > & rControllerList = ( * i ) - > GetList ( ) ;
for ( : : std : : vector < Reference < XFormController > > : : const_iterator j = rControllerList . begin ( ) ;
2000-09-18 16:07:07 +00:00
j ! = rControllerList . end ( ) ; + + j )
{
: : clearFilter ( * j ) ;
}
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : setControlLocks ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XTabController > xCtrler ( getActiveController ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrler . is ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XControlContainer > xControls ( xCtrler - > getContainer ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xControls . is ( ) )
return ;
2006-06-19 14:57:11 +00:00
DBG_ASSERT ( m_aControlLocks . empty ( ) , " FmXFormShell::setControlLocks: locking state array isn't empty (called me twice ?)! " ) ;
2000-09-18 16:07:07 +00:00
2000-11-24 06:01:26 +00:00
Sequence < Reference < XControl > > aControls = xControls - > getControls ( ) ;
const Reference < XControl > * pControls = aControls . getConstArray ( ) ;
2000-09-18 16:07:07 +00:00
// iterate through all bound controls, remember the old locking state, set the lock
for ( sal_Int32 i = 0 ; i < aControls . getLength ( ) ; + + i )
{
2000-11-24 06:01:26 +00:00
Reference < XBoundControl > xCtrl ( pControls [ i ] , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrl . is ( ) )
{
// it may be a container of controls
2000-11-24 06:01:26 +00:00
Reference < XIndexAccess > xContainer ( pControls [ i ] , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xContainer . is ( ) )
{ // no recursion. we only know top level control containers (e.g. grid controls)
2006-06-19 14:57:11 +00:00
for ( sal_Int16 j = 0 ; j < xContainer - > getCount ( ) ; + + j )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
xContainer - > getByIndex ( j ) > > = xCtrl ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrl . is ( ) )
continue ;
2006-06-19 14:57:11 +00:00
m_aControlLocks . push_back ( xCtrl - > getLock ( ) ) ;
2000-09-18 16:07:07 +00:00
xCtrl - > setLock ( sal_True ) ;
}
}
continue ;
}
2006-06-19 14:57:11 +00:00
m_aControlLocks . push_back ( xCtrl - > getLock ( ) ) ;
2000-09-18 16:07:07 +00:00
xCtrl - > setLock ( sal_True ) ;
}
}
//------------------------------------------------------------------------------
void FmXFormShell : : restoreControlLocks ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XTabController > xCtrler ( getActiveController ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrler . is ( ) )
return ;
2000-11-24 06:01:26 +00:00
Reference < XControlContainer > xControls ( xCtrler - > getContainer ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xControls . is ( ) )
return ;
2000-11-24 06:01:26 +00:00
Sequence < Reference < XControl > > aControls ( xControls - > getControls ( ) ) ;
const Reference < XControl > * pControls = aControls . getConstArray ( ) ;
2000-09-18 16:07:07 +00:00
// iterate through all bound controls, restore the old locking state
2006-06-19 14:57:11 +00:00
size_t nBoundControl = 0 ;
2000-09-18 16:07:07 +00:00
for ( sal_Int32 i = 0 ; i < aControls . getLength ( ) ; + + i )
{
2000-11-24 06:01:26 +00:00
Reference < XBoundControl > xCtrl ( pControls [ i ] , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrl . is ( ) )
{
// it may be a container of controls
2000-11-24 06:01:26 +00:00
Reference < XIndexAccess > xContainer ( pControls [ i ] , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xContainer . is ( ) )
{ // no recursion. we only know top level control containers (e.g. grid controls)
2006-06-19 14:57:11 +00:00
for ( sal_Int16 j = 0 ; j < xContainer - > getCount ( ) ; + + j )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
xContainer - > getByIndex ( j ) > > = xCtrl ;
2000-09-18 16:07:07 +00:00
if ( ! xCtrl . is ( ) )
continue ;
2006-06-19 14:57:11 +00:00
DBG_ASSERT ( nBoundControl < m_aControlLocks . size ( ) , " FmXFormShell::restoreControlLocks: m_aControlLocks is invalid! " ) ;
xCtrl - > setLock ( m_aControlLocks [ nBoundControl ] ) ;
2001-07-25 12:57:12 +00:00
+ + nBoundControl ;
2000-09-18 16:07:07 +00:00
}
}
continue ;
}
2006-06-19 14:57:11 +00:00
DBG_ASSERT ( nBoundControl < m_aControlLocks . size ( ) , " FmXFormShell::restoreControlLocks: m_aControlLocks is invalid! " ) ;
2000-09-18 16:07:07 +00:00
// a violation of this condition would mean a) setControlLocks hasn't been called or b) the ControlContainer
// has changed since the last call to setControlLocks.
// a) clearly is a fault of the programmer and b) shouldn't be possible (as we are in alive mode)
2006-06-19 14:57:11 +00:00
xCtrl - > setLock ( m_aControlLocks [ nBoundControl ] ) ;
2001-07-25 12:57:12 +00:00
+ + nBoundControl ;
2000-09-18 16:07:07 +00:00
}
2006-06-19 14:57:11 +00:00
: : std : : vector < sal_Bool > aEmpty ;
m_aControlLocks . swap ( aEmpty ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void FmXFormShell : : DoAsyncCursorAction ( const Reference < XFormController > & _xController , CURSOR_ACTION _eWhat )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( _xController . is ( ) , " FmXFormShell::DoAsyncCursorAction : invalid argument ! " ) ;
2000-11-24 06:01:26 +00:00
DoAsyncCursorAction ( Reference < XResultSet > ( _xController - > getModel ( ) , UNO_QUERY ) , _eWhat ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
void FmXFormShell : : DoAsyncCursorAction ( const Reference < XResultSet > & _xForm , CURSOR_ACTION _eWhat )
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aAsyncSafety ) ;
DBG_ASSERT ( _xForm . is ( ) , " FmXFormShell::DoAsyncCursorAction : invalid argument ! " ) ;
// build the access path for the form
if ( HasPendingCursorAction ( _xForm ) )
{
DBG_ERROR ( " FmXFormShell::DoAsyncCursorAction : invalid call ! " ) ;
return ;
}
2004-04-13 09:59:06 +00:00
CursorActionDescription & rDesc = m_aCursorActions [ _xForm ] ;
2000-09-18 16:07:07 +00:00
// [] will create a new one if non-existent
DBG_ASSERT ( rDesc . pThread = = NULL , " FmXFormShell::DoAsyncCursorAction : the cursor action thread for this form is still alive ! " ) ;
2004-04-13 09:59:06 +00:00
Reference < XResultSet > xCursor ( getInternalForm ( _xForm ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
switch ( _eWhat )
{
case CA_MOVE_TO_LAST :
2004-04-13 09:59:06 +00:00
rDesc . pThread = new FmMoveToLastThread ( xCursor ) ;
2000-09-18 16:07:07 +00:00
break ;
case CA_MOVE_ABSOLUTE :
DBG_ERROR ( " FmXFormShell::DoAsyncCursorAction : CA_MOVE_ABSOLUTE not supported yet ! " ) ;
return ;
}
rDesc . pThread - > SetTerminationHdl ( LINK ( this , FmXFormShell , OnCursorActionDone ) ) ;
rDesc . pThread - > EnableSelfDelete ( sal_False ) ;
rDesc . bCanceling = sal_False ;
// set the control locks before starting the thread
DBG_ASSERT ( getInternalForm ( m_xActiveForm ) = = m_xActiveForm , " FmXFormShell::DoAsyncCursorAction : the active form should always be a internal one ! " ) ;
if ( getInternalForm ( _xForm ) = = m_xActiveForm )
setControlLocks ( ) ;
// go ...
rDesc . pThread - > create ( ) ;
// set a priority slightly below normal
rDesc . pThread - > setPriority ( : : vos : : OThread : : TPriority_BelowNormal ) ;
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
sal_Bool FmXFormShell : : HasPendingCursorAction ( const Reference < XResultSet > & _xForm ) const
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return sal_False ;
2000-09-18 16:07:07 +00:00
if ( ! _xForm . is ( ) )
return sal_False ;
2004-04-13 09:59:06 +00:00
// TODO: if we ever re-implement the asynchronous cursor actions, then this will happen
// in the controller, and not in the form. In such a case, we here probably need to check
// whether the controller for the form has this "pending cursor action"
return sal_False ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
sal_Bool FmXFormShell : : HasPendingCursorAction ( const Reference < XFormController > & xController ) const
2000-09-18 16:07:07 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return sal_False ;
2000-09-18 16:07:07 +00:00
if ( ! xController . is ( ) )
return sal_False ;
2000-11-24 06:01:26 +00:00
return HasPendingCursorAction ( Reference < XResultSet > ( xController - > getModel ( ) , UNO_QUERY ) ) ;
2000-09-18 16:07:07 +00:00
}
//------------------------------------------------------------------------------
sal_Bool FmXFormShell : : HasAnyPendingCursorAction ( ) const
{
2004-04-13 09:59:06 +00:00
: : osl : : MutexGuard aGuard ( const_cast < FmXFormShell * > ( this ) - > m_aAsyncSafety ) ;
2000-09-18 16:07:07 +00:00
2004-04-13 09:59:06 +00:00
for ( CursorActions : : const_iterator aIter = m_aCursorActions . begin ( ) ; aIter ! = m_aCursorActions . end ( ) ; + + aIter )
2000-09-18 16:07:07 +00:00
{
if ( ( ( * aIter ) . second . pThread ! = NULL ) | | ( ( * aIter ) . second . nFinishedEvent ! = 0 ) )
return sal_True ;
}
return sal_False ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : CancelAnyPendingCursorAction ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2005-12-21 12:31:13 +00:00
: : osl : : ResettableMutexGuard aGuard ( m_aAsyncSafety ) ;
2000-09-18 16:07:07 +00:00
2004-04-13 09:59:06 +00:00
CursorActions : : iterator aIter ;
2000-09-18 16:07:07 +00:00
for ( aIter = m_aCursorActions . begin ( ) ; aIter ! = m_aCursorActions . end ( ) ; + + aIter )
{
if ( ! ( * aIter ) . second . nFinishedEvent & & ( * aIter ) . second . pThread )
{ // the thread is really running
( * aIter ) . second . bCanceling = sal_True ;
aGuard . clear ( ) ;
( * aIter ) . second . pThread - > StopItWait ( ) ;
// StopItWait returns after the termination handler (our OnCursorActionDone) has been called
2005-12-21 12:31:13 +00:00
aGuard . reset ( ) ;
2000-09-18 16:07:07 +00:00
}
}
// all threads are finished (means canceled), now do the cleanup
for ( aIter = m_aCursorActions . begin ( ) ; aIter ! = m_aCursorActions . end ( ) ; + + aIter )
{
if ( ( * aIter ) . second . pThread )
{
LINK ( this , FmXFormShell , OnCursorActionDoneMainThread ) . Call ( ( * aIter ) . second . pThread ) ;
DBG_ASSERT ( ( * aIter ) . second . pThread = = NULL , " FmXFormShell::CancelAnyPendingCursorAction : strange behaviour of OnCursorActionDoneMainThread ! " ) ;
}
}
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnCursorActionDone , FmCursorActionThread * , pThread )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0L ;
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aAsyncSafety ) ;
// search the pos of the thread within m_aCursorActions
2004-04-13 09:59:06 +00:00
CursorActions : : iterator aIter ;
2000-09-18 16:07:07 +00:00
for ( aIter = m_aCursorActions . begin ( ) ; aIter ! = m_aCursorActions . end ( ) ; + + aIter )
{
if ( ( * aIter ) . second . pThread = = pThread )
break ;
}
DBG_ASSERT ( aIter ! = m_aCursorActions . end ( ) , " FmXFormShell::OnCursorActionDone : could not ::std::find the thread ! " ) ;
DBG_ASSERT ( ( * aIter ) . second . nFinishedEvent = = 0 , " FmXFormShell::OnCursorActionDone : another 'ActionDone' for this thread is pending ! " ) ;
// as we allow only one async action at a time (per form) this shouldn't happen
if ( ! ( * aIter ) . second . bCanceling )
( * aIter ) . second . nFinishedEvent = Application : : PostUserEvent ( LINK ( this , FmXFormShell , OnCursorActionDoneMainThread ) , pThread ) ;
// if bCanceling is sal_True an other thread's execution is in CancelAnyPendingCursorAction
return 0L ;
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnCursorActionDoneMainThread , FmCursorActionThread * , pThread )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0L ;
2000-09-18 16:07:07 +00:00
: : osl : : MutexGuard aGuard ( m_aAsyncSafety ) ;
// search the pos of the thread within m_aCursorActions
2004-04-13 09:59:06 +00:00
CursorActions : : iterator aIter = m_aCursorActions . find ( pThread - > getDataSource ( ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( aIter ! = m_aCursorActions . end ( ) , " FmXFormShell::OnCursorActionDoneMainThread : could not ::std::find the thread data ! " ) ;
DBG_ASSERT ( ( * aIter ) . second . pThread = = pThread , " FmXFormShell::OnCursorActionDoneMainThread : invalid thread data ! " ) ;
// remember some thread parameters
2000-11-24 06:01:26 +00:00
Reference < XResultSet > xForm ( pThread - > getDataSource ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// throw away the thread
delete ( * aIter ) . second . pThread ;
( * aIter ) . second . pThread = NULL ;
( * aIter ) . second . nFinishedEvent = 0 ;
( * aIter ) . second . bCanceling = sal_False ;
// as we allow exactly one thread per form we may remove this ones data from m_aCursorActions
m_aCursorActions . erase ( aIter ) ;
DBG_ASSERT ( getInternalForm ( m_xActiveForm ) = = m_xActiveForm , " FmXFormShell::DoAsyncCursorAction : the active form should always be a internal one ! " ) ;
DBG_ASSERT ( getInternalForm ( xForm ) = = xForm , " FmXFormShell::DoAsyncCursorAction : the thread's form should always be a internal one ! " ) ;
// if one of the two asserts above fails the upcoming comparison is senseless
if ( xForm = = m_xActiveForm )
{
// the active controller belongs to the form where the action is finished
// -> re-enable the controls if they are not locked because of another running thread
if ( ! HasPendingCursorAction ( xForm ) )
restoreControlLocks ( ) ;
}
2000-09-21 11:31:31 +00:00
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > GetBindings ( ) . Invalidate ( DatabaseSlotMap ) ;
2000-09-18 16:07:07 +00:00
// it may not be neccessary but me thinks it's faster without the check if we really have to do this
return 0L ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : CreateExternalView ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( m_xAttachedFrame . is ( ) , " FmXFormShell::CreateExternalView : no frame ! " ) ;
// the frame the external view is displayed in
sal_Bool bAlreadyExistent = m_xExternalViewController . is ( ) ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XFrame > xExternalViewFrame ;
2000-11-06 06:19:53 +00:00
: : rtl : : OUString sFrameName = : : rtl : : OUString : : createFromAscii ( " _beamer " ) ;
sal_Int32 nSearchFlags = : : com : : sun : : star : : frame : : FrameSearchFlag : : CHILDREN | : : com : : sun : : star : : frame : : FrameSearchFlag : : CREATE ;
2000-09-18 16:07:07 +00:00
2000-11-24 06:01:26 +00:00
Reference < XFormController > xCurrentNavController ( getNavController ( ) ) ;
2000-09-18 16:07:07 +00:00
// 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
// FS - 21.10.99 - 69219
{
2006-06-19 14:57:11 +00:00
FmXBoundFormFieldIterator aModelIterator ( xCurrentNavController - > getModel ( ) ) ;
Reference < XPropertySet > xCurrentModelSet ;
sal_Bool bHaveUsableControls = sal_False ;
while ( ( xCurrentModelSet = Reference < XPropertySet > ( aModelIterator . Next ( ) , UNO_QUERY ) ) . is ( ) )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
// the FmXBoundFormFieldIterator only supplies controls with a valid control source
// so we just have to check the field type
sal_Int16 nClassId = : : comphelper : : getINT16 ( xCurrentModelSet - > getPropertyValue ( FM_PROP_CLASSID ) ) ;
switch ( nClassId )
{
case FormComponentType : : IMAGECONTROL :
case FormComponentType : : CONTROL :
continue ;
}
bHaveUsableControls = sal_True ;
break ;
2000-09-18 16:07:07 +00:00
}
2006-06-19 14:57:11 +00:00
if ( ! bHaveUsableControls )
{
ErrorBox ( NULL , WB_OK , SVX_RESSTR ( RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY ) ) . Execute ( ) ;
return ;
}
2000-09-18 16:07:07 +00:00
}
// load the component for external form views
if ( ! bAlreadyExistent )
{
2000-11-24 06:01:26 +00:00
URL aWantToDispatch ;
2000-09-18 16:07:07 +00:00
aWantToDispatch . Complete = FMURL_COMPONENT_FORMGRIDVIEW ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatchProvider > xProv ( m_xAttachedFrame , UNO_QUERY ) ;
Reference < : : com : : sun : : star : : frame : : XDispatch > xDisp ;
2000-09-18 16:07:07 +00:00
if ( xProv . is ( ) )
xDisp = xProv - > queryDispatch ( aWantToDispatch , sFrameName , nSearchFlags ) ;
if ( xDisp . is ( ) )
{
2000-11-24 06:01:26 +00:00
xDisp - > dispatch ( aWantToDispatch , Sequence < PropertyValue > ( ) ) ;
2000-09-18 16:07:07 +00:00
}
// with this the component should be loaded, now search the frame where it resides in
2000-11-06 06:19:53 +00:00
xExternalViewFrame = m_xAttachedFrame - > findFrame ( sFrameName , : : com : : sun : : star : : frame : : FrameSearchFlag : : CHILDREN ) ;
2000-09-18 16:07:07 +00:00
if ( xExternalViewFrame . is ( ) )
{
m_xExternalViewController = xExternalViewFrame - > getController ( ) ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : lang : : XComponent > xComp ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xComp . is ( ) )
2000-11-24 06:01:26 +00:00
xComp - > addEventListener ( ( XEventListener * ) ( XPropertyChangeListener * ) this ) ;
2000-09-18 16:07:07 +00:00
}
}
else
{
xExternalViewFrame = m_xExternalViewController - > getFrame ( ) ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatchProvider > xCommLink ( xExternalViewFrame , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// if we display the active form we interpret the slot as "remove it"
2000-11-24 06:01:26 +00:00
Reference < XForm > xCurrentModel ( xCurrentNavController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( ( xCurrentModel = = m_xExternalDisplayedForm ) | | ( getInternalForm ( xCurrentModel ) = = m_xExternalDisplayedForm ) )
{
2004-04-13 09:59:06 +00:00
if ( m_xExternalViewController = = getActiveController ( ) )
{
Reference < XFormController > xAsFormController ( m_xExternalViewController , UNO_QUERY ) ;
ControllerFeatures aHelper ( : : comphelper : : getProcessServiceFactory ( ) , xAsFormController , NULL ) ;
aHelper - > commitCurrentControl ( ) ;
}
2000-09-18 16:07:07 +00:00
2000-11-24 06:01:26 +00:00
Reference < XFormController > xNewController ( m_xExtViewTriggerController ) ;
2000-09-18 16:07:07 +00:00
CloseExternalFormViewer ( ) ;
setActiveController ( xNewController ) ;
return ;
}
2000-11-24 06:01:26 +00:00
URL aClearURL ;
2000-09-18 16:07:07 +00:00
aClearURL . Complete = FMURL_GRIDVIEW_CLEARVIEW ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatch > xClear ( xCommLink - > queryDispatch ( aClearURL , : : rtl : : OUString : : createFromAscii ( " " ) , 0 ) ) ;
2000-09-18 16:07:07 +00:00
if ( xClear . is ( ) )
2000-11-24 06:01:26 +00:00
xClear - > dispatch ( aClearURL , Sequence < PropertyValue > ( ) ) ;
2000-09-18 16:07:07 +00:00
}
// 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 )
{
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatchProviderInterception > xSupplier ( xExternalViewFrame , UNO_QUERY ) ;
2000-11-14 14:34:40 +00:00
: : rtl : : OUString sInterceptorScheme = FMURL_FORMSLOTS_PREFIX ;
2000-11-09 09:07:35 +00:00
sInterceptorScheme + = : : rtl : : OUString : : createFromAscii ( " * " ) ;
2004-04-13 09:59:06 +00:00
// 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
2000-09-18 16:07:07 +00:00
}
// get the dispatch interface of the frame so we can communicate (interceptable) with the controller
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatchProvider > xCommLink ( xExternalViewFrame , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( m_xExternalViewController . is ( ) )
{
DBG_ASSERT ( xCommLink . is ( ) , " FmXFormShell::CreateExternalView : the component doesn't have the necessary interfaces ! " ) ;
// collect the dispatchers we will need
2000-11-24 06:01:26 +00:00
URL aAddColumnURL ;
2000-09-18 16:07:07 +00:00
aAddColumnURL . Complete = FMURL_GRIDVIEW_ADDCOLUMN ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatch > xAddColumnDispatch ( xCommLink - > queryDispatch ( aAddColumnURL , : : rtl : : OUString : : createFromAscii ( " " ) , 0 ) ) ;
URL aAttachURL ;
2000-09-18 16:07:07 +00:00
aAttachURL . Complete = FMURL_GRIDVIEW_ATTACHTOFORM ;
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : frame : : XDispatch > xAttachDispatch ( xCommLink - > queryDispatch ( aAttachURL , : : rtl : : OUString : : createFromAscii ( " " ) , 0 ) ) ;
2000-09-18 16:07:07 +00:00
if ( xAddColumnDispatch . is ( ) & & xAttachDispatch . is ( ) )
{
DBG_ASSERT ( xCurrentNavController . is ( ) , " FmXFormShell::CreateExternalView : invalid call : have no nav controller ! " ) ;
// first : dispatch the descriptions for the columns to add
2000-11-24 06:01:26 +00:00
Sequence < Reference < XControl > > aCurrentControls ( xCurrentNavController - > getControls ( ) ) ;
2000-09-18 16:07:07 +00:00
sal_Int16 nAddedColumns = 0 ;
// for radio buttons we need some special structures
2000-11-24 06:01:26 +00:00
DECLARE_STL_USTRINGACCESS_MAP ( Sequence < : : rtl : : OUString > , MapUString2UstringSeq ) ;
2000-09-18 16:07:07 +00:00
DECLARE_STL_ITERATORS ( MapUString2UstringSeq ) ;
DECLARE_STL_USTRINGACCESS_MAP ( : : rtl : : OUString , FmMapUString2UString ) ;
DECLARE_STL_USTRINGACCESS_MAP ( sal_Int16 , FmMapUString2Int16 ) ;
DECLARE_STL_ITERATORS ( FmMapUString2Int16 ) ;
MapUString2UstringSeq aRadioValueLists ;
MapUString2UstringSeq aRadioListSources ;
FmMapUString2UString aRadioControlSources ;
FmMapUString2Int16 aRadioPositions ;
FmXBoundFormFieldIterator aModelIterator ( xCurrentNavController - > getModel ( ) ) ;
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xCurrentModelSet ;
Any aCurrentBoundField ;
2000-09-18 16:07:07 +00:00
: : rtl : : OUString sColumnType , aGroupName , sControlSource ;
2000-11-24 06:01:26 +00:00
Sequence < Property > aProps ;
Reference < XPropertySet > xCurrentBoundField ;
while ( ( xCurrentModelSet = Reference < XPropertySet > ( aModelIterator . Next ( ) , UNO_QUERY ) ) . is ( ) )
2000-09-18 16:07:07 +00:00
{
2000-11-07 12:16:50 +00:00
xCurrentModelSet - > getPropertyValue ( FM_PROP_BOUNDFIELD ) > > = xCurrentBoundField ;
2001-03-23 15:26:54 +00:00
OSL_ENSURE ( xCurrentModelSet . is ( ) , " xCurrentModelSet is null! " ) ;
2000-09-18 16:07:07 +00:00
// create a description of the column to be created
// first : determine it's type
2000-10-20 13:18:57 +00:00
sal_Int16 nClassId = : : comphelper : : getINT16 ( xCurrentModelSet - > getPropertyValue ( FM_PROP_CLASSID ) ) ;
2000-09-18 16:07:07 +00:00
switch ( nClassId )
{
2000-11-24 06:01:26 +00:00
case FormComponentType : : RADIOBUTTON :
2000-09-18 16:07:07 +00:00
{
// get the label of the button (this is the access key for our structures)
aGroupName = getLabelName ( xCurrentModelSet ) ;
// add the reference value of the radio button to the list source sequence
2000-11-24 06:01:26 +00:00
Sequence < : : rtl : : OUString > & aThisGroupLabels = aRadioListSources [ aGroupName ] ;
2000-09-18 16:07:07 +00:00
sal_Int32 nNewSizeL = aThisGroupLabels . getLength ( ) + 1 ;
aThisGroupLabels . realloc ( nNewSizeL ) ;
2000-10-20 13:18:57 +00:00
aThisGroupLabels . getArray ( ) [ nNewSizeL - 1 ] = : : comphelper : : getString ( xCurrentModelSet - > getPropertyValue ( FM_PROP_REFVALUE ) ) ;
2000-09-18 16:07:07 +00:00
// add the label to the value list sequence
2000-11-24 06:01:26 +00:00
Sequence < : : rtl : : OUString > & aThisGroupControlSources = aRadioValueLists [ aGroupName ] ;
2000-09-18 16:07:07 +00:00
sal_Int32 nNewSizeC = aThisGroupControlSources . getLength ( ) + 1 ;
aThisGroupControlSources . realloc ( nNewSizeC ) ;
2000-10-20 13:18:57 +00:00
aThisGroupControlSources . getArray ( ) [ nNewSizeC - 1 ] = : : comphelper : : getString ( xCurrentModelSet - > getPropertyValue ( FM_PROP_LABEL ) ) ;
2000-09-18 16:07:07 +00:00
// remember the controls source of the radio group
2000-10-20 13:18:57 +00:00
sControlSource = : : comphelper : : getString ( xCurrentModelSet - > getPropertyValue ( FM_PROP_CONTROLSOURCE ) ) ;
2000-09-18 16:07:07 +00:00
if ( aRadioControlSources . find ( aGroupName ) = = aRadioControlSources . end ( ) )
aRadioControlSources [ aGroupName ] = sControlSource ;
# ifdef DBG_UTIL
else
DBG_ASSERT ( aRadioControlSources [ aGroupName ] = = sControlSource ,
" FmXFormShell::CreateExternalView : inconsistent radio buttons detected ! " ) ;
// (radio buttons with the same name should have the same control source)
# endif
// remember the position within the columns
if ( aRadioPositions . find ( aGroupName ) = = aRadioPositions . end ( ) )
aRadioPositions [ aGroupName ] = ( sal_Int16 ) nAddedColumns ;
// any further handling is done below
}
2006-06-19 14:57:11 +00:00
continue ;
2000-09-18 16:07:07 +00:00
2000-11-24 06:01:26 +00:00
case FormComponentType : : IMAGECONTROL :
case FormComponentType : : CONTROL :
2000-09-18 16:07:07 +00:00
// no grid columns for these types (though they have a control source)
continue ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : CHECKBOX :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_CHECKBOX ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : LISTBOX :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_LISTBOX ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : COMBOBOX :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_COMBOBOX ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : DATEFIELD :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_DATEFIELD ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : TIMEFIELD :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_TIMEFIELD ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : NUMERICFIELD :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_NUMERICFIELD ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : CURRENCYFIELD :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_CURRENCYFIELD ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : PATTERNFIELD :
2000-09-18 16:07:07 +00:00
sColumnType = FM_COL_PATTERNFIELD ; break ;
2000-11-24 06:01:26 +00:00
case FormComponentType : : TEXTFIELD :
2000-09-18 16:07:07 +00:00
{
sColumnType = FM_COL_TEXTFIELD ;
// we know at least two different controls which are TextFields : the basic edit field and the formatted
// field. we distinguish them by their service name
2000-11-24 06:01:26 +00:00
Reference < XServiceInfo > xInfo ( xCurrentModelSet , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xInfo . is ( ) )
{
sal_Int16 nObjectType = getControlTypeByObject ( xInfo ) ;
if ( OBJ_FM_FORMATTEDFIELD = = nObjectType )
sColumnType = FM_COL_FORMATTEDFIELD ;
}
}
break ;
default :
sColumnType = FM_COL_TEXTFIELD ; break ;
}
const sal_Int16 nDispatchArgs = 3 ;
2000-11-24 06:01:26 +00:00
Sequence < PropertyValue > aDispatchArgs ( nDispatchArgs ) ;
PropertyValue * pDispatchArgs = aDispatchArgs . getArray ( ) ;
2000-09-18 16:07:07 +00:00
// properties describing "meta data" about the column
// the type
pDispatchArgs - > Name = FMARG_ADDCOL_COLUMNTYPE ;
pDispatchArgs - > Value < < = sColumnType ;
+ + pDispatchArgs ;
// the pos : append the col
pDispatchArgs - > Name = FMARG_ADDCOL_COLUMNPOS ;
pDispatchArgs - > Value < < = nAddedColumns ;
+ + pDispatchArgs ;
// the properties to forward to the new column
2000-11-24 06:01:26 +00:00
Sequence < PropertyValue > aColumnProps ( 1 ) ;
PropertyValue * pColumnProps = aColumnProps . getArray ( ) ;
2000-09-18 16:07:07 +00:00
// the label
pColumnProps - > Name = FM_PROP_LABEL ;
pColumnProps - > Value < < = getLabelName ( xCurrentModelSet ) ;
+ + pColumnProps ;
// for all other props : transfer them
2000-11-24 06:01:26 +00:00
Reference < XPropertySetInfo > xControlModelInfo ( xCurrentModelSet - > getPropertySetInfo ( ) ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xControlModelInfo . is ( ) , " FmXFormShell::CreateExternalView : the control model has no property info ! This will crash ! " ) ;
aProps = xControlModelInfo - > getProperties ( ) ;
2000-11-24 06:01:26 +00:00
const Property * pProps = aProps . getConstArray ( ) ;
2000-09-18 16:07:07 +00:00
// realloc the control description sequence
sal_Int32 nExistentDescs = pColumnProps - aColumnProps . getArray ( ) ;
aColumnProps . realloc ( nExistentDescs + aProps . getLength ( ) ) ;
pColumnProps = aColumnProps . getArray ( ) + nExistentDescs ;
for ( sal_Int32 i = 0 ; i < aProps . getLength ( ) ; + + i , + + pProps )
{
if ( pProps - > Name . equals ( FM_PROP_LABEL ) )
// already set
continue ;
if ( pProps - > Name . equals ( FM_PROP_DEFAULTCONTROL ) )
// allow the column's own "default control"
continue ;
2000-11-24 06:01:26 +00:00
if ( pProps - > Attributes & PropertyAttribute : : READONLY )
2000-09-18 16:07:07 +00:00
// assume that properties which are readonly for the control are ro for the column to be created, too
continue ;
pColumnProps - > Name = pProps - > Name ;
pColumnProps - > Value = xCurrentModelSet - > getPropertyValue ( pProps - > Name ) ;
+ + pColumnProps ;
}
aColumnProps . realloc ( pColumnProps - aColumnProps . getArray ( ) ) ;
// columns props are a dispatch argument
pDispatchArgs - > Name = : : rtl : : OUString : : createFromAscii ( " ColumnProperties " ) ; // TODO : fmurl.*
2000-11-24 06:01:26 +00:00
pDispatchArgs - > Value = makeAny ( aColumnProps ) ;
2000-09-18 16:07:07 +00:00
+ + pDispatchArgs ;
DBG_ASSERT ( nDispatchArgs = = ( pDispatchArgs - aDispatchArgs . getConstArray ( ) ) ,
" FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ? " ) ;
// dispatch the "add column"
xAddColumnDispatch - > dispatch ( aAddColumnURL , aDispatchArgs ) ;
+ + nAddedColumns ;
}
// now for the radio button handling
sal_Int16 nOffset ( 0 ) ;
// properties describing the "direct" column properties
const sal_Int16 nListBoxDescription = 6 ;
2000-11-24 06:01:26 +00:00
Sequence < PropertyValue > aListBoxDescription ( nListBoxDescription ) ;
2000-09-18 16:07:07 +00:00
for ( ConstFmMapUString2UStringIterator aCtrlSource = aRadioControlSources . begin ( ) ;
aCtrlSource ! = aRadioControlSources . end ( ) ;
+ + aCtrlSource , + + nOffset
)
{
2000-11-24 06:01:26 +00:00
PropertyValue * pListBoxDescription = aListBoxDescription . getArray ( ) ;
2000-09-18 16:07:07 +00:00
// label
pListBoxDescription - > Name = FM_PROP_LABEL ;
pListBoxDescription - > Value < < = ( * aCtrlSource ) . first ;
+ + pListBoxDescription ;
// control source
pListBoxDescription - > Name = FM_PROP_CONTROLSOURCE ;
pListBoxDescription - > Value < < = ( * aCtrlSource ) . second ;
+ + pListBoxDescription ;
// bound column
pListBoxDescription - > Name = FM_PROP_BOUNDCOLUMN ;
pListBoxDescription - > Value < < = ( sal_Int16 ) 1 ;
+ + pListBoxDescription ;
// content type
pListBoxDescription - > Name = FM_PROP_LISTSOURCETYPE ;
2000-11-24 06:01:26 +00:00
ListSourceType eType = ListSourceType_VALUELIST ;
pListBoxDescription - > Value = makeAny ( eType ) ;
2000-09-18 16:07:07 +00:00
+ + pListBoxDescription ;
// list source
MapUString2UstringSeq : : const_iterator aCurrentListSource = aRadioListSources . find ( ( * aCtrlSource ) . first ) ;
DBG_ASSERT ( aCurrentListSource ! = aRadioListSources . end ( ) ,
" FmXFormShell::CreateExternalView : inconsistent radio descriptions ! " ) ;
pListBoxDescription - > Name = FM_PROP_LISTSOURCE ;
2000-11-24 06:01:26 +00:00
pListBoxDescription - > Value = makeAny ( ( * aCurrentListSource ) . second ) ;
2000-09-18 16:07:07 +00:00
+ + pListBoxDescription ;
// value list
MapUString2UstringSeq : : const_iterator aCurrentValueList = aRadioValueLists . find ( ( * aCtrlSource ) . first ) ;
DBG_ASSERT ( aCurrentValueList ! = aRadioValueLists . end ( ) ,
" FmXFormShell::CreateExternalView : inconsistent radio descriptions ! " ) ;
pListBoxDescription - > Name = FM_PROP_STRINGITEMLIST ;
2000-11-24 06:01:26 +00:00
pListBoxDescription - > Value = makeAny ( ( ( * aCurrentValueList ) . second ) ) ;
2000-09-18 16:07:07 +00:00
+ + pListBoxDescription ;
DBG_ASSERT ( nListBoxDescription = = ( pListBoxDescription - aListBoxDescription . getConstArray ( ) ) ,
" FmXFormShell::CreateExternalView : forgot to adjust nListBoxDescription ? " ) ;
// properties describing the column "meta data"
const sal_Int16 nDispatchArgs = 3 ;
2000-11-24 06:01:26 +00:00
Sequence < PropertyValue > aDispatchArgs ( nDispatchArgs ) ;
PropertyValue * pDispatchArgs = aDispatchArgs . getArray ( ) ;
2000-09-18 16:07:07 +00:00
// column type : listbox
pDispatchArgs - > Name = FMARG_ADDCOL_COLUMNTYPE ;
: : rtl : : OUString fColName = FM_COL_LISTBOX ;
pDispatchArgs - > Value < < = fColName ;
// pDispatchArgs->Value <<= (::rtl::OUString)FM_COL_LISTBOX;
+ + pDispatchArgs ;
// column position
pDispatchArgs - > Name = FMARG_ADDCOL_COLUMNPOS ;
FmMapUString2Int16 : : const_iterator aOffset = aRadioPositions . find ( ( * aCtrlSource ) . first ) ;
DBG_ASSERT ( aOffset ! = aRadioPositions . end ( ) ,
" FmXFormShell::CreateExternalView : inconsistent radio descriptions ! " ) ;
sal_Int16 nPosition = ( * aOffset ) . second ;
2006-10-12 11:46:14 +00:00
nPosition = nPosition + nOffset ;
2000-09-18 16:07:07 +00:00
// we alread inserted nOffset additinal columns ....
pDispatchArgs - > Value < < = nPosition ;
+ + pDispatchArgs ;
// the
pDispatchArgs - > Name = : : rtl : : OUString : : createFromAscii ( " ColumnProperties " ) ; // TODO : fmurl.*
2000-11-24 06:01:26 +00:00
pDispatchArgs - > Value = makeAny ( aListBoxDescription ) ;
2000-09-18 16:07:07 +00:00
+ + pDispatchArgs ;
DBG_ASSERT ( nDispatchArgs = = ( pDispatchArgs - aDispatchArgs . getConstArray ( ) ) ,
" FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ? " ) ;
// dispatch the "add column"
xAddColumnDispatch - > dispatch ( aAddColumnURL , aDispatchArgs ) ;
+ + nAddedColumns ;
}
DBG_ASSERT ( nAddedColumns > 0 , " FmXFormShell::CreateExternalView : no controls (inconsistent) ! " ) ;
// we should have checked if we have any usable controls (see above).
// "load" the "form" of the external view
2000-11-24 06:01:26 +00:00
PropertyValue aArg ;
2000-09-18 16:07:07 +00:00
aArg . Name = FMARG_ATTACHTO_MASTERFORM ;
2000-11-24 06:01:26 +00:00
Reference < XResultSet > xForm ( xCurrentNavController - > getModel ( ) , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
aArg . Value < < = xForm ;
2000-11-24 06:01:26 +00:00
m_xExternalDisplayedForm = Reference < XResultSet > ( xForm , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
// do this before dispatching the "attach" command, as the atach may result in a call to our queryDispatch (for the FormSlots)
// whichs needs the m_xExternalDisplayedForm
2000-11-24 06:01:26 +00:00
xAttachDispatch - > dispatch ( aAttachURL , Sequence < PropertyValue > ( & aArg , 1 ) ) ;
2000-09-18 16:07:07 +00:00
m_xExtViewTriggerController = xCurrentNavController ;
// we want to know modifications done in the external view
2000-11-24 06:01:26 +00:00
// if the external controller is a XFormController we can use all our default handlings for it
Reference < XFormController > xFormController ( m_xExternalViewController , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xFormController . is ( ) )
2000-11-24 06:01:26 +00:00
xFormController - > addActivateListener ( ( XFormControllerListener * ) this ) ;
2000-09-18 16:07:07 +00:00
}
}
# ifdef DBG_UTIL
else
{
DBG_ERROR ( " FmXFormShell::CreateExternalView : could not create the external form view ! " ) ;
}
# endif
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_VIEW_AS_GRID , sal_False ) ;
2000-09-18 16:07:07 +00:00
}
2001-02-21 12:45:24 +00:00
//------------------------------------------------------------------------
void FmXFormShell : : implAdjustConfigCache ( )
{
// get (cache) the wizard usage flag
Sequence < : : rtl : : OUString > aNames ( 1 ) ;
aNames [ 0 ] = : : rtl : : OUString : : createFromAscii ( " FormControlPilotsEnabled " ) ;
Sequence < Any > aFlags = GetProperties ( aNames ) ;
if ( 1 = = aFlags . getLength ( ) )
m_bUseWizards = : : cppu : : any2bool ( aFlags [ 0 ] ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : Notify ( const com : : sun : : star : : uno : : Sequence < rtl : : OUString > & _rPropertyNames )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2006-01-19 14:40:05 +00:00
2001-02-21 12:45:24 +00:00
const : : rtl : : OUString * pSearch = _rPropertyNames . getConstArray ( ) ;
const : : rtl : : OUString * pSearchTil = pSearch + _rPropertyNames . getLength ( ) ;
for ( ; pSearch < pSearchTil ; + + pSearch )
if ( 0 = = pSearch - > compareToAscii ( " FormControlPilotsEnabled " ) )
{
implAdjustConfigCache ( ) ;
2005-01-05 11:21:07 +00:00
InvalidateSlot ( SID_FM_USE_WIZARDS , sal_True ) ;
2001-02-21 12:45:24 +00:00
}
}
//------------------------------------------------------------------------
void FmXFormShell : : SetWizardUsing ( sal_Bool _bUseThem )
{
m_bUseWizards = _bUseThem ;
Sequence < : : rtl : : OUString > aNames ( 1 ) ;
aNames [ 0 ] = : : rtl : : OUString : : createFromAscii ( " FormControlPilotsEnabled " ) ;
Sequence < Any > aValues ( 1 ) ;
aValues [ 0 ] = : : cppu : : bool2any ( m_bUseWizards ) ;
PutProperties ( aNames , aValues ) ;
}
2002-09-09 13:27:00 +00:00
//------------------------------------------------------------------------
2008-08-28 05:55:02 +00:00
void FmXFormShell : : viewDeactivated ( FmFormView & _rCurrentView , sal_Bool _bDeactivateController /* = sal_True */ )
2002-09-09 13:27:00 +00:00
{
2008-08-28 05:55:02 +00:00
OSL_TRACE ( " --- FmXFormShell::viewDeactivated: %p, %p, ........ \n " , this , & _rCurrentView ) ;
if ( _rCurrentView . GetImpl ( ) & & ! _rCurrentView . IsDesignMode ( ) )
2002-09-26 06:42:32 +00:00
{
2008-08-28 05:55:02 +00:00
_rCurrentView . GetImpl ( ) - > Deactivate ( _bDeactivateController ) ;
}
2002-09-26 06:42:32 +00:00
2008-08-28 05:55:02 +00:00
// if we have an async load operation pending for the 0-th page for this view,
// we need to cancel this
// 103727 - 2002-09-26 - fs@openoffice.org
FmFormPage * pPage = _rCurrentView . GetCurPage ( ) ;
if ( pPage )
{
// move all events from our queue to a new one, omit the events for the deactivated
// page
: : std : : queue < FmLoadAction > aNewEvents ;
while ( m_aLoadingPages . size ( ) )
2002-09-26 06:42:32 +00:00
{
2008-08-28 05:55:02 +00:00
FmLoadAction aAction = m_aLoadingPages . front ( ) ;
m_aLoadingPages . pop ( ) ;
if ( pPage ! = aAction . pPage )
2002-09-26 06:42:32 +00:00
{
2008-08-28 05:55:02 +00:00
aNewEvents . push ( aAction ) ;
}
else
{
Application : : RemoveUserEvent ( aAction . nEventId ) ;
2002-09-26 06:42:32 +00:00
}
}
2008-08-28 05:55:02 +00:00
m_aLoadingPages = aNewEvents ;
}
2008-05-05 14:45:47 +00:00
2008-08-28 05:55:02 +00:00
// remove callbacks at the page
if ( pPage & & pPage - > GetImpl ( ) )
{
OSL_TRACE ( " --- FmXFormShell::resetHandler : %p, ........, %p \n " , this , pPage ) ;
pPage - > GetImpl ( ) - > SetFormsCreationHdl ( Link ( ) ) ;
2002-09-26 06:42:32 +00:00
}
2008-08-28 05:55:02 +00:00
UpdateForms ( sal_True ) ;
2002-09-09 13:27:00 +00:00
}
2005-03-10 15:23:52 +00:00
//------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
IMPL_LINK ( FmXFormShell , OnFirstTimeActivation , void * , /*NOTINTERESTEDIN*/ )
2005-03-10 15:23:52 +00:00
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return 0L ;
2005-03-10 15:23:52 +00:00
m_nActivationEvent = 0 ;
2008-08-28 05:55:02 +00:00
SfxObjectShell * pDocument = m_pShell - > GetObjectShell ( ) ;
2005-03-10 15:23:52 +00:00
2005-09-23 10:59:24 +00:00
if ( pDocument & & ! pDocument - > HasName ( ) )
2005-03-10 15:23:52 +00:00
{
2007-04-16 15:21:12 +00:00
if ( isEnhancedForm ( ) )
2005-03-10 15:23:52 +00:00
{
2007-04-16 15:21:12 +00:00
// show the data navigator
2005-03-10 15:23:52 +00:00
if ( ! m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > HasChildWindow ( SID_FM_SHOW_DATANAVIGATOR ) )
m_pShell - > GetViewShell ( ) - > GetViewFrame ( ) - > ToggleChildWindow ( SID_FM_SHOW_DATANAVIGATOR ) ;
}
}
return 0L ;
}
2008-05-05 14:45:47 +00:00
//------------------------------------------------------------------------
IMPL_LINK ( FmXFormShell , OnFormsCreated , FmFormPage * , /*_pPage*/ )
{
UpdateForms ( sal_True ) ;
return 0L ;
}
2002-09-09 13:27:00 +00:00
//------------------------------------------------------------------------
2008-08-28 05:55:02 +00:00
void FmXFormShell : : viewActivated ( FmFormView & _rCurrentView , sal_Bool _bSyncAction /* = sal_False */ )
2002-09-09 13:27:00 +00:00
{
2008-08-28 05:55:02 +00:00
OSL_TRACE ( " --- FmXFormShell::viewActivated : %p, %p, ........ \n " , this , & _rCurrentView ) ;
FmFormPage * pPage = _rCurrentView . GetCurPage ( ) ;
2008-05-05 14:45:47 +00:00
2002-09-09 13:27:00 +00:00
// activate our view if we are activated ourself
// FS - 30.06.99 - 67308
2008-08-28 05:55:02 +00:00
if ( _rCurrentView . GetImpl ( ) & & ! _rCurrentView . IsDesignMode ( ) )
2002-09-09 13:27:00 +00:00
{
// load forms for the page the current view belongs to
if ( pPage )
{
if ( ! pPage - > GetImpl ( ) - > hasEverBeenActivated ( ) )
loadForms ( pPage , FORMS_LOAD | ( _bSyncAction ? FORMS_SYNC : FORMS_ASYNC ) ) ;
pPage - > GetImpl ( ) - > setHasBeenActivated ( ) ;
}
// first-time initializations for the views
2008-08-28 05:55:02 +00:00
if ( ! _rCurrentView . GetImpl ( ) - > hasEverBeenActivated ( ) )
2002-09-09 13:27:00 +00:00
{
2008-08-28 05:55:02 +00:00
_rCurrentView . GetImpl ( ) - > onFirstViewActivation ( PTR_CAST ( FmFormModel , _rCurrentView . GetModel ( ) ) ) ;
_rCurrentView . GetImpl ( ) - > setHasBeenActivated ( ) ;
2002-09-09 13:27:00 +00:00
}
// activate the current view
2008-08-28 05:55:02 +00:00
_rCurrentView . GetImpl ( ) - > Activate ( _bSyncAction ) ;
2002-09-09 13:27:00 +00:00
}
2005-03-10 15:23:52 +00:00
2008-05-05 14:45:47 +00:00
// set callbacks at the page
if ( pPage & & pPage - > GetImpl ( ) )
{
2008-08-28 05:55:02 +00:00
OSL_TRACE ( " --- FmXFormShell::setHandler : %p, ........, %p \n " , this , pPage ) ;
2008-05-05 14:45:47 +00:00
pPage - > GetImpl ( ) - > SetFormsCreationHdl ( LINK ( this , FmXFormShell , OnFormsCreated ) ) ;
}
2008-08-28 05:55:02 +00:00
2008-05-05 14:45:47 +00:00
UpdateForms ( sal_True ) ;
2005-03-10 15:23:52 +00:00
if ( ! hasEverBeenActivated ( ) )
{
m_nActivationEvent = Application : : PostUserEvent ( LINK ( this , FmXFormShell , OnFirstTimeActivation ) ) ;
setHasBeenActivated ( ) ;
}
2008-06-06 12:51:05 +00:00
// find a default "current form", if there is none, yet
// #i88186# / 2008-04-12 / frank.schoenheit@sun.com
impl_defaultCurrentForm_nothrow ( ) ;
}
//------------------------------------------------------------------------------
void FmXFormShell : : impl_defaultCurrentForm_nothrow ( )
{
2008-08-28 05:55:02 +00:00
if ( impl_checkDisposed ( ) )
return ;
2008-06-06 12:51:05 +00:00
if ( m_xCurrentForm . is ( ) )
// no action required
return ;
FmFormView * pFormView = m_pShell - > GetFormView ( ) ;
2008-08-28 05:55:02 +00:00
FmFormPage * pPage = pFormView ? pFormView - > GetCurPage ( ) : NULL ;
if ( ! pPage )
return ;
2008-06-06 12:51:05 +00:00
try
{
Reference < XIndexAccess > xForms ( pPage - > GetForms ( false ) , UNO_QUERY ) ;
if ( ! xForms . is ( ) | | ! xForms - > hasElements ( ) )
return ;
Reference < XForm > xNewCurrentForm ( xForms - > getByIndex ( 0 ) , UNO_QUERY_THROW ) ;
impl_updateCurrentForm ( xNewCurrentForm ) ;
}
catch ( const Exception & )
{
DBG_UNHANDLED_EXCEPTION ( ) ;
}
2002-09-09 13:27:00 +00:00
}
//------------------------------------------------------------------------------
void FmXFormShell : : smartControlReset ( const Reference < XIndexAccess > & _rxModels )
{
if ( ! _rxModels . is ( ) )
{
DBG_ERROR ( " FmXFormShell::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 ( ) ;
2003-10-21 07:44:09 +00:00
// reset only if it's *not* bound
bool bReset = ! xBoundField . is ( ) ;
// and additionally, check if it has an external value binding
Reference < XBindableValue > xBindable ( xCurrent , UNO_QUERY ) ;
if ( xBindable . is ( ) & & xBindable - > getValueBinding ( ) . is ( ) )
bReset = false ;
if ( bReset )
{
Reference < XReset > xControlReset ( xCurrent , UNO_QUERY ) ;
if ( xControlReset . is ( ) )
2002-09-09 13:27:00 +00:00
xControlReset - > reset ( ) ;
}
}
else
{
Reference < XIndexAccess > xContainer ( xCurrent , UNO_QUERY ) ;
if ( xContainer . is ( ) )
smartControlReset ( xContainer ) ;
}
}
}
//------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
IMPL_LINK ( FmXFormShell , OnLoadForms , FmFormPage * , /*_pPage*/ )
2002-09-09 13:27:00 +00:00
{
FmLoadAction aAction = m_aLoadingPages . front ( ) ;
m_aLoadingPages . pop ( ) ;
loadForms ( aAction . pPage , aAction . nFlags & ~ FORMS_ASYNC ) ;
return 0L ;
}
//------------------------------------------------------------------------
void FmXFormShell : : loadForms ( FmFormPage * _pPage , const sal_uInt16 _nBehaviour /* FORMS_LOAD | FORMS_SYNC */ )
{
DBG_ASSERT ( ( _nBehaviour & ( FORMS_ASYNC | FORMS_UNLOAD ) ) ! = ( FORMS_ASYNC | FORMS_UNLOAD ) ,
" FmXFormShell::loadForms: async loading not supported - this will heavily fail! " ) ;
if ( _nBehaviour & FORMS_ASYNC )
{
m_aLoadingPages . push ( FmLoadAction (
_pPage ,
_nBehaviour ,
Application : : PostUserEvent ( LINK ( this , FmXFormShell , OnLoadForms ) , _pPage )
) ) ;
return ;
}
DBG_ASSERT ( _pPage , " FmXFormShell::loadForms: invalid page! " ) ;
if ( _pPage )
{
// lock the undo env so the forms can change non-transient properties while loading
// (without this my doc's modified flag would be set)
FmFormModel * pModel = PTR_CAST ( FmFormModel , _pPage - > GetModel ( ) ) ;
DBG_ASSERT ( pModel , " FmXFormShell::loadForms: invalid model! " ) ;
if ( pModel )
pModel - > GetUndoEnv ( ) . Lock ( ) ;
// load all forms
Reference < XIndexAccess > xForms ;
2005-03-18 17:43:13 +00:00
xForms = xForms . query ( _pPage - > GetForms ( false ) ) ;
2002-09-09 13:27:00 +00:00
if ( xForms . is ( ) )
{
Reference < XLoadable > xForm ;
2004-03-19 11:20:43 +00:00
sal_Bool bFormWasLoaded = sal_False ;
2002-09-09 13:27:00 +00:00
for ( sal_Int32 j = 0 , nCount = xForms - > getCount ( ) ; j < nCount ; + + j )
{
xForms - > getByIndex ( j ) > > = xForm ;
2004-03-19 11:20:43 +00:00
bFormWasLoaded = sal_False ;
2002-09-09 13:27:00 +00:00
// a database form must be loaded for
2007-11-21 14:23:26 +00:00
try
2002-09-09 13:27:00 +00:00
{
2007-11-21 14:23:26 +00:00
if ( 0 = = ( _nBehaviour & FORMS_UNLOAD ) )
2004-03-19 11:20:43 +00:00
{
2007-11-21 14:23:26 +00:00
if ( : : isLoadable ( xForm ) & & ! xForm - > isLoaded ( ) )
xForm - > load ( ) ;
2004-03-19 11:20:43 +00:00
}
2007-11-21 14:23:26 +00:00
else
{
if ( xForm - > isLoaded ( ) )
{
bFormWasLoaded = sal_True ;
xForm - > unload ( ) ;
}
}
}
catch ( const Exception & )
{
DBG_UNHANDLED_EXCEPTION ( ) ;
2003-10-21 07:44:09 +00:00
}
2002-09-09 13:27:00 +00:00
2004-03-19 11:20:43 +00:00
// reset the form if it was loaded
if ( bFormWasLoaded )
2003-10-21 07:44:09 +00:00
{
Reference < XIndexAccess > xContainer ( xForm , UNO_QUERY ) ;
DBG_ASSERT ( xContainer . is ( ) , " FmXFormShell::loadForms: the form is no container! " ) ;
if ( xContainer . is ( ) )
smartControlReset ( xContainer ) ;
2002-09-09 13:27:00 +00:00
}
}
}
if ( pModel )
// unlock the environment
pModel - > GetUndoEnv ( ) . UnLock ( ) ;
}
}
2004-05-07 14:47:38 +00:00
//------------------------------------------------------------------------
void FmXFormShell : : ExecuteTextAttribute ( SfxRequest & _rReq )
{
m_pTextShell - > ExecuteTextAttribute ( _rReq ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : GetTextAttributeState ( SfxItemSet & _rSet )
{
m_pTextShell - > GetTextAttributeState ( _rSet ) ;
}
//------------------------------------------------------------------------
bool FmXFormShell : : IsActiveControl ( bool _bCountRichTextOnly ) const
{
return m_pTextShell - > IsActiveControl ( _bCountRichTextOnly ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : ForgetActiveControl ( )
{
m_pTextShell - > ForgetActiveControl ( ) ;
}
//------------------------------------------------------------------------
void FmXFormShell : : SetControlActivationHandler ( const Link & _rHdl )
{
m_pTextShell - > SetControlActivationHandler ( _rHdl ) ;
}
2004-09-09 09:22:22 +00:00
//------------------------------------------------------------------------
void FmXFormShell : : handleShowPropertiesRequest ( )
{
2004-11-16 10:24:36 +00:00
if ( onlyControlsAreMarked ( ) )
ShowSelectionProperties ( sal_True ) ;
2004-09-09 09:22:22 +00:00
}
//------------------------------------------------------------------------
void FmXFormShell : : handleMouseButtonDown ( const SdrViewEvent & _rViewEvent )
{
// catch simple double clicks
if ( ( _rViewEvent . nMouseClicks = = 2 ) & & ( _rViewEvent . nMouseCode = = MOUSE_LEFT ) )
{
if ( _rViewEvent . eHit = = SDRHIT_MARKEDOBJECT )
{
2004-11-16 10:24:36 +00:00
if ( onlyControlsAreMarked ( ) )
ShowSelectionProperties ( sal_True ) ;
2004-09-09 09:22:22 +00:00
}
}
}
2000-09-18 16:07:07 +00:00
//==============================================================================
//==============================================================================
2000-11-24 06:01:26 +00:00
SearchableControlIterator : : SearchableControlIterator ( Reference < XInterface > xStartingPoint )
2000-09-18 16:07:07 +00:00
: IndexAccessIterator ( xStartingPoint )
{
}
//------------------------------------------------------------------------------
2000-11-24 06:01:26 +00:00
sal_Bool SearchableControlIterator : : ShouldHandleElement ( const Reference < XInterface > & xElement )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
// wenn das Ding eine ControlSource und einen BoundField-Property hat
Reference < XPropertySet > xProperties ( xElement , UNO_QUERY ) ;
2000-10-20 13:18:57 +00:00
if ( : : comphelper : : hasProperty ( FM_PROP_CONTROLSOURCE , xProperties ) & & : : comphelper : : hasProperty ( FM_PROP_BOUNDFIELD , xProperties ) )
2000-09-18 16:07:07 +00:00
{
// und das BoundField gueltig ist
2000-11-24 06:01:26 +00:00
Reference < XPropertySet > xField ;
2000-11-07 12:16:50 +00:00
xProperties - > getPropertyValue ( FM_PROP_BOUNDFIELD ) > > = xField ;
2000-09-18 16:07:07 +00:00
if ( xField . is ( ) )
{
// nehmen wir's
2000-10-20 13:18:57 +00:00
m_sCurrentValue = : : comphelper : : getString ( xProperties - > getPropertyValue ( FM_PROP_CONTROLSOURCE ) ) ;
2000-09-18 16:07:07 +00:00
return sal_True ;
}
}
// wenn es ein Grid-Control ist
2000-10-20 13:18:57 +00:00
if ( : : comphelper : : hasProperty ( FM_PROP_CLASSID , xProperties ) )
2000-09-18 16:07:07 +00:00
{
2000-11-24 06:01:26 +00:00
Any aClassId ( xProperties - > getPropertyValue ( FM_PROP_CLASSID ) ) ;
if ( : : comphelper : : getINT16 ( aClassId ) = = FormComponentType : : GRIDCONTROL )
2000-09-18 16:07:07 +00:00
{
m_sCurrentValue = : : rtl : : OUString ( ) ;
return sal_True ;
}
}
return sal_False ;
}
//------------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
sal_Bool SearchableControlIterator : : ShouldStepInto ( const Reference < XInterface > & /*xContainer*/ ) const
2000-09-18 16:07:07 +00:00
{
return sal_True ;
}
//==============================================================================
//==============================================================================
2004-02-25 15:06:46 +00:00
2000-09-18 16:07:07 +00:00
SV_IMPL_PTRARR ( StatusForwarderArray , SfxStatusForwarder * )
SFX_IMPL_MENU_CONTROL ( ControlConversionMenuController , SfxBoolItem ) ;
//------------------------------------------------------------------------------
2006-06-19 14:57:11 +00:00
ControlConversionMenuController : : ControlConversionMenuController ( sal_uInt16 _nId , Menu & _rMenu , SfxBindings & _rBindings )
: SfxMenuControl ( _nId , _rBindings )
, m_pMainMenu ( & _rMenu )
, m_pConversionMenu ( NULL )
2000-09-18 16:07:07 +00:00
{
2006-06-19 14:57:11 +00:00
if ( _nId = = SID_FM_CHANGECONTROLTYPE )
2000-09-18 16:07:07 +00:00
{
m_pConversionMenu = FmXFormShell : : GetConversionMenu ( ) ;
2006-06-19 14:57:11 +00:00
_rMenu . SetPopupMenu ( _nId , m_pConversionMenu ) ;
2000-09-18 16:07:07 +00:00
for ( sal_Int16 i = 0 ; i < m_pConversionMenu - > GetItemCount ( ) ; + + i )
{
2006-06-19 14:57:11 +00:00
_rBindings . Invalidate ( m_pConversionMenu - > GetItemId ( i ) ) ;
2000-09-18 16:07:07 +00:00
SfxStatusForwarder * pForwarder = new SfxStatusForwarder ( m_pConversionMenu - > GetItemId ( i ) , * this ) ;
m_aStatusForwarders . C40_INSERT ( SfxStatusForwarder , pForwarder , m_aStatusForwarders . Count ( ) ) ;
}
}
}
//------------------------------------------------------------------------------
ControlConversionMenuController : : ~ ControlConversionMenuController ( )
{
m_pMainMenu - > SetPopupMenu ( SID_FM_CHANGECONTROLTYPE , NULL ) ;
delete m_pConversionMenu ;
}
//------------------------------------------------------------------------------
void ControlConversionMenuController : : StateChanged ( sal_uInt16 nSID , SfxItemState eState , const SfxPoolItem * pState )
{
if ( nSID = = GetId ( ) )
SfxMenuControl : : StateChanged ( nSID , eState , pState ) ;
2004-11-16 10:24:36 +00:00
else if ( FmXFormShell : : isControlConversionSlot ( nSID ) )
2000-09-18 16:07:07 +00:00
{
if ( ( m_pConversionMenu - > GetItemPos ( nSID ) ! = MENU_ITEM_NOTFOUND ) & & ( eState = = SFX_ITEM_DISABLED ) )
{
m_pConversionMenu - > RemoveItem ( m_pConversionMenu - > GetItemPos ( nSID ) ) ;
}
else if ( ( m_pConversionMenu - > GetItemPos ( nSID ) = = MENU_ITEM_NOTFOUND ) & & ( eState ! = SFX_ITEM_DISABLED ) )
{
// We can't simply re-insert the item because we have a clear order for all the our items.
// So first we have to determine the position of the item to insert.
PopupMenu * pSource = FmXFormShell : : GetConversionMenu ( ) ;
2006-06-19 14:57:11 +00:00
USHORT nSourcePos = pSource - > GetItemPos ( nSID ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( nSourcePos ! = MENU_ITEM_NOTFOUND , " ControlConversionMenuController::StateChanged : FmXFormShell supplied an invalid menu ! " ) ;
2006-06-19 14:57:11 +00:00
USHORT nPrevInSource = nSourcePos ;
USHORT nPrevInConversion = MENU_ITEM_NOTFOUND ;
2000-09-18 16:07:07 +00:00
while ( nPrevInSource > 0 )
{
sal_Int16 nPrevId = pSource - > GetItemId ( - - nPrevInSource ) ;
// do we have the source's predecessor in our conversion menu, too ?
nPrevInConversion = m_pConversionMenu - > GetItemPos ( nPrevId ) ;
if ( nPrevInConversion ! = MENU_ITEM_NOTFOUND )
break ;
}
if ( MENU_ITEM_NOTFOUND = = nPrevInConversion )
// none of the items which precede the nSID-slot in the source menu are present in our conversion menu
2006-10-12 11:46:14 +00:00
nPrevInConversion = sal : : static_int_cast < USHORT > ( - 1 ) ; // put the item at the first position
2000-09-18 16:07:07 +00:00
m_pConversionMenu - > InsertItem ( nSID , pSource - > GetItemText ( nSID ) , pSource - > GetItemBits ( nSID ) , + + nPrevInConversion ) ;
m_pConversionMenu - > SetItemImage ( nSID , pSource - > GetItemImage ( nSID ) ) ;
m_pConversionMenu - > SetHelpId ( nSID , pSource - > GetHelpId ( nSID ) ) ;
delete pSource ;
}
m_pMainMenu - > EnableItem ( SID_FM_CHANGECONTROLTYPE , m_pConversionMenu - > GetItemCount ( ) > 0 ) ;
}
else
{
DBG_ERROR ( " ControlConversionMenuController::StateChanged : unknown id ! " ) ;
}
}
//==================================================================
2004-04-13 09:59:06 +00:00
FmCursorActionThread : : FmCursorActionThread ( const Reference < XResultSet > & _xDataSource , const UniString & _rStopperCaption )
2000-09-18 16:07:07 +00:00
: m_xDataSource ( _xDataSource )
, m_sStopperCaption ( _rStopperCaption )
, m_bCanceled ( sal_False )
, m_bDeleteMyself ( sal_False )
, m_bDisposeCursor ( sal_False )
, m_bTerminated ( sal_False )
, m_bRunFailed ( sal_False )
{
2000-11-24 06:01:26 +00:00
DBG_ASSERT ( m_xDataSource . is ( ) & & Reference < XCancellable > ( m_xDataSource , UNO_QUERY ) . is ( ) ,
2000-09-18 16:07:07 +00:00
" FmCursorActionThread::FmCursorActionThread : invalid cursor ! " ) ;
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : run ( )
{
// On instantiation of a SfxCancellable the application is notified and 'switches on' the red stop button.
// Unfortunally this is conditioned with the acquirement of the solar mutex, and the application tries
// only once and ignores the notification if it fails.
// To prevent that we get the solar mutex and _block_ 'til we got it.
// As we are in the 'top level execution' of this thread (with a rather small stack and no other mutexes locked)
// we shouldn't experience problems with deadlocks ...
: : vos : : OClearableGuard aSolarGuard ( Application : : GetSolarMutex ( ) ) ;
ThreadStopper * pStopper = new ThreadStopper ( this , m_sStopperCaption ) ;
aSolarGuard . clear ( ) ;
// we're not canceled yet
: : osl : : ClearableMutexGuard aInitGuard ( m_aAccessSafety ) ;
m_bCanceled = sal_False ;
m_bRunFailed = sal_False ;
aInitGuard . clear ( ) ;
// start it
try
{
RunImpl ( ) ;
}
2000-11-24 06:01:26 +00:00
catch ( SQLException e )
2000-09-18 16:07:07 +00:00
{
: : osl : : MutexGuard aErrorGuard ( m_aAccessSafety ) ;
m_bRunFailed = sal_True ;
m_aRunException = e ;
}
2000-11-24 06:01:26 +00:00
catch ( Exception & )
2000-09-18 16:07:07 +00:00
{
DBG_ERROR ( " FmCursorActionThread::run : catched a non-database exception ! " ) ;
}
sal_Bool bReallyCanceled ;
: : osl : : ClearableMutexGuard aEvalGuard ( m_aAccessSafety ) ;
bReallyCanceled = m_bCanceled ;
aEvalGuard . clear ( ) ;
pStopper - > OwnerTerminated ( ) ;
// this will cause the stopper to delete itself (in the main thread) so we don't have to care of the
// solar mutex
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : onTerminated ( )
{
: : osl : : ClearableMutexGuard aResetGuard ( m_aAccessSafety ) ;
if ( m_aTerminationHandler . IsSet ( ) )
m_aTerminationHandler . Call ( this ) ;
if ( IsCursorDisposeEnabled ( ) )
{
2000-11-24 06:01:26 +00:00
Reference < : : com : : sun : : star : : lang : : XComponent > xDataSourceComponent ( m_xDataSource , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
if ( xDataSourceComponent . is ( ) )
xDataSourceComponent - > dispose ( ) ;
}
aResetGuard . clear ( ) ;
// with this StopItWait has a chance to do it's Terminated()
: : osl : : MutexGuard aGuard ( m_aFinalExitControl ) ;
// Terminated() in StopItWait still returns sal_False
m_bTerminated = sal_True ;
// Terminated() now returns sal_True, but StopItWait can't exit until this method exits (because of the guarded m_aFinalExitControl)
if ( IsSelfDeleteEnabled ( ) )
delete this ;
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : StopIt ( )
{
: : osl : : MutexGuard aGuard ( m_aAccessSafety ) ;
m_bCanceled = sal_True ;
2000-11-24 06:01:26 +00:00
Reference < XCancellable > xCancel ( m_xDataSource , UNO_QUERY ) ;
2000-09-18 16:07:07 +00:00
DBG_ASSERT ( xCancel . is ( ) , " FmCursorActionThread::StopIt : invalid cursor ! " ) ;
xCancel - > cancel ( ) ;
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : StopItWait ( )
{
StopIt ( ) ;
while ( ! Terminated ( ) )
;
// OnTerminated has been called, but we can't simply exit : Suppose the caller want's to delete the thread object
// immediately after returning from StopItWait. With the following guard we ensure that we exit this method
// only after onTerminated has exited.
: : osl : : ClearableMutexGuard aGuard ( m_aFinalExitControl ) ;
// now onTerminated has exited, so we can leave, too
}
//------------------------------------------------------------------------------
FmCursorActionThread : : ThreadStopper : : ThreadStopper ( FmCursorActionThread * pOwner , const UniString & rTitle )
: SfxCancellable ( SFX_APP ( ) - > GetCancelManager ( ) , rTitle )
, m_pOwner ( pOwner )
{
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : ThreadStopper : : Cancel ( )
{
if ( ! m_pOwner ) // the owner is already terminated and we're waiting for the OnDeleteInMainThread event
return ;
: : osl : : MutexGuard aGuard ( m_pOwner - > m_aAccessSafety ) ;
if ( IsCancelled ( ) )
// we already did pass this to our owner
return ;
SfxCancellable : : Cancel ( ) ;
m_pOwner - > StopIt ( ) ;
}
//------------------------------------------------------------------------------
void FmCursorActionThread : : ThreadStopper : : OwnerTerminated ( )
{
m_pOwner = NULL ;
Application : : PostUserEvent ( LINK ( this , FmCursorActionThread : : ThreadStopper , OnDeleteInMainThread ) , this ) ;
}
//------------------------------------------------------------------------------
IMPL_LINK ( FmCursorActionThread : : ThreadStopper , OnDeleteInMainThread , FmCursorActionThread : : ThreadStopper * , pThis )
{
delete pThis ;
return 0L ;
}
//==============================================================================