LibreOffice Module svx (master)  1
fmpgeimp.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 
21 #include <svx/svxerr.hxx>
22 #include <fmpgeimp.hxx>
23 #include <fmundo.hxx>
24 #include <svx/fmtools.hxx>
25 #include <fmprop.hxx>
26 #include <fmservs.hxx>
27 #include <fmobj.hxx>
28 #include <formcontrolfactory.hxx>
29 #include <svx/svditer.hxx>
30 #include <svx/strings.hrc>
31 #include <treevisitor.hxx>
32 
33 #include <com/sun/star/sdb/CommandType.hpp>
34 #include <com/sun/star/sdbc/XRowSet.hpp>
35 #include <com/sun/star/container/EnumerableMap.hpp>
36 #include <com/sun/star/drawing/XControlShape.hpp>
37 #include <com/sun/star/form/Forms.hpp>
38 
39 #include <sal/log.hxx>
40 #include <sfx2/objsh.hxx>
41 #include <svx/fmglob.hxx>
42 #include <svx/fmpage.hxx>
43 #include <svx/fmmodel.hxx>
44 #include <tools/debug.hxx>
45 #include <tools/diagnose_ex.h>
46 #include <vcl/stdtext.hxx>
47 #include <svx/dialmgr.hxx>
49 #include <comphelper/types.hxx>
50 #include <unotools/streamwrap.hxx>
51 #include <connectivity/dbtools.hxx>
52 
53 using namespace ::com::sun::star::uno;
54 using namespace ::com::sun::star::lang;
55 using namespace ::com::sun::star::sdbc;
56 using namespace ::com::sun::star::sdb;
57 using namespace ::com::sun::star::container;
58 using namespace ::com::sun::star::beans;
59 using namespace ::com::sun::star::form;
60 using ::com::sun::star::awt::XControlModel;
61 using ::com::sun::star::container::XMap;
62 using ::com::sun::star::container::EnumerableMap;
63 using ::com::sun::star::drawing::XControlShape;
64 using namespace ::svxform;
65 using namespace ::dbtools;
66 
67 
69  :m_rPage( _rPage )
70  ,m_bFirstActivation( true )
71  ,m_bAttemptedFormCreation( false )
72 {
73 }
74 
75 
76 namespace
77 {
78  class FormComponentInfo
79  {
80  public:
81  static size_t childCount( const Reference< XInterface >& _component )
82  {
83  Reference< XIndexAccess > xContainer( _component, UNO_QUERY );
84  if ( xContainer.is() )
85  return xContainer->getCount();
86  return 0;
87  }
88 
89  static Reference< XInterface > getChild( const Reference< XInterface >& _component, size_t _index )
90  {
91  Reference< XIndexAccess > xContainer( _component, UNO_QUERY_THROW );
92  return Reference< XInterface >( xContainer->getByIndex( _index ), UNO_QUERY );
93  }
94  };
95 
96  typedef ::std::pair< Reference< XInterface >, Reference< XInterface > > FormComponentPair;
97 
98  class FormHierarchyComparator
99  {
100  public:
101  FormHierarchyComparator()
102  {
103  }
104 
105  static size_t childCount( const FormComponentPair& _components )
106  {
107  size_t lhsCount = FormComponentInfo::childCount( _components.first );
108  size_t rhsCount = FormComponentInfo::childCount( _components.second );
109  if ( lhsCount != rhsCount )
110  throw RuntimeException( "Found inconsistent form component hierarchies (1)!" );
111  return lhsCount;
112  }
113 
114  static FormComponentPair getChild( const FormComponentPair& _components, size_t _index )
115  {
116  return FormComponentPair(
117  FormComponentInfo::getChild( _components.first, _index ),
118  FormComponentInfo::getChild( _components.second, _index )
119  );
120  }
121  };
122 
123  typedef ::std::map< Reference< XControlModel >, Reference< XControlModel > > MapControlModels;
124 
125  class FormComponentAssignment
126  {
127  public:
128  explicit FormComponentAssignment( MapControlModels& _out_controlModelMap )
129  :m_rControlModelMap( _out_controlModelMap )
130  {
131  }
132 
133  void process( const FormComponentPair& _component )
134  {
135  Reference< XControlModel > lhsControlModel( _component.first, UNO_QUERY );
136  Reference< XControlModel > rhsControlModel( _component.second, UNO_QUERY );
137  if ( lhsControlModel.is() != rhsControlModel.is() )
138  throw RuntimeException( "Found inconsistent form component hierarchies (2)!" );
139 
140  if ( lhsControlModel.is() )
141  m_rControlModelMap[ lhsControlModel ] = rhsControlModel;
142  }
143 
144  private:
145  MapControlModels& m_rControlModelMap;
146  };
147 }
148 
149 
151 {
152  // clone the Forms collection
153  const Reference< css::form::XForms > xForeignForms( i_foreignImpl.getForms( false ) );
154 
155  if ( !xForeignForms.is() )
156  return;
157 
158  try
159  {
160  m_xForms.set( xForeignForms->createClone(), UNO_QUERY_THROW );
161 
162  // create a mapping between the original control models and their clones
163  MapControlModels aModelAssignment;
164 
166  FormComponentVisitor aVisitor{ FormHierarchyComparator() };
167 
168  FormComponentAssignment aAssignmentProcessor( aModelAssignment );
169  aVisitor.process( FormComponentPair( xForeignForms, m_xForms ), aAssignmentProcessor );
170 
171  // assign the cloned models to their SdrObjects
172  SdrObjListIter aForeignIter( &i_foreignImpl.m_rPage );
173  SdrObjListIter aOwnIter( &m_rPage );
174 
175  OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (1)!" );
176  while ( aForeignIter.IsMore() && aOwnIter.IsMore() )
177  {
178  FmFormObj* pForeignObj = dynamic_cast< FmFormObj* >( aForeignIter.Next() );
179  FmFormObj* pOwnObj = dynamic_cast< FmFormObj* >( aOwnIter.Next() );
180 
181  bool bForeignIsForm = pForeignObj && ( pForeignObj->GetObjInventor() == SdrInventor::FmForm );
182  bool bOwnIsForm = pOwnObj && ( pOwnObj->GetObjInventor() == SdrInventor::FmForm );
183 
184  if ( bForeignIsForm != bOwnIsForm )
185  {
186  // if this fires, don't attempt to do further assignments, something's completely messed up
187  SAL_WARN( "svx.form", "FmFormPageImpl::FmFormPageImpl: inconsistent ordering of objects!" );
188  break;
189  }
190 
191  if ( !bForeignIsForm )
192  // no form control -> next round
193  continue;
194 
195  Reference< XControlModel > xForeignModel( pForeignObj->GetUnoControlModel() );
196  if ( !xForeignModel.is() )
197  {
198  // if this fires, the SdrObject does not have a UNO Control Model. This is pathological, but well ...
199  // So the cloned SdrObject will also not have a UNO Control Model.
200  SAL_WARN( "svx.form", "FmFormPageImpl::FmFormPageImpl: control shape without control!" );
201  continue;
202  }
203 
204  MapControlModels::const_iterator assignment = aModelAssignment.find( xForeignModel );
205  if ( assignment == aModelAssignment.end() )
206  {
207  // if this fires, the source SdrObject has a model, but it is not part of the model hierarchy in
208  // i_foreignImpl.getForms().
209  // Pathological, too ...
210  SAL_WARN( "svx.form", "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" );
211  continue;
212  }
213 
214  pOwnObj->SetUnoControlModel( assignment->second );
215  }
216  OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (2)!" );
217  }
218  catch( const Exception& )
219  {
221  }
222 }
223 
224 
226 {
227  Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
228  if ( xControlShapeMap.is() )
229  return xControlShapeMap;
230 
231  xControlShapeMap = impl_createControlShapeMap_nothrow();
232  m_aControlShapeMap = xControlShapeMap;
233  return xControlShapeMap;
234 }
235 
236 
237 namespace
238 {
239  void lcl_insertFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map )
240  {
241  // the control model
242  Reference< XControlModel > xControlModel = _object.GetUnoControlModel();
243  OSL_ENSURE( xControlModel.is(), "lcl_insertFormObject_throw: suspicious: no control model!" );
244  if ( !xControlModel.is() )
245  return;
246 
247  Reference< XControlShape > xControlShape( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY );
248  OSL_ENSURE( xControlShape.is(), "lcl_insertFormObject_throw: suspicious: no control shape!" );
249  if ( !xControlShape.is() )
250  return;
251 
252  _map->put( makeAny( xControlModel ), makeAny( xControlShape ) );
253  }
254 
255  void lcl_removeFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map )
256  {
257  // the control model
258  Reference< XControlModel > xControlModel = _object.GetUnoControlModel();
259  OSL_ENSURE( xControlModel.is(), "lcl_removeFormObject: suspicious: no control model!" );
260  if ( !xControlModel.is() )
261  {
262  return;
263  }
264 
265  Any aOldAssignment = _map->remove( makeAny( xControlModel ) );
266  OSL_ENSURE(
267  aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ),
268  "lcl_removeFormObject: map was inconsistent!" );
269  }
270 }
271 
272 
274 {
275  Reference< XMap > xMap;
276 
277  try
278  {
279  xMap = EnumerableMap::create( comphelper::getProcessComponentContext(),
282  );
283 
284  SdrObjListIter aPageIter( &m_rPage );
285  while ( aPageIter.IsMore() )
286  {
287  // only FmFormObjs are what we're interested in
288  FmFormObj* pCurrent = FmFormObj::GetFormObject( aPageIter.Next() );
289  if ( !pCurrent )
290  continue;
291 
292  lcl_insertFormObject_throw( *pCurrent, xMap );
293  }
294  }
295  catch( const Exception& )
296  {
298  }
299  return xMap;
300 }
301 
302 
303 const Reference< css::form::XForms >& FmFormPageImpl::getForms( bool _bForceCreate )
304 {
305  if ( m_xForms.is() || !_bForceCreate )
306  return m_xForms;
307 
309  {
311 
313  m_xForms = css::form::Forms::create( xContext );
314 
315  if ( m_aFormsCreationHdl.IsSet() )
316  {
317  m_aFormsCreationHdl.Call( *this );
318  }
319 
320  FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(m_rPage.getSdrModelFromSdrPage()));
321 
322  // give the newly created collection a place in the universe
323  SfxObjectShell* pObjShell(rFmFormModel.GetObjectShell());
324  if ( pObjShell )
325  m_xForms->setParent( pObjShell->GetModel() );
326 
327  // tell the UNDO environment that we have a new forms collection
328  rFmFormModel.GetUndoEnv().AddForms( Reference<XNameContainer>(m_xForms,UNO_QUERY_THROW) );
329  }
330  return m_xForms;
331 }
332 
333 
335 {
336  xCurrentForm = nullptr;
337 
338  ::comphelper::disposeComponent( m_xForms );
339 }
340 
341 
343 {
344  if ( !xCurrentForm.is() )
345  return false;
346 
347  if ( !xCurrentForm->getParent().is() )
348  xCurrentForm.clear();
349 
350  return xCurrentForm.is();
351 }
352 
353 
354 void FmFormPageImpl::setCurForm(const Reference< css::form::XForm >& xForm)
355 {
356  xCurrentForm = xForm;
357 }
358 
359 
360 Reference< XForm > FmFormPageImpl::getDefaultForm()
361 {
362  Reference< XForm > xForm;
363 
364  Reference< XForms > xForms( getForms() );
365 
366  // by default, we use our "current form"
367  if ( !validateCurForm() )
368  {
369  // check whether there is a "standard" form
370  if ( Reference<XNameAccess>(xForms,UNO_QUERY_THROW)->hasElements() )
371  {
372  // find the standard form
373  OUString sStandardFormname = SvxResId(RID_STR_STDFORMNAME);
374 
375  try
376  {
377  if ( xForms->hasByName( sStandardFormname ) )
378  xForm.set( xForms->getByName( sStandardFormname ), UNO_QUERY_THROW );
379  else
380  {
381  xForm.set( xForms->getByIndex(0), UNO_QUERY_THROW );
382  }
383  }
384  catch( const Exception& )
385  {
387  }
388  }
389  }
390  else
391  {
392  xForm = xCurrentForm;
393  }
394 
395  // did not find an existing suitable form -> create a new one
396  if ( !xForm.is() )
397  {
399 
400  if( rModel.IsUndoEnabled() )
401  {
402  OUString aStr(SvxResId(RID_STR_FORM));
403  OUString aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT));
404  rModel.BegUndo(aUndoStr.replaceFirst("'#'", aStr));
405  }
406 
407  try
408  {
410 
411  // a form should always have the command type table as default
412  Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW );
413  xFormProps->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny( sal_Int32( CommandType::TABLE ) ) );
414 
415  // and the "Standard" name
416  OUString sName = SvxResId(RID_STR_STDFORMNAME);
417  xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
418 
419  if( rModel.IsUndoEnabled() )
420  {
421  rModel.AddUndo(
422  std::make_unique<FmUndoContainerAction>(
423  static_cast< FmFormModel& >(rModel),
425  xForms,
426  xForm,
427  xForms->getCount()));
428  }
429  xForms->insertByName( sName, makeAny( xForm ) );
430  xCurrentForm = xForm;
431  }
432  catch( const Exception& )
433  {
435  xForm.clear();
436  }
437 
438  if( rModel.IsUndoEnabled() )
439  rModel.EndUndo();
440  }
441 
442  return xForm;
443 }
444 
445 
447  const Reference< XFormComponent > & rContent, const Reference< XDataSource > & rDatabase,
448  const OUString& rDBTitle, const OUString& rCursorSource, sal_Int32 nCommandType )
449 {
450  // if the control already is child of a form, don't do anything
451  if (!rContent.is() || rContent->getParent().is())
452  return nullptr;
453 
454  Reference< XForm > xForm;
455 
456  // If database and CursorSource are set, the form is searched for using
457  // these criteria, otherwise only current and the DefaultForm.
458  if (rDatabase.is() && !rCursorSource.isEmpty())
459  {
460  validateCurForm();
461 
462  // first search in the current form
463  xForm = findFormForDataSource( xCurrentForm, rDatabase, rCursorSource, nCommandType );
464 
465  Reference< css::container::XIndexAccess > xFormsByIndex = getForms();
466  DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::findPlaceInFormComponentHierarchy : no index access for my forms collection !");
467  sal_Int32 nCount = xFormsByIndex->getCount();
468  for (sal_Int32 i = 0; !xForm.is() && i < nCount; i++)
469  {
470  Reference< css::form::XForm > xToSearch;
471  xFormsByIndex->getByIndex(i) >>= xToSearch;
472  xForm = findFormForDataSource( xToSearch, rDatabase, rCursorSource, nCommandType );
473  }
474 
475  // If no css::form found, then create a new one
476  if (!xForm.is())
477  {
479  const bool bUndo(rModel.IsUndoEnabled());
480 
481  if( bUndo )
482  {
483  OUString aStr(SvxResId(RID_STR_FORM));
484  OUString aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT));
485  aUndoStr = aUndoStr.replaceFirst("#", aStr);
486  rModel.BegUndo(aUndoStr);
487  }
488 
490  // a form should always have the command type table as default
491  Reference< css::beans::XPropertySet > xFormProps(xForm, UNO_QUERY);
492  try { xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE))); }
493  catch(Exception&) { }
494 
495  if (!rDBTitle.isEmpty())
496  xFormProps->setPropertyValue(FM_PROP_DATASOURCE,makeAny(rDBTitle));
497  else
498  {
499  Reference< css::beans::XPropertySet > xDatabaseProps(rDatabase, UNO_QUERY);
500  Any aDatabaseUrl = xDatabaseProps->getPropertyValue(FM_PROP_URL);
501  xFormProps->setPropertyValue(FM_PROP_URL, aDatabaseUrl);
502  }
503 
504  xFormProps->setPropertyValue(FM_PROP_COMMAND,makeAny(rCursorSource));
505  xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(nCommandType));
506 
507  Reference< css::container::XNameAccess > xNamedSet = getForms();
508 
509  const bool bTableOrQuery = ( CommandType::TABLE == nCommandType ) || ( CommandType::QUERY == nCommandType );
510  OUString sName = FormControlFactory::getUniqueName( xNamedSet,
511  bTableOrQuery ? rCursorSource : SvxResId(RID_STR_STDFORMNAME) );
512 
513  xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
514 
515  if( bUndo )
516  {
517  Reference< css::container::XIndexContainer > xContainer = getForms();
518  rModel.AddUndo(
519  std::make_unique<FmUndoContainerAction>(
520  static_cast< FmFormModel& >(rModel),
522  xContainer,
523  xForm,
524  xContainer->getCount()));
525  }
526 
527  getForms()->insertByName( sName, makeAny( xForm ) );
528 
529  if( bUndo )
530  rModel.EndUndo();
531  }
532  xCurrentForm = xForm;
533  }
534 
535  xForm = getDefaultForm();
536  return xForm;
537 }
538 
539 
541  const Reference< XForm > & rForm, const Reference< XDataSource > & _rxDatabase,
542  const OUString& _rCursorSource, sal_Int32 nCommandType)
543 {
544  Reference< XForm > xResultForm;
545  Reference< XRowSet > xDBForm(rForm, UNO_QUERY);
546  Reference< XPropertySet > xFormProps(rForm, UNO_QUERY);
547  if (!xDBForm.is() || !xFormProps.is())
548  return xResultForm;
549 
550  OSL_ENSURE(_rxDatabase.is(), "FmFormPageImpl::findFormForDataSource: invalid data source!");
551  OUString sLookupName; // the name of the data source we're looking for
552  OUString sFormDataSourceName; // the name of the data source the current connection in the form is based on
553  try
554  {
555  Reference< XPropertySet > xDSProps(_rxDatabase, UNO_QUERY);
556  if (xDSProps.is())
557  xDSProps->getPropertyValue(FM_PROP_NAME) >>= sLookupName;
558 
559  xFormProps->getPropertyValue(FM_PROP_DATASOURCE) >>= sFormDataSourceName;
560  // if there's no DataSourceName set at the form, check whether we can deduce one from its
561  // ActiveConnection
562  if (sFormDataSourceName.isEmpty())
563  {
564  Reference< XConnection > xFormConnection;
565  xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ) >>= xFormConnection;
566  if ( !xFormConnection.is() )
567  isEmbeddedInDatabase( xFormProps, xFormConnection );
568  if (xFormConnection.is())
569  {
570  Reference< XChild > xConnAsChild(xFormConnection, UNO_QUERY);
571  if (xConnAsChild.is())
572  {
573  Reference< XDataSource > xFormDS(xConnAsChild->getParent(), UNO_QUERY);
574  if (xFormDS.is())
575  {
576  xDSProps.set(xFormDS, css::uno::UNO_QUERY);
577  if (xDSProps.is())
578  xDSProps->getPropertyValue(FM_PROP_NAME) >>= sFormDataSourceName;
579  }
580  }
581  }
582  }
583  }
584  catch(const Exception&)
585  {
586  OSL_FAIL("FmFormPageImpl::findFormForDataSource: caught an exception!");
587  }
588 
589  if (sLookupName == sFormDataSourceName)
590  {
591  // now check whether CursorSource and type match
592  OUString aCursorSource = ::comphelper::getString(xFormProps->getPropertyValue(FM_PROP_COMMAND));
593  sal_Int32 nType = ::comphelper::getINT32(xFormProps->getPropertyValue(FM_PROP_COMMANDTYPE));
594  if (aCursorSource.isEmpty() || ((nType == nCommandType) && (aCursorSource == _rCursorSource))) // found the form
595  {
596  xResultForm = rForm;
597  // if no data source is set yet, it is done here
598  if (aCursorSource.isEmpty())
599  {
600  xFormProps->setPropertyValue(FM_PROP_COMMAND, makeAny(_rCursorSource));
601  xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(nCommandType));
602  }
603  }
604  }
605 
606  // as long as xResultForm is NULL, search the child forms of rForm
607  Reference< XIndexAccess > xComponents(rForm, UNO_QUERY);
608  sal_Int32 nCount = xComponents->getCount();
609  for (sal_Int32 i = 0; !xResultForm.is() && i < nCount; ++i)
610  {
611  Reference< css::form::XForm > xSearchForm;
612  xComponents->getByIndex(i) >>= xSearchForm;
613  // continue searching in the sub form
614  if (xSearchForm.is())
615  xResultForm = findFormForDataSource( xSearchForm, _rxDatabase, _rCursorSource, nCommandType );
616  }
617  return xResultForm;
618 }
619 
620 
621 OUString FmFormPageImpl::setUniqueName(const Reference< XFormComponent > & xFormComponent, const Reference< XForm > & xControls)
622 {
623 #if OSL_DEBUG_LEVEL > 0
624  try
625  {
626  OSL_ENSURE( !xFormComponent->getParent().is(), "FmFormPageImpl::setUniqueName: to be called before insertion!" );
627  }
628  catch( const Exception& )
629  {
631  }
632 #endif
633  OUString sName;
634  Reference< css::beans::XPropertySet > xSet(xFormComponent, UNO_QUERY);
635  if (xSet.is())
636  {
637  sName = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_NAME ) );
638  Reference< css::container::XNameAccess > xNameAcc(xControls, UNO_QUERY);
639 
640  if (sName.isEmpty() || xNameAcc->hasByName(sName))
641  {
642  // set a default name via the ClassId
643  sal_Int16 nClassId( FormComponentType::CONTROL );
644  xSet->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
645 
646  OUString sDefaultName = FormControlFactory::getDefaultUniqueName_ByComponentType(
647  Reference< XNameAccess >( xControls, UNO_QUERY ), xSet );
648 
649  // do not overwrite the name of radio buttons that have it!
650  if (sName.isEmpty() || nClassId != css::form::FormComponentType::RADIOBUTTON)
651  {
652  xSet->setPropertyValue(FM_PROP_NAME, makeAny(sDefaultName));
653  }
654 
655  sName = sDefaultName;
656  }
657  }
658  return sName;
659 }
660 
661 
663 {
664  Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
665  if ( !xControlShapeMap.is() )
666  // our map does not exist -> not interested in this event
667  return;
668 
669  try
670  {
671  lcl_removeFormObject_throw( _object, xControlShapeMap );
672  lcl_insertFormObject_throw( _object, xControlShapeMap );
673  }
674  catch( const Exception& )
675  {
677  }
678 }
679 
680 
682 {
683  Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
684  if ( !xControlShapeMap.is() )
685  // our map does not exist -> not interested in this event
686  return;
687 
688  try
689  {
690  lcl_insertFormObject_throw( _object, xControlShapeMap );
691  }
692  catch( const Exception& )
693  {
695  }
696 }
697 
698 
700 {
701  Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
702  if ( !xControlShapeMap.is() )
703  // our map does not exist -> not interested in this event
704  return;
705 
706  try
707  {
708  lcl_removeFormObject_throw( _object, xControlShapeMap );
709  }
710  catch( const Exception& )
711  {
713  }
714 }
715 
716 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::form::XForms > m_xForms
Definition: fmpgeimp.hxx:50
css::uno::Reference< css::form::XForm > getDefaultForm()
Definition: fmpgeimp.cxx:360
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
::boost::spirit::rule< ScannerT > assignment
#define FM_PROP_COMMAND
Definition: fmprop.hxx:117
#define FM_PROP_DATASOURCE
Definition: fmprop.hxx:78
css::uno::Reference< css::form::XForm > findFormForDataSource(const css::uno::Reference< css::form::XForm > &rForm, const css::uno::Reference< css::sdbc::XDataSource > &rDatabase, const OUString &rCommand, sal_Int32 nCommandType)
finds a form with a given data source signature
Definition: fmpgeimp.cxx:540
Link< FmFormPageImpl &, void > m_aFormsCreationHdl
Definition: fmpgeimp.hxx:54
css::uno::Reference< css::container::XMap > impl_createControlShapeMap_nothrow()
Definition: fmpgeimp.cxx:273
#define FM_PROP_NAME
Definition: fmprop.hxx:29
bool IsMore() const
Definition: svditer.hxx:62
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
css::uno::WeakReference< css::container::XMap > m_aControlShapeMap
Definition: fmpgeimp.hxx:51
int nCount
#define FM_PROP_CLASSID
Definition: fmprop.hxx:30
FmXUndoEnvironment & GetUndoEnv()
Definition: fmmodel.cxx:203
#define FM_PROP_URL
Definition: fmprop.hxx:127
#define DBG_UNHANDLED_EXCEPTION(...)
#define DBG_ASSERT(sCon, aError)
OUString sName
FmFormPage & m_rPage
Definition: fmpgeimp.hxx:53
int i
QPRO_FUNC_TYPE const nType
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
virtual SAL_DLLPRIVATE void SetUnoControlModel(const css::uno::Reference< css::awt::XControlModel > &_rxModel) override
Definition: fmobj.cxx:608
void formModelAssigned(const FmFormObj &_object)
Definition: fmpgeimp.cxx:662
static SAL_DLLPRIVATE FmFormObj * GetFormObject(SdrObject *_pSdrObject)
returns the FmFormObj behind the given SdrObject
Definition: fmobj.cxx:582
#define FM_SUN_COMPONENT_FORM
Definition: fmservs.hxx:56
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:391
SdrObject * Next()
Definition: svditer.hxx:63
void formObjectInserted(const FmFormObj &_object)
Definition: fmpgeimp.cxx:681
Reference< XMultiServiceFactory > getProcessServiceFactory()
void AddForms(const css::uno::Reference< css::container::XNameContainer > &rForms)
Definition: fmundo.cxx:791
virtual SAL_DLLPRIVATE SdrInventor GetObjInventor() const override
Definition: fmobj.cxx:322
#define FM_PROP_ACTIVE_CONNECTION
Definition: fmprop.hxx:128
OOO_DLLPUBLIC_DBTOOLS bool isEmbeddedInDatabase(const css::uno::Reference< css::uno::XInterface > &_rxComponent, css::uno::Reference< css::sdbc::XConnection > &_rxActualConnection)
css::uno::Reference< css::form::XForm > xCurrentForm
Definition: fmpgeimp.hxx:49
SVX_DLLPUBLIC css::uno::Reference< css::container::XMap > getControlToShapeMap()
returns an object mapping from control models to drawing shapes.
Definition: fmpgeimp.cxx:225
bool m_bAttemptedFormCreation
Definition: fmpgeimp.hxx:57
Reference< XComponentContext > getProcessComponentContext()
#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
void setCurForm(const css::uno::Reference< css::form::XForm > &xForm)
Definition: fmpgeimp.cxx:354
#define SAL_WARN(area, stream)
class FmSearchEngine - Impl class for FmSearchDialog
const css::uno::Reference< css::form::XForms > & getForms(bool _bForceCreate=true)
Definition: fmpgeimp.cxx:303
void initFrom(FmFormPageImpl &i_foreignImpl)
Definition: fmpgeimp.cxx:150
aStr
bool validateCurForm()
validates whether xCurrentForm is still valid and to be used
Definition: fmpgeimp.cxx:342
FmFormPageImpl(FmFormPage &_rPage)
Definition: fmpgeimp.cxx:68
SfxObjectShell * GetObjectShell() const
Definition: fmmodel.hxx:58
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)