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