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