summaryrefslogtreecommitdiff
path: root/svx/source/form
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/form')
-rw-r--r--svx/source/form/delayedevent.cxx71
-rw-r--r--svx/source/form/fmctrler.cxx645
-rw-r--r--svx/source/form/fmexpl.cxx3
-rw-r--r--svx/source/form/fmmodel.cxx11
-rw-r--r--svx/source/form/fmobj.cxx229
-rw-r--r--svx/source/form/fmpage.cxx121
-rw-r--r--svx/source/form/fmpgeimp.cxx164
-rw-r--r--svx/source/form/fmprop.cxx1
-rw-r--r--svx/source/form/fmshell.cxx95
-rw-r--r--svx/source/form/fmshimp.cxx347
-rw-r--r--svx/source/form/fmtextcontrolshell.cxx95
-rw-r--r--svx/source/form/fmtools.cxx81
-rw-r--r--svx/source/form/fmundo.cxx71
-rw-r--r--svx/source/form/fmview.cxx139
-rw-r--r--svx/source/form/fmvwimp.cxx837
-rw-r--r--svx/source/form/formcontrolfactory.cxx738
-rw-r--r--svx/source/form/makefile.mk6
-rw-r--r--svx/source/form/navigatortree.cxx89
-rw-r--r--svx/source/form/navigatortreemodel.cxx126
19 files changed, 2180 insertions, 1689 deletions
diff --git a/svx/source/form/delayedevent.cxx b/svx/source/form/delayedevent.cxx
new file mode 100644
index 000000000000..c6bce8efec98
--- /dev/null
+++ b/svx/source/form/delayedevent.cxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: delayedevent.cxx,v $
+*
+* $Revision: 1.1.2.1 $
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "delayedevent.hxx"
+
+#include <osl/diagnose.h>
+#include <vcl/svapp.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= DelayedEvent
+ //====================================================================
+ //--------------------------------------------------------------------
+ void DelayedEvent::Call( void* _pArg )
+ {
+ CancelPendingCall();
+ OSL_POSTCOND( m_nEventId == 0, "DelayedEvent::Call: CancelPendingCall did not work!" );
+
+ m_nEventId = Application::PostUserEvent( LINK( this, DelayedEvent, OnCall ), _pArg );
+ }
+
+ //--------------------------------------------------------------------
+ void DelayedEvent::CancelPendingCall()
+ {
+ if ( m_nEventId )
+ Application::RemoveUserEvent( m_nEventId );
+ m_nEventId = 0;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DelayedEvent, OnCall, void*, _pArg )
+ {
+ m_nEventId = 0;
+ return m_aHandler.Call( _pArg );
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/fmctrler.cxx
index f0e79b10bdb2..eea5570389b0 100644
--- a/svx/source/form/fmctrler.cxx
+++ b/svx/source/form/fmctrler.cxx
@@ -119,8 +119,225 @@ using namespace ::connectivity;
using namespace ::svxform;
using namespace ::connectivity::simple;
+//==============================================================================
+// ColumnInfo
+//==============================================================================
+struct ColumnInfo
+{
+ // information about the column itself
+ Reference< XColumn > xColumn;
+ sal_Int32 nNullable;
+ sal_Bool bAutoIncrement;
+ ::rtl::OUString sName;
+
+ // information about the control(s) bound to this column
+
+ /// the first control which is bound to the given column, and which requires input
+ Reference< XControl > xFirstControlWithInputRequired;
+ /** the first grid control which contains a column which is bound to the given database column, and requires
+ input
+ */
+ Reference< XGrid > xFirstGridWithInputRequiredColumn;
+ /** if xFirstControlWithInputRequired is a grid control, then nRequiredGridColumn specifies the position
+ of the grid column which is actually bound
+ */
+ sal_Int32 nRequiredGridColumn;
+
+ ColumnInfo()
+ :xColumn()
+ ,nNullable( ColumnValue::NULLABLE_UNKNOWN )
+ ,bAutoIncrement( sal_False )
+ ,sName()
+ ,xFirstControlWithInputRequired()
+ ,xFirstGridWithInputRequiredColumn()
+ ,nRequiredGridColumn( -1 )
+ {
+ }
+};
+
+//==============================================================================
+//= ColumnInfoCache
+//==============================================================================
+class ColumnInfoCache
+{
+public:
+ ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier );
+
+ const size_t getColumnCount() const { return m_aColumns.size(); }
+ const ColumnInfo& getColumnInfo( size_t _pos );
+
+ bool controlsInitialized() const { return m_bControlsInitialized; }
+ void initializeControls( const Sequence< Reference< XControl > >& _rControls );
+ void deinitializeControls();
+
+private:
+ typedef ::std::vector< ColumnInfo > ColumnInfos;
+ ColumnInfos m_aColumns;
+ bool m_bControlsInitialized;
+};
+
+//------------------------------------------------------------------------------
+ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier )
+ :m_aColumns()
+ ,m_bControlsInitialized( false )
+{
+ try
+ {
+ m_aColumns.clear();
+
+ Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW );
+ Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW );
+ sal_Int32 nColumnCount = xColumns->getCount();
+ m_aColumns.reserve( nColumnCount );
+
+ Reference< XPropertySet > xColumnProps;
+ for ( sal_Int32 i = 0; i < nColumnCount; ++i )
+ {
+ ColumnInfo aColInfo;
+ aColInfo.xColumn.set( xColumns->getByIndex(i), UNO_QUERY_THROW );
+
+ xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_AUTOINCREMENT ) >>= aColInfo.bAutoIncrement );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_NAME ) >>= aColInfo.sName );
+
+ m_aColumns.push_back( aColInfo );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ bool lcl_isBoundTo( const Reference< XPropertySet >& _rxControlModel, const Reference< XInterface >& _rxNormDBField )
+ {
+ Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY );
+ return ( xNormBoundField.get() == _rxNormDBField.get() );
+ }
+
+ bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel )
+ {
+ sal_Bool bInputRequired = sal_True;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired );
+ return ( bInputRequired != sal_False );
+ }
+ void lcl_resetColumnControlInfo( ColumnInfo& _rColInfo )
+ {
+ _rColInfo.xFirstControlWithInputRequired.clear();
+ _rColInfo.xFirstGridWithInputRequiredColumn.clear();
+ _rColInfo.nRequiredGridColumn = -1;
+ }
+}
+
+//------------------------------------------------------------------------------
+void ColumnInfoCache::deinitializeControls()
+{
+ for ( ColumnInfos::iterator col = m_aColumns.begin();
+ col != m_aColumns.end();
+ ++col
+ )
+ {
+ lcl_resetColumnControlInfo( *col );
+ }
+}
+
+//------------------------------------------------------------------------------
+void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls )
+{
+ try
+ {
+ // for every of our known columns, find the controls which are bound to this column
+ for ( ColumnInfos::iterator col = m_aColumns.begin();
+ col != m_aColumns.end();
+ ++col
+ )
+ {
+ OSL_ENSURE( !col->xFirstControlWithInputRequired.is() && !col->xFirstGridWithInputRequiredColumn.is()
+ && ( col->nRequiredGridColumn == -1 ), "ColumnInfoCache::initializeControls: called me twice?" );
+
+ lcl_resetColumnControlInfo( *col );
+
+ Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW );
+
+ const Reference< XControl >* pControl( _rControls.getConstArray() );
+ const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() );
+ for ( ; pControl != pControlEnd; ++pControl )
+ {
+ if ( !pControl->is() )
+ continue;
+
+ Reference< XPropertySet > xModel( (*pControl)->getModel(), UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ // special handling for grid controls
+ Reference< XGrid > xGrid( *pControl, UNO_QUERY );
+ if ( xGrid.is() )
+ {
+ Reference< XIndexAccess > xGridColAccess( xModel, UNO_QUERY_THROW );
+ sal_Int32 gridColCount = xGridColAccess->getCount();
+ sal_Int32 gridCol = 0;
+ for ( gridCol = 0; gridCol < gridColCount; ++gridCol )
+ {
+ Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW );
+
+ if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn )
+ || !lcl_isInputRequired( xGridColumnModel )
+ )
+ continue; // with next grid column
+
+ break;
+ }
+
+ if ( gridCol < gridColCount )
+ {
+ // found a grid column which is bound to the given
+ col->xFirstGridWithInputRequiredColumn = xGrid;
+ col->nRequiredGridColumn = gridCol;
+ break;
+ }
+
+ continue; // with next control
+ }
+
+ if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD )
+ || !lcl_isBoundTo( xModel, xNormColumn )
+ || !lcl_isInputRequired( xModel )
+ )
+ continue; // with next control
+
+ break;
+ }
+
+ if ( pControl == pControlEnd )
+ // did not find a control which is bound to this particular column, and for which the input is required
+ continue; // with next DB column
+
+ col->xFirstControlWithInputRequired = *pControl;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_bControlsInitialized = true;
+}
+
+//------------------------------------------------------------------------------
+const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos )
+{
+ if ( _pos >= m_aColumns.size() )
+ throw IndexOutOfBoundsException();
+
+ return m_aColumns[ _pos ];
+}
+
//==================================================================
-// FmXAutoControl
+// OParameterContinuation
//==================================================================
class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
{
@@ -258,8 +475,8 @@ DBG_NAME( FmXFormController )
//------------------------------------------------------------------
FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _rxORB,
FmFormView* _pView, Window* _pWindow )
- :FmXFormController_BASE1(m_aMutex)
- ,OPropertySetHelper(FmXFormController_BASE1::rBHelper)
+ :FmXFormController_BASE( m_aMutex )
+ ,OPropertySetHelper( FmXFormController_BASE::rBHelper )
,OSQLParserClient(_rxORB)
,m_xORB(_rxORB)
,m_aActivateListeners(m_aMutex)
@@ -273,8 +490,10 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _
,m_pControlBorderManager( new ::svxform::ControlBorderManager )
,m_aControllerFeatures( _rxORB, this )
,m_aMode(getDataModeIdentifier())
- ,m_nLoadEvent( 0 )
- ,m_nToggleEvent(0)
+ ,m_aLoadEvent( LINK( this, FmXFormController, OnLoad ) )
+ ,m_aToggleEvent( LINK( this, FmXFormController, OnToggleAutoFields ) )
+ ,m_aActivationEvent( LINK( this, FmXFormController, OnActivated ) )
+ ,m_aDeactivationEvent( LINK( this, FmXFormController, OnDeactivated ) )
,m_nCurrentFilterPosition(0)
,m_bCurrentRecordModified(sal_False)
,m_bCurrentRecordNew(sal_False)
@@ -321,11 +540,11 @@ FmXFormController::~FmXFormController()
{
{
::osl::MutexGuard aGuard( m_aMutex );
- if( m_nLoadEvent )
- Application::RemoveUserEvent( m_nLoadEvent );
- if ( m_nToggleEvent )
- Application::RemoveUserEvent( m_nToggleEvent );
+ m_aLoadEvent.CancelPendingCall();
+ m_aToggleEvent.CancelPendingCall();
+ m_aActivationEvent.CancelPendingCall();
+ m_aDeactivationEvent.CancelPendingCall();
if ( m_aTabActivationTimer.IsActive() )
m_aTabActivationTimer.Stop();
@@ -349,59 +568,62 @@ FmXFormController::~FmXFormController()
}
// -----------------------------------------------------------------------------
-using namespace ::cppu;
-using namespace ::osl;
-
void SAL_CALL FmXFormController::acquire() throw ()
{
- FmXFormController_BASE1::acquire();
+ FmXFormController_BASE::acquire();
}
+
// -----------------------------------------------------------------------------
void SAL_CALL FmXFormController::release() throw ()
{
- FmXFormController_BASE1::release();
+ FmXFormController_BASE::release();
}
-// -----------------------------------------------------------------------------
-// XUnoTunnel
-Sequence< sal_Int8 > FmXFormController::getUnoTunnelImplementationId()
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXFormController::queryInterface( const Type& _rType ) throw(RuntimeException)
{
- static OImplementationId * pId = 0;
- if (! pId)
+ Any aRet = FmXFormController_BASE::queryInterface( _rType );
+ if ( !aRet.hasValue() )
+ aRet = OPropertySetHelper::queryInterface( _rType );
+ if ( !aRet.hasValue() )
+ aRet = m_xAggregate->queryAggregation( _rType );
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( RuntimeException )
+{
+ static ::cppu::OImplementationId* pId = NULL;
+ if ( !pId )
{
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pId )
{
- static OImplementationId aId;
+ static ::cppu::OImplementationId aId;
pId = &aId;
}
}
return pId->getImplementationId();
}
+
//------------------------------------------------------------------------------
-FmXFormController* FmXFormController::getImplementation( const Reference< XInterface >& _rxComponent )
-{
- Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY );
- if ( xTunnel.is() )
- return reinterpret_cast< FmXFormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
- return NULL;
-}
-//------------------------------------------------------------------------------
-sal_Int64 SAL_CALL FmXFormController::getSomething(Sequence<sal_Int8> const& rId)throw( RuntimeException )
+Sequence< Type > SAL_CALL FmXFormController::getTypes( ) throw(RuntimeException)
{
- if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
- return reinterpret_cast< sal_Int64 >( this );
-
- return sal_Int64();
+ return comphelper::concatSequences(
+ FmXFormController_BASE::getTypes(),
+ ::cppu::OPropertySetHelper::getTypes()
+ );
}
-//------------------------------------------------------------------------------
-Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( RuntimeException )
+// -----------------------------------------------------------------------------
+// XUnoTunnel
+Sequence< sal_Int8 > FmXFormController::getUnoTunnelImplementationId()
{
- static ::cppu::OImplementationId* pId = 0;
- if (! pId)
+ static ::cppu::OImplementationId * pId = NULL;
+ if ( !pId )
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if (! pId)
+ if ( !pId )
{
static ::cppu::OImplementationId aId;
pId = &aId;
@@ -409,29 +631,21 @@ Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( Ru
}
return pId->getImplementationId();
}
-
//------------------------------------------------------------------------------
-Sequence< Type > SAL_CALL FmXFormController::getTypes( ) throw(RuntimeException)
+FmXFormController* FmXFormController::getImplementation( const Reference< XInterface >& _rxComponent )
{
- return comphelper::concatSequences(FmXFormController_BASE1::getTypes(),FmXFormController_BASE2::getTypes(),FmXFormController_BASE3::getTypes());
+ Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY );
+ if ( xTunnel.is() )
+ return reinterpret_cast< FmXFormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
+ return NULL;
}
-//------------------------------------------------------------------
-Any SAL_CALL FmXFormController::queryAggregation( const Type& _rType ) throw(RuntimeException)
+//------------------------------------------------------------------------------
+sal_Int64 SAL_CALL FmXFormController::getSomething(Sequence<sal_Int8> const& rId)throw( RuntimeException )
{
- Any aRet = FmXFormController_BASE1::queryAggregation(_rType);
- if(!aRet.hasValue())
- {
- aRet = OPropertySetHelper::queryInterface(_rType);
- if(!aRet.hasValue())
- {
- aRet = FmXFormController_BASE2::queryInterface(_rType);
- if(!aRet.hasValue())
- aRet = FmXFormController_BASE3::queryInterface(_rType);
- }
- }
- if(aRet.hasValue())
- return aRet;
- return m_xAggregate->queryAggregation(_rType);
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast< sal_Int64 >( this );
+
+ return sal_Int64();
}
// XServiceInfo
@@ -840,7 +1054,7 @@ namespace
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if ( evt.PropertyName == FM_PROP_BOUNDFIELD )
{
Reference<XPropertySet> xOldBound;
@@ -881,13 +1095,8 @@ void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt)
stopListening();
}
- if (bNewChanged)
- {
- if (m_nToggleEvent)
- Application::RemoveUserEvent( m_nToggleEvent );
- m_nToggleEvent = Application::PostUserEvent( LINK(this, FmXFormController,
- OnToggleAutoFields) );
- }
+ if ( bNewChanged )
+ m_aToggleEvent.Call();
if (!m_bCurrentRecordModified)
m_bModified = sal_False;
@@ -973,7 +1182,7 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent
//------------------------------------------------------------------------------
void FmXFormController::toggleAutoFields(sal_Bool bAutoFields)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Sequence< Reference< XControl > > aControlsCopy( m_aControls );
@@ -1046,11 +1255,8 @@ void FmXFormController::toggleAutoFields(sal_Bool bAutoFields)
//------------------------------------------------------------------------------
IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG)
{
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
- m_nToggleEvent = 0;
- }
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
+
toggleAutoFields(m_bCurrentRecordNew);
return 1L;
}
@@ -1059,7 +1265,7 @@ IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG)
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if (m_bFiltering)
{
Reference< XTextComponent > xText(e.Source,UNO_QUERY);
@@ -1094,7 +1300,7 @@ void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeE
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::itemStateChanged(const ItemEvent& rEvent) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if (!m_bModified)
onModify( rEvent.Source );
}
@@ -1103,14 +1309,14 @@ void SAL_CALL FmXFormController::itemStateChanged(const ItemEvent& rEvent) throw
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aModifyListeners.addInterface( l );
}
//------------------------------------------------------------------------------
void FmXFormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aModifyListeners.removeInterface( l );
}
@@ -1118,7 +1324,7 @@ void FmXFormController::removeModifyListener(const Reference< XModifyListener >
//------------------------------------------------------------------------------
void FmXFormController::modified(const EventObject& rEvent) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if (!m_bModified)
onModify( rEvent.Source );
}
@@ -1126,7 +1332,7 @@ void FmXFormController::modified(const EventObject& rEvent) throw( RuntimeExcept
//------------------------------------------------------------------------------
void FmXFormController::onModify( const Reference< XInterface >& _rxControl )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if (!m_bModified)
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -1152,7 +1358,7 @@ void FmXFormController::onModify( const Reference< XInterface >& _rxControl )
//------------------------------------------------------------------------------
sal_Bool FmXFormController::determineLockState() const
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
// a.) in filter mode we are always locked
// b.) if we have no valid model or our model (a result set) is not alive -> we're locked
// c.) if we are inserting everything is OK and we are not locked
@@ -1171,7 +1377,7 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException
{
TRACE_RANGE( "FmXFormController::focusGained" );
- OSL_ENSURE( !FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController::focusGained: Object already disposed!" );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
Reference< XControl > xControl(e.Source, UNO_QUERY);
@@ -1192,10 +1398,13 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException
// c.) and it must be different from the new focus owning control or
// d.) the focus is moving around (so we have only one control)
- if ((m_bModified || m_bFiltering) &&
- m_xCurrentControl.is() &&
- ((xControl.get() != m_xCurrentControl.get()) ||
- ((e.FocusFlags & FocusChangeReason::AROUND) && (m_bCycle || m_bFiltering)))
+ if ( ( m_bModified || m_bFiltering )
+ && m_xCurrentControl.is()
+ && ( ( xControl.get() != m_xCurrentControl.get() )
+ || ( ( e.FocusFlags & FocusChangeReason::AROUND )
+ && ( m_bCycle || m_bFiltering )
+ )
+ )
)
{
// check the old control if the content is ok
@@ -1259,12 +1468,19 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException
sal_Bool bActivated = !m_xActiveControl.is() && xControl.is();
m_xActiveControl = xControl;
+
implSetCurrentControl( xControl );
+ OSL_POSTCOND( m_xCurrentControl.is(), "implSetCurrentControl did nonsense!" );
- DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert");
+ if ( bActivated )
+ {
+ // (asynchronously) call activation handlers
+ m_aActivationEvent.Call();
- if (bActivated)
- onActivate();
+ // call modify listeners
+ if ( m_bModified )
+ m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) );
+ }
// invalidate all features which depend on the currently focused control
if ( m_bDBConnection && !m_bFiltering && m_pView )
@@ -1285,23 +1501,29 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException
}
//------------------------------------------------------------------------------
-void FmXFormController::onActivate()
+IMPL_LINK( FmXFormController, OnActivated, void*, /**/ )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
- // benachrichtigen, dass form activiert
- EventObject aEvt;
- aEvt.Source = *this;
- m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvt );
+ EventObject aEvent;
+ aEvent.Source = *this;
+ m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvent );
- // verschicken ob modified
- if (m_bModified)
- m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FmXFormController, OnDeactivated, void*, /**/ )
+{
+ EventObject aEvent;
+ aEvent.Source = *this;
+ m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvent );
+
+ return 0L;
}
//------------------------------------------------------------------------------
void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException )
{
- OSL_ENSURE( !FmXFormController_BASE1::rBHelper.bDisposed, "FmXFormController::focusLost: Object already disposed!" );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_pControlBorderManager->focusLost( e.Source );
@@ -1311,9 +1533,7 @@ void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException )
if (!xNextControl.is())
{
m_xActiveControl = NULL;
- EventObject aEvt;
- aEvt.Source = *this;
- m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt );
+ m_aDeactivationEvent.Call();
}
}
@@ -1356,7 +1576,7 @@ void SAL_CALL FmXFormController::componentValidityChanged( const EventObject& _r
//--------------------------------------------------------------------
void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::setModel : invalid aggregate !");
@@ -1461,7 +1681,7 @@ void FmXFormController::setModel(const Reference< XTabControllerModel > & Model)
//------------------------------------------------------------------------------
Reference< XTabControllerModel > FmXFormController::getModel() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::getModel : invalid aggregate !");
if (!m_xTabController.is())
return Reference< XTabControllerModel > ();
@@ -1471,7 +1691,7 @@ Reference< XTabControllerModel > FmXFormController::getModel() throw( RuntimeEx
//------------------------------------------------------------------------------
void FmXFormController::addToEventAttacher(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
OSL_ENSURE( xControl.is(), "FmXFormController::addToEventAttacher: invalid control - how did you reach this?" );
if ( !xControl.is() )
return; /* throw IllegalArgumentException(); */
@@ -1499,7 +1719,7 @@ void FmXFormController::addToEventAttacher(const Reference< XControl > & xContro
//------------------------------------------------------------------------------
void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
OSL_ENSURE( xControl.is(), "FmXFormController::removeFromEventAttacher: invalid control - how did you reach this?" );
if ( !xControl.is() )
return; /* throw IllegalArgumentException(); */
@@ -1527,7 +1747,7 @@ void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xC
//------------------------------------------------------------------------------
void FmXFormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Reference< XTabControllerModel > xTabModel(getModel());
DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined");
// if we have a new container we need a model
@@ -1616,7 +1836,7 @@ void FmXFormController::setContainer(const Reference< XControlContainer > & xCon
Reference< XControlContainer > FmXFormController::getContainer() throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::getContainer : invalid aggregate !");
if (!m_xTabController.is())
return Reference< XControlContainer > ();
@@ -1626,7 +1846,7 @@ Reference< XControlContainer > FmXFormController::getContainer() throw( Runtime
//------------------------------------------------------------------------------
Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
if (!m_bControlsSorted)
{
@@ -1665,7 +1885,7 @@ Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( Ru
//------------------------------------------------------------------------------
void FmXFormController::autoTabOrder() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::autoTabOrder : invalid aggregate !");
if (m_xTabController.is())
@@ -1675,7 +1895,7 @@ void FmXFormController::autoTabOrder() throw( RuntimeException )
//------------------------------------------------------------------------------
void FmXFormController::activateTabOrder() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateTabOrder : invalid aggregate !");
if (m_xTabController.is())
@@ -1685,7 +1905,7 @@ void FmXFormController::activateTabOrder() throw( RuntimeException )
//------------------------------------------------------------------------------
void FmXFormController::setControlLock(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
sal_Bool bLocked = isLocked();
// es wird gelockt
@@ -1738,7 +1958,7 @@ void FmXFormController::setControlLock(const Reference< XControl > & xControl)
//------------------------------------------------------------------------------
void FmXFormController::setLocks()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
// alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken
const Reference< XControl >* pControls = m_aControls.getConstArray();
const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
@@ -1781,7 +2001,7 @@ namespace
//------------------------------------------------------------------------------
void FmXFormController::startControlModifyListening(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController::startControlModifyListening: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
bool bModifyListening = lcl_shouldListenForModifications( xControl, this );
@@ -1830,7 +2050,7 @@ void FmXFormController::startControlModifyListening(const Reference< XControl >
//------------------------------------------------------------------------------
void FmXFormController::stopControlModifyListening(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL );
@@ -1878,7 +2098,7 @@ void FmXFormController::stopControlModifyListening(const Reference< XControl > &
//------------------------------------------------------------------------------
void FmXFormController::startListening()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_bModified = sal_False;
// jetzt anmelden bei gebundenen feldern
@@ -1891,7 +2111,7 @@ void FmXFormController::startListening()
//------------------------------------------------------------------------------
void FmXFormController::stopListening()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_bModified = sal_False;
// jetzt anmelden bei gebundenen feldern
@@ -1905,7 +2125,7 @@ void FmXFormController::stopListening()
//------------------------------------------------------------------------------
Reference< XControl > FmXFormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" );
Reference< XControl >* pControls = _rControls.getArray();
@@ -2019,11 +2239,14 @@ void FmXFormController::implSetCurrentControl( const Reference< XControl >& _rxC
//------------------------------------------------------------------------------
void FmXFormController::insertControl(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_bControlsSorted = sal_False;
m_aControls.realloc(m_aControls.getLength() + 1);
m_aControls.getArray()[m_aControls.getLength() - 1] = xControl;
+ if ( m_pColumnInfoCache.get() )
+ m_pColumnInfoCache->deinitializeControls();
+
implControlInserted( xControl, m_bAttachEvents );
if (m_bDBConnection && !m_bFiltering)
@@ -2036,7 +2259,7 @@ void FmXFormController::insertControl(const Reference< XControl > & xControl)
//------------------------------------------------------------------------------
void FmXFormController::removeControl(const Reference< XControl > & xControl)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
const Reference< XControl >* pControls = m_aControls.getConstArray();
const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
while ( pControls != pControlsEnd )
@@ -2068,7 +2291,7 @@ void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeExceptio
{
OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FmXFormController::loaded: where did this come from?" );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY);
// do we have a connected data source
@@ -2092,10 +2315,7 @@ void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeExceptio
// set the locks for the current controls
if (getContainer().is())
{
- if (m_nLoadEvent)
- Application::RemoveUserEvent( m_nLoadEvent );
- m_nLoadEvent = Application::PostUserEvent( LINK(this, FmXFormController,
- OnLoad) );
+ m_aLoadEvent.Call();
}
}
else
@@ -2116,6 +2336,9 @@ void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeExceptio
m_bLocked = sal_False;
}
+ Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY );
+ m_pColumnInfoCache.reset( xFormColumns.is() ? new ColumnInfoCache( xFormColumns ) : NULL );
+
updateAllDispatchers();
}
@@ -2135,8 +2358,7 @@ void FmXFormController::updateAllDispatchers() const
//------------------------------------------------------------------------------
IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
- m_nLoadEvent = 0;
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_bLocked = determineLockState();
setLocks();
@@ -2154,49 +2376,42 @@ IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG)
//------------------------------------------------------------------------------
void FmXFormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
updateAllDispatchers();
}
//------------------------------------------------------------------------------
void FmXFormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
// do the same like in unloading
// just one exception toggle the auto values
- if (m_nToggleEvent)
- {
- Application::RemoveUserEvent( m_nToggleEvent );
- m_nToggleEvent = 0;
- }
+ m_aToggleEvent.CancelPendingCall();
unload();
}
//------------------------------------------------------------------------------
void FmXFormController::reloaded(const EventObject& aEvent) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
loaded(aEvent);
}
//------------------------------------------------------------------------------
void FmXFormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
unload();
}
//------------------------------------------------------------------------------
void FmXFormController::unload() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
- if (m_nLoadEvent)
- {
- Application::RemoveUserEvent( m_nLoadEvent );
- m_nLoadEvent = 0;
- }
+
+ m_aLoadEvent.CancelPendingCall();
// be sure not to have autofields
if (m_bCurrentRecordNew)
@@ -2215,6 +2430,8 @@ void FmXFormController::unload() throw( RuntimeException )
m_bDBConnection = sal_False;
m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked = sal_False;
+
+ m_pColumnInfoCache.reset( NULL );
}
// -----------------------------------------------------------------------------
@@ -2300,7 +2517,7 @@ void FmXFormController::stopFormListening( const Reference< XPropertySet >& _rxF
//------------------------------------------------------------------------------
void FmXFormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
// toggle the locking ?
if (m_bLocked != determineLockState())
{
@@ -2333,7 +2550,7 @@ void FmXFormController::rowSetChanged(const EventObject& /*event*/) throw( Runti
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Reference< XControl > xControl;
evt.Element >>= xControl;
if (!xControl.is())
@@ -2394,7 +2611,7 @@ void SAL_CALL FmXFormController::elementReplaced(const ContainerEvent& evt) thro
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
Reference< XControl > xControl;
@@ -2421,7 +2638,7 @@ void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw
//------------------------------------------------------------------------------
Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer > & xPeer) const
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
const Reference< XControl >* pControls = m_aControls.getConstArray();
sal_uInt32 nCtrls = m_aControls.getLength();
@@ -2440,7 +2657,7 @@ Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer
//------------------------------------------------------------------------------
void FmXFormController::activateFirst() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateFirst : invalid aggregate !");
if (m_xTabController.is())
@@ -2450,7 +2667,7 @@ void FmXFormController::activateFirst() throw( RuntimeException )
//------------------------------------------------------------------------------
void FmXFormController::activateLast() throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::osl::MutexGuard aGuard( m_aMutex );
DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateLast : invalid aggregate !");
if (m_xTabController.is())
@@ -2469,21 +2686,21 @@ Reference< XControl> SAL_CALL FmXFormController::getCurrentControl(void) throw(
void SAL_CALL FmXFormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aActivateListeners.addInterface(l);
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aActivateListeners.removeInterface(l);
}
//------------------------------------------------------------------------------
void FmXFormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
// create the composer
Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY);
Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm));
@@ -2659,7 +2876,7 @@ void FmXFormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
//------------------------------------------------------------------------------
void FmXFormController::startFiltering()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
OStaticDataAccessTools aStaticTools;
Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
@@ -2818,7 +3035,7 @@ void FmXFormController::startFiltering()
//------------------------------------------------------------------------------
void FmXFormController::stopFiltering()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if ( !m_bFiltering ) // #104693# OJ
{ // nothing to do
return;
@@ -2912,7 +3129,7 @@ void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExc
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
if (!supportsMode(Mode))
throw NoSupportException();
@@ -2939,14 +3156,14 @@ void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExc
::rtl::OUString SAL_CALL FmXFormController::getMode(void) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
return m_aMode;
}
//------------------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL FmXFormController::getSupportedModes(void) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
static Sequence< ::rtl::OUString > aModes;
if (!aModes.getLength())
{
@@ -2961,7 +3178,7 @@ Sequence< ::rtl::OUString > SAL_CALL FmXFormController::getSupportedModes(void)
//------------------------------------------------------------------------------
sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Sequence< ::rtl::OUString > aModes(getSupportedModes());
const ::rtl::OUString* pModes = aModes.getConstArray();
for (sal_Int32 i = aModes.getLength(); i > 0; )
@@ -2975,7 +3192,7 @@ sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) t
//------------------------------------------------------------------------------
Window* FmXFormController::getDialogParentWindow()
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Window* pParent = m_pWindow;
if ( !pParent )
{
@@ -3126,8 +3343,9 @@ namespace
//------------------------------------------------------------------------------
sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
sal_Bool bValid = sal_True;
if (aIter.hasMoreElements())
@@ -3150,7 +3368,9 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv
Reference< XControlModel > xInvalidModel;
if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) )
{
- displayErrorSetFocus( sInvalidityExplanation, locateControl( xInvalidModel ), getDialogParentWindow() );
+ Reference< XControl > xControl( locateControl( xInvalidModel ) );
+ aGuard.clear();
+ displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow() );
return false;
}
@@ -3158,63 +3378,43 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv
if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) )
return sal_True;
+ OSL_ENSURE( m_pColumnInfoCache.get(), "FmXFormController::approveRowChange: no column infos!" );
+ if ( !m_pColumnInfoCache.get() )
+ return sal_True;
+
try
{
- Reference< XColumnsSupplier > xSupplyCols( _rEvent.Source, UNO_QUERY_THROW );
- Reference< XEnumerationAccess > xEnumAccess( xSupplyCols->getColumns(), UNO_QUERY_THROW );
- Reference< XEnumeration > xEnumeration( xEnumAccess->createEnumeration(), UNO_QUERY_THROW );
+ if ( !m_pColumnInfoCache->controlsInitialized() )
+ m_pColumnInfoCache->initializeControls( getControls() );
- Reference< XPropertySet > xFieldSet;
- while ( xEnumeration->hasMoreElements() )
+ size_t colCount = m_pColumnInfoCache->getColumnCount();
+ for ( size_t col = 0; col < colCount; ++col )
{
- xEnumeration->nextElement() >>= xFieldSet;
- Reference< XColumn > xColumn( xFieldSet, UNO_QUERY);
- if ( !xColumn.is() )
- {
- DBG_ERROR( "FmXFormController::approveRowChange: invalid field !" );
+ const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo( col );
+ if ( rColInfo.nNullable != ColumnValue::NO_NULLS )
continue;
- }
- sal_Bool bRequired = ::comphelper::getINT32( xFieldSet->getPropertyValue( FM_PROP_ISNULLABLE ) ) == ColumnValue::NO_NULLS;
- if ( !bRequired )
+ if ( rColInfo.bAutoIncrement )
continue;
- sal_Bool bAutoIncrement = ::comphelper::getBOOL( xFieldSet->getPropertyValue( FM_PROP_AUTOINCREMENT ) );
- if ( bAutoIncrement )
+ if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() )
continue;
- ::rtl::OUString aFieldName( ::comphelper::getString( xFieldSet->getPropertyValue( FM_PROP_NAME ) ) );
-
// TODO: in case of binary fields, this "getString" below is extremely expensive
- if ( !xColumn->getString().getLength() && xColumn->wasNull() )
- {
- Sequence< Reference< XControl > > aControls( getControls() );
- sal_Int32 nLength = aControls.getLength();
- sal_Int32 i(0);
- const Reference< XControl > * pControls = aControls.getConstArray();
- for (; i < nLength; i++)
- {
- if (pControls[i].is())
- {
- Reference< XPropertySet > xModel(pControls[i]->getModel(), UNO_QUERY);
- if (xModel.is())
- {
- if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xModel))
- {
- ::rtl::OUString aName = ::comphelper::getString(xModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
- if (aName == aFieldName) // Control gefunden
- break;
- }
- }
- }
- }
+ if ( rColInfo.xColumn->getString().getLength() || !rColInfo.xColumn->wasNull() )
+ continue;
- String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) );
- sMessage.SearchAndReplace( '#', aFieldName.getStr() );
- displayErrorSetFocus( sMessage, ( i < nLength ) ? pControls[i] : Reference< XControl >(), getDialogParentWindow() );
+ String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) );
+ sMessage.SearchAndReplace( '#', rColInfo.sName );
- return sal_False;
- }
+ // the control to focus
+ Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired );
+ if ( !xControl.is() )
+ xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY );
+
+ aGuard.clear();
+ displayErrorSetFocus( sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow() );
+ return sal_False;
}
}
catch( const Exception& )
@@ -3229,7 +3429,7 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv
sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
if (aIter.hasMoreElements())
{
@@ -3245,7 +3445,7 @@ sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event)
sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& event) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
if (aIter.hasMoreElements())
{
@@ -3262,7 +3462,7 @@ sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& even
void SAL_CALL FmXFormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aRowSetApproveListeners.addInterface(_rxListener);
}
@@ -3270,7 +3470,7 @@ void SAL_CALL FmXFormController::addRowSetApproveListener(const Reference< XRowS
void SAL_CALL FmXFormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aRowSetApproveListeners.removeInterface(_rxListener);
}
@@ -3278,8 +3478,8 @@ void SAL_CALL FmXFormController::removeRowSetApproveListener(const Reference< XR
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners);
if (aIter.hasMoreElements())
@@ -3290,7 +3490,8 @@ void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw
}
else
{
- displayException(aEvent);
+ aGuard.clear();
+ displayException( aEvent );
}
}
@@ -3299,7 +3500,7 @@ void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw
void SAL_CALL FmXFormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aErrorListeners.addInterface(aListener);
}
@@ -3307,7 +3508,7 @@ void SAL_CALL FmXFormController::addSQLErrorListener(const Reference< XSQLErrorL
void SAL_CALL FmXFormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aErrorListeners.removeInterface(aListener);
}
@@ -3315,14 +3516,14 @@ void SAL_CALL FmXFormController::removeSQLErrorListener(const Reference< XSQLErr
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
{
- OSL_ENSURE( !FmXFormController_BASE1::rBHelper.bDisposed, "FmXFormController::addDatabaseParameterListener: Object already disposed!" );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aParameterListeners.addInterface(aListener);
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
{
- OSL_ENSURE( !FmXFormController_BASE1::rBHelper.bDisposed, "FmXFormController::removeDatabaseParameterListener: Object already disposed!" );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aParameterListeners.removeInterface(aListener);
}
@@ -3343,7 +3544,7 @@ void SAL_CALL FmXFormController::removeParameterListener(const Reference< XDatab
//------------------------------------------------------------------------------
sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners);
if (aIter.hasMoreElements())
@@ -3422,14 +3623,14 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aDeleteListeners.addInterface(aListener);
}
//------------------------------------------------------------------------------
void SAL_CALL FmXFormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
m_aDeleteListeners.removeInterface(aListener);
}
@@ -3437,7 +3638,7 @@ void SAL_CALL FmXFormController::removeConfirmDeleteListener(const Reference< XC
//------------------------------------------------------------------------------
sal_Bool SAL_CALL FmXFormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners);
if (aIter.hasMoreElements())
@@ -3484,7 +3685,7 @@ FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL
const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/)
throw( RuntimeException )
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
Reference< XDispatch > xReturn;
// dispatches handled by ourself
if ( ( aURL.Complete == FMURL_CONFIRM_DELETION )
@@ -3576,7 +3777,7 @@ void SAL_CALL FmXFormController::removeStatusListener( const Reference< XStatusL
//------------------------------------------------------------------------------
Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
#ifdef DBG_UTIL
// check if we already have a interceptor for the given object
for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin();
@@ -3624,7 +3825,7 @@ void SAL_CALL FmXFormController::handle( const Reference< XInteractionRequest >&
//------------------------------------------------------------------------------
void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
{
- OSL_ENSURE(!FmXFormController_BASE1::rBHelper.bDisposed,"FmXFormController: Object already disposed!");
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" );
// search the interceptor responsible for the given object
InterceptorsIterator aIter;
for ( aIter = m_aControlDispatchInterceptors.begin();
diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
index 0b848c5432f3..733581521ea4 100644
--- a/svx/source/form/fmexpl.cxx
+++ b/svx/source/form/fmexpl.cxx
@@ -30,9 +30,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
-#ifndef _SVX_FMUNOVW_HXX
-#include "fmvwimp.hxx"
-#endif
#ifndef _SVX_FMRESIDS_HRC
#include "fmresids.hrc"
diff --git a/svx/source/form/fmmodel.cxx b/svx/source/form/fmmodel.cxx
index d816dc06b813..09008ae220b9 100644
--- a/svx/source/form/fmmodel.cxx
+++ b/svx/source/form/fmmodel.cxx
@@ -223,18 +223,21 @@ void FmFormModel::MovePage( USHORT nPgNum, USHORT nNewPos )
\************************************************************************/
SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
{
- FmFormPage* pPage = (FmFormPage*)SdrModel::RemovePage(nPgNum);
+ FmFormPage* pToBeRemovedPage = dynamic_cast< FmFormPage* >( GetPage( nPgNum ) );
+ OSL_ENSURE( pToBeRemovedPage, "FmFormModel::RemovePage: *which page*?" );
#ifndef SVX_LIGHT
- if (pPage)
+ if ( pToBeRemovedPage )
{
- Reference< XNameContainer > xForms( pPage->GetForms( false ) );
+ Reference< XNameContainer > xForms( pToBeRemovedPage->GetForms( false ) );
if ( xForms.is() )
m_pImpl->pUndoEnv->RemoveForms( xForms );
}
#endif
- return pPage;
+ FmFormPage* pRemovedPage = (FmFormPage*)SdrModel::RemovePage(nPgNum);
+ OSL_ENSURE( pRemovedPage == pToBeRemovedPage, "FmFormModel::RemovePage: inconsistency!" );
+ return pRemovedPage;
}
/*************************************************************************
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 71dffe76dd9b..fd5299fe62d5 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -31,12 +31,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
#include <tools/resmgr.hxx>
+#include <tools/diagnose_ex.h>
#include "fmobj.hxx"
-
-#ifndef _SVX_FMPROP_HRC
#include "fmprop.hrc"
-#endif
+#include "fmvwimp.hxx"
#include <svx/editeng.hxx>
+#include <svx/svdovirt.hxx>
/** === begin UNO includes === **/
#include <com/sun/star/awt/XDevice.hpp>
@@ -49,15 +49,11 @@
#include <tools/shl.hxx>
#include <svx/dialmgr.hxx>
-#ifndef _SVX_FMRESIDS_HRC
#include "fmresids.hrc"
-#endif
#include <svx/fmview.hxx>
#include <svx/fmglob.hxx>
-#ifndef _SVX_FMPGEIMP_HXX
#include "fmpgeimp.hxx"
-#endif
#include <svx/fmpage.hxx>
#include <comphelper/property.hxx>
#include <comphelper/processfactory.hxx>
@@ -79,24 +75,20 @@ TYPEINIT1(FmFormObj, SdrUnoObj);
DBG_NAME(FmFormObj);
//------------------------------------------------------------------
FmFormObj::FmFormObj(const ::rtl::OUString& rModelName,sal_Int32 _nType)
- :SdrUnoObj ( rModelName, sal_False )
- ,m_pControlCreationView ( 0 )
- ,m_nControlCreationEvent ( 0 )
- ,m_nPos ( -1 )
- ,m_nType ( _nType )
- ,m_pLastKnownRefDevice ( NULL )
+ :SdrUnoObj ( rModelName )
+ ,m_nPos ( -1 )
+ ,m_nType ( _nType )
+ ,m_pLastKnownRefDevice ( NULL )
{
DBG_CTOR(FmFormObj, NULL);
}
//------------------------------------------------------------------
FmFormObj::FmFormObj( sal_Int32 _nType )
- :SdrUnoObj ( String(), sal_False )
- ,m_pControlCreationView ( 0 )
- ,m_nControlCreationEvent ( 0 )
- ,m_nPos ( -1 )
- ,m_nType ( _nType )
- ,m_pLastKnownRefDevice ( NULL )
+ :SdrUnoObj ( String() )
+ ,m_nPos ( -1 )
+ ,m_nType ( _nType )
+ ,m_pLastKnownRefDevice ( NULL )
{
DBG_CTOR(FmFormObj, NULL);
}
@@ -105,8 +97,6 @@ FmFormObj::FmFormObj( sal_Int32 _nType )
FmFormObj::~FmFormObj()
{
DBG_DTOR(FmFormObj, NULL);
- if (m_nControlCreationEvent)
- Application::RemoveUserEvent(m_nControlCreationEvent);
Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
if (xHistory.is())
@@ -117,7 +107,7 @@ FmFormObj::~FmFormObj()
}
//------------------------------------------------------------------
-void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, sal_Int32 nIdx,
+void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, const sal_Int32 nIdx,
const Sequence< ScriptEventDescriptor >& rEvts)
{
m_xParent = xForm;
@@ -126,71 +116,112 @@ void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, sal_Int32
}
//------------------------------------------------------------------
+void FmFormObj::ClearObjEnv()
+{
+ m_xParent.clear();
+ aEvts.realloc( 0 );
+ m_nPos = -1;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::impl_isolateControlModel_nothrow()
+{
+ try
+ {
+ Reference< XChild > xControlModel( GetUnoControlModel(), UNO_QUERY );
+ if ( xControlModel.is() )
+ {
+ Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
+ if ( xParent.is() )
+ {
+ sal_Int32 nPos = getElementPos( xParent.get(), xControlModel );
+ xParent->removeByIndex( nPos );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------
void FmFormObj::SetPage(SdrPage* _pNewPage)
{
FmFormPage* pNewFormPage = PTR_CAST(FmFormPage, _pNewPage);
- if (!pNewFormPage || (GetPage() == _pNewPage))
+ if ( GetPage() == _pNewPage )
+ {
+ SdrUnoObj::SetPage(_pNewPage);
+ return;
+ }
+
+ if ( !pNewFormPage )
{ // Maybe it makes sense to create an environment history here : if somebody set's our page to NULL, and we have a valid page before,
- // me may want to remember our place within the old page. For this we could create a new m_pEnvironmentHistory to store it.
+ // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it.
// So the next SetPage with a valid new page would restore that environment within the new page.
// But for the original Bug (#57300#) we don't need that, so I omit it here. Maybe this will be implemented later.
+ impl_isolateControlModel_nothrow();
SdrUnoObj::SetPage(_pNewPage);
return;
}
- Reference< XIndexContainer > xNewParent;
+ Reference< XIndexContainer > xNewPageForms( pNewFormPage->GetForms( true ), UNO_QUERY );
+ Reference< XIndexContainer > xNewParent;
Sequence< ScriptEventDescriptor> aNewEvents;
// calc the new parent for my model (within the new page's forms hierarchy)
// do we have a history ? (from :Clone)
- if (m_xEnvironmentHistory.is())
+ if ( m_xEnvironmentHistory.is() )
{
- // the element in *m_pEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within _pNewPage->GetForms)
+ // the element in m_xEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within _pNewPage->GetForms)
// is the right-most element in the tree.
- Reference< XIndexContainer > xLoop = m_xEnvironmentHistory;
- do
+ Reference< XIndexContainer > xRightMostLeaf = m_xEnvironmentHistory;
+ try
{
- if (xLoop->getCount() == 0)
- break;
- Reference< XIndexContainer > xRightMostChild;
- xLoop->getByIndex(xLoop->getCount() - 1) >>= xRightMostChild;
- if (!xRightMostChild.is())
+ while ( xRightMostLeaf->getCount() )
{
- DBG_ERROR("FmFormObj::SetPage : invalid elements in environment history !");
- break;
+ xRightMostLeaf.set(
+ xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
+ UNO_QUERY_THROW
+ );
}
- xLoop = xRightMostChild;
- }
- while (sal_True);
- xNewParent = Reference< XIndexContainer > (ensureModelEnv(xLoop, Reference< XIndexContainer > (pNewFormPage->GetForms(), ::com::sun::star::uno::UNO_QUERY)), ::com::sun::star::uno::UNO_QUERY);
- if (xNewParent.is())
- // we successfully clone the environment in m_pEnvironmentHistory, so we can use m_aEventsHistory
- // (which describes the events of our model at the moment m_pEnvironmentHistory was created)
+ xNewParent.set( ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
+
+ // we successfully cloned the environment in m_xEnvironmentHistory, so we can use m_aEventsHistory
+ // (which describes the events of our model at the moment m_xEnvironmentHistory was created)
aNewEvents = m_aEventsHistory;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
- if (!xNewParent.is())
+ if ( !xNewParent.is() )
{
// are we a valid part of our current page forms ?
- FmFormPage* pOldFormPage = PTR_CAST(FmFormPage, GetPage());
- Reference< XIndexContainer > xOldForms = pOldFormPage ? Reference< XIndexContainer > (pOldFormPage->GetForms(), ::com::sun::star::uno::UNO_QUERY) : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > ();
- if (xOldForms.is())
+ Reference< XIndexContainer > xOldForms;
+ FmFormPage* pOldFormPage = dynamic_cast< FmFormPage* >( GetPage() );
+ if ( pOldFormPage )
+ xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW );
+
+ if ( xOldForms.is() )
{
// search (upward from our model) for xOldForms
- Reference< XChild > xSearch(GetUnoControlModel(), UNO_QUERY);
+ Reference< XChild > xSearch( GetUnoControlModel(), UNO_QUERY );
while (xSearch.is())
{
- if (xSearch == xOldForms)
+ if ( xSearch == xOldForms )
break;
- xSearch = Reference< XChild > (xSearch->getParent(), UNO_QUERY);
+ xSearch = Reference< XChild >( xSearch->getParent(), UNO_QUERY );
}
- if (xSearch.is()) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
+ if ( xSearch.is() ) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
{
- Reference< XChild > xMeAsChild(GetUnoControlModel(), UNO_QUERY);
- xNewParent = Reference< XIndexContainer > (ensureModelEnv(xMeAsChild->getParent(), Reference< XIndexContainer > (pNewFormPage->GetForms(), ::com::sun::star::uno::UNO_QUERY)), ::com::sun::star::uno::UNO_QUERY);
+ Reference< XChild > xMeAsChild( GetUnoControlModel(), UNO_QUERY );
+ xNewParent.set( ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
- if (xNewParent.is())
+ if ( xNewParent.is() )
{
try
{
@@ -206,11 +237,10 @@ void FmFormObj::SetPage(SdrPage* _pNewPage)
else
aNewEvents = aEvts;
}
- catch(...)
+ catch( const Exception& )
{
- DBG_ERROR("FmFormObj::SetPage : could not retrieve script events !");
+ DBG_UNHANDLED_EXCEPTION();
}
-
}
}
}
@@ -250,9 +280,9 @@ void FmFormObj::SetPage(SdrPage* _pNewPage)
xEventManager->registerScriptEvents(nPos, aNewEvents);
}
}
- catch(...)
+ catch( const Exception& )
{
- DBG_ERROR("FmFormObj::SetPage : could not tranfer script events !");
+ DBG_UNHANDLED_EXCEPTION();
}
}
@@ -528,44 +558,81 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
}
//------------------------------------------------------------------
-FASTBOOL FmFormObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
+{
+ FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
+ if ( !pFormObject )
+ {
+ SdrVirtObj* pVirtualObject = dynamic_cast< SdrVirtObj* >( _pSdrObject );
+ if ( pVirtualObject )
+ pFormObject = dynamic_cast< FmFormObj* >( &pVirtualObject->ReferencedObj() );
+ }
+ return pFormObject;
+}
+
+//------------------------------------------------------------------
+const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject )
+{
+ const FmFormObj* pFormObject = dynamic_cast< const FmFormObj* >( _pSdrObject );
+ if ( !pFormObject )
+ {
+ const SdrVirtObj* pVirtualObject = dynamic_cast< const SdrVirtObj* >( _pSdrObject );
+ if ( pVirtualObject )
+ pFormObject = dynamic_cast< const FmFormObj* >( &pVirtualObject->GetReferencedObj() );
+ }
+ return pFormObject;
+}
+
+//------------------------------------------------------------------
+FASTBOOL FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
{
bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
- if (bResult && SDRCREATE_FORCEEND == eCmd && rStat.GetView())
+ if ( bResult && SDRCREATE_FORCEEND == eCmd && rStat.GetView() )
{
- // ist das Object teil einer Form?
- Reference< XFormComponent > xContent(xUnoControlModel, UNO_QUERY);
- if (xContent.is() && pPage)
+ if ( pPage )
{
- // Komponente gehoert noch keiner Form an
- if (!xContent->getParent().is())
+ FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pPage );
+
+ try
{
- Reference< XForm > xTemp = ((FmFormPage*)pPage)->GetImpl()->placeInFormComponentHierarchy(xContent);
- Reference< XIndexContainer > xForm(xTemp, UNO_QUERY);
+ Reference< XFormComponent > xContent( xUnoControlModel, UNO_QUERY_THROW );
+ Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
+
+ Reference< XIndexContainer > xFormToInsertInto;
- // Position des Elements
- sal_Int32 nPos = xForm->getCount();
- xForm->insertByIndex(nPos, makeAny(xContent));
+ if ( !xParentForm.is() )
+ { // model is not yet part of a form component hierachy
+ xParentForm.set( rPage.GetImpl()->findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
+ xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
+ }
+
+ rPage.GetImpl()->setUniqueName( xContent, xParentForm );
+
+ if ( xFormToInsertInto.is() )
+ xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
}
- if ( m_nControlCreationEvent )
- Application::RemoveUserEvent( m_nControlCreationEvent );
-
- m_pControlCreationView = static_cast< FmFormView* >( rStat.GetView() );
- m_nControlCreationEvent = Application::PostUserEvent( LINK( this, FmFormObj, OnCreate ) );
+ FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
+ FmXFormView* pViewImpl = pView ? pView->GetImpl() : NULL;
+ OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
+ if ( pViewImpl )
+ pViewImpl->onCreatedFormObject( *this );
}
return bResult;
}
//------------------------------------------------------------------------------
-IMPL_LINK(FmFormObj, OnCreate, void*, /*EMPTYTAG*/)
+void FmFormObj::BrkCreate( SdrDragStat& rStat )
{
- m_nControlCreationEvent = 0;
- if ( m_pControlCreationView )
- m_pControlCreationView->ObjectCreated( this );
- return 0;
+ SdrUnoObj::BrkCreate( rStat );
+ impl_isolateControlModel_nothrow();
}
+
// -----------------------------------------------------------------------------
sal_Int32 FmFormObj::getType() const
{
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index c460d70bc7e1..892894d23cb4 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -86,6 +86,7 @@ using namespace ::svxform;
using com::sun::star::uno::Reference;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::container::XChild;
+using com::sun::star::container::XNameContainer;
TYPEINIT1(FmFormPage, SdrPage);
@@ -131,20 +132,19 @@ void FmFormPage::SetModel(SdrModel* pNewModel)
// doesn't, so get the old model to do a check.
SdrModel *pOldModel = GetModel();
-
SdrPage::SetModel( pNewModel );
-
/* #35055# */
if ( ( pOldModel != pNewModel ) && m_pImpl )
{
try
{
- if ( m_pImpl->m_xForms.is() )
+ Reference< XNameContainer > xForms( m_pImpl->getForms( false ) );
+ if ( xForms.is() )
{
// we want to keep the current collection, just reset the model
// with which it's associated.
- Reference< XChild > xAsChild( m_pImpl->m_xForms, UNO_QUERY );
+ Reference< XChild > xAsChild( xForms, UNO_QUERY );
if ( xAsChild.is() )
{
FmFormModel* pDrawModel = (FmFormModel*) GetModel();
@@ -183,7 +183,13 @@ void FmFormPage::InsertObject(SdrObject* pObj, ULONG nPos,
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & FmFormPage::GetForms( bool _bForceCreate ) const
{
#ifndef SVX_LIGHT
- return m_pImpl->getForms( _bForceCreate );
+ const SdrPage& rMasterPage( *this );
+ const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage );
+ OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" );
+ if ( !pFormPage )
+ pFormPage = this;
+
+ return pFormPage->m_pImpl->getForms( _bForceCreate );
#else
static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > aRef;
return aRef;
@@ -195,68 +201,67 @@ sal_Bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView,
const HelpEvent& rEvt )
{
#ifndef SVX_LIGHT
- if( !pView->IsAction() )
+ if( pView->IsAction() )
+ return sal_False;
+
+ Point aPos = rEvt.GetMousePosPixel();
+ aPos = pWindow->ScreenToOutputPixel( aPos );
+ aPos = pWindow->PixelToLogic( aPos );
+
+ SdrObject* pObj = NULL;
+ SdrPageView* pPV = NULL;
+ if ( !pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) )
+ return sal_False;
+
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( !pFormObject )
+ return sal_False;
+
+ UniString aHelpText;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSet( pFormObject->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY );
+ if (xSet.is())
{
- Point aPos = rEvt.GetMousePosPixel();
- aPos = pWindow->ScreenToOutputPixel( aPos );
- aPos = pWindow->PixelToLogic( aPos );
+ if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
+ aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr();
- SdrObject* pObj = NULL;
- SdrPageView* pPV = NULL;
- if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) )
+ if (!aHelpText.Len() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
{
- // Ein Object getroffen
- if( pObj->ISA(FmFormObj) )
- {
- UniString aHelpText;
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSet(((FmFormObj*)pObj)->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
- if (xSet.is())
- {
- if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
- aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr();
+ ::rtl::OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
+ INetURLObject aUrl(aText);
- if (!aHelpText.Len() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
- {
- ::rtl::OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
- INetURLObject aUrl(aText);
-
- // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will
- INetProtocol aProtocol = aUrl.GetProtocol();
- static const INetProtocol s_aQuickHelpSupported[] =
- { INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS,
- INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3,
- INET_PROT_VIM, INET_PROT_LDAP
- };
- for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i)
- if (s_aQuickHelpSupported[i] == aProtocol)
- {
- aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
- break;
- }
- }
- }
- if ( aHelpText.Len() != 0 )
+ // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will
+ INetProtocol aProtocol = aUrl.GetProtocol();
+ static const INetProtocol s_aQuickHelpSupported[] =
+ { INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS,
+ INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3,
+ INET_PROT_VIM, INET_PROT_LDAP
+ };
+ for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i)
+ if (s_aQuickHelpSupported[i] == aProtocol)
{
- // Hilfe anzeigen
- Rectangle aItemRect = pObj->GetCurrentBoundRect();
- aItemRect = pWindow->LogicToPixel( aItemRect );
- Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
- aItemRect.Left() = aPt.X();
- aItemRect.Top() = aPt.Y();
- aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
- aItemRect.Right() = aPt.X();
- aItemRect.Bottom() = aPt.Y();
- if( rEvt.GetMode() == HELPMODE_BALLOON )
- Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
- else
- Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
+ aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ break;
}
- return sal_True;
- }
}
}
+ if ( aHelpText.Len() != 0 )
+ {
+ // Hilfe anzeigen
+ Rectangle aItemRect = pObj->GetCurrentBoundRect();
+ aItemRect = pWindow->LogicToPixel( aItemRect );
+ Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
+ aItemRect.Left() = aPt.X();
+ aItemRect.Top() = aPt.Y();
+ aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
+ aItemRect.Right() = aPt.X();
+ aItemRect.Bottom() = aPt.Y();
+ if( rEvt.GetMode() == HELPMODE_BALLOON )
+ Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
+ else
+ Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
+ }
#endif
- return sal_False;
+ return sal_True;
}
//------------------------------------------------------------------
diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx
index 98ca98a13fb0..29fc384674ac 100644
--- a/svx/source/form/fmpgeimp.cxx
+++ b/svx/source/form/fmpgeimp.cxx
@@ -53,11 +53,10 @@
#include <svx/fmpage.hxx>
#include <svx/fmmodel.hxx>
#include <tools/resid.hxx>
+#include <tools/diagnose_ex.h>
#include "svditer.hxx"
-#ifndef _SVX_FMRESIDS_HRC
#include "fmresids.hrc"
-#endif
#include <tools/shl.hxx>
#include <vcl/stdtext.hxx>
#include <svx/dialmgr.hxx>
@@ -94,6 +93,10 @@ FmFormPageImpl::FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl)
{
DBG_CTOR(FmFormPageImpl,NULL);
+ OSL_ENSURE( false, "FmFormPageImpl::FmFormPageImpl: I'm pretty sure the below code isn't valid anymore ..." );
+ // streaming of form/controls is not a supported operation anymore, in that it is not guaranteed
+ // that really everything is copied. XCloneable should be used instead.
+
// copy it by streaming
// creating a pipe
Reference< ::com::sun::star::io::XOutputStream > xOutPipe(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY);
@@ -183,15 +186,17 @@ FmFormPageImpl::~FmFormPageImpl()
}
//------------------------------------------------------------------------------
-void FmFormPageImpl::validateCurForm()
+bool FmFormPageImpl::validateCurForm()
{
if ( !xCurrentForm.is() )
- return;
+ return false;
Reference< XChild > xAsChild( xCurrentForm, UNO_QUERY );
DBG_ASSERT( xAsChild.is(), "FmFormPageImpl::validateCurForm: a form which is no child??" );
if ( !xAsChild.is() || !xAsChild->getParent().is() )
xCurrentForm.clear();
+
+ return xCurrentForm.is();
}
//------------------------------------------------------------------------------
@@ -201,102 +206,86 @@ void FmFormPageImpl::setCurForm(Reference< ::com::sun::star::form::XForm > xFor
}
//------------------------------------------------------------------------------
-Reference< ::com::sun::star::form::XForm > FmFormPageImpl::getDefaultForm()
+Reference< XForm > FmFormPageImpl::getDefaultForm()
{
- Reference< ::com::sun::star::form::XForm > xForm;
-
- try
- {
- Reference< XNameContainer > xForms( getForms() );
+ Reference< XForm > xForm;
- validateCurForm();
+ Reference< XNameContainer > xForms( getForms() );
- // wenn noch kein TargetForm gefunden, dann aktuelle oder Default
- if (!xCurrentForm.is())
+ // by default, we use our "current form"
+ if ( !validateCurForm() )
+ {
+ // check whether there is a "standard" form
+ if ( xForms->hasElements() )
{
- if (xForms->hasElements())
- {
- // suche die Standardform
- ::rtl::OUString ustrStdFormName = ::rtl::OUString(String(SVX_RES(RID_STR_STDFORMNAME)));
+ // suche die Standardform
+ ::rtl::OUString sStandardFormname = String( SVX_RES( RID_STR_STDFORMNAME ) );
- if (xForms->hasByName(ustrStdFormName))
- {
- try
- {
- xForms->getByName(ustrStdFormName) >>= xForm;
- }
- catch(::com::sun::star::container::NoSuchElementException &)
- {
- DBG_ERROR("NoSuchElementException occured!");
- }
- catch(::com::sun::star::lang::WrappedTargetException &)
- {
- DBG_ERROR("WrappedTargetException occured!");
- }
-
- }
-
- // gibt es denn ueberhaupt eine
- if (!xForm.is())
+ try
+ {
+ if ( xForms->hasByName( sStandardFormname ) )
+ xForm.set( xForms->getByName( sStandardFormname ), UNO_QUERY_THROW );
+ else
{
- Reference< ::com::sun::star::container::XIndexAccess > xGetFirst(xForms, UNO_QUERY);
- DBG_ASSERT(xGetFirst.is(), "FmFormPageImpl::getDefaultForm : no IndexAccess on my form container !");
- // wenn das anspringt, muesste man sich die Namen des NameContainers geben lassen und dann das Objekt fuer den
- // ersten Namen erfragen ... aber normalerweise sollte die FOrms-Sammlung auch einen IndexAccess haben
- xGetFirst->getByIndex(0) >>= xForm;
+ Reference< XIndexAccess > xFormsByIndex( xForms, UNO_QUERY_THROW );
+ xForm.set( xFormsByIndex->getByIndex(0), UNO_QUERY_THROW );
}
}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
- else
- xForm = xCurrentForm;
+ }
+ else
+ {
+ xForm = xCurrentForm;
+ }
- // keine gefunden dann standard erzeugen
- if (!xForm.is())
- {
+ // did not find an existing suitable form -> create a new one
+ if ( !xForm.is() )
+ {
+ SdrModel* pModel = pPage->GetModel();
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pModel->BegUndo(aUndoStr);
- SdrModel* pModel = pPage->GetModel();
- XubString aStr(SVX_RES(RID_STR_FORM));
- XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
- aUndoStr.SearchAndReplace('#', aStr);
- pModel->BegUndo(aUndoStr);
+ try
+ {
+ xForm.set( ::comphelper::getProcessServiceFactory()->createInstance( FM_SUN_COMPONENT_FORM ), UNO_QUERY );
- xForm = Reference< ::com::sun::star::form::XForm >(::comphelper::getProcessServiceFactory()->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
// a form should always have the command type table as default
- Reference< ::com::sun::star::beans::XPropertySet > xSet(xForm, UNO_QUERY);
- try
- {
- xSet->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE)));
- }
- catch(Exception&)
- {
- }
-
- ::rtl::OUString aName = String(SVX_RES(RID_STR_STDFORMNAME));
- xSet->setPropertyValue(FM_PROP_NAME, makeAny(aName));
+ Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW );
+ xFormProps->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny( sal_Int32( CommandType::TABLE ) ) );
+ // and the "Standard" name
+ ::rtl::OUString sName = String( SVX_RES( RID_STR_STDFORMNAME ) );
+ xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
- Reference< ::com::sun::star::container::XIndexContainer > xContainer(xForms, UNO_QUERY);
+ Reference< XIndexContainer > xContainer( xForms, UNO_QUERY );
pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
FmUndoContainerAction::Inserted,
xContainer,
xForm,
xContainer->getCount()));
- xForms->insertByName(aName, makeAny(xForm));
+ xForms->insertByName( sName, makeAny( xForm ) );
xCurrentForm = xForm;
- pModel->EndUndo();
}
- }
- catch( const Exception& )
- {
- DBG_ERROR( "FmFormPageImpl::getDefaultForm: caught an exception!" );
- xForm.clear();
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ xForm.clear();
+ }
+
+ pModel->EndUndo();
}
return xForm;
}
//------------------------------------------------------------------------------
-Reference< ::com::sun::star::form::XForm > FmFormPageImpl::placeInFormComponentHierarchy(
+Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy(
const Reference< XFormComponent > & rContent, const Reference< XDataSource > & rDatabase,
const ::rtl::OUString& rDBTitle, const ::rtl::OUString& rCursorSource, sal_Int32 nCommandType )
{
@@ -317,7 +306,7 @@ Reference< ::com::sun::star::form::XForm > FmFormPageImpl::placeInFormComponent
xForm = findFormForDataSource( xCurrentForm, rDatabase, rCursorSource, nCommandType );
Reference< ::com::sun::star::container::XIndexAccess > xFormsByIndex( getForms(), UNO_QUERY );
- DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::placeInFormComponentHierarchy : no index access for my forms collection !");
+ DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::findPlaceInFormComponentHierarchy : no index access for my forms collection !");
sal_Int32 nCount = xFormsByIndex->getCount();
for (sal_Int32 i = 0; !xForm.is() && i < nCount; i++)
{
@@ -381,8 +370,6 @@ Reference< ::com::sun::star::form::XForm > FmFormPageImpl::placeInFormComponent
}
xForm = getDefaultForm();
- // eindeutigen Namen fuer die Componente setzen
- setUniqueName(rContent, xForm);
return xForm;
}
@@ -469,7 +456,7 @@ Reference< XForm > FmFormPageImpl::findFormForDataSource(
}
//------------------------------------------------------------------------------
-::rtl::OUString FmFormPageImpl::setUniqueName(const Reference< ::com::sun::star::form::XFormComponent > & xFormComponent, const Reference< ::com::sun::star::form::XForm > & xControls)
+::rtl::OUString FmFormPageImpl::setUniqueName(const Reference< XFormComponent > & xFormComponent, const Reference< XForm > & xControls)
{
::rtl::OUString sName;
Reference< ::com::sun::star::beans::XPropertySet > xSet(xFormComponent, UNO_QUERY);
@@ -492,31 +479,6 @@ Reference< XForm > FmFormPageImpl::findFormForDataSource(
xSet->setPropertyValue(FM_PROP_NAME, makeAny(sDefaultName));
}
- //////////////////////////////////////////////////////////////
- // Labels anpassen
- UniString aLabel = sDefaultName;
- sal_uInt16 nResId = 0;
-
- switch (nClassId)
- {
- case ::com::sun::star::form::FormComponentType::COMMANDBUTTON: nResId = RID_STR_PROPTITLE_PUSHBUTTON; break;
- case ::com::sun::star::form::FormComponentType::RADIOBUTTON: nResId = RID_STR_PROPTITLE_RADIOBUTTON; break;
- case ::com::sun::star::form::FormComponentType::CHECKBOX: nResId = RID_STR_PROPTITLE_CHECKBOX; break;
- case ::com::sun::star::form::FormComponentType::GROUPBOX: nResId = RID_STR_PROPTITLE_GROUPBOX; break;
- case ::com::sun::star::form::FormComponentType::FIXEDTEXT: nResId = RID_STR_PROPTITLE_FIXEDTEXT; break;
- }
-
- if (nResId)
- {
- ::rtl::OUString aText;
- xSet->getPropertyValue( FM_PROP_LABEL ) >>= aText;
- if (!aText.getLength())
- {
- aLabel.SearchAndReplace( getDefaultName( nClassId, xSI ), ::rtl::OUString(String(SVX_RES(nResId)) ));
- xSet->setPropertyValue( FM_PROP_LABEL, makeAny(::rtl::OUString(aLabel)) );
- }
- }
-
sName = sDefaultName;
}
}
diff --git a/svx/source/form/fmprop.cxx b/svx/source/form/fmprop.cxx
index 603dd9539a5f..577b8b3ec550 100644
--- a/svx/source/form/fmprop.cxx
+++ b/svx/source/form/fmprop.cxx
@@ -186,6 +186,7 @@ namespace svxform
IMPLEMENT_CONSTASCII_USTRING( FM_PROP_BUTTON_TYPE, "ButtonType" );
IMPLEMENT_CONSTASCII_USTRING( FM_PROP_FORM_OPERATIONS, "FormOperations" );
+ IMPLEMENT_CONSTASCII_USTRING( FM_PROP_INPUT_REQUIRED, "InputRequired" );
} // namespace svxform
diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx
index cc325a2122a6..738aad42fb2c 100644
--- a/svx/source/form/fmshell.cxx
+++ b/svx/source/form/fmshell.cxx
@@ -187,95 +187,6 @@ using namespace ::com::sun::star::frame;
using namespace ::svxform;
//========================================================================
-//------------------------------------------------------------------------
-sal_Bool IsFormComponent( const SdrObject& rObj )
-{
- //////////////////////////////////////////////////////////////////////
- // Gruppenobjekte rekursiv pruefen
- if( rObj.IsGroupObject() )
- {
- SdrObject* pObj;
- SdrObjListIter aIter( *rObj.GetSubList() );
-
- while( aIter.IsMore() )
- {
- pObj = aIter.Next();
-
- if( !IsFormComponent(*pObj) )
- return sal_False;
- }
- }
-
- //////////////////////////////////////////////////////////////////
- // ...ansonsten Pruefen, ob SdrObj eine FormComponent ist
- else
- {
- if( !rObj.ISA(SdrUnoObj) )
- return sal_False;
-
- Reference< ::com::sun::star::form::XFormComponent > xFormComponent(((SdrUnoObj*)&rObj)->GetUnoControlModel(), UNO_QUERY);
- if (!xFormComponent.is())
- return sal_False;
- }
-
- return sal_True;
-}
-
-//------------------------------------------------------------------------
-sal_Bool IsFormComponentList( const SdrMarkList& rMarkList )
-{
- sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
-
- if( nMarkCount==0 )
- return sal_False;
-
- SdrObject* pObj;
- for( sal_uInt32 i=0; i<nMarkCount; ++i )
- {
- pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
- if( !IsFormComponent(*pObj) )
- return sal_False;
- }
-
- return sal_True;
-}
-
-//------------------------------------------------------------------------
-sal_Bool IsFormComponentList( const SdrObjList& rSdrObjList )
-{
- SdrObject* pSdrObj;
-
-
- SdrObjListIter aIter( rSdrObjList );
- while( aIter.IsMore() )
- {
- pSdrObj = aIter.Next();
-
- //////////////////////////////////////////////////////////////////
- // Gruppenobjekte rekursiv pruefen
- if( pSdrObj->IsGroupObject() )
- {
- if( !IsFormComponentList(*pSdrObj->GetSubList()) )
- return sal_False;
- }
-
- //////////////////////////////////////////////////////////////////
- // ...ansonsten Pruefen, ob SdrObj eine FormComponent ist
- else
- {
- if (!pSdrObj->ISA(SdrUnoObj))
- return sal_False;
-
- Reference< ::com::sun::star::form::XFormComponent > xFormComponent(((SdrUnoObj*)pSdrObj)->GetUnoControlModel(), UNO_QUERY);
- if (!xFormComponent.is())
- return sal_False;
- }
- }
-
- return sal_True;
-}
-
-//========================================================================
// class FmDesignModeChangedHint
//========================================================================
TYPEINIT1( FmDesignModeChangedHint, SfxHint );
@@ -1029,7 +940,7 @@ void FmFormShell::GetState(SfxItemSet &rSet)
sal_Bool bLayerLocked = sal_False;
if (m_pFormView)
{
- // Ist der ::com::sun::star::drawing::Layer gelocked, so m�ssen die Slots disabled werden. #36897
+ // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
SdrPageView* pPV = m_pFormView->GetSdrPageView();
if (pPV != NULL)
bLayerLocked = pPV->IsLayerLocked(m_pFormView->GetActiveLayer());
@@ -1326,7 +1237,7 @@ void FmFormShell::SetView( FmFormView* _pView )
if ( IsActive() )
GetImpl()->viewDeactivated( *m_pFormView );
- m_pFormView->SetFormShell( NULL );
+ m_pFormView->SetFormShell( NULL, FmFormView::FormShellAccess() );
m_pFormView = NULL;
m_pFormModel = NULL;
}
@@ -1335,7 +1246,7 @@ void FmFormShell::SetView( FmFormView* _pView )
return;
m_pFormView = _pView;
- m_pFormView->SetFormShell( this );
+ m_pFormView->SetFormShell( this, FmFormView::FormShellAccess() );
m_pFormModel = (FmFormModel*)m_pFormView->GetModel();
impl_setDesignMode( m_pFormView->IsDesignMode() );
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index efdf05a52d84..fab478154247 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -306,7 +306,8 @@ namespace
while ( pCurrent )
{
- FmFormObj* pAsFormObject = PTR_CAST( FmFormObj, pCurrent );
+ FmFormObj* pAsFormObject = FmFormObj::GetFormObject( pCurrent );
+ // note this will de-reference virtual objects, if necessary/possible
if ( pAsFormObject )
{
Reference< XInterface > xControlModel( pAsFormObject->GetUnoControlModel(), UNO_QUERY );
@@ -745,11 +746,9 @@ void SAL_CALL FmXFormShell::formActivated(const EventObject& rEvent) throw( Runt
if ( impl_checkDisposed() )
return;
- Reference< XFormController > xController( rEvent.Source, UNO_QUERY );
- OSL_ENSURE( xController.is(), "FmXFormShell::formActivated: invalid event source!" );
-
- setActiveController( xController );
+ Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
m_pTextShell->formActivated( xController );
+ setActiveController( xController );
}
//------------------------------------------------------------------------------
@@ -758,9 +757,7 @@ void SAL_CALL FmXFormShell::formDeactivated(const EventObject& rEvent) throw( Ru
if ( impl_checkDisposed() )
return;
- Reference< XFormController > xController( rEvent.Source, UNO_QUERY );
- OSL_ENSURE( xController.is(), "FmXFormShell::formDeactivated: invalid event source!" );
-
+ Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
m_pTextShell->formDeactivated( xController );
}
@@ -828,12 +825,15 @@ void FmXFormShell::disposing()
DisableNotification();
- // we are disposed from within the destructor of our shell, so now the shell pointer is invalid ....
- m_pShell = NULL;
+ RemoveElement( m_xForms );
+ m_xForms.clear();
+
+ impl_switchActiveControllerListening( false );
m_xActiveController = NULL;
- m_xNavigationController = NULL;
m_xActiveForm = NULL;
- m_xForms = NULL;
+
+ m_pShell = NULL;
+ m_xNavigationController = NULL;
m_xCurrentForm = NULL;
m_xLastGridFound = NULL;
m_xAttachedFrame = NULL;
@@ -1005,6 +1005,12 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
if ( !_rxObject.is() )
return false;
+ 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;
+
OSL_ENSURE( isSolelySelected( _rxObject ),
"FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant?" );
@@ -1012,46 +1018,25 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
{
if (nConvertSlots[lookupSlot] == _nSlotId)
{
- FmFormPage* pCurrentPage = m_pShell->GetCurPage();
+ Reference< XInterface > xNormalizedObject( _rxObject, UNO_QUERY );
- SdrUnoObj* pFound = NULL;
- for (sal_uInt32 obj=0; obj<pCurrentPage->GetObjCount(); ++obj)
+ FmFormObj* pFormObject = NULL;
+ SdrObjListIter aPageIter( *pFormPage );
+ while ( aPageIter.IsMore() )
{
- SdrObject* pCurrent = pCurrentPage->GetObj(obj);
-
- // wenn das Ding eine Gruppierung ist -> durchiterieren
- SdrObjListIter* pGroupIterator = NULL;
- if (pCurrent->IsGroupObject())
- {
- pGroupIterator = new SdrObjListIter(*pCurrent->GetSubList());
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- }
-
- Reference< XInterface > xNormalizedObject( _rxObject, UNO_QUERY );
- while (pCurrent)
- {
- if (pCurrent->IsUnoObj())
- {
- Reference< XInterface > xCurrentNormalized( static_cast< SdrUnoObj* >( pCurrent )->GetUnoControlModel(), UNO_QUERY );
- if ( xCurrentNormalized == xNormalizedObject )
- break;
- }
-
- if (pGroupIterator) // ich iteriere gerade durch eine Gruppe von Controls
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- else
- pCurrent = NULL;
- }
- delete pGroupIterator;
+ SdrObject* pCurrent = aPageIter.Next();
+ pFormObject = FmFormObj::GetFormObject( pCurrent );
+ if ( !pFormObject )
+ continue;
- if (pCurrent)
- {
- pFound = (SdrUnoObj*)pCurrent;
+ Reference< XInterface > xCurrentNormalized( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( xCurrentNormalized.get() == xNormalizedObject.get() )
break;
- }
+
+ pFormObject = NULL;
}
- if (!pFound)
+ if ( !pFormObject )
return false;
::rtl::OUString sNewName( getServiceNameByControlType( nObjectTypes[ lookupSlot ] ) );
@@ -1059,7 +1044,7 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
if (!xNewModel.is())
return false;
- Reference< XControlModel> xOldModel(pFound->GetUnoControlModel());
+ Reference< XControlModel> xOldModel( pFormObject->GetUnoControlModel() );
Reference< XServiceInfo> xModelInfo(xOldModel, UNO_QUERY);
// Properties uebertragen
@@ -1135,8 +1120,8 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
}
// neues Model setzen
- pFound->SetChanged();
- pFound->SetUnoControlModel(xNewModel);
+ pFormObject->SetChanged();
+ pFormObject->SetUnoControlModel(xNewModel);
// transfer script events
// (do this _after_ SetUnoControlModel as we need the new (implicitly created) control)
@@ -1198,7 +1183,7 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
FmFormModel* pModel = m_pShell->GetFormModel();
DBG_ASSERT(pModel != NULL, "FmXFormShell::executeControlConversionSlot: my shell has no model !");
if (pModel)
- pModel->AddUndo(new FmUndoModelReplaceAction(*pModel, pFound, xOldModel));
+ pModel->AddUndo(new FmUndoModelReplaceAction(*pModel, pFormObject, xOldModel));
return true;
}
@@ -1757,6 +1742,19 @@ void FmXFormShell::ExecuteFormSlot( sal_Int32 _nSlot )
}
//------------------------------------------------------------------------------
+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 );
+}
+
+//------------------------------------------------------------------------------
void FmXFormShell::setActiveController( const Reference< XFormController>& xController, sal_Bool _bNoSaveOldContent )
{
if ( impl_checkDisposed() )
@@ -1811,7 +1809,7 @@ void FmXFormShell::setActiveController( const Reference< XFormController>& xCont
{
m_bSetFocus = sal_True;
if ( m_aActiveControllerFeatures->isModifiedRow() )
- {
+ {
sal_Bool bIsNew = m_aActiveControllerFeatures->isInsertionRow();
sal_Bool bResult = m_aActiveControllerFeatures->commitCurrentRecord();
if ( !bResult && m_bSetFocus )
@@ -1820,7 +1818,7 @@ void FmXFormShell::setActiveController( const Reference< XFormController>& xCont
// current control
Reference< XWindow > xWindow( m_xActiveController->getCurrentControl(), UNO_QUERY );
if ( xWindow.is() )
- xWindow->setFocus();
+ xWindow->setFocus();
m_bInActivate = sal_False;
return;
}
@@ -1838,20 +1836,17 @@ void FmXFormShell::setActiveController( const Reference< XFormController>& xCont
stopListening();
+ impl_switchActiveControllerListening( false );
+
m_aActiveControllerFeatures.dispose();
m_xActiveController = xController;
if ( m_xActiveController.is() )
m_aActiveControllerFeatures.assign( m_xActiveController );
- if ( m_xActiveController.is() )
- {
- // set eventlistener to know when it is disposed
- Reference< ::com::sun::star::lang::XComponent> xComp(m_xActiveController, UNO_QUERY);
- if (xComp.is())
- xComp->addEventListener((XEventListener*)(XPropertyChangeListener*)this);
+ impl_switchActiveControllerListening( true );
- m_xActiveForm = getInternalForm(Reference< XForm>(m_xActiveController->getModel(), UNO_QUERY));
- }
+ if ( m_xActiveController.is() )
+ m_xActiveForm = getInternalForm( Reference< XForm >( m_xActiveController->getModel(), UNO_QUERY ) );
else
m_xActiveForm = NULL;
@@ -2172,9 +2167,9 @@ IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere)
m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
m_pShell->GetFormView()->MarkObj(pObject, m_pShell->GetFormView()->GetSdrPageView());
- DBG_ASSERT(pObject->IsUnoObj(), "FmXFormShell::OnFoundData : ungueltiges Control !");
- Reference< XControlModel> xControlModel( ((SdrUnoObj*)pObject)->GetUnoControlModel());
- DBG_ASSERT(xControlModel.is(), "FmXFormShell::OnFoundData : ungueltiges Control !");
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
+ Reference< XControlModel > xControlModel( pFormObject ? pFormObject->GetUnoControlModel() : Reference< XControlModel >() );
+ DBG_ASSERT( xControlModel.is(), "FmXFormShell::OnFoundData: invalid control!" );
// disable the permanent cursor for the last grid we found a record
if (m_xLastGridFound.is() && (m_xLastGridFound != xControlModel))
@@ -2287,157 +2282,131 @@ IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextIn
FmFormPage* pCurrentPage = m_pShell->GetCurPage();
DBG_ASSERT(pCurrentPage!=NULL, "FmXFormShell::OnSearchContextRequest : no page !");
// alle Sdr-Controls dieser Seite durchsuchen ...
- ::rtl::OUString sControlSource, sCompareString,aName;
- for (sal_Int32 i=0; i<(sal_Int32)pCurrentPage->GetObjCount(); ++i)
+ ::rtl::OUString sControlSource, aName;
+
+ SdrObjListIter aPageIter( *pCurrentPage );
+ while ( aPageIter.IsMore() )
{
- SdrObject* pCurrent = pCurrentPage->GetObj(i);
+ SdrObject* pCurrent = aPageIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pCurrent );
+ // note that in case pCurrent is a virtual object, pFormObject points to the referenced object
- // wenn das Ding eine Gruppierung ist -> durchiterieren
- SdrObjListIter* pGroupIterator = NULL;
- if (pCurrent->IsGroupObject())
- {
- pGroupIterator = new SdrObjListIter(*pCurrent->GetSubList());
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- }
+ if ( !pFormObject )
+ continue;
- while (pCurrent)
- {
- if (pCurrent->IsUnoObj())
- {
- // das Model zum aktuellen Object ...
- Reference< XControlModel> xControlModel( ((SdrUnoObj*)pCurrent)->GetUnoControlModel());
- DBG_ASSERT(xControlModel.is(), "FmXFormShell::OnSearchContextRequest : invalid objects !");
- // ... als FormComponent
- Reference< XFormComponent> xCurrentAsFormComponent(xControlModel, UNO_QUERY);
- if (!xCurrentAsFormComponent.is())
- {
- if (pGroupIterator) // ich iteriere gerade durch eine Gruppe von Controls
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- else
- pCurrent = NULL;
- 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;
- // gehoert diese FormComponent ueberhaupt zu der Form, um die es geht ?
- Reference< XInterface> xParentOfCurrent( xCurrentAsFormComponent->getParent());
- if (xParentOfCurrent != xForm) // vergleich fuehrt zu richtigem Ergebnis, seit TF_ONE
- {
- if (pGroupIterator) // ich iteriere gerade durch eine Gruppe von Controls
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- else
- pCurrent = NULL;
- 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(xCurrentAsFormComponent);
- 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)
+ // ... 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> xCurrent( iter.Next());
- while (xCurrent.is())
+ Reference< XInterface > xSearchable( iter.Next() );
+ while ( xSearchable.is() )
+ {
+ 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
{
- sControlSource = iter.getCurrentValue();
- if (sControlSource == sCompareString)
- { // 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 !");
+ if (!xGridPeer.is())
+ break;
+
+ Reference< XIndexAccess> xPeerContainer(xGridPeer, UNO_QUERY);
+ if (!xPeerContainer.is())
+ break;
+
+ 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 !");
- Reference< XGridPeer> xGridPeer(xControlBehindModel->getPeer(), UNO_QUERY);
- do
+ 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))
{
- if (!xGridPeer.is())
- break;
+ strFieldList += aName.getStr();
+ strFieldList += ';';
- Reference< XIndexAccess> xPeerContainer(xGridPeer, UNO_QUERY);
- if (!xPeerContainer.is())
- break;
+ sFieldDisplayNames += ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_LABEL)).getStr();
+ sFieldDisplayNames += ';';
- 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 !");
+ pfmscContextInfo->arrFields.push_back(xCurrentColumn);
- 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))
- {
- strFieldList += aName.getStr();
- strFieldList += ';';
-
- sFieldDisplayNames += ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_LABEL)).getStr();
- sFieldDisplayNames += ';';
-
- pfmscContextInfo->arrFields.push_back(xCurrentColumn);
-
- // 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());
- }
- }
- } while (sal_False);
+ // 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());
+ }
}
- else
+ } while (sal_False);
+ }
+ else
+ {
+ if (sControlSource.getLength() && xValidFormFields->hasByName(sControlSource))
+ {
+ // jetzt brauche ich das Control zum SdrObject
+ if (!xControlBehindModel.is())
{
- if (sControlSource.getLength() && xValidFormFields->hasByName(sControlSource))
- {
- // jetzt brauche ich das Control zum SdrObject
- if (!xControlBehindModel.is())
- {
- xControlBehindModel = GetControlFromModel(xControlModel);
- DBG_ASSERT(xControlBehindModel.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
- }
+ xControlBehindModel = GetControlFromModel(xControlModel);
+ DBG_ASSERT(xControlBehindModel.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
+ }
- if (IsSearchableControl(xControlBehindModel))
- { // alle Tests ueberstanden -> in die Liste mit aufnehmen
- strFieldList += sControlSource.getStr();
- strFieldList += ';';
+ if (IsSearchableControl(xControlBehindModel))
+ { // alle Tests ueberstanden -> in die Liste mit aufnehmen
+ strFieldList += sControlSource.getStr();
+ strFieldList += ';';
- // the label which should appear for the control :
- sFieldDisplayNames += getLabelName(Reference< XPropertySet>(xControlModel, UNO_QUERY)).getStr();
- sFieldDisplayNames += ';';
+ // the label which should appear for the control :
+ sFieldDisplayNames += getLabelName(Reference< XPropertySet>(xControlModel, UNO_QUERY)).getStr();
+ sFieldDisplayNames += ';';
- // das SdrObjekt merken (beschleunigt die Behandlung in OnFoundData)
- m_arrSearchedControls.C40_INSERT(SdrObject, pCurrent, m_arrSearchedControls.Count());
+ // das SdrObjekt merken (beschleunigt die Behandlung in OnFoundData)
+ m_arrSearchedControls.C40_INSERT(SdrObject, pCurrent, m_arrSearchedControls.Count());
- // die Nummer der Spalte (hier ein Dummy, nur fuer GridControls interesant)
- m_arrRelativeGridColumn.Insert(-1, m_arrRelativeGridColumn.Count());
+ // die Nummer der Spalte (hier ein Dummy, nur fuer GridControls interesant)
+ m_arrRelativeGridColumn.Insert(-1, m_arrRelativeGridColumn.Count());
- // und fuer die formatierte Suche ...
- pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControlBehindModel, UNO_QUERY));
- }
- }
+ // und fuer die formatierte Suche ...
+ pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControlBehindModel, UNO_QUERY));
}
-
- xCurrent = iter.Next();
}
}
- if (pGroupIterator) // ich iteriere gerade durch eine Gruppe von Controls
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
- else
- pCurrent = NULL;
+ xSearchable = iter.Next();
}
- delete pGroupIterator;
}
+
strFieldList.EraseTrailingChars(';');
sFieldDisplayNames.EraseTrailingChars(';');
diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx
index 3aaa8d73f65e..8c8f787690fd 100644
--- a/svx/source/form/fmtextcontrolshell.cxx
+++ b/svx/source/form/fmtextcontrolshell.cxx
@@ -30,8 +30,20 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
-#include "fmtextcontrolshell.hxx"
+
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "fmtextcontroldialogs.hxx"
#include "fmtextcontrolfeature.hxx"
+#include "fmtextcontrolshell.hxx"
+#include "svx/crsditem.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/editeng.hxx"
+#include "svx/eeitem.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/scriptspaceitem.hxx"
+#include "svx/svxids.hrc"
+#include "svx/udlnitem.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -42,48 +54,28 @@
#include <com/sun/star/awt/XFocusListener.hpp>
#include <com/sun/star/awt/XMouseListener.hpp>
/** === end UNO includes === **/
-#include <sfx2/request.hxx>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <sfx2/app.hxx>
#include <sfx2/bindings.hxx>
-#include <sfx2/msgpool.hxx>
#include <sfx2/dispatch.hxx>
-#include <sfx2/sfxuno.hxx>
-#include <sfx2/viewfrm.hxx>
+#include <sfx2/msgpool.hxx>
#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
#include <sfx2/sfxuno.hxx>
-
-#include <sfx2/app.hxx>
-#include <vcl/outdev.hxx>
-#include <vcl/msgbox.hxx>
-#include <svtools/languageoptions.hxx>
-#include <svtools/intitem.hxx>
-#include <svtools/whiter.hxx>
+#include <sfx2/viewfrm.hxx>
#include <svtools/eitem.hxx>
+#include <svtools/intitem.hxx>
#include <svtools/itempool.hxx>
+#include <svtools/languageoptions.hxx>
#include <svtools/stringtransfer.hxx>
+#include <svtools/whiter.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
-#include <comphelper/componentcontext.hxx>
-#include <comphelper/processfactory.hxx>
-#include <cppuhelper/implbase1.hxx>
-
-#ifndef _SVX_SVXIDS_HRC
-#include <svx/svxids.hrc>
-#endif
-#include <svx/fmglob.hxx>
-#include <svx/dialmgr.hxx>
-#ifndef _SVX_FMRESIDS_HRC
-#include "fmresids.hrc"
-#endif
-#include <svx/editeng.hxx>
-#include <svx/eeitem.hxx>
-#ifndef _SVX_FMPROP_HRC
-#include "fmprop.hrc"
-#endif
-#include "fmtextcontroldialogs.hxx"
-#include <svx/scriptspaceitem.hxx>
-
-#include <svx/udlnitem.hxx>
-#include <svx/crsditem.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/outdev.hxx>
#include <vos/mutex.hxx>
#include <memory>
@@ -227,7 +219,7 @@ namespace svx
}
catch( const Exception& )
{
- DBG_ERROR( "FmFocusListenerAdapter::FmFocusListenerAdapter: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
}
osl_decrementInterlockedCount( &m_refCount );
@@ -324,7 +316,7 @@ namespace svx
}
catch( const Exception& )
{
- DBG_ERROR( "FmMouseListenerAdapter::FmMouseListenerAdapter: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
}
osl_decrementInterlockedCount( &m_refCount );
@@ -517,7 +509,7 @@ namespace svx
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "lcl_determineReadOnly: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return bIsReadOnlyModel;
}
@@ -536,7 +528,7 @@ namespace svx
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "lcl_getWindow: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return pWindow;
@@ -563,7 +555,7 @@ namespace svx
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "lcl_isRichText: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return bIsRichText;
}
@@ -797,7 +789,7 @@ namespace svx
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "FmTextControlShell::executeSelectAll: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return false; // not handled
}
@@ -839,7 +831,7 @@ namespace svx
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "FmTextControlShell::executeClipboardSlot: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return false; // not handled
}
@@ -1085,18 +1077,18 @@ namespace svx
if ( !_rxController.is() )
return;
+ // sometimes, a form controller notifies activations, even if it's already activated
+ if ( m_xActiveController == _rxController )
+ return;
+
try
{
- if ( m_xActiveController == _rxController )
- // sometimes, a form controller notifies activations, even if it's already activated
- return;
-
startControllerListening( _rxController );
controlActivated( _rxController->getCurrentControl() );
}
catch( const Exception& )
{
- DBG_ERROR( "FmTextControlShell::formActivated: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
}
@@ -1119,11 +1111,11 @@ namespace svx
//------------------------------------------------------------------------
void FmTextControlShell::startControllerListening( const Reference< XFormController >& _rxController )
{
- DBG_ASSERT( _rxController.is(), "FmTextControlShell::startControllerListening: invalid controller!" );
+ OSL_PRECOND( _rxController.is(), "FmTextControlShell::startControllerListening: invalid controller!" );
if ( !_rxController.is() )
return;
- DBG_ASSERT( !isControllerListening(), "FmTextControlShell::startControllerListening: already listening!" );
+ OSL_PRECOND( !isControllerListening(), "FmTextControlShell::startControllerListening: already listening!" );
if ( isControllerListening() )
stopControllerListening( );
DBG_ASSERT( !isControllerListening(), "FmTextControlShell::startControllerListening: inconsistence!" );
@@ -1143,7 +1135,7 @@ namespace svx
}
catch( const Exception& )
{
- DBG_ERROR( "FmTextControlShell::startControllerListening: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
m_xActiveController = _rxController;
@@ -1152,7 +1144,7 @@ namespace svx
//------------------------------------------------------------------------
void FmTextControlShell::stopControllerListening( )
{
- DBG_ASSERT( isControllerListening(), "FmTextControlShell::stopControllerListening: inconsistence!" );
+ OSL_PRECOND( isControllerListening(), "FmTextControlShell::stopControllerListening: inconsistence!" );
// dispose all listeners associated with the controls of the active controller
for ( FocusListenerAdapters::iterator aLoop = m_aControlObservers.begin();
@@ -1207,7 +1199,6 @@ namespace svx
void FmTextControlShell::controlDeactivated( )
{
DBG_ASSERT( IsActiveControl(), "FmTextControlShell::controlDeactivated: no active control!" );
- OSL_TRACE( "deactivated: %X", m_xActiveControl.get() );
m_bActiveControl = false;
@@ -1217,8 +1208,6 @@ namespace svx
//------------------------------------------------------------------------
void FmTextControlShell::controlActivated( const Reference< XControl >& _rxControl )
{
- OSL_TRACE( "activated : %X", _rxControl.get() );
-
// ensure that all knittings with the previously active control are lost
if ( m_xActiveControl.is() )
implClearActiveControlRef();
diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx
index 66bb70881252..d3b83f7c7676 100644
--- a/svx/source/form/fmtools.cxx
+++ b/svx/source/form/fmtools.cxx
@@ -288,7 +288,7 @@ sal_Bool searchElement(const Reference< ::com::sun::star::container::XIndexAcces
xCont->getByIndex(i) >>= xComp;
if (xComp.is())
{
- if (((XInterface *)xElement.get()) == (XInterface*)xComp.get())
+ if ( xElement == xComp )
return sal_True;
else
{
@@ -1120,82 +1120,3 @@ sal_Bool isRowSetAlive(const Reference< XInterface >& _rxRowSet)
return bIsAlive;
}
-// -----------------------------------------------------------------------------
-namespace
-{
- //....................................................................
- static Sequence< PropertyValue > lcl_getDataSourceIndirectProperties( const Reference< XPropertySet >& _rxControlModel,
- const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW(())
- {
- OSL_PRECOND( _rxControlModel.is(), "lcl_getDataSourceIndirectProperties: invalid model!" );
-
- Sequence< PropertyValue > aInfo;
- try
- {
- Reference< XChild > xChild( _rxControlModel, UNO_QUERY );
- Reference< XPropertySet > xForm;
- if ( xChild.is() )
- xForm = xForm.query( xChild->getParent() );
-
- if ( Reference< XGridColumnFactory >( xForm, UNO_QUERY ).is() )
- { // hmm. the model is a grid column, in real
- xChild = xChild.query( xForm );
- xForm = xForm.query( xChild->getParent() );
- }
-
- OSL_ENSURE( xForm.is(), "lcl_getDataSourceIndirectProperties: could not determine the form!" );
- if ( !xForm.is() )
- return aInfo;
- ::rtl::OUString sDataSourceName;
- xForm->getPropertyValue( FM_PROP_DATASOURCE ) >>= sDataSourceName;
-
- Reference< XPropertySet > xDsProperties;
- if ( sDataSourceName.getLength() )
- xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rxORB ) );
- if ( xDsProperties.is() )
- xDsProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Info" ) ) ) >>= aInfo;
- }
- catch( const Exception& )
- {
- OSL_ENSURE( sal_False, "lcl_getDataSourceIndirectProperties: caught an exception!" );
- }
- return aInfo;
- }
-}
-
-//------------------------------------------------------------------------------
-void initializeTextFieldLineEnds( const Reference< XPropertySet >& _rxModel, const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW(())
-{
- OSL_PRECOND( _rxModel.is(), "initializeTextFieldLineEnds: invalid model!" );
- if ( !_rxModel.is() )
- return;
-
- try
- {
- Reference< XPropertySetInfo > xInfo = _rxModel->getPropertySetInfo();
- if ( !xInfo.is() || !xInfo->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
- return;
-
- // let's see if the data source which the form belongs to (if any)
- // has a setting for the preferred line end format
- sal_Bool bDosLineEnds = sal_False;
- Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, _rxORB );
- const PropertyValue* pInfo = aInfo.getConstArray();
- const PropertyValue* pInfoEnd = pInfo + aInfo.getLength();
- for ( ; pInfo != pInfoEnd; ++pInfo )
- {
- if ( pInfo->Name.equalsAscii( "PreferDosLikeLineEnds" ) )
- {
- pInfo->Value >>= bDosLineEnds;
- break;
- }
- }
-
- sal_Int16 nLineEndFormat = bDosLineEnds ? LineEndFormat::CARRIAGE_RETURN_LINE_FEED : LineEndFormat::LINE_FEED;
- _rxModel->setPropertyValue( FM_PROP_LINEENDFORMAT, makeAny( nLineEndFormat ) );
- }
- catch( const Exception& )
- {
- OSL_ENSURE( sal_False, "initializeTextFieldLineEnds: caught an exception!" );
- }
-}
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx
index 6f1afa5f571a..42bc91c53a15 100644
--- a/svx/source/form/fmundo.cxx
+++ b/svx/source/form/fmundo.cxx
@@ -306,47 +306,59 @@ void FmXUndoEnvironment::Inserted(FmFormObj* pObj)
Reference< XFormComponent > xContent(xModel, UNO_QUERY);
if (xContent.is() && pObj->GetPage())
{
- // Komponente gehoert noch keiner Form an
+ // if the component doesn't belong to a form, yet, find one to insert into
if (!xContent->getParent().is())
{
- // Einfuegen in den Parent falls noetig
- Reference< XIndexContainer > xParent = pObj->GetParent();
- // Suchen des Form in der aktuellen Page
- Reference< XIndexContainer > xForm;
- Reference< XInterface > xIface(xParent, UNO_QUERY);
- Reference< XIndexAccess > xForms(((FmFormPage*)pObj->GetPage())->GetForms(), UNO_QUERY);;
-
- if (searchElement(xForms, xIface))
- xForm = xParent;
- else
+ try
{
- Reference< XForm > xTemp = ((FmFormPage*)pObj->GetPage())->GetImpl()->placeInFormComponentHierarchy(xContent);
- xForm = Reference< XIndexContainer > (xTemp, UNO_QUERY);
- }
+ Reference< XIndexContainer > xObjectParent = pObj->GetOriginalParent();
- // Position des Elements
- sal_Int32 nPos = xForm->getCount();
- if ((XIndexContainer*)xForm.get() == (XIndexContainer*)xParent.get())
- {
- if (nPos > pObj->GetPos())
- nPos = xForm->getCount();
- }
+ FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pObj->GetPage() );
+ Reference< XIndexAccess > xForms( rPage.GetForms(), UNO_QUERY_THROW );
+
+ Reference< XIndexContainer > xNewParent;
+ Reference< XForm > xForm;
+ sal_Int32 nPos = -1;
+ if ( searchElement( xForms, xObjectParent ) )
+ {
+ // the form which was the parent of the object when it was removed is still
+ // part of the form component hierachy of the current page
+ xNewParent = xObjectParent;
+ xForm.set( xNewParent, UNO_QUERY_THROW );
+ nPos = ::std::min( pObj->GetOriginalIndex(), xNewParent->getCount() );
+ }
+ else
+ {
+ xForm.set( rPage.GetImpl()->findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
+ xNewParent.set( xForm, UNO_QUERY_THROW );
+ nPos = xNewParent->getCount();
+ }
- xForm->insertByIndex(nPos, makeAny(xContent));
+ rPage.GetImpl()->setUniqueName( xContent, xForm );
+ xNewParent->insertByIndex( nPos, makeAny( xContent ) );
- Reference< XEventAttacherManager > xManager(xForm, UNO_QUERY);
- if (xManager.is())
- xManager->registerScriptEvents(nPos, pObj->GetEvents());
+ Reference< XEventAttacherManager > xManager( xNewParent, UNO_QUERY_THROW );
+ xManager->registerScriptEvents( nPos, pObj->GetOriginalEvents() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
// FormObject zuruecksetzen
- pObj->SetObjEnv(Reference< XIndexContainer > ());
+ pObj->ClearObjEnv();
}
}
//------------------------------------------------------------------
void FmXUndoEnvironment::Removed(SdrObject* pObj)
{
+ if ( pObj->IsVirtualObj() )
+ // for virtual objects, we've already been notified of the removal of the master
+ // object, which is sufficient here
+ return;
+
if (pObj->GetObjInventor() == FmFormInventor)
{
FmFormObj* pFormObj = PTR_CAST(FmFormObj, pObj);
@@ -398,6 +410,7 @@ void FmXUndoEnvironment::Removed(FmFormObj* pObj)
}
catch(Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
@@ -492,8 +505,9 @@ void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt)
Any aCurrentControlSource = xSet->getPropertyValue(FM_PROP_CONTROLSOURCE);
aNewEntry.bHasEmptyControlSource = !aCurrentControlSource.hasValue() || (::comphelper::getString(aCurrentControlSource).getLength() == 0);
}
- catch(Exception&)
+ catch(const Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
aSetPos = pCache->insert(PropertySetInfoCache::value_type(xSet,aNewEntry)).first;
@@ -532,8 +546,9 @@ void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt)
aNewEntry.bIsValueProperty = (sControlSourceProperty.equals(evt.PropertyName));
}
}
- catch(Exception&)
+ catch(const Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
// insert the new entry
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index af0bee21c9bf..2b5095473067 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -56,25 +56,15 @@
#include "svditer.hxx"
#include <svx/svdpagv.hxx>
#include <svx/svdogrp.hxx>
-#ifndef _FM_FMVIEW_HXX
#include <svx/fmview.hxx>
-#endif
-#ifndef _FM_FMMODEL_HXX
#include <svx/fmmodel.hxx>
-#endif
-#ifndef _FM_FMPAGE_HXX
#include <svx/fmpage.hxx>
-#endif
#include <svx/fmshell.hxx>
-#ifndef _SVX_FMPGEIMP_HXX
#include "fmpgeimp.hxx"
-#endif
#include "fmtools.hxx"
#include "fmshimp.hxx"
#include "fmservs.hxx"
-#ifndef _SVX_FMPROP_HRC
#include "fmprop.hrc"
-#endif
#include "fmundo.hxx"
#include <svx/dataaccessdescriptor.hxx>
#include <comphelper/processfactory.hxx>
@@ -85,6 +75,7 @@
#include <com/sun/star/form/FormComponentType.hpp>
#include <vcl/svapp.hxx>
#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
#include <vcl/stdtext.hxx>
#include <svx/fmglob.hxx>
#include <svx/sdrpagewindow.hxx>
@@ -95,7 +86,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdb;
-using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::form;
@@ -445,97 +435,6 @@ void FmFormView::DeactivateControls(SdrPageView* pPageView)
}
//------------------------------------------------------------------------
-void FmFormView::ObjectCreated(FmFormObj* pObj)
-{
- // it is valid that the form shell's forms collection is not initialized, yet
- if ( pFormShell && pFormShell->GetImpl() )
- pFormShell->GetImpl()->UpdateForms( sal_True );
-
- Reference< XPropertySet > xSet( pObj->GetUnoControlModel(), UNO_QUERY );
- if ( !xSet.is() )
- return;
-
- // some initial property defaults
- sal_Int16 nClassId = pImpl->implInitializeNewControlModel( xSet, pObj );
-
- if ( !pFormShell->GetImpl()->GetWizardUsing() )
- return;
-
- // #i31958# don't call wizards in XForms mode
- if ( pFormShell->GetImpl()->isEnhancedForm() )
- return;
-
- // #i46898# no wizards if there is no Base installed - currently, all wizards are
- // database related
- if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
- return;
-
- Reference< XChild > xChild(xSet, UNO_QUERY);
- Reference< XRowSet > xForm(xChild->getParent(), UNO_QUERY);
- String sWizardName;
- Any aObj;
-
- switch (nClassId)
- {
- case FormComponentType::GRIDCONTROL:
- sWizardName.AssignAscii("com.sun.star.sdb.GridControlAutoPilot");
- aObj <<= xChild;
- break;
- case FormComponentType::LISTBOX:
- case FormComponentType::COMBOBOX:
- sWizardName.AssignAscii("com.sun.star.sdb.ListComboBoxAutoPilot");
- aObj <<= xChild;
- break;
- case FormComponentType::GROUPBOX:
- sWizardName.AssignAscii("com.sun.star.sdb.GroupBoxAutoPilot");
- aObj <<= xChild;
- break;
- }
-
- if (sWizardName.Len() != 0)
- {
- // build the argument list
- Sequence< Any > aWizardArgs(1);
- // the object affected
- aWizardArgs[0] = makeAny(PropertyValue(
- ::rtl::OUString::createFromAscii("ObjectModel"),
- 0,
- makeAny(xChild),
- PropertyState_DIRECT_VALUE
- ));
-
- // create the wizard object
- Reference< XExecutableDialog > xWizard;
- try
- {
- Reference< XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
- xWizard = Reference< XExecutableDialog >(
- ::comphelper::getProcessServiceFactory()->createInstanceWithArguments(sWizardName, aWizardArgs),
- UNO_QUERY);
- }
- catch(Exception&)
- {
- }
- if (!xWizard.is())
- {
- ShowServiceNotAvailableError(NULL, sWizardName, sal_True);
- return;
- }
-
- // execute the wizard
- try
- {
- xWizard->execute();
- }
- catch(Exception&)
- {
- DBG_ERROR("FmFormView::ObjectCreated: could not execute the AutoPilot!");
- // TODO: real error handling
- }
- }
-}
-
-//------------------------------------------------------------------------
SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
{
return pImpl->implCreateFieldControl( _rColumnDescriptor );
@@ -643,7 +542,7 @@ BOOL FmFormView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
}
}
}
- // Alt-RETURN alone enters shows the properties of the selection
+ // Alt-RETURN alone shows the properties of the selection
if ( pFormShell
&& pFormShell->GetImpl()
&& !rKeyCode.IsShift()
@@ -689,37 +588,39 @@ BOOL FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin )
// -----------------------------------------------------------------------------
FmFormObj* FmFormView::getMarkedGrid() const
{
- FmFormObj* pObj = NULL;
+ FmFormObj* pFormObject = NULL;
const SdrMarkList& rMarkList = GetMarkedObjectList();
if ( 1 == rMarkList.GetMarkCount() )
{
SdrMark* pMark = rMarkList.GetMark(0);
if ( pMark )
{
- pObj = PTR_CAST(FmFormObj,pMark->GetMarkedSdrObj());
- if ( pObj )
+ pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() );
+ if ( pFormObject )
{
- Reference<XServiceInfo> xServInfo(pObj->GetUnoControlModel(),UNO_QUERY);
- if ( !xServInfo.is() || !xServInfo->supportsService(FM_SUN_COMPONENT_GRIDCONTROL) )
- pObj = NULL;
+ Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) )
+ pFormObject = NULL;
}
}
}
- return pObj;
+ return pFormObject;
}
// -----------------------------------------------------------------------------
-void FmFormView::createControlLabelPair(SdrView* _pView,OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
+void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
- sal_uInt16 _nObjID, const ::rtl::OUString& _rFieldPostfix,UINT32 _nInventor,UINT16 _nIndent,
- SdrPage* _pLabelPage,SdrPage* _pPage,SdrModel* _pModel,
- SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl)
+ sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID,
+ SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl )
{
- FmXFormView::createControlLabelPair(_pView,_pOutDev,_nXOffsetMM, _nYOffsetMM,
- _rxField, _rxNumberFormats,
- _nObjID, _rFieldPostfix,_nInventor,_nIndent,
- _pLabelPage,_pPage,_pModel,
- _rpLabel, _rpControl);
+ FmXFormView::createControlLabelPair(
+ ::comphelper::getProcessServiceFactory(),
+ *_pOutDev, _nXOffsetMM, _nYOffsetMM,
+ _rxField, _rxNumberFormats,
+ _nControlObjectID, _rFieldPostfix, _nInventor, _nLabelObjectID,
+ _pLabelPage, _pControlPage, _pModel,
+ _rpLabel, _rpControl
+ );
}
// -----------------------------------------------------------------------------
Reference< XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index 37b50a931299..065ac0b94905 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -30,27 +30,40 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
-#include <fmctrler.hxx>
-#include "fmvwimp.hxx"
-#include <svx/fmglob.hxx>
-#include <svx/dialmgr.hxx>
-#ifndef _SVX_FMRESIDS_HRC
-#include "fmresids.hrc"
-#endif
+
+#include "fmctrler.hxx"
+#include "fmdocumentclassification.hxx"
#include "fmobj.hxx"
-#include <svx/svdogrp.hxx>
-#include "svditer.hxx"
+#include "fmpgeimp.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
#include "fmservs.hxx"
-#include "fmdocumentclassification.hxx"
-#include "fmcontrollayout.hxx"
+#include "fmshimp.hxx"
+#include "fmtools.hxx"
+#include "fmundo.hxx"
+#include "fmvwimp.hxx"
+#include "formcontrolfactory.hxx"
+#include "sdrpaintwindow.hxx"
+#include "svditer.hxx"
+#include "svx/dataaccessdescriptor.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/fmmodel.hxx"
+#include "svx/fmpage.hxx"
+#include "svx/fmshell.hxx"
+#include "svx/fmview.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include "svx/svdogrp.hxx"
+#include "svx/svdpagv.hxx"
+#include "xmlexchg.hxx"
/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp>
#include <com/sun/star/form/XLoadable.hpp>
#include <com/sun/star/awt/VisualEffect.hpp>
-#include <com/sun/star/awt/ScrollBarOrientation.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/util/XNumberFormats.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
@@ -71,31 +84,16 @@
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
/** === end UNO includes === **/
-#include <svx/fmmodel.hxx>
-#include "fmundo.hxx"
-#include <svx/fmpage.hxx>
-#include "fmpgeimp.hxx"
-#include <svx/fmview.hxx>
-#include <svx/fmshell.hxx>
-#include "fmshimp.hxx"
-#include "fmtools.hxx"
-#ifndef _SVX_FMPROP_HRC
-#include "fmprop.hrc"
-#endif
-#include <vcl/msgbox.hxx>
-#include <svx/svdpagv.hxx>
-#include "xmlexchg.hxx"
-#include <svx/dataaccessdescriptor.hxx>
-#include <comphelper/extract.hxx>
+
#include <comphelper/enumhelper.hxx>
-#include <comphelper/property.hxx>
+#include <comphelper/extract.hxx>
#include <comphelper/numbers.hxx>
-#include <svtools/syslocale.hxx>
+#include <comphelper/property.hxx>
+#include <svtools/moduleoptions.hxx>
#include <tools/diagnose_ex.h>
-#include <svx/sdrpagewindow.hxx>
-#include "sdrpaintwindow.hxx"
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
#include <algorithm>
@@ -113,6 +111,7 @@ using namespace ::com::sun::star::util;
using namespace ::com::sun::star::script;
using namespace ::com::sun::star::style;
using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ui::dialogs;
using namespace ::comphelper;
using namespace ::svxform;
using namespace ::svx;
@@ -159,9 +158,9 @@ public:
//========================================================================
DBG_NAME(FmXPageViewWinRec)
//------------------------------------------------------------------------
-FmXPageViewWinRec::FmXPageViewWinRec(const Reference< XMultiServiceFactory >& _rxORB, const SdrPageWindow& _rWindow, FmXFormView* _pViewImpl )
+FmXPageViewWinRec::FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext, const SdrPageWindow& _rWindow, FmXFormView* _pViewImpl )
: m_xControlContainer( _rWindow.GetControlContainer() ),
- m_xORB( _rxORB ),
+ m_aContext( _rContext ),
m_pViewImpl( _pViewImpl ),
m_pWindow( dynamic_cast< Window* >( &_rWindow.GetPaintWindow().GetOutputDevice() ) )
{
@@ -215,7 +214,6 @@ void FmXPageViewWinRec::dispose()
xComp->dispose();
}
m_aControllerList.clear(); // this call deletes the formcontrollers
- m_xORB = NULL;
}
@@ -310,7 +308,7 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FmXForm
Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY);
// create a form controller
- FmXFormController* pController = new FmXFormController( m_xORB,m_pViewImpl->getView(), m_pWindow );
+ FmXFormController* pController = new FmXFormController( m_aContext.getLegacyServiceFactory(), m_pViewImpl->getView(), m_pWindow );
Reference< XFormController > xController( pController );
Reference< XInteractionHandler > xHandler;
@@ -406,14 +404,14 @@ void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm )
}
//------------------------------------------------------------------------
-FmXFormView::FmXFormView(const Reference< XMultiServiceFactory >& _xORB,
- FmFormView* _pView)
- :m_xORB( _xORB )
+FmXFormView::FmXFormView(const ::comphelper::ComponentContext& _rContext, FmFormView* _pView )
+ :m_aContext( _rContext )
,m_pMarkedGrid(NULL)
,m_pView(_pView)
,m_nActivationEvent(0)
,m_nErrorMessageEvent( 0 )
,m_nAutoFocusEvent( 0 )
+ ,m_nControlWizardEvent( 0 )
,m_pWatchStoredList( NULL )
,m_bFirstActivation( true )
,m_isTabOrderUpdateSuspended( false )
@@ -440,6 +438,12 @@ void FmXFormView::cancelEvents()
Application::RemoveUserEvent( m_nAutoFocusEvent );
m_nAutoFocusEvent = 0;
}
+
+ if ( m_nControlWizardEvent )
+ {
+ Application::RemoveUserEvent( m_nControlWizardEvent );
+ m_nControlWizardEvent = 0;
+ }
}
//------------------------------------------------------------------------
@@ -560,7 +564,7 @@ void FmXFormView::addWindow(const SdrPageWindow& rWindow)
Reference< XControlContainer > xCC = rWindow.GetControlContainer();
if ( xCC.is() && findWindow( xCC ) == m_aWinList.end())
{
- FmXPageViewWinRec *pFmRec = new FmXPageViewWinRec(m_xORB, rWindow, this);
+ FmXPageViewWinRec *pFmRec = new FmXPageViewWinRec( m_aContext, rWindow, this );
pFmRec->acquire();
m_aWinList.push_back(pFmRec);
@@ -818,17 +822,17 @@ namespace
SdrObjListIter aSdrObjectLoop( _rPage, IM_DEEPNOGROUPS );
while ( aSdrObjectLoop.IsMore() )
{
- const SdrUnoObj* pUnoObject = dynamic_cast< const SdrUnoObj* >( aSdrObjectLoop.Next() );
- if ( !pUnoObject )
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( aSdrObjectLoop.Next() );
+ if ( !pFormObject )
continue;
- Reference< XChild > xModel( pUnoObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XChild > xModel( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
Reference< XInterface > xModelParent( xModel->getParent(), UNO_QUERY_THROW );
if ( xNormalizedForm.get() != xModelParent.get() )
continue;
- pUnoObject->GetUnoControl( _rView, _rWindow );
+ pFormObject->GetUnoControl( _rView, _rWindow );
}
}
catch( const Exception& )
@@ -937,324 +941,142 @@ IMPL_LINK(FmXFormView, OnAutoFocus, void*, /*EMPTYTAG*/)
// -----------------------------------------------------------------------------
namespace
{
- /*
- ATTENTION!
- Broken for solaris? It seems that the old used template argument TYPE was already
- defined as a macro ... which expand to ... "TYPE "!?
- All platforms are OK - excepting Solaris. There the line "template< class TYPE >"
- was expanded to "template < class TYPE " where the closing ">" was missing.
- */
- #ifdef MYTYPE
- #error "Who defines the macro MYTYPE, which is used as template argument here?"
- #endif
-
- //....................................................................
- template< class MYTYPE >
- Reference< MYTYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
- {
- Reference< MYTYPE > xTypedNode( _rxModelNode, UNO_QUERY );
- if ( xTypedNode.is() )
- return xTypedNode;
- else
- {
- Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
- if ( xChild.is() )
- return getTypedModelNode< MYTYPE >( xChild->getParent() );
- else
- return NULL;
- }
- }
-
- //....................................................................
- static bool lcl_getDocumentDefaultStyleAndFamily( const Reference< XInterface >& _rxDocument, ::rtl::OUString& _rFamilyName, ::rtl::OUString& _rStyleName ) SAL_THROW(( Exception ))
- {
- bool bSuccess = true;
- Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
- if ( xDocumentSI.is() )
- {
- if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) )
- || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) )
- )
- {
- _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
- _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- }
- else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) )
- {
- _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) );
- _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
- }
- else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) )
- || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
- )
- {
- _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
- _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
- }
- else
- bSuccess = false;
- }
- return bSuccess;
- }
+}
- static const sal_Char* aCharacterAndParagraphProperties[] =
- {
- "CharFontName",
- "CharFontStyleName",
- "CharFontFamily",
- "CharFontCharSet",
- "CharFontPitch",
- "CharColor",
- "CharEscapement",
- "CharHeight",
- "CharUnderline",
- "CharWeight",
- "CharPosture",
- "CharAutoKerning",
- "CharBackColor",
- "CharBackTransparent",
- "CharCaseMap",
- "CharCrossedOut",
- "CharFlash",
- "CharStrikeout",
- "CharWordMode",
- "CharKerning",
- "CharLocale",
- "CharKeepTogether",
- "CharNoLineBreak",
- "CharShadowed",
- "CharFontType",
- "CharStyleName",
- "CharContoured",
- "CharCombineIsOn",
- "CharCombinePrefix",
- "CharCombineSuffix",
- "CharEmphasize",
- "CharRelief",
- "RubyText",
- "RubyAdjust",
- "RubyCharStyleName",
- "RubyIsAbove",
- "CharRotation",
- "CharRotationIsFitToLine",
- "CharScaleWidth",
- "HyperLinkURL",
- "HyperLinkTarget",
- "HyperLinkName",
- "VisitedCharStyleName",
- "UnvisitedCharStyleName",
- "CharEscapementHeight",
- "CharNoHyphenation",
- "CharUnderlineColor",
- "CharUnderlineHasColor",
- "CharStyleNames",
- "CharHeightAsian",
- "CharWeightAsian",
- "CharFontNameAsian",
- "CharFontStyleNameAsian",
- "CharFontFamilyAsian",
- "CharFontCharSetAsian",
- "CharFontPitchAsian",
- "CharPostureAsian",
- "CharLocaleAsian",
- "ParaIsCharacterDistance",
- "ParaIsForbiddenRules",
- "ParaIsHangingPunctuation",
- "CharHeightComplex",
- "CharWeightComplex",
- "CharFontNameComplex",
- "CharFontStyleNameComplex",
- "CharFontFamilyComplex",
- "CharFontCharSetComplex",
- "CharFontPitchComplex",
- "CharPostureComplex",
- "CharLocaleComplex",
- "ParaAdjust",
- "ParaLineSpacing",
- "ParaBackColor",
- "ParaBackTransparent",
- "ParaBackGraphicURL",
- "ParaBackGraphicFilter",
- "ParaBackGraphicLocation",
- "ParaLastLineAdjust",
- "ParaExpandSingleWord",
- "ParaLeftMargin",
- "ParaRightMargin",
- "ParaTopMargin",
- "ParaBottomMargin",
- "ParaLineNumberCount",
- "ParaLineNumberStartValue",
- "PageDescName",
- "PageNumberOffset",
- "ParaRegisterModeActive",
- "ParaTabStops",
- "ParaStyleName",
- "DropCapFormat",
- "DropCapWholeWord",
- "ParaKeepTogether",
- "Setting",
- "ParaSplit",
- "Setting",
- "NumberingLevel",
- "NumberingRules",
- "NumberingStartValue",
- "ParaIsNumberingRestart",
- "NumberingStyleName",
- "ParaOrphans",
- "ParaWidows",
- "ParaShadowFormat",
- "LeftBorder",
- "RightBorder",
- "TopBorder",
- "BottomBorder",
- "BorderDistance",
- "LeftBorderDistance",
- "RightBorderDistance",
- "TopBorderDistance",
- "BottomBorderDistance",
- "BreakType",
- "DropCapCharStyleName",
- "ParaFirstLineIndent",
- "ParaIsAutoFirstLineIndent",
- "ParaIsHyphenation",
- "ParaHyphenationMaxHyphens",
- "ParaHyphenationMaxLeadingChars",
- "ParaHyphenationMaxTrailingChars",
- "ParaVertAlignment",
- "ParaUserDefinedAttributes",
- "NumberingIsNumber",
- "ParaIsConnectBorder",
- NULL
- };
+// -----------------------------------------------------------------------------
+void FmXFormView::onCreatedFormObject( FmFormObj& _rFormObject )
+{
+ FmFormShell* pShell = m_pView ? m_pView->GetFormShell() : NULL;
+ FmXFormShell* pShellImpl = pShell ? pShell->GetImpl() : NULL;
+ OSL_ENSURE( pShellImpl, "FmXFormView::onCreatedFormObject: no form shell!" );
+ if ( !pShellImpl )
+ return;
- //....................................................................
- static void lcl_initializeCharacterAttributes( const Reference< XPropertySet >& _rxModel )
- {
- // need to initialize the attributes from the "Default" style of the document we live in
+ // it is valid that the form shell's forms collection is not initialized, yet
+ pShellImpl->UpdateForms( sal_True );
- try
- {
- // the style family collection
- Reference< XStyleFamiliesSupplier > xSuppStyleFamilies = getTypedModelNode< XStyleFamiliesSupplier >( _rxModel.get() );
- Reference< XNameAccess > xStyleFamilies;
- if ( xSuppStyleFamilies.is() )
- xStyleFamilies = xSuppStyleFamilies->getStyleFamilies();
- OSL_ENSURE( xStyleFamilies.is(), "lcl_initializeCharacterAttributes: could not obtain the style families!" );
- if ( !xStyleFamilies.is() )
- return;
-
- // the names of the family, and the style - depends on the document type we live in
- ::rtl::OUString sFamilyName, sStyleName;
- bool bKnownDocumentType = lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies.get(), sFamilyName, sStyleName );
- OSL_ENSURE( bKnownDocumentType, "lcl_initializeCharacterAttributes: Huh? What document type is this?" );
- if ( !bKnownDocumentType )
- return;
+ m_xLastCreatedControlModel.set( _rFormObject.GetUnoControlModel(), UNO_QUERY );
+ if ( !m_xLastCreatedControlModel.is() )
+ return;
- // the concrete style
- Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY );
- Reference< XPropertySet > xStyle;
- if ( xStyleFamily.is() )
- xStyleFamily->getByName( sStyleName ) >>= xStyle;
- OSL_ENSURE( xStyle.is(), "lcl_initializeCharacterAttributes: could not retrieve the style!" );
- if ( !xStyle.is() )
- return;
+ // some initial property defaults
+ FormControlFactory aControlFactory( m_aContext );
+ aControlFactory.initializeControlModel( pShellImpl->getDocumentType(), _rFormObject );
- // transfer all properties which are described by the com.sun.star.style.
- Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo() );
- Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo() );
- OSL_ENSURE( xSourcePropInfo.is() && xDestPropInfo.is(), "lcl_initializeCharacterAttributes: no property set info!" );
- if ( !xSourcePropInfo.is() || !xDestPropInfo.is() )
- return;
+ if ( !pShellImpl->GetWizardUsing() )
+ return;
- ::rtl::OUString sPropertyName;
- const sal_Char** pCharacterProperty = aCharacterAndParagraphProperties;
- while ( *pCharacterProperty )
- {
- sPropertyName = ::rtl::OUString::createFromAscii( *pCharacterProperty );
+ // #i31958# don't call wizards in XForms mode
+ if ( pShellImpl->isEnhancedForm() )
+ return;
- if ( xSourcePropInfo->hasPropertyByName( sPropertyName ) && xDestPropInfo->hasPropertyByName( sPropertyName ) )
- _rxModel->setPropertyValue( sPropertyName, xStyle->getPropertyValue( sPropertyName ) );
+ // #i46898# no wizards if there is no Base installed - currently, all wizards are
+ // database related
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ return;
- ++pCharacterProperty;
- }
- }
- catch( const Exception& )
- {
- OSL_ENSURE( sal_False, "lcl_initializeCharacterAttributes: caught an exception!" );
- }
- }
+ if ( m_nControlWizardEvent )
+ Application::RemoveUserEvent( m_nControlWizardEvent );
+ m_nControlWizardEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnStartControlWizard ) );
}
// -----------------------------------------------------------------------------
-sal_Int16 FmXFormView::implInitializeNewControlModel( const Reference< XPropertySet >& _rxModel, const SdrObject* _pObject ) const
+IMPL_LINK( FmXFormView, OnStartControlWizard, void*, /**/ )
{
- OSL_ENSURE( _rxModel.is() && _pObject, "FmXFormView::implInitializeNewControlModel: invalid model!" );
+ m_nControlWizardEvent = 0;
+ OSL_PRECOND( m_xLastCreatedControlModel.is(), "FmXFormView::OnStartControlWizard: illegal call!" );
+ if ( !m_xLastCreatedControlModel.is() )
+ return 0L;
sal_Int16 nClassId = FormComponentType::CONTROL;
- if ( !_rxModel.is() || !_pObject )
- return nClassId;
-
try
{
- DocumentType eDocumentType = GetFormShell() ? GetFormShell()->GetImpl()->getDocumentType() : eUnknownDocumentType;
- ControlLayouter::initializeControlLayout( _rxModel, eDocumentType );
+ OSL_VERIFY( m_xLastCreatedControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
- _rxModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
- Reference< XPropertySetInfo> xPSI(_rxModel->getPropertySetInfo());
- switch ( nClassId )
- {
- case FormComponentType::SCROLLBAR:
- _rxModel->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LiveScroll" ) ), makeAny( (sal_Bool)sal_True ) );
- // NO break!
- case FormComponentType::SPINBUTTON:
- {
- const ::Rectangle& rBoundRect = _pObject->GetCurrentBoundRect();
- sal_Int32 eOrientation = ScrollBarOrientation::HORIZONTAL;
- if ( rBoundRect.GetWidth() < rBoundRect.GetHeight() )
- eOrientation = ScrollBarOrientation::VERTICAL;
- _rxModel->setPropertyValue( FM_PROP_ORIENTATION, makeAny( eOrientation ) );
- }
+ const sal_Char* pWizardAsciiName = NULL;
+ switch ( nClassId )
+ {
+ case FormComponentType::GRIDCONTROL:
+ pWizardAsciiName = "com.sun.star.sdb.GridControlAutoPilot";
break;
-
- case FormComponentType::LISTBOX:
- case FormComponentType::COMBOBOX:
- {
- const ::Rectangle& rBoundRect = _pObject->GetCurrentBoundRect();
- sal_Bool bDropDown = ( rBoundRect.GetWidth() >= 3 * rBoundRect.GetHeight() );
- _rxModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) );
- }
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ pWizardAsciiName = "com.sun.star.sdb.ListComboBoxAutoPilot";
+ break;
+ case FormComponentType::GROUPBOX:
+ pWizardAsciiName = "com.sun.star.sdb.GroupBoxAutoPilot";
break;
+ }
- case FormComponentType::TEXTFIELD:
- {
- initializeTextFieldLineEnds( _rxModel, m_xORB );
- lcl_initializeCharacterAttributes( _rxModel );
+ if ( pWizardAsciiName )
+ {
+ // build the argument list
+ Sequence< Any > aWizardArgs(1);
+ // the object affected
+ aWizardArgs[0] = makeAny( PropertyValue(
+ ::rtl::OUString::createFromAscii("ObjectModel"),
+ 0,
+ makeAny( m_xLastCreatedControlModel ),
+ PropertyState_DIRECT_VALUE
+ ) );
+
+ // create the wizard object
+ Reference< XExecutableDialog > xWizard;
+ try
+ {
+ m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs, xWizard );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
- const ::Rectangle& rBoundRect = _pObject->GetCurrentBoundRect();
- if ( !( rBoundRect.GetWidth() > 4 * rBoundRect.GetHeight() ) ) // heuristics
- {
- if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_MULTILINE ) )
- _rxModel->setPropertyValue( FM_PROP_MULTILINE, makeAny( (sal_Bool)sal_True ) );
- }
+ if ( !xWizard.is() )
+ {
+ ShowServiceNotAvailableError( NULL, String::CreateFromAscii( pWizardAsciiName ), sal_True );
+ }
+ else
+ {
+ // execute the wizard
+ try
+ {
+ xWizard->execute();
}
- break;
-
- case FormComponentType::RADIOBUTTON:
- case FormComponentType::CHECKBOX:
- case FormComponentType::FIXEDTEXT:
+ catch( const Exception& )
{
- ::rtl::OUString sVertAlignPropertyName( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) );
- if ( xPSI.is() && xPSI->hasPropertyByName( sVertAlignPropertyName ) )
- _rxModel->setPropertyValue( sVertAlignPropertyName, makeAny( VerticalAlignment_MIDDLE ) );
+ DBG_UNHANDLED_EXCEPTION();
}
- break;
}
}
- catch( const Exception& )
+
+ m_xLastCreatedControlModel.clear();
+ return 1L;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_insertIntoFormComponentHierarchy_throw( const FmFormView& _rView, const SdrUnoObj& _rSdrObj,
+ const Reference< XDataSource >& _rxDataSource = NULL, const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
+ const ::rtl::OUString& _rCommand = ::rtl::OUString(), const sal_Int32 _nCommandType = -1 )
{
- OSL_ENSURE( sal_False, "FmXFormView::implInitializeNewControlModel: caught an exception!" );
+ FmFormPage& rPage = static_cast< FmFormPage& >( *_rView.GetSdrPageView()->GetPage() );
+
+ Reference< XFormComponent > xFormComponent( _rSdrObj.GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XForm > xTargetForm(
+ rPage.GetImpl()->findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ),
+ UNO_SET_THROW );
+
+ Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW );
+ xFormAsContainer->insertByIndex( xFormAsContainer->getCount(), makeAny( xFormComponent ) );
+
+ rPage.GetImpl()->setUniqueName( xFormComponent, xTargetForm );
}
- return nClassId;
}
// -----------------------------------------------------------------------------
@@ -1301,7 +1123,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
// obtain the data source
if ( !xDataSource.is() )
- xDataSource = OStaticDataAccessTools().getDataSource(sDataSource, getORB());
+ xDataSource = OStaticDataAccessTools().getDataSource( sDataSource, m_aContext.getLegacyServiceFactory() );
// and the connection, if necessary
if ( !xConnection.is() )
@@ -1309,7 +1131,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
sDataSource,
::rtl::OUString(),
::rtl::OUString(),
- getORB()
+ m_aContext.getLegacyServiceFactory()
) );
}
catch(const SQLContext& e) { aError.Reason <<= e; }
@@ -1334,8 +1156,6 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
// go
try
{
- FmFormPage& rPage = *static_cast<FmFormPage*>(m_pView->GetSdrPageView()->GetPage());
-
// determine the table/query field which we should create a control for
Reference< XPropertySet > xField;
@@ -1357,13 +1177,13 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
////////////////////////////////////////////////////////////////
// nur fuer Textgroesse
- OutputDevice* _pOutDev = NULL;
+ OutputDevice* pOutDev = NULL;
if (m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
- _pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
+ pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
else
{// OutDev suchen
SdrPageView* pPageView = m_pView->GetSdrPageView();
- if( pPageView && !_pOutDev )
+ if( pPageView && !pOutDev )
{
// const SdrPageViewWinList& rWinList = pPageView->GetWinList();
// const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
@@ -1374,14 +1194,14 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
if( rPageWindow.GetPaintWindow().OutputToWindow())
{
- _pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
+ pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
break;
}
}
}
}
- if (!_pOutDev)
+ if ( !pOutDev )
return NULL;
sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
@@ -1445,33 +1265,16 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
if (!nOBJID)
return NULL;
- SdrUnoObj* pLabel;
- SdrUnoObj* pControl;
- createControlLabelPair(m_pView,_pOutDev, 0,0, xField, xNumberFormats, nOBJID, sLabelPostfix, FmFormInventor,OBJ_FM_FIXEDTEXT,NULL,NULL,NULL,pLabel, pControl);
- if (!pLabel || !pControl)
+ SdrUnoObj* pLabel( NULL );
+ SdrUnoObj* pControl( NULL );
+ if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
+ pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
+ )
{
- delete pLabel;
- delete pControl;
return NULL;
}
//////////////////////////////////////////////////////////////////////
- // Feststellen ob eine form erzeugt werden muss
- // Dieses erledigt die Page fuer uns bzw. die PageImpl
- Reference< XFormComponent > xContent(pLabel->GetUnoControlModel(), UNO_QUERY);
- Reference< XIndexContainer > xContainer(rPage.GetImpl()->placeInFormComponentHierarchy(xContent, xDataSource, sDataSource, sCommand, nCommandType), UNO_QUERY);
- if (xContainer.is())
- xContainer->insertByIndex(xContainer->getCount(), makeAny(xContent));
- implInitializeNewControlModel( Reference< XPropertySet >( xContent, UNO_QUERY ), pLabel );
-
- xContent = Reference< XFormComponent > (pControl->GetUnoControlModel(), UNO_QUERY);
- xContainer = Reference< XIndexContainer > (rPage.GetImpl()->placeInFormComponentHierarchy(xContent, xDataSource,
- sDataSource, sCommand, nCommandType), UNO_QUERY);
- if (xContainer.is())
- xContainer->insertByIndex(xContainer->getCount(), makeAny(xContent));
- implInitializeNewControlModel( Reference< XPropertySet >( xContent, UNO_QUERY ), pLabel );
-
- //////////////////////////////////////////////////////////////////////
// Objekte gruppieren
SdrObjGroup* pGroup = new SdrObjGroup();
SdrObjList* pObjList = pGroup->GetSubList();
@@ -1479,24 +1282,16 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
pObjList->InsertObject(pControl);
- if (bDateNTimeField)
- { // wir haben bis jetzt nur ein Datums-Feld eingefuegt, brauchen aber noch ein extra Feld fuer
- // die Zeit-Komponente
+ if ( bDateNTimeField )
+ { // so far we created a date field only, but we also need a time field
pLabel = pControl = NULL;
- createControlLabelPair(m_pView,_pOutDev, 0,1000, xField, xNumberFormats, OBJ_FM_TIMEFIELD,
- String( SVX_RES( RID_STR_POSTFIX_TIME ) ), FmFormInventor,OBJ_FM_FIXEDTEXT,
- NULL,NULL,NULL,
- pLabel, pControl);
-
- if (pLabel && pControl)
- {
- pObjList->InsertObject(pLabel);
- pObjList->InsertObject(pControl);
- }
- else
+ if ( createControlLabelPair( *pOutDev, 0, 1000, xField, xNumberFormats, OBJ_FM_TIMEFIELD,
+ String( SVX_RES( RID_STR_POSTFIX_TIME ) ), pLabel, pControl,
+ xDataSource, sDataSource, sCommand, nCommandType )
+ )
{
- delete pLabel;
- delete pControl;
+ pObjList->InsertObject( pLabel );
+ pObjList->InsertObject( pControl );
}
}
@@ -1523,8 +1318,6 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
// go
try
{
- FmFormPage& rPage = *static_cast<FmFormPage*>(m_pView->GetSdrPageView()->GetPage());
-
// determine the table/query field which we should create a control for
Reference< XPropertySet > xField;
Reference< XNumberFormats > xNumberFormats;
@@ -1532,13 +1325,13 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
////////////////////////////////////////////////////////////////
// nur fuer Textgroesse
- OutputDevice* _pOutDev = NULL;
+ OutputDevice* pOutDev = NULL;
if (m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
- _pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
+ pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
else
{// OutDev suchen
SdrPageView* pPageView = m_pView->GetSdrPageView();
- if( pPageView && !_pOutDev )
+ if( pPageView && !pOutDev )
{
// const SdrPageViewWinList& rWinList = pPageView->GetWinList();
// const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
@@ -1549,14 +1342,14 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
if( rPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType() == OUTDEV_WINDOW)
{
- _pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
+ pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
break;
}
}
}
}
- if (!_pOutDev)
+ if ( !pOutDev )
return NULL;
//////////////////////////////////////////////////////////////////////
@@ -1575,13 +1368,12 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
// xform control or submission button?
if ( !xSubmission.is() )
{
-
- SdrUnoObj* pLabel;
- SdrUnoObj* pControl;
- createControlLabelPair(m_pView,_pOutDev, 0,0, xField, xNumberFormats, nOBJID, sLabelPostfix, FmFormInventor,OBJ_FM_FIXEDTEXT,NULL,NULL,NULL,pLabel, pControl);
- if (!pLabel || !pControl) {
- delete pLabel;
- delete pControl;
+ SdrUnoObj* pLabel( NULL );
+ SdrUnoObj* pControl( NULL );
+ if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
+ pLabel, pControl )
+ )
+ {
return NULL;
}
@@ -1595,22 +1387,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
xBindableValue->setValueBinding(xValueBinding);
//////////////////////////////////////////////////////////////////////
- // Feststellen ob eine ::com::sun::star::form erzeugt werden muss
- // Dieses erledigt die Page fuer uns bzw. die PageImpl
- Reference< XFormComponent > xContent(pLabel->GetUnoControlModel(), UNO_QUERY);
- Reference< XIndexContainer > xContainer(rPage.GetImpl()->placeInFormComponentHierarchy( xContent ), UNO_QUERY);
- if (xContainer.is())
- xContainer->insertByIndex(xContainer->getCount(), makeAny(xContent));
- implInitializeNewControlModel( Reference< XPropertySet >( xContent, UNO_QUERY ), pControl );
-
- xContent = Reference< XFormComponent > (pControl->GetUnoControlModel(), UNO_QUERY);
- xContainer = Reference< XIndexContainer > (rPage.GetImpl()->placeInFormComponentHierarchy( xContent ), UNO_QUERY);
- if (xContainer.is())
- xContainer->insertByIndex(xContainer->getCount(), makeAny(xContent));
- implInitializeNewControlModel( Reference< XPropertySet >( xContent, UNO_QUERY ), pControl );
-
- //////////////////////////////////////////////////////////////////////
- // Objekte gruppieren
+ // group objects
SdrObjGroup* pGroup = new SdrObjGroup();
SdrObjList* pObjList = pGroup->GetSubList();
pObjList->InsertObject(pLabel);
@@ -1621,15 +1398,15 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
else {
// create a button control
- const MapMode eTargetMode(_pOutDev->GetMapMode());
+ const MapMode eTargetMode( pOutDev->GetMapMode() );
const MapMode eSourceMode(MAP_100TH_MM);
const sal_uInt16 nObjID = OBJ_FM_BUTTON;
::Size controlSize(4000, 500);
FmFormObj *pControl = static_cast<FmFormObj*>(SdrObjFactory::MakeNewObject( FmFormInventor, nObjID, NULL, NULL ));
controlSize.Width() = Fraction(controlSize.Width(), 1) * eTargetMode.GetScaleX();
controlSize.Height() = Fraction(controlSize.Height(), 1) * eTargetMode.GetScaleY();
- ::Point controlPos(_pOutDev->LogicToLogic(::Point(controlSize.Width(),0),eSourceMode,eTargetMode));
- ::Rectangle controlRect(controlPos,_pOutDev->LogicToLogic(controlSize, eSourceMode, eTargetMode));
+ ::Point controlPos( pOutDev->LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
+ ::Rectangle controlRect( controlPos, pOutDev->LogicToLogic( controlSize, eSourceMode, eTargetMode ) );
pControl->SetLogicRect(controlRect);
// set the button label
@@ -1656,43 +1433,63 @@ SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor
}
//------------------------------------------------------------------------
-void FmXFormView::createControlLabelPair(SdrView* /*_pView*/,OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
- const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
- sal_uInt16 _nObjID, const ::rtl::OUString& _rFieldPostfix,UINT32 _nInventor,UINT16 _nIndent
- ,SdrPage* _pLabelPage,SdrPage* _pPage,SdrModel* _pModel,
- SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl)
+bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
+ const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
+ sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix,
+ SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl,
+ const Reference< XDataSource >& _rxDataSource, const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rCommand, const sal_Int32 _nCommandType )
+{
+ if ( !createControlLabelPair( m_aContext, _rOutDev, _nXOffsetMM, _nYOffsetMM,
+ _rxField, _rxNumberFormats, _nControlObjectID, _rFieldPostfix, FmFormInventor, OBJ_FM_FIXEDTEXT,
+ NULL, NULL, NULL, _rpLabel, _rpControl )
+ )
+ return false;
+
+ // insert the control model(s) into the form component hierachy
+ lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpLabel, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
+ lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpControl, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
+
+ // some context-dependent initializations
+ FormControlFactory aControlFactory( m_aContext );
+ aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpLabel );
+ aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpControl );
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& _rContext,
+ OutputDevice& _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, const Reference< XPropertySet >& _rxField,
+ const Reference< XNumberFormats >& _rxNumberFormats, sal_uInt16 _nControlObjectID,
+ const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID,
+ SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl)
{
sal_Int32 nDataType = 0;
- sal_Int32 nFormatKey = 0;
::rtl::OUString sFieldName;
Any aFieldName;
if ( _rxField.is() )
{
nDataType = ::comphelper::getINT32(_rxField->getPropertyValue(FM_PROP_FIELDTYPE));
- Reference< XPropertySetInfo > xPSI( _rxField->getPropertySetInfo() );
- if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_FORMATKEY ) )
- nFormatKey = ::comphelper::getINT32(_rxField->getPropertyValue(FM_PROP_FORMATKEY));
- else
- nFormatKey = OStaticDataAccessTools().getDefaultNumberFormat(
- _rxField,
- Reference< XNumberFormatTypes >( _rxNumberFormats, UNO_QUERY ),
- SvtSysLocale().GetLocaleData().getLocale()
- );
-
aFieldName = Any(_rxField->getPropertyValue(FM_PROP_NAME));
aFieldName >>= sFieldName;
}
- // das Label
- _rpLabel = static_cast<SdrUnoObj*>(SdrObjFactory::MakeNewObject( _nInventor, _nIndent, _pLabelPage,_pModel ));
- Reference< XPropertySet > xLabelSet(_rpLabel->GetUnoControlModel(), UNO_QUERY);
- xLabelSet->setPropertyValue(FM_PROP_LABEL, makeAny(sFieldName + _rFieldPostfix));
+ // the label
+ ::std::auto_ptr< SdrUnoObj > pLabel( dynamic_cast< SdrUnoObj* >(
+ SdrObjFactory::MakeNewObject( _nInventor, _nLabelObjectID, _pLabelPage, _pModel ) ) );
+ OSL_ENSURE( pLabel.get(), "FmXFormView::createControlLabelPair: could not create the label!" );
+ if ( !pLabel.get() )
+ return false;
+
+ Reference< XPropertySet > xLabelSet( pLabel->GetUnoControlModel(), UNO_QUERY );
+ xLabelSet->setPropertyValue( FM_PROP_LABEL, makeAny( sFieldName + _rFieldPostfix ) );
// positionieren unter Beachtung der Einstellungen des Ziel-Output-Devices
- ::Size aTextSize(_pOutDev->GetTextWidth(sFieldName + _rFieldPostfix), _pOutDev->GetTextHeight());
+ ::Size aTextSize( _rOutDev.GetTextWidth(sFieldName + _rFieldPostfix), _rOutDev.GetTextHeight() );
- MapMode eTargetMode(_pOutDev->GetMapMode()),
- eSourceMode(MAP_100TH_MM);
+ MapMode eTargetMode( _rOutDev.GetMapMode() ),
+ eSourceMode( MAP_100TH_MM );
// Textbreite ist mindestens 5cm
// Texthoehe immer halber cm
@@ -1702,27 +1499,34 @@ void FmXFormView::createControlLabelPair(SdrView* /*_pView*/,OutputDevice* _pOut
// Abstand zwischen Text und Control
::Size aDelta(500, 0);
- ::Size aRealSize = _pOutDev->LogicToLogic(aTextSize, eTargetMode, eSourceMode);
+ ::Size aRealSize = _rOutDev.LogicToLogic(aTextSize, eTargetMode, eSourceMode);
aRealSize.Width() = std::max(aRealSize.Width(), aDefTxtSize.Width()) + aDelta.Width();
aRealSize.Height()= aDefSize.Height();
// je nach Skalierung des Zieldevices muss die Groesse noch normiert werden (#53523#)
aRealSize.Width() = long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX());
aRealSize.Height() = long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY());
- _rpLabel->SetLogicRect(
- ::Rectangle( _pOutDev->LogicToLogic(::Point(_nXOffsetMM, _nYOffsetMM), eSourceMode, eTargetMode),
- _pOutDev->LogicToLogic(aRealSize, eSourceMode, eTargetMode)
- ));
-
- // jetzt das Control
- _rpControl = static_cast<SdrUnoObj*>(SdrObjFactory::MakeNewObject( _nInventor, _nObjID, _pPage,_pModel ));
- Reference< XPropertySet > xControlSet( _rpControl->GetUnoControlModel(), UNO_QUERY );
-
- // positionieren
+ pLabel->SetLogicRect( ::Rectangle(
+ _rOutDev.LogicToLogic( ::Point( _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
+ _rOutDev.LogicToLogic( aRealSize, eSourceMode, eTargetMode )
+ ) );
+
+ // the control
+ ::std::auto_ptr< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
+ SdrObjFactory::MakeNewObject( _nInventor, _nControlObjectID, _pControlPage, _pModel ) ) );
+ OSL_ENSURE( pControl.get(), "FmXFormView::createControlLabelPair: could not create the control!" );
+ if ( !pControl.get() )
+ return false;
+
+ Reference< XPropertySet > xControlSet( pControl->GetUnoControlModel(), UNO_QUERY );
+ if ( !xControlSet.is() )
+ return false;
+
+ // position
::Size szControlSize;
if (DataType::BIT == nDataType || nDataType == DataType::BOOLEAN )
szControlSize = aDefSize;
- else if (OBJ_FM_IMAGECONTROL == _nObjID || DataType::LONGVARCHAR == nDataType || DataType::LONGVARBINARY == nDataType )
+ else if (OBJ_FM_IMAGECONTROL == _nControlObjectID || DataType::LONGVARCHAR == nDataType || DataType::LONGVARBINARY == nDataType )
szControlSize = aDefImageSize;
else
szControlSize = aDefSize;
@@ -1730,101 +1534,46 @@ void FmXFormView::createControlLabelPair(SdrView* /*_pView*/,OutputDevice* _pOut
// normieren wie oben
szControlSize.Width() = long(Fraction(szControlSize.Width(), 1) * eTargetMode.GetScaleX());
szControlSize.Height() = long(Fraction(szControlSize.Height(), 1) * eTargetMode.GetScaleY());
- _rpControl->SetLogicRect(
- ::Rectangle( _pOutDev->LogicToLogic(::Point(aRealSize.Width() + _nXOffsetMM, _nYOffsetMM), eSourceMode, eTargetMode),
- _pOutDev->LogicToLogic(szControlSize, eSourceMode, eTargetMode)
- ));
+ pControl->SetLogicRect( ::Rectangle(
+ _rOutDev.LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
+ _rOutDev.LogicToLogic( szControlSize, eSourceMode, eTargetMode )
+ ) );
- // ein paar initiale Einstellungen am ControlModel
- if (xControlSet.is())
- {
- Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
- // ein paar numersiche Eigenschaften durchschleifen
- if (xControlPropInfo->hasPropertyByName(FM_PROP_DECIMAL_ACCURACY))
- {
- // Number braucht eine Scale
- Any aScaleVal(::comphelper::getNumberFormatDecimals(_rxNumberFormats, nFormatKey));
- xControlSet->setPropertyValue(FM_PROP_DECIMAL_ACCURACY, aScaleVal);
- }
- if (xControlPropInfo->hasPropertyByName(FM_PROP_VALUEMIN) && xControlPropInfo->hasPropertyByName(FM_PROP_VALUEMAX))
- {
- // die minimale/maximale Zahl in diesem Feld
- sal_Int32 nMinValue = -1000000000, nMaxValue = 1000000000;
- switch (nDataType)
- {
- case DataType::TINYINT : nMinValue = 0; nMaxValue = 255; break;
- case DataType::SMALLINT : nMinValue = -32768; nMaxValue = 32767; break;
- case DataType::INTEGER : nMinValue = 0x80000000; nMaxValue = 0x7FFFFFFF; break;
- // um die doubles/singles kuemmere ich mich nicht, da es ein wenig sinnlos ist
- }
-
- Any aVal;
-
- Property aMinProp = xControlPropInfo->getPropertyByName(FM_PROP_VALUEMIN);
- if (aMinProp.Type.getTypeClass() == TypeClass_DOUBLE)
- aVal <<= (double)nMinValue;
- else if (aMinProp.Type.getTypeClass() == TypeClass_LONG)
- aVal <<= (sal_Int32)nMinValue;
- else
- {
- DBG_ERROR("FmXFormView::createControlLabelPair: unexpected property type (MinValue)!");
- }
- xControlSet->setPropertyValue(FM_PROP_VALUEMIN,aVal);
+ // some initializations
+ Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
- Property aMaxProp = xControlPropInfo->getPropertyByName(FM_PROP_VALUEMAX);
- if (aMaxProp.Type.getTypeClass() == TypeClass_DOUBLE)
- aVal <<= (double)nMaxValue;
- else if (aMaxProp.Type.getTypeClass() == TypeClass_LONG)
- aVal <<= (sal_Int32)nMaxValue;
- else
- {
- DBG_ERROR("FmXFormView::createControlLabelPair: unexpected property type (MaxValue)!");
- }
- xControlSet->setPropertyValue(FM_PROP_VALUEMAX,aVal);
- }
+ if ( aFieldName.hasValue() )
+ {
+ xControlSet->setPropertyValue(FM_PROP_CONTROLSOURCE, aFieldName);
+ xControlSet->setPropertyValue(FM_PROP_NAME, aFieldName);
+ }
- if (xControlPropInfo->hasPropertyByName(FM_PROP_STRICTFORMAT))
- { // Formatueberpruefung fue numeric fields standardmaessig sal_True
- sal_Bool bB(sal_True);
- Any aVal(&bB,getBooleanCppuType());
- xControlSet->setPropertyValue(FM_PROP_STRICTFORMAT, aVal);
- }
+ if ( nDataType == DataType::LONGVARCHAR && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
+ {
+ xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( sal_Bool( sal_True ) ) );
+ }
- if ( aFieldName.hasValue() )
+ // announce the label to the control
+ if (xControlPropInfo->hasPropertyByName(FM_PROP_CONTROLLABEL))
+ {
+ // (try-catch as the control may refuse a model without the right service name - which we don't know
+ // usually a fixed text we use as label should be accepted, but to be sure ....)
+ try
{
- xControlSet->setPropertyValue(FM_PROP_CONTROLSOURCE, aFieldName);
- xControlSet->setPropertyValue(FM_PROP_NAME, aFieldName);
+ xControlSet->setPropertyValue(FM_PROP_CONTROLLABEL, makeAny(xLabelSet));
}
-
- if (nDataType == DataType::LONGVARCHAR && xControlPropInfo->hasPropertyByName(FM_PROP_MULTILINE) )
+ catch( const Exception& )
{
- sal_Bool bB(sal_True);
- xControlSet->setPropertyValue(FM_PROP_MULTILINE,Any(&bB,getBooleanCppuType()));
+ DBG_UNHANDLED_EXCEPTION();
}
+ }
- if (_nObjID == OBJ_FM_CHECKBOX)
- {
- sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
- if( _rxField.is() )
- _rxField->getPropertyValue( FM_PROP_ISNULLABLE ) >>= nNullable;
- xControlSet->setPropertyValue( FM_PROP_TRISTATE, makeAny( sal_Bool( ColumnValue::NULLABLE == nNullable ) ) );
- }
+ FormControlFactory aControlFactory( _rContext );
+ aControlFactory.initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
- // announce the label to the control
- if (xControlPropInfo->hasPropertyByName(FM_PROP_CONTROLLABEL))
- {
- // (try-catch as the control may refuse a model without the right service name - which we don't know
- // usually a fixed text we use as label should be accepted, but to be sure ....)
- try
- {
- xControlSet->setPropertyValue(FM_PROP_CONTROLLABEL, makeAny(xLabelSet));
- }
- catch(Exception&)
- {
- DBG_ERROR("FmXFormView::createControlLabelPair : could not marry the control and the label !");
- }
- }
- }
+ _rpLabel = pLabel.release();
+ _rpControl = pControl.release();
+ return true;
}
//------------------------------------------------------------------------------
@@ -2039,8 +1788,7 @@ void SAL_CALL FmXFormView::focusGained( const FocusEvent& /*e*/ ) throw (Runtime
{
if ( m_xWindow.is() && m_pView )
{
- m_pView->SetMoveOutside(TRUE);
- //OLMm_pView->RefreshAllIAOManagers();
+ m_pView->SetMoveOutside( TRUE, FmFormView::ImplAccess() );
}
}
// -----------------------------------------------------------------------------
@@ -2050,8 +1798,7 @@ void SAL_CALL FmXFormView::focusLost( const FocusEvent& /*e*/ ) throw (RuntimeEx
// so we can not remove us as focus listener
if ( m_xWindow.is() && m_pView )
{
- m_pView->SetMoveOutside(FALSE);
- //OLMm_pView->RefreshAllIAOManagers();
+ m_pView->SetMoveOutside( FALSE, FmFormView::ImplAccess() );
}
}
// -----------------------------------------------------------------------------
@@ -2062,12 +1809,16 @@ void FmXFormView::removeGridWindowListening()
m_xWindow->removeFocusListener(this);
if ( m_pView )
{
- m_pView->SetMoveOutside(FALSE);
- //OLMm_pView->RefreshAllIAOManagers();
+ m_pView->SetMoveOutside( FALSE, FmFormView::ImplAccess() );
}
m_xWindow = NULL;
}
}
-// -----------------------------------------------------------------------------
-
+// -----------------------------------------------------------------------------
+DocumentType FmXFormView::impl_getDocumentType() const
+{
+ if ( GetFormShell() && GetFormShell()->GetImpl() )
+ return GetFormShell()->GetImpl()->getDocumentType();
+ return eUnknownDocumentType;
+}
diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx
new file mode 100644
index 000000000000..eea338c58c38
--- /dev/null
+++ b/svx/source/form/formcontrolfactory.cxx
@@ -0,0 +1,738 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: formcontrolfactory.cxx,v $
+*
+* $Revision: 1.1.2.3 $
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+
+#include "dbtoolsclient.hxx"
+#include "formcontrolfactory.hxx"
+#include "fmcontrollayout.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "svx/dialmgr.hxx"
+#include "svx/svdouno.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/ImageScaleMode.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/numbers.hxx>
+#include <svtools/syslocale.hxx>
+#include <tools/gen.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <set>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::form::XFormComponent;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::form::XGridColumnFactory;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::style::XStyleFamiliesSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::style::VerticalAlignment_MIDDLE;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::uno::TypeClass_DOUBLE;
+ using ::com::sun::star::uno::TypeClass_LONG;
+ using ::com::sun::star::util::XNumberFormats;
+ using ::com::sun::star::util::XNumberFormatTypes;
+ /** === end UNO using === **/
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+ namespace ScrollBarOrientation = ::com::sun::star::awt::ScrollBarOrientation;
+ namespace LineEndFormat = ::com::sun::star::awt::LineEndFormat;
+ namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue;
+
+ //====================================================================
+ //= FormControlFactory_Data
+ //====================================================================
+ struct FormControlFactory_Data
+ {
+ ::comphelper::ComponentContext m_aContext;
+
+ FormControlFactory_Data( const ::comphelper::ComponentContext& _rContext )
+ :m_aContext( _rContext )
+ {
+ }
+ };
+
+ //====================================================================
+ //= FormControlFactory
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormControlFactory::FormControlFactory( const ::comphelper::ComponentContext& _rContext )
+ :m_pData( new FormControlFactory_Data( _rContext ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ FormControlFactory::~FormControlFactory()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const SdrUnoObj& _rObject )
+ {
+ return initializeControlModel(
+ _eDocType,
+ Reference< XPropertySet >( _rObject.GetUnoControlModel(), UNO_QUERY ),
+ _rObject.GetCurrentBoundRect()
+ );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel )
+ {
+ return initializeControlModel(
+ _eDocType, _rxControlModel, Rectangle()
+ );
+ }
+
+ // -----------------------------------------------------------------------------
+ namespace
+ {
+ //....................................................................
+ static ::rtl::OUString lcl_getUniqueLabel_nothrow( const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rBaseLabel )
+ {
+ ::rtl::OUString sLabel( _rBaseLabel );
+ try
+ {
+ typedef ::std::set< ::rtl::OUString > StringBag;
+ StringBag aUsedLabels;
+
+ Reference< XFormComponent > xFormComponent( _rxControlModel, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW );
+ // loop through all siblings of the control model, and collect their labels
+ for ( sal_Int32 index=xContainer->getCount(); index>0; )
+ {
+ Reference< XPropertySet > xElement( xContainer->getByIndex( --index ), UNO_QUERY_THROW );
+ if ( xElement == _rxControlModel )
+ continue;
+
+ Reference< XPropertySetInfo > xPSI( xElement->getPropertySetInfo(), UNO_SET_THROW );
+ if ( !xPSI->hasPropertyByName( FM_PROP_LABEL ) )
+ continue;
+
+ ::rtl::OUString sElementLabel;
+ OSL_VERIFY( xElement->getPropertyValue( FM_PROP_LABEL ) >>= sElementLabel );
+ aUsedLabels.insert( sElementLabel );
+ }
+
+ // now find a free label
+ sal_Int32 i=2;
+ while ( aUsedLabels.find( sLabel ) != aUsedLabels.end() )
+ {
+ ::rtl::OUStringBuffer aBuffer( _rBaseLabel );
+ aBuffer.appendAscii( " " );
+ aBuffer.append( (sal_Int32)i++ );
+ sLabel = aBuffer.makeStringAndClear();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sLabel;
+ }
+
+ //....................................................................
+ static Sequence< PropertyValue > lcl_getDataSourceIndirectProperties( const Reference< XPropertySet >& _rxControlModel,
+ const ::comphelper::ComponentContext& _rContext )
+ {
+ OSL_PRECOND( _rxControlModel.is(), "lcl_getDataSourceIndirectProperties: invalid model!" );
+
+ Sequence< PropertyValue > aInfo;
+ try
+ {
+ Reference< XChild > xChild( _rxControlModel, UNO_QUERY );
+ Reference< XPropertySet > xForm;
+ if ( xChild.is() )
+ xForm = xForm.query( xChild->getParent() );
+
+ if ( Reference< XGridColumnFactory >( xForm, UNO_QUERY ).is() )
+ { // hmm. the model is a grid column, in real
+ xChild = xChild.query( xForm );
+ xForm = xForm.query( xChild->getParent() );
+ }
+
+ OSL_ENSURE( xForm.is(), "lcl_getDataSourceIndirectProperties: could not determine the form!" );
+ if ( !xForm.is() )
+ return aInfo;
+ ::rtl::OUString sDataSourceName;
+ xForm->getPropertyValue( FM_PROP_DATASOURCE ) >>= sDataSourceName;
+
+ Reference< XPropertySet > xDsProperties;
+ if ( sDataSourceName.getLength() )
+ xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext.getLegacyServiceFactory() ) );
+ if ( xDsProperties.is() )
+ xDsProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Info" ) ) ) >>= aInfo;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_getDataSourceIndirectProperties: caught an exception!" );
+ }
+ return aInfo;
+ }
+ /*
+ ATTENTION!
+ Broken for solaris? It seems that the old used template argument TYPE was already
+ defined as a macro ... which expand to ... "TYPE "!?
+ All platforms are OK - excepting Solaris. There the line "template< class TYPE >"
+ was expanded to "template < class TYPE " where the closing ">" was missing.
+ */
+ #ifdef MYTYPE
+ #error "Who defines the macro MYTYPE, which is used as template argument here?"
+ #endif
+
+ //....................................................................
+ template< class MYTYPE >
+ Reference< MYTYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
+ {
+ Reference< MYTYPE > xTypedNode( _rxModelNode, UNO_QUERY );
+ if ( xTypedNode.is() )
+ return xTypedNode;
+ else
+ {
+ Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
+ if ( xChild.is() )
+ return getTypedModelNode< MYTYPE >( xChild->getParent() );
+ else
+ return NULL;
+ }
+ }
+
+ //....................................................................
+ static bool lcl_getDocumentDefaultStyleAndFamily( const Reference< XInterface >& _rxDocument, ::rtl::OUString& _rFamilyName, ::rtl::OUString& _rStyleName ) SAL_THROW(( Exception ))
+ {
+ bool bSuccess = true;
+ Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
+ if ( xDocumentSI.is() )
+ {
+ if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) )
+ || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) )
+ )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ }
+ else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
+ }
+ else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) )
+ || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
+ )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
+ }
+ else
+ bSuccess = false;
+ }
+ return bSuccess;
+ }
+
+ //....................................................................
+ static const sal_Char* aCharacterAndParagraphProperties[] =
+ {
+ "CharFontName",
+ "CharFontStyleName",
+ "CharFontFamily",
+ "CharFontCharSet",
+ "CharFontPitch",
+ "CharColor",
+ "CharEscapement",
+ "CharHeight",
+ "CharUnderline",
+ "CharWeight",
+ "CharPosture",
+ "CharAutoKerning",
+ "CharBackColor",
+ "CharBackTransparent",
+ "CharCaseMap",
+ "CharCrossedOut",
+ "CharFlash",
+ "CharStrikeout",
+ "CharWordMode",
+ "CharKerning",
+ "CharLocale",
+ "CharKeepTogether",
+ "CharNoLineBreak",
+ "CharShadowed",
+ "CharFontType",
+ "CharStyleName",
+ "CharContoured",
+ "CharCombineIsOn",
+ "CharCombinePrefix",
+ "CharCombineSuffix",
+ "CharEmphasize",
+ "CharRelief",
+ "RubyText",
+ "RubyAdjust",
+ "RubyCharStyleName",
+ "RubyIsAbove",
+ "CharRotation",
+ "CharRotationIsFitToLine",
+ "CharScaleWidth",
+ "HyperLinkURL",
+ "HyperLinkTarget",
+ "HyperLinkName",
+ "VisitedCharStyleName",
+ "UnvisitedCharStyleName",
+ "CharEscapementHeight",
+ "CharNoHyphenation",
+ "CharUnderlineColor",
+ "CharUnderlineHasColor",
+ "CharStyleNames",
+ "CharHeightAsian",
+ "CharWeightAsian",
+ "CharFontNameAsian",
+ "CharFontStyleNameAsian",
+ "CharFontFamilyAsian",
+ "CharFontCharSetAsian",
+ "CharFontPitchAsian",
+ "CharPostureAsian",
+ "CharLocaleAsian",
+ "ParaIsCharacterDistance",
+ "ParaIsForbiddenRules",
+ "ParaIsHangingPunctuation",
+ "CharHeightComplex",
+ "CharWeightComplex",
+ "CharFontNameComplex",
+ "CharFontStyleNameComplex",
+ "CharFontFamilyComplex",
+ "CharFontCharSetComplex",
+ "CharFontPitchComplex",
+ "CharPostureComplex",
+ "CharLocaleComplex",
+ "ParaAdjust",
+ "ParaLineSpacing",
+ "ParaBackColor",
+ "ParaBackTransparent",
+ "ParaBackGraphicURL",
+ "ParaBackGraphicFilter",
+ "ParaBackGraphicLocation",
+ "ParaLastLineAdjust",
+ "ParaExpandSingleWord",
+ "ParaLeftMargin",
+ "ParaRightMargin",
+ "ParaTopMargin",
+ "ParaBottomMargin",
+ "ParaLineNumberCount",
+ "ParaLineNumberStartValue",
+ "PageDescName",
+ "PageNumberOffset",
+ "ParaRegisterModeActive",
+ "ParaTabStops",
+ "ParaStyleName",
+ "DropCapFormat",
+ "DropCapWholeWord",
+ "ParaKeepTogether",
+ "Setting",
+ "ParaSplit",
+ "Setting",
+ "NumberingLevel",
+ "NumberingRules",
+ "NumberingStartValue",
+ "ParaIsNumberingRestart",
+ "NumberingStyleName",
+ "ParaOrphans",
+ "ParaWidows",
+ "ParaShadowFormat",
+ "LeftBorder",
+ "RightBorder",
+ "TopBorder",
+ "BottomBorder",
+ "BorderDistance",
+ "LeftBorderDistance",
+ "RightBorderDistance",
+ "TopBorderDistance",
+ "BottomBorderDistance",
+ "BreakType",
+ "DropCapCharStyleName",
+ "ParaFirstLineIndent",
+ "ParaIsAutoFirstLineIndent",
+ "ParaIsHyphenation",
+ "ParaHyphenationMaxHyphens",
+ "ParaHyphenationMaxLeadingChars",
+ "ParaHyphenationMaxTrailingChars",
+ "ParaVertAlignment",
+ "ParaUserDefinedAttributes",
+ "NumberingIsNumber",
+ "ParaIsConnectBorder",
+ NULL
+ };
+
+ //....................................................................
+ static void lcl_initializeCharacterAttributes( const Reference< XPropertySet >& _rxModel )
+ {
+ // need to initialize the attributes from the "Default" style of the document we live in
+
+ try
+ {
+ // the style family collection
+ Reference< XStyleFamiliesSupplier > xSuppStyleFamilies = getTypedModelNode< XStyleFamiliesSupplier >( _rxModel.get() );
+ Reference< XNameAccess > xStyleFamilies;
+ if ( xSuppStyleFamilies.is() )
+ xStyleFamilies = xSuppStyleFamilies->getStyleFamilies();
+ OSL_ENSURE( xStyleFamilies.is(), "lcl_initializeCharacterAttributes: could not obtain the style families!" );
+ if ( !xStyleFamilies.is() )
+ return;
+
+ // the names of the family, and the style - depends on the document type we live in
+ ::rtl::OUString sFamilyName, sStyleName;
+ bool bKnownDocumentType = lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies.get(), sFamilyName, sStyleName );
+ OSL_ENSURE( bKnownDocumentType, "lcl_initializeCharacterAttributes: Huh? What document type is this?" );
+ if ( !bKnownDocumentType )
+ return;
+
+ // the concrete style
+ Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY );
+ Reference< XPropertySet > xStyle;
+ if ( xStyleFamily.is() )
+ xStyleFamily->getByName( sStyleName ) >>= xStyle;
+ OSL_ENSURE( xStyle.is(), "lcl_initializeCharacterAttributes: could not retrieve the style!" );
+ if ( !xStyle.is() )
+ return;
+
+ // transfer all properties which are described by the com.sun.star.style.
+ Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo() );
+ Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo() );
+ OSL_ENSURE( xSourcePropInfo.is() && xDestPropInfo.is(), "lcl_initializeCharacterAttributes: no property set info!" );
+ if ( !xSourcePropInfo.is() || !xDestPropInfo.is() )
+ return;
+
+ ::rtl::OUString sPropertyName;
+ const sal_Char** pCharacterProperty = aCharacterAndParagraphProperties;
+ while ( *pCharacterProperty )
+ {
+ sPropertyName = ::rtl::OUString::createFromAscii( *pCharacterProperty );
+
+ if ( xSourcePropInfo->hasPropertyByName( sPropertyName ) && xDestPropInfo->hasPropertyByName( sPropertyName ) )
+ _rxModel->setPropertyValue( sPropertyName, xStyle->getPropertyValue( sPropertyName ) );
+
+ ++pCharacterProperty;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel,
+ const Rectangle& _rControlBoundRect )
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+
+ OSL_ENSURE( _rxControlModel.is(), "FormControlFactory::initializeControlModel: invalid model!" );
+ if ( !_rxControlModel.is() )
+ return nClassId;
+
+ try
+ {
+ ControlLayouter::initializeControlLayout( _rxControlModel, _eDocType );
+
+ _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
+ Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
+ switch ( nClassId )
+ {
+ case FormComponentType::SCROLLBAR:
+ _rxControlModel->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LiveScroll" ) ), makeAny( (sal_Bool)sal_True ) );
+ // NO break!
+ case FormComponentType::SPINBUTTON:
+ {
+ sal_Int32 eOrientation = ScrollBarOrientation::HORIZONTAL;
+ if ( !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() < _rControlBoundRect.GetHeight() ) )
+ eOrientation = ScrollBarOrientation::VERTICAL;
+ _rxControlModel->setPropertyValue( FM_PROP_ORIENTATION, makeAny( eOrientation ) );
+ }
+ break;
+
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ {
+ sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() );
+ _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) );
+ }
+ break;
+
+ case FormComponentType::TEXTFIELD:
+ {
+ initializeTextFieldLineEnds( _rxControlModel );
+ lcl_initializeCharacterAttributes( _rxControlModel );
+
+ if ( !_rControlBoundRect.IsEmpty()
+ && !( _rControlBoundRect.GetWidth() > 4 * _rControlBoundRect.GetHeight() )
+ )
+ {
+ if ( xPSI->hasPropertyByName( FM_PROP_MULTILINE ) )
+ _rxControlModel->setPropertyValue( FM_PROP_MULTILINE, makeAny( (sal_Bool)sal_True ) );
+ }
+ }
+ break;
+
+ case FormComponentType::RADIOBUTTON:
+ case FormComponentType::CHECKBOX:
+ case FormComponentType::FIXEDTEXT:
+ {
+ ::rtl::OUString sVertAlignPropertyName( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) );
+ if ( xPSI->hasPropertyByName( sVertAlignPropertyName ) )
+ _rxControlModel->setPropertyValue( sVertAlignPropertyName, makeAny( VerticalAlignment_MIDDLE ) );
+ }
+ break;
+
+ case FormComponentType::IMAGEBUTTON:
+ case FormComponentType::IMAGECONTROL:
+ {
+ const ::rtl::OUString sScaleModeProperty( RTL_CONSTASCII_USTRINGPARAM( "ScaleMode" ) );
+ if ( xPSI->hasPropertyByName( sScaleModeProperty ) )
+ _rxControlModel->setPropertyValue( sScaleModeProperty, makeAny( ImageScaleMode::Isotropic ) );
+ }
+ break;
+ }
+
+ // initial default label for the control
+ if ( xPSI->hasPropertyByName( FM_PROP_LABEL ) )
+ {
+ ::rtl::OUString sExistingLabel;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_LABEL ) >>= sExistingLabel );
+ if ( !sExistingLabel.getLength() )
+ {
+ ::rtl::OUString sInitialLabel;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_NAME ) >>= sInitialLabel );
+
+ sal_uInt16 nTitleResId = 0;
+ switch ( nClassId )
+ {
+ case FormComponentType::COMMANDBUTTON: nTitleResId = RID_STR_PROPTITLE_PUSHBUTTON; break;
+ case FormComponentType::RADIOBUTTON: nTitleResId = RID_STR_PROPTITLE_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX: nTitleResId = RID_STR_PROPTITLE_CHECKBOX; break;
+ case FormComponentType::GROUPBOX: nTitleResId = RID_STR_PROPTITLE_GROUPBOX; break;
+ case FormComponentType::FIXEDTEXT: nTitleResId = RID_STR_PROPTITLE_FIXEDTEXT; break;
+ }
+
+ if ( nTitleResId )
+ sInitialLabel = String( SVX_RES( nTitleResId ) );
+
+ _rxControlModel->setPropertyValue(
+ FM_PROP_LABEL,
+ makeAny( lcl_getUniqueLabel_nothrow( _rxControlModel, sInitialLabel ) )
+ );
+ }
+ }
+
+ // strict format = yes is the default (i93467)
+ if ( xPSI->hasPropertyByName( FM_PROP_STRICTFORMAT ) )
+ {
+ _rxControlModel->setPropertyValue( FM_PROP_STRICTFORMAT, makeAny( sal_Bool( sal_True ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nClassId;
+ }
+
+ //------------------------------------------------------------------------------
+ void FormControlFactory::initializeTextFieldLineEnds( const Reference< XPropertySet >& _rxModel )
+ {
+ OSL_PRECOND( _rxModel.is(), "initializeTextFieldLineEnds: invalid model!" );
+ if ( !_rxModel.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySetInfo > xInfo = _rxModel->getPropertySetInfo();
+ if ( !xInfo.is() || !xInfo->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
+ return;
+
+ // let's see if the data source which the form belongs to (if any)
+ // has a setting for the preferred line end format
+ sal_Bool bDosLineEnds = sal_False;
+ Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, m_pData->m_aContext );
+ const PropertyValue* pInfo = aInfo.getConstArray();
+ const PropertyValue* pInfoEnd = pInfo + aInfo.getLength();
+ for ( ; pInfo != pInfoEnd; ++pInfo )
+ {
+ if ( pInfo->Name.equalsAscii( "PreferDosLikeLineEnds" ) )
+ {
+ pInfo->Value >>= bDosLineEnds;
+ break;
+ }
+ }
+
+ sal_Int16 nLineEndFormat = bDosLineEnds ? LineEndFormat::CARRIAGE_RETURN_LINE_FEED : LineEndFormat::LINE_FEED;
+ _rxModel->setPropertyValue( FM_PROP_LINEENDFORMAT, makeAny( nLineEndFormat ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void FormControlFactory::initializeFieldDependentProperties( const Reference< XPropertySet >& _rxDatabaseField,
+ const Reference< XPropertySet >& _rxControlModel, const Reference< XNumberFormats >& _rxNumberFormats )
+ {
+ OSL_PRECOND( _rxDatabaseField.is() && _rxControlModel.is(),
+ "FormControlFactory::initializeFieldDependentProperties: illegal params!" );
+ if ( !_rxDatabaseField.is() || !_rxControlModel.is() )
+ return;
+
+ try
+ {
+ ////////////////////////////////////////////////////////////////////////
+ // if the field has a numeric format, and the model has a "Scale" property, sync it
+ Reference< XPropertySetInfo > xFieldPSI( _rxDatabaseField->getPropertySetInfo(), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xModelPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_DECIMAL_ACCURACY ) )
+ {
+ sal_Int32 nFormatKey = 0;
+ if ( xFieldPSI->hasPropertyByName( FM_PROP_FORMATKEY ) )
+ {
+ _rxDatabaseField->getPropertyValue( FM_PROP_FORMATKEY ) >>= nFormatKey;
+ }
+ else
+ {
+ nFormatKey = OStaticDataAccessTools().getDefaultNumberFormat(
+ _rxDatabaseField,
+ Reference< XNumberFormatTypes >( _rxNumberFormats, UNO_QUERY ),
+ SvtSysLocale().GetLocaleData().getLocale()
+ );
+ }
+
+ Any aScaleVal( ::comphelper::getNumberFormatDecimals( _rxNumberFormats, nFormatKey ) );
+ _rxControlModel->setPropertyValue( FM_PROP_DECIMAL_ACCURACY, aScaleVal );
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // minimum and maximum of the control according to the type of the database field
+ sal_Int32 nDataType = DataType::OTHER;
+ OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_FIELDTYPE ) >>= nDataType );
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_VALUEMIN )
+ && xModelPSI->hasPropertyByName( FM_PROP_VALUEMAX )
+ )
+ {
+ sal_Int32 nMinValue = -1000000000, nMaxValue = 1000000000;
+ switch ( nDataType )
+ {
+ case DataType::TINYINT : nMinValue = 0; nMaxValue = 255; break;
+ case DataType::SMALLINT : nMinValue = -32768; nMaxValue = 32767; break;
+ case DataType::INTEGER : nMinValue = 0x80000000; nMaxValue = 0x7FFFFFFF; break;
+ // double and singles are ignored
+ }
+
+ Any aValue;
+
+ // both the minimum and the maximum value properties can be either Long or Double
+ Property aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMIN );
+ if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE )
+ aValue <<= (double)nMinValue;
+ else if ( aProperty.Type.getTypeClass() == TypeClass_LONG )
+ aValue <<= (sal_Int32)nMinValue;
+ else
+ {
+ DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MinValue)!" );
+ }
+ _rxControlModel->setPropertyValue( FM_PROP_VALUEMIN, aValue );
+
+ // both the minimum and the maximum value properties can be either Long or Double
+ aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMAX );
+ if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE )
+ aValue <<= (double)nMaxValue;
+ else if ( aProperty.Type.getTypeClass() == TypeClass_LONG )
+ aValue <<= (sal_Int32)nMaxValue;
+ else
+ {
+ DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MaxValue)!" );
+ }
+ _rxControlModel->setPropertyValue( FM_PROP_VALUEMAX, aValue );
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // a check box can be tristate if and only if the column it is bound to is nullable
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+ if ( nClassId == FormComponentType::CHECKBOX )
+ {
+ sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
+ OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_ISNULLABLE ) >>= nNullable );
+ _rxControlModel->setPropertyValue( FM_PROP_TRISTATE, makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk
index 238faf5e34e2..3d405edc00f1 100644
--- a/svx/source/form/makefile.mk
+++ b/svx/source/form/makefile.mk
@@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.35 $
+# $Revision: 1.35.2.2 $
#
# This file is part of OpenOffice.org.
#
@@ -105,7 +105,9 @@ SLOFILES = \
$(SLO)$/datalistener.obj \
$(SLO)$/fmscriptingenv.obj \
$(SLO)$/stringlistresource.obj \
- $(SLO)$/databaselocationinput.obj
+ $(SLO)$/databaselocationinput.obj \
+ $(SLO)$/delayedevent.obj \
+ $(SLO)$/formcontrolfactory.obj
.IF "$(OS)$(CPU)"=="SOLARISI"
NOOPTFILES=$(SLO)$/fmprop.obj
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 2e52dd2bf31d..d565cd0eb65b 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -37,21 +37,16 @@
#include <svx/svdpagv.hxx>
#include "svditer.hxx"
-#ifndef _SVX_FMHELP_HRC
#include "fmhelp.hrc"
-#endif
-#ifndef _SVX_FMEXPL_HRC
#include "fmexpl.hrc"
-#endif
#include "fmexpl.hxx"
-#ifndef _SVX_FMRESIDS_HRC
#include "fmresids.hrc"
-#endif
#include "fmshimp.hxx"
#include "fmservs.hxx"
#include "fmundo.hxx"
#include "fmpgeimp.hxx"
#include "fmitems.hxx"
+#include "fmobj.hxx"
#include <vcl/wrkwin.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/dispatch.hxx>
@@ -112,23 +107,20 @@ namespace svxform
SdrObjListIter aIter( *_pPage );
while ( aIter.IsMore() )
{
- // get the shape
- SdrObject* pShape = aIter.Next();
+ SdrObject* pSdrObject = aIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
+ if ( !pFormObject )
+ continue;
- // is it a UNO control shape?
- if ( pShape->IsUnoObj() )
- {
- Reference< XInterface > xNormalizedModel;
- xNormalizedModel = xNormalizedModel.query( ( static_cast< SdrUnoObj* >( pShape )->GetUnoControlModel() ) );
- // note that this is normalized (i.e. queried for XInterface explicitly)
+ Reference< XInterface > xNormalizedModel( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ // note that this is normalized (i.e. queried for XInterface explicitly)
#ifdef DBG_UTIL
- ::std::pair< MapModelToShape::iterator, bool > aPos =
+ ::std::pair< MapModelToShape::iterator, bool > aPos =
#endif
- _rMapping.insert( ModelShapePair( xNormalizedModel, pShape ) );
- DBG_ASSERT( aPos.second, "collectShapeModelMapping: model was already existent!" );
- // if this asserts, this would mean we have 2 shapes pointing to the same model
- }
+ _rMapping.insert( ModelShapePair( xNormalizedModel, pSdrObject ) );
+ DBG_ASSERT( aPos.second, "collectShapeModelMapping: model was already existent!" );
+ // if this asserts, this would mean we have 2 shapes pointing to the same model
}
}
@@ -2183,46 +2175,35 @@ namespace svxform
SdrPageView* pPageView = pFormView->GetSdrPageView();
SdrPage* pPage = pPageView->GetPage();
- SdrObjListIter aIter( *pPage );
- while( aIter.IsMore() )
+ SdrObjListIter aIter( *pPage );
+ while ( aIter.IsMore() )
{
- SdrObject* pObj = aIter.Next();
-
- //////////////////////////////////////////////////////////////////////
- // Es interessieren nur Uno-Objekte
- if( pObj->IsUnoObj() )
- {
- Reference< XInterface > xControlModel(((SdrUnoObj*)pObj)->GetUnoControlModel());
-
- //////////////////////////////////////////////////////////////////////
- // Ist dieses Objekt ein XFormComponent?
- Reference< XFormComponent > xFormViewControl(xControlModel, UNO_QUERY);
- if( !xFormViewControl.is() )
- return;
+ SdrObject* pSdrObject = aIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
+ if ( !pFormObject )
+ continue;
- if (xFormViewControl == xFormComponent )
- {
- // Objekt markieren
- if (bMark != pFormView->IsObjMarked(pObj))
- // der Writer mag das leider nicht, wenn schon markierte Objekte noch mal markiert werden ...
- pFormView->MarkObj( pObj, pPageView, !bMark, sal_False );
+ Reference< XInterface > xControlModel( pFormObject->GetUnoControlModel() );
+ if ( xControlModel != xFormComponent )
+ continue;
- // Markierung in allen Fenstern in den sichtbaren Bereich verschieben
- if( bMarkHandles && bMark)
- {
- ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
+ // mark the object
+ if ( bMark != pFormView->IsObjMarked( pSdrObject ) )
+ // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
+ pFormView->MarkObj( pSdrObject, pPageView, !bMark, sal_False );
- for(sal_uInt32 a(0L); a < pFormView->PaintWindowCount(); a++)
- {
- SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow(a);
- OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ if ( !bMarkHandles || !bMark )
+ continue;
- if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
- {
- pFormView->MakeVisible(aMarkRect, (Window&)rOutDev);
- }
- }
- }
+ // make the mark visible
+ ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
+ for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
+ {
+ SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i );
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ if ( OUTDEV_WINDOW == rOutDev.GetOutDevType() )
+ {
+ pFormView->MakeVisible( aMarkRect, (Window&)rOutDev );
}
}
}
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
index b30b68a722eb..27958709550d 100644
--- a/svx/source/form/navigatortreemodel.cxx
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -41,18 +41,14 @@
#include "fmundo.hxx"
-#ifndef _SVX_FMHELP_HRC
#include "fmhelp.hrc"
-#endif
-#ifndef _SVX_FMEXPL_HRC
#include "fmexpl.hrc"
-#endif
#include "fmexpl.hxx"
-#ifndef _SVX_FMRESIDS_HRC
#include "fmresids.hrc"
-#endif
#include "fmshimp.hxx"
+#include "fmobj.hxx"
#include <sfx2/objsh.hxx>
+#include <tools/diagnose_ex.h>
#include <com/sun/star/container/XContainer.hpp>
//............................................................................
@@ -731,49 +727,55 @@ namespace svxform
}
//------------------------------------------------------------------------
- void NavigatorTreeModel::InsertSdrObj(const SdrObject* pObj)
+ void NavigatorTreeModel::InsertSdrObj( const SdrObject* pObj )
{
- if (pObj->GetObjInventor() == FmFormInventor)
- { //////////////////////////////////////////////////////////////////////
- // Ist dieses Objekt ein XFormComponent?
- Reference< XFormComponent > xFormComponent(((SdrUnoObj*)pObj)->GetUnoControlModel(), UNO_QUERY);
- if (xFormComponent.is())
+ const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ try
{
- Reference< XIndexContainer > xContainer(xFormComponent->getParent(), UNO_QUERY);
- if (xContainer.is())
- {
- sal_Int32 nPos = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xFormComponent);
- InsertFormComponent(xFormComponent, nPos);
- }
+ Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW );
+
+ sal_Int32 nPos = getElementPos( xContainer, xFormComponent );
+ InsertFormComponent( xFormComponent, nPos );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
}
- else if (pObj->IsGroupObject())
+ else if ( pObj->IsGroupObject() )
{
- SdrObjListIter aIter(*pObj->GetSubList());
- while (aIter.IsMore())
- InsertSdrObj(aIter.Next());
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ while ( aIter.IsMore() )
+ InsertSdrObj( aIter.Next() );
}
}
//------------------------------------------------------------------------
- void NavigatorTreeModel::RemoveSdrObj(const SdrObject* pObj)
+ void NavigatorTreeModel::RemoveSdrObj( const SdrObject* pObj )
{
- if (pObj->GetObjInventor() == FmFormInventor)
- { //////////////////////////////////////////////////////////////////////
- // Ist dieses Objekt ein XFormComponent?
- Reference< XFormComponent > xFormComponent(((SdrUnoObj*)pObj)->GetUnoControlModel(), UNO_QUERY);
- if (xFormComponent.is())
+ const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ try
{
- FmEntryData* pEntryData = FindData(xFormComponent, GetRootList(), sal_True);
- if (pEntryData)
- Remove(pEntryData);
+ Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ FmEntryData* pEntryData = FindData( xFormComponent, GetRootList(), sal_True );
+ if ( pEntryData )
+ Remove( pEntryData );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
}
- else if (pObj->IsGroupObject())
+ else if ( pObj->IsGroupObject() )
{
- SdrObjListIter aIter(*pObj->GetSubList());
- while (aIter.IsMore())
- RemoveSdrObj(aIter.Next());
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ while ( aIter.IsMore() )
+ RemoveSdrObj( aIter.Next() );
}
}
@@ -788,23 +790,29 @@ namespace svxform
if (!InsertFormComponent(rHint, pCurrent))
return sal_False;
}
- } else
- if (pObject->IsUnoObj())
+ }
+ else
+ {
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
+ if ( !pFormObject )
+ return sal_False;
+
+ try
{
- Reference< XInterface > xControlModel( ((SdrUnoObj*)pObject)->GetUnoControlModel());
- // Ist dieses Objekt ein XFormComponent?
- Reference< XFormComponent > xFormViewControl(xControlModel, UNO_QUERY);
- if (xFormViewControl.is())
- { // es ist ein Form-Control -> selektieren lassen
- FmEntryData* pControlData = FindData( xFormViewControl, GetRootList() );
- if (pControlData)
- rHint.AddItem( pControlData );
- } else
- { // es ist kein Form-Control -> im Baum ueberhaupt nix selektieren lassen
+ Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ FmEntryData* pControlData = FindData( xFormViewControl, GetRootList() );
+ if ( !pControlData )
return sal_False;
- }
- } else
+
+ rHint.AddItem( pControlData );
+ return sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
return sal_False;
+ }
+ }
return sal_True;
}
@@ -1036,20 +1044,18 @@ namespace svxform
while (rIter.IsMore())
{
SdrObject* pObj = rIter.Next();
- //////////////////////////////////////////////////////////////////////
- // Es interessieren nur Uno-Objekte
- if (pObj->GetObjInventor() == FmFormInventor)
- { //////////////////////////////////////////////////////////////////////
- // Ist dieses Objekt ein XFormComponent?
- Reference< XFormComponent > xFormViewControl(((SdrUnoObj*)pObj)->GetUnoControlModel(), UNO_QUERY);
- if (xFormViewControl == xComp)
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( xFormViewControl == xComp )
return pObj;
}
- else if (pObj->IsGroupObject())
+ else if ( pObj->IsGroupObject() )
{
- SdrObjListIter aIter(*pObj->GetSubList());
- pObj = Search(aIter, xComp);
- if (pObj)
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ pObj = Search( aIter, xComp );
+ if ( pObj )
return pObj;
}
}