1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svx/svxerr.hxx" 28cdf0e10cSrcweir #include "fmpgeimp.hxx" 29cdf0e10cSrcweir #include "fmundo.hxx" 30cdf0e10cSrcweir #include "svx/fmtools.hxx" 31cdf0e10cSrcweir #include "fmprop.hrc" 32cdf0e10cSrcweir #include "fmservs.hxx" 33cdf0e10cSrcweir #include "fmobj.hxx" 34cdf0e10cSrcweir #include "formcontrolfactory.hxx" 35cdf0e10cSrcweir #include "svx/svditer.hxx" 36cdf0e10cSrcweir #include "svx/fmresids.hrc" 37cdf0e10cSrcweir #include "svx/dbtoolsclient.hxx" 38cdf0e10cSrcweir #include "treevisitor.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 41cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp> 42cdf0e10cSrcweir #include <com/sun/star/container/EnumerableMap.hpp> 43cdf0e10cSrcweir #include <com/sun/star/drawing/XControlShape.hpp> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <sfx2/objsh.hxx> 46cdf0e10cSrcweir #include <svx/fmglob.hxx> 47cdf0e10cSrcweir #include <svx/fmpage.hxx> 48cdf0e10cSrcweir #include <svx/fmmodel.hxx> 49cdf0e10cSrcweir #include <tools/resid.hxx> 50cdf0e10cSrcweir #include <tools/diagnose_ex.h> 51cdf0e10cSrcweir #include <tools/shl.hxx> 52cdf0e10cSrcweir #include <vcl/stdtext.hxx> 53cdf0e10cSrcweir #include <svx/dialmgr.hxx> 54cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 55cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 56cdf0e10cSrcweir #include <comphelper/uno3.hxx> 57cdf0e10cSrcweir #include <comphelper/types.hxx> 58cdf0e10cSrcweir #include <unotools/streamwrap.hxx> 59cdf0e10cSrcweir #include <rtl/logfile.hxx> 60cdf0e10cSrcweir 61cdf0e10cSrcweir using namespace ::com::sun::star::uno; 62cdf0e10cSrcweir using namespace ::com::sun::star::lang; 63cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 64cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 65cdf0e10cSrcweir using namespace ::com::sun::star::container; 66cdf0e10cSrcweir using namespace ::com::sun::star::beans; 67cdf0e10cSrcweir using namespace ::com::sun::star::form; 68cdf0e10cSrcweir using ::com::sun::star::util::XCloneable; 69cdf0e10cSrcweir using ::com::sun::star::awt::XControlModel; 70cdf0e10cSrcweir using ::com::sun::star::container::XMap; 71cdf0e10cSrcweir using ::com::sun::star::container::EnumerableMap; 72cdf0e10cSrcweir using ::com::sun::star::drawing::XControlShape; 73cdf0e10cSrcweir using namespace ::svxform; 74cdf0e10cSrcweir 75cdf0e10cSrcweir DBG_NAME(FmFormPageImpl) 76cdf0e10cSrcweir //------------------------------------------------------------------------------ 77cdf0e10cSrcweir FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage ) 78cdf0e10cSrcweir :m_rPage( _rPage ) 79cdf0e10cSrcweir ,m_bFirstActivation( sal_True ) 80cdf0e10cSrcweir ,m_bAttemptedFormCreation( false ) 81cdf0e10cSrcweir ,m_bInFind( false ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::FmFormPageImpl" ); 84cdf0e10cSrcweir DBG_CTOR(FmFormPageImpl,NULL); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir //------------------------------------------------------------------------------ 88cdf0e10cSrcweir namespace 89cdf0e10cSrcweir { 90cdf0e10cSrcweir typedef Reference< XInterface > FormComponent; 91cdf0e10cSrcweir 92cdf0e10cSrcweir class FormComponentInfo 93cdf0e10cSrcweir { 94cdf0e10cSrcweir public: 95cdf0e10cSrcweir size_t childCount( const FormComponent& _component ) const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir Reference< XIndexAccess > xContainer( _component, UNO_QUERY ); 98cdf0e10cSrcweir if ( xContainer.is() ) 99cdf0e10cSrcweir return xContainer->getCount(); 100cdf0e10cSrcweir return 0; 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir FormComponent getChild( const FormComponent& _component, size_t _index ) const 104cdf0e10cSrcweir { 105cdf0e10cSrcweir Reference< XIndexAccess > xContainer( _component, UNO_QUERY_THROW ); 106cdf0e10cSrcweir return FormComponent( xContainer->getByIndex( _index ), UNO_QUERY ); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir }; 109cdf0e10cSrcweir 110cdf0e10cSrcweir typedef ::std::pair< FormComponent, FormComponent > FormComponentPair; 111cdf0e10cSrcweir 112cdf0e10cSrcweir class FormHierarchyComparator 113cdf0e10cSrcweir { 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir FormHierarchyComparator() 116cdf0e10cSrcweir { 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir size_t childCount( const FormComponentPair& _components ) const 120cdf0e10cSrcweir { 121cdf0e10cSrcweir size_t lhsCount = m_aComponentInfo.childCount( _components.first ); 122cdf0e10cSrcweir size_t rhsCount = m_aComponentInfo.childCount( _components.second ); 123cdf0e10cSrcweir if ( lhsCount != rhsCount ) 124cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Found inconsistent form component hierarchies (1)!" ) ), NULL ); 125cdf0e10cSrcweir return lhsCount; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir FormComponentPair getChild( const FormComponentPair& _components, size_t _index ) const 129cdf0e10cSrcweir { 130cdf0e10cSrcweir return FormComponentPair( 131cdf0e10cSrcweir m_aComponentInfo.getChild( _components.first, _index ), 132cdf0e10cSrcweir m_aComponentInfo.getChild( _components.second, _index ) 133cdf0e10cSrcweir ); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir private: 136cdf0e10cSrcweir FormComponentInfo m_aComponentInfo; 137cdf0e10cSrcweir }; 138cdf0e10cSrcweir 139cdf0e10cSrcweir typedef ::std::map< Reference< XControlModel >, Reference< XControlModel >, ::comphelper::OInterfaceCompare< XControlModel > > MapControlModels; 140cdf0e10cSrcweir 141cdf0e10cSrcweir class FormComponentAssignment 142cdf0e10cSrcweir { 143cdf0e10cSrcweir public: 144cdf0e10cSrcweir FormComponentAssignment( MapControlModels& _out_controlModelMap ) 145cdf0e10cSrcweir :m_rControlModelMap( _out_controlModelMap ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir void process( const FormComponentPair& _component ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir Reference< XControlModel > lhsControlModel( _component.first, UNO_QUERY ); 152cdf0e10cSrcweir Reference< XControlModel > rhsControlModel( _component.second, UNO_QUERY ); 153cdf0e10cSrcweir if ( lhsControlModel.is() != rhsControlModel.is() ) 154cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Found inconsistent form component hierarchies (2)!" ) ), NULL ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir if ( lhsControlModel.is() ) 157cdf0e10cSrcweir m_rControlModelMap[ lhsControlModel ] = rhsControlModel; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir private: 161cdf0e10cSrcweir MapControlModels& m_rControlModelMap; 162cdf0e10cSrcweir }; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir //------------------------------------------------------------------------------ 166cdf0e10cSrcweir void FmFormPageImpl::initFrom( FmFormPageImpl& i_foreignImpl ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir // clone the Forms collection 169cdf0e10cSrcweir const Reference< XNameContainer > xForeignForms( const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ) ); 170cdf0e10cSrcweir const Reference< XCloneable > xCloneable( xForeignForms, UNO_QUERY ); 171cdf0e10cSrcweir if ( !xCloneable.is() ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir // great, nothing to do 174cdf0e10cSrcweir OSL_ENSURE( !xForeignForms.is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" ); 175cdf0e10cSrcweir return; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir try 179cdf0e10cSrcweir { 180cdf0e10cSrcweir m_xForms.set( xCloneable->createClone(), UNO_QUERY_THROW ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir // create a mapping between the original control models and their clones 183cdf0e10cSrcweir MapControlModels aModelAssignment; 184cdf0e10cSrcweir 185cdf0e10cSrcweir typedef TreeVisitor< FormComponentPair, FormHierarchyComparator, FormComponentAssignment > FormComponentVisitor; 186cdf0e10cSrcweir FormComponentVisitor aVisitor = FormComponentVisitor( FormHierarchyComparator() ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir FormComponentAssignment aAssignmentProcessor( aModelAssignment ); 189cdf0e10cSrcweir aVisitor.process( FormComponentPair( xCloneable, m_xForms ), aAssignmentProcessor ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir // assign the cloned models to their SdrObjects 192cdf0e10cSrcweir SdrObjListIter aForeignIter( i_foreignImpl.m_rPage ); 193cdf0e10cSrcweir SdrObjListIter aOwnIter( m_rPage ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (1)!" ); 196cdf0e10cSrcweir while ( aForeignIter.IsMore() && aOwnIter.IsMore() ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir FmFormObj* pForeignObj = dynamic_cast< FmFormObj* >( aForeignIter.Next() ); 199cdf0e10cSrcweir FmFormObj* pOwnObj = dynamic_cast< FmFormObj* >( aOwnIter.Next() ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir bool bForeignIsForm = pForeignObj && ( pForeignObj->GetObjInventor() == FmFormInventor ); 202cdf0e10cSrcweir bool bOwnIsForm = pOwnObj && ( pOwnObj->GetObjInventor() == FmFormInventor ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir ENSURE_OR_BREAK( bForeignIsForm == bOwnIsForm, "FmFormPageImpl::FmFormPageImpl: inconsistent ordering of objects!" ); 205cdf0e10cSrcweir // if this fires, don't attempt to do further assignments, something's completely messed up 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( !bForeignIsForm ) 208cdf0e10cSrcweir // no form control -> next round 209cdf0e10cSrcweir continue; 210cdf0e10cSrcweir 211cdf0e10cSrcweir Reference< XControlModel > xForeignModel( pForeignObj->GetUnoControlModel() ); 212cdf0e10cSrcweir ENSURE_OR_CONTINUE( xForeignModel.is(), "FmFormPageImpl::FmFormPageImpl: control shape without control!" ); 213cdf0e10cSrcweir // if this fires, the SdrObject does not have a UNO Control Model. This is pathological, but well ... 214cdf0e10cSrcweir // So the cloned SdrObject will also not have a UNO Control Model. 215cdf0e10cSrcweir 216cdf0e10cSrcweir MapControlModels::const_iterator assignment = aModelAssignment.find( xForeignModel ); 217cdf0e10cSrcweir ENSURE_OR_CONTINUE( assignment != aModelAssignment.end(), "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" ); 218cdf0e10cSrcweir // if this fires, the source SdrObject has a model, but it is not part of the model hierarchy in 219cdf0e10cSrcweir // i_foreignImpl.getForms(). 220cdf0e10cSrcweir // Pathological, too ... 221cdf0e10cSrcweir 222cdf0e10cSrcweir pOwnObj->SetUnoControlModel( assignment->second ); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (2)!" ); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir catch( const Exception& ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir //------------------------------------------------------------------------------ 233cdf0e10cSrcweir Reference< XMap > FmFormPageImpl::getControlToShapeMap() 234cdf0e10cSrcweir { 235cdf0e10cSrcweir Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); 236cdf0e10cSrcweir if ( xControlShapeMap.is() ) 237cdf0e10cSrcweir return xControlShapeMap; 238cdf0e10cSrcweir 239cdf0e10cSrcweir xControlShapeMap = impl_createControlShapeMap_nothrow(); 240cdf0e10cSrcweir m_aControlShapeMap = xControlShapeMap; 241cdf0e10cSrcweir return xControlShapeMap; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir //------------------------------------------------------------------------------ 245cdf0e10cSrcweir namespace 246cdf0e10cSrcweir { 247cdf0e10cSrcweir static void lcl_insertFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir // the control model 250cdf0e10cSrcweir Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); 251cdf0e10cSrcweir OSL_ENSURE( xControlModel.is(), "lcl_insertFormObject_throw: suspicious: no control model!" ); 252cdf0e10cSrcweir if ( !xControlModel.is() ) 253cdf0e10cSrcweir return; 254cdf0e10cSrcweir 255cdf0e10cSrcweir Reference< XControlShape > xControlShape( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ); 256cdf0e10cSrcweir OSL_ENSURE( xControlShape.is(), "lcl_insertFormObject_throw: suspicious: no control shape!" ); 257cdf0e10cSrcweir if ( !xControlShape.is() ) 258cdf0e10cSrcweir return; 259cdf0e10cSrcweir 260cdf0e10cSrcweir _map->put( makeAny( xControlModel ), makeAny( xControlShape ) ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir static void lcl_removeFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map, bool i_ignoreNonExistence = false ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir // the control model 266cdf0e10cSrcweir Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY ); 267cdf0e10cSrcweir OSL_ENSURE( xControlModel.is(), "lcl_removeFormObject: suspicious: no control model!" ); 268cdf0e10cSrcweir if ( !xControlModel.is() ) 269cdf0e10cSrcweir return; 270cdf0e10cSrcweir 271cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 272cdf0e10cSrcweir Any aOldAssignment = 273cdf0e10cSrcweir #endif 274cdf0e10cSrcweir _map->remove( makeAny( xControlModel ) ); 275cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 276cdf0e10cSrcweir (void)aOldAssignment; 277cdf0e10cSrcweir #endif 278cdf0e10cSrcweir OSL_ENSURE( !i_ignoreNonExistence || 279cdf0e10cSrcweir ( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ) ), 280cdf0e10cSrcweir "lcl_removeFormObject: map was inconsistent!" ); 281cdf0e10cSrcweir (void)i_ignoreNonExistence; 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir //------------------------------------------------------------------------------ 286cdf0e10cSrcweir Reference< XMap > FmFormPageImpl::impl_createControlShapeMap_nothrow() 287cdf0e10cSrcweir { 288cdf0e10cSrcweir Reference< XMap > xMap; 289cdf0e10cSrcweir 290cdf0e10cSrcweir try 291cdf0e10cSrcweir { 292cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 293cdf0e10cSrcweir xMap.set( EnumerableMap::create( aContext.getUNOContext(), 294cdf0e10cSrcweir ::cppu::UnoType< XControlModel >::get(), 295cdf0e10cSrcweir ::cppu::UnoType< XControlShape >::get() 296cdf0e10cSrcweir ).get(), UNO_SET_THROW ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir SdrObjListIter aPageIter( m_rPage ); 299cdf0e10cSrcweir while ( aPageIter.IsMore() ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir // only FmFormObjs are what we're interested in 302cdf0e10cSrcweir FmFormObj* pCurrent = FmFormObj::GetFormObject( aPageIter.Next() ); 303cdf0e10cSrcweir if ( !pCurrent ) 304cdf0e10cSrcweir continue; 305cdf0e10cSrcweir 306cdf0e10cSrcweir lcl_insertFormObject_throw( *pCurrent, xMap ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir catch( const Exception& ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir return xMap; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir //------------------------------------------------------------------------------ 317cdf0e10cSrcweir const Reference< XNameContainer >& FmFormPageImpl::getForms( bool _bForceCreate ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::getForms" ); 320cdf0e10cSrcweir if ( m_xForms.is() || !_bForceCreate ) 321cdf0e10cSrcweir return m_xForms; 322cdf0e10cSrcweir 323cdf0e10cSrcweir if ( !m_bAttemptedFormCreation ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir m_bAttemptedFormCreation = true; 326cdf0e10cSrcweir 327cdf0e10cSrcweir const ::rtl::OUString sFormsCollectionServiceName = ::rtl::OUString::createFromAscii("com.sun.star.form.Forms"); 328cdf0e10cSrcweir m_xForms = Reference< XNameContainer > ( 329cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( sFormsCollectionServiceName ), 330cdf0e10cSrcweir UNO_QUERY 331cdf0e10cSrcweir ); 332cdf0e10cSrcweir DBG_ASSERT( m_xForms.is(), "FmFormPageImpl::getForms: could not create a forms collection!" ); 333cdf0e10cSrcweir 334cdf0e10cSrcweir if ( m_aFormsCreationHdl.IsSet() ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir m_aFormsCreationHdl.Call( this ); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir FmFormModel* pFormsModel = PTR_CAST( FmFormModel, m_rPage.GetModel() ); 340cdf0e10cSrcweir 341cdf0e10cSrcweir // give the newly created collection a place in the universe 342cdf0e10cSrcweir Reference< XChild > xAsChild( m_xForms, UNO_QUERY ); 343cdf0e10cSrcweir if ( xAsChild.is() ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir SfxObjectShell* pObjShell = pFormsModel ? pFormsModel->GetObjectShell() : NULL; 346cdf0e10cSrcweir if ( pObjShell ) 347cdf0e10cSrcweir xAsChild->setParent( pObjShell->GetModel() ); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir // tell the UNDO environment that we have a new forms collection 351cdf0e10cSrcweir if ( pFormsModel ) 352cdf0e10cSrcweir pFormsModel->GetUndoEnv().AddForms( m_xForms ); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir return m_xForms; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir //------------------------------------------------------------------------------ 358cdf0e10cSrcweir FmFormPageImpl::~FmFormPageImpl() 359cdf0e10cSrcweir { 360cdf0e10cSrcweir xCurrentForm = NULL; 361cdf0e10cSrcweir 362cdf0e10cSrcweir ::comphelper::disposeComponent( m_xForms ); 363cdf0e10cSrcweir DBG_DTOR(FmFormPageImpl,NULL); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir //------------------------------------------------------------------------------ 367cdf0e10cSrcweir bool FmFormPageImpl::validateCurForm() 368cdf0e10cSrcweir { 369cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::validateCurForm" ); 370cdf0e10cSrcweir if ( !xCurrentForm.is() ) 371cdf0e10cSrcweir return false; 372cdf0e10cSrcweir 373cdf0e10cSrcweir Reference< XChild > xAsChild( xCurrentForm, UNO_QUERY ); 374cdf0e10cSrcweir DBG_ASSERT( xAsChild.is(), "FmFormPageImpl::validateCurForm: a form which is no child??" ); 375cdf0e10cSrcweir if ( !xAsChild.is() || !xAsChild->getParent().is() ) 376cdf0e10cSrcweir xCurrentForm.clear(); 377cdf0e10cSrcweir 378cdf0e10cSrcweir return xCurrentForm.is(); 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir //------------------------------------------------------------------------------ 382cdf0e10cSrcweir void FmFormPageImpl::setCurForm(Reference< ::com::sun::star::form::XForm > xForm) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::setCurForm" ); 385cdf0e10cSrcweir xCurrentForm = xForm; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir //------------------------------------------------------------------------------ 389cdf0e10cSrcweir Reference< XForm > FmFormPageImpl::getDefaultForm() 390cdf0e10cSrcweir { 391cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::getDefaultForm" ); 392cdf0e10cSrcweir Reference< XForm > xForm; 393cdf0e10cSrcweir 394cdf0e10cSrcweir Reference< XNameContainer > xForms( getForms() ); 395cdf0e10cSrcweir 396cdf0e10cSrcweir // by default, we use our "current form" 397cdf0e10cSrcweir if ( !validateCurForm() ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir // check whether there is a "standard" form 400cdf0e10cSrcweir if ( xForms->hasElements() ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir // suche die Standardform 403cdf0e10cSrcweir ::rtl::OUString sStandardFormname = String( SVX_RES( RID_STR_STDFORMNAME ) ); 404cdf0e10cSrcweir 405cdf0e10cSrcweir try 406cdf0e10cSrcweir { 407cdf0e10cSrcweir if ( xForms->hasByName( sStandardFormname ) ) 408cdf0e10cSrcweir xForm.set( xForms->getByName( sStandardFormname ), UNO_QUERY_THROW ); 409cdf0e10cSrcweir else 410cdf0e10cSrcweir { 411cdf0e10cSrcweir Reference< XIndexAccess > xFormsByIndex( xForms, UNO_QUERY_THROW ); 412cdf0e10cSrcweir xForm.set( xFormsByIndex->getByIndex(0), UNO_QUERY_THROW ); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir catch( const Exception& ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir else 422cdf0e10cSrcweir { 423cdf0e10cSrcweir xForm = xCurrentForm; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir // did not find an existing suitable form -> create a new one 427cdf0e10cSrcweir if ( !xForm.is() ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir SdrModel* pModel = m_rPage.GetModel(); 430cdf0e10cSrcweir 431cdf0e10cSrcweir if( pModel->IsUndoEnabled() ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir XubString aStr(SVX_RES(RID_STR_FORM)); 434cdf0e10cSrcweir XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT)); 435cdf0e10cSrcweir aUndoStr.SearchAndReplace('#', aStr); 436cdf0e10cSrcweir pModel->BegUndo(aUndoStr); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir 439cdf0e10cSrcweir try 440cdf0e10cSrcweir { 441cdf0e10cSrcweir xForm.set( ::comphelper::getProcessServiceFactory()->createInstance( FM_SUN_COMPONENT_FORM ), UNO_QUERY ); 442cdf0e10cSrcweir 443cdf0e10cSrcweir // a form should always have the command type table as default 444cdf0e10cSrcweir Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); 445cdf0e10cSrcweir xFormProps->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny( sal_Int32( CommandType::TABLE ) ) ); 446cdf0e10cSrcweir 447cdf0e10cSrcweir // and the "Standard" name 448cdf0e10cSrcweir ::rtl::OUString sName = String( SVX_RES( RID_STR_STDFORMNAME ) ); 449cdf0e10cSrcweir xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) ); 450cdf0e10cSrcweir 451cdf0e10cSrcweir Reference< XIndexContainer > xContainer( xForms, UNO_QUERY ); 452cdf0e10cSrcweir if( pModel->IsUndoEnabled() ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel, 455cdf0e10cSrcweir FmUndoContainerAction::Inserted, 456cdf0e10cSrcweir xContainer, 457cdf0e10cSrcweir xForm, 458cdf0e10cSrcweir xContainer->getCount())); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir xForms->insertByName( sName, makeAny( xForm ) ); 461cdf0e10cSrcweir xCurrentForm = xForm; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir catch( const Exception& ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 466cdf0e10cSrcweir xForm.clear(); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir 469cdf0e10cSrcweir if( pModel->IsUndoEnabled() ) 470cdf0e10cSrcweir pModel->EndUndo(); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir return xForm; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir //------------------------------------------------------------------------------ 477cdf0e10cSrcweir Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy( 478cdf0e10cSrcweir const Reference< XFormComponent > & rContent, const Reference< XDataSource > & rDatabase, 479cdf0e10cSrcweir const ::rtl::OUString& rDBTitle, const ::rtl::OUString& rCursorSource, sal_Int32 nCommandType ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::findPlaceInFormComponentHierarchy" ); 482cdf0e10cSrcweir // if the control already is child of a form, don't do anything 483cdf0e10cSrcweir if (!rContent.is() || rContent->getParent().is()) 484cdf0e10cSrcweir return NULL; 485cdf0e10cSrcweir 486cdf0e10cSrcweir Reference< XForm > xForm; 487cdf0e10cSrcweir 488cdf0e10cSrcweir // Wenn Datenbank und CursorSource gesetzt sind, dann wird 489cdf0e10cSrcweir // die Form anhand dieser Kriterien gesucht, ansonsten nur aktuelle 490cdf0e10cSrcweir // und die StandardForm 491cdf0e10cSrcweir if (rDatabase.is() && rCursorSource.getLength()) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir validateCurForm(); 494cdf0e10cSrcweir 495cdf0e10cSrcweir // erst in der aktuellen form suchen 496cdf0e10cSrcweir xForm = findFormForDataSource( xCurrentForm, rDatabase, rCursorSource, nCommandType ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir Reference< ::com::sun::star::container::XIndexAccess > xFormsByIndex( getForms(), UNO_QUERY ); 499cdf0e10cSrcweir DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::findPlaceInFormComponentHierarchy : no index access for my forms collection !"); 500cdf0e10cSrcweir sal_Int32 nCount = xFormsByIndex->getCount(); 501cdf0e10cSrcweir for (sal_Int32 i = 0; !xForm.is() && i < nCount; i++) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir Reference< ::com::sun::star::form::XForm > xToSearch; 504cdf0e10cSrcweir xFormsByIndex->getByIndex(i) >>= xToSearch; 505cdf0e10cSrcweir xForm = findFormForDataSource( xToSearch, rDatabase, rCursorSource, nCommandType ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir // wenn keine ::com::sun::star::form gefunden, dann eine neue erzeugen 509cdf0e10cSrcweir if (!xForm.is()) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir SdrModel* pModel = m_rPage.GetModel(); 512cdf0e10cSrcweir 513cdf0e10cSrcweir const bool bUndo = pModel->IsUndoEnabled(); 514cdf0e10cSrcweir 515cdf0e10cSrcweir if( bUndo ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir XubString aStr(SVX_RES(RID_STR_FORM)); 518cdf0e10cSrcweir XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT)); 519cdf0e10cSrcweir aUndoStr.SearchAndReplace('#', aStr); 520cdf0e10cSrcweir pModel->BegUndo(aUndoStr); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir xForm = Reference< ::com::sun::star::form::XForm >(::comphelper::getProcessServiceFactory()->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY); 524cdf0e10cSrcweir // a form should always have the command type table as default 525cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySet > xFormProps(xForm, UNO_QUERY); 526cdf0e10cSrcweir try { xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE))); } 527cdf0e10cSrcweir catch(Exception&) { } 528cdf0e10cSrcweir 529cdf0e10cSrcweir if (rDBTitle.getLength()) 530cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_DATASOURCE,makeAny(rDBTitle)); 531cdf0e10cSrcweir else 532cdf0e10cSrcweir { 533cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySet > xDatabaseProps(rDatabase, UNO_QUERY); 534cdf0e10cSrcweir Any aDatabaseUrl = xDatabaseProps->getPropertyValue(FM_PROP_URL); 535cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_DATASOURCE, aDatabaseUrl); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_COMMAND,makeAny(rCursorSource)); 539cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(nCommandType)); 540cdf0e10cSrcweir 541cdf0e10cSrcweir Reference< ::com::sun::star::container::XNameAccess > xNamedSet( getForms(), UNO_QUERY ); 542cdf0e10cSrcweir 543cdf0e10cSrcweir const bool bTableOrQuery = ( CommandType::TABLE == nCommandType ) || ( CommandType::QUERY == nCommandType ); 544cdf0e10cSrcweir ::rtl::OUString sName = FormControlFactory::getUniqueName( xNamedSet, 545cdf0e10cSrcweir bTableOrQuery ? rCursorSource : ::rtl::OUString( String( SVX_RES( RID_STR_STDFORMNAME ) ) ) ); 546cdf0e10cSrcweir 547cdf0e10cSrcweir xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir if( bUndo ) 550cdf0e10cSrcweir { 551cdf0e10cSrcweir Reference< ::com::sun::star::container::XIndexContainer > xContainer( getForms(), UNO_QUERY ); 552cdf0e10cSrcweir pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel, 553cdf0e10cSrcweir FmUndoContainerAction::Inserted, 554cdf0e10cSrcweir xContainer, 555cdf0e10cSrcweir xForm, 556cdf0e10cSrcweir xContainer->getCount())); 557cdf0e10cSrcweir } 558cdf0e10cSrcweir 559cdf0e10cSrcweir getForms()->insertByName( sName, makeAny( xForm ) ); 560cdf0e10cSrcweir 561cdf0e10cSrcweir if( bUndo ) 562cdf0e10cSrcweir pModel->EndUndo(); 563cdf0e10cSrcweir } 564cdf0e10cSrcweir xCurrentForm = xForm; 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir xForm = getDefaultForm(); 568cdf0e10cSrcweir return xForm; 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir //------------------------------------------------------------------------------ 572cdf0e10cSrcweir Reference< XForm > FmFormPageImpl::findFormForDataSource( 573cdf0e10cSrcweir const Reference< XForm > & rForm, const Reference< XDataSource > & _rxDatabase, 574cdf0e10cSrcweir const ::rtl::OUString& _rCursorSource, sal_Int32 nCommandType) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::findFormForDataSource" ); 577cdf0e10cSrcweir Reference< XForm > xResultForm; 578cdf0e10cSrcweir Reference< XRowSet > xDBForm(rForm, UNO_QUERY); 579cdf0e10cSrcweir Reference< XPropertySet > xFormProps(rForm, UNO_QUERY); 580cdf0e10cSrcweir if (!xDBForm.is() || !xFormProps.is()) 581cdf0e10cSrcweir return xResultForm; 582cdf0e10cSrcweir 583cdf0e10cSrcweir OSL_ENSURE(_rxDatabase.is(), "FmFormPageImpl::findFormForDataSource: invalid data source!"); 584cdf0e10cSrcweir ::rtl::OUString sLookupName; // the name of the data source we're looking for 585cdf0e10cSrcweir ::rtl::OUString sFormDataSourceName; // the name of the data source the current connection in the form is based on 586cdf0e10cSrcweir try 587cdf0e10cSrcweir { 588cdf0e10cSrcweir Reference< XPropertySet > xDSProps(_rxDatabase, UNO_QUERY); 589cdf0e10cSrcweir if (xDSProps.is()) 590cdf0e10cSrcweir xDSProps->getPropertyValue(FM_PROP_NAME) >>= sLookupName; 591cdf0e10cSrcweir 592cdf0e10cSrcweir xFormProps->getPropertyValue(FM_PROP_DATASOURCE) >>= sFormDataSourceName; 593cdf0e10cSrcweir // if there's no DataSourceName set at the form, check whether we can deduce one from its 594cdf0e10cSrcweir // ActiveConnection 595cdf0e10cSrcweir if (0 == sFormDataSourceName.getLength()) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir Reference< XConnection > xFormConnection; 598cdf0e10cSrcweir xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ) >>= xFormConnection; 599cdf0e10cSrcweir if ( !xFormConnection.is() ) 600cdf0e10cSrcweir OStaticDataAccessTools().isEmbeddedInDatabase( xFormProps, xFormConnection ); 601cdf0e10cSrcweir if (xFormConnection.is()) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir Reference< XChild > xConnAsChild(xFormConnection, UNO_QUERY); 604cdf0e10cSrcweir if (xConnAsChild.is()) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir Reference< XDataSource > xFormDS(xConnAsChild->getParent(), UNO_QUERY); 607cdf0e10cSrcweir if (xFormDS.is()) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir xDSProps = xDSProps.query(xFormDS); 610cdf0e10cSrcweir if (xDSProps.is()) 611cdf0e10cSrcweir xDSProps->getPropertyValue(FM_PROP_NAME) >>= sFormDataSourceName; 612cdf0e10cSrcweir } 613cdf0e10cSrcweir } 614cdf0e10cSrcweir } 615cdf0e10cSrcweir } 616cdf0e10cSrcweir } 617cdf0e10cSrcweir catch(const Exception& e) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir (void)e; 620cdf0e10cSrcweir OSL_ENSURE(sal_False, "FmFormPageImpl::findFormForDataSource: caught an exception!"); 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir if (sLookupName == sFormDataSourceName) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir // jetzt noch ueberpruefen ob CursorSource und Type uebereinstimmen 626cdf0e10cSrcweir ::rtl::OUString aCursorSource = ::comphelper::getString(xFormProps->getPropertyValue(FM_PROP_COMMAND)); 627cdf0e10cSrcweir sal_Int32 nType = ::comphelper::getINT32(xFormProps->getPropertyValue(FM_PROP_COMMANDTYPE)); 628cdf0e10cSrcweir if (!aCursorSource.getLength() || ((nType == nCommandType) && (aCursorSource == _rCursorSource))) // found the form 629cdf0e10cSrcweir { 630cdf0e10cSrcweir xResultForm = rForm; 631cdf0e10cSrcweir // Ist noch keine Datenquelle gesetzt, wird dieses hier nachgeholt 632cdf0e10cSrcweir if (!aCursorSource.getLength()) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_COMMAND, makeAny(_rCursorSource)); 635cdf0e10cSrcweir xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny((sal_Int32)nCommandType)); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir } 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir // as long as xResultForm is NULL, search the child forms of rForm 641cdf0e10cSrcweir Reference< XIndexAccess > xComponents(rForm, UNO_QUERY); 642cdf0e10cSrcweir sal_Int32 nCount = xComponents->getCount(); 643cdf0e10cSrcweir for (sal_Int32 i = 0; !xResultForm.is() && i < nCount; ++i) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir Reference< ::com::sun::star::form::XForm > xSearchForm; 646cdf0e10cSrcweir xComponents->getByIndex(i) >>= xSearchForm; 647cdf0e10cSrcweir // continue searching in the sub form 648cdf0e10cSrcweir if (xSearchForm.is()) 649cdf0e10cSrcweir xResultForm = findFormForDataSource( xSearchForm, _rxDatabase, _rCursorSource, nCommandType ); 650cdf0e10cSrcweir } 651cdf0e10cSrcweir return xResultForm; 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir //------------------------------------------------------------------------------ 655cdf0e10cSrcweir ::rtl::OUString FmFormPageImpl::setUniqueName(const Reference< XFormComponent > & xFormComponent, const Reference< XForm > & xControls) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 658cdf0e10cSrcweir try 659cdf0e10cSrcweir { 660cdf0e10cSrcweir Reference< XChild > xChild( xFormComponent, UNO_QUERY_THROW ); 661cdf0e10cSrcweir OSL_ENSURE( !xChild->getParent().is(), "FmFormPageImpl::setUniqueName: to be called before insertion!" ); 662cdf0e10cSrcweir } 663cdf0e10cSrcweir catch( const Exception& ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir #endif 668cdf0e10cSrcweir ::rtl::OUString sName; 669cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySet > xSet(xFormComponent, UNO_QUERY); 670cdf0e10cSrcweir if (xSet.is()) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir sName = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_NAME ) ); 673cdf0e10cSrcweir Reference< ::com::sun::star::container::XNameAccess > xNameAcc(xControls, UNO_QUERY); 674cdf0e10cSrcweir 675cdf0e10cSrcweir if (!sName.getLength() || xNameAcc->hasByName(sName)) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir // setzen eines default Namens ueber die ClassId 678cdf0e10cSrcweir sal_Int16 nClassId( FormComponentType::CONTROL ); 679cdf0e10cSrcweir xSet->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId; 680cdf0e10cSrcweir 681cdf0e10cSrcweir ::rtl::OUString sDefaultName = FormControlFactory::getDefaultUniqueName_ByComponentType( 682cdf0e10cSrcweir Reference< XNameAccess >( xControls, UNO_QUERY ), xSet ); 683cdf0e10cSrcweir 684cdf0e10cSrcweir // bei Radiobuttons, die einen Namen haben, diesen nicht ueberschreiben! 685cdf0e10cSrcweir if (!sName.getLength() || nClassId != ::com::sun::star::form::FormComponentType::RADIOBUTTON) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir xSet->setPropertyValue(FM_PROP_NAME, makeAny(sDefaultName)); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir 690cdf0e10cSrcweir sName = sDefaultName; 691cdf0e10cSrcweir } 692cdf0e10cSrcweir } 693cdf0e10cSrcweir return sName; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 697cdf0e10cSrcweir void FmFormPageImpl::formModelAssigned( const FmFormObj& _object ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); 700cdf0e10cSrcweir if ( !xControlShapeMap.is() ) 701cdf0e10cSrcweir // our map does not exist -> not interested in this event 702cdf0e10cSrcweir return; 703cdf0e10cSrcweir 704cdf0e10cSrcweir try 705cdf0e10cSrcweir { 706cdf0e10cSrcweir lcl_removeFormObject_throw( _object, xControlShapeMap, false ); 707cdf0e10cSrcweir lcl_insertFormObject_throw( _object, xControlShapeMap ); 708cdf0e10cSrcweir } 709cdf0e10cSrcweir catch( const Exception& ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 716cdf0e10cSrcweir void FmFormPageImpl::formObjectInserted( const FmFormObj& _object ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); 719cdf0e10cSrcweir if ( !xControlShapeMap.is() ) 720cdf0e10cSrcweir // our map does not exist -> not interested in this event 721cdf0e10cSrcweir return; 722cdf0e10cSrcweir 723cdf0e10cSrcweir try 724cdf0e10cSrcweir { 725cdf0e10cSrcweir lcl_insertFormObject_throw( _object, xControlShapeMap ); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir catch( const Exception& ) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir } 732cdf0e10cSrcweir 733cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 734cdf0e10cSrcweir void FmFormPageImpl::formObjectRemoved( const FmFormObj& _object ) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY ); 737cdf0e10cSrcweir if ( !xControlShapeMap.is() ) 738cdf0e10cSrcweir // our map does not exist -> not interested in this event 739cdf0e10cSrcweir return; 740cdf0e10cSrcweir 741cdf0e10cSrcweir try 742cdf0e10cSrcweir { 743cdf0e10cSrcweir lcl_removeFormObject_throw( _object, xControlShapeMap ); 744cdf0e10cSrcweir } 745cdf0e10cSrcweir catch( const Exception& ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir } 750