update dev300-m57
[ooovba.git] / chart2 / source / controller / main / ChartController.cxx
blob9437abc429dd6644307f34cb587c9d0c7e5a036e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartController.cxx,v $
10 * $Revision: 1.30.16.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "ChartController.hxx"
34 #include "servicenames.hxx"
35 #include "ResId.hxx"
36 #include "dlg_DataSource.hxx"
37 #include "ChartModelHelper.hxx"
38 #include "ControllerCommandDispatch.hxx"
39 #include "Strings.hrc"
40 #include "chartview/ExplicitValueProvider.hxx"
41 #include "ChartViewHelper.hxx"
43 #include "ChartWindow.hxx"
44 #include "chartview/DrawModelWrapper.hxx"
45 #include "DrawViewWrapper.hxx"
46 #include "ObjectIdentifier.hxx"
47 #include "DiagramHelper.hxx"
48 #include "ControllerLockGuard.hxx"
49 #include "UndoGuard.hxx"
50 #include "ChartDropTargetHelper.hxx"
52 #include "macros.hxx"
53 #include "dlg_CreationWizard.hxx"
54 #include "dlg_ChartType.hxx"
55 //#include "svx/ActionDescriptionProvider.hxx"
57 #include <comphelper/InlineContainer.hxx>
59 #include <com/sun/star/awt/PosSize.hpp>
60 #include <com/sun/star/chart2/XChartDocument.hpp>
61 #include <com/sun/star/chart2/XUndoSupplier.hpp>
62 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
63 #include <com/sun/star/frame/XLoadable.hpp>
64 #include <com/sun/star/util/XCloneable.hpp>
65 #include <com/sun/star/embed/XEmbeddedClient.hpp>
66 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
67 #include <com/sun/star/util/XModifyBroadcaster.hpp>
68 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
70 //-------
71 // header for define RET_OK
72 #include <vcl/msgbox.hxx>
73 //-------
75 //-------
76 #include <toolkit/awt/vclxwindow.hxx>
77 #include <toolkit/helper/vclunohelper.hxx>
78 #include <vcl/svapp.hxx>
79 #include <vos/mutex.hxx>
80 //-------
81 #include <com/sun/star/frame/XLayoutManager.hpp>
82 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
84 // this is needed to properly destroy the auto_ptr to the AcceleratorExecute
85 // object in the DTOR
86 #include <svtools/acceleratorexecute.hxx>
87 #include <svx/ActionDescriptionProvider.hxx>
89 // enable the following define to let the controller listen to model changes and
90 // react on this by rebuilding the view
91 #define TEST_ENABLE_MODIFY_LISTENER
94 #include <vcl/svapp.hxx>
97 //.............................................................................
98 namespace chart
100 //.............................................................................
102 using namespace ::com::sun::star;
103 using namespace ::com::sun::star::chart2;
104 using ::com::sun::star::uno::Any;
105 using ::com::sun::star::uno::Reference;
106 using ::com::sun::star::uno::Sequence;
107 DBG_NAME(ChartController)
108 //-----------------------------------------------------------------
109 // ChartController Constructor and Destructor
110 //-----------------------------------------------------------------
112 ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext)
113 : m_aLifeTimeManager( NULL )
114 , m_bSuspended( sal_False )
115 , m_bCanClose( sal_True )
116 , m_xCC(xContext) //@todo is it allowed to hold this context??
117 , m_xFrame( NULL )
118 , m_aModelMutex()
119 , m_aModel( NULL, m_aModelMutex )
120 , m_pChartWindow( NULL )
121 , m_xViewWindow()
122 , m_xChartView()
123 , m_pDrawModelWrapper()
124 , m_pDrawViewWrapper(NULL)
125 , m_eDragMode(SDRDRAG_MOVE)
126 , m_bWaitingForDoubleClick(false)
127 , m_bWaitingForMouseUp(false)
128 , m_bConnectingToView(false)
129 , m_xUndoManager( 0 )
130 , m_aDispatchContainer( m_xCC )
132 DBG_CTOR(ChartController,NULL);
133 // m_aDispatchContainer.setUndoManager( m_xUndoManager );
134 m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) );
137 ChartController::~ChartController()
139 DBG_DTOR(ChartController,NULL);
140 stopDoubleClickWaiting();
143 //-----------------------------------------------------------------
145 ChartController::RefCountable::RefCountable() : m_nRefCount(0)
149 ChartController::RefCountable::~RefCountable()
152 void ChartController::RefCountable::acquire()
154 m_nRefCount++;
156 void ChartController::RefCountable::release()
158 m_nRefCount--;
159 if(!m_nRefCount)
160 delete this;
163 //-----------------------------------------------------------------
165 ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel )
166 : m_xModel( xModel )
167 , m_xCloseable( NULL )
168 , m_bOwnership( sal_True )
169 , m_bOwnershipIsWellKnown( sal_False )
171 m_xCloseable =
172 uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY );
175 ChartController::TheModel::~TheModel()
179 void ChartController::TheModel::SetOwnerShip( sal_Bool bGetsOwnership )
181 m_bOwnership = bGetsOwnership;
182 m_bOwnershipIsWellKnown = sal_True;
185 void ChartController::TheModel::addListener( ChartController* pController )
187 if(m_xCloseable.is())
189 //if you need to be able to veto against the destruction of the model
190 // you must add as a close listener
192 //otherwise you 'can' add as closelistener or 'must' add as dispose event listener
194 m_xCloseable->addCloseListener(
195 static_cast<util::XCloseListener*>(pController) );
197 else if( m_xModel.is() )
199 //we need to add as dispose event listener
200 m_xModel->addEventListener(
201 static_cast<util::XCloseListener*>(pController) );
206 void ChartController::TheModel::removeListener( ChartController* pController )
208 if(m_xCloseable.is())
209 m_xCloseable->removeCloseListener(
210 static_cast<util::XCloseListener*>(pController) );
212 else if( m_xModel.is() )
213 m_xModel->removeEventListener(
214 static_cast<util::XCloseListener*>(pController) );
217 void ChartController::TheModel::tryTermination()
219 if(!m_bOwnership)
220 return;
224 if(m_xCloseable.is())
228 //@todo ? are we allowed to use sal_True here if we have the explicit ownership?
229 //I think yes, because there might be other closelistners later in the list which might be interested still
230 //but make sure that we do not throw the CloseVetoException here ourselfs
231 //so stop listening before trying to terminate or check the source of queryclosing event
232 m_xCloseable->close(sal_True);
234 m_bOwnership = false;
235 m_bOwnershipIsWellKnown = sal_True;
237 catch( util::CloseVetoException& )
239 //since we have indicated to give up the ownership with paramter true in close call
240 //the one who has thrown the CloseVetoException is the new owner
242 #if OSL_DEBUG_LEVEL > 2
243 OSL_ENSURE( !m_bOwnership,
244 "INFO: a well known owner has catched a CloseVetoException after calling close(true)" );
245 #endif
247 m_bOwnership = false;
248 m_bOwnershipIsWellKnown = sal_True;
249 return;
253 else if( m_xModel.is() )
255 //@todo correct??
256 m_xModel->dispose();
257 return;
260 catch( uno::Exception& ex)
262 (void)(ex); // no warning in non-debug builds
263 OSL_ENSURE( sal_False, ( rtl::OString("Termination of model failed: ")
264 + rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_ASCII_US ) ).getStr() );
268 //-----------------------------------------------------------------
270 ChartController::TheModelRef::TheModelRef( TheModel* pTheModel, ::osl::Mutex& rMutex )
271 : m_pTheModel(pTheModel), m_rModelMutex(rMutex)
273 ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
274 if(m_pTheModel)
275 m_pTheModel->acquire();
277 ChartController::TheModelRef::TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex )
278 : m_rModelMutex(rMutex)
280 ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
281 m_pTheModel=rTheModel.operator->();
282 if(m_pTheModel)
283 m_pTheModel->acquire();
285 ChartController::TheModelRef& ChartController::TheModelRef::operator=(TheModel* pTheModel)
287 ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
288 if(m_pTheModel==pTheModel)
289 return *this;
290 if(m_pTheModel)
291 m_pTheModel->release();
292 m_pTheModel=pTheModel;
293 if(m_pTheModel)
294 m_pTheModel->acquire();
295 return *this;
297 ChartController::TheModelRef& ChartController::TheModelRef::operator=(const TheModelRef& rTheModel)
299 ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
300 TheModel* pNew=rTheModel.operator->();
301 if(m_pTheModel==pNew)
302 return *this;
303 if(m_pTheModel)
304 m_pTheModel->release();
305 m_pTheModel=pNew;
306 if(m_pTheModel)
307 m_pTheModel->acquire();
308 return *this;
310 ChartController::TheModelRef::~TheModelRef()
312 ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex );
313 if(m_pTheModel)
314 m_pTheModel->release();
316 sal_Bool ChartController::TheModelRef::is() const
318 return (m_pTheModel != 0);
322 //-----------------------------------------------------------------
323 // private methods
324 //-----------------------------------------------------------------
326 sal_Bool ChartController
327 ::impl_isDisposedOrSuspended() const
329 if( m_aLifeTimeManager.impl_isDisposed() )
330 return sal_True;
332 if( m_bSuspended )
334 OSL_ENSURE( sal_False, "This Controller is suspended" );
335 return sal_True;
337 return sal_False;
340 //-----------------------------------------------------------------
341 // lang::XServiceInfo
342 //-----------------------------------------------------------------
344 APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME)
346 uno::Sequence< rtl::OUString > ChartController
347 ::getSupportedServiceNames_Static()
349 uno::Sequence< rtl::OUString > aSNS( 2 );
350 aSNS.getArray()[ 0 ] = CHART_CONTROLLER_SERVICE_NAME;
351 aSNS.getArray()[ 1 ] = ::rtl::OUString::createFromAscii("com.sun.star.frame.Controller");
352 //// @todo : add additional services if you support any further
353 return aSNS;
356 //-----------------------------------------------------------------
357 // XController
358 //-----------------------------------------------------------------
360 void SAL_CALL ChartController
361 ::attachFrame( const uno::Reference<frame::XFrame>& xFrame )
362 throw(uno::RuntimeException)
364 ::vos::OGuard aGuard( Application::GetSolarMutex());
366 if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended?
367 return; //behave passive if already disposed or suspended
369 if(m_xFrame.is()) //what happens, if we do have a Frame already??
371 //@todo? throw exception?
372 OSL_ENSURE( sal_False, "there is already a frame attached to the controller" );
373 return;
376 //--attach frame
377 m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent
379 //add as disposelistener to the frame (due to persistent reference) ??...:
381 //the frame is considered to be owner of this controller and will live longer than we do
382 //the frame or the disposer of the frame has the duty to call suspend and dispose on this object
383 //so we do not need to add as lang::XEventListener for DisposingEvents right?
385 //@todo nothing right???
389 //--------------------------------------------------
390 //create view @todo is this the correct place here??
392 Window* pParent = NULL;
393 //get the window parent from the frame to use as parent for our new window
394 if(xFrame.is())
396 uno::Reference< awt::XWindow > xContainerWindow = xFrame->getContainerWindow();
397 VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xContainerWindow);
398 pParentComponent->setVisible(sal_True);
400 pParent = VCLUnoHelper::GetWindow( xContainerWindow );
403 if(m_pChartWindow)
405 //@todo delete ...
406 m_pChartWindow->clear();
407 m_apDropTargetHelper.reset();
410 awt::Size aPageSize( ChartModelHelper::getPageSize(m_aModel->getModel()) );
412 // calls to VCL
413 ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
414 m_pChartWindow = new ChartWindow(this,pParent,pParent?pParent->GetStyle():0);
415 m_pChartWindow->SetBackground();//no Background
416 m_xViewWindow = uno::Reference< awt::XWindow >( m_pChartWindow->GetComponentInterface(), uno::UNO_QUERY );
417 m_pChartWindow->Show();
418 m_apDropTargetHelper.reset(
419 new ChartDropTargetHelper( m_pChartWindow->GetDropTarget(),
420 uno::Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY )));
422 impl_createDrawViewController();
425 //create the menu
427 uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
428 if( xPropSet.is() )
432 uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
433 xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager;
434 if ( xLayoutManager.is() )
436 xLayoutManager->lock();
437 xLayoutManager->requestElement( C2U( "private:resource/menubar/menubar" ) );
438 //@todo: createElement should become unnecessary, remove when #i79198# is fixed
439 xLayoutManager->createElement( C2U( "private:resource/toolbar/standardbar" ) );
440 xLayoutManager->requestElement( C2U( "private:resource/toolbar/standardbar" ) );
441 //@todo: createElement should become unnecessary, remove when #i79198# is fixed
442 xLayoutManager->createElement( C2U( "private:resource/toolbar/toolbar" ) );
443 xLayoutManager->requestElement( C2U( "private:resource/toolbar/toolbar" ) );
444 xLayoutManager->requestElement( C2U( "private:resource/statusbar/statusbar" ) );
445 xLayoutManager->unlock();
447 // add as listener to get notified when
448 m_xLayoutManagerEventBroadcaster.set( xLayoutManager, uno::UNO_QUERY );
449 if( m_xLayoutManagerEventBroadcaster.is())
450 m_xLayoutManagerEventBroadcaster->addLayoutManagerEventListener( this );
453 catch( uno::Exception & ex )
455 ASSERT_EXCEPTION( ex );
461 //XModeChangeListener
462 void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent )
463 throw ( uno::RuntimeException )
465 //adjust controller to view status changes
467 if( rEvent.NewMode.equals(C2U("dirty")) )
469 //the view has become dirty, we should repaint it if we have a window
470 if( m_pChartWindow )
471 m_pChartWindow->ForceInvalidate();
473 else if( rEvent.NewMode.equals(C2U("invalid")) )
475 //the view is about to become invalid so end all actions on it
476 impl_invalidateAccessible();
477 ::vos::OGuard aGuard( Application::GetSolarMutex());
478 if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() )
479 this->EndTextEdit();
480 if( m_pDrawViewWrapper )
482 m_pDrawViewWrapper->UnmarkAll();
483 //m_pDrawViewWrapper->hideMarkHandles(); todo??
484 m_pDrawViewWrapper->HideSdrPage();
487 else
489 //the view was rebuild so we can start some actions on it again
490 if( !m_bConnectingToView )
492 if(m_pChartWindow && m_aModel.is() )
494 m_bConnectingToView = true;
496 GetDrawModelWrapper();
497 if(m_pDrawModelWrapper)
500 ::vos::OGuard aGuard( Application::GetSolarMutex());
501 if( m_pDrawViewWrapper )
502 m_pDrawViewWrapper->ReInit();
505 //reselect object
506 if( m_aSelection.hasSelection() )
507 this->impl_selectObjectAndNotiy();
508 else
509 ChartModelHelper::triggerRangeHighlighting( m_aModel->getModel() );
511 impl_initializeAccessible();
513 if( m_pChartWindow )
514 m_pChartWindow->Invalidate();
517 m_bConnectingToView = false;
523 sal_Bool SAL_CALL ChartController
524 ::attachModel( const uno::Reference< frame::XModel > & xModel )
525 throw(uno::RuntimeException)
527 impl_invalidateAccessible();
529 //is called to attach the controller to a new model.
530 //return true if attach was successfully, false otherwise (e.g. if you do not work with a model)
532 ::vos::OClearableGuard aGuard( Application::GetSolarMutex());
533 if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended?
534 return sal_False; //behave passive if already disposed or suspended
535 aGuard.clear();
538 TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex);
539 TheModelRef aOldModelRef(m_aModel,m_aModelMutex);
540 m_aModel = aNewModelRef;
542 //--handle relations to the old model if any
543 if( aOldModelRef.is() )
545 uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
546 if( xViewBroadcaster.is() )
547 xViewBroadcaster->removeModeChangeListener(this);
548 m_pDrawModelWrapper.reset();
550 aOldModelRef->removeListener( this );
551 //@todo?? termination correct?
552 // aOldModelRef->tryTermination();
553 #ifdef TEST_ENABLE_MODIFY_LISTENER
554 uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY );
555 if( xMBroadcaster.is())
556 xMBroadcaster->removeModifyListener( this );
557 #endif
560 //--handle relations to the new model
561 aNewModelRef->addListener( this );
563 // set new model at dispatchers
564 m_aDispatchContainer.setModel( aNewModelRef->getModel());
565 ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this );
566 pDispatch->initialize();
568 // the dispatch container will return "this" for all commands returned by
569 // impl_getAvailableCommands(). That means, for those commands dispatch()
570 // is called here at the ChartController.
571 m_aDispatchContainer.setFallbackDispatch( pDispatch, impl_getAvailableCommands() );
573 #ifdef TEST_ENABLE_MODIFY_LISTENER
574 uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY );
575 if( xMBroadcaster.is())
576 xMBroadcaster->addModifyListener( this );
577 #endif
579 uno::Reference< lang::XMultiServiceFactory > xFact( m_aModel->getModel(), uno::UNO_QUERY );
580 if( xFact.is())
582 m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME );
583 GetDrawModelWrapper();
584 uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
585 if( xViewBroadcaster.is() )
586 xViewBroadcaster->addModeChangeListener(this);
589 //the frameloader is responsible to call xModel->connectController
590 if( m_pChartWindow )
591 m_pChartWindow->Invalidate();
593 uno::Reference< chart2::XUndoSupplier > xUndoSupplier( m_aModel->getModel(), uno::UNO_QUERY );
594 if( xUndoSupplier.is())
595 m_xUndoManager.set( xUndoSupplier->getUndoManager());
597 return sal_True;
600 uno::Reference< frame::XFrame > SAL_CALL ChartController
601 ::getFrame() throw(uno::RuntimeException)
603 //provides access to owner frame of this controller
604 //return the frame containing this controller
606 return m_xFrame;
609 uno::Reference< frame::XModel > SAL_CALL ChartController
610 ::getModel() throw(uno::RuntimeException)
612 //provides access to currently attached model
613 //returns the currently attached model
615 //return nothing, if you do not have a model
616 TheModelRef aModelRef( m_aModel, m_aModelMutex);
617 if(aModelRef.is())
618 return aModelRef->getModel();
620 return uno::Reference< frame::XModel > ();
623 uno::Any SAL_CALL ChartController
624 ::getViewData() throw(uno::RuntimeException)
626 //provides access to current view status
627 //set of data that can be used to restore the current view status at later time
628 // by using XController::restoreViewData()
630 ::vos::OGuard aGuard( Application::GetSolarMutex());
631 if( impl_isDisposedOrSuspended() )
632 return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception??
634 //-- collect current view state
635 uno::Any aRet;
636 //// @todo integrate specialized implementation
638 return aRet;
641 void SAL_CALL ChartController
642 ::restoreViewData( const uno::Any& /* Value */ )
643 throw(uno::RuntimeException)
645 //restores the view status using the data gotten from a previous call to XController::getViewData()
647 ::vos::OGuard aGuard( Application::GetSolarMutex());
648 if( impl_isDisposedOrSuspended() )
649 return; //behave passive if already disposed or suspended //@todo? or throw an exception??
651 //// @todo integrate specialized implementation
654 sal_Bool SAL_CALL ChartController
655 ::suspend( sal_Bool bSuspend )
656 throw(uno::RuntimeException)
658 //is called to prepare the controller for closing the view
659 //bSuspend==true: force the controller to suspend his work
660 //bSuspend==false try to reactivate the controller
661 //returns true if request was accepted and of course successfully finished, false otherwise
663 //we may show dialogs here to ask the user for saving changes ... @todo?
665 ::vos::OGuard aGuard( Application::GetSolarMutex());
666 if( m_aLifeTimeManager.impl_isDisposed() )
667 return sal_False; //behave passive if already disposed, return false because request was not accepted //@todo? correct
669 if(bSuspend==m_bSuspended)
671 OSL_ENSURE( sal_False, "new suspend mode equals old suspend mode" );
672 return sal_True;
675 //change suspend mode
676 if(bSuspend)
678 //aGuard.clear();
679 //@todo ??? try to stop all what may prevent me from becoming disposed
680 //aGuard.reset();
682 m_bSuspended = bSuspend;
683 return sal_True;
685 else
687 //aGuard.clear();
688 //@todo ??? redo what was made in section bSuspend==true
689 //aGuard.reset();
691 m_bSuspended = bSuspend;
693 return sal_True;
697 if ( bSuspend )
698 getFrame()->removeFrameActionListener( pImp );
699 else
700 getFrame()->addFrameActionListener( pImp );
705 void ChartController::impl_createDrawViewController()
707 ::vos::OGuard aGuard( Application::GetSolarMutex());
708 if(!m_pDrawViewWrapper)
710 if( m_pDrawModelWrapper )
712 m_pDrawViewWrapper = new DrawViewWrapper(&m_pDrawModelWrapper->getSdrModel(),m_pChartWindow,true);
713 m_pDrawViewWrapper->attachParentReferenceDevice( m_aModel->getModel());
717 void ChartController::impl_deleteDrawViewController()
719 if( m_pDrawViewWrapper )
721 ::vos::OGuard aGuard( Application::GetSolarMutex());
722 if( m_pDrawViewWrapper->IsTextEdit() )
723 this->EndTextEdit();
724 DELETEZ( m_pDrawViewWrapper );
728 //-----------------------------------------------------------------
729 // XComponent (base of XController)
730 //-----------------------------------------------------------------
732 void SAL_CALL ChartController
733 ::dispose() throw(uno::RuntimeException)
737 //This object should release all resources and references in the
738 //easiest possible manner
739 //This object must notify all registered listeners using the method
740 //<member>XEventListener::disposing</member>
742 //hold no mutex
743 if( !m_aLifeTimeManager.dispose() )
744 return;
746 // OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" );
748 this->stopDoubleClickWaiting();
750 //end range highlighting
751 if( m_aModel.is())
753 uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener;
754 uno::Reference< chart2::data::XDataReceiver > xDataReceiver( m_aModel->getModel(), uno::UNO_QUERY );
755 if( xDataReceiver.is() )
756 xSelectionChangeListener = uno::Reference< view::XSelectionChangeListener >( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY );
757 if( xSelectionChangeListener.is() )
759 uno::Reference< frame::XController > xController( this );
760 uno::Reference< lang::XComponent > xComp( xController, uno::UNO_QUERY );
761 //lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) );
762 lang::EventObject aEvent( xComp );
763 xSelectionChangeListener->disposing( aEvent );
767 //--release all resources and references
769 uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
770 if( xViewBroadcaster.is() )
771 xViewBroadcaster->removeModeChangeListener(this);
772 // /--
773 impl_invalidateAccessible();
774 ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
775 impl_deleteDrawViewController();
776 m_pDrawModelWrapper.reset();
778 m_apDropTargetHelper.reset();
780 //the accessible view is disposed within window destructor of m_pChartWindow
781 m_pChartWindow->clear();
782 m_pChartWindow = NULL;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also))
783 m_xViewWindow->dispose();
784 m_xChartView.clear();
785 // \--
788 // remove as listener to layout manager events
789 if( m_xLayoutManagerEventBroadcaster.is())
791 m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this );
792 m_xLayoutManagerEventBroadcaster.set( 0 );
795 m_xFrame.clear();
796 m_xUndoManager.clear();
798 TheModelRef aModelRef( m_aModel, m_aModelMutex);
799 m_aModel = NULL;
801 if( aModelRef.is())
803 uno::Reference< frame::XModel > xModel( aModelRef->getModel() );
804 if(xModel.is())
805 xModel->disconnectController( uno::Reference< frame::XController >( this ));
807 aModelRef->removeListener( this );
808 #ifdef TEST_ENABLE_MODIFY_LISTENER
811 uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY );
812 if( xMBroadcaster.is())
813 xMBroadcaster->removeModifyListener( this );
815 catch( const uno::Exception & ex )
817 ASSERT_EXCEPTION( ex );
819 #endif
820 aModelRef->tryTermination();
823 //// @todo integrate specialized implementation
824 //e.g. release further resources and references
826 m_aDispatchContainer.DisposeAndClear();
828 catch( const uno::Exception & ex )
830 ASSERT_EXCEPTION( ex );
834 void SAL_CALL ChartController
835 ::addEventListener( const uno::Reference<lang::XEventListener>& xListener )
836 throw(uno::RuntimeException)
838 ::vos::OGuard aGuard( Application::GetSolarMutex());
839 if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
840 return; //behave passive if already disposed or suspended
842 //--add listener
843 m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
846 void SAL_CALL ChartController
847 ::removeEventListener( const uno::Reference<
848 lang::XEventListener>& xListener )
849 throw(uno::RuntimeException)
851 ::vos::OGuard aGuard( Application::GetSolarMutex());
852 if( m_aLifeTimeManager.impl_isDisposed() )
853 return; //behave passive if already disposed or suspended
855 //--remove listener
856 m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
860 //-----------------------------------------------------------------
861 // util::XCloseListener
862 //-----------------------------------------------------------------
863 void SAL_CALL ChartController
864 ::queryClosing( const lang::EventObject& rSource, sal_Bool bGetsOwnership )
865 throw(util::CloseVetoException, uno::RuntimeException)
867 //do not use the m_aControllerMutex here because this call is not allowed to block
869 TheModelRef aModelRef( m_aModel, m_aModelMutex);
871 if( !aModelRef.is() )
872 return;
874 if( !(aModelRef->getModel() == rSource.Source) )
876 OSL_ENSURE( sal_False, "queryClosing was called on a controller from an unknown source" );
877 return;
880 if( !m_bCanClose )//@todo tryaqcuire mutex
882 if( bGetsOwnership )
884 aModelRef->SetOwnerShip( bGetsOwnership );
887 throw util::CloseVetoException();
889 else
891 //@ todo prepare to to closing model -> don't start any further hindering actions
895 void SAL_CALL ChartController
896 ::notifyClosing( const lang::EventObject& rSource )
897 throw(uno::RuntimeException)
899 //Listener should deregister himself and relaese all references to the closing object.
901 TheModelRef aModelRef( m_aModel, m_aModelMutex);
902 if( impl_releaseThisModel( rSource.Source ) )
904 //--stop listening to the closing model
905 aModelRef->removeListener( this );
907 // #i79087# If the model using this controller is closed, the frame is
908 // expected to be closed as well
909 Reference< util::XCloseable > xFrameCloseable( m_xFrame, uno::UNO_QUERY );
910 if( xFrameCloseable.is())
914 xFrameCloseable->close( sal_False /* DeliverOwnership */ );
915 m_xFrame.clear();
917 catch( util::CloseVetoException & )
919 // closing was vetoed
925 bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterface > & xModel )
927 bool bReleaseModel = sal_False;
929 ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex );
930 if( m_aModel.is() && m_aModel->getModel() == xModel )
932 m_aModel = NULL;
933 m_xUndoManager.clear();
934 bReleaseModel = true;
937 return bReleaseModel;
940 //-----------------------------------------------------------------
941 // util::XEventListener (base of XCloseListener)
942 //-----------------------------------------------------------------
943 void SAL_CALL ChartController
944 ::disposing( const lang::EventObject& rSource )
945 throw(uno::RuntimeException)
947 if( !impl_releaseThisModel( rSource.Source ))
949 if( rSource.Source == m_xLayoutManagerEventBroadcaster )
950 m_xLayoutManagerEventBroadcaster.set( 0 );
954 void SAL_CALL ChartController::layoutEvent( const lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const uno::Any& /* aInfo */ )
955 throw (uno::RuntimeException)
957 if( eLayoutEvent == frame::LayoutManagerEvents::MERGEDMENUBAR )
959 Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY );
960 if( xLM.is())
962 xLM->createElement( C2U("private:resource/statusbar/statusbar"));
963 xLM->requestElement( C2U("private:resource/statusbar/statusbar"));
969 //-----------------------------------------------------------------
970 // XDispatchProvider (required interface)
971 //-----------------------------------------------------------------
973 namespace
975 bool lcl_isFormatObjectCommand( const rtl::OString& aCommand )
977 if( aCommand.equals("MainTitle")
978 || aCommand.equals("SubTitle")
979 || aCommand.equals("XTitle")
980 || aCommand.equals("YTitle")
981 || aCommand.equals("ZTitle")
982 || aCommand.equals("SecondaryXTitle")
983 || aCommand.equals("SecondaryYTitle")
984 || aCommand.equals("AllTitles")
985 || aCommand.equals("Legend")
986 || aCommand.equals("DiagramAxisX")
987 || aCommand.equals("DiagramAxisY")
988 || aCommand.equals("DiagramAxisZ")
989 || aCommand.equals("DiagramAxisA")
990 || aCommand.equals("DiagramAxisB")
991 || aCommand.equals("DiagramAxisAll")
992 || aCommand.equals("DiagramGridXMain")
993 || aCommand.equals("DiagramGridYMain")
994 || aCommand.equals("DiagramGridZMain")
995 || aCommand.equals("DiagramGridXHelp")
996 || aCommand.equals("DiagramGridYHelp")
997 || aCommand.equals("DiagramGridZHelp")
998 || aCommand.equals("DiagramGridAll")
999 || aCommand.equals("DiagramWall")
1000 || aCommand.equals("DiagramFloor")
1001 || aCommand.equals("DiagramArea")
1003 return true;
1005 // else
1006 return false;
1008 } // anonymous namespace
1010 uno::Reference<frame::XDispatch> SAL_CALL ChartController
1011 ::queryDispatch( const util::URL& rURL
1012 , const rtl::OUString& rTargetFrameName
1013 , sal_Int32 /* nSearchFlags */)
1014 throw(uno::RuntimeException)
1016 if ( !m_aLifeTimeManager.impl_isDisposed() )
1018 if( rTargetFrameName.getLength() &&
1019 rTargetFrameName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_self")))
1020 return m_aDispatchContainer.getDispatchForURL( rURL );
1022 return uno::Reference< frame::XDispatch > ();
1025 uno::Sequence<uno::Reference<frame::XDispatch > > ChartController
1026 ::queryDispatches( const uno::Sequence<
1027 frame::DispatchDescriptor>& xDescripts)
1028 throw(uno::RuntimeException)
1030 if ( !m_aLifeTimeManager.impl_isDisposed() )
1032 return m_aDispatchContainer.getDispatchesForURLs( xDescripts );
1034 return uno::Sequence<uno::Reference<frame::XDispatch > > ();
1037 //-----------------------------------------------------------------
1038 // frame::XDispatch
1039 //-----------------------------------------------------------------
1041 void SAL_CALL ChartController
1042 ::dispatch( const util::URL& rURL
1043 , const uno::Sequence< beans::PropertyValue >& /* rArgs */ )
1044 throw (uno::RuntimeException)
1046 //@todo avoid OString (see Mathias mail on bug #104387#)
1047 rtl::OString aCommand( rtl::OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) );
1049 if(aCommand.equals("Paste"))
1050 this->executeDispatch_Paste();
1051 else if(aCommand.equals("Copy"))
1052 this->executeDispatch_Copy();
1053 else if(aCommand.equals("Cut"))
1054 this->executeDispatch_Cut();
1055 else if(aCommand.equals("DataRanges"))
1056 this->executeDispatch_SourceData();
1057 //----------------------------------
1058 else if(aCommand.equals("Update")) //Update Chart
1060 ChartViewHelper::setViewToDirtyState( m_aModel->getModel() );
1061 if( m_pChartWindow )
1062 m_pChartWindow->Invalidate();
1064 else if(aCommand.equals("DiagramData"))
1065 this->executeDispatch_EditData();
1066 //insert objects
1067 else if( aCommand.equals("InsertTitle"))
1068 this->executeDispatch_InsertTitle();
1069 else if( aCommand.equals("InsertLegend"))
1070 this->executeDispatch_InsertLegend();
1071 else if( aCommand.equals("InsertDescription"))
1072 this->executeDispatch_InsertDataLabel();
1073 else if( aCommand.equals("InsertAxis"))
1074 this->executeDispatch_InsertAxis();
1075 else if( aCommand.equals("InsertGrids"))
1076 this->executeDispatch_InsertGrid();
1077 // else if( aCommand.equals("InsertStatistics"))
1078 // this->executeDispatch_InsertStatistic();
1079 else if( aCommand.equals("InsertTrendlines"))
1080 this->executeDispatch_InsertTrendlines();
1081 else if( aCommand.equals("InsertMeanValues"))
1082 this->executeDispatch_InsertMeanValues();
1083 else if( aCommand.equals("InsertYErrorbars"))
1084 this->executeDispatch_InsertYErrorbars();
1085 else if( aCommand.equals("InsertSymbol"))
1086 this->executeDispatch_InsertSpecialCharacter();
1087 else if( aCommand.equals("InsertTrendline"))
1088 this->executeDispatch_InsertTrendline();
1089 else if( aCommand.equals("DeleteTrendline"))
1090 this->executeDispatch_DeleteTrendline();
1091 else if( aCommand.equals("InsertMeanValue"))
1092 this->executeDispatch_InsertMeanValue();
1093 else if( aCommand.equals("DeleteMeanValue"))
1094 this->executeDispatch_DeleteMeanValue();
1095 else if( aCommand.equals("InsertYErrorbar"))
1096 this->executeDispatch_InsertYErrorbar();
1097 else if( aCommand.equals("DeleteYErrorbar"))
1098 this->executeDispatch_DeleteYErrorbar();
1099 else if( aCommand.equals("InsertTrendlineEquation"))
1100 this->executeDispatch_InsertTrendlineEquation();
1101 //format objects
1102 else if( aCommand.equals("DiagramObjects"))
1103 this->executeDispatch_ObjectProperties();
1104 else if( aCommand.equals("TransformDialog"))
1105 this->executeDispatch_PositionAndSize();
1106 else if( lcl_isFormatObjectCommand(aCommand) )
1107 this->executeDispatch_FormatObject(rURL.Path);
1108 //more format
1109 //MENUCHANGE else if(aCommand.equals("SelectSourceRanges"))
1110 //MENUCHANGE this->executeDispatch_SourceData();
1111 else if( aCommand.equals("DiagramType"))
1112 this->executeDispatch_ChartType();
1113 else if( aCommand.equals("View3D"))
1114 this->executeDispatch_View3D();
1115 else if( aCommand.equals("Forward"))
1116 this->executeDispatch_MoveSeries( sal_True );
1117 else if( aCommand.equals("Backward"))
1118 this->executeDispatch_MoveSeries( sal_False );
1119 else if( aCommand.equals("NewArrangement"))
1120 this->executeDispatch_NewArrangement();
1121 else if( aCommand.equals("ToggleLegend"))
1122 this->executeDispatch_ToggleLegend();
1123 else if( aCommand.equals("ToggleGridHorizontal"))
1124 this->executeDispatch_ToggleGridHorizontal();
1125 else if( aCommand.equals("ScaleText"))
1126 this->executeDispatch_ScaleText();
1127 else if( aCommand.equals("StatusBarVisible"))
1129 // workaround: this should not be necessary.
1130 uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY );
1131 if( xPropSet.is() )
1133 uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1134 xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager;
1135 if ( xLayoutManager.is() )
1137 bool bIsVisible( xLayoutManager->isElementVisible( C2U("private:resource/statusbar/statusbar")));
1138 if( bIsVisible )
1140 xLayoutManager->hideElement( C2U( "private:resource/statusbar/statusbar"));
1141 xLayoutManager->destroyElement( C2U( "private:resource/statusbar/statusbar"));
1143 else
1145 xLayoutManager->createElement( C2U( "private:resource/statusbar/statusbar"));
1146 xLayoutManager->showElement( C2U( "private:resource/statusbar/statusbar"));
1148 // @todo: update menu state (checkmark next to "Statusbar").
1154 case SID_TEXTEDIT:
1155 this->executeDispatch_EditText();
1159 void SAL_CALL ChartController
1160 ::addStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */
1161 , const util::URL& /* aURL */ )
1162 throw (uno::RuntimeException)
1164 // // TODO: add listener by URL !
1165 // ::vos::OGuard aGuard( Application::GetSolarMutex());
1166 // if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
1167 // return; //behave passive if already disposed or suspended
1169 // //--add listener
1170 // m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType( & xControl ), xControl );
1173 void SAL_CALL ChartController
1174 ::removeStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */
1175 , const util::URL& /* aURL */ )
1176 throw (uno::RuntimeException)
1178 // // TODO: remove listener by URL !
1179 // ::vos::OGuard aGuard( Application::GetSolarMutex());
1180 // if( m_aLifeTimeManager.impl_isDisposed() )
1181 // return; //behave passive if already disposed or suspended
1183 // //--remove listener
1184 // m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType( & xControl ), xControl );
1187 //-----------------------------------------------------------------
1188 // XContextMenuInterception (optional interface)
1189 //-----------------------------------------------------------------
1190 void SAL_CALL ChartController
1191 ::registerContextMenuInterceptor( const uno::Reference<
1192 ui::XContextMenuInterceptor > & /* xInterceptor */)
1193 throw(uno::RuntimeException)
1195 //@todo
1198 void SAL_CALL ChartController
1199 ::releaseContextMenuInterceptor( const uno::Reference<
1200 ui::XContextMenuInterceptor > & /* xInterceptor */)
1201 throw(uno::RuntimeException)
1203 //@todo
1206 // ____ XEmbeddedClient ____
1207 // implementation see: ChartController_EditData.cxx
1209 //-----------------------------------------------------------------------------
1210 //-----------------------------------------------------------------------------
1211 //-----------------------------------------------------------------------------
1213 void SAL_CALL ChartController::executeDispatch_ChartType()
1215 // using assignment for broken gcc 3.3
1216 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
1217 ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, m_aModel->getModel() );
1219 // /--
1220 ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
1221 //prepare and open dialog
1222 ChartTypeDialog aDlg( m_pChartWindow, m_aModel->getModel(), m_xCC );
1223 if( aDlg.Execute() == RET_OK )
1225 impl_adaptDataSeriesAutoResize();
1226 aUndoGuard.commitAction();
1228 // \--
1231 void SAL_CALL ChartController::executeDispatch_SourceData()
1233 //-------------------------------------------------------------
1234 //convert properties to ItemSet
1235 uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY );
1236 DBG_ASSERT( xChartDoc.is(), "Invalid XChartDocument" );
1237 if( !xChartDoc.is())
1238 return;
1240 // using assignment for broken gcc 3.3
1241 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
1242 ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, m_aModel->getModel() );
1243 if( xChartDoc.is())
1245 // /--
1246 ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
1247 ::chart::DataSourceDialog aDlg( m_pChartWindow, xChartDoc, m_xCC );
1248 if( aDlg.Execute() == RET_OK )
1250 impl_adaptDataSeriesAutoResize();
1251 aUndoGuard.commitAction();
1253 // \--
1257 void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward )
1259 ControllerLockGuard aCLGuard( m_aModel->getModel());
1261 //get selected series
1262 ::rtl::OUString aObjectCID(m_aSelection.getSelectedCID());
1263 uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels?
1264 aObjectCID, m_aModel->getModel() ) );
1266 UndoGuardWithSelection aUndoGuard(
1267 ActionDescriptionProvider::createDescription(
1268 (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM),
1269 ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))),
1270 m_xUndoManager, m_aModel->getModel());
1272 bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( m_aModel->getModel() ), xGivenDataSeries, bForward );
1273 if( bChanged )
1275 m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
1276 aUndoGuard.commitAction();
1280 // ____ XMultiServiceFactory ____
1281 uno::Reference< uno::XInterface > SAL_CALL
1282 ChartController::createInstance( const ::rtl::OUString& aServiceSpecifier )
1283 throw (uno::Exception,
1284 uno::RuntimeException)
1286 uno::Reference< uno::XInterface > xResult;
1288 if( aServiceSpecifier.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ))
1289 xResult.set( impl_createAccessibleTextContext());
1290 return xResult;
1293 uno::Reference< uno::XInterface > SAL_CALL
1294 ChartController::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier,
1295 const uno::Sequence< uno::Any >& /* Arguments */ )
1296 throw (uno::Exception,
1297 uno::RuntimeException)
1299 // ignore Arguments
1300 return createInstance( ServiceSpecifier );
1303 uno::Sequence< ::rtl::OUString > SAL_CALL
1304 ChartController::getAvailableServiceNames()
1305 throw (uno::RuntimeException)
1307 static uno::Sequence< ::rtl::OUString > aServiceNames;
1309 if( aServiceNames.getLength() == 0 )
1311 aServiceNames.realloc(1);
1312 aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME;
1315 return aServiceNames;
1318 // ____ XModifyListener ____
1319 void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ )
1320 throw (uno::RuntimeException)
1322 // the source can also be a subobject of the ChartModel
1323 // @todo: change the source in ChartModel to always be the model itself ?
1324 // if( m_aModel->getModel() == aEvent.Source )
1327 //todo? update menu states ?
1330 //-----------------------------------------------------------------------------
1331 //-----------------------------------------------------------------------------
1332 //-----------------------------------------------------------------------------
1334 DrawModelWrapper* ChartController::GetDrawModelWrapper()
1336 if( !m_pDrawModelWrapper.get() )
1338 ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( m_xChartView );
1339 if( pProvider )
1340 m_pDrawModelWrapper = pProvider->getDrawModelWrapper();
1342 return m_pDrawModelWrapper.get();
1345 uno::Reference< accessibility::XAccessible > ChartController::CreateAccessible()
1347 uno::Reference< accessibility::XAccessible > xResult(
1348 m_xCC->getServiceManager()->createInstanceWithContext(
1349 CHART2_ACCESSIBLE_SERVICE_NAME, m_xCC ), uno::UNO_QUERY );
1351 impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) );
1352 return xResult;
1355 void ChartController::impl_invalidateAccessible()
1357 if( m_pChartWindow )
1359 Reference< lang::XInitialization > xInit( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY );
1360 if(xInit.is())
1362 uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible
1363 xInit->initialize(aArguments);
1367 void ChartController::impl_initializeAccessible()
1369 if( m_pChartWindow )
1370 this->impl_initializeAccessible( Reference< lang::XInitialization >( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ) );
1372 void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit )
1374 if(xInit.is())
1376 uno::Sequence< uno::Any > aArguments(5);
1377 uno::Reference<view::XSelectionSupplier> xSelectionSupplier(this);
1378 aArguments[0]=uno::makeAny(xSelectionSupplier);
1379 uno::Reference<frame::XModel> xModel(m_aModel->getModel());
1380 aArguments[1]=uno::makeAny(xModel);
1381 aArguments[2]=uno::makeAny(m_xChartView);
1382 uno::Reference< accessibility::XAccessible > xParent;
1383 if( m_pChartWindow )
1385 Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow());
1386 if( pParentWin )
1387 xParent.set( pParentWin->GetAccessible());
1389 aArguments[3]=uno::makeAny(xParent);
1390 aArguments[4]=uno::makeAny(m_xViewWindow);
1392 xInit->initialize(aArguments);
1396 ::std::set< ::rtl::OUString > ChartController::impl_getAvailableCommands()
1398 return ::comphelper::MakeSet< ::rtl::OUString >
1399 // commands for container forward
1400 ( C2U("AddDirect")) ( C2U("NewDoc")) ( C2U("Open"))
1401 ( C2U("Save")) ( C2U("SaveAs")) ( C2U("SendMail"))
1402 ( C2U("EditDoc")) ( C2U("ExportDirectToPDF")) ( C2U("PrintDefault"))
1404 // own commands
1405 ( C2U("Cut") ) ( C2U("Copy") ) ( C2U("Paste") )
1406 ( C2U("DataRanges") ) ( C2U("DiagramData") )
1407 // insert objects
1408 ( C2U("InsertTitle") ) ( C2U("InsertLegend") ) ( C2U("InsertDescription") )
1409 ( C2U("InsertAxis") ) ( C2U("InsertGrids") ) ( C2U("InsertStatistics") )
1410 ( C2U("InsertSymbol") ) ( C2U("InsertTrendline") ) ( C2U("InsertTrendlineEquation") )
1411 ( C2U("InsertTrendlines") ) ( C2U("InsertMeanValue") ) ( C2U("InsertMeanValues") )
1412 ( C2U("InsertYErrorbars") ) ( C2U("InsertYErrorbar") )
1413 ( C2U("DeleteTrendline") ) ( C2U("DeleteMeanValue") ) ( C2U("DeleteYErrorbar") )
1414 //format objects
1415 //MENUCHANGE ( C2U("SelectSourceRanges") )
1416 ( C2U("DiagramObjects") ) ( C2U("TransformDialog") )
1417 ( C2U("DiagramType") ) ( C2U("View3D") )
1418 ( C2U("Forward") ) ( C2U("Backward") )
1419 ( C2U("MainTitle") ) ( C2U("SubTitle") )
1420 ( C2U("XTitle") ) ( C2U("YTitle") ) ( C2U("ZTitle") )
1421 ( C2U("SecondaryXTitle") ) ( C2U("SecondaryYTitle") )
1422 ( C2U("AllTitles") ) ( C2U("Legend") )
1423 ( C2U("DiagramAxisX") ) ( C2U("DiagramAxisY") ) ( C2U("DiagramAxisZ") )
1424 ( C2U("DiagramAxisA") ) ( C2U("DiagramAxisB") ) ( C2U("DiagramAxisAll") )
1425 ( C2U("DiagramGridXMain") ) ( C2U("DiagramGridYMain") ) ( C2U("DiagramGridZMain") )
1426 ( C2U("DiagramGridXHelp") ) ( C2U("DiagramGridYHelp") ) ( C2U("DiagramGridZHelp") )
1427 ( C2U("DiagramGridAll") )
1428 ( C2U("DiagramWall") ) ( C2U("DiagramFloor") ) ( C2U("DiagramArea") )
1429 // toolbar commands
1430 ( C2U("ToggleGridHorizontal"))( C2U("ToggleLegend") ) ( C2U("ScaleText") )
1431 ( C2U("NewArrangement") ) ( C2U("Update") )
1432 ( C2U("DefaultColors") ) ( C2U("BarWidth") ) ( C2U("NumberOfLines") )
1433 ( C2U("ArrangeRow") )
1434 ( C2U("StatusBarVisible") )
1438 //.............................................................................
1439 } //namespace chart
1440 //.............................................................................