Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/embed/EmbedStates.hpp>
21 : #include <com/sun/star/embed/XVisualObject.hpp>
22 : #include <com/sun/star/embed/XEmbeddedClient.hpp>
23 : #include <com/sun/star/embed/XInplaceClient.hpp>
24 : #include <com/sun/star/embed/XInplaceObject.hpp>
25 : #include <com/sun/star/embed/XComponentSupplier.hpp>
26 : #include <com/sun/star/embed/XWindowSupplier.hpp>
27 : #include <com/sun/star/embed/XEmbedPersist.hpp>
28 : #include <com/sun/star/embed/EmbedVerbs.hpp>
29 : #include <com/sun/star/container/XChild.hpp>
30 : #include <com/sun/star/beans/XPropertySet.hpp>
31 : #include <com/sun/star/beans/PropertyValue.hpp>
32 : #include <com/sun/star/embed/XStateChangeListener.hpp>
33 : #include <com/sun/star/embed/StateChangeInProgressException.hpp>
34 : #include <com/sun/star/embed/XLinkageSupport.hpp>
35 : #include <com/sun/star/lang/XInitialization.hpp>
36 : #include <com/sun/star/task/ErrorCodeIOException.hpp>
37 : #include <com/sun/star/task/StatusIndicatorFactory.hpp>
38 : #include <com/sun/star/task/XStatusIndicator.hpp>
39 :
40 : #include <com/sun/star/embed/EmbedMisc.hpp>
41 : #include <svtools/embedhlp.hxx>
42 : #include <vcl/svapp.hxx>
43 :
44 : #include <sfx2/ipclient.hxx>
45 : #include <sfx2/viewsh.hxx>
46 : #include <sfx2/viewfrm.hxx>
47 : #include <sfx2/objsh.hxx>
48 : #include <sfx2/dispatch.hxx>
49 : #include "workwin.hxx"
50 : #include "guisaveas.hxx"
51 : #include <cppuhelper/implbase5.hxx>
52 : #include <svtools/ehdl.hxx>
53 :
54 : #include <vcl/timer.hxx>
55 : #include <vcl/window.hxx>
56 : #include <toolkit/awt/vclxwindow.hxx>
57 : #include <toolkit/helper/vclunohelper.hxx>
58 : #include <toolkit/helper/convert.hxx>
59 : #include <tools/fract.hxx>
60 : #include <tools/gen.hxx>
61 : #include <svl/rectitem.hxx>
62 : #include <svtools/soerr.hxx>
63 : #include <comphelper/processfactory.hxx>
64 :
65 : #define SFX_CLIENTACTIVATE_TIMEOUT 100
66 :
67 : using namespace com::sun::star;
68 :
69 :
70 : // SfxEmbedResizeGuard
71 : class SfxBooleanFlagGuard
72 : {
73 : bool& m_rFlag;
74 : bool m_bLifeValue;
75 : public:
76 0 : SfxBooleanFlagGuard( bool& bFlag, bool bLifeValue )
77 : : m_rFlag( bFlag )
78 0 : , m_bLifeValue( bLifeValue )
79 : {
80 0 : m_rFlag = m_bLifeValue;
81 0 : }
82 :
83 0 : ~SfxBooleanFlagGuard()
84 : {
85 0 : m_rFlag = !m_bLifeValue;
86 0 : }
87 : };
88 :
89 :
90 : // SfxInPlaceClient_Impl
91 :
92 :
93 : class SfxInPlaceClient_Impl : public ::cppu::WeakImplHelper5< embed::XEmbeddedClient,
94 : embed::XInplaceClient,
95 : document::XEventListener,
96 : embed::XStateChangeListener,
97 : embed::XWindowSupplier >
98 : {
99 : public:
100 : Timer m_aTimer; // activation timeout, starts after object connection
101 : Rectangle m_aObjArea; // area of object in coordinate system of the container (without scaling)
102 : Fraction m_aScaleWidth; // scaling that was applied to the object when it was not active
103 : Fraction m_aScaleHeight;
104 : SfxInPlaceClient* m_pClient;
105 : sal_Int64 m_nAspect; // ViewAspect that is assigned from the container
106 : Rectangle m_aLastObjAreaPixel; // area of object in coordinate system of the container (without scaling)
107 : bool m_bStoreObject;
108 : bool m_bUIActive; // set and cleared when notification for UI (de)activation is sent
109 : bool m_bResizeNoScale;
110 :
111 : uno::Reference < embed::XEmbeddedObject > m_xObject;
112 : uno::Reference < embed::XEmbeddedClient > m_xClient;
113 :
114 :
115 8 : SfxInPlaceClient_Impl()
116 : : m_pClient( NULL )
117 : , m_nAspect( 0 )
118 : , m_bStoreObject( true )
119 : , m_bUIActive( false )
120 8 : , m_bResizeNoScale( false )
121 8 : {}
122 :
123 : virtual ~SfxInPlaceClient_Impl();
124 :
125 : void SizeHasChanged();
126 : DECL_LINK_TYPED(TimerHdl, Timer *, void);
127 : uno::Reference < frame::XFrame > GetFrame() const;
128 :
129 : // XEmbeddedClient
130 : virtual void SAL_CALL saveObject() throw ( embed::ObjectSaveVetoException, uno::Exception, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
131 : virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
132 :
133 : // XInplaceClient
134 : virtual sal_Bool SAL_CALL canInplaceActivate() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
135 : virtual void SAL_CALL activatingInplace() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
136 : virtual void SAL_CALL activatingUI() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
137 : virtual void SAL_CALL deactivatedInplace() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
138 : virtual void SAL_CALL deactivatedUI() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
139 : virtual uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL getLayoutManager() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
140 : virtual uno::Reference< frame::XDispatchProvider > SAL_CALL getInplaceDispatchProvider() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
141 : virtual awt::Rectangle SAL_CALL getPlacement() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
142 : virtual awt::Rectangle SAL_CALL getClipRectangle() throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
143 : virtual void SAL_CALL translateAccelerators( const uno::Sequence< awt::KeyEvent >& aKeys ) throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
144 : virtual void SAL_CALL scrollObject( const awt::Size& aOffset ) throw ( embed::WrongStateException, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
145 : virtual void SAL_CALL changedPlacement( const awt::Rectangle& aPosRect ) throw ( embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception ) SAL_OVERRIDE;
146 :
147 : // XComponentSupplier
148 : virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
149 :
150 : // XWindowSupplier
151 : virtual uno::Reference< awt::XWindow > SAL_CALL getWindow() throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
152 :
153 : // document::XEventListener
154 : virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
155 :
156 : // XStateChangeListener
157 : 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, std::exception) SAL_OVERRIDE;
158 : virtual void SAL_CALL stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : };
161 :
162 16 : SfxInPlaceClient_Impl::~SfxInPlaceClient_Impl()
163 : {
164 16 : }
165 :
166 2 : void SAL_CALL SfxInPlaceClient_Impl::changingState(
167 : const ::com::sun::star::lang::EventObject& /*aEvent*/,
168 : ::sal_Int32 /*nOldState*/,
169 : ::sal_Int32 /*nNewState*/ )
170 : throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException, std::exception)
171 : {
172 2 : }
173 :
174 2 : void SAL_CALL SfxInPlaceClient_Impl::stateChanged(
175 : const ::com::sun::star::lang::EventObject& /*aEvent*/,
176 : ::sal_Int32 nOldState,
177 : ::sal_Int32 nNewState )
178 : throw (::com::sun::star::uno::RuntimeException, std::exception)
179 : {
180 2 : if ( m_pClient && nOldState != embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
181 : {
182 : // deactivation of object
183 1 : uno::Reference< frame::XModel > xDocument;
184 1 : if ( m_pClient->GetViewShell()->GetObjectShell() )
185 1 : xDocument = m_pClient->GetViewShell()->GetObjectShell()->GetModel();
186 1 : SfxObjectShell::SetCurrentComponent( xDocument );
187 : }
188 2 : }
189 :
190 22 : void SAL_CALL SfxInPlaceClient_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException, std::exception )
191 : {
192 22 : SolarMutexGuard aGuard;
193 :
194 22 : if ( m_pClient && aEvent.EventName == "OnVisAreaChanged" && m_nAspect != embed::Aspects::MSOLE_ICON )
195 : {
196 8 : m_pClient->FormatChanged(); // for Writer when format of the object is changed with the area
197 8 : m_pClient->ViewChanged();
198 8 : m_pClient->Invalidate();
199 22 : }
200 22 : }
201 :
202 0 : void SAL_CALL SfxInPlaceClient_Impl::disposing( const ::com::sun::star::lang::EventObject& /*aEvent*/ )
203 : throw (::com::sun::star::uno::RuntimeException, std::exception)
204 : {
205 0 : DELETEZ( m_pClient );
206 0 : }
207 :
208 : // XEmbeddedClient
209 :
210 4 : uno::Reference < frame::XFrame > SfxInPlaceClient_Impl::GetFrame() const
211 : {
212 4 : if ( !m_pClient )
213 0 : throw uno::RuntimeException();
214 4 : return m_pClient->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
215 : }
216 :
217 1 : void SAL_CALL SfxInPlaceClient_Impl::saveObject()
218 : throw ( embed::ObjectSaveVetoException,
219 : uno::Exception,
220 : uno::RuntimeException, std::exception )
221 : {
222 1 : if ( !m_bStoreObject )
223 : // client wants to discard the object (usually it means the container document is closed while an object is active
224 : // and the user didn't request saving the changes
225 2 : return;
226 :
227 : // the common persistence is supported by objects and links
228 0 : uno::Reference< embed::XCommonEmbedPersist > xPersist( m_xObject, uno::UNO_QUERY );
229 0 : if ( !xPersist.is() )
230 0 : throw uno::RuntimeException();
231 :
232 0 : uno::Reference< frame::XFrame > xFrame;
233 0 : uno::Reference< task::XStatusIndicator > xStatusIndicator;
234 0 : uno::Reference< frame::XModel > xModel( m_xObject->getComponent(), uno::UNO_QUERY );
235 0 : uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
236 :
237 0 : if ( xModel.is() )
238 : {
239 0 : uno::Reference< frame::XController > xController = xModel->getCurrentController();
240 0 : if ( xController.is() )
241 0 : xFrame = xController->getFrame();
242 : }
243 :
244 0 : if ( xFrame.is() )
245 : {
246 : // set non-reschedule progress to prevent problems when asynchronous calls are made
247 : // during storing of the embedded object
248 : uno::Reference< task::XStatusIndicatorFactory > xStatusIndicatorFactory =
249 0 : task::StatusIndicatorFactory::createWithFrame( xContext, xFrame, sal_True/*DisableReschedule*/, sal_False/*AllowParentShow*/ );
250 :
251 0 : uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
252 0 : if ( xPropSet.is() )
253 : {
254 : try
255 : {
256 0 : xStatusIndicator = xStatusIndicatorFactory->createStatusIndicator();
257 0 : xPropSet->setPropertyValue( "IndicatorInterception" , uno::makeAny( xStatusIndicator ));
258 : }
259 0 : catch ( const uno::RuntimeException& )
260 : {
261 0 : throw;
262 : }
263 0 : catch ( uno::Exception& )
264 : {
265 : }
266 0 : }
267 : }
268 :
269 : try
270 : {
271 0 : xPersist->storeOwn();
272 0 : m_xObject->update();
273 : }
274 0 : catch ( uno::Exception& )
275 : {
276 : //TODO/LATER: what should happen if object can't be saved?!
277 : }
278 :
279 : // reset status indicator interception after storing
280 : try
281 : {
282 0 : uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
283 0 : if ( xPropSet.is() )
284 : {
285 0 : xStatusIndicator.clear();
286 0 : xPropSet->setPropertyValue( "IndicatorInterception" , uno::makeAny( xStatusIndicator ));
287 0 : }
288 : }
289 0 : catch ( const uno::RuntimeException& )
290 : {
291 0 : throw;
292 : }
293 0 : catch ( uno::Exception& )
294 : {
295 : }
296 :
297 : // the client can exist only in case there is a view shell
298 0 : if ( !m_pClient || !m_pClient->GetViewShell() )
299 0 : throw uno::RuntimeException();
300 :
301 0 : SfxObjectShell* pDocShell = m_pClient->GetViewShell()->GetObjectShell();
302 0 : if ( !pDocShell )
303 0 : throw uno::RuntimeException();
304 :
305 0 : pDocShell->SetModified( true );
306 :
307 : //TODO/LATER: invalidation might be necessary when object was modified, but is not
308 : //saved through this method
309 : // m_pClient->Invalidate();
310 : }
311 :
312 :
313 2 : void SAL_CALL SfxInPlaceClient_Impl::visibilityChanged( sal_Bool bVisible )
314 : throw ( embed::WrongStateException,
315 : uno::RuntimeException, std::exception )
316 : {
317 2 : SolarMutexGuard aGuard;
318 :
319 2 : if ( !m_pClient || !m_pClient->GetViewShell() )
320 0 : throw uno::RuntimeException();
321 :
322 2 : m_pClient->GetViewShell()->OutplaceActivated( bVisible, m_pClient );
323 2 : m_pClient->Invalidate();
324 2 : }
325 :
326 :
327 : // XInplaceClient
328 :
329 1 : sal_Bool SAL_CALL SfxInPlaceClient_Impl::canInplaceActivate()
330 : throw ( uno::RuntimeException, std::exception )
331 : {
332 1 : if ( !m_xObject.is() )
333 0 : throw uno::RuntimeException();
334 :
335 : // we don't want to switch directly from outplace to inplace mode
336 1 : if ( m_xObject->getCurrentState() == embed::EmbedStates::ACTIVE || m_nAspect == embed::Aspects::MSOLE_ICON )
337 0 : return sal_False;
338 :
339 1 : return sal_True;
340 : }
341 :
342 :
343 1 : void SAL_CALL SfxInPlaceClient_Impl::activatingInplace()
344 : throw ( embed::WrongStateException,
345 : uno::RuntimeException, std::exception )
346 : {
347 1 : if ( !m_pClient || !m_pClient->GetViewShell() )
348 0 : throw uno::RuntimeException();
349 1 : }
350 :
351 :
352 1 : void SAL_CALL SfxInPlaceClient_Impl::activatingUI()
353 : throw ( embed::WrongStateException,
354 : uno::RuntimeException, std::exception )
355 : {
356 1 : if ( !m_pClient || !m_pClient->GetViewShell() )
357 0 : throw uno::RuntimeException();
358 :
359 1 : m_pClient->GetViewShell()->ResetAllClients_Impl(m_pClient);
360 1 : m_bUIActive = true;
361 1 : m_pClient->GetViewShell()->UIActivating( m_pClient );
362 1 : }
363 :
364 :
365 1 : void SAL_CALL SfxInPlaceClient_Impl::deactivatedInplace()
366 : throw ( embed::WrongStateException,
367 : uno::RuntimeException, std::exception )
368 : {
369 1 : if ( !m_pClient || !m_pClient->GetViewShell() )
370 0 : throw uno::RuntimeException();
371 1 : }
372 :
373 :
374 1 : void SAL_CALL SfxInPlaceClient_Impl::deactivatedUI()
375 : throw ( embed::WrongStateException,
376 : uno::RuntimeException, std::exception )
377 : {
378 1 : if ( !m_pClient || !m_pClient->GetViewShell() )
379 0 : throw uno::RuntimeException();
380 :
381 1 : m_pClient->GetViewShell()->UIDeactivated( m_pClient );
382 1 : m_bUIActive = false;
383 1 : }
384 :
385 :
386 2 : uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL SfxInPlaceClient_Impl::getLayoutManager()
387 : throw ( embed::WrongStateException,
388 : uno::RuntimeException, std::exception )
389 : {
390 2 : uno::Reference < beans::XPropertySet > xFrame( GetFrame(), uno::UNO_QUERY );
391 2 : if ( !xFrame.is() )
392 0 : throw uno::RuntimeException();
393 :
394 2 : uno::Reference< ::com::sun::star::frame::XLayoutManager > xMan;
395 : try
396 : {
397 2 : uno::Any aAny = xFrame->getPropertyValue( "LayoutManager" );
398 2 : aAny >>= xMan;
399 : }
400 0 : catch ( uno::Exception& )
401 : {
402 0 : throw uno::RuntimeException();
403 : }
404 :
405 2 : return xMan;
406 : }
407 :
408 :
409 2 : uno::Reference< frame::XDispatchProvider > SAL_CALL SfxInPlaceClient_Impl::getInplaceDispatchProvider()
410 : throw ( embed::WrongStateException,
411 : uno::RuntimeException, std::exception )
412 : {
413 2 : return uno::Reference < frame::XDispatchProvider >( GetFrame(), uno::UNO_QUERY_THROW );
414 : }
415 :
416 :
417 2 : awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getPlacement()
418 : throw ( embed::WrongStateException,
419 : uno::RuntimeException, std::exception )
420 : {
421 2 : if ( !m_pClient || !m_pClient->GetViewShell() )
422 0 : throw uno::RuntimeException();
423 :
424 : // apply scaling to object area and convert to pixels
425 2 : Rectangle aRealObjArea( m_aObjArea );
426 4 : aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_aScaleWidth,
427 6 : Fraction( aRealObjArea.GetHeight() ) * m_aScaleHeight ) );
428 :
429 2 : aRealObjArea = m_pClient->GetEditWin()->LogicToPixel( aRealObjArea );
430 2 : return AWTRectangle( aRealObjArea );
431 : }
432 :
433 :
434 2 : awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getClipRectangle()
435 : throw ( embed::WrongStateException,
436 : uno::RuntimeException, std::exception )
437 : {
438 2 : if ( !m_pClient || !m_pClient->GetViewShell() )
439 0 : throw uno::RuntimeException();
440 :
441 : // currently(?) same as placement
442 2 : Rectangle aRealObjArea( m_aObjArea );
443 4 : aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_aScaleWidth,
444 6 : Fraction( aRealObjArea.GetHeight() ) * m_aScaleHeight ) );
445 :
446 2 : aRealObjArea = m_pClient->GetEditWin()->LogicToPixel( aRealObjArea );
447 2 : return AWTRectangle( aRealObjArea );
448 : }
449 :
450 :
451 0 : void SAL_CALL SfxInPlaceClient_Impl::translateAccelerators( const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
452 : throw ( embed::WrongStateException,
453 : uno::RuntimeException, std::exception )
454 : {
455 0 : if ( !m_pClient || !m_pClient->GetViewShell() )
456 0 : throw uno::RuntimeException();
457 :
458 : // TODO/MBA: keyboard accelerators
459 0 : }
460 :
461 :
462 0 : void SAL_CALL SfxInPlaceClient_Impl::scrollObject( const awt::Size& /*aOffset*/ )
463 : throw ( embed::WrongStateException,
464 : uno::RuntimeException, std::exception )
465 : {
466 0 : if ( !m_pClient || !m_pClient->GetViewShell() )
467 0 : throw uno::RuntimeException();
468 0 : }
469 :
470 :
471 0 : void SAL_CALL SfxInPlaceClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
472 : throw ( embed::WrongStateException,
473 : uno::Exception,
474 : uno::RuntimeException, std::exception )
475 : {
476 0 : uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY );
477 0 : if ( !xInplace.is() || !m_pClient || !m_pClient->GetEditWin() || !m_pClient->GetViewShell() )
478 0 : throw uno::RuntimeException();
479 :
480 : // check if the change is at least one pixel in size
481 0 : awt::Rectangle aOldRect = getPlacement();
482 0 : Rectangle aNewPixelRect = VCLRectangle( aPosRect );
483 0 : Rectangle aOldPixelRect = VCLRectangle( aOldRect );
484 0 : if ( aOldPixelRect == aNewPixelRect )
485 : // nothing has changed
486 0 : return;
487 :
488 : // new scaled object area
489 0 : Rectangle aNewLogicRect = m_pClient->GetEditWin()->PixelToLogic( aNewPixelRect );
490 :
491 : // all the size changes in this method should happen without scaling
492 : // SfxBooleanFlagGuard aGuard( m_bResizeNoScale, sal_True );
493 :
494 : // allow container to apply restrictions on the requested new area;
495 : // the container might change the object view during size calculation;
496 : // currently only writer does it
497 0 : m_pClient->RequestNewObjectArea( aNewLogicRect);
498 :
499 0 : if ( aNewLogicRect != m_pClient->GetScaledObjArea() )
500 : {
501 : // the calculation of the object area has not changed the object size
502 : // it should be done here then
503 0 : SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true );
504 :
505 : // new size of the object area without scaling
506 0 : Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth,
507 0 : Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight );
508 :
509 : // now remove scaling from new placement and keep this a the new object area
510 0 : aNewLogicRect.SetSize( aNewObjSize );
511 0 : m_aObjArea = aNewLogicRect;
512 :
513 : // let the window size be recalculated
514 0 : SizeHasChanged();
515 : }
516 :
517 : // notify container view about changes
518 0 : m_pClient->ObjectAreaChanged();
519 : }
520 :
521 : // XComponentSupplier
522 :
523 1 : uno::Reference< util::XCloseable > SAL_CALL SfxInPlaceClient_Impl::getComponent()
524 : throw ( uno::RuntimeException, std::exception )
525 : {
526 1 : if ( !m_pClient || !m_pClient->GetViewShell() )
527 0 : throw uno::RuntimeException();
528 :
529 1 : SfxObjectShell* pDocShell = m_pClient->GetViewShell()->GetObjectShell();
530 1 : if ( !pDocShell )
531 0 : throw uno::RuntimeException();
532 :
533 : // all the components must implement XCloseable
534 1 : uno::Reference< util::XCloseable > xComp( pDocShell->GetModel(), uno::UNO_QUERY );
535 1 : if ( !xComp.is() )
536 0 : throw uno::RuntimeException();
537 :
538 1 : return xComp;
539 : }
540 :
541 :
542 : // XWindowSupplier
543 :
544 1 : uno::Reference< awt::XWindow > SAL_CALL SfxInPlaceClient_Impl::getWindow()
545 : throw ( uno::RuntimeException, std::exception )
546 : {
547 1 : if ( !m_pClient || !m_pClient->GetEditWin() )
548 0 : throw uno::RuntimeException();
549 :
550 1 : uno::Reference< awt::XWindow > xWin( m_pClient->GetEditWin()->GetComponentInterface(), uno::UNO_QUERY );
551 1 : return xWin;
552 : }
553 :
554 :
555 : // notification to the client implementation that either the object area or the scaling has been changed
556 : // as a result the logical size of the window has changed also
557 8 : void SfxInPlaceClient_Impl::SizeHasChanged()
558 : {
559 8 : if ( !m_pClient || !m_pClient->GetViewShell() )
560 0 : throw uno::RuntimeException();
561 :
562 : try {
563 16 : if ( m_xObject.is()
564 9 : && ( m_xObject->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
565 7 : || m_xObject->getCurrentState() == embed::EmbedStates::UI_ACTIVE ) )
566 : {
567 : // only possible in active states
568 1 : uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY );
569 1 : if ( !xInplace.is() )
570 0 : throw uno::RuntimeException();
571 :
572 1 : if ( m_bResizeNoScale )
573 : {
574 : // the resizing should be done without scaling
575 : // set the correct size to the object to avoid the scaling
576 0 : MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( m_xObject->getMapUnit( m_nAspect ) ) );
577 0 : MapMode aClientMap( m_pClient->GetEditWin()->GetMapMode().GetMapUnit() );
578 :
579 : // convert to logical coordinates of the embedded object
580 0 : Size aNewSize = m_pClient->GetEditWin()->LogicToLogic( m_aObjArea.GetSize(), &aClientMap, &aObjectMap );
581 0 : m_xObject->setVisualAreaSize( m_nAspect, awt::Size( aNewSize.Width(), aNewSize.Height() ) );
582 : }
583 :
584 1 : xInplace->setObjectRectangles( getPlacement(), getClipRectangle() );
585 : }
586 : }
587 0 : catch( uno::Exception& )
588 : {
589 : // TODO/LATER: handle error
590 : }
591 8 : }
592 :
593 :
594 2 : IMPL_LINK_NOARG_TYPED(SfxInPlaceClient_Impl, TimerHdl, Timer *, void)
595 : {
596 1 : if ( m_pClient && m_xObject.is() )
597 1 : m_pClient->GetViewShell()->CheckIPClient_Impl( m_pClient, m_pClient->GetViewShell()->GetObjectShell()->GetVisArea() );
598 1 : }
599 :
600 :
601 :
602 : // SfxInPlaceClient
603 :
604 :
605 8 : SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, vcl::Window *pDraw, sal_Int64 nAspect ) :
606 8 : m_pImp( new SfxInPlaceClient_Impl ),
607 : m_pViewSh( pViewShell ),
608 16 : m_pEditWin( pDraw )
609 : {
610 8 : m_pImp->acquire();
611 8 : m_pImp->m_pClient = this;
612 8 : m_pImp->m_nAspect = nAspect;
613 8 : m_pImp->m_aScaleWidth = m_pImp->m_aScaleHeight = Fraction(1,1);
614 8 : m_pImp->m_xClient = static_cast< embed::XEmbeddedClient* >( m_pImp );
615 8 : pViewShell->NewIPClient_Impl(this);
616 8 : m_pImp->m_aTimer.SetTimeout( SFX_CLIENTACTIVATE_TIMEOUT );
617 8 : m_pImp->m_aTimer.SetTimeoutHdl( LINK( m_pImp, SfxInPlaceClient_Impl, TimerHdl ) );
618 8 : }
619 :
620 :
621 :
622 16 : SfxInPlaceClient::~SfxInPlaceClient()
623 : {
624 8 : m_pViewSh->IPClientGone_Impl(this);
625 :
626 : // deleting the client before storing the object means discarding all changes
627 8 : m_pImp->m_bStoreObject = false;
628 8 : SetObject(0);
629 :
630 8 : m_pImp->m_pClient = NULL;
631 :
632 : // the next call will destroy m_pImp if no other reference to it exists
633 8 : m_pImp->m_xClient = uno::Reference < embed::XEmbeddedClient >();
634 8 : m_pImp->release();
635 :
636 : // TODO/LATER:
637 : // the class is not intended to be used in multithreaded environment;
638 : // if it will this disconnection and all the parts that use the m_pClient
639 : // must be guarded with mutex
640 8 : }
641 :
642 :
643 8 : void SfxInPlaceClient::SetObjectState( sal_Int32 nState )
644 : {
645 8 : if ( GetObject().is() )
646 : {
647 8 : if ( m_pImp->m_nAspect == embed::Aspects::MSOLE_ICON
648 0 : && ( nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::INPLACE_ACTIVE ) )
649 : {
650 : OSL_FAIL( "Iconified object should not be activated inplace!\n" );
651 8 : return;
652 : }
653 :
654 : try
655 : {
656 8 : GetObject()->changeState( nState );
657 : }
658 0 : catch ( uno::Exception& )
659 : {}
660 : }
661 : }
662 :
663 :
664 2 : sal_Int64 SfxInPlaceClient::GetObjectMiscStatus() const
665 : {
666 2 : if ( GetObject().is() )
667 2 : return GetObject()->getStatus( m_pImp->m_nAspect );
668 0 : return 0;
669 : }
670 :
671 :
672 123 : uno::Reference < embed::XEmbeddedObject > SfxInPlaceClient::GetObject() const
673 : {
674 123 : return m_pImp->m_xObject;
675 : }
676 :
677 :
678 16 : void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject >& rObject )
679 : {
680 16 : if ( m_pImp->m_xObject.is() && rObject != m_pImp->m_xObject )
681 : {
682 : DBG_ASSERT( GetObject()->getClientSite() == m_pImp->m_xClient, "Wrong ClientSite!" );
683 8 : if ( GetObject()->getClientSite() == m_pImp->m_xClient )
684 : {
685 8 : if ( GetObject()->getCurrentState() != embed::EmbedStates::LOADED )
686 8 : SetObjectState( embed::EmbedStates::RUNNING );
687 8 : m_pImp->m_xObject->removeEventListener( uno::Reference < document::XEventListener >( m_pImp->m_xClient, uno::UNO_QUERY ) );
688 8 : m_pImp->m_xObject->removeStateChangeListener( uno::Reference < embed::XStateChangeListener >( m_pImp->m_xClient, uno::UNO_QUERY ) );
689 : try
690 : {
691 8 : m_pImp->m_xObject->setClientSite( 0 );
692 : }
693 0 : catch( uno::Exception& )
694 : {
695 : OSL_FAIL( "Can not clean the client site!\n" );
696 : }
697 : }
698 : }
699 :
700 16 : if ( m_pViewSh->GetViewFrame()->GetFrame().IsClosing_Impl() )
701 : // sometimes applications reconnect clients on shutting down because it happens in their Paint methods
702 24 : return;
703 :
704 8 : m_pImp->m_xObject = rObject;
705 :
706 8 : if ( rObject.is() )
707 : {
708 : // as soon as an object was connected to a client it has to be checked whether the object wants
709 : // to be activated
710 8 : rObject->addStateChangeListener( uno::Reference < embed::XStateChangeListener >( m_pImp->m_xClient, uno::UNO_QUERY ) );
711 8 : rObject->addEventListener( uno::Reference < document::XEventListener >( m_pImp->m_xClient, uno::UNO_QUERY ) );
712 :
713 : try
714 : {
715 8 : rObject->setClientSite( m_pImp->m_xClient );
716 : }
717 0 : catch( uno::Exception& )
718 : {
719 : OSL_FAIL( "Can not set the client site!\n" );
720 : }
721 :
722 8 : m_pImp->m_aTimer.Start();
723 : }
724 : else
725 0 : m_pImp->m_aTimer.Stop();
726 : }
727 :
728 :
729 0 : bool SfxInPlaceClient::SetObjArea( const Rectangle& rArea )
730 : {
731 0 : if( rArea != m_pImp->m_aObjArea )
732 : {
733 0 : m_pImp->m_aObjArea = rArea;
734 0 : m_pImp->SizeHasChanged();
735 :
736 0 : Invalidate();
737 0 : return true;
738 : }
739 :
740 0 : return false;
741 : }
742 :
743 :
744 0 : Rectangle SfxInPlaceClient::GetObjArea() const
745 : {
746 0 : return m_pImp->m_aObjArea;
747 : }
748 :
749 0 : Rectangle SfxInPlaceClient::GetScaledObjArea() const
750 : {
751 0 : Rectangle aRealObjArea( m_pImp->m_aObjArea );
752 0 : aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_pImp->m_aScaleWidth,
753 0 : Fraction( aRealObjArea.GetHeight() ) * m_pImp->m_aScaleHeight ) );
754 0 : return aRealObjArea;
755 : }
756 :
757 :
758 0 : void SfxInPlaceClient::SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight )
759 : {
760 0 : if ( m_pImp->m_aScaleWidth != rScaleWidth || m_pImp->m_aScaleHeight != rScaleHeight )
761 : {
762 0 : m_pImp->m_aScaleWidth = rScaleWidth;
763 0 : m_pImp->m_aScaleHeight = rScaleHeight;
764 :
765 0 : m_pImp->SizeHasChanged();
766 :
767 : // TODO/LATER: Invalidate seems to trigger (wrong) recalculations of the ObjArea, so it's better
768 : // not to call it here, but maybe it sounds reasonable to do so.
769 : //Invalidate();
770 : }
771 0 : }
772 :
773 :
774 7 : bool SfxInPlaceClient::SetObjAreaAndScale( const Rectangle& rArea, const Fraction& rScaleWidth, const Fraction& rScaleHeight )
775 : {
776 7 : if( rArea != m_pImp->m_aObjArea || m_pImp->m_aScaleWidth != rScaleWidth || m_pImp->m_aScaleHeight != rScaleHeight )
777 : {
778 7 : m_pImp->m_aObjArea = rArea;
779 7 : m_pImp->m_aScaleWidth = rScaleWidth;
780 7 : m_pImp->m_aScaleHeight = rScaleHeight;
781 :
782 7 : m_pImp->SizeHasChanged();
783 :
784 7 : Invalidate();
785 7 : return true;
786 : }
787 :
788 0 : return false;
789 : }
790 :
791 :
792 30 : const Fraction& SfxInPlaceClient::GetScaleWidth() const
793 : {
794 30 : return m_pImp->m_aScaleWidth;
795 : }
796 :
797 :
798 30 : const Fraction& SfxInPlaceClient::GetScaleHeight() const
799 : {
800 30 : return m_pImp->m_aScaleHeight;
801 : }
802 :
803 :
804 17 : void SfxInPlaceClient::Invalidate()
805 : {
806 : // TODO/LATER: do we need both?
807 :
808 : // the object area is provided in logical coordinates of the window but without scaling applied
809 17 : Rectangle aRealObjArea( m_pImp->m_aObjArea );
810 34 : aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_pImp->m_aScaleWidth,
811 51 : Fraction( aRealObjArea.GetHeight() ) * m_pImp->m_aScaleHeight ) );
812 17 : m_pEditWin->Invalidate( aRealObjArea );
813 :
814 17 : ViewChanged();
815 17 : }
816 :
817 :
818 74 : bool SfxInPlaceClient::IsObjectUIActive() const
819 : {
820 : try {
821 74 : return ( m_pImp->m_xObject.is() && ( m_pImp->m_xObject->getCurrentState() == embed::EmbedStates::UI_ACTIVE ) );
822 : }
823 0 : catch( uno::Exception& )
824 : {}
825 :
826 0 : return false;
827 : }
828 :
829 :
830 7 : bool SfxInPlaceClient::IsObjectInPlaceActive() const
831 : {
832 : try {
833 : return(
834 : (
835 14 : m_pImp->m_xObject.is() &&
836 7 : (m_pImp->m_xObject->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE)
837 14 : ) ||
838 : (
839 12 : m_pImp->m_xObject.is() &&
840 6 : (m_pImp->m_xObject->getCurrentState() == embed::EmbedStates::UI_ACTIVE)
841 : )
842 7 : );
843 : }
844 0 : catch( uno::Exception& )
845 : {}
846 :
847 0 : return false;
848 : }
849 :
850 :
851 292 : SfxInPlaceClient* SfxInPlaceClient::GetClient( SfxObjectShell* pDoc, const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& xObject )
852 : {
853 328 : for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst(pDoc); pFrame; pFrame=SfxViewFrame::GetNext(*pFrame,pDoc) )
854 : {
855 36 : if( pFrame->GetViewShell() )
856 : {
857 36 : SfxInPlaceClient* pClient = pFrame->GetViewShell()->FindIPClient( xObject, NULL );
858 36 : if ( pClient )
859 0 : return pClient;
860 : }
861 : }
862 :
863 292 : return NULL;
864 : }
865 :
866 69 : sal_Int64 SfxInPlaceClient::GetAspect() const
867 : {
868 69 : return m_pImp->m_nAspect;
869 : }
870 :
871 0 : ErrCode SfxInPlaceClient::DoVerb( long nVerb )
872 : {
873 0 : SfxErrorContext aEc( ERRCTX_SO_DOVERB, m_pViewSh->GetWindow(), RID_SO_ERRCTX );
874 0 : ErrCode nError = ERRCODE_NONE;
875 :
876 0 : if ( m_pImp->m_xObject.is() )
877 : {
878 0 : bool bSaveCopyAs = false;
879 0 : if ( nVerb == -8 ) // "Save Copy as..."
880 : {
881 0 : svt::EmbeddedObjectRef::TryRunningState( m_pImp->m_xObject );
882 : // TODO/LATER: this special verb should disappear when outplace activation is completely available
883 0 : uno::Reference< frame::XModel > xEmbModel( m_pImp->m_xObject->getComponent(), uno::UNO_QUERY );
884 0 : if ( xEmbModel.is() )
885 : {
886 0 : bSaveCopyAs = true;
887 :
888 : try
889 : {
890 0 : SfxStoringHelper aHelper;
891 0 : uno::Sequence< beans::PropertyValue > aDispatchArgs( 1 );
892 0 : aDispatchArgs[0].Name = "SaveTo";
893 0 : aDispatchArgs[0].Value <<= true;
894 :
895 : aHelper.GUIStoreModel( xEmbModel,
896 : "SaveAs",
897 : aDispatchArgs,
898 : false,
899 0 : "" );
900 : }
901 0 : catch( const task::ErrorCodeIOException& aErrorEx )
902 : {
903 0 : nError = (sal_uInt32)aErrorEx.ErrCode;
904 : }
905 0 : catch( uno::Exception& )
906 : {
907 0 : nError = ERRCODE_IO_GENERAL;
908 : // TODO/LATER: better error handling
909 : }
910 0 : }
911 : }
912 :
913 0 : if ( !bSaveCopyAs )
914 : {
915 0 : if ( m_pImp->m_nAspect == embed::Aspects::MSOLE_ICON )
916 : {
917 0 : if ( nVerb == embed::EmbedVerbs::MS_OLEVERB_PRIMARY || nVerb == embed::EmbedVerbs::MS_OLEVERB_SHOW )
918 0 : nVerb = embed::EmbedVerbs::MS_OLEVERB_OPEN; // outplace activation
919 0 : else if ( nVerb == embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE
920 0 : || nVerb == embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE )
921 0 : nError = ERRCODE_SO_GENERALERROR;
922 : }
923 :
924 0 : if ( !nError )
925 : {
926 :
927 0 : m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(true);
928 : try
929 : {
930 0 : m_pImp->m_xObject->setClientSite( m_pImp->m_xClient );
931 :
932 0 : m_pImp->m_xObject->doVerb( nVerb );
933 : }
934 0 : catch ( embed::UnreachableStateException& )
935 : {
936 0 : if ( nVerb == 0 || nVerb == embed::EmbedVerbs::MS_OLEVERB_OPEN )
937 : {
938 : // a workaround for the default verb, usually makes sense for alien objects
939 : try
940 : {
941 0 : m_pImp->m_xObject->doVerb( -9 ); // open own view, a workaround verb that is not visible
942 :
943 0 : if ( m_pImp->m_xObject->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
944 : {
945 : // the object was converted to OOo object
946 0 : awt::Size aSize = m_pImp->m_xObject->getVisualAreaSize( m_pImp->m_nAspect );
947 0 : MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( m_pImp->m_xObject->getMapUnit( m_pImp->m_nAspect ) ) );
948 0 : MapMode aClientMap( GetEditWin()->GetMapMode().GetMapUnit() );
949 0 : Size aNewSize = GetEditWin()->LogicToLogic( Size( aSize.Width, aSize.Height ), &aObjectMap, &aClientMap );
950 :
951 0 : Rectangle aScaledArea = GetScaledObjArea();
952 0 : m_pImp->m_aObjArea.SetSize( aNewSize );
953 0 : m_pImp->m_aScaleWidth = Fraction( aScaledArea.GetWidth(), aNewSize.Width() );
954 0 : m_pImp->m_aScaleHeight = Fraction( aScaledArea.GetHeight(), aNewSize.Height() );
955 : }
956 : }
957 0 : catch (uno::Exception const& e)
958 : {
959 : SAL_WARN("embeddedobj", "SfxInPlaceClient::DoVerb:"
960 : " -9 fallback path: exception caught: "
961 : << e.Message);
962 0 : nError = ERRCODE_SO_GENERALERROR;
963 : }
964 : }
965 : }
966 0 : catch ( embed::StateChangeInProgressException& )
967 : {
968 : // TODO/LATER: it would be nice to be able to provide the current target state outside
969 0 : nError = ERRCODE_SO_CANNOT_DOVERB_NOW;
970 : }
971 0 : catch (uno::Exception const& e)
972 : {
973 : SAL_WARN("embeddedobj", "SfxInPlaceClient::DoVerb:"
974 : " exception caught: " << e.Message);
975 0 : nError = ERRCODE_SO_GENERALERROR;
976 : //TODO/LATER: better error handling
977 : }
978 :
979 0 : SfxViewFrame* pFrame = m_pViewSh->GetViewFrame();
980 0 : pFrame->GetTopFrame().LockResize_Impl(false);
981 0 : pFrame->GetTopFrame().Resize();
982 : }
983 : }
984 : }
985 :
986 0 : if( nError )
987 0 : ErrorHandler::HandleError( nError );
988 :
989 0 : return nError;
990 : }
991 :
992 1 : void SfxInPlaceClient::VisAreaChanged()
993 : {
994 1 : uno::Reference < embed::XInplaceObject > xObj( m_pImp->m_xObject, uno::UNO_QUERY );
995 2 : uno::Reference < embed::XInplaceClient > xClient( m_pImp->m_xClient, uno::UNO_QUERY );
996 1 : if ( xObj.is() && xClient.is() )
997 2 : m_pImp->SizeHasChanged();
998 1 : }
999 :
1000 0 : void SfxInPlaceClient::ObjectAreaChanged()
1001 : {
1002 : // dummy implementation
1003 0 : }
1004 :
1005 0 : void SfxInPlaceClient::RequestNewObjectArea( Rectangle& )
1006 : {
1007 : // dummy implementation
1008 0 : }
1009 :
1010 2 : void SfxInPlaceClient::ViewChanged()
1011 : {
1012 : // dummy implementation
1013 2 : }
1014 :
1015 0 : void SfxInPlaceClient::MakeVisible()
1016 : {
1017 : // dummy implementation
1018 0 : }
1019 :
1020 0 : void SfxInPlaceClient::FormatChanged()
1021 : {
1022 : // dummy implementation
1023 0 : }
1024 :
1025 0 : void SfxInPlaceClient::DeactivateObject()
1026 : {
1027 0 : if ( GetObject().is() )
1028 : {
1029 : try
1030 : {
1031 0 : m_pImp->m_bUIActive = false;
1032 0 : bool bHasFocus = false;
1033 0 : uno::Reference< frame::XModel > xModel( m_pImp->m_xObject->getComponent(), uno::UNO_QUERY );
1034 0 : if ( xModel.is() )
1035 : {
1036 0 : uno::Reference< frame::XController > xController = xModel->getCurrentController();
1037 0 : if ( xController.is() )
1038 : {
1039 0 : vcl::Window* pWindow = VCLUnoHelper::GetWindow( xController->getFrame()->getContainerWindow() );
1040 0 : bHasFocus = pWindow->HasChildPathFocus( true );
1041 0 : }
1042 : }
1043 :
1044 0 : m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(true);
1045 :
1046 0 : if ( (m_pImp->m_xObject->getStatus( m_pImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE) ||
1047 0 : svt::EmbeddedObjectRef::IsGLChart(m_pImp->m_xObject) )
1048 : {
1049 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
1050 0 : if (bHasFocus)
1051 0 : m_pViewSh->GetWindow()->GrabFocus();
1052 : }
1053 : else
1054 : {
1055 : // the links should not stay in running state for long time because of locking
1056 0 : uno::Reference< embed::XLinkageSupport > xLink( m_pImp->m_xObject, uno::UNO_QUERY );
1057 0 : if ( xLink.is() && xLink->isLink() )
1058 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::LOADED );
1059 : else
1060 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::RUNNING );
1061 : }
1062 :
1063 0 : SfxViewFrame* pFrame = m_pViewSh->GetViewFrame();
1064 0 : SfxViewFrame::SetViewFrame( pFrame );
1065 0 : pFrame->GetTopFrame().LockResize_Impl(false);
1066 0 : pFrame->GetTopFrame().Resize();
1067 : }
1068 0 : catch (com::sun::star::uno::Exception& )
1069 : {}
1070 : }
1071 0 : }
1072 :
1073 0 : void SfxInPlaceClient::ResetObject()
1074 : {
1075 0 : if ( GetObject().is() )
1076 : {
1077 : try
1078 : {
1079 0 : m_pImp->m_bUIActive = false;
1080 0 : if ( (m_pImp->m_xObject->getStatus( m_pImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE) ||
1081 0 : svt::EmbeddedObjectRef::IsGLChart(m_pImp->m_xObject) )
1082 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
1083 : else
1084 : {
1085 : // the links should not stay in running state for long time because of locking
1086 0 : uno::Reference< embed::XLinkageSupport > xLink( m_pImp->m_xObject, uno::UNO_QUERY );
1087 0 : if ( xLink.is() && xLink->isLink() )
1088 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::LOADED );
1089 : else
1090 0 : m_pImp->m_xObject->changeState( embed::EmbedStates::RUNNING );
1091 : }
1092 : }
1093 0 : catch (com::sun::star::uno::Exception& )
1094 : {}
1095 : }
1096 0 : }
1097 :
1098 1 : bool SfxInPlaceClient::IsUIActive()
1099 : {
1100 1 : return m_pImp->m_bUIActive;
1101 648 : }
1102 :
1103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|