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>
50#include <com/sun/star/lang/XEventListener.hpp>
66 virtual void SAL_CALL
disposing(
const css::lang::EventObject& Source )
override;
68 void StopListening(
const uno::Reference< lang::XComponent >& xComp);
69 void StartListening(
const uno::Reference< lang::XComponent >& xComp);
84 xComp->removeEventListener(
this);
90 xComp->addEventListener(
this);
96 mutable ::rtl::Reference< SdrControlEventListenerImpl >
103 void lcl_ensureControlVisibility(
SdrView const * _pView,
const SdrUnoObj* _pObject,
bool _bVisible )
105 OSL_PRECOND( _pObject,
"lcl_ensureControlVisibility: no object -> no survival!" );
108 DBG_ASSERT( pPageView,
"lcl_ensureControlVisibility: no view found!" );
117 DBG_ASSERT( pPageWindow,
"lcl_ensureControlVisibility: invalid PageViewWindow!" );
127 DBG_ASSERT( pUnoControlContact,
"lcl_ensureControlVisibility: wrong ViewObjectContact type!" );
128 if ( !pUnoControlContact )
138 const OUString& rModelName)
148 if (!rModelName.isEmpty())
165 const uno::Reference< awt::XControlModel > xSourceControlModel = rSource.
GetUnoControlModel();
166 if ( xSourceControlModel.is() )
170 uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW );
173 catch(
const uno::Exception& )
180 uno::Reference< beans::XPropertySet > xSet(
xUnoControlModel, uno::UNO_QUERY);
183 uno::Any aValue( xSet->getPropertyValue(
"DefaultControl") );
186 if( aValue >>=
aStr )
192 m_pImpl->pEventListener->StartListening(xComp);
197 const OUString& rModelName,
198 const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
207 if (!rModelName.isEmpty())
220 uno::Reference< container::XChild > xContent(
xUnoControlModel, uno::UNO_QUERY);
221 if (xContent.is() && !xContent->getParent().is())
224 m_pImpl->pEventListener->StopListening(xComp);
227 catch(
const uno::Exception& )
260 uno::Reference< beans::XPropertySet > xModelProperties(
GetUnoControlModel(), uno::UNO_QUERY_THROW );
261 xModelProperties->setPropertyValue(
"ContextWritingMode",
uno::Any( _nContextWritingMode ) );
263 catch(
const uno::Exception& )
274 if (!
aName.isEmpty())
282 return SvxResId(STR_ObjNamePluralUno);
287 return new SdrUnoObj(rTargetModel, *
this);
338 [&aPreviouslyVisible] (
SdrView* pView)
340 aPreviouslyVisible.
insert( pView );
351 [&aPreviouslyVisible, &aNewlyVisible] (
SdrView* pView)
353 if ( aPreviouslyVisible.
erase(pView) == 0 )
358 aNewlyVisible.insert( pView );
363 for (
const auto& rpView : aPreviouslyVisible)
365 lcl_ensureControlVisibility( rpView,
this,
false );
369 for (
const auto& rpView : aNewlyVisible)
371 lcl_ensureControlVisibility( rpView,
this,
true );
381 uno::Reference< awt::XControlModel >
xModel;
382 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
385 xModel.set(xContext->getServiceManager()->createInstanceWithContext(
396 const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
402 uno::Reference< awt::XControlModel >
xModel;
420 m_pImpl->pEventListener->StopListening(xComp);
428 uno::Reference< beans::XPropertySet > xSet(
xUnoControlModel, uno::UNO_QUERY);
431 uno::Any aValue( xSet->getPropertyValue(
"DefaultControl") );
433 if( aValue >>=
aStr )
439 m_pImpl->pEventListener->StartListening(xComp);
455 uno::Reference< awt::XControl > xControl;
458 OSL_ENSURE( pPageView &&
getSdrPageFromSdrObject() == pPageView->
GetPage(),
"SdrUnoObj::GetUnoControl: This object is not displayed in that particular view!" );
463 OSL_ENSURE( pPageWindow,
"SdrUnoObj::GetUnoControl: did not find my SdrPageWindow!" );
469 OSL_ENSURE( pUnoContact,
"SdrUnoObj::GetUnoControl: wrong contact type!" );
478 const vcl::Window& _rWindow, uno::Reference< awt::XControlContainer >& _inout_ControlContainer )
const
480 uno::Reference< awt::XControl > xControl;
494 DBG_ASSERT( _out_rpContact,
"SdrUnoObj::impl_getViewContact: could not find my ViewContact!" );
495 return ( _out_rpContact !=
nullptr );
501 return std::make_unique<sdr::contact::ViewContactOfUnoControl>( *
this );
double mfCosRotationAngle
double mfSinRotationAngle
Degree100 m_nRotationAngle
void StartListening(const uno::Reference< lang::XComponent > &xComp)
SdrControlEventListenerImpl(SdrUnoObj *_pObj)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void StopListening(const uno::Reference< lang::XComponent > &xComp)
virtual void NbcSetLayer(SdrLayerID nLayer)
virtual const OUString & GetName() const
sdr::contact::ViewContact & GetViewContact() const
virtual void SetChanged()
SdrPage * getSdrPageFromSdrObject() const
virtual SdrLayerID GetLayer() const
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself=false, bool bRecursive=true)
sal_uInt32 PageWindowCount() const
SdrPage * GetPage() const
SdrPageWindow * GetPageWindow(sal_uInt32 nIndex) const
SdrPageWindow * FindPageWindow(const SdrPaintWindow &rPaintWindow) const
bool HasObjectContact() const
determines whether there already exists an ObjectContact
const sdr::contact::ObjectContact & GetObjectContact() const
SdrPageView * GetSdrPageView() const
Rectangle objects (rectangle, circle, ...)
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
tools::Rectangle const & getRectangle() const
void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
SVX_DLLPRIVATE void CreateUnoControlModel(const OUString &rModelName)
virtual void NbcSetLayer(SdrLayerID nLayer) override
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
css::uno::Reference< css::awt::XControlModel > xUnoControlModel
virtual OUString TakeObjNameSingul() const override
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.
OUString aUnoControlTypeName
OUString aUnoControlModelTypeName
virtual void SetContextWritingMode(const sal_Int16 _nContextWritingMode) override
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
std::unique_ptr< SdrUnoObjDataHolder > m_pImpl
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView &_rView, const OutputDevice &_rOut) const
friend class SdrControlEventListenerImpl
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
virtual OUString TakeObjNamePlural() const override
virtual void SetUnoControlModel(const css::uno::Reference< css::awt::XControlModel > &xModel)
SdrUnoObj(SdrModel &rSdrModel, const OUString &rModelName)
virtual SdrObjKind GetObjIdentifier() const override
virtual ~SdrUnoObj() override
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
SVX_DLLPRIVATE bool impl_getViewContact(sdr::contact::ViewContactOfUnoControl *&_out_rpContact) const
Retrieves the typed ViewContact for the object.
oslInterlockedCount m_refCount
size_type erase(const Value &x)
std::pair< const_iterator, bool > insert(Value &&x)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
OUString SvxResId(TranslateId aId)
void ForAllViews(const SdrPage *pPage, std::function< void(SdrView *)> f)
mutable ::rtl::Reference< SdrControlEventListenerImpl > pEventListener
Reference< XModel > xModel
@ UNO
continuously activated OLE (PlugIn-Frame or similar)