LibreOffice Module svx (master)  1
fmobj.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <fmobj.hxx>
21 #include <fmprop.hxx>
22 #include <fmvwimp.hxx>
23 #include <fmpgeimp.hxx>
24 #include <svx/fmview.hxx>
25 #include <svx/fmpage.hxx>
26 #include <svx/svdovirt.hxx>
27 #include <svx/fmmodel.hxx>
28 
29 #include <com/sun/star/awt/XDevice.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/form/Forms.hpp>
32 #include <com/sun/star/script/XEventAttacherManager.hpp>
33 #include <svx/fmtools.hxx>
34 
35 #include <comphelper/property.hxx>
38 #include <tools/debug.hxx>
39 #include <tools/diagnose_ex.h>
40 
41 using namespace ::com::sun::star::io;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::awt;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::util;
46 using namespace ::com::sun::star::form;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::script;
49 using namespace ::com::sun::star::container;
50 using namespace ::svxform;
51 
52 
53 FmFormObj::FmFormObj(
54  SdrModel& rSdrModel,
55  const OUString& rModelName)
56 : SdrUnoObj(rSdrModel, rModelName)
57  ,m_nPos(-1)
58  ,m_pLastKnownRefDevice(nullptr)
59 {
60  // normally, this is done in SetUnoControlModel, but if the call happened in the base class ctor,
61  // then our incarnation of it was not called (since we were not constructed at this time).
62  impl_checkRefDevice_nothrow( true );
63 }
64 
65 FmFormObj::FmFormObj(SdrModel& rSdrModel)
66 : SdrUnoObj(rSdrModel, "")
67  ,m_nPos(-1)
68  ,m_pLastKnownRefDevice(nullptr)
69 {
70  // Stuff that old SetModel also did:
71  impl_checkRefDevice_nothrow();
72 }
73 
74 FmFormObj::FmFormObj(SdrModel& rSdrModel, FmFormObj const & rSource)
75 : SdrUnoObj(rSdrModel, rSource)
76  ,m_nPos(-1)
77  ,m_pLastKnownRefDevice(nullptr)
78 {
79  // Stuff that old SetModel also did:
80  impl_checkRefDevice_nothrow();
81 
82  // If UnoControlModel is part of an event environment,
83  // events may assigned to it.
84  Reference< XFormComponent > xContent(rSource.xUnoControlModel, UNO_QUERY);
85  if (xContent.is())
86  {
87  Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY);
88  Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY);
89  if (xManagerAsIndex.is())
90  {
91  sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent );
92  if ( nPos >= 0 )
93  aEvts = xManager->getScriptEvents( nPos );
94  }
95  }
96  else
97  aEvts = rSource.aEvts;
98 
99  Reference< XChild > xSourceAsChild(rSource.GetUnoControlModel(), UNO_QUERY);
100  if (!xSourceAsChild.is())
101  return;
102 
103  Reference< XInterface > xSourceContainer = xSourceAsChild->getParent();
104 
105  m_xEnvironmentHistory = css::form::Forms::create( comphelper::getProcessComponentContext() );
106 
107  ensureModelEnv(xSourceContainer, m_xEnvironmentHistory);
108  m_aEventsHistory = aEvts;
109  // if we were clone there was a call to operator=, so aEvts are exactly the events we need here...
110 }
111 
112 FmFormObj::~FmFormObj()
113 {
114 
115  if (m_xEnvironmentHistory.is())
116  m_xEnvironmentHistory->dispose();
117 
118  m_xEnvironmentHistory = nullptr;
119  m_aEventsHistory.realloc(0);
120 }
121 
122 
123 void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, const sal_Int32 nIdx,
124  const Sequence< ScriptEventDescriptor >& rEvts)
125 {
126  m_xParent = xForm;
127  aEvts = rEvts;
128  m_nPos = nIdx;
129 }
130 
131 
132 void FmFormObj::ClearObjEnv()
133 {
134  m_xParent.clear();
135  aEvts.realloc( 0 );
136  m_nPos = -1;
137 }
138 
139 
140 void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
141 {
142  const FmFormModel* pFormModel = dynamic_cast<FmFormModel*>(&getSdrModelFromSdrObject());
143  if ( !pFormModel || !pFormModel->ControlsUseRefDevice() )
144  return;
145 
146  OutputDevice* pCurrentRefDevice = pFormModel->GetRefDevice();
147  if ( ( m_pLastKnownRefDevice.get() == pCurrentRefDevice ) && !_force )
148  return;
149 
150  Reference< XControlModel > xControlModel( GetUnoControlModel() );
151  if ( !xControlModel.is() )
152  return;
153 
154  m_pLastKnownRefDevice = pCurrentRefDevice;
155  if ( !m_pLastKnownRefDevice )
156  return;
157 
158  try
159  {
160  Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
161  Reference< XPropertySetInfo > xPropertyInfo( xModelProps->getPropertySetInfo(), UNO_SET_THROW );
162 
163  static constexpr OUStringLiteral sRefDevicePropName = u"ReferenceDevice";
164  if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
165  {
166  rtl::Reference<VCLXDevice> pUnoRefDevice = new VCLXDevice;
167  pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
168  Reference< XDevice > xRefDevice( pUnoRefDevice );
169  xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
170  }
171  }
172  catch( const Exception& )
173  {
175  }
176 }
177 
178 
179 void FmFormObj::impl_isolateControlModel_nothrow()
180 {
181  try
182  {
183  Reference< XChild > xControlModel( GetUnoControlModel(), UNO_QUERY );
184  if ( xControlModel.is() )
185  {
186  Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
187  if ( xParent.is() )
188  {
189  sal_Int32 nPos = getElementPos( xParent, xControlModel );
190  xParent->removeByIndex( nPos );
191  }
192  }
193  }
194  catch( const Exception& )
195  {
197  }
198 }
199 
200 
201 void FmFormObj::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
202 {
203  FmFormPage* pOldFormPage(dynamic_cast< FmFormPage* >(getSdrPageFromSdrObject()));
204  if ( pOldFormPage )
205  pOldFormPage->GetImpl().formObjectRemoved( *this );
206 
207  FmFormPage* pNewFormPage = dynamic_cast<FmFormPage*>( pNewPage );
208  if ( !pNewFormPage )
209  {
210  // 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,
211  // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it.
212  // So the next SetPage with a valid new page would restore that environment within the new page.
213  // But for the original Bug (#57300#) we don't need that, so I omit it here. Maybe this will be implemented later.
214  impl_isolateControlModel_nothrow();
215  SdrUnoObj::handlePageChange(pOldPage, pNewPage);
216  return;
217  }
218 
219  Reference< css::form::XForms > xNewPageForms = pNewFormPage->GetForms();
220  Reference< XIndexContainer > xNewParent;
221  Sequence< ScriptEventDescriptor> aNewEvents;
222 
223  // calc the new parent for my model (within the new page's forms hierarchy)
224  // do we have a history ? (from :Clone)
225  if ( m_xEnvironmentHistory.is() )
226  {
227  // the element in m_xEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within pNewPage->GetForms)
228  // is the right-most element in the tree.
229  Reference< XIndexContainer > xRightMostLeaf( m_xEnvironmentHistory, UNO_QUERY_THROW );
230  try
231  {
232  while ( xRightMostLeaf->getCount() )
233  {
234  xRightMostLeaf.set(
235  xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
236  UNO_QUERY_THROW
237  );
238  }
239 
240  xNewParent.set( ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
241 
242  // we successfully cloned the environment in m_xEnvironmentHistory, so we can use m_aEventsHistory
243  // (which describes the events of our model at the moment m_xEnvironmentHistory was created)
244  aNewEvents = m_aEventsHistory;
245  }
246  catch( const Exception& )
247  {
249  }
250  }
251 
252  if ( !xNewParent.is() )
253  {
254  // are we a valid part of our current page forms ?
255  Reference< XIndexContainer > xOldForms;
256  if ( pOldFormPage )
257  xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW );
258 
259  if ( xOldForms.is() )
260  {
261  // search (upward from our model) for xOldForms
262  Reference< XChild > xSearch( GetUnoControlModel(), UNO_QUERY );
263  while (xSearch.is())
264  {
265  if ( xSearch == xOldForms )
266  break;
267  xSearch.set( xSearch->getParent(), UNO_QUERY );
268  }
269  if ( xSearch.is() ) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
270  {
271  Reference< XChild > xMeAsChild( GetUnoControlModel(), UNO_QUERY );
272  xNewParent.set( ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
273 
274  if ( xNewParent.is() )
275  {
276  try
277  {
278  // transfer the events from our (model's) parent to the new (model's) parent, too
279  Reference< XEventAttacherManager > xEventManager(xMeAsChild->getParent(), UNO_QUERY);
280  Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
281  if (xManagerAsIndex.is())
282  {
283  sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsChild);
284  if (nPos >= 0)
285  aNewEvents = xEventManager->getScriptEvents(nPos);
286  }
287  else
288  aNewEvents = aEvts;
289  }
290  catch( const Exception& )
291  {
293  }
294  }
295  }
296  }
297  }
298 
299  // now set the page
300  SdrUnoObj::handlePageChange(pOldPage, pNewPage);
301 
302  // place my model within the new parent container
303  if (xNewParent.is())
304  {
305  Reference< XFormComponent > xMeAsFormComp(GetUnoControlModel(), UNO_QUERY);
306  if (xMeAsFormComp.is())
307  {
308  // check if I have another parent (and remove me, if necessary)
309  Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY);
310  if (xOldParent.is())
311  {
312  sal_Int32 nPos = getElementPos(xOldParent, xMeAsFormComp);
313  if (nPos > -1)
314  xOldParent->removeByIndex(nPos);
315  }
316 
317  // and insert into the new container
318  xNewParent->insertByIndex(xNewParent->getCount(), makeAny(xMeAsFormComp));
319 
320  // transfer the events
321  if (aNewEvents.hasElements())
322  {
323  try
324  {
325  Reference< XEventAttacherManager > xEventManager(xNewParent, UNO_QUERY);
326  Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
327  if (xManagerAsIndex.is())
328  {
329  sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsFormComp);
330  DBG_ASSERT(nPos >= 0, "FmFormObj::SetPage : inserted but not present ?");
331  xEventManager->registerScriptEvents(nPos, aNewEvents);
332  }
333  }
334  catch( const Exception& )
335  {
337  }
338 
339  }
340  }
341  }
342 
343  // delete my history
344  if (m_xEnvironmentHistory.is())
345  m_xEnvironmentHistory->dispose();
346 
347  m_xEnvironmentHistory = nullptr;
348  m_aEventsHistory.realloc(0);
349 
350  pNewFormPage->GetImpl().formObjectInserted( *this );
351 }
352 
353 SdrInventor FmFormObj::GetObjInventor() const
354 {
355  return SdrInventor::FmForm;
356 }
357 
358 SdrObjKind FmFormObj::GetObjIdentifier() const
359 {
360  return OBJ_UNO;
361 }
362 
363 FmFormObj* FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const
364 {
365  return new FmFormObj(rTargetModel, *this);
366 }
367 
368 void FmFormObj::NbcReformatText()
369 {
370  impl_checkRefDevice_nothrow();
372 }
373 
374 
375 namespace
376 {
377  OUString lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement)
378  {
379  Reference< css::form::XFormComponent> xChild(_xElement, UNO_QUERY);
380  Reference< css::container::XIndexAccess> xParent;
381  if (xChild.is())
382  xParent.set(xChild->getParent(), UNO_QUERY);
383 
384  // while the current content is a form
385  OUString sReturn;
386  while (xChild.is())
387  {
388  // get the content's relative pos within its parent container
389  sal_Int32 nPos = getElementPos(xParent, xChild);
390 
391  // prepend this current relative pos
392  OUString sCurrentIndex = OUString::number(nPos);
393  if (!sReturn.isEmpty())
394  {
395  sCurrentIndex += "\\" + sReturn;
396  }
397 
398  sReturn = sCurrentIndex;
399 
400  // travel up
401  xChild.set(xParent, css::uno::UNO_QUERY);
402  if (xChild.is())
403  xParent.set(xChild->getParent(), UNO_QUERY);
404  }
405 
406  _rTopLevelElement = xParent;
407  return sReturn;
408  }
409 }
410 
411 
412 Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const Reference<css::form::XForms>& _rTopLevelDestContainer)
413 {
414  Reference< XInterface > xTopLevelSource;
415  OUString sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSource);
416  if (!xTopLevelSource.is())
417  // something went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy
418  return Reference< XInterface > ();
419 
420  Reference< XIndexContainer > xDestContainer(_rTopLevelDestContainer, UNO_QUERY_THROW);
421  Reference< XIndexContainer > xSourceContainer(xTopLevelSource, UNO_QUERY);
422  DBG_ASSERT(xSourceContainer.is(), "FmFormObj::ensureModelEnv : the top level source is invalid !");
423 
424  sal_Int32 nTokIndex = 0;
425  do
426  {
427  OUString aToken = sAccessPath.getToken( 0, '\\', nTokIndex );
428  sal_uInt16 nIndex = static_cast<sal_uInt16>(aToken.toInt32());
429 
430  // get the DSS of the source form (we have to find an equivalent for)
431  DBG_ASSERT(nIndex<xSourceContainer->getCount(), "FmFormObj::ensureModelEnv : invalid access path !");
432  Reference< XPropertySet > xSourceForm;
433  xSourceContainer->getByIndex(nIndex) >>= xSourceForm;
434  DBG_ASSERT(xSourceForm.is(), "FmFormObj::ensureModelEnv : invalid source form !");
435 
436  Any aSrcCursorSource, aSrcCursorSourceType, aSrcDataSource;
438  && ::comphelper::hasProperty(FM_PROP_DATASOURCE, xSourceForm), "FmFormObj::ensureModelEnv : invalid access path or invalid form (missing props) !");
439  // the parent access path should refer to a row set
440  try
441  {
442  aSrcCursorSource = xSourceForm->getPropertyValue(FM_PROP_COMMAND);
443  aSrcCursorSourceType = xSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE);
444  aSrcDataSource = xSourceForm->getPropertyValue(FM_PROP_DATASOURCE);
445  }
446  catch(Exception&)
447  {
448  OSL_FAIL("FmFormObj::ensureModelEnv : could not retrieve a source DSS !");
449  }
450 
451 
452  // calc the number of (source) form siblings with the same DSS
453  Reference< XPropertySet > xCurrentSourceForm, xCurrentDestForm;
454  sal_Int16 nCurrentSourceIndex = 0;
455  sal_Int32 nCurrentDestIndex = 0;
456  while (nCurrentSourceIndex <= nIndex)
457  {
458  bool bEqualDSS = false;
459  while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bound by nIndex)
460  {
461  xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
462  DBG_ASSERT(xCurrentSourceForm.is(), "FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
463  bEqualDSS = false;
464  if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentSourceForm))
465  { // it is a form
466  try
467  {
468  if ( xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND) == aSrcCursorSource
469  && xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE) == aSrcCursorSourceType
470  && xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE) == aSrcDataSource
471  )
472  {
473  bEqualDSS = true;
474  }
475  }
476  catch(Exception&)
477  {
478  TOOLS_WARN_EXCEPTION("svx.form",
479  "exception while getting a sibling's DSS !");
480  }
481 
482  }
483  ++nCurrentSourceIndex;
484  }
485 
486  DBG_ASSERT(bEqualDSS, "FmFormObj::ensureModelEnv : found no source form !");
487  // ??? at least the nIndex-th one should have been found ???
488 
489  // now search the next one with the given DSS (within the destination container)
490  bEqualDSS = false;
491  while (!bEqualDSS && (nCurrentDestIndex < xDestContainer->getCount()))
492  {
493  xDestContainer->getByIndex(nCurrentDestIndex) >>= xCurrentDestForm;
494  DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid destination form !");
495  bEqualDSS = false;
496  if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentDestForm))
497  { // it is a form
498  try
499  {
500  if ( xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND) == aSrcCursorSource
501  && xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE) == aSrcCursorSourceType
502  && xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE) == aSrcDataSource
503  )
504  {
505  bEqualDSS = true;
506  }
507  }
508  catch(Exception&)
509  {
510  TOOLS_WARN_EXCEPTION("svx.form",
511  "exception while getting a destination DSS !");
512  }
513 
514  }
515  ++nCurrentDestIndex;
516  }
517 
518  if (!bEqualDSS)
519  { // There is at least one more source form with the given DSS than destination forms are.
520  // correct this ...
521  try
522  {
523  // create and insert (into the destination) a copy of the form
524  xCurrentDestForm.set(
525  ::comphelper::getProcessServiceFactory()->createInstance("com.sun.star.form.component.DataForm"),
526  UNO_QUERY_THROW );
527  ::comphelper::copyProperties( xCurrentSourceForm, xCurrentDestForm );
528 
529  DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !");
530  xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm));
531 
532  ++nCurrentDestIndex;
533  // like nCurrentSourceIndex, nCurrentDestIndex now points 'behind' the form it actually means
534  }
535  catch(Exception&)
536  {
537  OSL_FAIL("FmFormObj::ensureModelEnv : something went seriously wrong while creating a new form !");
538  // no more options anymore ...
539  return Reference< XInterface > ();
540  }
541 
542  }
543  }
544 
545  // now xCurrentDestForm is a form equivalent to xSourceForm (which means they have the same DSS and the same number
546  // of left siblings with the same DSS, which counts for all their ancestors, too)
547 
548  // go down
549  xDestContainer.set(xCurrentDestForm, UNO_QUERY);
550  xSourceContainer.set(xSourceForm, UNO_QUERY);
551  DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(), "FmFormObj::ensureModelEnv : invalid container !");
552  }
553  while ( nTokIndex >= 0 );
554 
555  return Reference<XInterface>( xDestContainer, UNO_QUERY );
556 }
557 
558 FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
559 {
560  FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
561  if ( !pFormObject )
562  {
563  SdrVirtObj* pVirtualObject = dynamic_cast< SdrVirtObj* >( _pSdrObject );
564  if ( pVirtualObject )
565  pFormObject = dynamic_cast< FmFormObj* >( &pVirtualObject->ReferencedObj() );
566  }
567  return pFormObject;
568 }
569 
570 
571 const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject )
572 {
573  const FmFormObj* pFormObject = dynamic_cast< const FmFormObj* >( _pSdrObject );
574  if ( !pFormObject )
575  {
576  const SdrVirtObj* pVirtualObject = dynamic_cast< const SdrVirtObj* >( _pSdrObject );
577  if ( pVirtualObject )
578  pFormObject = dynamic_cast< const FmFormObj* >( &pVirtualObject->GetReferencedObj() );
579  }
580  return pFormObject;
581 }
582 
583 
584 void FmFormObj::SetUnoControlModel( const Reference< css::awt::XControlModel >& _rxModel )
585 {
586  SdrUnoObj::SetUnoControlModel( _rxModel );
587 
588  FmFormPage* pFormPage(dynamic_cast< FmFormPage* >(getSdrPageFromSdrObject()));
589  if ( pFormPage )
590  pFormPage->GetImpl().formModelAssigned( *this );
591 
592  impl_checkRefDevice_nothrow( true );
593 }
594 
595 
596 bool FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
597 {
598  bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
599  if ( bResult && SdrCreateCmd::ForceEnd == eCmd && rStat.GetView() )
600  {
601  FmFormPage* pFormPage(dynamic_cast< FmFormPage* >(getSdrPageFromSdrObject()));
602 
603  if (nullptr != pFormPage)
604  {
605  try
606  {
607  Reference< XFormComponent > xContent( xUnoControlModel, UNO_QUERY_THROW );
608  Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
609 
610  Reference< XIndexContainer > xFormToInsertInto;
611 
612  if ( !xParentForm.is() )
613  { // model is not yet part of a form component hierarchy
614  xParentForm.set( pFormPage->GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
615  xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
616  }
617 
618  FmFormPageImpl::setUniqueName( xContent, xParentForm );
619 
620  if ( xFormToInsertInto.is() )
621  xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) );
622  }
623  catch( const Exception& )
624  {
626  }
627  }
628 
629  FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
630  FmXFormView* pViewImpl = pView ? pView->GetImpl() : nullptr;
631  OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
632  if ( pViewImpl )
633  pViewImpl->onCreatedFormObject( *this );
634  }
635  return bResult;
636 }
637 
638 
639 void FmFormObj::BrkCreate( SdrDragStat& rStat )
640 {
641  SdrUnoObj::BrkCreate( rStat );
642  impl_isolateControlModel_nothrow();
643 
644  FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
645  FmXFormView* pViewImpl = pView ? pView->GetImpl() : nullptr;
646  OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
647  if ( pViewImpl )
648  pViewImpl->breakCreateFormObject();
649 }
650 
651 
652 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nIndex
SdrObject & ReferencedObj()
Definition: svdovirt.cxx:76
size_t m_nPos
Definition: filtnav.cxx:172
static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent > &xFormComponent, const css::uno::Reference< css::form::XForm > &xControls)
Definition: fmpgeimp.cxx:618
#define FM_PROP_COMMAND
Definition: fmprop.hxx:117
sal_Int32 getElementPos(const Reference< css::container::XIndexAccess > &xCont, const Reference< XInterface > &xElement)
Definition: fmtools.cxx:118
SdrInventor
Definition: svdobj.hxx:99
#define FM_PROP_DATASOURCE
Definition: fmprop.hxx:78
virtual void NbcReformatText() override
Definition: svdotext.cxx:1376
SdrObjKind
Definition: svdobjkind.hxx:24
OutputDevice * GetRefDevice() const
Definition: svdmodel.hxx:327
const SdrObject & GetReferencedObj() const
Definition: svdovirt.cxx:71
FmFormPageImpl & GetImpl() const
Definition: fmpage.hxx:62
void onCreatedFormObject(FmFormObj const &_rFormObject)
Definition: fmvwimp.cxx:968
#define DBG_UNHANDLED_EXCEPTION(...)
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:489
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_ASSERT(sCon, aError)
bool ControlsUseRefDevice() const
determines whether form controls should use the SdrModel's reference device for text rendering ...
Definition: fmmodel.cxx:156
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:221
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
SdrView * GetView() const
Definition: svddrag.hxx:96
virtual void SetUnoControlModel(const css::uno::Reference< css::awt::XControlModel > &xModel)
Definition: svdouno.cxx:412
float u
Abstract DrawObject.
Definition: svdobj.hxx:259
void breakCreateFormObject()
Definition: fmvwimp.cxx:1004
void formObjectInserted(const FmFormObj &_object)
Definition: fmpgeimp.cxx:678
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
FIXME: The virtual object is not yet fully implemented and tested.
Definition: svdovirt.hxx:29
#define FM_PROP_COMMANDTYPE
Definition: fmprop.hxx:118
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotxdr.cxx:207
class FmSearchEngine - Impl class for FmSearchDialog
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
continuously activated OLE (PlugIn-Frame or similar)
Definition: svdobjkind.hxx:54
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
Definition: fmpage.cxx:86
SdrCreateCmd
Definition: svdtypes.hxx:26
uno::Reference< ucb::XContent > xContent
sal_uInt16 nPos
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)