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