xref: /aoo42x/main/svx/source/svdraw/svdoole2.cxx (revision a5258243)
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 	Init();
766 	bFrame=bFrame_;
767 }
768 
769 // -----------------------------------------------------------------------------
770 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, FASTBOOL bFrame_)
771     : xObjRef( rNewObjRef )
772     , m_bTypeAsked(false)
773     , m_bChart(false)
774 {
775     DBG_CTOR( SdrOle2Obj,NULL);
776 	bInDestruction = sal_False;
777 	Init();
778 
779 	bFrame=bFrame_;
780 
781     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
782         SetResizeProtect(sal_True);
783 
784     // #108759# For math objects, set closed state to transparent
785     if( ImplIsMathObj( xObjRef.GetObject() ) )
786         SetClosedObj( false );
787 }
788 
789 // -----------------------------------------------------------------------------
790 
791 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, FASTBOOL bFrame_)
792     : xObjRef( rNewObjRef )
793     , m_bTypeAsked(false)
794     , m_bChart(false)
795 {
796     DBG_CTOR( SdrOle2Obj,NULL);
797 	bInDestruction = sal_False;
798 	Init();
799 
800 	mpImpl->aPersistName = rNewObjName;
801 	bFrame=bFrame_;
802 
803     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
804         SetResizeProtect(sal_True);
805 
806     // #108759# For math objects, set closed state to transparent
807     if( ImplIsMathObj( xObjRef.GetObject() ) )
808         SetClosedObj( false );
809 }
810 
811 // -----------------------------------------------------------------------------
812 
813 SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef&  rNewObjRef, const XubString& rNewObjName, const Rectangle& rNewRect, FASTBOOL bFrame_)
814     : SdrRectObj(rNewRect)
815     , xObjRef( rNewObjRef )
816     , m_bTypeAsked(false)
817     , m_bChart(false)
818 {
819     DBG_CTOR( SdrOle2Obj,NULL);
820 	bInDestruction = sal_False;
821 	Init();
822 
823 	mpImpl->aPersistName = rNewObjName;
824 	bFrame=bFrame_;
825 
826     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
827         SetResizeProtect(sal_True);
828 
829     // #108759# For math objects, set closed state to transparent
830     if( ImplIsMathObj( xObjRef.GetObject() ) )
831         SetClosedObj( false );
832 }
833 
834 // -----------------------------------------------------------------------------
835 
836 void SdrOle2Obj::Init()
837 {
838 	mpImpl = new SdrOle2ObjImpl;
839 	pModifyListener = NULL;
840 	pGraphic=NULL;
841 	mpImpl->pGraphicObject=NULL;
842     mpImpl->pLightClient = 0;
843 
844     xObjRef.Lock( sal_True );
845 }
846 
847 // -----------------------------------------------------------------------------
848 
849 SdrOle2Obj::~SdrOle2Obj()
850 {
851     DBG_DTOR( SdrOle2Obj,NULL);
852 	bInDestruction = sal_True;
853 
854     if ( mpImpl->mbConnected )
855         Disconnect();
856 
857     if( pGraphic!=NULL )
858 		delete pGraphic;
859 
860 	if(mpImpl->pGraphicObject!=NULL)
861 		delete mpImpl->pGraphicObject;
862 
863 	if(pModifyListener)
864 	{
865 		pModifyListener->invalidate();
866 		pModifyListener->release();
867 	}
868 
869 	DisconnectFileLink_Impl();
870 
871     if ( mpImpl->pLightClient )
872 	{
873         mpImpl->pLightClient->Release();
874 		mpImpl->pLightClient = NULL;
875 	}
876 
877 	delete mpImpl;
878 }
879 
880 // -----------------------------------------------------------------------------
881 void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
882 {
883 	xObjRef.SetViewAspect( nAspect );
884 }
885 
886 // -----------------------------------------------------------------------------
887 
888 void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf)
889 {
890 	if ( pGraphic )
891 	{
892 		delete pGraphic;
893 		pGraphic = NULL;
894 		delete mpImpl->pGraphicObject;
895 		mpImpl->pGraphicObject = NULL;
896 	}
897 
898 	if (pGrf!=NULL)
899 	{
900 		pGraphic = new Graphic(*pGrf);
901 		mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
902 	}
903 
904 	SetChanged();
905 	BroadcastObjectChange();
906 
907 	//if ( ppObjRef->Is() && pGrf )
908 	//	BroadcastObjectChange();
909 }
910 
911 void SdrOle2Obj::SetGraphic(const Graphic* pGrf)
912 {
913     // only for setting a preview graphic
914     SetGraphic_Impl( pGrf );
915 }
916 
917 // -----------------------------------------------------------------------------
918 
919 FASTBOOL SdrOle2Obj::IsEmpty() const
920 {
921     return !(xObjRef.is());
922 }
923 
924 // -----------------------------------------------------------------------------
925 
926 void SdrOle2Obj::Connect()
927 {
928 	if( IsEmptyPresObj() )
929 		return;
930 
931     if( mpImpl->mbConnected )
932     {
933         // mba: currently there are situations where it seems to be unavoidable to have multiple connects
934         // changing this would need a larger code rewrite, so for now I remove the assertion
935         // DBG_ERROR("Connect() called on connected object!");
936 		return;
937     }
938 
939     Connect_Impl();
940     AddListeners_Impl();
941 }
942 
943 // -----------------------------------------------------------------------------
944 
945 sal_Bool SdrOle2Obj::UpdateLinkURL_Impl()
946 {
947 	sal_Bool bResult = sal_False;
948 
949 	if ( mpImpl->mpObjectLink )
950 	{
951 		sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
952 		if ( pLinkManager )
953 		{
954 			String aNewLinkURL;
955 			pLinkManager->GetDisplayNames( mpImpl->mpObjectLink, 0, &aNewLinkURL, 0, 0 );
956 			if ( !aNewLinkURL.EqualsIgnoreCaseAscii( mpImpl->maLinkURL ) )
957 			{
958     			const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
959 				uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObjRef.GetObject(), uno::UNO_QUERY );
960 				OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
961     			if ( xPersObj.is() )
962 				{
963 					try
964 					{
965 						sal_Int32 nCurState = xObjRef->getCurrentState();
966 						if ( nCurState != embed::EmbedStates::LOADED )
967 							xObjRef->changeState( embed::EmbedStates::LOADED );
968 
969 						// TODO/LATER: there should be possible to get current mediadescriptor settings from the object
970 						uno::Sequence< beans::PropertyValue > aArgs( 1 );
971 						aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
972 						aArgs[0].Value <<= ::rtl::OUString( aNewLinkURL );
973 						xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
974 
975 						mpImpl->maLinkURL = aNewLinkURL;
976 						bResult = sal_True;
977 
978 						if ( nCurState != embed::EmbedStates::LOADED )
979 							xObjRef->changeState( nCurState );
980 					}
981 					catch( ::com::sun::star::uno::Exception& e )
982 					{
983 						(void)e;
984 						DBG_ERROR(
985 							(OString("SdrOle2Obj::UpdateLinkURL_Impl(), "
986 									"exception caught: ") +
987 							rtl::OUStringToOString(
988 								comphelper::anyToString( cppu::getCaughtException() ),
989 								RTL_TEXTENCODING_UTF8 )).getStr() );
990 					}
991 				}
992 
993 				if ( !bResult )
994 				{
995 					// TODO/LATER: return the old name to the link manager, is it possible?
996 				}
997 			}
998 		}
999 	}
1000 
1001 	return bResult;
1002 }
1003 
1004 // -----------------------------------------------------------------------------
1005 
1006 void SdrOle2Obj::BreakFileLink_Impl()
1007 {
1008     uno::Reference<document::XStorageBasedDocument> xDoc;
1009 	if ( pModel )
1010 		xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
1011 
1012 	if ( xDoc.is() )
1013 	{
1014 		uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage();
1015 		if ( xStorage.is() )
1016 		{
1017 			try
1018 			{
1019 				uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY_THROW );
1020 				xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
1021 				DisconnectFileLink_Impl();
1022 				mpImpl->maLinkURL = String();
1023 			}
1024 			catch( ::com::sun::star::uno::Exception& e )
1025 			{
1026 				(void)e;
1027 				DBG_ERROR(
1028 					(OString("SdrOle2Obj::BreakFileLink_Impl(), "
1029 							"exception caught: ") +
1030 					rtl::OUStringToOString(
1031 						comphelper::anyToString( cppu::getCaughtException() ),
1032 						RTL_TEXTENCODING_UTF8 )).getStr() );
1033 			}
1034 		}
1035 	}
1036 }
1037 
1038 // -----------------------------------------------------------------------------
1039 
1040 void SdrOle2Obj::DisconnectFileLink_Impl()
1041 {
1042 	sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
1043 	if ( pLinkManager && mpImpl->mpObjectLink )
1044 	{
1045 		pLinkManager->Remove( mpImpl->mpObjectLink );
1046 		mpImpl->mpObjectLink = NULL;
1047 	}
1048 }
1049 
1050 // -----------------------------------------------------------------------------
1051 
1052 void SdrOle2Obj::CheckFileLink_Impl()
1053 {
1054 	if ( pModel && xObjRef.GetObject().is() && !mpImpl->mpObjectLink )
1055 	{
1056 		try
1057 		{
1058 			uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY );
1059 			if ( xLinkSupport.is() && xLinkSupport->isLink() )
1060 			{
1061 				String aLinkURL = xLinkSupport->getLinkURL();
1062 				if ( aLinkURL.Len() )
1063 				{
1064 					// this is a file link so the model link manager should handle it
1065 					sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
1066 					if ( pLinkManager )
1067 					{
1068 						mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
1069 						mpImpl->maLinkURL = aLinkURL;
1070 						pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
1071 						mpImpl->mpObjectLink->Connect();
1072 					}
1073 				}
1074 			}
1075 		}
1076 		catch( ::com::sun::star::uno::Exception& e )
1077 		{
1078 			(void)e;
1079 			DBG_ERROR(
1080 				(OString("SdrOle2Obj::CheckFileLink_Impl(), "
1081 						"exception caught: ") +
1082 				rtl::OUStringToOString(
1083 					comphelper::anyToString( cppu::getCaughtException() ),
1084 					RTL_TEXTENCODING_UTF8 )).getStr() );
1085 		}
1086 	}
1087 }
1088 
1089 // -----------------------------------------------------------------------------
1090 
1091 void SdrOle2Obj::Reconnect_Impl()
1092 {
1093     DBG_ASSERT( mpImpl->mbConnected, "Assigned unconnected object?!" );
1094     Connect_Impl();
1095 }
1096 
1097 void SdrOle2Obj::Connect_Impl()
1098 {
1099     if( pModel && mpImpl->aPersistName.Len() )
1100 	{
1101 		try
1102 		{
1103 			::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
1104 			if ( pPers )
1105 			{
1106 				comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
1107 				if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
1108 				  || ( xObjRef.is() && !rContainer.HasEmbeddedObject( xObjRef.GetObject() ) ) )
1109 				{
1110 					// object not known to container document
1111 					// No object -> disaster!
1112 					DBG_ASSERT( xObjRef.is(), "No object in connect!");
1113 					if ( xObjRef.is() )
1114 					{
1115 						// object came from the outside, now add it to the container
1116 						::rtl::OUString aTmp;
1117 						rContainer.InsertEmbeddedObject( xObjRef.GetObject(), aTmp );
1118                         mpImpl->aPersistName = aTmp;
1119 					}
1120 				}
1121 				else if ( !xObjRef.is() )
1122                 {
1123 					xObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), xObjRef.GetViewAspect() );
1124                     m_bTypeAsked = false;
1125                 }
1126 
1127 				if ( xObjRef.GetObject().is() )
1128 				{
1129 					xObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
1130 					mpImpl->mbConnected = true;
1131 					xObjRef.Lock( sal_True );
1132 				}
1133 			}
1134 
1135 			if ( xObjRef.is() )
1136 			{
1137 				if ( !mpImpl->pLightClient )
1138 				{
1139 					mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
1140 					mpImpl->pLightClient->acquire();
1141 				}
1142 
1143 				xObjRef->addStateChangeListener( mpImpl->pLightClient );
1144 				xObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
1145 
1146 				if ( xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
1147 					GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
1148 
1149 				CheckFileLink_Impl();
1150 
1151 				uno::Reference< container::XChild > xChild( xObjRef.GetObject(), uno::UNO_QUERY );
1152 				if( xChild.is() )
1153                 {
1154                     uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
1155                     if( xParent.is())
1156                         xChild->setParent( pModel->getUnoModel() );
1157                 }
1158 
1159 			}
1160 		}
1161 		catch( ::com::sun::star::uno::Exception& e )
1162 		{
1163 			(void)e;
1164 			DBG_ERROR(
1165 				(OString("SdrOle2Obj::Connect_Impl(), "
1166 						"exception caught: ") +
1167 				rtl::OUStringToOString(
1168 					comphelper::anyToString( cppu::getCaughtException() ),
1169 					RTL_TEXTENCODING_UTF8 )).getStr() );
1170 		}
1171 	}
1172 
1173     //TODO/LATER: wait for definition of MiscStatus RESIZEONPRINTERCHANGE
1174     //if ( xObjRef.is() && (*ppObjRef)->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
1175 	{
1176         //TODO/LATER: needs a new handling for OnPrinterChanged
1177         /*
1178 		if (pModel && pModel->GetRefDevice() &&
1179 			pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
1180 		{
1181 			// Kein RefDevice oder RefDevice kein Printer
1182 			sal_Bool bModified = (*ppObjRef)->IsModified();
1183 			Printer* pPrinter = (Printer*) pModel->GetRefDevice();
1184 			(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
1185 			(*ppObjRef)->SetModified( bModified );
1186         }*/
1187 	}
1188 }
1189 
1190 void SdrOle2Obj::ObjectLoaded()
1191 {
1192     AddListeners_Impl();
1193 }
1194 
1195 void SdrOle2Obj::AddListeners_Impl()
1196 {
1197     if( xObjRef.is() && xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
1198 	{
1199 		// register modify listener
1200         if( !pModifyListener )
1201 		{
1202 			((SdrOle2Obj*)this)->pModifyListener = new SvxUnoShapeModifyListener( (SdrOle2Obj*)this );
1203 			pModifyListener->acquire();
1204 		}
1205 
1206 		uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1207 		if( xBC.is() && pModifyListener )
1208 		{
1209 			uno::Reference< util::XModifyListener > xListener( pModifyListener );
1210 			xBC->addModifyListener( xListener );
1211 		}
1212 	}
1213 }
1214 
1215 // -----------------------------------------------------------------------------
1216 
1217 void SdrOle2Obj::Disconnect()
1218 {
1219 	if( IsEmptyPresObj() )
1220 		return;
1221 
1222 	if( !mpImpl->mbConnected )
1223     {
1224         DBG_ERROR("Disconnect() called on disconnected object!");
1225 		return;
1226     }
1227 
1228     RemoveListeners_Impl();
1229     Disconnect_Impl();
1230 }
1231 
1232 void SdrOle2Obj::RemoveListeners_Impl()
1233 {
1234     if( xObjRef.is() && mpImpl->aPersistName.Len() )
1235 	{
1236 		try
1237 		{
1238 			sal_Int32 nState = xObjRef->getCurrentState();
1239 			if ( nState != embed::EmbedStates::LOADED )
1240 			{
1241 				uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1242 				if( xBC.is() && pModifyListener )
1243 				{
1244 					uno::Reference< util::XModifyListener > xListener( pModifyListener );
1245 					xBC->removeModifyListener( xListener );
1246 				}
1247 			}
1248 		}
1249 		catch( ::com::sun::star::uno::Exception& e )
1250 		{
1251 			(void)e;
1252 			DBG_ERROR(
1253 				(OString("SdrOle2Obj::RemoveListeners_Impl(), "
1254 						"exception caught: ") +
1255 				rtl::OUStringToOString(
1256 					comphelper::anyToString( cppu::getCaughtException() ),
1257 					RTL_TEXTENCODING_UTF8 )).getStr() );
1258 		}
1259 	}
1260 }
1261 
1262 void SdrOle2Obj::Disconnect_Impl()
1263 {
1264 	try
1265 	{
1266 		if ( pModel && mpImpl->aPersistName.Len() )
1267 		{
1268 			if( pModel->IsInDestruction() )
1269 			{
1270 				// TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
1271 				// remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
1272 				// There is no real need to do the following removing of the object from the container
1273 				// in case the model has correct persistance, but in case of problems such a removing
1274 				// would make the behaviour of the office more stable
1275 
1276 				comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
1277 				if ( pContainer )
1278 				{
1279 					pContainer->CloseEmbeddedObject( xObjRef.GetObject() );
1280 					xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
1281 				}
1282 
1283 				// happens later than the destruction of the model, so we can't assert that).
1284 				//DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
1285 				//TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
1286 				/*
1287 				uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
1288 				if ( xClose.is() )
1289 				{
1290 					try
1291 					{
1292 						xClose->close( sal_True );
1293 					}
1294 					catch ( util::CloseVetoException& )
1295 					{
1296 						// there's still someone who needs the object!
1297 					}
1298 				}
1299 
1300 				xObjRef = NULL;*/
1301 			}
1302 			else if ( xObjRef.is() )
1303 			{
1304 				if ( pModel->getUnoModel().is() )
1305 				{
1306 					// remove object, but don't close it (that's up to someone else)
1307 					comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
1308 					if ( pContainer )
1309 					{
1310 						pContainer->RemoveEmbeddedObject( xObjRef.GetObject(), sal_False);
1311 
1312 						// TODO/LATER: mpImpl->aPersistName contains outdated information, to have it uptodate
1313 						// it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
1314 						// since no container is adjusted, actually the empty string could be provided as a name here
1315 						xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
1316 					}
1317 
1318 					DisconnectFileLink_Impl();
1319 				}
1320 			}
1321 		}
1322 
1323 		if ( xObjRef.is() && mpImpl->pLightClient )
1324 		{
1325 			xObjRef->removeStateChangeListener ( mpImpl->pLightClient );
1326 			xObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
1327 			xObjRef->setClientSite( NULL );
1328 
1329 			GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
1330 		}
1331 	}
1332 	catch( ::com::sun::star::uno::Exception& e )
1333 	{
1334 		(void)e;
1335 		DBG_ERROR(
1336 			(OString("SdrOle2Obj::Disconnect_Impl(), "
1337 					"exception caught: ") +
1338 			rtl::OUStringToOString(
1339 				comphelper::anyToString( cppu::getCaughtException() ),
1340 				RTL_TEXTENCODING_UTF8 )).getStr() );
1341 	}
1342 
1343 	mpImpl->mbConnected = false;
1344 }
1345 
1346 // -----------------------------------------------------------------------------
1347 
1348 SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText, bool bUseHCGraphic) const
1349 {
1350     Graphic* pOLEGraphic = GetGraphic();
1351 
1352     if(bUseHCGraphic && Application::GetSettings().GetStyleSettings().GetHighContrastMode())
1353     {
1354         pOLEGraphic = getEmbeddedObjectRef().GetHCGraphic();
1355     }
1356 
1357     if(pOLEGraphic)
1358     {
1359         // #i118485# allow creating a SdrGrafObj representation
1360         SdrGrafObj* pClone = new SdrGrafObj(*pOLEGraphic);
1361         pClone->SetModel(GetModel());
1362 
1363         // copy transformation
1364         basegfx::B2DHomMatrix aMatrix;
1365         basegfx::B2DPolyPolygon aPolyPolygon;
1366 
1367         TRGetBaseGeometry(aMatrix, aPolyPolygon);
1368         pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon);
1369 
1370         // copy all attributes to support graphic styles for OLEs
1371         pClone->SetStyleSheet(GetStyleSheet(), false);
1372         pClone->SetMergedItemSet(GetMergedItemSet());
1373 
1374         if(bAddText)
1375         {
1376             // #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
1377             OutlinerParaObject* pOPO = GetOutlinerParaObject();
1378 
1379             if(pOPO && GetModel())
1380             {
1381                 pClone->NbcSetOutlinerParaObject(new OutlinerParaObject(*pOPO));
1382             }
1383         }
1384 
1385         return pClone;
1386     }
1387     else
1388     {
1389         // #i100710# pOLEGraphic may be zero (no visualisation available),
1390         // so we need to use the OLE replacement graphic
1391         SdrRectObj* pClone = new SdrRectObj(GetSnapRect());
1392         pClone->SetModel(GetModel());
1393 
1394         // gray outline
1395         pClone->SetMergedItem(XLineStyleItem(XLINE_SOLID));
1396         const svtools::ColorConfig aColorConfig;
1397         const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
1398         pClone->SetMergedItem(XLineColorItem(String(), aColor.nColor));
1399 
1400         // bitmap fill
1401         pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
1402         pClone->SetMergedItem(XFillBitmapItem(String(), GetEmtyOLEReplacementBitmap()));
1403         pClone->SetMergedItem(XFillBmpTileItem(false));
1404         pClone->SetMergedItem(XFillBmpStretchItem(false));
1405 
1406         return pClone;
1407     }
1408 }
1409 
1410 SdrObject* SdrOle2Obj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
1411 {
1412     // #i118485# missing converter added
1413     if(GetModel())
1414     {
1415         SdrObject* pRetval = createSdrGrafObjReplacement(true, false);
1416 
1417         if(pRetval)
1418         {
1419             SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
1420             SdrObject::Free(pRetval);
1421 
1422             return pRetval2;
1423         }
1424     }
1425 
1426     return 0;
1427 }
1428 
1429 // -----------------------------------------------------------------------------
1430 
1431 void SdrOle2Obj::SetModel(SdrModel* pNewModel)
1432 {
1433     ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : 0;
1434     ::comphelper::IEmbeddedHelper* pSrcPers  = pModel ? pModel->GetPersist() : 0;
1435 
1436     if ( pNewModel == pModel )
1437     {
1438         // don't know if this is necessary or if it will ever happen, but who know?!
1439         SdrRectObj::SetModel( pNewModel );
1440         return;
1441     }
1442 
1443     // assignment to model has changed
1444     DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
1445 
1446 	DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
1447 	DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
1448 
1449 	// this is a bug if the target model has no persistence
1450 	// no error handling is possible so just do nothing in this method
1451 	if ( !pDestPers )
1452 		return;
1453 
1454     RemoveListeners_Impl();
1455 
1456     if( pDestPers && pSrcPers && !IsEmptyPresObj() )
1457     {
1458 		try
1459 		{
1460 			// move the objects' storage; ObjectRef remains the same, but PersistName may change
1461 			::rtl::OUString aTmp;
1462 			comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
1463 			uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
1464 			DBG_ASSERT( !xObjRef.is() || xObjRef.GetObject() == xObj, "Wrong object identity!" );
1465 			if ( xObj.is() )
1466 			{
1467 				pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
1468 				mpImpl->aPersistName = aTmp;
1469 				xObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
1470 			}
1471 	        DBG_ASSERT( aTmp.getLength(), "Copying embedded object failed!" );
1472 		}
1473 		catch( ::com::sun::star::uno::Exception& e )
1474 		{
1475 			(void)e;
1476 			DBG_ERROR(
1477 				(OString("SdrOle2Obj::SetModel(), "
1478 						"exception caught: ") +
1479 				rtl::OUStringToOString(
1480 					comphelper::anyToString( cppu::getCaughtException() ),
1481 					RTL_TEXTENCODING_UTF8 )).getStr() );
1482 		}
1483     }
1484 
1485 	SdrRectObj::SetModel( pNewModel );
1486 
1487     // #i43086#
1488     // #i85304 redo the change for charts for the above bugfix, as #i43086# does not ocur anymore
1489     //so maybe the ImpSetVisAreaSize call can be removed here completely
1490     //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
1491     if( pModel && !pModel->isLocked() && !IsChart() )
1492         ImpSetVisAreaSize();
1493 
1494     if( pDestPers && !IsEmptyPresObj() )
1495     {
1496         if ( !pSrcPers || IsEmptyPresObj() )
1497             // object wasn't connected, now it should
1498             Connect_Impl();
1499         else
1500             Reconnect_Impl();
1501     }
1502 
1503     AddListeners_Impl();
1504 }
1505 
1506 // -----------------------------------------------------------------------------
1507 
1508 void SdrOle2Obj::SetPage(SdrPage* pNewPage)
1509 {
1510 	FASTBOOL bRemove=pNewPage==NULL && pPage!=NULL;
1511 	FASTBOOL bInsert=pNewPage!=NULL && pPage==NULL;
1512 
1513     if (bRemove && mpImpl->mbConnected )
1514         Disconnect();
1515 
1516 	SdrRectObj::SetPage(pNewPage);
1517 
1518     if (bInsert && !mpImpl->mbConnected )
1519         Connect();
1520 }
1521 
1522 // -----------------------------------------------------------------------------
1523 
1524 void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& rNewObjRef )
1525 {
1526     DBG_ASSERT( !rNewObjRef.is() || !xObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
1527     if( rNewObjRef == xObjRef.GetObject() )
1528 		return;
1529 
1530     // MBA: the caller of the method is responsible to control the old object, it will not be closed here
1531     // Otherwise WW8 import crashes because it tranfers control to OLENode by this method
1532     if ( xObjRef.GetObject().is() )
1533         xObjRef.Lock( sal_False );
1534 
1535     // MBA: avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
1536     // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
1537     xObjRef.Clear();
1538 
1539     if ( mpImpl->mbConnected )
1540         Disconnect();
1541 
1542     xObjRef.Assign( rNewObjRef, GetAspect() );
1543     m_bTypeAsked = false;
1544 
1545     if ( xObjRef.is() )
1546     {
1547         DELETEZ( pGraphic );
1548 
1549         if ( (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
1550             SetResizeProtect(sal_True);
1551 
1552         // #108759# For math objects, set closed state to transparent
1553         if( ImplIsMathObj( rNewObjRef ) )
1554             SetClosedObj( false );
1555 
1556         Connect();
1557     }
1558 
1559 	SetChanged();
1560 	BroadcastObjectChange();
1561 }
1562 
1563 // -----------------------------------------------------------------------------
1564 
1565 void SdrOle2Obj::SetClosedObj( bool bIsClosed )
1566 {
1567     // TODO/LATER: do we still need this hack?
1568     // #108759# Allow changes to the closed state of OLE objects
1569     bClosedObj = bIsClosed;
1570 }
1571 
1572 // -----------------------------------------------------------------------------
1573 
1574 SdrObject* SdrOle2Obj::getFullDragClone() const
1575 {
1576     // special handling for OLE. The default handling works, but is too
1577     // slow when the whole OLE needs to be cloned. Get the Metafile and
1578     // create a graphic object with it
1579 
1580     // #i118485# use central replacement generator
1581     return createSdrGrafObjReplacement(false, true);
1582 }
1583 
1584 // -----------------------------------------------------------------------------
1585 
1586 void SdrOle2Obj::SetPersistName( const String& rPersistName )
1587 {
1588     DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!");
1589 
1590     mpImpl->aPersistName = rPersistName;
1591 	mpImpl->mbLoadingOLEObjectFailed = false;
1592 
1593 	Connect();
1594     SetChanged();
1595 }
1596 
1597 void SdrOle2Obj::AbandonObject()
1598 {
1599     mpImpl->aPersistName.Erase();
1600 	mpImpl->mbLoadingOLEObjectFailed = false;
1601     SetObjRef(0);
1602 }
1603 
1604 // -----------------------------------------------------------------------------
1605 
1606 String SdrOle2Obj::GetPersistName() const
1607 {
1608     return mpImpl->aPersistName;
1609 }
1610 
1611 // -----------------------------------------------------------------------------
1612 
1613 void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
1614 {
1615     // #i118485# Allowing much more attributes for OLEs
1616 	rInfo.bRotateFreeAllowed = true;
1617 	rInfo.bRotate90Allowed = true;
1618 	rInfo.bMirrorFreeAllowed = true;
1619 	rInfo.bMirror45Allowed = true;
1620 	rInfo.bMirror90Allowed = true;
1621 	rInfo.bTransparenceAllowed = true;
1622 	rInfo.bGradientAllowed = true;
1623 	rInfo.bShearAllowed = true;
1624 	rInfo.bEdgeRadiusAllowed = false;
1625 	rInfo.bNoOrthoDesired = false;
1626 	rInfo.bCanConvToPath = true;
1627 	rInfo.bCanConvToPoly = true;
1628 	rInfo.bCanConvToPathLineToArea = false;
1629 	rInfo.bCanConvToPolyLineToArea = false;
1630 	rInfo.bCanConvToContour = true;
1631 }
1632 
1633 // -----------------------------------------------------------------------------
1634 
1635 sal_uInt16 SdrOle2Obj::GetObjIdentifier() const
1636 {
1637 	return bFrame ? sal_uInt16(OBJ_FRAME) : sal_uInt16(OBJ_OLE2);
1638 }
1639 
1640 // -----------------------------------------------------------------------------
1641 
1642 void SdrOle2Obj::TakeObjNameSingul(XubString& rName) const
1643 {
1644 	rName = ImpGetResStr(bFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2);
1645 
1646 	const String aName(GetName());
1647 
1648 	if( aName.Len() )
1649 	{
1650 		rName.AppendAscii(" '");
1651 		rName += aName;
1652 		rName += sal_Unicode('\'');
1653 	}
1654 }
1655 
1656 // -----------------------------------------------------------------------------
1657 
1658 void SdrOle2Obj::TakeObjNamePlural(XubString& rName) const
1659 {
1660 	rName=ImpGetResStr(bFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
1661 }
1662 
1663 // -----------------------------------------------------------------------------
1664 
1665 void SdrOle2Obj::operator=(const SdrObject& rObj)
1666 {
1667     //TODO/LATER: who takes over control of my old object?!
1668     if( &rObj != this )
1669 	{
1670 		// #116235#
1671 		// ImpAssign( rObj );
1672         const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
1673 
1674         uno::Reference < util::XCloseable > xClose( xObjRef.GetObject(), uno::UNO_QUERY );
1675 
1676         if( pModel && mpImpl->mbConnected )
1677             Disconnect();
1678 
1679         SdrRectObj::operator=( rObj );
1680 
1681         // #108867# Manually copying bClosedObj attribute
1682         SetClosedObj( rObj.IsClosedObj() );
1683 
1684         mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
1685         aProgName = rOle2Obj.aProgName;
1686         bFrame = rOle2Obj.bFrame;
1687 
1688         if( rOle2Obj.pGraphic )
1689         {
1690             if( pGraphic )
1691             {
1692                 delete pGraphic;
1693                 delete mpImpl->pGraphicObject;
1694             }
1695 
1696             pGraphic = new Graphic( *rOle2Obj.pGraphic );
1697             mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
1698         }
1699 
1700         if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
1701         {
1702             ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
1703             ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
1704             if( pDestPers && pSrcPers )
1705             {
1706     			DBG_ASSERT( !xObjRef.is(), "Object already existing!" );
1707     			comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
1708     			uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
1709     			if ( xObj.is() )
1710     			{
1711         			::rtl::OUString aTmp;
1712         			xObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( rContainer, xObj, aTmp ), rOle2Obj.GetAspect() );
1713                     m_bTypeAsked = false;
1714         			mpImpl->aPersistName = aTmp;
1715 					CheckFileLink_Impl();
1716     			}
1717 
1718                 Connect();
1719 
1720                 /* only needed for MSOLE-Objects, now handled inside implementation of Object
1721 				if ( xObjRef.is() && rOle2Obj.xObjRef.is() && rOle2Obj.GetAspect() != embed::Aspects::MSOLE_ICON )
1722 				{
1723 					try
1724 					{
1725 						awt::Size aVisSize = rOle2Obj.xObjRef->getVisualAreaSize( rOle2Obj.GetAspect() );
1726 						if( rOle2Obj.xObjRef->getMapUnit( rOle2Obj.GetAspect() ) == xObjRef->getMapUnit( GetAspect() ) )
1727 						xObjRef->setVisualAreaSize( GetAspect(), aVisSize );
1728 					}
1729 					catch ( embed::WrongStateException& )
1730 					{
1731 						// setting of VisArea not necessary for objects that don't cache it in loaded state
1732 					}
1733 					catch( embed::NoVisualAreaSizeException& )
1734 					{
1735 						// objects my not have visual areas
1736 					}
1737 					catch( uno::Exception& e )
1738 					{
1739 						(void)e;
1740 						DBG_ERROR( "SdrOle2Obj::operator=(), unexcpected exception caught!" );
1741 					}
1742                 }                                                                            */
1743             }
1744         }
1745     }
1746 }
1747 
1748 // -----------------------------------------------------------------------------
1749 
1750 void SdrOle2Obj::ImpSetVisAreaSize()
1751 {
1752 	// currently there is no need to recalculate scaling for iconified objects
1753 	// TODO/LATER: it might be needed in future when it is possible to change the icon
1754 	if ( GetAspect() == embed::Aspects::MSOLE_ICON )
1755 		return;
1756 
1757     // the object area of an embedded object was changed, e.g. by user interaction an a selected object
1758     GetObjRef();
1759     if ( xObjRef.is() )
1760 	{
1761         OSL_ASSERT( pModel );
1762         sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
1763 
1764 		// the client is required to get access to scaling
1765 		SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() );
1766 		sal_Bool bHasOwnClient =
1767 						( mpImpl->pLightClient
1768 						&& xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
1769 
1770 		if ( pClient || bHasOwnClient )
1771 		{
1772             // TODO/LATER: IMHO we need to do similar things when object is UIActive or OutplaceActive?! (MBA)
1773             if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1774                     svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ))
1775                     || xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
1776                     )
1777 			{
1778 				Fraction aScaleWidth;
1779 				Fraction aScaleHeight;
1780 				if ( pClient )
1781 				{
1782 					aScaleWidth = pClient->GetScaleWidth();
1783 					aScaleHeight = pClient->GetScaleHeight();
1784 				}
1785 				else
1786 				{
1787 					aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
1788 					aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
1789 				}
1790 
1791                 // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
1792                 // or object is inplace active and so has a window that must be resized also
1793                 // In these cases the change in the object area size will be reflected in a change of the
1794                 // objects' visual area. The scaling will not change, but it might exist already and must
1795                 // be used in calculations
1796 				MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1797 				Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ),
1798 								(long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) );
1799 
1800 				aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit);
1801 				awt::Size aSz;
1802 				aSz.Width = aVisSize.Width();
1803 				aSz.Height = aVisSize.Height();
1804 				xObjRef->setVisualAreaSize( GetAspect(), aSz );
1805 
1806 				try
1807 				{
1808 					aSz = xObjRef->getVisualAreaSize( GetAspect() );
1809 				}
1810 				catch( embed::NoVisualAreaSizeException& )
1811 				{}
1812 
1813 				Rectangle aAcceptedVisArea;
1814 				aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ),
1815 												(long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) );
1816 				if (aVisSize != aAcceptedVisArea.GetSize())
1817 				{
1818                     // server changed VisArea to its liking and the VisArea is different than the suggested one
1819                     // store the new value as given by the object
1820 					MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1821 					aRect.SetSize(OutputDevice::LogicToLogic( aAcceptedVisArea.GetSize(), aNewMapUnit, pModel->GetScaleUnit()));
1822                 }
1823 
1824                 // make the new object area known to the client
1825                 // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
1826                 // OJ: WHY this -> OSL_ASSERT( pClient );
1827                 if( pClient )
1828                     pClient->SetObjArea(aRect);
1829 
1830                 // we need a new replacement image as the object has resized itself
1831 
1832                 //#i79578# don't request a new replacement image for charts to often
1833                 //a chart sends a modified call to the framework if it was changed
1834                 //thus the replacement update is already handled there
1835                 if( !IsChart() )
1836                     xObjRef.UpdateReplacement();
1837 			}
1838 			else
1839 			{
1840                 // The object isn't active and does not want to resize itself so the changed object area size
1841                 // will be reflected in a changed object scaling
1842 				Fraction aScaleWidth;
1843 				Fraction aScaleHeight;
1844 				Size aObjAreaSize;
1845 				if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
1846 				{
1847 					if ( pClient )
1848 					{
1849 						Rectangle aScaleRect(aRect.TopLeft(), aObjAreaSize);
1850 						pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
1851 					}
1852 					else
1853 					{
1854 						mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
1855 					}
1856 				}
1857 			}
1858 		}
1859         else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1860             svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ) )
1861         {
1862             //also handle not sfx based ole objects e.g. charts
1863             //#i83860# resizing charts in impress distorts fonts
1864             uno::Reference< embed::XVisualObject > xVisualObject( this->getXModel(), uno::UNO_QUERY );
1865             if( xVisualObject.is() )
1866             {
1867                 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
1868                 Point aTL( aRect.TopLeft() );
1869                 Point aBR( aRect.BottomRight() );
1870                 Point aTL2( OutputDevice::LogicToLogic( aTL, pModel->GetScaleUnit(), aMapUnit) );
1871                 Point aBR2( OutputDevice::LogicToLogic( aBR, pModel->GetScaleUnit(), aMapUnit) );
1872                 Rectangle aNewRect( aTL2, aBR2 );
1873                 xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
1874             }
1875         }
1876 	}
1877 }
1878 
1879 // -----------------------------------------------------------------------------
1880 
1881 void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1882 {
1883 	if( pModel && !pModel->isLocked() )
1884     {
1885         GetObjRef();
1886         if ( xObjRef.is() && ( xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
1887         {
1888             // if the object needs recompose on resize
1889             // the client site should be created before the resize will take place
1890             // check whether there is no client site and create it if necessary
1891             AddOwnLightClient();
1892         }
1893     }
1894 
1895 	SdrRectObj::NbcResize(rRef,xFact,yFact);
1896 	if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0) { // kleine Korrekturen
1897 		if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000) {
1898 			aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
1899 		}
1900 		aGeo.nDrehWink=0;
1901 		aGeo.nShearWink=0;
1902 		aGeo.nSin=0.0;
1903 		aGeo.nCos=1.0;
1904 		aGeo.nTan=0.0;
1905 		SetRectsDirty();
1906 	}
1907 	if( pModel && !pModel->isLocked() )
1908 		ImpSetVisAreaSize();
1909 }
1910 
1911 // -----------------------------------------------------------------------------
1912 
1913 void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
1914 {
1915 	SdrRectObj::SetGeoData(rGeo);
1916 	if( pModel && !pModel->isLocked() )
1917 		ImpSetVisAreaSize();
1918 }
1919 
1920 // -----------------------------------------------------------------------------
1921 
1922 void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect)
1923 {
1924 	SdrRectObj::NbcSetSnapRect(rRect);
1925 	if( pModel && !pModel->isLocked() )
1926 		ImpSetVisAreaSize();
1927 
1928     if ( xObjRef.is() && IsChart() )
1929     {
1930         //#i103460# charts do not necessaryly have an own size within ODF files,
1931         //for this case they need to use the size settings from the surrounding frame,
1932         //which is made available with this method as there is no other way
1933         xObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) );
1934     }
1935 }
1936 
1937 // -----------------------------------------------------------------------------
1938 
1939 void SdrOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
1940 {
1941 	SdrRectObj::NbcSetLogicRect(rRect);
1942 	if( pModel && !pModel->isLocked() )
1943 		ImpSetVisAreaSize();
1944 }
1945 
1946 Graphic* SdrOle2Obj::GetGraphic() const
1947 {
1948     if ( xObjRef.is() )
1949         return xObjRef.GetGraphic();
1950     return pGraphic;
1951 }
1952 
1953 void SdrOle2Obj::GetNewReplacement()
1954 {
1955 	if ( xObjRef.is() )
1956 		xObjRef.UpdateReplacement();
1957 }
1958 
1959 // -----------------------------------------------------------------------------
1960 
1961 Size SdrOle2Obj::GetOrigObjSize( MapMode* pTargetMapMode ) const
1962 {
1963 	return xObjRef.GetSize( pTargetMapMode );
1964 }
1965 
1966 // -----------------------------------------------------------------------------
1967 
1968 void SdrOle2Obj::NbcMove(const Size& rSize)
1969 {
1970 	SdrRectObj::NbcMove(rSize);
1971 	if( pModel && !pModel->isLocked() )
1972 		ImpSetVisAreaSize();
1973 }
1974 
1975 // -----------------------------------------------------------------------------
1976 
1977 sal_Bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
1978 {
1979 	sal_Bool bResult = sal_False;
1980 
1981 	sal_Int32 nState = xObj->getCurrentState();
1982 	if ( nState == embed::EmbedStates::LOADED )
1983 	{
1984         // the object is already unloaded
1985 		bResult = sal_True;
1986 	}
1987 	else
1988 	{
1989         uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
1990         if ( !xModifiable.is() )
1991             bResult = sal_True;
1992         else
1993         {
1994             sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1995 
1996             if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1997             embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
1998             !( xModifiable.is() && xModifiable->isModified() ) &&
1999             !( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
2000             {
2001                 bResult = sal_True;
2002             }
2003         }
2004     }
2005 
2006 	return bResult;
2007 }
2008 
2009 // -----------------------------------------------------------------------------
2010 
2011 sal_Bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
2012 {
2013 	sal_Bool bResult = sal_False;
2014 
2015     if ( CanUnloadRunningObj( xObj, nAspect ) )
2016     {
2017         try
2018         {
2019             xObj->changeState( embed::EmbedStates::LOADED );
2020             bResult = sal_True;
2021         }
2022         catch( ::com::sun::star::uno::Exception& e )
2023         {
2024             (void)e;
2025             DBG_ERROR(
2026                 (OString("SdrOle2Obj::Unload=(), "
2027                         "exception caught: ") +
2028                 rtl::OUStringToOString(
2029                     comphelper::anyToString( cppu::getCaughtException() ),
2030                     RTL_TEXTENCODING_UTF8 )).getStr() );
2031         }
2032     }
2033 
2034 	return bResult;
2035 }
2036 
2037 // -----------------------------------------------------------------------------
2038 
2039 sal_Bool SdrOle2Obj::Unload()
2040 {
2041 	sal_Bool bUnloaded = sal_False;
2042 
2043     if( xObjRef.is() )
2044 	{
2045         //TODO/LATER: no refcounting tricks anymore!
2046         //"customers" must register as state change listeners
2047 		//Nicht notwendig im Doc DTor (MM)
2048         //sal_uIntPtr nRefCount = (*ppObjRef)->GetRefCount();
2049 		// prevent Unload if there are external references
2050         //if( nRefCount > 2 )
2051         //    return sal_False;
2052         //DBG_ASSERT( nRefCount == 2, "Wrong RefCount for unload" );
2053 	}
2054 	else
2055 		bUnloaded = sal_True;
2056 
2057     if ( pModel && xObjRef.is() )
2058     {
2059 		bUnloaded = Unload( xObjRef.GetObject(), GetAspect() );
2060 	}
2061 
2062 	return bUnloaded;
2063 }
2064 
2065 // -----------------------------------------------------------------------------
2066 
2067 void SdrOle2Obj::GetObjRef_Impl()
2068 {
2069     if ( !xObjRef.is() && mpImpl->aPersistName.Len() && pModel && pModel->GetPersist() )
2070     {
2071 		// #107645#
2072         // Only try loading if it did not went wrong up to now
2073 		if(!mpImpl->mbLoadingOLEObjectFailed)
2074 		{
2075             xObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
2076             m_bTypeAsked = false;
2077 			CheckFileLink_Impl();
2078 
2079 			// #107645#
2080 			// If loading of OLE object failed, remember that to not invoke a endless
2081 			// loop trying to load it again and again.
2082             if( xObjRef.is() )
2083 			{
2084 				mpImpl->mbLoadingOLEObjectFailed = sal_True;
2085 			}
2086 
2087             // #108759# For math objects, set closed state to transparent
2088             if( ImplIsMathObj( xObjRef.GetObject() ) )
2089                 SetClosedObj( false );
2090 		}
2091 
2092         if ( xObjRef.is() )
2093 		{
2094 			if( !IsEmptyPresObj() )
2095 			{
2096 				// #75637# remember modified status of model
2097 				const sal_Bool bWasChanged(pModel ? pModel->IsChanged() : sal_False);
2098 
2099 				// perhaps preview not valid anymore
2100 				// #75637# This line changes the modified state of the model
2101                 SetGraphic_Impl( NULL );
2102 
2103 				// #75637# if status was not set before, force it back
2104 				// to not set, so that SetGraphic(0L) above does not
2105 				// set the modified state of the model.
2106 				if(!bWasChanged && pModel && pModel->IsChanged())
2107 				{
2108 					pModel->SetChanged( sal_False );
2109 				}
2110 			}
2111 
2112             sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
2113             (void)nMiscStatus;
2114             //TODO/LATER: wait until ResizeOnPrinterChange is defined
2115             //if ( nMiscStatus & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
2116 			{
2117 				if (pModel && pModel->GetRefDevice() &&
2118 					pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
2119 				{
2120 					if(!bInDestruction)
2121 					{
2122                         //TODO/LATER: printerchange notification
2123                         /*
2124 						// prevent SetModified (don't want no update here)
2125 						sal_Bool bWasEnabled = (*ppObjRef)->IsEnableSetModified();
2126 						if ( bWasEnabled )
2127 							(*ppObjRef)->EnableSetModified( sal_False );
2128 
2129 						// Kein RefDevice oder RefDevice kein Printer
2130 						Printer* pPrinter = (Printer*) pModel->GetRefDevice();
2131 						(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
2132 
2133 						// reset state
2134                         (*ppObjRef)->EnableSetModified( bWasEnabled );*/
2135 					}
2136 				}
2137 			}
2138         }
2139 
2140         if ( xObjRef.is() )
2141             Connect();
2142     }
2143 
2144     if ( mpImpl->mbConnected )
2145         // move object to first position in cache
2146         GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
2147 }
2148 
2149 uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef() const
2150 {
2151     const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
2152     return xObjRef.GetObject();
2153 }
2154 
2155 uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef_NoInit() const
2156 {
2157     return xObjRef.GetObject();
2158 }
2159 
2160 // -----------------------------------------------------------------------------
2161 
2162 uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
2163 {
2164     GetObjRef();
2165     if ( svt::EmbeddedObjectRef::TryRunningState(xObjRef.GetObject()) )
2166         return uno::Reference< frame::XModel >( xObjRef->getComponent(), uno::UNO_QUERY );
2167     else
2168         return uno::Reference< frame::XModel >();
2169 }
2170 
2171 // -----------------------------------------------------------------------------
2172 
2173 // #109985#
2174 sal_Bool SdrOle2Obj::IsChart() const
2175 {
2176     if ( !m_bTypeAsked )
2177     {
2178         m_bChart = ChartPrettyPainter::IsChart(xObjRef);
2179         m_bTypeAsked = true;
2180     }
2181     return m_bChart;
2182 }
2183 
2184 // -----------------------------------------------------------------------------
2185 void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const ::rtl::OUString& aMediaType )
2186 {
2187 	xObjRef.SetGraphic( aGraphic, aMediaType );
2188 }
2189 
2190 // -----------------------------------------------------------------------------
2191 void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const ::rtl::OUString& aMediaType )
2192 {
2193 	xObjRef.SetGraphicStream( xGrStream, aMediaType );
2194 }
2195 
2196 // -----------------------------------------------------------------------------
2197 sal_Bool SdrOle2Obj::IsCalc() const
2198 {
2199     if ( !xObjRef.is() )
2200         return false;
2201 
2202     SvGlobalName aObjClsId( xObjRef->getClassID() );
2203     if(    SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
2204         || SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
2205         || SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
2206         || SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
2207 		|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60) == aObjClsId
2208 		|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8) == aObjClsId
2209 		|| SvGlobalName(SO3_SC_CLASSID) == aObjClsId )
2210     {
2211         return sal_True;
2212     }
2213 
2214 	return sal_False;
2215 }
2216 
2217 // -----------------------------------------------------------------------------
2218 uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
2219 {
2220     uno::Reference< frame::XModel > xDoc;
2221 	if ( pModel )
2222 		xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
2223     return xDoc;
2224 }
2225 
2226 // -----------------------------------------------------------------------------
2227 sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
2228 {
2229 	// TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
2230 	// If we don't cache it for own objects also we must load the object here
2231 	if ( !xObjRef.is() || !pModel )
2232 		return sal_False;
2233 
2234 	MapMode aMapMode( pModel->GetScaleUnit() );
2235 	aObjAreaSize = xObjRef.GetSize( &aMapMode );
2236 
2237 	Size aSize = aRect.GetSize();
2238 	aScaleWidth = Fraction(aSize.Width(),  aObjAreaSize.Width() );
2239 	aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
2240 
2241 	// reduce to 10 binary digits
2242 	Kuerzen(aScaleHeight, 10);
2243 	Kuerzen(aScaleWidth,  10);
2244 
2245 	return sal_True;
2246 }
2247 
2248 // -----------------------------------------------------------------------------
2249 sal_Bool SdrOle2Obj::AddOwnLightClient()
2250 {
2251 	// The Own Light Client must be registered in object only using this method!
2252     if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() )
2253       && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) )
2254     {
2255 	    Connect();
2256 
2257 	    if ( xObjRef.is() && mpImpl->pLightClient )
2258 	    {
2259 		    Fraction aScaleWidth;
2260 		    Fraction aScaleHeight;
2261 		    Size aObjAreaSize;
2262 		    if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
2263 		    {
2264 			    mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
2265 			    try {
2266 				    xObjRef->setClientSite( mpImpl->pLightClient );
2267 				    return sal_True;
2268 			    } catch( uno::Exception& )
2269 			    {}
2270 		    }
2271 
2272 	    }
2273 
2274     	return sal_False;
2275     }
2276 
2277    	return sal_True;
2278 }
2279 
2280 //////////////////////////////////////////////////////////////////////////////
2281 
2282 Bitmap SdrOle2Obj::GetEmtyOLEReplacementBitmap()
2283 {
2284 	return Bitmap(ResId(BMP_SVXOLEOBJ, *ImpGetResMgr()));
2285 }
2286 
2287 //////////////////////////////////////////////////////////////////////////////
2288 
2289 void SdrOle2Obj::SetWindow(const com::sun::star::uno::Reference < com::sun::star::awt::XWindow >& _xWindow)
2290 {
2291     if ( xObjRef.is() && mpImpl->pLightClient )
2292     {
2293         mpImpl->pLightClient->setWindow(_xWindow);
2294     }
2295 }
2296 
2297 //////////////////////////////////////////////////////////////////////////////
2298 // eof
2299