update dev300-m58
[ooovba.git] / svx / source / form / fmobj.cxx
blob5a32ea831442719f69c46bbc2656203d142f1452
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmobj.cxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <tools/resmgr.hxx>
34 #include <tools/diagnose_ex.h>
35 #include "fmobj.hxx"
36 #include "fmprop.hrc"
37 #include "fmvwimp.hxx"
38 #include <svx/editeng.hxx>
39 #include <svx/svdovirt.hxx>
41 /** === begin UNO includes === **/
42 #include <com/sun/star/awt/XDevice.hpp>
43 #include <com/sun/star/script/XEventAttacherManager.hpp>
44 #include <com/sun/star/io/XPersistObject.hpp>
45 #include <com/sun/star/awt/XControlContainer.hpp>
46 /** === end UNO includes === **/
47 #include <svx/fmmodel.hxx>
48 #include "fmtools.hxx"
49 #include <tools/shl.hxx>
50 #include <svx/dialmgr.hxx>
52 #include "fmresids.hrc"
53 #include <svx/fmview.hxx>
54 #include <svx/fmglob.hxx>
56 #include "fmpgeimp.hxx"
57 #include <svx/fmpage.hxx>
58 #include <comphelper/property.hxx>
59 #include <comphelper/processfactory.hxx>
60 #include <toolkit/awt/vclxdevice.hxx>
61 #include <vcl/svapp.hxx>
63 using namespace ::com::sun::star::io;
64 using namespace ::com::sun::star::uno;
65 using namespace ::com::sun::star::awt;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::util;
68 using namespace ::com::sun::star::form;
69 using namespace ::com::sun::star::beans;
70 using namespace ::com::sun::star::script;
71 using namespace ::com::sun::star::container;
72 using namespace ::svxform;
74 TYPEINIT1(FmFormObj, SdrUnoObj);
75 DBG_NAME(FmFormObj);
76 //------------------------------------------------------------------
77 FmFormObj::FmFormObj(const ::rtl::OUString& rModelName,sal_Int32 _nType)
78 :SdrUnoObj ( rModelName )
79 ,m_nPos ( -1 )
80 ,m_nType ( _nType )
81 ,m_pLastKnownRefDevice ( NULL )
83 DBG_CTOR(FmFormObj, NULL);
86 //------------------------------------------------------------------
87 FmFormObj::FmFormObj( sal_Int32 _nType )
88 :SdrUnoObj ( String() )
89 ,m_nPos ( -1 )
90 ,m_nType ( _nType )
91 ,m_pLastKnownRefDevice ( NULL )
93 DBG_CTOR(FmFormObj, NULL);
96 //------------------------------------------------------------------
97 FmFormObj::~FmFormObj()
99 DBG_DTOR(FmFormObj, NULL);
101 Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
102 if (xHistory.is())
103 xHistory->dispose();
105 m_xEnvironmentHistory = NULL;
106 m_aEventsHistory.realloc(0);
109 //------------------------------------------------------------------
110 void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, const sal_Int32 nIdx,
111 const Sequence< ScriptEventDescriptor >& rEvts)
113 m_xParent = xForm;
114 aEvts = rEvts;
115 m_nPos = nIdx;
118 //------------------------------------------------------------------
119 void FmFormObj::ClearObjEnv()
121 m_xParent.clear();
122 aEvts.realloc( 0 );
123 m_nPos = -1;
126 //------------------------------------------------------------------
127 void FmFormObj::impl_isolateControlModel_nothrow()
131 Reference< XChild > xControlModel( GetUnoControlModel(), UNO_QUERY );
132 if ( xControlModel.is() )
134 Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
135 if ( xParent.is() )
137 sal_Int32 nPos = getElementPos( xParent.get(), xControlModel );
138 xParent->removeByIndex( nPos );
142 catch( const Exception& )
144 DBG_UNHANDLED_EXCEPTION();
148 //------------------------------------------------------------------
149 void FmFormObj::SetPage(SdrPage* _pNewPage)
151 if ( GetPage() == _pNewPage )
153 SdrUnoObj::SetPage(_pNewPage);
154 return;
157 FmFormPage* pOldFormPage = PTR_CAST( FmFormPage, GetPage() );
158 if ( pOldFormPage )
159 pOldFormPage->GetImpl().formObjectRemoved( *this );
161 FmFormPage* pNewFormPage = PTR_CAST( FmFormPage, _pNewPage );
162 if ( !pNewFormPage )
163 { // 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,
164 // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it.
165 // So the next SetPage with a valid new page would restore that environment within the new page.
166 // But for the original Bug (#57300#) we don't need that, so I omit it here. Maybe this will be implemented later.
167 impl_isolateControlModel_nothrow();
168 SdrUnoObj::SetPage(_pNewPage);
169 return;
172 Reference< XIndexContainer > xNewPageForms( pNewFormPage->GetForms( true ), UNO_QUERY );
173 Reference< XIndexContainer > xNewParent;
174 Sequence< ScriptEventDescriptor> aNewEvents;
176 // calc the new parent for my model (within the new page's forms hierarchy)
177 // do we have a history ? (from :Clone)
178 if ( m_xEnvironmentHistory.is() )
180 // the element in m_xEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within _pNewPage->GetForms)
181 // is the right-most element in the tree.
182 Reference< XIndexContainer > xRightMostLeaf = m_xEnvironmentHistory;
185 while ( xRightMostLeaf->getCount() )
187 xRightMostLeaf.set(
188 xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
189 UNO_QUERY_THROW
193 xNewParent.set( ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
195 // we successfully cloned the environment in m_xEnvironmentHistory, so we can use m_aEventsHistory
196 // (which describes the events of our model at the moment m_xEnvironmentHistory was created)
197 aNewEvents = m_aEventsHistory;
199 catch( const Exception& )
201 DBG_UNHANDLED_EXCEPTION();
205 if ( !xNewParent.is() )
207 // are we a valid part of our current page forms ?
208 Reference< XIndexContainer > xOldForms;
209 if ( pOldFormPage )
210 xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW );
212 if ( xOldForms.is() )
214 // search (upward from our model) for xOldForms
215 Reference< XChild > xSearch( GetUnoControlModel(), UNO_QUERY );
216 while (xSearch.is())
218 if ( xSearch == xOldForms )
219 break;
220 xSearch = Reference< XChild >( xSearch->getParent(), UNO_QUERY );
222 if ( xSearch.is() ) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
224 Reference< XChild > xMeAsChild( GetUnoControlModel(), UNO_QUERY );
225 xNewParent.set( ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
227 if ( xNewParent.is() )
231 // transfer the events from our (model's) parent to the new (model's) parent, too
232 Reference< XEventAttacherManager > xEventManager(xMeAsChild->getParent(), UNO_QUERY);
233 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
234 if (xManagerAsIndex.is())
236 sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsChild);
237 if (nPos >= 0)
238 aNewEvents = xEventManager->getScriptEvents(nPos);
240 else
241 aNewEvents = aEvts;
243 catch( const Exception& )
245 DBG_UNHANDLED_EXCEPTION();
252 // now set the page
253 SdrUnoObj::SetPage(_pNewPage);
255 // place my model within the new parent container
256 if (xNewParent.is())
258 Reference< XFormComponent > xMeAsFormComp(GetUnoControlModel(), UNO_QUERY);
259 if (xMeAsFormComp.is())
261 // check if I have another parent (and remove me, if neccessary)
262 Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY);
263 if (xOldParent.is())
265 sal_Int32 nPos = getElementPos(Reference< XIndexAccess > (xOldParent, UNO_QUERY), xMeAsFormComp);
266 if (nPos > -1)
267 xOldParent->removeByIndex(nPos);
269 // and insert into the new container
270 xNewParent->insertByIndex(xNewParent->getCount(), makeAny(xMeAsFormComp));
272 // transfer the events
273 if (aNewEvents.getLength())
277 Reference< XEventAttacherManager > xEventManager(xNewParent, UNO_QUERY);
278 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
279 if (xManagerAsIndex.is())
281 sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsFormComp);
282 DBG_ASSERT(nPos >= 0, "FmFormObj::SetPage : inserted but not present ?");
283 xEventManager->registerScriptEvents(nPos, aNewEvents);
286 catch( const Exception& )
288 DBG_UNHANDLED_EXCEPTION();
295 // delete my history
296 Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
297 if (xHistory.is())
298 xHistory->dispose();
300 m_xEnvironmentHistory = NULL;
301 m_aEventsHistory.realloc(0);
303 if ( pNewFormPage )
304 pNewFormPage->GetImpl().formObjectInserted( *this );
307 //------------------------------------------------------------------
308 sal_uInt32 FmFormObj::GetObjInventor() const
310 return FmFormInventor;
313 //------------------------------------------------------------------
314 sal_uInt16 FmFormObj::GetObjIdentifier() const
316 return OBJ_UNO;
319 //------------------------------------------------------------------
320 void FmFormObj::clonedFrom(const FmFormObj* _pSource)
322 DBG_ASSERT(_pSource != NULL, "FmFormObj::clonedFrom : invalid source !");
323 Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
324 if (xHistory.is())
325 xHistory->dispose();
327 m_xEnvironmentHistory = NULL;
328 m_aEventsHistory.realloc(0);
330 Reference< XChild > xSourceAsChild(_pSource->GetUnoControlModel(), UNO_QUERY);
331 if (!xSourceAsChild.is())
332 return;
334 Reference< XInterface > xSourceContainer = xSourceAsChild->getParent();
336 m_xEnvironmentHistory = Reference< XIndexContainer >(
337 ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.form.Forms")),
338 UNO_QUERY);
339 DBG_ASSERT(m_xEnvironmentHistory.is(), "FmFormObj::clonedFrom : could not create a forms collection !");
341 if (m_xEnvironmentHistory.is())
343 ensureModelEnv(xSourceContainer, m_xEnvironmentHistory);
344 m_aEventsHistory = aEvts;
345 // if we we're clone there was a call to operator=, so aEvts are excatly the events we need here ...
349 //------------------------------------------------------------------
350 SdrObject* FmFormObj::Clone() const
352 SdrObject* pReturn = SdrUnoObj::Clone();
354 FmFormObj* pFormObject = PTR_CAST(FmFormObj, pReturn);
355 DBG_ASSERT(pFormObject != NULL, "FmFormObj::Clone : invalid clone !");
356 if (pFormObject)
357 pFormObject->clonedFrom(this);
359 return pReturn;
362 //------------------------------------------------------------------
363 void FmFormObj::ReformatText()
365 const FmFormModel* pFormModel = PTR_CAST( FmFormModel, GetModel() );
366 OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
368 if ( m_pLastKnownRefDevice != pCurrentRefDevice )
370 m_pLastKnownRefDevice = pCurrentRefDevice;
374 Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY );
375 Reference< XPropertySetInfo > xPropertyInfo;
376 if ( xModelProps.is() )
377 xPropertyInfo = xModelProps->getPropertySetInfo();
379 const ::rtl::OUString sRefDevicePropName( RTL_CONSTASCII_USTRINGPARAM( "ReferenceDevice" ) );
380 if ( xPropertyInfo.is() && xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
382 VCLXDevice* pUnoRefDevice = new VCLXDevice;
383 pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
384 Reference< XDevice > xRefDevice( pUnoRefDevice );
385 xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
388 catch( const Exception& )
390 OSL_ENSURE( sal_False, "FmFormObj::ReformatText: caught an exception!" );
394 SdrUnoObj::ReformatText();
397 //------------------------------------------------------------------
398 void FmFormObj::operator= (const SdrObject& rObj)
400 SdrUnoObj::operator= (rObj);
402 FmFormObj* pFormObj = PTR_CAST(FmFormObj, &rObj);
403 if (pFormObj)
405 // liegt das UnoControlModel in einer Eventumgebung,
406 // dann koennen noch Events zugeordnet sein
407 Reference< XFormComponent > xContent(pFormObj->xUnoControlModel, UNO_QUERY);
408 if (xContent.is())
410 Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY);
411 Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY);
412 if (xManagerAsIndex.is())
414 sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent );
415 if ( nPos >= 0 )
416 aEvts = xManager->getScriptEvents( nPos );
419 else
420 aEvts = pFormObj->aEvts;
424 //------------------------------------------------------------------
425 Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _rTopLevelDestContainer)
427 Reference< XInterface > xTopLevelSouce;
428 String sAccessPath = getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce);
429 if (!xTopLevelSouce.is())
430 // somthing went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy
431 return Reference< XInterface > ();
433 Reference< XIndexContainer > xDestContainer(_rTopLevelDestContainer);
434 Reference< XIndexContainer > xSourceContainer(xTopLevelSouce, UNO_QUERY);
435 DBG_ASSERT(xSourceContainer.is(), "FmFormObj::ensureModelEnv : the top level source is invalid !");
437 for (xub_StrLen i=0; i<sAccessPath.GetTokenCount('\\'); ++i)
439 sal_uInt16 nIndex = (sal_uInt16)sAccessPath.GetToken(i, '\\').ToInt32();
441 // get the DSS of the source form (we have to find an aquivalent for)
442 DBG_ASSERT(nIndex<xSourceContainer->getCount(), "FmFormObj::ensureModelEnv : invalid access path !");
443 Reference< XPropertySet > xSourceForm;
444 xSourceContainer->getByIndex(nIndex) >>= xSourceForm;
445 DBG_ASSERT(xSourceForm.is(), "FmFormObj::ensureModelEnv : invalid source form !");
447 Any aSrcCursorSource, aSrcCursorSourceType, aSrcDataSource;
448 DBG_ASSERT(::comphelper::hasProperty(FM_PROP_COMMAND, xSourceForm) && ::comphelper::hasProperty(FM_PROP_COMMANDTYPE, xSourceForm)
449 && ::comphelper::hasProperty(FM_PROP_DATASOURCE, xSourceForm), "FmFormObj::ensureModelEnv : invalid access path or invalid form (missing props) !");
450 // the parent access path should refer to a row set
453 aSrcCursorSource = xSourceForm->getPropertyValue(FM_PROP_COMMAND);
454 aSrcCursorSourceType = xSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE);
455 aSrcDataSource = xSourceForm->getPropertyValue(FM_PROP_DATASOURCE);
457 catch(Exception&)
459 DBG_ERROR("FmFormObj::ensureModelEnv : could not retrieve a source DSS !");
463 // calc the number of (source) form siblings with the same DSS
464 Reference< XPropertySet > xCurrentSourceForm, xCurrentDestForm;
465 sal_Int16 nCurrentSourceIndex = 0, nCurrentDestIndex = 0;
466 while (nCurrentSourceIndex <= nIndex)
468 sal_Bool bEqualDSS = sal_False;
469 while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bounded by nIndex)
471 xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
472 DBG_ASSERT(xCurrentSourceForm.is(), "FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
473 bEqualDSS = sal_False;
474 if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentSourceForm))
475 { // it is a form
478 if ( ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
479 && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
480 && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
483 bEqualDSS = sal_True;
486 catch(Exception&)
488 DBG_ERROR("FmFormObj::ensureModelEnv : exception while getting a sibling's DSS !");
492 ++nCurrentSourceIndex;
495 DBG_ASSERT(bEqualDSS, "FmFormObj::ensureModelEnv : found no source form !");
496 // ??? at least the nIndex-th one should have been found ???
498 // now search the next one with the given DSS (within the destination container)
499 bEqualDSS = sal_False;
500 while (!bEqualDSS && (nCurrentDestIndex < xDestContainer->getCount()))
502 xDestContainer->getByIndex(nCurrentDestIndex) >>= xCurrentDestForm;
503 DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid destination form !");
504 bEqualDSS = sal_False;
505 if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentDestForm))
506 { // it is a form
509 if ( ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
510 && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
511 && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
514 bEqualDSS = sal_True;
517 catch(Exception&)
519 DBG_ERROR("FmFormObj::ensureModelEnv : exception while getting a destination DSS !");
523 ++nCurrentDestIndex;
526 if (!bEqualDSS)
527 { // There is at least one more source form with the given DSS than destination forms are.
528 // correct this ...
531 Reference< XPersistObject > xSourcePersist(xCurrentSourceForm, UNO_QUERY);
532 DBG_ASSERT(xSourcePersist.is(), "FmFormObj::ensureModelEnv : invalid form (no persist object) !");
534 // create and insert (into the destination) a clone of the form
535 xCurrentDestForm = Reference< XPropertySet > (cloneUsingProperties(xSourcePersist), UNO_QUERY);
536 DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid cloned form !");
538 DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !");
539 xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm));
541 ++nCurrentDestIndex;
542 // like nCurrentSourceIndex, nCurrentDestIndex now points 'behind' the form it actally means
544 catch(Exception&)
546 DBG_ERROR("FmFormObj::ensureModelEnv : something went seriously wrong while creating a new form !");
547 // no more options anymore ...
548 return Reference< XInterface > ();
554 // now xCurrentDestForm is a form aequivalent to xSourceForm (which means they have the same DSS and the same number
555 // of left siblings with the same DSS, which counts for all their ancestors, too)
557 // go down
558 xDestContainer = Reference< XIndexContainer > (xCurrentDestForm, UNO_QUERY);
559 xSourceContainer = Reference< XIndexContainer > (xSourceForm, UNO_QUERY);
560 DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(), "FmFormObj::ensureModelEnv : invalid container !");
563 return Reference< XInterface > (xDestContainer, UNO_QUERY);
566 //------------------------------------------------------------------
567 FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
569 FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
570 if ( !pFormObject )
572 SdrVirtObj* pVirtualObject = dynamic_cast< SdrVirtObj* >( _pSdrObject );
573 if ( pVirtualObject )
574 pFormObject = dynamic_cast< FmFormObj* >( &pVirtualObject->ReferencedObj() );
576 return pFormObject;
579 //------------------------------------------------------------------
580 const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject )
582 const FmFormObj* pFormObject = dynamic_cast< const FmFormObj* >( _pSdrObject );
583 if ( !pFormObject )
585 const SdrVirtObj* pVirtualObject = dynamic_cast< const SdrVirtObj* >( _pSdrObject );
586 if ( pVirtualObject )
587 pFormObject = dynamic_cast< const FmFormObj* >( &pVirtualObject->GetReferencedObj() );
589 return pFormObject;
592 //------------------------------------------------------------------
593 void FmFormObj::SetUnoControlModel( const Reference< com::sun::star::awt::XControlModel >& _rxModel )
595 SdrUnoObj::SetUnoControlModel( _rxModel );
597 // TODO: call something like formObjectInserted at the form page, to tell it the new model
600 //------------------------------------------------------------------
601 FASTBOOL FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
603 bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
604 if ( bResult && SDRCREATE_FORCEEND == eCmd && rStat.GetView() )
606 if ( pPage )
608 FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pPage );
612 Reference< XFormComponent > xContent( xUnoControlModel, UNO_QUERY_THROW );
613 Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
615 Reference< XIndexContainer > xFormToInsertInto;
617 if ( !xParentForm.is() )
618 { // model is not yet part of a form component hierachy
619 xParentForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
620 xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
623 rPage.GetImpl().setUniqueName( xContent, xParentForm );
625 if ( xFormToInsertInto.is() )
626 xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) );
628 catch( const Exception& )
630 DBG_UNHANDLED_EXCEPTION();
634 FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
635 FmXFormView* pViewImpl = pView ? pView->GetImpl() : NULL;
636 OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
637 if ( pViewImpl )
638 pViewImpl->onCreatedFormObject( *this );
640 return bResult;
643 //------------------------------------------------------------------------------
644 void FmFormObj::BrkCreate( SdrDragStat& rStat )
646 SdrUnoObj::BrkCreate( rStat );
647 impl_isolateControlModel_nothrow();
650 // -----------------------------------------------------------------------------
651 sal_Int32 FmFormObj::getType() const
653 return m_nType;
656 // -----------------------------------------------------------------------------
657 // #i70852# overload Layer interface to force to FormColtrol layer
659 SdrLayerID FmFormObj::GetLayer() const
661 // #i72535#
662 // i70852 was too radical, in SW obects (and thus, FormControls, too)
663 // get moved to invisible layers to hide them (e.g. in hidden sections).
664 // This means that form controls ARE allowed to be on other layers than
665 // the form control layer ATM and that being member of form control layer
666 // is no criteria to find all FormControls of a document.
667 // To fix, use parent functionality
668 return SdrUnoObj::GetLayer();
671 void FmFormObj::NbcSetLayer(SdrLayerID nLayer)
673 // #i72535#
674 // See above. To fix, use parent functionality
675 return SdrUnoObj::NbcSetLayer(nLayer);
678 // eof