22 #include <com/sun/star/container/XChild.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/util/XCloneable.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <svx/strings.hrc>
35 #include <rtl/ustrbuf.hxx>
36 #include <rtl/ref.hxx>
51 #include <com/sun/star/lang/XEventListener.hpp>
67 virtual void SAL_CALL disposing(
const css::lang::EventObject& Source )
override;
69 void StopListening(
const uno::Reference< lang::XComponent >& xComp);
70 void StartListening(
const uno::Reference< lang::XComponent >& xComp);
78 pObj->xUnoControlModel =
nullptr;
85 xComp->removeEventListener(
this);
91 xComp->addEventListener(
this);
97 mutable ::rtl::Reference< SdrControlEventListenerImpl >
104 void lcl_ensureControlVisibility(
SdrView const * _pView,
const SdrUnoObj* _pObject,
bool _bVisible )
106 OSL_PRECOND( _pObject,
"lcl_ensureControlVisibility: no object -> no survival!" );
109 DBG_ASSERT( pPageView,
"lcl_ensureControlVisibility: no view found!" );
118 DBG_ASSERT( pPageWindow,
"lcl_ensureControlVisibility: invalid PageViewWindow!" );
126 const ViewObjectContact& rViewObjectContact( rUnoControlContact.GetViewObjectContact( rPageViewContact ) );
128 DBG_ASSERT( pUnoControlContact,
"lcl_ensureControlVisibility: wrong ViewObjectContact type!" );
129 if ( !pUnoControlContact )
132 pUnoControlContact->ensureControlVisibility( _bVisible );
139 const OUString& rModelName)
148 if (!rModelName.isEmpty())
154 const OUString& rModelName,
155 const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
164 if (!rModelName.isEmpty())
178 if (xContent.is() && !xContent->getParent().is())
181 m_pImpl->pEventListener->StopListening(xComp);
184 catch(
const uno::Exception& )
217 uno::Reference< beans::XPropertySet > xModelProperties(
GetUnoControlModel(), uno::UNO_QUERY_THROW );
218 xModelProperties->setPropertyValue(
"ContextWritingMode", uno::makeAny( _nContextWritingMode ) );
220 catch(
const uno::Exception& )
231 if (!aName.isEmpty())
239 return sName.makeStringAndClear();
244 return SvxResId(STR_ObjNamePluralUno);
249 return CloneHelper< SdrUnoObj >(rTargetModel);
265 const uno::Reference< awt::XControlModel > xSourceControlModel = rObj.
GetUnoControlModel();
266 if ( xSourceControlModel.is() )
270 uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW );
273 catch(
const uno::Exception& )
280 uno::Reference< beans::XPropertySet > xSet(
xUnoControlModel, uno::UNO_QUERY);
283 uno::Any aValue( xSet->getPropertyValue(
"DefaultControl") );
286 if( aValue >>= aStr )
292 m_pImpl->pEventListener->StartListening(xComp);
345 aPreviouslyVisible.
insert( pView );
357 if ( aPreviouslyVisible.
erase(pView) == 0 )
362 aNewlyVisible.
insert( pView );
368 for (
const auto& rpView : aPreviouslyVisible)
370 lcl_ensureControlVisibility( rpView,
this,
false );
374 for (
const auto& rpView : aNewlyVisible)
376 lcl_ensureControlVisibility( rpView,
this,
true );
386 uno::Reference< awt::XControlModel >
xModel;
388 if (!aUnoControlModelTypeName.isEmpty() )
390 xModel.set(xContext->getServiceManager()->createInstanceWithContext(
391 aUnoControlModelTypeName, xContext), uno::UNO_QUERY);
401 const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
407 uno::Reference< awt::XControlModel >
xModel;
408 if (!aUnoControlModelTypeName.isEmpty() && rxSFac.is() )
410 xModel.set(rxSFac->createInstance(aUnoControlModelTypeName), uno::UNO_QUERY);
425 m_pImpl->pEventListener->StopListening(xComp);
433 uno::Reference< beans::XPropertySet > xSet(
xUnoControlModel, uno::UNO_QUERY);
436 uno::Any aValue( xSet->getPropertyValue(
"DefaultControl") );
438 if( aValue >>= aStr )
444 m_pImpl->pEventListener->StartListening(xComp);
460 uno::Reference< awt::XControl > xControl;
463 OSL_ENSURE( pPageView &&
getSdrPageFromSdrObject() == pPageView->
GetPage(),
"SdrUnoObj::GetUnoControl: This object is not displayed in that particular view!" );
468 OSL_ENSURE( pPageWindow,
"SdrUnoObj::GetUnoControl: did not find my SdrPageWindow!" );
474 OSL_ENSURE( pUnoContact,
"SdrUnoObj::GetUnoControl: wrong contact type!" );
483 const vcl::Window& _rWindow, uno::Reference< awt::XControlContainer >& _inout_ControlContainer )
const
485 uno::Reference< awt::XControl > xControl;
499 DBG_ASSERT( _out_rpContact,
"SdrUnoObj::impl_getViewContact: could not find my ViewContact!" );
500 return ( _out_rpContact !=
nullptr );
506 return std::make_unique<sdr::contact::ViewContactOfUnoControl>( *this );
SVX_DLLPRIVATE bool impl_getViewContact(sdr::contact::ViewContactOfUnoControl *&_out_rpContact) const
Retrieves the typed ViewContact for the object.
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void StartListening(const uno::Reference< lang::XComponent > &xComp)
virtual SdrObjKind GetObjIdentifier() const override
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
SdrUnoObj & operator=(const SdrUnoObj &rObj)
double mfSinRotationAngle
virtual void SetContextWritingMode(const sal_Int16 _nContextWritingMode) override
SdrUnoObj(SdrModel &rSdrModel, const OUString &rModelName)
sdr::contact::ViewContact & GetViewContact() const
Rectangle objects (rectangle, circle, ...)
SdrPageWindow * FindPageWindow(SdrPaintWindow &rPaintWindow) const
virtual void NbcSetLayer(SdrLayerID nLayer) override
SdrPageWindow * GetPageWindow(sal_uInt32 nIndex) const
SdrPage * getSdrPageFromSdrObject() const
OUString SvxResId(const char *pId)
SVX_DLLPRIVATE void CreateUnoControlModel(const OUString &rModelName)
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
virtual ~SdrUnoObj() override
void StopListening(const uno::Reference< lang::XComponent > &xComp)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
virtual OUString TakeObjNamePlural() const override
OUString aUnoControlTypeName
#define DBG_UNHANDLED_EXCEPTION(...)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_ASSERT(sCon, aError)
friend class SdrControlEventListenerImpl
css::uno::Reference< css::awt::XControl > GetTemporaryControlForWindow(const vcl::Window &_rWindow, css::uno::Reference< css::awt::XControlContainer > &_inout_ControlContainer) const
Retrieves a temporary XControl instance for a given output device.
virtual void SetUnoControlModel(const css::uno::Reference< css::awt::XControlModel > &xModel)
const sdr::contact::ObjectContact & GetObjectContact() const
virtual SdrLayerID GetLayer() const
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
SdrControlEventListenerImpl(SdrUnoObj *_pObj)
SdrRectObj & operator=(const SdrRectObj &rCopy)
mutable::rtl::Reference< SdrControlEventListenerImpl > pEventListener
std::unique_ptr< SdrUnoObjDataHolder > m_pImpl
SdrPage * GetPage() const
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
bool HasObjectContact() const
determines whether there already exists an ObjectContact
double mfCosRotationAngle
Reference< XComponentContext > getProcessComponentContext()
virtual OUString TakeObjNameSingul() const override
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
SdrPageView * GetSdrPageView() const
virtual void SetRectsDirty(bool bNotMyself=false, bool bRecursive=true)
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
uno::Reference< ucb::XContent > xContent
Reference< XModel > xModel
css::uno::Reference< css::awt::XControlModel > xUnoControlModel
continuously activated OLE (PlugIn-Frame or similar)
std::pair< const_iterator, bool > insert(Value &&x)
virtual void SetChanged()
virtual SdrUnoObj * CloneSdrObject(SdrModel &rTargetModel) const override
OUString aUnoControlModelTypeName
size_type erase(const Value &x)
virtual void NbcSetLayer(SdrLayerID nLayer)
sal_uInt32 PageWindowCount() const