lok: Don't attempt to select the exact text after a failed search.
[LibreOffice.git] / svx / source / form / fmobj.cxx
blob0ce45b66c13070476a358b51562a105a3eea2de5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fmobj.hxx"
21 #include "fmprop.hrc"
22 #include "fmvwimp.hxx"
23 #include "fmpgeimp.hxx"
24 #include "svx/fmresids.hrc"
25 #include "svx/fmview.hxx"
26 #include "svx/fmglob.hxx"
27 #include "svx/fmpage.hxx"
28 #include "editeng/editeng.hxx"
29 #include "svx/svdovirt.hxx"
30 #include "svx/fmmodel.hxx"
31 #include "svx/dialmgr.hxx"
33 #include <com/sun/star/awt/XDevice.hpp>
34 #include <com/sun/star/awt/XControlContainer.hpp>
35 #include <com/sun/star/form/Forms.hpp>
36 #include <com/sun/star/io/XPersistObject.hpp>
37 #include <com/sun/star/script/XEventAttacherManager.hpp>
38 #include <com/sun/star/util/XCloneable.hpp>
39 #include "svx/fmtools.hxx"
41 #include <comphelper/property.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <toolkit/awt/vclxdevice.hxx>
44 #include <vcl/svapp.hxx>
45 #include <tools/diagnose_ex.h>
47 using namespace ::com::sun::star::io;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::awt;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::util;
52 using namespace ::com::sun::star::form;
53 using namespace ::com::sun::star::beans;
54 using namespace ::com::sun::star::script;
55 using namespace ::com::sun::star::container;
56 using namespace ::svxform;
58 TYPEINIT1(FmFormObj, SdrUnoObj);
60 FmFormObj::FmFormObj(const OUString& rModelName)
61 :SdrUnoObj ( rModelName )
62 ,m_nPos ( -1 )
63 ,m_pLastKnownRefDevice ( NULL )
66 // normally, this is done in SetUnoControlModel, but if the call happened in the base class ctor,
67 // then our incarnation of it was not called (since we were not constructed at this time).
68 impl_checkRefDevice_nothrow( true );
72 FmFormObj::FmFormObj()
73 :SdrUnoObj ( "" )
74 ,m_nPos ( -1 )
75 ,m_pLastKnownRefDevice ( NULL )
80 FmFormObj::~FmFormObj()
83 if (m_xEnvironmentHistory.is())
84 m_xEnvironmentHistory->dispose();
86 m_xEnvironmentHistory = NULL;
87 m_aEventsHistory.realloc(0);
91 void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, const sal_Int32 nIdx,
92 const Sequence< ScriptEventDescriptor >& rEvts)
94 m_xParent = xForm;
95 aEvts = rEvts;
96 m_nPos = nIdx;
100 void FmFormObj::ClearObjEnv()
102 m_xParent.clear();
103 aEvts.realloc( 0 );
104 m_nPos = -1;
108 void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
110 const FmFormModel* pFormModel = PTR_CAST( FmFormModel, GetModel() );
111 if ( !pFormModel || !pFormModel->ControlsUseRefDevice() )
112 return;
114 OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
115 if ( ( m_pLastKnownRefDevice.get() == pCurrentRefDevice ) && !_force )
116 return;
118 Reference< XControlModel > xControlModel( GetUnoControlModel() );
119 if ( !xControlModel.is() )
120 return;
122 m_pLastKnownRefDevice = pCurrentRefDevice;
123 if ( !m_pLastKnownRefDevice )
124 return;
128 Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
129 Reference< XPropertySetInfo > xPropertyInfo( xModelProps->getPropertySetInfo(), UNO_SET_THROW );
131 static const char sRefDevicePropName[] = "ReferenceDevice";
132 if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
134 VCLXDevice* pUnoRefDevice = new VCLXDevice;
135 pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
136 Reference< XDevice > xRefDevice( pUnoRefDevice );
137 xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
140 catch( const Exception& )
142 DBG_UNHANDLED_EXCEPTION();
147 void FmFormObj::impl_isolateControlModel_nothrow()
151 Reference< XChild > xControlModel( GetUnoControlModel(), UNO_QUERY );
152 if ( xControlModel.is() )
154 Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
155 if ( xParent.is() )
157 sal_Int32 nPos = getElementPos( xParent.get(), xControlModel );
158 xParent->removeByIndex( nPos );
162 catch( const Exception& )
164 DBG_UNHANDLED_EXCEPTION();
169 void FmFormObj::SetPage(SdrPage* _pNewPage)
171 if ( GetPage() == _pNewPage )
173 SdrUnoObj::SetPage(_pNewPage);
174 return;
177 FmFormPage* pOldFormPage = PTR_CAST( FmFormPage, GetPage() );
178 if ( pOldFormPage )
179 pOldFormPage->GetImpl().formObjectRemoved( *this );
181 FmFormPage* pNewFormPage = PTR_CAST( FmFormPage, _pNewPage );
182 if ( !pNewFormPage )
183 { // 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,
184 // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it.
185 // So the next SetPage with a valid new page would restore that environment within the new page.
186 // But for the original Bug (#57300#) we don't need that, so I omit it here. Maybe this will be implemented later.
187 impl_isolateControlModel_nothrow();
188 SdrUnoObj::SetPage(_pNewPage);
189 return;
192 Reference< css::form::XForms > xNewPageForms = pNewFormPage->GetForms( true );
193 Reference< XIndexContainer > xNewParent;
194 Sequence< ScriptEventDescriptor> aNewEvents;
196 // calc the new parent for my model (within the new page's forms hierarchy)
197 // do we have a history ? (from :Clone)
198 if ( m_xEnvironmentHistory.is() )
200 // the element in m_xEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within _pNewPage->GetForms)
201 // is the right-most element in the tree.
202 Reference< XIndexContainer > xRightMostLeaf( m_xEnvironmentHistory, UNO_QUERY_THROW );
205 while ( xRightMostLeaf->getCount() )
207 xRightMostLeaf.set(
208 xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
209 UNO_QUERY_THROW
213 xNewParent.set( ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
215 // we successfully cloned the environment in m_xEnvironmentHistory, so we can use m_aEventsHistory
216 // (which describes the events of our model at the moment m_xEnvironmentHistory was created)
217 aNewEvents = m_aEventsHistory;
219 catch( const Exception& )
221 DBG_UNHANDLED_EXCEPTION();
225 if ( !xNewParent.is() )
227 // are we a valid part of our current page forms ?
228 Reference< XIndexContainer > xOldForms;
229 if ( pOldFormPage )
230 xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW );
232 if ( xOldForms.is() )
234 // search (upward from our model) for xOldForms
235 Reference< XChild > xSearch( GetUnoControlModel(), UNO_QUERY );
236 while (xSearch.is())
238 if ( xSearch == xOldForms )
239 break;
240 xSearch = Reference< XChild >( xSearch->getParent(), UNO_QUERY );
242 if ( xSearch.is() ) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
244 Reference< XChild > xMeAsChild( GetUnoControlModel(), UNO_QUERY );
245 xNewParent.set( ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
247 if ( xNewParent.is() )
251 // transfer the events from our (model's) parent to the new (model's) parent, too
252 Reference< XEventAttacherManager > xEventManager(xMeAsChild->getParent(), UNO_QUERY);
253 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
254 if (xManagerAsIndex.is())
256 sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsChild);
257 if (nPos >= 0)
258 aNewEvents = xEventManager->getScriptEvents(nPos);
260 else
261 aNewEvents = aEvts;
263 catch( const Exception& )
265 DBG_UNHANDLED_EXCEPTION();
272 // now set the page
273 SdrUnoObj::SetPage(_pNewPage);
275 // place my model within the new parent container
276 if (xNewParent.is())
278 Reference< XFormComponent > xMeAsFormComp(GetUnoControlModel(), UNO_QUERY);
279 if (xMeAsFormComp.is())
281 // check if I have another parent (and remove me, if necessary)
282 Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY);
283 if (xOldParent.is())
285 sal_Int32 nPos = getElementPos(xOldParent, xMeAsFormComp);
286 if (nPos > -1)
287 xOldParent->removeByIndex(nPos);
289 // and insert into the new container
290 xNewParent->insertByIndex(xNewParent->getCount(), makeAny(xMeAsFormComp));
292 // transfer the events
293 if (aNewEvents.getLength())
297 Reference< XEventAttacherManager > xEventManager(xNewParent, UNO_QUERY);
298 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
299 if (xManagerAsIndex.is())
301 sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsFormComp);
302 DBG_ASSERT(nPos >= 0, "FmFormObj::SetPage : inserted but not present ?");
303 xEventManager->registerScriptEvents(nPos, aNewEvents);
306 catch( const Exception& )
308 DBG_UNHANDLED_EXCEPTION();
315 // delete my history
316 if (m_xEnvironmentHistory.is())
317 m_xEnvironmentHistory->dispose();
319 m_xEnvironmentHistory = NULL;
320 m_aEventsHistory.realloc(0);
322 if ( pNewFormPage )
323 pNewFormPage->GetImpl().formObjectInserted( *this );
327 sal_uInt32 FmFormObj::GetObjInventor() const
329 return FmFormInventor;
333 sal_uInt16 FmFormObj::GetObjIdentifier() const
335 return OBJ_UNO;
339 void FmFormObj::clonedFrom(const FmFormObj* _pSource)
341 DBG_ASSERT(_pSource != NULL, "FmFormObj::clonedFrom : invalid source !");
342 if (m_xEnvironmentHistory.is())
343 m_xEnvironmentHistory->dispose();
345 m_xEnvironmentHistory = NULL;
346 m_aEventsHistory.realloc(0);
348 Reference< XChild > xSourceAsChild(_pSource->GetUnoControlModel(), UNO_QUERY);
349 if (!xSourceAsChild.is())
350 return;
352 Reference< XInterface > xSourceContainer = xSourceAsChild->getParent();
354 m_xEnvironmentHistory = css::form::Forms::create( comphelper::getProcessComponentContext() );
356 ensureModelEnv(xSourceContainer, m_xEnvironmentHistory);
357 m_aEventsHistory = aEvts;
358 // if we were clone there was a call to operator=, so aEvts are exactly the events we need here...
362 FmFormObj* FmFormObj::Clone() const
364 FmFormObj* pFormObject = CloneHelper< FmFormObj >();
365 DBG_ASSERT(pFormObject != NULL, "FmFormObj::Clone : invalid clone !");
366 if (pFormObject)
367 pFormObject->clonedFrom(this);
369 return pFormObject;
373 void FmFormObj::NbcReformatText()
375 impl_checkRefDevice_nothrow( false );
376 SdrUnoObj::NbcReformatText();
380 FmFormObj& FmFormObj::operator= (const FmFormObj& rObj)
382 if( this == &rObj )
383 return *this;
384 SdrUnoObj::operator= (rObj);
386 // If UnoControlModel is part of an event environment,
387 // events may assigned to it.
388 Reference< XFormComponent > xContent(rObj.xUnoControlModel, UNO_QUERY);
389 if (xContent.is())
391 Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY);
392 Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY);
393 if (xManagerAsIndex.is())
395 sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent );
396 if ( nPos >= 0 )
397 aEvts = xManager->getScriptEvents( nPos );
400 else
401 aEvts = rObj.aEvts;
402 return *this;
406 namespace
408 OUString lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement)
410 Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY);
411 Reference< ::com::sun::star::container::XIndexAccess> xParent;
412 if (xChild.is())
413 xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
415 // while the current content is a form
416 OUString sReturn;
417 OUString sCurrentIndex;
418 while (xChild.is())
420 // get the content's relative pos within its parent container
421 sal_Int32 nPos = getElementPos(xParent, xChild);
423 // prepend this current relaive pos
424 sCurrentIndex = OUString::number(nPos);
425 if (!sReturn.isEmpty())
427 sCurrentIndex += "\\";
428 sCurrentIndex += sReturn;
431 sReturn = sCurrentIndex;
433 // travel up
434 xChild.set(xParent, css::uno::UNO_QUERY);
435 if (xChild.is())
436 xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
439 _rTopLevelElement = xParent;
440 return sReturn;
445 Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const Reference<css::form::XForms>& _rTopLevelDestContainer)
447 Reference< XInterface > xTopLevelSource;
448 OUString sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSource);
449 if (!xTopLevelSource.is())
450 // something went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy
451 return Reference< XInterface > ();
453 Reference< XIndexContainer > xDestContainer(_rTopLevelDestContainer, UNO_QUERY_THROW);
454 Reference< XIndexContainer > xSourceContainer(xTopLevelSource, UNO_QUERY);
455 DBG_ASSERT(xSourceContainer.is(), "FmFormObj::ensureModelEnv : the top level source is invalid !");
457 sal_Int32 nTokIndex = 0;
460 OUString aToken = sAccessPath.getToken( 0, '\\', nTokIndex );
461 sal_uInt16 nIndex = (sal_uInt16)aToken.toInt32();
463 // get the DSS of the source form (we have to find an aquivalent for)
464 DBG_ASSERT(nIndex<xSourceContainer->getCount(), "FmFormObj::ensureModelEnv : invalid access path !");
465 Reference< XPropertySet > xSourceForm;
466 xSourceContainer->getByIndex(nIndex) >>= xSourceForm;
467 DBG_ASSERT(xSourceForm.is(), "FmFormObj::ensureModelEnv : invalid source form !");
469 Any aSrcCursorSource, aSrcCursorSourceType, aSrcDataSource;
470 DBG_ASSERT(::comphelper::hasProperty(FM_PROP_COMMAND, xSourceForm) && ::comphelper::hasProperty(FM_PROP_COMMANDTYPE, xSourceForm)
471 && ::comphelper::hasProperty(FM_PROP_DATASOURCE, xSourceForm), "FmFormObj::ensureModelEnv : invalid access path or invalid form (missing props) !");
472 // the parent access path should refer to a row set
475 aSrcCursorSource = xSourceForm->getPropertyValue(FM_PROP_COMMAND);
476 aSrcCursorSourceType = xSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE);
477 aSrcDataSource = xSourceForm->getPropertyValue(FM_PROP_DATASOURCE);
479 catch(Exception&)
481 OSL_FAIL("FmFormObj::ensureModelEnv : could not retrieve a source DSS !");
485 // calc the number of (source) form siblings with the same DSS
486 Reference< XPropertySet > xCurrentSourceForm, xCurrentDestForm;
487 sal_Int16 nCurrentSourceIndex = 0, nCurrentDestIndex = 0;
488 while (nCurrentSourceIndex <= nIndex)
490 bool bEqualDSS = false;
491 while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bound by nIndex)
493 xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
494 DBG_ASSERT(xCurrentSourceForm.is(), "FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
495 bEqualDSS = false;
496 if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentSourceForm))
497 { // it is a form
500 if ( ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
501 && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
502 && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
505 bEqualDSS = true;
508 catch(Exception&)
510 OSL_FAIL("FmFormObj::ensureModelEnv : exception while getting a sibling's DSS !");
514 ++nCurrentSourceIndex;
517 DBG_ASSERT(bEqualDSS, "FmFormObj::ensureModelEnv : found no source form !");
518 // ??? at least the nIndex-th one should have been found ???
520 // now search the next one with the given DSS (within the destination container)
521 bEqualDSS = false;
522 while (!bEqualDSS && (nCurrentDestIndex < xDestContainer->getCount()))
524 xDestContainer->getByIndex(nCurrentDestIndex) >>= xCurrentDestForm;
525 DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid destination form !");
526 bEqualDSS = false;
527 if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentDestForm))
528 { // it is a form
531 if ( ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
532 && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
533 && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
536 bEqualDSS = true;
539 catch(Exception&)
541 OSL_FAIL("FmFormObj::ensureModelEnv : exception while getting a destination DSS !");
545 ++nCurrentDestIndex;
548 if (!bEqualDSS)
549 { // There is at least one more source form with the given DSS than destination forms are.
550 // correct this ...
553 // create and insert (into the destination) a copy of the form
554 xCurrentDestForm.set(
555 ::comphelper::getProcessServiceFactory()->createInstance("com.sun.star.form.component.DataForm"),
556 UNO_QUERY_THROW );
557 ::comphelper::copyProperties( xCurrentSourceForm, xCurrentDestForm );
559 DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !");
560 xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm));
562 ++nCurrentDestIndex;
563 // like nCurrentSourceIndex, nCurrentDestIndex now points 'behind' the form it actally means
565 catch(Exception&)
567 OSL_FAIL("FmFormObj::ensureModelEnv : something went seriously wrong while creating a new form !");
568 // no more options anymore ...
569 return Reference< XInterface > ();
575 // now xCurrentDestForm is a form equivalent to xSourceForm (which means they have the same DSS and the same number
576 // of left siblings with the same DSS, which counts for all their ancestors, too)
578 // go down
579 xDestContainer = Reference< XIndexContainer > (xCurrentDestForm, UNO_QUERY);
580 xSourceContainer = Reference< XIndexContainer > (xSourceForm, UNO_QUERY);
581 DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(), "FmFormObj::ensureModelEnv : invalid container !");
583 while ( nTokIndex >= 0 );
585 return Reference<XInterface>( xDestContainer, UNO_QUERY );
589 void FmFormObj::SetModel( SdrModel* _pNewModel )
591 SdrUnoObj::SetModel( _pNewModel );
592 impl_checkRefDevice_nothrow();
596 FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
598 FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
599 if ( !pFormObject )
601 SdrVirtObj* pVirtualObject = dynamic_cast< SdrVirtObj* >( _pSdrObject );
602 if ( pVirtualObject )
603 pFormObject = dynamic_cast< FmFormObj* >( &pVirtualObject->ReferencedObj() );
605 return pFormObject;
609 const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject )
611 const FmFormObj* pFormObject = dynamic_cast< const FmFormObj* >( _pSdrObject );
612 if ( !pFormObject )
614 const SdrVirtObj* pVirtualObject = dynamic_cast< const SdrVirtObj* >( _pSdrObject );
615 if ( pVirtualObject )
616 pFormObject = dynamic_cast< const FmFormObj* >( &pVirtualObject->GetReferencedObj() );
618 return pFormObject;
622 void FmFormObj::SetUnoControlModel( const Reference< com::sun::star::awt::XControlModel >& _rxModel )
624 SdrUnoObj::SetUnoControlModel( _rxModel );
626 FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetPage() );
627 if ( pFormPage )
628 pFormPage->GetImpl().formModelAssigned( *this );
630 impl_checkRefDevice_nothrow( true );
634 bool FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
636 bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
637 if ( bResult && SDRCREATE_FORCEEND == eCmd && rStat.GetView() )
639 if ( pPage )
641 FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pPage );
645 Reference< XFormComponent > xContent( xUnoControlModel, UNO_QUERY_THROW );
646 Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
648 Reference< XIndexContainer > xFormToInsertInto;
650 if ( !xParentForm.is() )
651 { // model is not yet part of a form component hierarchy
652 xParentForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
653 xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
656 FmFormPageImpl::setUniqueName( xContent, xParentForm );
658 if ( xFormToInsertInto.is() )
659 xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) );
661 catch( const Exception& )
663 DBG_UNHANDLED_EXCEPTION();
667 FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
668 FmXFormView* pViewImpl = pView ? pView->GetImpl() : NULL;
669 OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
670 if ( pViewImpl )
671 pViewImpl->onCreatedFormObject( *this );
673 return bResult;
677 void FmFormObj::BrkCreate( SdrDragStat& rStat )
679 SdrUnoObj::BrkCreate( rStat );
680 impl_isolateControlModel_nothrow();
682 FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
683 FmXFormView* pViewImpl = pView ? pView->GetImpl() : NULL;
684 OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
685 if ( pViewImpl )
686 pViewImpl->breakCreateFormObject();
690 // #i70852# override Layer interface to force to FormControl layer
692 SdrLayerID FmFormObj::GetLayer() const
694 // #i72535#
695 // i70852 was too radical, in SW obects (and thus, FormControls, too)
696 // get moved to invisible layers to hide them (e.g. in hidden sections).
697 // This means that form controls ARE allowed to be on other layers than
698 // the form control layer ATM and that being member of form control layer
699 // is no criteria to find all FormControls of a document.
700 // To fix, use parent functionality
701 return SdrUnoObj::GetLayer();
704 void FmFormObj::NbcSetLayer(SdrLayerID nLayer)
706 // #i72535#
707 // See above. To fix, use parent functionality
708 return SdrUnoObj::NbcSetLayer(nLayer);
711 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */