1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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"
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"
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>
71 // header for define RET_OK
72 #include <vcl/msgbox.hxx>
76 #include <toolkit/awt/vclxwindow.hxx>
77 #include <toolkit/helper/vclunohelper.hxx>
78 #include <vcl/svapp.hxx>
79 #include <vos/mutex.hxx>
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
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 //.............................................................................
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??
119 , m_aModel( NULL
, m_aModelMutex
)
120 , m_pChartWindow( NULL
)
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()
156 void ChartController::RefCountable::release()
163 //-----------------------------------------------------------------
165 ChartController::TheModel::TheModel( const uno::Reference
< frame::XModel
> & xModel
)
167 , m_xCloseable( NULL
)
168 , m_bOwnership( sal_True
)
169 , m_bOwnershipIsWellKnown( sal_False
)
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()
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)" );
247 m_bOwnership
= false;
248 m_bOwnershipIsWellKnown
= sal_True
;
253 else if( m_xModel
.is() )
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
);
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->();
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
)
291 m_pTheModel
->release();
292 m_pTheModel
=pTheModel
;
294 m_pTheModel
->acquire();
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
)
304 m_pTheModel
->release();
307 m_pTheModel
->acquire();
310 ChartController::TheModelRef::~TheModelRef()
312 ::osl::Guard
< ::osl::Mutex
> aGuard( m_rModelMutex
);
314 m_pTheModel
->release();
316 sal_Bool
ChartController::TheModelRef::is() const
318 return (m_pTheModel
!= 0);
322 //-----------------------------------------------------------------
324 //-----------------------------------------------------------------
326 sal_Bool ChartController
327 ::impl_isDisposedOrSuspended() const
329 if( m_aLifeTimeManager
.impl_isDisposed() )
334 OSL_ENSURE( sal_False
, "This Controller is suspended" );
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
356 //-----------------------------------------------------------------
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" );
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
396 uno::Reference
< awt::XWindow
> xContainerWindow
= xFrame
->getContainerWindow();
397 VCLXWindow
* pParentComponent
= VCLXWindow::GetImplementation(xContainerWindow
);
398 pParentComponent
->setVisible(sal_True
);
400 pParent
= VCLUnoHelper::GetWindow( xContainerWindow
);
406 m_pChartWindow
->clear();
407 m_apDropTargetHelper
.reset();
410 awt::Size
aPageSize( ChartModelHelper::getPageSize(m_aModel
->getModel()) );
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();
427 uno::Reference
< beans::XPropertySet
> xPropSet( xFrame
, uno::UNO_QUERY
);
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
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() )
480 if( m_pDrawViewWrapper
)
482 m_pDrawViewWrapper
->UnmarkAll();
483 //m_pDrawViewWrapper->hideMarkHandles(); todo??
484 m_pDrawViewWrapper
->HideSdrPage();
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();
506 if( m_aSelection
.hasSelection() )
507 this->impl_selectObjectAndNotiy();
509 ChartModelHelper::triggerRangeHighlighting( m_aModel
->getModel() );
511 impl_initializeAccessible();
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
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 );
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 );
579 //select chart area per default:
580 select( uno::makeAny( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE
, rtl::OUString() ) ) );
582 uno::Reference
< lang::XMultiServiceFactory
> xFact( m_aModel
->getModel(), uno::UNO_QUERY
);
585 m_xChartView
= xFact
->createInstance( CHART_VIEW_SERVICE_NAME
);
586 GetDrawModelWrapper();
587 uno::Reference
< util::XModeChangeBroadcaster
> xViewBroadcaster( m_xChartView
, uno::UNO_QUERY
);
588 if( xViewBroadcaster
.is() )
589 xViewBroadcaster
->addModeChangeListener(this);
592 //the frameloader is responsible to call xModel->connectController
594 m_pChartWindow
->Invalidate();
596 uno::Reference
< chart2::XUndoSupplier
> xUndoSupplier( m_aModel
->getModel(), uno::UNO_QUERY
);
597 if( xUndoSupplier
.is())
598 m_xUndoManager
.set( xUndoSupplier
->getUndoManager());
603 uno::Reference
< frame::XFrame
> SAL_CALL ChartController
604 ::getFrame() throw(uno::RuntimeException
)
606 //provides access to owner frame of this controller
607 //return the frame containing this controller
612 uno::Reference
< frame::XModel
> SAL_CALL ChartController
613 ::getModel() throw(uno::RuntimeException
)
615 //provides access to currently attached model
616 //returns the currently attached model
618 //return nothing, if you do not have a model
619 TheModelRef
aModelRef( m_aModel
, m_aModelMutex
);
621 return aModelRef
->getModel();
623 return uno::Reference
< frame::XModel
> ();
626 uno::Any SAL_CALL ChartController
627 ::getViewData() throw(uno::RuntimeException
)
629 //provides access to current view status
630 //set of data that can be used to restore the current view status at later time
631 // by using XController::restoreViewData()
633 ::vos::OGuard
aGuard( Application::GetSolarMutex());
634 if( impl_isDisposedOrSuspended() )
635 return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception??
637 //-- collect current view state
639 //// @todo integrate specialized implementation
644 void SAL_CALL ChartController
645 ::restoreViewData( const uno::Any
& /* Value */ )
646 throw(uno::RuntimeException
)
648 //restores the view status using the data gotten from a previous call to XController::getViewData()
650 ::vos::OGuard
aGuard( Application::GetSolarMutex());
651 if( impl_isDisposedOrSuspended() )
652 return; //behave passive if already disposed or suspended //@todo? or throw an exception??
654 //// @todo integrate specialized implementation
657 sal_Bool SAL_CALL ChartController
658 ::suspend( sal_Bool bSuspend
)
659 throw(uno::RuntimeException
)
661 //is called to prepare the controller for closing the view
662 //bSuspend==true: force the controller to suspend his work
663 //bSuspend==false try to reactivate the controller
664 //returns true if request was accepted and of course successfully finished, false otherwise
666 //we may show dialogs here to ask the user for saving changes ... @todo?
668 ::vos::OGuard
aGuard( Application::GetSolarMutex());
669 if( m_aLifeTimeManager
.impl_isDisposed() )
670 return sal_False
; //behave passive if already disposed, return false because request was not accepted //@todo? correct
672 if(bSuspend
==m_bSuspended
)
674 OSL_ENSURE( sal_False
, "new suspend mode equals old suspend mode" );
678 //change suspend mode
682 //@todo ??? try to stop all what may prevent me from becoming disposed
685 m_bSuspended
= bSuspend
;
691 //@todo ??? redo what was made in section bSuspend==true
694 m_bSuspended
= bSuspend
;
701 getFrame()->removeFrameActionListener( pImp );
703 getFrame()->addFrameActionListener( pImp );
708 void ChartController::impl_createDrawViewController()
710 ::vos::OGuard
aGuard( Application::GetSolarMutex());
711 if(!m_pDrawViewWrapper
)
713 if( m_pDrawModelWrapper
)
715 m_pDrawViewWrapper
= new DrawViewWrapper(&m_pDrawModelWrapper
->getSdrModel(),m_pChartWindow
,true);
716 m_pDrawViewWrapper
->attachParentReferenceDevice( m_aModel
->getModel());
720 void ChartController::impl_deleteDrawViewController()
722 if( m_pDrawViewWrapper
)
724 ::vos::OGuard
aGuard( Application::GetSolarMutex());
725 if( m_pDrawViewWrapper
->IsTextEdit() )
727 DELETEZ( m_pDrawViewWrapper
);
731 //-----------------------------------------------------------------
732 // XComponent (base of XController)
733 //-----------------------------------------------------------------
735 void SAL_CALL ChartController
736 ::dispose() throw(uno::RuntimeException
)
740 //This object should release all resources and references in the
741 //easiest possible manner
742 //This object must notify all registered listeners using the method
743 //<member>XEventListener::disposing</member>
746 if( !m_aLifeTimeManager
.dispose() )
749 // OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" );
751 this->stopDoubleClickWaiting();
753 //end range highlighting
756 uno::Reference
< view::XSelectionChangeListener
> xSelectionChangeListener
;
757 uno::Reference
< chart2::data::XDataReceiver
> xDataReceiver( m_aModel
->getModel(), uno::UNO_QUERY
);
758 if( xDataReceiver
.is() )
759 xSelectionChangeListener
= uno::Reference
< view::XSelectionChangeListener
>( xDataReceiver
->getRangeHighlighter(), uno::UNO_QUERY
);
760 if( xSelectionChangeListener
.is() )
762 uno::Reference
< frame::XController
> xController( this );
763 uno::Reference
< lang::XComponent
> xComp( xController
, uno::UNO_QUERY
);
764 //lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) );
765 lang::EventObject
aEvent( xComp
);
766 xSelectionChangeListener
->disposing( aEvent
);
770 //--release all resources and references
772 uno::Reference
< util::XModeChangeBroadcaster
> xViewBroadcaster( m_xChartView
, uno::UNO_QUERY
);
773 if( xViewBroadcaster
.is() )
774 xViewBroadcaster
->removeModeChangeListener(this);
776 impl_invalidateAccessible();
777 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex());
778 impl_deleteDrawViewController();
779 m_pDrawModelWrapper
.reset();
781 m_apDropTargetHelper
.reset();
783 //the accessible view is disposed within window destructor of m_pChartWindow
784 m_pChartWindow
->clear();
785 m_pChartWindow
= NULL
;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also))
786 m_xViewWindow
->dispose();
787 m_xChartView
.clear();
791 // remove as listener to layout manager events
792 if( m_xLayoutManagerEventBroadcaster
.is())
794 m_xLayoutManagerEventBroadcaster
->removeLayoutManagerEventListener( this );
795 m_xLayoutManagerEventBroadcaster
.set( 0 );
799 m_xUndoManager
.clear();
801 TheModelRef
aModelRef( m_aModel
, m_aModelMutex
);
806 uno::Reference
< frame::XModel
> xModel( aModelRef
->getModel() );
808 xModel
->disconnectController( uno::Reference
< frame::XController
>( this ));
810 aModelRef
->removeListener( this );
811 #ifdef TEST_ENABLE_MODIFY_LISTENER
814 uno::Reference
< util::XModifyBroadcaster
> xMBroadcaster( aModelRef
->getModel(),uno::UNO_QUERY
);
815 if( xMBroadcaster
.is())
816 xMBroadcaster
->removeModifyListener( this );
818 catch( const uno::Exception
& ex
)
820 ASSERT_EXCEPTION( ex
);
823 aModelRef
->tryTermination();
826 //// @todo integrate specialized implementation
827 //e.g. release further resources and references
829 m_aDispatchContainer
.DisposeAndClear();
831 catch( const uno::Exception
& ex
)
833 ASSERT_EXCEPTION( ex
);
837 void SAL_CALL ChartController
838 ::addEventListener( const uno::Reference
<lang::XEventListener
>& xListener
)
839 throw(uno::RuntimeException
)
841 ::vos::OGuard
aGuard( Application::GetSolarMutex());
842 if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
843 return; //behave passive if already disposed or suspended
846 m_aLifeTimeManager
.m_aListenerContainer
.addInterface( ::getCppuType((const uno::Reference
< lang::XEventListener
>*)0), xListener
);
849 void SAL_CALL ChartController
850 ::removeEventListener( const uno::Reference
<
851 lang::XEventListener
>& xListener
)
852 throw(uno::RuntimeException
)
854 ::vos::OGuard
aGuard( Application::GetSolarMutex());
855 if( m_aLifeTimeManager
.impl_isDisposed() )
856 return; //behave passive if already disposed or suspended
859 m_aLifeTimeManager
.m_aListenerContainer
.removeInterface( ::getCppuType((const uno::Reference
< lang::XEventListener
>*)0), xListener
);
863 //-----------------------------------------------------------------
864 // util::XCloseListener
865 //-----------------------------------------------------------------
866 void SAL_CALL ChartController
867 ::queryClosing( const lang::EventObject
& rSource
, sal_Bool bGetsOwnership
)
868 throw(util::CloseVetoException
, uno::RuntimeException
)
870 //do not use the m_aControllerMutex here because this call is not allowed to block
872 TheModelRef
aModelRef( m_aModel
, m_aModelMutex
);
874 if( !aModelRef
.is() )
877 if( !(aModelRef
->getModel() == rSource
.Source
) )
879 OSL_ENSURE( sal_False
, "queryClosing was called on a controller from an unknown source" );
883 if( !m_bCanClose
)//@todo tryaqcuire mutex
887 aModelRef
->SetOwnerShip( bGetsOwnership
);
890 throw util::CloseVetoException();
894 //@ todo prepare to to closing model -> don't start any further hindering actions
898 void SAL_CALL ChartController
899 ::notifyClosing( const lang::EventObject
& rSource
)
900 throw(uno::RuntimeException
)
902 //Listener should deregister himself and relaese all references to the closing object.
904 TheModelRef
aModelRef( m_aModel
, m_aModelMutex
);
905 if( impl_releaseThisModel( rSource
.Source
) )
907 //--stop listening to the closing model
908 aModelRef
->removeListener( this );
910 // #i79087# If the model using this controller is closed, the frame is
911 // expected to be closed as well
912 Reference
< util::XCloseable
> xFrameCloseable( m_xFrame
, uno::UNO_QUERY
);
913 if( xFrameCloseable
.is())
917 xFrameCloseable
->close( sal_False
/* DeliverOwnership */ );
920 catch( util::CloseVetoException
& )
922 // closing was vetoed
928 bool ChartController::impl_releaseThisModel( const uno::Reference
< uno::XInterface
> & xModel
)
930 bool bReleaseModel
= sal_False
;
932 ::osl::Guard
< ::osl::Mutex
> aGuard( m_aModelMutex
);
933 if( m_aModel
.is() && m_aModel
->getModel() == xModel
)
936 m_xUndoManager
.clear();
937 bReleaseModel
= true;
940 return bReleaseModel
;
943 //-----------------------------------------------------------------
944 // util::XEventListener (base of XCloseListener)
945 //-----------------------------------------------------------------
946 void SAL_CALL ChartController
947 ::disposing( const lang::EventObject
& rSource
)
948 throw(uno::RuntimeException
)
950 if( !impl_releaseThisModel( rSource
.Source
))
952 if( rSource
.Source
== m_xLayoutManagerEventBroadcaster
)
953 m_xLayoutManagerEventBroadcaster
.set( 0 );
957 void SAL_CALL
ChartController::layoutEvent( const lang::EventObject
& aSource
, ::sal_Int16 eLayoutEvent
, const uno::Any
& /* aInfo */ )
958 throw (uno::RuntimeException
)
960 if( eLayoutEvent
== frame::LayoutManagerEvents::MERGEDMENUBAR
)
962 Reference
< frame::XLayoutManager
> xLM( aSource
.Source
, uno::UNO_QUERY
);
965 xLM
->createElement( C2U("private:resource/statusbar/statusbar"));
966 xLM
->requestElement( C2U("private:resource/statusbar/statusbar"));
972 //-----------------------------------------------------------------
973 // XDispatchProvider (required interface)
974 //-----------------------------------------------------------------
978 bool lcl_isFormatObjectCommand( const rtl::OString
& aCommand
)
980 if( aCommand
.equals("MainTitle")
981 || aCommand
.equals("SubTitle")
982 || aCommand
.equals("XTitle")
983 || aCommand
.equals("YTitle")
984 || aCommand
.equals("ZTitle")
985 || aCommand
.equals("SecondaryXTitle")
986 || aCommand
.equals("SecondaryYTitle")
987 || aCommand
.equals("AllTitles")
988 || aCommand
.equals("DiagramAxisX")
989 || aCommand
.equals("DiagramAxisY")
990 || aCommand
.equals("DiagramAxisZ")
991 || aCommand
.equals("DiagramAxisA")
992 || aCommand
.equals("DiagramAxisB")
993 || aCommand
.equals("DiagramAxisAll")
994 || aCommand
.equals("DiagramGridXMain")
995 || aCommand
.equals("DiagramGridYMain")
996 || aCommand
.equals("DiagramGridZMain")
997 || aCommand
.equals("DiagramGridXHelp")
998 || aCommand
.equals("DiagramGridYHelp")
999 || aCommand
.equals("DiagramGridZHelp")
1000 || aCommand
.equals("DiagramGridAll")
1002 || aCommand
.equals("DiagramWall")
1003 || aCommand
.equals("DiagramFloor")
1004 || aCommand
.equals("DiagramArea")
1005 || aCommand
.equals("Legend")
1007 || aCommand
.equals("FormatWall")
1008 || aCommand
.equals("FormatFloor")
1009 || aCommand
.equals("FormatChartArea")
1010 || aCommand
.equals("FormatLegend")
1012 || aCommand
.equals("FormatTitle")
1013 || aCommand
.equals("FormatAxis")
1014 || aCommand
.equals("FormatDataSeries")
1015 || aCommand
.equals("FormatDataPoint")
1016 || aCommand
.equals("FormatDataLabels")
1017 || aCommand
.equals("FormatDataLabel")
1018 || aCommand
.equals("FormatYErrorBars")
1019 || aCommand
.equals("FormatMeanValue")
1020 || aCommand
.equals("FormatTrendline")
1021 || aCommand
.equals("FormatTrendlineEquation")
1022 || aCommand
.equals("FormatStockLoss")
1023 || aCommand
.equals("FormatStockGain")
1024 || aCommand
.equals("FormatMajorGrid")
1025 || aCommand
.equals("FormatMinorGrid")
1032 } // anonymous namespace
1034 uno::Reference
<frame::XDispatch
> SAL_CALL ChartController
1035 ::queryDispatch( const util::URL
& rURL
1036 , const rtl::OUString
& rTargetFrameName
1037 , sal_Int32
/* nSearchFlags */)
1038 throw(uno::RuntimeException
)
1040 if ( !m_aLifeTimeManager
.impl_isDisposed() )
1042 if( rTargetFrameName
.getLength() &&
1043 rTargetFrameName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_self")))
1044 return m_aDispatchContainer
.getDispatchForURL( rURL
);
1046 return uno::Reference
< frame::XDispatch
> ();
1049 uno::Sequence
<uno::Reference
<frame::XDispatch
> > ChartController
1050 ::queryDispatches( const uno::Sequence
<
1051 frame::DispatchDescriptor
>& xDescripts
)
1052 throw(uno::RuntimeException
)
1054 if ( !m_aLifeTimeManager
.impl_isDisposed() )
1056 return m_aDispatchContainer
.getDispatchesForURLs( xDescripts
);
1058 return uno::Sequence
<uno::Reference
<frame::XDispatch
> > ();
1061 //-----------------------------------------------------------------
1063 //-----------------------------------------------------------------
1065 void SAL_CALL ChartController
1066 ::dispatch( const util::URL
& rURL
1067 , const uno::Sequence
< beans::PropertyValue
>& /* rArgs */ )
1068 throw (uno::RuntimeException
)
1070 //@todo avoid OString (see Mathias mail on bug #104387#)
1071 rtl::OString
aCommand( rtl::OUStringToOString( rURL
.Path
, RTL_TEXTENCODING_ASCII_US
) );
1073 if(aCommand
.equals("Paste"))
1074 this->executeDispatch_Paste();
1075 else if(aCommand
.equals("Copy"))
1076 this->executeDispatch_Copy();
1077 else if(aCommand
.equals("Cut"))
1078 this->executeDispatch_Cut();
1079 else if(aCommand
.equals("DataRanges"))
1080 this->executeDispatch_SourceData();
1081 //----------------------------------
1082 else if(aCommand
.equals("Update")) //Update Chart
1084 ChartViewHelper::setViewToDirtyState( m_aModel
->getModel() );
1085 if( m_pChartWindow
)
1086 m_pChartWindow
->Invalidate();
1088 else if(aCommand
.equals("DiagramData"))
1089 this->executeDispatch_EditData();
1091 else if( aCommand
.equals("InsertTitles")
1092 || aCommand
.equals("InsertMenuTitles") )
1093 this->executeDispatch_InsertTitles();
1094 else if( aCommand
.equals("InsertMenuLegend") )
1095 this->executeDispatch_OpenLegendDialog();
1096 else if( aCommand
.equals("InsertLegend") )
1097 this->executeDispatch_InsertLegend();
1098 else if( aCommand
.equals("DeleteLegend") )
1099 this->executeDispatch_DeleteLegend();
1100 else if( aCommand
.equals("InsertMenuDataLabels"))
1101 this->executeDispatch_InsertMenu_DataLabels();
1102 else if( aCommand
.equals("InsertMenuAxes")
1103 || aCommand
.equals("InsertRemoveAxes") )
1104 this->executeDispatch_InsertAxes();
1105 else if( aCommand
.equals("InsertMenuGrids"))
1106 this->executeDispatch_InsertGrid();
1107 else if( aCommand
.equals("InsertMenuTrendlines"))
1108 this->executeDispatch_InsertMenu_Trendlines();
1109 else if( aCommand
.equals("InsertMenuMeanValues"))
1110 this->executeDispatch_InsertMenu_MeanValues();
1111 else if( aCommand
.equals("InsertMenuYErrorBars"))
1112 this->executeDispatch_InsertMenu_YErrorBars();
1113 else if( aCommand
.equals("InsertSymbol"))
1114 this->executeDispatch_InsertSpecialCharacter();
1115 else if( aCommand
.equals("InsertTrendline"))
1116 this->executeDispatch_InsertTrendline();
1117 else if( aCommand
.equals("DeleteTrendline"))
1118 this->executeDispatch_DeleteTrendline();
1119 else if( aCommand
.equals("InsertMeanValue"))
1120 this->executeDispatch_InsertMeanValue();
1121 else if( aCommand
.equals("DeleteMeanValue"))
1122 this->executeDispatch_DeleteMeanValue();
1123 else if( aCommand
.equals("InsertYErrorBars"))
1124 this->executeDispatch_InsertYErrorBars();
1125 else if( aCommand
.equals("DeleteYErrorBars"))
1126 this->executeDispatch_DeleteYErrorBars();
1127 else if( aCommand
.equals("InsertTrendlineEquation"))
1128 this->executeDispatch_InsertTrendlineEquation();
1129 else if( aCommand
.equals("DeleteTrendlineEquation"))
1130 this->executeDispatch_DeleteTrendlineEquation();
1131 else if( aCommand
.equals("InsertTrendlineEquationAndR2"))
1132 this->executeDispatch_InsertTrendlineEquation( true );
1133 else if( aCommand
.equals("InsertR2Value"))
1134 this->executeDispatch_InsertR2Value();
1135 else if( aCommand
.equals("DeleteR2Value"))
1136 this->executeDispatch_DeleteR2Value();
1137 else if( aCommand
.equals("InsertDataLabels") )
1138 this->executeDispatch_InsertDataLabels();
1139 else if( aCommand
.equals("InsertDataLabel") )
1140 this->executeDispatch_InsertDataLabel();
1141 else if( aCommand
.equals("DeleteDataLabels") )
1142 this->executeDispatch_DeleteDataLabels();
1143 else if( aCommand
.equals("DeleteDataLabel") )
1144 this->executeDispatch_DeleteDataLabel();
1145 else if( aCommand
.equals("ResetAllDataPoints") )
1146 this->executeDispatch_ResetAllDataPoints();
1147 else if( aCommand
.equals("ResetDataPoint") )
1148 this->executeDispatch_ResetDataPoint();
1149 else if( aCommand
.equals("InsertAxis") )
1150 this->executeDispatch_InsertAxis();
1151 else if( aCommand
.equals("InsertMajorGrid") )
1152 this->executeDispatch_InsertMajorGrid();
1153 else if( aCommand
.equals("InsertMinorGrid") )
1154 this->executeDispatch_InsertMinorGrid();
1155 else if( aCommand
.equals("InsertAxisTitle") )
1156 this->executeDispatch_InsertAxisTitle();
1157 else if( aCommand
.equals("DeleteAxis") )
1158 this->executeDispatch_DeleteAxis();
1159 else if( aCommand
.equals("DeleteMajorGrid") )
1160 this->executeDispatch_DeleteMajorGrid();
1161 else if( aCommand
.equals("DeleteMinorGrid") )
1162 this->executeDispatch_DeleteMinorGrid();
1164 else if( aCommand
.equals("FormatSelection") )
1165 this->executeDispatch_ObjectProperties();
1166 else if( aCommand
.equals("TransformDialog"))
1167 this->executeDispatch_PositionAndSize();
1168 else if( lcl_isFormatObjectCommand(aCommand
) )
1169 this->executeDispatch_FormatObject(rURL
.Path
);
1171 //MENUCHANGE else if(aCommand.equals("SelectSourceRanges"))
1172 //MENUCHANGE this->executeDispatch_SourceData();
1173 else if( aCommand
.equals("DiagramType"))
1174 this->executeDispatch_ChartType();
1175 else if( aCommand
.equals("View3D"))
1176 this->executeDispatch_View3D();
1177 else if( aCommand
.equals("Forward"))
1178 this->executeDispatch_MoveSeries( sal_True
);
1179 else if( aCommand
.equals("Backward"))
1180 this->executeDispatch_MoveSeries( sal_False
);
1181 else if( aCommand
.equals("NewArrangement"))
1182 this->executeDispatch_NewArrangement();
1183 else if( aCommand
.equals("ToggleLegend"))
1184 this->executeDispatch_ToggleLegend();
1185 else if( aCommand
.equals("ToggleGridHorizontal"))
1186 this->executeDispatch_ToggleGridHorizontal();
1187 else if( aCommand
.equals("ScaleText"))
1188 this->executeDispatch_ScaleText();
1189 else if( aCommand
.equals("StatusBarVisible"))
1191 // workaround: this should not be necessary.
1192 uno::Reference
< beans::XPropertySet
> xPropSet( m_xFrame
, uno::UNO_QUERY
);
1195 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1196 xPropSet
->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager
;
1197 if ( xLayoutManager
.is() )
1199 bool bIsVisible( xLayoutManager
->isElementVisible( C2U("private:resource/statusbar/statusbar")));
1202 xLayoutManager
->hideElement( C2U( "private:resource/statusbar/statusbar"));
1203 xLayoutManager
->destroyElement( C2U( "private:resource/statusbar/statusbar"));
1207 xLayoutManager
->createElement( C2U( "private:resource/statusbar/statusbar"));
1208 xLayoutManager
->showElement( C2U( "private:resource/statusbar/statusbar"));
1210 // @todo: update menu state (checkmark next to "Statusbar").
1217 this->executeDispatch_EditText();
1221 void SAL_CALL ChartController
1222 ::addStatusListener( const uno::Reference
<frame::XStatusListener
>& /* xControl */
1223 , const util::URL
& /* aURL */ )
1224 throw (uno::RuntimeException
)
1226 // // TODO: add listener by URL !
1227 // ::vos::OGuard aGuard( Application::GetSolarMutex());
1228 // if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
1229 // return; //behave passive if already disposed or suspended
1232 // m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType( & xControl ), xControl );
1235 void SAL_CALL ChartController
1236 ::removeStatusListener( const uno::Reference
<frame::XStatusListener
>& /* xControl */
1237 , const util::URL
& /* aURL */ )
1238 throw (uno::RuntimeException
)
1240 // // TODO: remove listener by URL !
1241 // ::vos::OGuard aGuard( Application::GetSolarMutex());
1242 // if( m_aLifeTimeManager.impl_isDisposed() )
1243 // return; //behave passive if already disposed or suspended
1245 // //--remove listener
1246 // m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType( & xControl ), xControl );
1249 //-----------------------------------------------------------------
1250 // XContextMenuInterception (optional interface)
1251 //-----------------------------------------------------------------
1252 void SAL_CALL ChartController
1253 ::registerContextMenuInterceptor( const uno::Reference
<
1254 ui::XContextMenuInterceptor
> & /* xInterceptor */)
1255 throw(uno::RuntimeException
)
1260 void SAL_CALL ChartController
1261 ::releaseContextMenuInterceptor( const uno::Reference
<
1262 ui::XContextMenuInterceptor
> & /* xInterceptor */)
1263 throw(uno::RuntimeException
)
1268 // ____ XEmbeddedClient ____
1269 // implementation see: ChartController_EditData.cxx
1271 //-----------------------------------------------------------------------------
1272 //-----------------------------------------------------------------------------
1273 //-----------------------------------------------------------------------------
1275 void SAL_CALL
ChartController::executeDispatch_ChartType()
1277 // using assignment for broken gcc 3.3
1278 UndoLiveUpdateGuard aUndoGuard
= UndoLiveUpdateGuard(
1279 ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE
))), m_xUndoManager
, m_aModel
->getModel() );
1282 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex());
1283 //prepare and open dialog
1284 ChartTypeDialog
aDlg( m_pChartWindow
, m_aModel
->getModel(), m_xCC
);
1285 if( aDlg
.Execute() == RET_OK
)
1287 impl_adaptDataSeriesAutoResize();
1288 aUndoGuard
.commitAction();
1293 void SAL_CALL
ChartController::executeDispatch_SourceData()
1295 //-------------------------------------------------------------
1296 //convert properties to ItemSet
1297 uno::Reference
< XChartDocument
> xChartDoc( m_aModel
->getModel(), uno::UNO_QUERY
);
1298 DBG_ASSERT( xChartDoc
.is(), "Invalid XChartDocument" );
1299 if( !xChartDoc
.is())
1302 // using assignment for broken gcc 3.3
1303 UndoLiveUpdateGuard aUndoGuard
= UndoLiveUpdateGuard(
1304 ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES
))), m_xUndoManager
, m_aModel
->getModel() );
1308 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex());
1309 ::chart::DataSourceDialog
aDlg( m_pChartWindow
, xChartDoc
, m_xCC
);
1310 if( aDlg
.Execute() == RET_OK
)
1312 impl_adaptDataSeriesAutoResize();
1313 aUndoGuard
.commitAction();
1319 void SAL_CALL
ChartController::executeDispatch_MoveSeries( sal_Bool bForward
)
1321 ControllerLockGuard
aCLGuard( m_aModel
->getModel());
1323 //get selected series
1324 ::rtl::OUString
aObjectCID(m_aSelection
.getSelectedCID());
1325 uno::Reference
< XDataSeries
> xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels?
1326 aObjectCID
, m_aModel
->getModel() ) );
1328 UndoGuardWithSelection
aUndoGuard(
1329 ActionDescriptionProvider::createDescription(
1330 (bForward
? ActionDescriptionProvider::MOVE_TOTOP
: ActionDescriptionProvider::MOVE_TOBOTTOM
),
1331 ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES
)))),
1332 m_xUndoManager
, m_aModel
->getModel());
1334 bool bChanged
= DiagramHelper::moveSeries( ChartModelHelper::findDiagram( m_aModel
->getModel() ), xGivenDataSeries
, bForward
);
1337 m_aSelection
.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID
, bForward
) );
1338 aUndoGuard
.commitAction();
1342 // ____ XMultiServiceFactory ____
1343 uno::Reference
< uno::XInterface
> SAL_CALL
1344 ChartController::createInstance( const ::rtl::OUString
& aServiceSpecifier
)
1345 throw (uno::Exception
,
1346 uno::RuntimeException
)
1348 uno::Reference
< uno::XInterface
> xResult
;
1350 if( aServiceSpecifier
.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME
))
1351 xResult
.set( impl_createAccessibleTextContext());
1355 uno::Reference
< uno::XInterface
> SAL_CALL
1356 ChartController::createInstanceWithArguments( const ::rtl::OUString
& ServiceSpecifier
,
1357 const uno::Sequence
< uno::Any
>& /* Arguments */ )
1358 throw (uno::Exception
,
1359 uno::RuntimeException
)
1362 return createInstance( ServiceSpecifier
);
1365 uno::Sequence
< ::rtl::OUString
> SAL_CALL
1366 ChartController::getAvailableServiceNames()
1367 throw (uno::RuntimeException
)
1369 static uno::Sequence
< ::rtl::OUString
> aServiceNames
;
1371 if( aServiceNames
.getLength() == 0 )
1373 aServiceNames
.realloc(1);
1374 aServiceNames
[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME
;
1377 return aServiceNames
;
1380 // ____ XModifyListener ____
1381 void SAL_CALL
ChartController::modified( const lang::EventObject
& /* aEvent */ )
1382 throw (uno::RuntimeException
)
1384 // the source can also be a subobject of the ChartModel
1385 // @todo: change the source in ChartModel to always be the model itself ?
1386 // if( m_aModel->getModel() == aEvent.Source )
1389 //todo? update menu states ?
1392 //-----------------------------------------------------------------------------
1393 //-----------------------------------------------------------------------------
1394 //-----------------------------------------------------------------------------
1396 DrawModelWrapper
* ChartController::GetDrawModelWrapper()
1398 if( !m_pDrawModelWrapper
.get() )
1400 ExplicitValueProvider
* pProvider
= ExplicitValueProvider::getExplicitValueProvider( m_xChartView
);
1402 m_pDrawModelWrapper
= pProvider
->getDrawModelWrapper();
1404 return m_pDrawModelWrapper
.get();
1407 uno::Reference
< accessibility::XAccessible
> ChartController::CreateAccessible()
1409 uno::Reference
< accessibility::XAccessible
> xResult(
1410 m_xCC
->getServiceManager()->createInstanceWithContext(
1411 CHART2_ACCESSIBLE_SERVICE_NAME
, m_xCC
), uno::UNO_QUERY
);
1413 impl_initializeAccessible( uno::Reference
< lang::XInitialization
>( xResult
, uno::UNO_QUERY
) );
1417 void ChartController::impl_invalidateAccessible()
1419 if( m_pChartWindow
)
1421 Reference
< lang::XInitialization
> xInit( m_pChartWindow
->GetAccessible(false), uno::UNO_QUERY
);
1424 uno::Sequence
< uno::Any
> aArguments(3);//empty arguments -> invalid accessible
1425 xInit
->initialize(aArguments
);
1429 void ChartController::impl_initializeAccessible()
1431 if( m_pChartWindow
)
1432 this->impl_initializeAccessible( Reference
< lang::XInitialization
>( m_pChartWindow
->GetAccessible(false), uno::UNO_QUERY
) );
1434 void ChartController::impl_initializeAccessible( const uno::Reference
< lang::XInitialization
>& xInit
)
1438 uno::Sequence
< uno::Any
> aArguments(5);
1439 uno::Reference
<view::XSelectionSupplier
> xSelectionSupplier(this);
1440 aArguments
[0]=uno::makeAny(xSelectionSupplier
);
1441 uno::Reference
<frame::XModel
> xModel(m_aModel
->getModel());
1442 aArguments
[1]=uno::makeAny(xModel
);
1443 aArguments
[2]=uno::makeAny(m_xChartView
);
1444 uno::Reference
< accessibility::XAccessible
> xParent
;
1445 if( m_pChartWindow
)
1447 Window
* pParentWin( m_pChartWindow
->GetAccessibleParentWindow());
1449 xParent
.set( pParentWin
->GetAccessible());
1451 aArguments
[3]=uno::makeAny(xParent
);
1452 aArguments
[4]=uno::makeAny(m_xViewWindow
);
1454 xInit
->initialize(aArguments
);
1458 ::std::set
< ::rtl::OUString
> ChartController::impl_getAvailableCommands()
1460 return ::comphelper::MakeSet
< ::rtl::OUString
>
1461 // commands for container forward
1462 ( C2U("AddDirect")) ( C2U("NewDoc")) ( C2U("Open"))
1463 ( C2U("Save")) ( C2U("SaveAs")) ( C2U("SendMail"))
1464 ( C2U("EditDoc")) ( C2U("ExportDirectToPDF")) ( C2U("PrintDefault"))
1467 ( C2U("Cut") ) ( C2U("Copy") ) ( C2U("Paste") )
1468 ( C2U("DataRanges") ) ( C2U("DiagramData") )
1470 ( C2U("InsertMenuTitles") ) ( C2U("InsertTitles") )
1471 ( C2U("InsertMenuLegend") ) ( C2U("InsertLegend") ) ( C2U("DeleteLegend") )
1472 ( C2U("InsertMenuDataLabels") )
1473 ( C2U("InsertMenuAxes") ) ( C2U("InsertRemoveAxes") ) ( C2U("InsertMenuGrids") )
1474 ( C2U("InsertSymbol") )
1475 ( C2U("InsertTrendlineEquation") ) ( C2U("InsertTrendlineEquationAndR2") )
1476 ( C2U("InsertR2Value") ) ( C2U("DeleteR2Value") )
1477 ( C2U("InsertMenuTrendlines") ) ( C2U("InsertTrendline") )
1478 ( C2U("InsertMenuMeanValues") ) ( C2U("InsertMeanValue") )
1479 ( C2U("InsertMenuYErrorBars") ) ( C2U("InsertYErrorBars") )
1480 ( C2U("InsertDataLabels") ) ( C2U("InsertDataLabel") )
1481 ( C2U("DeleteTrendline") ) ( C2U("DeleteMeanValue") ) ( C2U("DeleteTrendlineEquation") )
1482 ( C2U("DeleteYErrorBars") )
1483 ( C2U("DeleteDataLabels") ) ( C2U("DeleteDataLabel") )
1485 //MENUCHANGE ( C2U("SelectSourceRanges") )
1486 ( C2U("FormatSelection") ) ( C2U("TransformDialog") )
1487 ( C2U("DiagramType") ) ( C2U("View3D") )
1488 ( C2U("Forward") ) ( C2U("Backward") )
1489 ( C2U("MainTitle") ) ( C2U("SubTitle") )
1490 ( C2U("XTitle") ) ( C2U("YTitle") ) ( C2U("ZTitle") )
1491 ( C2U("SecondaryXTitle") ) ( C2U("SecondaryYTitle") )
1492 ( C2U("AllTitles") ) ( C2U("Legend") )
1493 ( C2U("DiagramAxisX") ) ( C2U("DiagramAxisY") ) ( C2U("DiagramAxisZ") )
1494 ( C2U("DiagramAxisA") ) ( C2U("DiagramAxisB") ) ( C2U("DiagramAxisAll") )
1495 ( C2U("DiagramGridXMain") ) ( C2U("DiagramGridYMain") ) ( C2U("DiagramGridZMain") )
1496 ( C2U("DiagramGridXHelp") ) ( C2U("DiagramGridYHelp") ) ( C2U("DiagramGridZHelp") )
1497 ( C2U("DiagramGridAll") )
1498 ( C2U("DiagramWall") ) ( C2U("DiagramFloor") ) ( C2U("DiagramArea") )
1500 //context menu - format objects entries
1501 ( C2U("FormatWall") ) ( C2U("FormatFloor") ) ( C2U("FormatChartArea") )
1502 ( C2U("FormatLegend") )
1504 ( C2U("FormatAxis") ) ( C2U("FormatTitle") )
1505 ( C2U("FormatDataSeries") ) ( C2U("FormatDataPoint") )
1506 ( C2U("ResetAllDataPoints") ) ( C2U("ResetDataPoint") )
1507 ( C2U("FormatDataLabels") ) ( C2U("FormatDataLabel") )
1508 ( C2U("FormatMeanValue") ) ( C2U("FormatTrendline") ) ( C2U("FormatTrendlineEquation") )
1509 ( C2U("FormatYErrorBars") )
1510 ( C2U("FormatStockLoss") ) ( C2U("FormatStockGain") )
1512 ( C2U("FormatMajorGrid") ) ( C2U("InsertMajorGrid") ) ( C2U("DeleteMajorGrid") )
1513 ( C2U("FormatMinorGrid") ) ( C2U("InsertMinorGrid") ) ( C2U("DeleteMinorGrid") )
1514 ( C2U("InsertAxis") ) ( C2U("DeleteAxis") ) ( C2U("InsertAxisTitle") )
1517 ( C2U("ToggleGridHorizontal"))( C2U("ToggleLegend") ) ( C2U("ScaleText") )
1518 ( C2U("NewArrangement") ) ( C2U("Update") )
1519 ( C2U("DefaultColors") ) ( C2U("BarWidth") ) ( C2U("NumberOfLines") )
1520 ( C2U("ArrangeRow") )
1521 ( C2U("StatusBarVisible") )
1522 ( C2U("ChartElementSelector") )
1526 //.............................................................................
1528 //.............................................................................