xref: /trunk/main/svx/source/svdraw/svdoole2.cxx (revision 079eb148)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <svx/svdoole2.hxx>
32 #include <com/sun/star/util/XModifyBroadcaster.hpp>
33 #include <com/sun/star/util/XModifiable.hpp>
34 #include <com/sun/star/embed/EmbedStates.hpp>
35 #include <com/sun/star/embed/ElementModes.hpp>
36 #include <com/sun/star/embed/EmbedMisc.hpp>
37 #include <com/sun/star/embed/Aspects.hpp>
38 #include <com/sun/star/embed/XInplaceClient.hpp>
39 #include <com/sun/star/embed/XInplaceObject.hpp>
40 #include <com/sun/star/embed/XLinkageSupport.hpp>
41 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
42 #include <com/sun/star/embed/XWindowSupplier.hpp>
43 #include <com/sun/star/document/XEventListener.hpp>
44 #include <com/sun/star/container/XChild.hpp>
45 #include "com/sun/star/document/XStorageBasedDocument.hpp"
46 
47 #include <comphelper/processfactory.hxx>
48 #include <cppuhelper/exc_hlp.hxx>
49 #include <unotools/ucbstreamhelper.hxx>
50 
51 #include <toolkit/helper/vclunohelper.hxx>
52 #include <toolkit/awt/vclxwindow.hxx>
53 #include <toolkit/helper/convert.hxx>
54 
55 #include <svtools/filter.hxx>
56 #include <svtools/embedhlp.hxx>
57 
58 #include <sfx2/objsh.hxx>
59 #include <sfx2/ipclient.hxx>
60 #include <sfx2/lnkbase.hxx>
61 #include <tools/stream.hxx>
62 #include <comphelper/anytostring.hxx>
63 #include <svx/svdpagv.hxx>
64 #include <tools/globname.hxx>
65 #include <vcl/jobset.hxx>
66 #include <sot/clsids.hxx>
67 
68 #include <sot/formats.hxx>
69 #include <sfx2/linkmgr.hxx>
70 #include <svtools/transfer.hxx>
71 #include <cppuhelper/implbase5.hxx>
72 
73 #include <svl/solar.hrc>
74 #include <svl/urihelper.hxx>
75 #include <vos/mutex.hxx>
76 #include <vcl/svapp.hxx>
77 
78 #include <svx/svdpagv.hxx>
79 #include <svx/svdmodel.hxx>
80 #include "svx/svdglob.hxx"  // Stringcache
81 #include "svx/svdstr.hrc"   // Objektname
82 #include <svx/svdetc.hxx>
83 #include <svx/svdview.hxx>
84 #include "unomlstr.hxx"
85 #include <svtools/chartprettypainter.hxx>
86 #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
87 #include <svx/svdograf.hxx>
88 #include <svx/sdr/properties/oleproperties.hxx>
89 
90 // #i100710#
91 #include <svx/xlnclit.hxx>
92 #include <svx/xbtmpit.hxx>
93 #include <svx/xflbmtit.hxx>
94 #include <svx/xflbstit.hxx>
95 
96 // #i118485#
97 #include <basegfx/matrix/b2dhommatrix.hxx>
98 #include <basegfx/polygon/b2dpolypolygon.hxx>
99 #include <editeng/outlobj.hxx>
100 
101 using namespace ::rtl;
102 using namespace ::com::sun::star;
103 
104 uno::Reference < beans::XPropertySet > lcl_getFrame_throw(const SdrOle2Obj* _pObject)
105 {
106     uno::Reference < beans::XPropertySet > xFrame;
107     if ( _pObject )
108     {
109         uno::Reference< frame::XController> xController = _pObject->GetParentXModel()->getCurrentController();
110         if ( xController.is() )
111         {
112             xFrame.set( xController->getFrame(),uno::UNO_QUERY_THROW);
113         }
114     } // if ( _pObject )
115     return xFrame;
116 }
117 
118 class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper5
119 															< embed::XStateChangeListener
120 															, document::XEventListener
121                                                             , embed::XInplaceClient
122 															, embed::XEmbeddedClient
123                                                             , embed::XWindowSupplier
124                                                             >
125 {
126     uno::Reference< awt::XWindow > m_xWindow;
127 	SdrOle2Obj* mpObj;
128 
129 	Fraction m_aScaleWidth;
130 	Fraction m_aScaleHeight;
131 
132 
133 public:
134     SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
135     void Release();
136 
137 	void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
138 	{
139 		m_aScaleWidth = aScaleWidth;
140 		m_aScaleHeight = aScaleHeight;
141 	}
142 
143 	Fraction GetScaleWidth() const { return m_aScaleWidth; }
144 	Fraction GetScaleHeight() const { return m_aScaleHeight; }
145 
146     void setWindow(const uno::Reference< awt::XWindow >& _xWindow);
147 
148 private:
149     Rectangle impl_getScaledRect_nothrow() const;
150 	// XStateChangeListener
151     virtual void SAL_CALL changingState( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException);
152     virtual void SAL_CALL stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException);
153     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
154 
155     // document::XEventListener
156     virtual void SAL_CALL       notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
157 
158 	// XEmbeddedClient
159     virtual void SAL_CALL saveObject() throw ( embed::ObjectSaveVetoException, uno::Exception, uno::RuntimeException );
160     virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) throw ( embed::WrongStateException, uno::RuntimeException );
161 
162 	// XComponentSupplier
163     virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() throw ( uno::RuntimeException );
164 
165     // XInplaceClient
166     virtual sal_Bool SAL_CALL canInplaceActivate() throw ( uno::RuntimeException );
167     virtual void SAL_CALL activatingInplace() throw ( embed::WrongStateException, uno::RuntimeException );
168     virtual void SAL_CALL activatingUI() throw ( embed::WrongStateException, uno::RuntimeException );
169     virtual void SAL_CALL deactivatedInplace() throw ( embed::WrongStateException, uno::RuntimeException );
170     virtual void SAL_CALL deactivatedUI() throw ( embed::WrongStateException, uno::RuntimeException );
171     virtual uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL getLayoutManager() throw ( embed::WrongStateException, uno::RuntimeException );
172     virtual uno::Reference< frame::XDispatchProvider > SAL_CALL getInplaceDispatchProvider() throw ( embed::WrongStateException, uno::RuntimeException );
173     virtual awt::Rectangle SAL_CALL getPlacement() throw ( embed::WrongStateException, uno::RuntimeException );
174     virtual awt::Rectangle SAL_CALL getClipRectangle() throw ( embed::WrongStateException, uno::RuntimeException );
175     virtual void SAL_CALL translateAccelerators( const uno::Sequence< awt::KeyEvent >& aKeys ) throw ( embed::WrongStateException, uno::RuntimeException );
176     virtual void SAL_CALL scrollObject( const awt::Size& aOffset ) throw ( embed::WrongStateException, uno::RuntimeException );
177     virtual void SAL_CALL changedPlacement( const awt::Rectangle& aPosRect ) throw ( embed::WrongStateException, uno::Exception, uno::RuntimeException );
178 
179     // XWindowSupplier
180     virtual uno::Reference< awt::XWindow > SAL_CALL getWindow() throw ( uno::RuntimeException );
181 };
182 
183 //--------------------------------------------------------------------
184 SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj )
185 : mpObj( pObj )
186 {
187 }
188 Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const
189 {
190     MapUnit aContainerMapUnit( MAP_100TH_MM );
191     uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
192     if ( xParentVis.is() )
193 	    aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
194     Rectangle aLogicRect( mpObj->GetLogicRect() );
195     // apply scaling to object area and convert to pixels
196     aLogicRect.SetSize( Size( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth,
197                     			Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) );
198     return aLogicRect;
199 }
200 //--------------------------------------------------------------------
201 void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException)
202 {
203 }
204 
205 //--------------------------------------------------------------------
206 void SdrLightEmbeddedClient_Impl::Release()
207 {
208 	{
209 		::vos::OGuard aGuard( Application::GetSolarMutex() );
210     	mpObj = NULL;
211 	}
212 
213     release();
214 }
215 
216 //--------------------------------------------------------------------
217 void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException)
218 {
219 	::vos::OGuard aGuard( Application::GetSolarMutex() );
220 
221     if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
222     {
223         mpObj->ObjectLoaded();
224         GetSdrGlobalData().GetOLEObjCache().InsertObj(mpObj);
225     }
226     else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
227     {
228         GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
229     }
230 }
231 
232 //--------------------------------------------------------------------
233 void SAL_CALL SdrLightEmbeddedClient_Impl::disposing( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
234 {
235 	::vos::OGuard aGuard( Application::GetSolarMutex() );
236 
237     GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
238 }
239 
240 //--------------------------------------------------------------------
241 void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
242 {
243 	// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
244 
245 	::vos::OGuard aGuard( Application::GetSolarMutex() );
246 
247 	// the code currently makes sence only in case there is no other client
248 	if ( mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName.equalsAscii("OnVisAreaChanged")
249 	  && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this ) )
250 	{
251 		try
252 		{
253             MapUnit aContainerMapUnit( MAP_100TH_MM );
254 		    uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
255 		    if ( xParentVis.is() )
256 			    aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
257 
258 		    MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) );
259 
260 		    Rectangle		   aVisArea;
261 		    awt::Size aSz;
262 		    try
263 		    {
264 			    aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() );
265 		    }
266 		    catch( embed::NoVisualAreaSizeException& )
267 		    {
268 			    OSL_ENSURE( sal_False, "No visual area size!\n" );
269 			    aSz.Width = 5000;
270 			    aSz.Height = 5000;
271 		    }
272 		    catch( uno::Exception& )
273 		    {
274 			    OSL_ENSURE( sal_False, "Unexpected exception!\n" );
275 			    aSz.Width = 5000;
276 			    aSz.Height = 5000;
277 		    }
278 
279 		    aVisArea.SetSize( Size( aSz.Width, aSz.Height ) );
280 		    aVisArea = OutputDevice::LogicToLogic( aVisArea, aObjMapUnit, aContainerMapUnit );
281 		    Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ),
282 							    static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) );
283             Rectangle aLogicRect( mpObj->GetLogicRect() );
284 
285 			// react to the change if the difference is bigger than one pixel
286 			Size aPixelDiff =
287 				Application::GetDefaultDevice()->LogicToPixel(
288 					Size( aLogicRect.GetWidth() - aScaledSize.Width(),
289 						  aLogicRect.GetHeight() - aScaledSize.Height() ),
290 					aContainerMapUnit );
291 			if( aPixelDiff.Width() || aPixelDiff.Height() )
292 			{
293 				mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
294 				mpObj->BroadcastObjectChange();
295 			}
296 			else
297 				mpObj->ActionChanged();
298 		}
299 		catch( uno::Exception& )
300 		{
301 			OSL_ENSURE( sal_False, "Unexpected exception!\n" );
302 		}
303 	}
304 }
305 
306 //--------------------------------------------------------------------
307 void SAL_CALL SdrLightEmbeddedClient_Impl::saveObject()
308 	throw ( embed::ObjectSaveVetoException,
309 			uno::Exception,
310 			uno::RuntimeException )
311 {
312 	// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
313 	uno::Reference< embed::XCommonEmbedPersist > xPersist;
314 	uno::Reference< util::XModifiable > xModifiable;
315 
316 	{
317 		::vos::OGuard aGuard( Application::GetSolarMutex() );
318 
319 		if ( !mpObj )
320 			throw embed::ObjectSaveVetoException();
321 
322 		// the common persistance is supported by objects and links
323 		xPersist = uno::Reference< embed::XCommonEmbedPersist >( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
324 		xModifiable = uno::Reference< util::XModifiable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
325 	}
326 
327 	xPersist->storeOwn();
328 
329 	if ( xModifiable.is() )
330 		xModifiable->setModified( sal_True );
331 }
332 
333 //--------------------------------------------------------------------
334 void SAL_CALL SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool /*bVisible*/ )
335 	throw ( embed::WrongStateException,
336 			uno::RuntimeException )
337 {
338 	// nothing to do currently
339 	// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
340     if ( mpObj )
341     {
342         Rectangle aLogicRect( mpObj->GetLogicRect() );
343         Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
344 
345         if( mpObj->IsChart() )
346         {
347             //charts never should be stretched see #i84323# for example
348             mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
349             mpObj->BroadcastObjectChange();
350         } // if( mpObj->IsChart() )
351     }
352 }
353 
354 //--------------------------------------------------------------------
355 uno::Reference< util::XCloseable > SAL_CALL SdrLightEmbeddedClient_Impl::getComponent()
356 	throw ( uno::RuntimeException )
357 {
358 	uno::Reference< util::XCloseable > xResult;
359 
360 	::vos::OGuard aGuard( Application::GetSolarMutex() );
361 	if ( mpObj )
362 		xResult = uno::Reference< util::XCloseable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
363 
364 	return xResult;
365 }
366 // XInplaceClient
367 //--------------------------------------------------------------------
368 sal_Bool SAL_CALL SdrLightEmbeddedClient_Impl::canInplaceActivate()
369 	throw ( uno::RuntimeException )
370 {
371     sal_Bool bRet = sal_False;
372     ::vos::OGuard aGuard( Application::GetSolarMutex() );
373     if ( mpObj )
374     {
375         uno::Reference< embed::XEmbeddedObject > xObject = mpObj->GetObjRef();
376         if ( !xObject.is() )
377 		    throw uno::RuntimeException();
378         // we don't want to switch directly from outplace to inplace mode
379         bRet = !( xObject->getCurrentState() == embed::EmbedStates::ACTIVE || mpObj->GetAspect() == embed::Aspects::MSOLE_ICON );
380     } // if ( mpObj )
381     return bRet;
382 }
383 
384 //--------------------------------------------------------------------
385 void SAL_CALL SdrLightEmbeddedClient_Impl::activatingInplace()
386 	throw ( embed::WrongStateException,
387 			uno::RuntimeException )
388 {
389 }
390 
391 //--------------------------------------------------------------------
392 void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI()
393 	throw ( embed::WrongStateException,
394 			uno::RuntimeException )
395 {
396     ::vos::OGuard aGuard( Application::GetSolarMutex() );
397 
398     uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
399     uno::Reference < frame::XFrame > xOwnFrame( xFrame,uno::UNO_QUERY);
400     uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
401     if ( xParentFrame.is() )
402         xParentFrame->setActiveFrame( xOwnFrame );
403 
404     OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
405     const sal_uIntPtr nCount = rObjCache.Count();
406     for(sal_Int32 i = nCount-1 ; i >= 0;--i)
407     {
408         SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i));
409         if ( pObj != mpObj )
410         {
411             // only deactivate ole objects which belongs to the same frame
412             if ( xFrame == lcl_getFrame_throw(pObj) )
413             {
414                 uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
415                 try
416                 {
417                     if ( xObject->getStatus( pObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
418                         xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
419                     else
420                     {
421                         // the links should not stay in running state for long time because of locking
422                         uno::Reference< embed::XLinkageSupport > xLink( xObject, uno::UNO_QUERY );
423                         if ( xLink.is() && xLink->isLink() )
424                             xObject->changeState( embed::EmbedStates::LOADED );
425                         else
426                             xObject->changeState( embed::EmbedStates::RUNNING );
427                     }
428                 }
429                 catch (com::sun::star::uno::Exception& )
430                 {}
431             }
432         }
433     } // for(sal_Int32 i = nCount-1 ; i >= 0;--i)
434 
435     //m_pClient->GetViewShell()->UIActivating( m_pClient );
436 }
437 
438 //--------------------------------------------------------------------
439 void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedInplace()
440 	throw ( embed::WrongStateException,
441 			uno::RuntimeException )
442 {
443 }
444 
445 //--------------------------------------------------------------------
446 void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedUI()
447 	throw ( embed::WrongStateException,
448 			uno::RuntimeException )
449 {
450     ::vos::OGuard aGuard( Application::GetSolarMutex() );
451     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager(getLayoutManager());
452     if ( xLayoutManager.is() )
453     {
454         const static rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
455 		if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
456         	xLayoutManager->createElement( aMenuBarURL );
457     }
458 }
459 
460 //--------------------------------------------------------------------
461 uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL SdrLightEmbeddedClient_Impl::getLayoutManager()
462 	throw ( embed::WrongStateException,
463 			uno::RuntimeException )
464 {
465     uno::Reference< ::com::sun::star::frame::XLayoutManager > xMan;
466     ::vos::OGuard aGuard( Application::GetSolarMutex() );
467     uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
468     try
469     {
470         xMan.set(xFrame->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") ),uno::UNO_QUERY);
471     }
472     catch ( uno::Exception& )
473     {
474         throw uno::RuntimeException();
475     }
476 
477     return xMan;
478 }
479 
480 //--------------------------------------------------------------------
481 uno::Reference< frame::XDispatchProvider > SAL_CALL SdrLightEmbeddedClient_Impl::getInplaceDispatchProvider()
482 	throw ( embed::WrongStateException,
483 			uno::RuntimeException )
484 {
485     ::vos::OGuard aGuard( Application::GetSolarMutex() );
486 	return uno::Reference < frame::XDispatchProvider >( lcl_getFrame_throw(mpObj), uno::UNO_QUERY_THROW );
487 }
488 
489 //--------------------------------------------------------------------
490 awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getPlacement()
491 	throw ( embed::WrongStateException,
492 			uno::RuntimeException )
493 {
494     ::vos::OGuard aGuard( Application::GetSolarMutex() );
495     if ( !mpObj )
496         throw uno::RuntimeException();
497 
498     Rectangle aLogicRect = impl_getScaledRect_nothrow();
499     MapUnit aContainerMapUnit( MAP_100TH_MM );
500     uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
501     if ( xParentVis.is() )
502 	    aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
503 
504     aLogicRect = Application::GetDefaultDevice()->LogicToPixel(aLogicRect,aContainerMapUnit);
505 	return AWTRectangle( aLogicRect );
506 }
507 
508 //--------------------------------------------------------------------
509 awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getClipRectangle()
510 	throw ( embed::WrongStateException,
511 			uno::RuntimeException )
512 {
513 	return getPlacement();
514 }
515 
516 //--------------------------------------------------------------------
517 void SAL_CALL SdrLightEmbeddedClient_Impl::translateAccelerators( const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
518 	throw ( embed::WrongStateException,
519 			uno::RuntimeException )
520 {
521 }
522 
523 //--------------------------------------------------------------------
524 void SAL_CALL SdrLightEmbeddedClient_Impl::scrollObject( const awt::Size& /*aOffset*/ )
525 	throw ( embed::WrongStateException,
526 			uno::RuntimeException )
527 {
528 }
529 
530 //--------------------------------------------------------------------
531 void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
532 	throw ( embed::WrongStateException,
533 			uno::Exception,
534 			uno::RuntimeException )
535 {
536     ::vos::OGuard aGuard( Application::GetSolarMutex() );
537     if ( !mpObj )
538         throw uno::RuntimeException();
539 
540 	uno::Reference< embed::XInplaceObject > xInplace( mpObj->GetObjRef(), uno::UNO_QUERY );
541     if ( !xInplace.is() )
542 		throw uno::RuntimeException();
543 
544     // check if the change is at least one pixel in size
545     awt::Rectangle aOldRect = getPlacement();
546     Rectangle aNewPixelRect = VCLRectangle( aPosRect );
547     Rectangle aOldPixelRect = VCLRectangle( aOldRect );
548     if ( aOldPixelRect == aNewPixelRect )
549         // nothing has changed
550         return;
551 
552     // new scaled object area
553     MapUnit aContainerMapUnit( MAP_100TH_MM );
554     uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
555     if ( xParentVis.is() )
556 	    aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
557 
558     Rectangle aNewLogicRect = Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect,aContainerMapUnit);
559     Rectangle aLogicRect = impl_getScaledRect_nothrow();
560 
561     if ( aNewLogicRect != aLogicRect )
562 	{
563 		// the calculation of the object area has not changed the object size
564 		// it should be done here then
565 		//SfxBooleanFlagGuard aGuard( m_bResizeNoScale, sal_True );
566 
567     	// new size of the object area without scaling
568     	Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth,
569                           Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight );
570 
571     	// now remove scaling from new placement and keep this a the new object area
572     	aNewLogicRect.SetSize( aNewObjSize );
573         // react to the change if the difference is bigger than one pixel
574 		Size aPixelDiff =
575 			Application::GetDefaultDevice()->LogicToPixel(
576 				Size( aLogicRect.GetWidth() - aNewObjSize.Width(),
577 					  aLogicRect.GetHeight() - aNewObjSize.Height() ),
578 				aContainerMapUnit );
579 		if( aPixelDiff.Width() || aPixelDiff.Height() )
580 		{
581 			mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aNewObjSize ) );
582 			mpObj->BroadcastObjectChange();
583 		}
584 		else
585 			mpObj->ActionChanged();
586 
587 		// let the window size be recalculated
588 		//SizeHasChanged(); // TODO: OJ
589 	}
590 }
591 // XWindowSupplier
592 //--------------------------------------------------------------------
593 uno::Reference< awt::XWindow > SAL_CALL SdrLightEmbeddedClient_Impl::getWindow()
594 	throw ( uno::RuntimeException )
595 {
596 	::vos::OGuard aGuard( Application::GetSolarMutex() );
597     uno::Reference< awt::XWindow > xCurrent = m_xWindow;
598     if ( !xCurrent.is() )
599     {
600         if ( !mpObj )
601             throw uno::RuntimeException();
602         uno::Reference< frame::XFrame> xFrame(lcl_getFrame_throw(mpObj),uno::UNO_QUERY_THROW);
603         xCurrent = xFrame->getComponentWindow();
604     } // if ( !xCurrent.is() )
605     return xCurrent;
606 }
607 void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >& _xWindow)
608 {
609     m_xWindow = _xWindow;
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////////////////////////
613 
614 class SdrEmbedObjectLink : public sfx2::SvBaseLink
615 {
616 	SdrOle2Obj*			pObj;
617 
618 public:
619 						SdrEmbedObjectLink(SdrOle2Obj* pObj);
620 	virtual				~SdrEmbedObjectLink();
621 
622 	virtual void		Closed();
623 	virtual void		DataChanged( const String& rMimeType,
624 								const ::com::sun::star::uno::Any & rValue );
625 
626 	sal_Bool			Connect() { return GetRealObject() != NULL; }
627 };
628 
629 // -----------------------------------------------------------------------------
630 
631 SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
632 	::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
633 	pObj(pObject)
634 {
635 	SetSynchron( sal_False );
636 }
637 
638 // -----------------------------------------------------------------------------
639 
640 SdrEmbedObjectLink::~SdrEmbedObjectLink()
641 {
642 }
643 
644 // -----------------------------------------------------------------------------
645 
646 void SdrEmbedObjectLink::DataChanged( const String& /*rMimeType*/,
647 								const ::com::sun::star::uno::Any & /*rValue*/ )
648 {
649 	if ( !pObj->UpdateLinkURL_Impl() )
650 	{
651 		// the link URL was not changed
652 		uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
653 		OSL_ENSURE( xObject.is(), "The object must exist always!\n" );
654 		if ( xObject.is() )
655 		{
656 			// let the object reload the link
657 			// TODO/LATER: reload call could be used for this case
658 
659 			try
660 			{
661 				sal_Int32 nState = xObject->getCurrentState();
662 				if ( nState != embed::EmbedStates::LOADED )
663 				{
664 					// in some cases the linked file probably is not locked so it could be changed
665 					xObject->changeState( embed::EmbedStates::LOADED );
666 					xObject->changeState( nState );
667 				}
668 			}
669 			catch ( uno::Exception& )
670 			{
671 			}
672 		}
673 	}
674 
675 	pObj->GetNewReplacement();
676 	pObj->SetChanged();
677 }
678 
679 // -----------------------------------------------------------------------------
680 
681 void SdrEmbedObjectLink::Closed()
682 {
683 	pObj->BreakFileLink_Impl();
684 	SvBaseLink::Closed();
685 }
686 
687 ////////////////////////////////////////////////////////////////////////////////////////////////////
688 
689 class SdrOle2ObjImpl
690 {
691 public:
692     // TODO/LATER: do we really need this pointer?
693 	GraphicObject*	pGraphicObject;
694 	String          aPersistName;       // name of object in persist
695     SdrLightEmbeddedClient_Impl* pLightClient; // must be registered as client only using AddOwnLightClient() call
696 
697 	// #107645#
698 	// New local var to avoid repeated loading if load of OLE2 fails
699 	sal_Bool		mbLoadingOLEObjectFailed;
700     sal_Bool        mbConnected;
701 
702 	SdrEmbedObjectLink*	mpObjectLink;
703 	String maLinkURL;
704 
705 	SdrOle2ObjImpl()
706 	: pGraphicObject( NULL )
707 	// #107645#
708 	// init to start situation, loading did not fail
709 	, mbLoadingOLEObjectFailed( sal_False )
710 	, mbConnected( sal_False )
711 	, mpObjectLink( NULL )
712 	{
713 	}
714 };
715 
716 ////////////////////////////////////////////////////////////////////////////////////////////////////
717 
718 // Predicate determining whether the given OLE is an internal math
719 // object
720 static bool ImplIsMathObj( const uno::Reference < embed::XEmbeddedObject >& rObjRef )
721 {
722     if ( !rObjRef.is() )
723         return false;
724 
725     SvGlobalName aClassName( rObjRef->getClassID() );
726     if( aClassName == SvGlobalName(SO3_SM_CLASSID_30) ||
727         aClassName == SvGlobalName(SO3_SM_CLASSID_40) ||
728         aClassName == SvGlobalName(SO3_SM_CLASSID_50) ||
729         aClassName == SvGlobalName(SO3_SM_CLASSID_60) ||
730         aClassName == SvGlobalName(SO3_SM_CLASSID) 		)
731     {
732         return true;
733     }
734     else
735     {
736         return false;
737     }
738 }
739 
740 //////////////////////////////////////////////////////////////////////////////
741 // BaseProperties section
742 
743 sdr::properties::BaseProperties* SdrOle2Obj::CreateObjectSpecificProperties()
744 {
745 	return new sdr::properties::OleProperties(*this);
746 }
747 
748 //////////////////////////////////////////////////////////////////////////////
749 // DrawContact section
750 
751 sdr::contact::ViewContact* SdrOle2Obj::CreateObjectSpecificViewContact()
752 {
753 	return new sdr::contact::ViewContactOfSdrOle2Obj(*this);
754 }
755 
756 // -----------------------------------------------------------------------------
757 
758 TYPEINIT1(SdrOle2Obj,SdrRectObj);
759 DBG_NAME(SdrOle2Obj)
760 SdrOle2Obj::SdrOle2Obj(FASTBOOL bFrame_) : m_bTypeAsked(false)
761 ,m_bChart(false)
762 {
763     DBG_CTOR( SdrOle2Obj,NULL);
764 	bInDestruction = sal_False;
765     mbSuppressSetVisAreaSize = false;
766 	Init();
767 	bFrame=bFrame_;
768 }
769 
770 // -----------------------------------------------------------------------------
771 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, FASTBOOL bFrame_)
772     : xObjRef( rNewObjRef )
773     , m_bTypeAsked(false)
774     , m_bChart(false)
775 {
776     DBG_CTOR( SdrOle2Obj,NULL);
777 	bInDestruction = sal_False;
778     mbSuppressSetVisAreaSize = false;
779 	Init();
780 
781 	bFrame=bFrame_;
782 
783     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
784         SetResizeProtect(sal_True);
785 
786     // #108759# For math objects, set closed state to transparent
787     if( ImplIsMathObj( xObjRef.GetObject() ) )
788         SetClosedObj( false );
789 }
790 
791 // -----------------------------------------------------------------------------
792 
793 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, FASTBOOL bFrame_)
794     : xObjRef( rNewObjRef )
795     , m_bTypeAsked(false)
796     , m_bChart(false)
797 {
798     DBG_CTOR( SdrOle2Obj,NULL);
799 	bInDestruction = sal_False;
800     mbSuppressSetVisAreaSize = false;
801 	Init();
802 
803 	mpImpl->aPersistName = rNewObjName;
804 	bFrame=bFrame_;
805 
806     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
807         SetResizeProtect(sal_True);
808 
809     // #108759# For math objects, set closed state to transparent
810     if( ImplIsMathObj( xObjRef.GetObject() ) )
811         SetClosedObj( false );
812 }
813 
814 // -----------------------------------------------------------------------------
815 
816 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef&  rNewObjRef, const XubString& rNewObjName, const Rectangle& rNewRect, FASTBOOL bFrame_)
817     : SdrRectObj(rNewRect)
818     , xObjRef( rNewObjRef )
819     , m_bTypeAsked(false)
820     , m_bChart(false)
821 {
822     DBG_CTOR( SdrOle2Obj,NULL);
823 	bInDestruction = sal_False;
824     mbSuppressSetVisAreaSize = false;
825 	Init();
826 
827 	mpImpl->aPersistName = rNewObjName;
828 	bFrame=bFrame_;
829 
830     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
831         SetResizeProtect(sal_True);
832 
833     // #108759# For math objects, set closed state to transparent
834     if( ImplIsMathObj( xObjRef.GetObject() ) )
835         SetClosedObj( false );
836 }
837 
838 // -----------------------------------------------------------------------------
839 
840 void SdrOle2Obj::Init()
841 {
842 	mpImpl = new SdrOle2ObjImpl;
843 	pModifyListener = NULL;
844 	pGraphic=NULL;
845 	mpImpl->pGraphicObject=NULL;
846     mpImpl->pLightClient = 0;
847 
848     xObjRef.Lock( sal_True );
849 }
850 
851 // -----------------------------------------------------------------------------
852 
853 SdrOle2Obj::~SdrOle2Obj()
854 {
855     DBG_DTOR( SdrOle2Obj,NULL);
856 	bInDestruction = sal_True;
857 
858     if ( mpImpl->mbConnected )
859         Disconnect();
860 
861     if( pGraphic!=NULL )
862 		delete pGraphic;
863 
864 	if(mpImpl->pGraphicObject!=NULL)
865 		delete mpImpl->pGraphicObject;
866 
867 	if(pModifyListener)
868 	{
869 		pModifyListener->invalidate();
870 		pModifyListener->release();
871 	}
872 
873 	DisconnectFileLink_Impl();
874 
875     if ( mpImpl->pLightClient )
876 	{
877         mpImpl->pLightClient->Release();
878 		mpImpl->pLightClient = NULL;
879 	}
880 
881 	delete mpImpl;
882 }
883 
884 // -----------------------------------------------------------------------------
885 void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
886 {
887 	xObjRef.SetViewAspect( nAspect );
888 }
889 
890 // -----------------------------------------------------------------------------
891 bool SdrOle2Obj::isInplaceActive() const
892 {
893     return xObjRef.is() && embed::EmbedStates::INPLACE_ACTIVE == xObjRef->getCurrentState();
894 }
895 
896 // -----------------------------------------------------------------------------
897 bool SdrOle2Obj::isUiActive() const
898 {
899     return xObjRef.is() && embed::EmbedStates::UI_ACTIVE == xObjRef->getCurrentState();
900 }
901 
902 // -----------------------------------------------------------------------------
903 
904 void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf)
905 {
906 	if ( pGraphic )
907 	{
908 		delete pGraphic;
909 		pGraphic = NULL;
910 		delete mpImpl->pGraphicObject;
911 		mpImpl->pGraphicObject = NULL;
912 	}
913 
914 	if (pGrf!=NULL)
915 	{
916 		pGraphic = new Graphic(*pGrf);
917 		mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
918 	}
919 
920 	SetChanged();
921 	BroadcastObjectChange();
922 
923 	//if ( ppObjRef->Is() && pGrf )
924 	//	BroadcastObjectChange();
925 }
926 
927 void SdrOle2Obj::SetGraphic(const Graphic* pGrf)
928 {
929     // only for setting a preview graphic
930     SetGraphic_Impl( pGrf );
931 }
932 
933 // -----------------------------------------------------------------------------
934 
935 FASTBOOL SdrOle2Obj::IsEmpty() const
936 {
937     return !(xObjRef.is());
938 }
939 
940 // -----------------------------------------------------------------------------
941 
942 void SdrOle2Obj::Connect()
943 {
944 	if( IsEmptyPresObj() )
945 		return;
946 
947     if( mpImpl->mbConnected )
948     {
949         // mba: currently there are situations where it seems to be unavoidable to have multiple connects
950         // changing this would need a larger code rewrite, so for now I remove the assertion
951         // DBG_ERROR("Connect() called on connected object!");
952 		return;
953     }
954 
955     Connect_Impl();
956     AddListeners_Impl();
957 }
958 
959 // -----------------------------------------------------------------------------
960 
961 sal_Bool SdrOle2Obj::UpdateLinkURL_Impl()
962 {
963 	sal_Bool bResult = sal_False;
964 
965 	if ( mpImpl->mpObjectLink )
966 	{
967 		sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
968 		if ( pLinkManager )
969 		{
970 			String aNewLinkURL;
971 			pLinkManager->GetDisplayNames( mpImpl->mpObjectLink, 0, &aNewLinkURL, 0, 0 );
972 			if ( !aNewLinkURL.EqualsIgnoreCaseAscii( mpImpl->maLinkURL ) )
973 			{
974     			const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
975 				uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObjRef.GetObject(), uno::UNO_QUERY );
976 				OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
977     			if ( xPersObj.is() )
978 				{
979 					try
980 					{
981 						sal_Int32 nCurState = xObjRef->getCurrentState();
982 						if ( nCurState != embed::EmbedStates::LOADED )
983 							xObjRef->changeState( embed::EmbedStates::LOADED );
984 
985 						// TODO/LATER: there should be possible to get current mediadescriptor settings from the object
986 						uno::Sequence< beans::PropertyValue > aArgs( 1 );
987 						aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
988 						aArgs[0].Value <<= ::rtl::OUString( aNewLinkURL );
989 						xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
990 
991 						mpImpl->maLinkURL = aNewLinkURL;
992 						bResult = sal_True;
993 
994 						if ( nCurState != embed::EmbedStates::LOADED )
995 							xObjRef->changeState( nCurState );
996 					}
997 					catch( ::com::sun::star::uno::Exception& e )
998 					{
999 						(void)e;
1000 						DBG_ERROR(
1001 							(OString("SdrOle2Obj::UpdateLinkURL_Impl(), "
1002 									"exception caught: ") +
1003 							rtl::OUStringToOString(
1004 								comphelper::anyToString( cppu::getCaughtException() ),
1005 								RTL_TEXTENCODING_UTF8 )).getStr() );
1006 					}
1007 				}
1008 
1009 				if ( !bResult )
1010 				{
1011 					// TODO/LATER: return the old name to the link manager, is it possible?
1012 				}
1013 			}
1014 		}
1015 	}
1016 
1017 	return bResult;
1018 }
1019 
1020 // -----------------------------------------------------------------------------
1021 
1022 void SdrOle2Obj::BreakFileLink_Impl()
1023 {
1024     uno::Reference<document::XStorageBasedDocument> xDoc;
1025 	if ( pModel )
1026 		xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
1027 
1028 	if ( xDoc.is() )
1029 	{
1030 		uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage();
1031 		if ( xStorage.is() )
1032 		{
1033 			try
1034 			{
1035 				uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY_THROW );
1036 				xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
1037 				DisconnectFileLink_Impl();
1038 				mpImpl->maLinkURL = String();
1039 			}
1040 			catch( ::com::sun::star::uno::Exception& e )
1041 			{
1042 				(void)e;
1043 				DBG_ERROR(
1044 					(OString("SdrOle2Obj::BreakFileLink_Impl(), "
1045 							"exception caught: ") +
1046 					rtl::OUStringToOString(
1047 						comphelper::anyToString( cppu::getCaughtException() ),
1048 						RTL_TEXTENCODING_UTF8 )).getStr() );
1049 			}
1050 		}
1051 	}
1052 }
1053 
1054 // -----------------------------------------------------------------------------
1055 
1056 void SdrOle2Obj::DisconnectFileLink_Impl()
1057 {
1058 	sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
1059 	if ( pLinkManager && mpImpl->mpObjectLink )
1060 	{
1061 		pLinkManager->Remove( mpImpl->mpObjectLink );
1062 		mpImpl->mpObjectLink = NULL;
1063 	}
1064 }
1065 
1066 // -----------------------------------------------------------------------------
1067 
1068 void SdrOle2Obj::CheckFileLink_Impl()
1069 {
1070 	if ( pModel && xObjRef.GetObject().is() && !mpImpl->mpObjectLink )
1071 	{
1072 		try
1073 		{
1074 			uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY );
1075 			if ( xLinkSupport.is() && xLinkSupport->isLink() )
1076 			{
1077 				String aLinkURL = xLinkSupport->getLinkURL();
1078 				if ( aLinkURL.Len() )
1079 				{
1080 					// this is a file link so the model link manager should handle it
1081 					sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
1082 					if ( pLinkManager )
1083 					{
1084 						mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
1085 						mpImpl->maLinkURL = aLinkURL;
1086 						pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
1087 						mpImpl->mpObjectLink->Connect();
1088 					}
1089 				}
1090 			}
1091 		}
1092 		catch( ::com::sun::star::uno::Exception& e )
1093 		{
1094 			(void)e;
1095 			DBG_ERROR(
1096 				(OString("SdrOle2Obj::CheckFileLink_Impl(), "
1097 						"exception caught: ") +
1098 				rtl::OUStringToOString(
1099 					comphelper::anyToString( cppu::getCaughtException() ),
1100 					RTL_TEXTENCODING_UTF8 )).getStr() );
1101 		}
1102 	}
1103 }
1104 
1105 // -----------------------------------------------------------------------------
1106 
1107 void SdrOle2Obj::Reconnect_Impl()
1108 {
1109     DBG_ASSERT( mpImpl->mbConnected, "Assigned unconnected object?!" );
1110     Connect_Impl();
1111 }
1112 
1113 void SdrOle2Obj::Connect_Impl()
1114 {
1115     if( pModel && mpImpl->aPersistName.Len() )
1116 	{
1117 		try
1118 		{
1119 			::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
1120 			if ( pPers )
1121 			{
1122 				comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
1123 				if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
1124 				  || ( xObjRef.is() && !rContainer.HasEmbeddedObject( xObjRef.GetObject() ) ) )
1125 				{
1126 					// object not known to container document
1127 					// No object -> disaster!
1128 					DBG_ASSERT( xObjRef.is(), "No object in connect!");
1129 					if ( xObjRef.is() )
1130 					{
1131 						// object came from the outside, now add it to the container
1132 						::rtl::OUString aTmp;
1133 						rContainer.InsertEmbeddedObject( xObjRef.GetObject(), aTmp );
1134                         mpImpl->aPersistName = aTmp;
1135 					}
1136 				}
1137 				else if ( !xObjRef.is() )
1138                 {
1139 					xObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), xObjRef.GetViewAspect() );
1140                     m_bTypeAsked = false;
1141                 }
1142 
1143 				if ( xObjRef.GetObject().is() )
1144 				{
1145 					xObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
1146 					mpImpl->mbConnected = true;
1147 					xObjRef.Lock( sal_True );
1148 				}
1149 			}
1150 
1151 			if ( xObjRef.is() )
1152 			{
1153 				if ( !mpImpl->pLightClient )
1154 				{
1155 					mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
1156 					mpImpl->pLightClient->acquire();
1157 				}
1158 
1159 				xObjRef->addStateChangeListener( mpImpl->pLightClient );
1160 				xObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
1161 
1162 				if ( xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
1163 					GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
1164 
1165 				CheckFileLink_Impl();
1166 
1167 				uno::Reference< container::XChild > xChild( xObjRef.GetObject(), uno::UNO_QUERY );
1168 				if( xChild.is() )
1169                 {
1170                     uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
1171                     if( xParent.is())
1172                         xChild->setParent( pModel->getUnoModel() );
1173                 }
1174 
1175 			}
1176 		}
1177 		catch( ::com::sun::star::uno::Exception& e )
1178 		{
1179 			(void)e;
1180 			DBG_ERROR(
1181 				(OString("SdrOle2Obj::Connect_Impl(), "
1182 						"exception caught: ") +
1183 				rtl::OUStringToOString(
1184 					comphelper::anyToString( cppu::getCaughtException() ),
1185 					RTL_TEXTENCODING_UTF8 )).getStr() );
1186 		}
1187 	}
1188 
1189     //TODO/LATER: wait for definition of MiscStatus RESIZEONPRINTERCHANGE
1190     //if ( xObjRef.is() && (*ppObjRef)->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
1191 	{
1192         //TODO/LATER: needs a new handling for OnPrinterChanged
1193         /*
1194 		if (pModel && pModel->GetRefDevice() &&
1195 			pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
1196 		{
1197 			// Kein RefDevice oder RefDevice kein Printer
1198 			sal_Bool bModified = (*ppObjRef)->IsModified();
1199 			Printer* pPrinter = (Printer*) pModel->GetRefDevice();
1200 			(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
1201 			(*ppObjRef)->SetModified( bModified );
1202         }*/
1203 	}
1204 }
1205 
1206 void SdrOle2Obj::ObjectLoaded()
1207 {
1208     AddListeners_Impl();
1209 }
1210 
1211 void SdrOle2Obj::AddListeners_Impl()
1212 {
1213     if( xObjRef.is() && xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
1214 	{
1215 		// register modify listener
1216         if( !pModifyListener )
1217 		{
1218 			((SdrOle2Obj*)this)->pModifyListener = new SvxUnoShapeModifyListener( (SdrOle2Obj*)this );
1219 			pModifyListener->acquire();
1220 		}
1221 
1222 		uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1223 		if( xBC.is() && pModifyListener )
1224 		{
1225 			uno::Reference< util::XModifyListener > xListener( pModifyListener );
1226 			xBC->addModifyListener( xListener );
1227 		}
1228 	}
1229 }
1230 
1231 // -----------------------------------------------------------------------------
1232 
1233 void SdrOle2Obj::Disconnect()
1234 {
1235 	if( IsEmptyPresObj() )
1236 		return;
1237 
1238 	if( !mpImpl->mbConnected )
1239     {
1240         DBG_ERROR("Disconnect() called on disconnected object!");
1241 		return;
1242     }
1243 
1244     RemoveListeners_Impl();
1245     Disconnect_Impl();
1246 }
1247 
1248 void SdrOle2Obj::RemoveListeners_Impl()
1249 {
1250     if( xObjRef.is() && mpImpl->aPersistName.Len() )
1251 	{
1252 		try
1253 		{
1254 			sal_Int32 nState = xObjRef->getCurrentState();
1255 			if ( nState != embed::EmbedStates::LOADED )
1256 			{
1257 				uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1258 				if( xBC.is() && pModifyListener )
1259 				{
1260 					uno::Reference< util::XModifyListener > xListener( pModifyListener );
1261 					xBC->removeModifyListener( xListener );
1262 				}
1263 			}
1264 		}
1265 		catch( ::com::sun::star::uno::Exception& e )
1266 		{
1267 			(void)e;
1268 			DBG_ERROR(
1269 				(OString("SdrOle2Obj::RemoveListeners_Impl(), "
1270 						"exception caught: ") +
1271 				rtl::OUStringToOString(
1272 					comphelper::anyToString( cppu::getCaughtException() ),
1273 					RTL_TEXTENCODING_UTF8 )).getStr() );
1274 		}
1275 	}
1276 }
1277 
1278 void SdrOle2Obj::Disconnect_Impl()
1279 {
1280 	try
1281 	{
1282 		if ( pModel && mpImpl->aPersistName.Len() )
1283 		{
1284 			if( pModel->IsInDestruction() )
1285 			{
1286 				// TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
1287 				// remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
1288 				// There is no real need to do the following removing of the object from the container
1289 				// in case the model has correct persistance, but in case of problems such a removing
1290 				// would make the behaviour of the office more stable
1291 
1292 				comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
1293 				if ( pContainer )
1294 				{
1295 					pContainer->CloseEmbeddedObject( xObjRef.GetObject() );
1296 					xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
1297 				}
1298 
1299 				// happens later than the destruction of the model, so we can't assert that).
1300 				//DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
1301 				//TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
1302 				/*
1303 				uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
1304 				if ( xClose.is() )
1305 				{
1306 					try
1307 					{
1308 						xClose->close( sal_True );
1309 					}
1310 					catch ( util::CloseVetoException& )
1311 					{
1312 						// there's still someone who needs the object!
1313 					}
1314 				}
1315 
1316 				xObjRef = NULL;*/
1317 			}
1318 			else if ( xObjRef.is() )
1319 			{
1320 				if ( pModel->getUnoModel().is() )
1321 				{
1322 					// remove object, but don't close it (that's up to someone else)
1323 					comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
1324 					if ( pContainer )
1325 					{
1326 						pContainer->RemoveEmbeddedObject( xObjRef.GetObject(), sal_False);
1327 
1328 						// TODO/LATER: mpImpl->aPersistName contains outdated information, to have it uptodate
1329 						// it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
1330 						// since no container is adjusted, actually the empty string could be provided as a name here
1331 						xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
1332 					}
1333 
1334 					DisconnectFileLink_Impl();
1335 				}
1336 			}
1337 		}
1338 
1339 		if ( xObjRef.is() && mpImpl->pLightClient )
1340 		{
1341 			xObjRef->removeStateChangeListener ( mpImpl->pLightClient );
1342 			xObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
1343 			xObjRef->setClientSite( NULL );
1344 
1345 			GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
1346 		}
1347 	}
1348 	catch( ::com::sun::star::uno::Exception& e )
1349 	{
1350 		(void)e;
1351 		DBG_ERROR(
1352 			(OString("SdrOle2Obj::Disconnect_Impl(), "
1353 					"exception caught: ") +
1354 			rtl::OUStringToOString(
1355 				comphelper::anyToString( cppu::getCaughtException() ),
1356 				RTL_TEXTENCODING_UTF8 )).getStr() );
1357 	}
1358 
1359 	mpImpl->mbConnected = false;
1360 }
1361 
1362 // -----------------------------------------------------------------------------
1363 
1364 SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText, bool bUseHCGraphic) const
1365 {
1366     Graphic* pOLEGraphic = GetGraphic();
1367 
1368     if(bUseHCGraphic && Application::GetSettings().GetStyleSettings().GetHighContrastMode())
1369     {
1370         pOLEGraphic = getEmbeddedObjectRef().GetHCGraphic();
1371     }
1372 
1373     if(pOLEGraphic)
1374     {
1375         // #i118485# allow creating a SdrGrafObj representation
1376         SdrGrafObj* pClone = new SdrGrafObj(*pOLEGraphic);
1377         pClone->SetModel(GetModel());
1378 
1379         // copy transformation
1380         basegfx::B2DHomMatrix aMatrix;
1381         basegfx::B2DPolyPolygon aPolyPolygon;
1382 
1383         TRGetBaseGeometry(aMatrix, aPolyPolygon);
1384         pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon);
1385 
1386         // copy all attributes to support graphic styles for OLEs
1387         pClone->SetStyleSheet(GetStyleSheet(), false);
1388         pClone->SetMergedItemSet(GetMergedItemSet());
1389 
1390         if(bAddText)
1391         {
1392             // #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
1393             OutlinerParaObject* pOPO = GetOutlinerParaObject();
1394 
1395             if(pOPO && GetModel())
1396             {
1397                 pClone->NbcSetOutlinerParaObject(new OutlinerParaObject(*pOPO));
1398             }
1399         }
1400 
1401         return pClone;
1402     }
1403     else
1404     {
1405         // #i100710# pOLEGraphic may be zero (no visualisation available),
1406         // so we need to use the OLE replacement graphic
1407         SdrRectObj* pClone = new SdrRectObj(GetSnapRect());
1408         pClone->SetModel(GetModel());
1409 
1410         // gray outline
1411         pClone->SetMergedItem(XLineStyleItem(XLINE_SOLID));
1412         const svtools::ColorConfig aColorConfig;
1413         const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
1414         pClone->SetMergedItem(XLineColorItem(String(), aColor.nColor));
1415 
1416         // bitmap fill
1417         pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
1418         pClone->SetMergedItem(XFillBitmapItem(String(), GetEmtyOLEReplacementBitmap()));
1419         pClone->SetMergedItem(XFillBmpTileItem(false));
1420         pClone->SetMergedItem(XFillBmpStretchItem(false));
1421 
1422         return pClone;
1423     }
1424 }
1425 
1426 SdrObject* SdrOle2Obj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
1427 {
1428     // #i118485# missing converter added
1429     if(GetModel())
1430     {
1431         SdrObject* pRetval = createSdrGrafObjReplacement(true, false);
1432 
1433         if(pRetval)
1434         {
1435             SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
1436             SdrObject::Free(pRetval);
1437 
1438             return pRetval2;
1439         }
1440     }
1441 
1442     return 0;
1443 }
1444 
1445 // -----------------------------------------------------------------------------
1446 
1447 void SdrOle2Obj::SetModel(SdrModel* pNewModel)
1448 {
1449     ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : 0;
1450     ::comphelper::IEmbeddedHelper* pSrcPers  = pModel ? pModel->GetPersist() : 0;
1451 
1452     if ( pNewModel == pModel )
1453     {
1454         // don't know if this is necessary or if it will ever happen, but who know?!
1455         SdrRectObj::SetModel( pNewModel );
1456         return;
1457     }
1458 
1459     // assignment to model has changed
1460     DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
1461 
1462 	DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
1463 	DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
1464 
1465 	// this is a bug if the target model has no persistence
1466 	// no error handling is possible so just do nothing in this method
1467 	if ( !pDestPers )
1468 		return;
1469 
1470     RemoveListeners_Impl();
1471 
1472     if( pDestPers && pSrcPers && !IsEmptyPresObj() )
1473     {
1474 		try
1475 		{
1476 			// move the objects' storage; ObjectRef remains the same, but PersistName may change
1477 			::rtl::OUString aTmp;
1478 			comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
1479 			uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
1480 			DBG_ASSERT( !xObjRef.is() || xObjRef.GetObject() == xObj, "Wrong object identity!" );
1481 			if ( xObj.is() )
1482 			{
1483 				pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
1484 				mpImpl->aPersistName = aTmp;
1485 				xObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
1486 			}
1487 	        DBG_ASSERT( aTmp.getLength(), "Copying embedded object failed!" );
1488 		}
1489 		catch( ::com::sun::star::uno::Exception& e )
1490 		{
1491 			(void)e;
1492 			DBG_ERROR(
1493 				(OString("SdrOle2Obj::SetModel(), "
1494 						"exception caught: ") +
1495 				rtl::OUStringToOString(
1496 					comphelper::anyToString( cppu::getCaughtException() ),
1497 					RTL_TEXTENCODING_UTF8 )).getStr() );
1498 		}
1499     }
1500 
1501 	SdrRectObj::SetModel( pNewModel );
1502 
1503     // #i43086#
1504     // #i85304 redo the change for charts for the above bugfix, as #i43086# does not ocur anymore
1505     //so maybe the ImpSetVisAreaSize call can be removed here completely
1506     //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
1507     if( pModel && !pModel->isLocked() && !IsChart() )
1508         ImpSetVisAreaSize();
1509 
1510     if( pDestPers && !IsEmptyPresObj() )
1511     {
1512         if ( !pSrcPers || IsEmptyPresObj() )
1513             // object wasn't connected, now it should
1514             Connect_Impl();
1515         else
1516             Reconnect_Impl();
1517     }
1518 
1519     AddListeners_Impl();
1520 }
1521 
1522 // -----------------------------------------------------------------------------
1523 
1524 void SdrOle2Obj::SetPage(SdrPage* pNewPage)
1525 {
1526 	FASTBOOL bRemove=pNewPage==NULL && pPage!=NULL;
1527 	FASTBOOL bInsert=pNewPage!=NULL && pPage==NULL;
1528 
1529     if (bRemove && mpImpl->mbConnected )
1530         Disconnect();
1531 
1532 	SdrRectObj::SetPage(pNewPage);
1533 
1534     if (bInsert && !mpImpl->mbConnected )
1535         Connect();
1536 }
1537 
1538 // -----------------------------------------------------------------------------
1539 
1540 void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& rNewObjRef )
1541 {
1542     DBG_ASSERT( !rNewObjRef.is() || !xObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
1543     if( rNewObjRef == xObjRef.GetObject() )
1544 		return;
1545 
1546     // MBA: the caller of the method is responsible to control the old object, it will not be closed here
1547     // Otherwise WW8 import crashes because it tranfers control to OLENode by this method
1548     if ( xObjRef.GetObject().is() )
1549         xObjRef.Lock( sal_False );
1550 
1551     // MBA: avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
1552     // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
1553     xObjRef.Clear();
1554 
1555     if ( mpImpl->mbConnected )
1556         Disconnect();
1557 
1558     xObjRef.Assign( rNewObjRef, GetAspect() );
1559     m_bTypeAsked = false;
1560 
1561     if ( xObjRef.is() )
1562     {
1563         DELETEZ( pGraphic );
1564 
1565         if ( (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
1566             SetResizeProtect(sal_True);
1567 
1568         // #108759# For math objects, set closed state to transparent
1569         if( ImplIsMathObj( rNewObjRef ) )
1570             SetClosedObj( false );
1571 
1572         Connect();
1573     }
1574 
1575 	SetChanged();
1576 	BroadcastObjectChange();
1577 }
1578 
1579 // -----------------------------------------------------------------------------
1580 
1581 void SdrOle2Obj::SetClosedObj( bool bIsClosed )
1582 {
1583     // TODO/LATER: do we still need this hack?
1584     // #108759# Allow changes to the closed state of OLE objects
1585     bClosedObj = bIsClosed;
1586 }
1587 
1588 // -----------------------------------------------------------------------------
1589 
1590 SdrObject* SdrOle2Obj::getFullDragClone() const
1591 {
1592     // special handling for OLE. The default handling works, but is too
1593     // slow when the whole OLE needs to be cloned. Get the Metafile and
1594     // create a graphic object with it
1595 
1596     // #i118485# use central replacement generator
1597     return createSdrGrafObjReplacement(false, true);
1598 }
1599 
1600 // -----------------------------------------------------------------------------
1601 
1602 void SdrOle2Obj::SetPersistName( const String& rPersistName )
1603 {
1604     DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!");
1605 
1606     mpImpl->aPersistName = rPersistName;
1607 	mpImpl->mbLoadingOLEObjectFailed = false;
1608 
1609 	Connect();
1610     SetChanged();
1611 }
1612 
1613 void SdrOle2Obj::AbandonObject()
1614 {
1615     mpImpl->aPersistName.Erase();
1616 	mpImpl->mbLoadingOLEObjectFailed = false;
1617     SetObjRef(0);
1618 }
1619 
1620 // -----------------------------------------------------------------------------
1621 
1622 String SdrOle2Obj::GetPersistName() const
1623 {
1624     return mpImpl->aPersistName;
1625 }
1626 
1627 // -----------------------------------------------------------------------------
1628 
1629 void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
1630 {
1631     // #i118485# Allowing much more attributes for OLEs
1632 	rInfo.bRotateFreeAllowed = true;
1633 	rInfo.bRotate90Allowed = true;
1634 	rInfo.bMirrorFreeAllowed = true;
1635 	rInfo.bMirror45Allowed = true;
1636 	rInfo.bMirror90Allowed = true;
1637 	rInfo.bTransparenceAllowed = true;
1638 	rInfo.bGradientAllowed = true;
1639 	rInfo.bShearAllowed = true;
1640 	rInfo.bEdgeRadiusAllowed = false;
1641 	rInfo.bNoOrthoDesired = false;
1642 	rInfo.bCanConvToPath = true;
1643 	rInfo.bCanConvToPoly = true;
1644 	rInfo.bCanConvToPathLineToArea = false;
1645 	rInfo.bCanConvToPolyLineToArea = false;
1646 	rInfo.bCanConvToContour = true;
1647 }
1648 
1649 // -----------------------------------------------------------------------------
1650 
1651 sal_uInt16 SdrOle2Obj::GetObjIdentifier() const
1652 {
1653 	return bFrame ? sal_uInt16(OBJ_FRAME) : sal_uInt16(OBJ_OLE2);
1654 }
1655 
1656 // -----------------------------------------------------------------------------
1657 
1658 void SdrOle2Obj::TakeObjNameSingul(XubString& rName) const
1659 {
1660 	rName = ImpGetResStr(bFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2);
1661 
1662 	const String aName(GetName());
1663 
1664 	if( aName.Len() )
1665 	{
1666 		rName.AppendAscii(" '");
1667 		rName += aName;
1668 		rName += sal_Unicode('\'');
1669 	}
1670 }
1671 
1672 // -----------------------------------------------------------------------------
1673 
1674 void SdrOle2Obj::TakeObjNamePlural(XubString& rName) const
1675 {
1676 	rName=ImpGetResStr(bFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
1677 }
1678 
1679 // -----------------------------------------------------------------------------
1680 
1681 void SdrOle2Obj::operator=(const SdrObject& rObj)
1682 {
1683     //TODO/LATER: who takes over control of my old object?!
1684     if( &rObj != this )
1685 	{
1686 		// #116235#
1687 		// ImpAssign( rObj );
1688         const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
1689 
1690         uno::Reference < util::XCloseable > xClose( xObjRef.GetObject(), uno::UNO_QUERY );
1691 
1692         if( pModel && mpImpl->mbConnected )
1693             Disconnect();
1694 
1695         SdrRectObj::operator=( rObj );
1696 
1697         // #108867# Manually copying bClosedObj attribute
1698         SetClosedObj( rObj.IsClosedObj() );
1699 
1700         mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
1701         aProgName = rOle2Obj.aProgName;
1702         bFrame = rOle2Obj.bFrame;
1703 
1704         if( rOle2Obj.pGraphic )
1705         {
1706             if( pGraphic )
1707             {
1708                 delete pGraphic;
1709                 delete mpImpl->pGraphicObject;
1710             }
1711 
1712             pGraphic = new Graphic( *rOle2Obj.pGraphic );
1713             mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
1714         }
1715 
1716         if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
1717         {
1718             ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
1719             ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
1720             if( pDestPers && pSrcPers )
1721             {
1722     			DBG_ASSERT( !xObjRef.is(), "Object already existing!" );
1723     			comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
1724     			uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
1725     			if ( xObj.is() )
1726     			{
1727         			::rtl::OUString aTmp;
1728         			xObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( rContainer, xObj, aTmp ), rOle2Obj.GetAspect() );
1729                     m_bTypeAsked = false;
1730         			mpImpl->aPersistName = aTmp;
1731 					CheckFileLink_Impl();
1732     			}
1733 
1734                 Connect();
1735 
1736                 /* only needed for MSOLE-Objects, now handled inside implementation of Object
1737 				if ( xObjRef.is() && rOle2Obj.xObjRef.is() && rOle2Obj.GetAspect() != embed::Aspects::MSOLE_ICON )
1738 				{
1739 					try
1740 					{
1741 						awt::Size aVisSize = rOle2Obj.xObjRef->getVisualAreaSize( rOle2Obj.GetAspect() );
1742 						if( rOle2Obj.xObjRef->getMapUnit( rOle2Obj.GetAspect() ) == xObjRef->getMapUnit( GetAspect() ) )
1743 						xObjRef->setVisualAreaSize( GetAspect(), aVisSize );
1744 					}
1745 					catch ( embed::WrongStateException& )
1746 					{
1747 						// setting of VisArea not necessary for objects that don't cache it in loaded state
1748 					}
1749 					catch( embed::NoVisualAreaSizeException& )
1750 					{
1751 						// objects my not have visual areas
1752 					}
1753 					catch( uno::Exception& e )
1754 					{
1755 						(void)e;
1756 						DBG_ERROR( "SdrOle2Obj::operator=(), unexcpected exception caught!" );
1757 					}
1758                 }                                                                            */
1759             }
1760         }
1761     }
1762 }
1763 
1764 // -----------------------------------------------------------------------------
1765 
1766 void SdrOle2Obj::ImpSetVisAreaSize()
1767 {
1768     // #i118524# do not again set VisAreaSize when the call comes from OLE client (e.g. ObjectAreaChanged)
1769     if(mbSuppressSetVisAreaSize)
1770         return;
1771 
1772 	// currently there is no need to recalculate scaling for iconified objects
1773 	// TODO/LATER: it might be needed in future when it is possible to change the icon
1774 	if ( GetAspect() == embed::Aspects::MSOLE_ICON )
1775 		return;
1776 
1777     // the object area of an embedded object was changed, e.g. by user interaction an a selected object
1778     GetObjRef();
1779     if ( xObjRef.is() )
1780 	{
1781         OSL_ASSERT( pModel );
1782         sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
1783 
1784 		// the client is required to get access to scaling
1785 		SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() );
1786 		sal_Bool bHasOwnClient =
1787 						( mpImpl->pLightClient
1788 						&& xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
1789 
1790 		if ( pClient || bHasOwnClient )
1791 		{
1792             // TODO/LATER: IMHO we need to do similar things when object is UIActive or OutplaceActive?! (MBA)
1793             if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1794                     svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ))
1795                     || xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
1796                     )
1797 			{
1798 				Fraction aScaleWidth;
1799 				Fraction aScaleHeight;
1800 				if ( pClient )
1801 				{
1802 					aScaleWidth = pClient->GetScaleWidth();
1803 					aScaleHeight = pClient->GetScaleHeight();
1804 				}
1805 				else
1806 				{
1807 					aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
1808 					aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
1809 				}
1810 
1811                 // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
1812                 // or object is inplace active and so has a window that must be resized also
1813                 // In these cases the change in the object area size will be reflected in a change of the
1814                 // objects' visual area. The scaling will not change, but it might exist already and must
1815                 // be used in calculations
1816 				MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1817 				Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ),
1818 								(long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) );
1819 
1820 				aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit);
1821 				awt::Size aSz;
1822 				aSz.Width = aVisSize.Width();
1823 				aSz.Height = aVisSize.Height();
1824 				xObjRef->setVisualAreaSize( GetAspect(), aSz );
1825 
1826 				try
1827 				{
1828 					aSz = xObjRef->getVisualAreaSize( GetAspect() );
1829 				}
1830 				catch( embed::NoVisualAreaSizeException& )
1831 				{}
1832 
1833 				Rectangle aAcceptedVisArea;
1834 				aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ),
1835 												(long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) );
1836 				if (aVisSize != aAcceptedVisArea.GetSize())
1837 				{
1838                     // server changed VisArea to its liking and the VisArea is different than the suggested one
1839                     // store the new value as given by the object
1840 					MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1841 					aRect.SetSize(OutputDevice::LogicToLogic( aAcceptedVisArea.GetSize(), aNewMapUnit, pModel->GetScaleUnit()));
1842                 }
1843 
1844                 // make the new object area known to the client
1845                 // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
1846                 // OJ: WHY this -> OSL_ASSERT( pClient );
1847                 if( pClient )
1848                     pClient->SetObjArea(aRect);
1849 
1850                 // we need a new replacement image as the object has resized itself
1851 
1852                 //#i79578# don't request a new replacement image for charts to often
1853                 //a chart sends a modified call to the framework if it was changed
1854                 //thus the replacement update is already handled there
1855                 if( !IsChart() )
1856                     xObjRef.UpdateReplacement();
1857 			}
1858 			else
1859 			{
1860                 // The object isn't active and does not want to resize itself so the changed object area size
1861                 // will be reflected in a changed object scaling
1862 				Fraction aScaleWidth;
1863 				Fraction aScaleHeight;
1864 				Size aObjAreaSize;
1865 				if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
1866 				{
1867 					if ( pClient )
1868 					{
1869 						Rectangle aScaleRect(aRect.TopLeft(), aObjAreaSize);
1870 						pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
1871 					}
1872 					else
1873 					{
1874 						mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
1875 					}
1876 				}
1877 			}
1878 		}
1879         else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1880             svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ) )
1881         {
1882             //also handle not sfx based ole objects e.g. charts
1883             //#i83860# resizing charts in impress distorts fonts
1884             uno::Reference< embed::XVisualObject > xVisualObject( this->getXModel(), uno::UNO_QUERY );
1885             if( xVisualObject.is() )
1886             {
1887                 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1888                 Point aTL( aRect.TopLeft() );
1889                 Point aBR( aRect.BottomRight() );
1890                 Point aTL2( OutputDevice::LogicToLogic( aTL, pModel->GetScaleUnit(), aMapUnit) );
1891                 Point aBR2( OutputDevice::LogicToLogic( aBR, pModel->GetScaleUnit(), aMapUnit) );
1892                 Rectangle aNewRect( aTL2, aBR2 );
1893                 xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
1894             }
1895         }
1896 	}
1897 }
1898 
1899 // -----------------------------------------------------------------------------
1900 
1901 void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1902 {
1903 	if( pModel && !pModel->isLocked() )
1904     {
1905         GetObjRef();
1906         if ( xObjRef.is() && ( xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
1907         {
1908             // if the object needs recompose on resize
1909             // the client site should be created before the resize will take place
1910             // check whether there is no client site and create it if necessary
1911             AddOwnLightClient();
1912         }
1913     }
1914 
1915 	SdrRectObj::NbcResize(rRef,xFact,yFact);
1916 
1917     if( pModel && !pModel->isLocked() )
1918 		ImpSetVisAreaSize();
1919 }
1920 
1921 // -----------------------------------------------------------------------------
1922 
1923 void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
1924 {
1925 	SdrRectObj::SetGeoData(rGeo);
1926 
1927     if( pModel && !pModel->isLocked() )
1928 		ImpSetVisAreaSize();
1929 }
1930 
1931 // -----------------------------------------------------------------------------
1932 
1933 void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect)
1934 {
1935 	SdrRectObj::NbcSetSnapRect(rRect);
1936 
1937     if( pModel && !pModel->isLocked() )
1938 		ImpSetVisAreaSize();
1939 
1940     if ( xObjRef.is() && IsChart() )
1941     {
1942         //#i103460# charts do not necessaryly have an own size within ODF files,
1943         //for this case they need to use the size settings from the surrounding frame,
1944         //which is made available with this method as there is no other way
1945         xObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) );
1946     }
1947 }
1948 
1949 // -----------------------------------------------------------------------------
1950 
1951 void SdrOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
1952 {
1953 	SdrRectObj::NbcSetLogicRect(rRect);
1954 
1955     if( pModel && !pModel->isLocked() )
1956 		ImpSetVisAreaSize();
1957 }
1958 
1959 Graphic* SdrOle2Obj::GetGraphic() const
1960 {
1961     if ( xObjRef.is() )
1962         return xObjRef.GetGraphic();
1963     return pGraphic;
1964 }
1965 
1966 void SdrOle2Obj::GetNewReplacement()
1967 {
1968 	if ( xObjRef.is() )
1969 		xObjRef.UpdateReplacement();
1970 }
1971 
1972 // -----------------------------------------------------------------------------
1973 
1974 Size SdrOle2Obj::GetOrigObjSize( MapMode* pTargetMapMode ) const
1975 {
1976 	return xObjRef.GetSize( pTargetMapMode );
1977 }
1978 
1979 // -----------------------------------------------------------------------------
1980 
1981 void SdrOle2Obj::NbcMove(const Size& rSize)
1982 {
1983 	SdrRectObj::NbcMove(rSize);
1984 
1985     if( pModel && !pModel->isLocked() )
1986 		ImpSetVisAreaSize();
1987 }
1988 
1989 // -----------------------------------------------------------------------------
1990 
1991 sal_Bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
1992 {
1993 	sal_Bool bResult = sal_False;
1994 
1995 	sal_Int32 nState = xObj->getCurrentState();
1996 	if ( nState == embed::EmbedStates::LOADED )
1997 	{
1998         // the object is already unloaded
1999 		bResult = sal_True;
2000 	}
2001 	else
2002 	{
2003         uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
2004         if ( !xModifiable.is() )
2005             bResult = sal_True;
2006         else
2007         {
2008             sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
2009 
2010             if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
2011             embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
2012             !( xModifiable.is() && xModifiable->isModified() ) &&
2013             !( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
2014             {
2015                 bResult = sal_True;
2016             }
2017         }
2018     }
2019 
2020 	return bResult;
2021 }
2022 
2023 // -----------------------------------------------------------------------------
2024 
2025 sal_Bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
2026 {
2027 	sal_Bool bResult = sal_False;
2028 
2029     if ( CanUnloadRunningObj( xObj, nAspect ) )
2030     {
2031         try
2032         {
2033             xObj->changeState( embed::EmbedStates::LOADED );
2034             bResult = sal_True;
2035         }
2036         catch( ::com::sun::star::uno::Exception& e )
2037         {
2038             (void)e;
2039             DBG_ERROR(
2040                 (OString("SdrOle2Obj::Unload=(), "
2041                         "exception caught: ") +
2042                 rtl::OUStringToOString(
2043                     comphelper::anyToString( cppu::getCaughtException() ),
2044                     RTL_TEXTENCODING_UTF8 )).getStr() );
2045         }
2046     }
2047 
2048 	return bResult;
2049 }
2050 
2051 // -----------------------------------------------------------------------------
2052 
2053 sal_Bool SdrOle2Obj::Unload()
2054 {
2055 	sal_Bool bUnloaded = sal_False;
2056 
2057     if( xObjRef.is() )
2058 	{
2059         //TODO/LATER: no refcounting tricks anymore!
2060         //"customers" must register as state change listeners
2061 		//Nicht notwendig im Doc DTor (MM)
2062         //sal_uIntPtr nRefCount = (*ppObjRef)->GetRefCount();
2063 		// prevent Unload if there are external references
2064         //if( nRefCount > 2 )
2065         //    return sal_False;
2066         //DBG_ASSERT( nRefCount == 2, "Wrong RefCount for unload" );
2067 	}
2068 	else
2069 		bUnloaded = sal_True;
2070 
2071     if ( pModel && xObjRef.is() )
2072     {
2073 		bUnloaded = Unload( xObjRef.GetObject(), GetAspect() );
2074 	}
2075 
2076 	return bUnloaded;
2077 }
2078 
2079 // -----------------------------------------------------------------------------
2080 
2081 void SdrOle2Obj::GetObjRef_Impl()
2082 {
2083     if ( !xObjRef.is() && mpImpl->aPersistName.Len() && pModel && pModel->GetPersist() )
2084     {
2085 		// #107645#
2086         // Only try loading if it did not went wrong up to now
2087 		if(!mpImpl->mbLoadingOLEObjectFailed)
2088 		{
2089             xObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
2090             m_bTypeAsked = false;
2091 			CheckFileLink_Impl();
2092 
2093 			// #107645#
2094 			// If loading of OLE object failed, remember that to not invoke a endless
2095 			// loop trying to load it again and again.
2096             if( xObjRef.is() )
2097 			{
2098 				mpImpl->mbLoadingOLEObjectFailed = sal_True;
2099 			}
2100 
2101             // #108759# For math objects, set closed state to transparent
2102             if( ImplIsMathObj( xObjRef.GetObject() ) )
2103                 SetClosedObj( false );
2104 		}
2105 
2106         if ( xObjRef.is() )
2107 		{
2108 			if( !IsEmptyPresObj() )
2109 			{
2110 				// #75637# remember modified status of model
2111 				const sal_Bool bWasChanged(pModel ? pModel->IsChanged() : sal_False);
2112 
2113 				// perhaps preview not valid anymore
2114 				// #75637# This line changes the modified state of the model
2115                 SetGraphic_Impl( NULL );
2116 
2117 				// #75637# if status was not set before, force it back
2118 				// to not set, so that SetGraphic(0L) above does not
2119 				// set the modified state of the model.
2120 				if(!bWasChanged && pModel && pModel->IsChanged())
2121 				{
2122 					pModel->SetChanged( sal_False );
2123 				}
2124 			}
2125 
2126             sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
2127             (void)nMiscStatus;
2128             //TODO/LATER: wait until ResizeOnPrinterChange is defined
2129             //if ( nMiscStatus & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
2130 			{
2131 				if (pModel && pModel->GetRefDevice() &&
2132 					pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
2133 				{
2134 					if(!bInDestruction)
2135 					{
2136                         //TODO/LATER: printerchange notification
2137                         /*
2138 						// prevent SetModified (don't want no update here)
2139 						sal_Bool bWasEnabled = (*ppObjRef)->IsEnableSetModified();
2140 						if ( bWasEnabled )
2141 							(*ppObjRef)->EnableSetModified( sal_False );
2142 
2143 						// Kein RefDevice oder RefDevice kein Printer
2144 						Printer* pPrinter = (Printer*) pModel->GetRefDevice();
2145 						(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
2146 
2147 						// reset state
2148                         (*ppObjRef)->EnableSetModified( bWasEnabled );*/
2149 					}
2150 				}
2151 			}
2152         }
2153 
2154         if ( xObjRef.is() )
2155             Connect();
2156     }
2157 
2158     if ( mpImpl->mbConnected )
2159         // move object to first position in cache
2160         GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
2161 }
2162 
2163 uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef() const
2164 {
2165     const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
2166     return xObjRef.GetObject();
2167 }
2168 
2169 uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef_NoInit() const
2170 {
2171     return xObjRef.GetObject();
2172 }
2173 
2174 // -----------------------------------------------------------------------------
2175 
2176 uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
2177 {
2178     GetObjRef();
2179     if ( svt::EmbeddedObjectRef::TryRunningState(xObjRef.GetObject()) )
2180         return uno::Reference< frame::XModel >( xObjRef->getComponent(), uno::UNO_QUERY );
2181     else
2182         return uno::Reference< frame::XModel >();
2183 }
2184 
2185 // -----------------------------------------------------------------------------
2186 
2187 // #109985#
2188 sal_Bool SdrOle2Obj::IsChart() const
2189 {
2190     if ( !m_bTypeAsked )
2191     {
2192         m_bChart = ChartPrettyPainter::IsChart(xObjRef);
2193         m_bTypeAsked = true;
2194     }
2195     return m_bChart;
2196 }
2197 
2198 // -----------------------------------------------------------------------------
2199 void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const ::rtl::OUString& aMediaType )
2200 {
2201 	xObjRef.SetGraphic( aGraphic, aMediaType );
2202 }
2203 
2204 // -----------------------------------------------------------------------------
2205 void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const ::rtl::OUString& aMediaType )
2206 {
2207 	xObjRef.SetGraphicStream( xGrStream, aMediaType );
2208 }
2209 
2210 // -----------------------------------------------------------------------------
2211 sal_Bool SdrOle2Obj::IsCalc() const
2212 {
2213     if ( !xObjRef.is() )
2214         return false;
2215 
2216     SvGlobalName aObjClsId( xObjRef->getClassID() );
2217     if(    SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
2218         || SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
2219         || SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
2220         || SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
2221 		|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60) == aObjClsId
2222 		|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8) == aObjClsId
2223 		|| SvGlobalName(SO3_SC_CLASSID) == aObjClsId )
2224     {
2225         return sal_True;
2226     }
2227 
2228 	return sal_False;
2229 }
2230 
2231 // -----------------------------------------------------------------------------
2232 uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
2233 {
2234     uno::Reference< frame::XModel > xDoc;
2235 	if ( pModel )
2236 		xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
2237     return xDoc;
2238 }
2239 
2240 // -----------------------------------------------------------------------------
2241 sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
2242 {
2243 	// TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
2244 	// If we don't cache it for own objects also we must load the object here
2245 	if ( !xObjRef.is() || !pModel )
2246 		return sal_False;
2247 
2248 	MapMode aMapMode( pModel->GetScaleUnit() );
2249 	aObjAreaSize = xObjRef.GetSize( &aMapMode );
2250 
2251 	Size aSize = aRect.GetSize();
2252 	aScaleWidth = Fraction(aSize.Width(),  aObjAreaSize.Width() );
2253 	aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
2254 
2255 	// reduce to 10 binary digits
2256 	Kuerzen(aScaleHeight, 10);
2257 	Kuerzen(aScaleWidth,  10);
2258 
2259 	return sal_True;
2260 }
2261 
2262 // -----------------------------------------------------------------------------
2263 sal_Bool SdrOle2Obj::AddOwnLightClient()
2264 {
2265 	// The Own Light Client must be registered in object only using this method!
2266     if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() )
2267       && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) )
2268     {
2269 	    Connect();
2270 
2271 	    if ( xObjRef.is() && mpImpl->pLightClient )
2272 	    {
2273 		    Fraction aScaleWidth;
2274 		    Fraction aScaleHeight;
2275 		    Size aObjAreaSize;
2276 		    if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
2277 		    {
2278 			    mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
2279 			    try {
2280 				    xObjRef->setClientSite( mpImpl->pLightClient );
2281 				    return sal_True;
2282 			    } catch( uno::Exception& )
2283 			    {}
2284 		    }
2285 
2286 	    }
2287 
2288     	return sal_False;
2289     }
2290 
2291    	return sal_True;
2292 }
2293 
2294 //////////////////////////////////////////////////////////////////////////////
2295 
2296 Bitmap SdrOle2Obj::GetEmtyOLEReplacementBitmap()
2297 {
2298 	return Bitmap(ResId(BMP_SVXOLEOBJ, *ImpGetResMgr()));
2299 }
2300 
2301 //////////////////////////////////////////////////////////////////////////////
2302 
2303 void SdrOle2Obj::SetWindow(const com::sun::star::uno::Reference < com::sun::star::awt::XWindow >& _xWindow)
2304 {
2305     if ( xObjRef.is() && mpImpl->pLightClient )
2306     {
2307         mpImpl->pLightClient->setWindow(_xWindow);
2308     }
2309 }
2310 
2311 //////////////////////////////////////////////////////////////////////////////
2312 // eof
2313