LCOV - code coverage report
Current view: top level - libreoffice/svx/source/svdraw - svdouno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 72 242 29.8 %
Date: 2012-12-27 Functions: 17 39 43.6 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <svx/sdr/contact/viewcontactofunocontrol.hxx>
      21             : #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
      22             : #include <com/sun/star/container/XChild.hpp>
      23             : #include <com/sun/star/awt/XWindow.hpp>
      24             : #include <com/sun/star/awt/PosSize.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/io/XPersistObject.hpp>
      27             : #include <com/sun/star/io/XOutputStream.hpp>
      28             : #include <com/sun/star/io/XInputStream.hpp>
      29             : #include <com/sun/star/io/XActiveDataSink.hpp>
      30             : #include <com/sun/star/io/XActiveDataSource.hpp>
      31             : #include <com/sun/star/io/XObjectOutputStream.hpp>
      32             : #include <com/sun/star/io/XObjectInputStream.hpp>
      33             : #include <com/sun/star/util/XCloneable.hpp>
      34             : #include <comphelper/processfactory.hxx>
      35             : #include <comphelper/types.hxx>
      36             : #include <vcl/pdfextoutdevdata.hxx>
      37             : #include <svx/svdouno.hxx>
      38             : #include <svx/svdpagv.hxx>
      39             : #include <svx/svdmodel.hxx>
      40             : #include "svx/svdglob.hxx"  // string cache
      41             : #include "svx/svdstr.hrc"   // the object's name
      42             : #include <svx/svdetc.hxx>
      43             : #include <svx/svdview.hxx>
      44             : #include <svx/svdorect.hxx>
      45             : #include "svx/svdviter.hxx"
      46             : #include <rtl/ref.hxx>
      47             : #include <set>
      48             : #include <memory>
      49             : #include <svx/sdrpagewindow.hxx>
      50             : #include <svx/sdrpaintwindow.hxx>
      51             : #include <tools/diagnose_ex.h>
      52             : #include <svx/svdograf.hxx>
      53             : 
      54             : using namespace ::com::sun::star;
      55             : using namespace ::sdr::contact;
      56             : 
      57             : //************************************************************
      58             : //   Defines
      59             : //************************************************************
      60             : 
      61             : //************************************************************
      62             : //   Helper class SdrControlEventListenerImpl
      63             : //************************************************************
      64             : #include <com/sun/star/lang/XEventListener.hpp>
      65             : 
      66             : #include <cppuhelper/implbase1.hxx>
      67             : 
      68             : // =============================================================================
      69          18 : class SdrControlEventListenerImpl : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
      70             : {
      71             : protected:
      72             :     SdrUnoObj*                  pObj;
      73             : 
      74             : public:
      75           9 :     SdrControlEventListenerImpl(SdrUnoObj* _pObj)
      76           9 :     :   pObj(_pObj)
      77           9 :     {}
      78             : 
      79             :     // XEventListener
      80             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
      81             : 
      82             :     void StopListening(const uno::Reference< lang::XComponent >& xComp);
      83             :     void StartListening(const uno::Reference< lang::XComponent >& xComp);
      84             : };
      85             : 
      86             : // XEventListener
      87           9 : void SAL_CALL SdrControlEventListenerImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/)
      88             :     throw(::com::sun::star::uno::RuntimeException)
      89             : {
      90           9 :     if (pObj)
      91             :     {
      92           9 :         pObj->xUnoControlModel = NULL;
      93             :     }
      94           9 : }
      95             : 
      96           0 : void SdrControlEventListenerImpl::StopListening(const uno::Reference< lang::XComponent >& xComp)
      97             : {
      98           0 :     if (xComp.is())
      99           0 :         xComp->removeEventListener(this);
     100           0 : }
     101             : 
     102           9 : void SdrControlEventListenerImpl::StartListening(const uno::Reference< lang::XComponent >& xComp)
     103             : {
     104           9 :     if (xComp.is())
     105           9 :         xComp->addEventListener(this);
     106           9 : }
     107             : 
     108             : // =============================================================================
     109          18 : struct SAL_DLLPRIVATE SdrUnoObjDataHolder
     110             : {
     111             :     mutable ::rtl::Reference< SdrControlEventListenerImpl >
     112             :                                     pEventListener;
     113             : };
     114             : 
     115             : // =============================================================================
     116             : namespace
     117             : {
     118           0 :     void lcl_ensureControlVisibility( SdrView* _pView, const SdrUnoObj* _pObject, bool _bVisible )
     119             :     {
     120             :         OSL_PRECOND( _pObject, "lcl_ensureControlVisibility: no object -> no survival!" );
     121             : 
     122           0 :         SdrPageView* pPageView = _pView ? _pView->GetSdrPageView() : NULL;
     123             :         DBG_ASSERT( pPageView, "lcl_ensureControlVisibility: no view found!" );
     124           0 :         if ( !pPageView )
     125           0 :             return;
     126             : 
     127           0 :         ViewContact& rUnoControlContact( _pObject->GetViewContact() );
     128             : 
     129           0 :         for ( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i )
     130             :         {
     131           0 :             const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( i );
     132             :             DBG_ASSERT( pPageWindow, "lcl_ensureControlVisibility: invalid PageViewWindow!" );
     133           0 :             if ( !pPageWindow )
     134           0 :                 continue;
     135             : 
     136           0 :             if ( !pPageWindow->HasObjectContact() )
     137           0 :                 continue;
     138             : 
     139           0 :             ObjectContact& rPageViewContact( pPageWindow->GetObjectContact() );
     140           0 :             const ViewObjectContact& rViewObjectContact( rUnoControlContact.GetViewObjectContact( rPageViewContact ) );
     141           0 :             const ViewObjectContactOfUnoControl* pUnoControlContact = dynamic_cast< const ViewObjectContactOfUnoControl* >( &rViewObjectContact );
     142             :             DBG_ASSERT( pUnoControlContact, "lcl_ensureControlVisibility: wrong ViewObjectContact type!" );
     143           0 :             if ( !pUnoControlContact )
     144           0 :                 continue;
     145             : 
     146           0 :             pUnoControlContact->ensureControlVisibility( _bVisible );
     147             :         }
     148             :     }
     149             : }
     150             : 
     151             : //************************************************************
     152             : //   SdrUnoObj
     153             : //************************************************************
     154             : 
     155         142 : TYPEINIT1(SdrUnoObj, SdrRectObj);
     156             : 
     157           9 : SdrUnoObj::SdrUnoObj(const String& rModelName, sal_Bool _bOwnUnoControlModel)
     158           9 : :   m_pImpl( new SdrUnoObjDataHolder ),
     159          18 :     bOwnUnoControlModel( _bOwnUnoControlModel )
     160             : {
     161           9 :     bIsUnoObj = sal_True;
     162             : 
     163           9 :     m_pImpl->pEventListener = new SdrControlEventListenerImpl(this);
     164             : 
     165             :     // only an owner may create independently
     166           9 :     if (rModelName.Len())
     167           0 :         CreateUnoControlModel(rModelName);
     168           9 : }
     169             : 
     170           0 : SdrUnoObj::SdrUnoObj(const String& rModelName,
     171             :                      const uno::Reference< lang::XMultiServiceFactory >& rxSFac,
     172             :                      sal_Bool _bOwnUnoControlModel)
     173           0 : :   m_pImpl( new SdrUnoObjDataHolder ),
     174           0 :     bOwnUnoControlModel( _bOwnUnoControlModel )
     175             : {
     176           0 :     bIsUnoObj = sal_True;
     177             : 
     178           0 :     m_pImpl->pEventListener = new SdrControlEventListenerImpl(this);
     179             : 
     180             :     // only an owner may create independently
     181           0 :     if (rModelName.Len())
     182           0 :         CreateUnoControlModel(rModelName,rxSFac);
     183           0 : }
     184             : 
     185          18 : SdrUnoObj::~SdrUnoObj()
     186             : {
     187             :     try
     188             :     {
     189             :         // clean up the control model
     190           9 :         uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
     191           9 :         if (xComp.is())
     192             :         {
     193             :             // is the control model owned by its environment?
     194           0 :             uno::Reference< container::XChild > xContent(xUnoControlModel, uno::UNO_QUERY);
     195           0 :             if (xContent.is() && !xContent->getParent().is())
     196           0 :                 xComp->dispose();
     197             :             else
     198           0 :                 m_pImpl->pEventListener->StopListening(xComp);
     199           9 :         }
     200             :     }
     201           0 :     catch( const uno::Exception& )
     202             :     {
     203             :         OSL_FAIL( "SdrUnoObj::~SdrUnoObj: caught an exception!" );
     204             :     }
     205           9 :     delete m_pImpl;
     206           9 : }
     207             : 
     208           9 : void SdrUnoObj::SetModel(SdrModel* pNewModel)
     209             : {
     210           9 :     SdrRectObj::SetModel(pNewModel);
     211           9 : }
     212             : 
     213           9 : void SdrUnoObj::SetPage(SdrPage* pNewPage)
     214             : {
     215           9 :     SdrRectObj::SetPage(pNewPage);
     216           9 : }
     217             : 
     218           0 : void SdrUnoObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
     219             : {
     220           0 :     rInfo.bRotateFreeAllowed        =   sal_False;
     221           0 :     rInfo.bRotate90Allowed          =   sal_False;
     222           0 :     rInfo.bMirrorFreeAllowed        =   sal_False;
     223           0 :     rInfo.bMirror45Allowed          =   sal_False;
     224           0 :     rInfo.bMirror90Allowed          =   sal_False;
     225           0 :     rInfo.bTransparenceAllowed = sal_False;
     226           0 :     rInfo.bGradientAllowed = sal_False;
     227           0 :     rInfo.bShearAllowed             =   sal_False;
     228           0 :     rInfo.bEdgeRadiusAllowed        =   sal_False;
     229           0 :     rInfo.bNoOrthoDesired           =   sal_False;
     230           0 :     rInfo.bCanConvToPath            =   sal_False;
     231           0 :     rInfo.bCanConvToPoly            =   sal_False;
     232           0 :     rInfo.bCanConvToPathLineToArea  =   sal_False;
     233           0 :     rInfo.bCanConvToPolyLineToArea  =   sal_False;
     234           0 :     rInfo.bCanConvToContour = sal_False;
     235           0 : }
     236             : 
     237           0 : sal_uInt16 SdrUnoObj::GetObjIdentifier() const
     238             : {
     239           0 :     return sal_uInt16(OBJ_UNO);
     240             : }
     241             : 
     242           0 : void SdrUnoObj::SetContextWritingMode( const sal_Int16 _nContextWritingMode )
     243             : {
     244             :     try
     245             :     {
     246           0 :         uno::Reference< beans::XPropertySet > xModelProperties( GetUnoControlModel(), uno::UNO_QUERY_THROW );
     247           0 :         xModelProperties->setPropertyValue(
     248             :             ::rtl::OUString(  "ContextWritingMode"  ),
     249             :             uno::makeAny( _nContextWritingMode )
     250           0 :         );
     251             :     }
     252           0 :     catch( const uno::Exception& )
     253             :     {
     254             :         DBG_UNHANDLED_EXCEPTION();
     255             :     }
     256           0 : }
     257             : 
     258             : // ----------------------------------------------------------------------------
     259             : namespace
     260             : {
     261             :     /** helper class to restore graphics at <awt::XView> object after <SdrUnoObj::Paint>
     262             :         Restoration of graphics necessary to assure that paint on a window  */
     263             :     class RestoreXViewGraphics
     264             :     {
     265             :         private:
     266             :             uno::Reference< awt::XView >        m_rXView;
     267             :             uno::Reference< awt::XGraphics >    m_rXGraphics;
     268             : 
     269             :         public:
     270             :             RestoreXViewGraphics( const uno::Reference< awt::XView >& _rXView )
     271             :             {
     272             :                 m_rXView = _rXView;
     273             :                 m_rXGraphics = m_rXView->getGraphics();
     274             :             }
     275             :             ~RestoreXViewGraphics()
     276             :             {
     277             :                 m_rXView->setGraphics( m_rXGraphics );
     278             :             }
     279             :     };
     280             : }
     281             : 
     282           0 : void SdrUnoObj::TakeObjNameSingul(XubString& rName) const
     283             : {
     284           0 :     rName = ImpGetResStr(STR_ObjNameSingulUno);
     285             : 
     286           0 :     String aName( GetName() );
     287           0 :     if(aName.Len())
     288             :     {
     289           0 :         rName += sal_Unicode(' ');
     290           0 :         rName += sal_Unicode('\'');
     291           0 :         rName += aName;
     292           0 :         rName += sal_Unicode('\'');
     293           0 :     }
     294           0 : }
     295             : 
     296           0 : void SdrUnoObj::TakeObjNamePlural(XubString& rName) const
     297             : {
     298           0 :     rName = ImpGetResStr(STR_ObjNamePluralUno);
     299           0 : }
     300             : 
     301           0 : SdrUnoObj* SdrUnoObj::Clone() const
     302             : {
     303           0 :     return CloneHelper< SdrUnoObj >();
     304             : }
     305             : 
     306           0 : SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj)
     307             : {
     308           0 :     if( this == &rObj )
     309           0 :         return *this;
     310           0 :     SdrRectObj::operator= (rObj);
     311             : 
     312             :     // release the reference to the current control model
     313           0 :     SetUnoControlModel( NULL );
     314             : 
     315           0 :     aUnoControlModelTypeName = rObj.aUnoControlModelTypeName;
     316           0 :     aUnoControlTypeName = rObj.aUnoControlTypeName;
     317             : 
     318             :     // copy the uno control model
     319           0 :     const uno::Reference< awt::XControlModel > xSourceControlModel( rObj.GetUnoControlModel(), uno::UNO_QUERY );
     320           0 :     if ( xSourceControlModel.is() )
     321             :     {
     322             :         try
     323             :         {
     324           0 :             uno::Reference< util::XCloneable > xClone( xSourceControlModel, uno::UNO_QUERY_THROW );
     325           0 :             xUnoControlModel.set( xClone->createClone(), uno::UNO_QUERY_THROW );
     326             :         }
     327           0 :         catch( const uno::Exception& )
     328             :         {
     329             :             DBG_UNHANDLED_EXCEPTION();
     330             :         }
     331             :     }
     332             : 
     333             :     // get service name of the control from the control model
     334           0 :     uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY);
     335           0 :     if (xSet.is())
     336             :     {
     337           0 :         uno::Any aValue( xSet->getPropertyValue( rtl::OUString("DefaultControl")) );
     338           0 :         ::rtl::OUString aStr;
     339             : 
     340           0 :         if( aValue >>= aStr )
     341           0 :             aUnoControlTypeName = String(aStr);
     342             :     }
     343             : 
     344           0 :     uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
     345           0 :     if (xComp.is())
     346           0 :         m_pImpl->pEventListener->StartListening(xComp);
     347           0 :     return *this;
     348             : }
     349             : 
     350           0 : void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
     351             : {
     352           0 :     SdrRectObj::NbcResize(rRef,xFact,yFact);
     353             : 
     354           0 :     if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0)
     355             :     {
     356             :         // small correctures
     357           0 :         if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000)
     358             :         {
     359           0 :             aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
     360             :         }
     361             : 
     362           0 :         aGeo.nDrehWink  = 0;
     363           0 :         aGeo.nShearWink = 0;
     364           0 :         aGeo.nSin       = 0.0;
     365           0 :         aGeo.nCos       = 1.0;
     366           0 :         aGeo.nTan       = 0.0;
     367           0 :         SetRectsDirty();
     368             :     }
     369           0 : }
     370             : 
     371             : // -----------------------------------------------------------------------------
     372             : 
     373           0 : bool SdrUnoObj::hasSpecialDrag() const
     374             : {
     375             :     // no special drag; we have no rounding rect and
     376             :     // do want frame handles
     377           0 :     return false;
     378             : }
     379             : 
     380           0 : bool SdrUnoObj::supportsFullDrag() const
     381             : {
     382             :     // overloaded to have the possibility to enable/disable in debug and
     383             :     // to ckeck some things out. Current solution is working, so default is
     384             :     // enabled
     385             :     static bool bDoSupportFullDrag(true);
     386             : 
     387           0 :     return bDoSupportFullDrag;
     388             : }
     389             : 
     390           0 : SdrObject* SdrUnoObj::getFullDragClone() const
     391             : {
     392           0 :     SdrObject* pRetval = 0;
     393             :     static bool bHandleSpecial(false);
     394             : 
     395           0 :     if(bHandleSpecial)
     396             :     {
     397             :         // special handling for SdrUnoObj (FormControl). Create a SdrGrafObj
     398             :         // for drag containing the graphical representation. This does not work too
     399             :         // well, so the default is to simply clone
     400           0 :         pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
     401             :     }
     402             :     else
     403             :     {
     404             :         // call parent (simply clone)
     405           0 :         pRetval = SdrRectObj::getFullDragClone();
     406             :     }
     407             : 
     408           0 :     return pRetval;
     409             : }
     410             : 
     411             : // -----------------------------------------------------------------------------
     412          16 : void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer )
     413             : {
     414          16 :     if ( GetLayer() == _nLayer )
     415             :     {   // redundant call -> not interested in doing anything here
     416           0 :         SdrRectObj::NbcSetLayer( _nLayer );
     417          16 :         return;
     418             :     }
     419             : 
     420             :     // we need some special handling here in case we're moved from an invisible layer
     421             :     // to a visible one, or vice versa
     422             :     // (relative to a layer. Remember that the visibility of a layer is a view attribute
     423             :     // - the same layer can be visible in one view, and invisible in another view, at the
     424             :     // same time)
     425             : 
     426             :     // collect all views in which our old layer is visible
     427          16 :     ::std::set< SdrView* > aPreviouslyVisible;
     428             : 
     429             :     {
     430          16 :         SdrViewIter aIter( this );
     431          16 :         for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
     432           0 :             aPreviouslyVisible.insert( pView );
     433             :     }
     434             : 
     435          16 :     SdrRectObj::NbcSetLayer( _nLayer );
     436             : 
     437             :     // collect all views in which our new layer is visible
     438          16 :     ::std::set< SdrView* > aNewlyVisible;
     439             : 
     440             :     {
     441          16 :         SdrViewIter aIter( this );
     442          16 :         for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
     443             :         {
     444           0 :             ::std::set< SdrView* >::const_iterator aPrevPos = aPreviouslyVisible.find( pView );
     445           0 :             if ( aPreviouslyVisible.end() != aPrevPos )
     446             :             {   // in pView, we were visible _before_ the layer change, and are
     447             :                 // visible _after_ the layer change, too
     448             :                 // -> we're not interested in this view at all
     449           0 :                 aPreviouslyVisible.erase( aPrevPos );
     450             :             }
     451             :             else
     452             :             {
     453             :                 // in pView, we were visible _before_ the layer change, and are
     454             :                 // _not_ visible after the layer change
     455             :                 // => remember this view, as our visibility there changed
     456           0 :                 aNewlyVisible.insert( pView );
     457             :             }
     458             :         }
     459             :     }
     460             : 
     461             :     // now aPreviouslyVisible contains all views where we became invisible
     462          16 :     ::std::set< SdrView* >::const_iterator aLoopViews;
     463          48 :     for (   aLoopViews = aPreviouslyVisible.begin();
     464          32 :             aLoopViews != aPreviouslyVisible.end();
     465             :             ++aLoopViews
     466             :         )
     467             :     {
     468           0 :         lcl_ensureControlVisibility( *aLoopViews, this, false );
     469             :     }
     470             : 
     471             :     // and aNewlyVisible all views where we became visible
     472          48 :     for (   aLoopViews = aNewlyVisible.begin();
     473          32 :             aLoopViews != aNewlyVisible.end();
     474             :             ++aLoopViews
     475             :         )
     476             :     {
     477           0 :         lcl_ensureControlVisibility( *aLoopViews, this, true );
     478          16 :     }
     479             : }
     480             : 
     481           0 : void SdrUnoObj::CreateUnoControlModel(const String& rModelName)
     482             : {
     483             :     DBG_ASSERT(!xUnoControlModel.is(), "model already exists");
     484             : 
     485           0 :     aUnoControlModelTypeName = rModelName;
     486             : 
     487           0 :     uno::Reference< awt::XControlModel >   xModel;
     488           0 :     uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
     489           0 :     if (aUnoControlModelTypeName.Len() && xFactory.is() )
     490             :     {
     491           0 :         xModel = uno::Reference< awt::XControlModel >(xFactory->createInstance(
     492           0 :             aUnoControlModelTypeName), uno::UNO_QUERY);
     493             : 
     494           0 :         if (xModel.is())
     495           0 :             SetChanged();
     496             :     }
     497             : 
     498           0 :     SetUnoControlModel(xModel);
     499           0 : }
     500             : 
     501           0 : void SdrUnoObj::CreateUnoControlModel(const String& rModelName,
     502             :                                       const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
     503             : {
     504             :     DBG_ASSERT(!xUnoControlModel.is(), "model already exists");
     505             : 
     506           0 :     aUnoControlModelTypeName = rModelName;
     507             : 
     508           0 :     uno::Reference< awt::XControlModel >   xModel;
     509           0 :     if (aUnoControlModelTypeName.Len() && rxSFac.is() )
     510             :     {
     511           0 :         xModel = uno::Reference< awt::XControlModel >(rxSFac->createInstance(
     512           0 :             aUnoControlModelTypeName), uno::UNO_QUERY);
     513             : 
     514           0 :         if (xModel.is())
     515           0 :             SetChanged();
     516             :     }
     517             : 
     518           0 :     SetUnoControlModel(xModel);
     519           0 : }
     520             : 
     521           9 : void SdrUnoObj::SetUnoControlModel( const uno::Reference< awt::XControlModel >& xModel)
     522             : {
     523           9 :     if (xUnoControlModel.is())
     524             :     {
     525           0 :         uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
     526           0 :         if (xComp.is())
     527           0 :             m_pImpl->pEventListener->StopListening(xComp);
     528             :     }
     529             : 
     530           9 :     xUnoControlModel = xModel;
     531             : 
     532             :     // control model has to contain service name of the control
     533           9 :     if (xUnoControlModel.is())
     534             :     {
     535           9 :         uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY);
     536           9 :         if (xSet.is())
     537             :         {
     538           9 :             uno::Any aValue( xSet->getPropertyValue(String("DefaultControl", osl_getThreadTextEncoding())) );
     539           9 :             ::rtl::OUString aStr;
     540           9 :             if( aValue >>= aStr )
     541           9 :                 aUnoControlTypeName = String(aStr);
     542             :         }
     543             : 
     544           9 :         uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
     545           9 :         if (xComp.is())
     546           9 :             m_pImpl->pEventListener->StartListening(xComp);
     547             :     }
     548             : 
     549             :     // invalidate all ViewObject contacts
     550           9 :     ViewContactOfUnoControl* pVC = NULL;
     551           9 :     if ( impl_getViewContact( pVC ) )
     552             :     {
     553             :         // flushViewObjectContacts() removes all existing VOCs for the local DrawHierarchy. This
     554             :         // is always allowed since they will be re-created on demand (and with the changed model)
     555           9 :         GetViewContact().flushViewObjectContacts(true);
     556             :     }
     557           9 : }
     558             : 
     559             : //------------------------------------------------------------------------
     560           0 : uno::Reference< awt::XControl > SdrUnoObj::GetUnoControl(const SdrView& _rView, const OutputDevice& _rOut) const
     561             : {
     562           0 :     uno::Reference< awt::XControl > xControl;
     563             : 
     564           0 :     SdrPageView* pPageView = _rView.GetSdrPageView();
     565             :     OSL_ENSURE( GetPage() == pPageView->GetPage(), "SdrUnoObj::GetUnoControl: This object is not displayed in that particular view!" );
     566           0 :     if ( GetPage() != pPageView->GetPage() )
     567           0 :         return NULL;
     568             : 
     569           0 :     SdrPageWindow* pPageWindow = pPageView ? pPageView->FindPageWindow( _rOut ) : NULL;
     570             :     OSL_ENSURE( pPageWindow, "SdrUnoObj::GetUnoControl: did not find my SdrPageWindow!" );
     571           0 :     if ( !pPageWindow )
     572           0 :         return NULL;
     573             : 
     574           0 :     ViewObjectContact& rViewObjectContact( GetViewContact().GetViewObjectContact( pPageWindow->GetObjectContact() ) );
     575           0 :     ViewObjectContactOfUnoControl* pUnoContact = dynamic_cast< ViewObjectContactOfUnoControl* >( &rViewObjectContact );
     576             :     OSL_ENSURE( pUnoContact, "SdrUnoObj::GetUnoControl: wrong contact type!" );
     577           0 :     if ( pUnoContact )
     578           0 :         xControl = pUnoContact->getControl();
     579             : 
     580           0 :     return xControl;
     581             : }
     582             : 
     583             : //------------------------------------------------------------------------
     584           0 : uno::Reference< awt::XControl > SdrUnoObj::GetTemporaryControlForWindow(
     585             :     const Window& _rWindow, uno::Reference< awt::XControlContainer >& _inout_ControlContainer ) const
     586             : {
     587           0 :     uno::Reference< awt::XControl > xControl;
     588             : 
     589           0 :     ViewContactOfUnoControl* pVC = NULL;
     590           0 :     if ( impl_getViewContact( pVC ) )
     591           0 :         xControl = pVC->getTemporaryControlForWindow( _rWindow, _inout_ControlContainer );
     592             : 
     593           0 :     return xControl;
     594             : }
     595             : 
     596             : //------------------------------------------------------------------------
     597           9 : bool SdrUnoObj::impl_getViewContact( ViewContactOfUnoControl*& _out_rpContact ) const
     598             : {
     599           9 :     ViewContact& rViewContact( GetViewContact() );
     600           9 :     _out_rpContact = dynamic_cast< ViewContactOfUnoControl* >( &rViewContact );
     601             :     DBG_ASSERT( _out_rpContact, "SdrUnoObj::impl_getViewContact: could not find my ViewContact!" );
     602           9 :     return ( _out_rpContact != NULL );
     603             : }
     604             : 
     605             : //------------------------------------------------------------------------
     606           9 : ::sdr::contact::ViewContact* SdrUnoObj::CreateObjectSpecificViewContact()
     607             : {
     608           9 :   return new ::sdr::contact::ViewContactOfUnoControl( *this );
     609             : }
     610             : 
     611             : 
     612             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10