27 #include <editeng/editeng.hxx>
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>
61 const OUString& rModelName)
64 ,m_pLastKnownRefDevice(nullptr)
74 ,m_pLastKnownRefDevice(nullptr)
92 const Sequence< ScriptEventDescriptor >& rEvts)
119 if ( !xControlModel.is() )
129 Reference< XPropertySetInfo > xPropertyInfo( xModelProps->getPropertySetInfo(), UNO_SET_THROW );
131 static const char sRefDevicePropName[] =
"ReferenceDevice";
132 if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
136 Reference< XDevice > xRefDevice( pUnoRefDevice );
137 xModelProps->setPropertyValue( sRefDevicePropName,
makeAny( xRefDevice ) );
152 if ( xControlModel.is() )
154 Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
158 xParent->removeByIndex( nPos );
187 Reference< css::form::XForms > xNewPageForms = pNewFormPage->
GetForms();
188 Reference< XIndexContainer > xNewParent;
189 Sequence< ScriptEventDescriptor> aNewEvents;
200 while ( xRightMostLeaf->getCount() )
203 xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
208 xNewParent.set(
ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
220 if ( !xNewParent.is() )
223 Reference< XIndexContainer > xOldForms;
225 xOldForms.set( pOldFormPage->
GetForms(), UNO_QUERY_THROW );
227 if ( xOldForms.is() )
233 if ( xSearch == xOldForms )
235 xSearch.set( xSearch->getParent(), UNO_QUERY );
240 xNewParent.set(
ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
242 if ( xNewParent.is() )
247 Reference< XEventAttacherManager > xEventManager(xMeAsChild->getParent(), UNO_QUERY);
248 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
249 if (xManagerAsIndex.is())
253 aNewEvents = xEventManager->getScriptEvents(nPos);
274 if (xMeAsFormComp.is())
277 Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY);
282 xOldParent->removeByIndex(nPos);
286 xNewParent->insertByIndex(xNewParent->getCount(),
makeAny(xMeAsFormComp));
289 if (aNewEvents.hasElements())
293 Reference< XEventAttacherManager > xEventManager(xNewParent, UNO_QUERY);
294 Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
295 if (xManagerAsIndex.is())
298 DBG_ASSERT(nPos >= 0,
"FmFormObj::SetPage : inserted but not present ?");
299 xEventManager->registerScriptEvents(nPos, aNewEvents);
336 DBG_ASSERT(_pSource !=
nullptr,
"FmFormObj::clonedFrom : invalid source !");
344 if (!xSourceAsChild.is())
359 FmFormObj* pFormObject = CloneHelper< FmFormObj >(rTargetModel);
360 DBG_ASSERT(pFormObject !=
nullptr,
"FmFormObj::Clone : invalid clone !");
379 Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY);
380 Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY);
381 if (xManagerAsIndex.is())
385 aEvts = xManager->getScriptEvents( nPos );
405 Reference< css::form::XFormComponent> xChild(_xElement, UNO_QUERY);
406 Reference< css::container::XIndexAccess> xParent;
408 xParent.set(xChild->getParent(), UNO_QUERY);
418 OUString sCurrentIndex = OUString::number(nPos);
419 if (!sReturn.isEmpty())
421 sCurrentIndex +=
"\\" + sReturn;
424 sReturn = sCurrentIndex;
427 xChild.set(xParent, css::uno::UNO_QUERY);
429 xParent.set(xChild->getParent(), UNO_QUERY);
432 _rTopLevelElement = xParent;
441 OUString sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSource);
442 if (!xTopLevelSource.is())
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 !");
450 sal_Int32 nTokIndex = 0;
453 OUString aToken = sAccessPath.getToken( 0,
'\\', nTokIndex );
454 sal_uInt16
nIndex =
static_cast<sal_uInt16
>(aToken.toInt32());
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 !");
462 Any aSrcCursorSource, aSrcCursorSourceType, aSrcDataSource;
474 OSL_FAIL(
"FmFormObj::ensureModelEnv : could not retrieve a source DSS !");
479 Reference< XPropertySet > xCurrentSourceForm, xCurrentDestForm;
480 sal_Int16 nCurrentSourceIndex = 0;
481 sal_Int32 nCurrentDestIndex = 0;
482 while (nCurrentSourceIndex <= nIndex)
484 bool bEqualDSS =
false;
487 xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
488 DBG_ASSERT(xCurrentSourceForm.is(),
"FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
494 if ( xCurrentSourceForm->getPropertyValue(
FM_PROP_COMMAND) == aSrcCursorSource
504 OSL_FAIL(
"FmFormObj::ensureModelEnv : exception while getting a sibling's DSS !");
508 ++nCurrentSourceIndex;
511 DBG_ASSERT(bEqualDSS,
"FmFormObj::ensureModelEnv : found no source form !");
516 while (!bEqualDSS && (nCurrentDestIndex < xDestContainer->getCount()))
518 xDestContainer->getByIndex(nCurrentDestIndex) >>= xCurrentDestForm;
519 DBG_ASSERT(xCurrentDestForm.is(),
"FmFormObj::ensureModelEnv : invalid destination form !");
525 if ( xCurrentDestForm->getPropertyValue(
FM_PROP_COMMAND) == aSrcCursorSource
535 OSL_FAIL(
"FmFormObj::ensureModelEnv : exception while getting a destination DSS !");
548 xCurrentDestForm.set(
551 ::comphelper::copyProperties( xCurrentSourceForm, xCurrentDestForm );
553 DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(),
"FmFormObj::ensureModelEnv : something went wrong with the numbers !");
554 xDestContainer->insertByIndex(nCurrentDestIndex,
makeAny(xCurrentDestForm));
561 OSL_FAIL(
"FmFormObj::ensureModelEnv : something went seriously wrong while creating a new form !");
573 xDestContainer.set(xCurrentDestForm, UNO_QUERY);
574 xSourceContainer.set(xSourceForm, UNO_QUERY);
575 DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(),
"FmFormObj::ensureModelEnv : invalid container !");
577 while ( nTokIndex >= 0 );
588 if ( pVirtualObject )
601 if ( pVirtualObject )
627 if (
nullptr != pFormPage)
632 Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
634 Reference< XIndexContainer > xFormToInsertInto;
636 if ( !xParentForm.is() )
639 xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
644 if ( xFormToInsertInto.is() )
645 xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(),
makeAny( xContent ) );
655 OSL_ENSURE( pViewImpl,
"FmFormObj::EndCreate: no view!?" );
670 OSL_ENSURE( pViewImpl,
"FmFormObj::EndCreate: no view!?" );
SdrObject & ReferencedObj()
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 ...
static OUString setUniqueName(const css::uno::Reference< css::form::XFormComponent > &xFormComponent, const css::uno::Reference< css::form::XForm > &xControls)
SdrUnoObj & operator=(const SdrUnoObj &rObj)
#define FM_PROP_DATASOURCE
virtual void NbcReformatText() override
OutputDevice * GetRefDevice() const
SdrPage * getSdrPageFromSdrObject() const
continuously activated OLE (PlugIn-Frame or similar)
const SdrObject & GetReferencedObj() const
void SetOutputDevice(const VclPtr< OutputDevice > &pOutDev)
FmFormPageImpl & GetImpl() const
#define DBG_UNHANDLED_EXCEPTION(...)
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
#define DBG_ASSERT(sCon, aError)
virtual void BrkCreate(SdrDragStat &rStat) override
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
SdrView * GetView() const
virtual void SetUnoControlModel(const css::uno::Reference< css::awt::XControlModel > &xModel)
SdrModel & getSdrModelFromSdrObject() const
void formModelAssigned(const FmFormObj &_object)
void formObjectInserted(const FmFormObj &_object)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
FIXME: The virtual object is not yet fully implemented and tested.
#define FM_PROP_COMMANDTYPE
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
void formObjectRemoved(const FmFormObj &_object)
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
uno::Reference< ucb::XContent > xContent
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
OutputDevice * get() const
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
css::uno::Reference< css::awt::XControlModel > xUnoControlModel
const css::uno::Reference< css::form::XForms > & GetForms(bool _bForceCreate=true) const
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)